17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 525cf1a30Sjl * Common Development and Distribution License (the "License"). 625cf1a30Sjl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22df3cd224SVijay S Balakrishna * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 263fe80ca4SDan Cross /* 273fe80ca4SDan Cross * Copyright 2023 Oxide Computer Company 283fe80ca4SDan Cross */ 293fe80ca4SDan Cross 307c478bd9Sstevel@tonic-gate #ifndef _SYS_DR_H 317c478bd9Sstevel@tonic-gate #define _SYS_DR_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #include <sys/processor.h> 397c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h> 407c478bd9Sstevel@tonic-gate #include <sys/memlist.h> 417c478bd9Sstevel@tonic-gate #include <sys/sbd_ioctl.h> 427c478bd9Sstevel@tonic-gate #include <sys/mem_config.h> 437c478bd9Sstevel@tonic-gate #include <sys/dr_util.h> 447c478bd9Sstevel@tonic-gate #include <sys/drmach.h> 457c478bd9Sstevel@tonic-gate #include <sys/param.h> /* for MAXPATHLEN */ 467c478bd9Sstevel@tonic-gate #include <sys/varargs.h> 477c478bd9Sstevel@tonic-gate #include <sys/note.h> 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define DR_MAXNUM_NT 3 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* used to map sbd_comp_type_t to array index */ 5225cf1a30Sjl #define NIX(t) \ 5325cf1a30Sjl (((t) == SBD_COMP_CPU) ? 0 : \ 5425cf1a30Sjl ((t) == SBD_COMP_MEM) ? 1 : \ 5525cf1a30Sjl ((t) == SBD_COMP_IO) ? 2 : \ 567c478bd9Sstevel@tonic-gate ((t) == SBD_COMP_CMP) ? 0 : DR_MAXNUM_NT) 577c478bd9Sstevel@tonic-gate 5825cf1a30Sjl #define BIX(t) \ 5925cf1a30Sjl (((t) == SBD_COMP_CPU) ? 0 : \ 6025cf1a30Sjl ((t) == SBD_COMP_MEM) ? 32 : \ 6125cf1a30Sjl ((t) == SBD_COMP_IO) ? 40 : \ 6225cf1a30Sjl ((t) == SBD_COMP_CMP) ? 0 : 0) 6325cf1a30Sjl 6425cf1a30Sjl #define NMASK(t) \ 6525cf1a30Sjl (((t) == SBD_COMP_CPU) ? ((dr_devset_t)0xffffffff) : \ 6625cf1a30Sjl ((t) == SBD_COMP_MEM) ? ((dr_devset_t)0x1) : \ 6725cf1a30Sjl ((t) == SBD_COMP_IO) ? ((dr_devset_t)0x1ff) : \ 6825cf1a30Sjl ((t) == SBD_COMP_CMP) ? ((dr_devset_t)0xffffffff) : 0) 6925cf1a30Sjl 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * helper macros for constructing and reporting internal error messages. 727c478bd9Sstevel@tonic-gate * NOTE: each module which uses one or more this these macros is expected 737c478bd9Sstevel@tonic-gate * to supply a char *dr_ie_fmt string containing the SCCS filename 747c478bd9Sstevel@tonic-gate * expansion macro (percent M percent) and a sprintf %d to render the 757c478bd9Sstevel@tonic-gate * line number argument. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #define DR_INTERNAL_ERROR(hp) \ 787c478bd9Sstevel@tonic-gate drerr_new(1, ESBD_INTERNAL, dr_ie_fmt, __LINE__) 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define DR_OP_INTERNAL_ERROR(hp) \ 817c478bd9Sstevel@tonic-gate drerr_set_c(CE_WARN, &(hp)->h_err, \ 827c478bd9Sstevel@tonic-gate ESBD_INTERNAL, dr_ie_fmt, __LINE__) 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate #define DR_DEV_INTERNAL_ERROR(cp) \ 857c478bd9Sstevel@tonic-gate drerr_set_c(CE_WARN, &(cp)->sbdev_error, \ 867c478bd9Sstevel@tonic-gate ESBD_INTERNAL, dr_ie_fmt, __LINE__) 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * TODO: Simplify or get rid of this. 907c478bd9Sstevel@tonic-gate * Macros for keeping an error code and an associated list of integers. 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate #define DR_MAX_ERR_INT (32) 937c478bd9Sstevel@tonic-gate #define DR_GET_E_CODE(sep) ((sep)->e_code) 947c478bd9Sstevel@tonic-gate #define DR_SET_E_CODE(sep, en) ((sep)->e_code = (en)) 957c478bd9Sstevel@tonic-gate #define DR_GET_E_RSC(sep) ((sep)->e_rsc) 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Format of dr_devset_t bit masks: 997c478bd9Sstevel@tonic-gate * 10025cf1a30Sjl * 64 48 40 32 24 16 8 0 10125cf1a30Sjl * |....|...I|IIII|IIII|....|...M|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC|CCCC| 1027c478bd9Sstevel@tonic-gate * 1037c478bd9Sstevel@tonic-gate * 1 = indicates respective component present/attached. 1047c478bd9Sstevel@tonic-gate * I = I/O, M = Memory, C = CPU. 1057c478bd9Sstevel@tonic-gate */ 10625cf1a30Sjl #define _NT2DEVPOS(t, u) (BIX(t) + (u)) 10725cf1a30Sjl #define _DEVSET_MASK ((dr_devset_t)0x1ff01ffffffff) 10825cf1a30Sjl #define _CMP_DEVSET_MASK ((dr_devset_t)0x11111111) 10925cf1a30Sjl #define DEVSET_ONEUNIT ((dr_devset_t)1) 11025cf1a30Sjl #define DEVSET_ANYUNIT (dr_devset_t)(-1) 1117c478bd9Sstevel@tonic-gate #define DEVSET(t, u) \ 1127c478bd9Sstevel@tonic-gate (((u) == DEVSET_ANYUNIT) ? \ 11325cf1a30Sjl ((NMASK(t) << _NT2DEVPOS((t), 0)) & _DEVSET_MASK) : \ 1147c478bd9Sstevel@tonic-gate ((t) == SBD_COMP_CMP) ? \ 11525cf1a30Sjl (_CMP_DEVSET_MASK << _NT2DEVPOS((t), (u))) : \ 11625cf1a30Sjl (DEVSET_ONEUNIT << _NT2DEVPOS((t), (u)))) 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #define DEVSET_IN_SET(ds, t, u) (((ds) & DEVSET((t), (u))) != 0) 1197c478bd9Sstevel@tonic-gate #define DEVSET_ADD(ds, t, u) ((ds) |= DEVSET((t), (u))) 1207c478bd9Sstevel@tonic-gate #define DEVSET_DEL(ds, t, u) ((ds) &= ~DEVSET((t), (u))) 1217c478bd9Sstevel@tonic-gate #define DEVSET_GET_UNITSET(ds, t) \ 1227c478bd9Sstevel@tonic-gate (((ds) & DEVSET((t), DEVSET_ANYUNIT)) >> _NT2DEVPOS((t), 0)) 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_* 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate #define DR_DEV_IS(ds, cp) DEVSET_IN_SET( \ 1287c478bd9Sstevel@tonic-gate (cp)->sbdev_bp->b_dev_##ds, \ 1297c478bd9Sstevel@tonic-gate (cp)->sbdev_type, \ 1307c478bd9Sstevel@tonic-gate (cp)->sbdev_unum) 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #define DR_DEV_ADD(ds, cp) DEVSET_ADD( \ 1337c478bd9Sstevel@tonic-gate (cp)->sbdev_bp->b_dev_##ds, \ 1347c478bd9Sstevel@tonic-gate (cp)->sbdev_type, \ 1357c478bd9Sstevel@tonic-gate (cp)->sbdev_unum) 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #define DR_DEV_DEL(ds, cp) DEVSET_DEL( \ 1387c478bd9Sstevel@tonic-gate (cp)->sbdev_bp->b_dev_##ds, \ 1397c478bd9Sstevel@tonic-gate (cp)->sbdev_type, \ 1407c478bd9Sstevel@tonic-gate (cp)->sbdev_unum) 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_present 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate #define DR_DEV_IS_PRESENT(cp) DR_DEV_IS(present, cp) 1467c478bd9Sstevel@tonic-gate #define DR_DEV_SET_PRESENT(cp) DR_DEV_ADD(present, cp) 1477c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_PRESENT(cp) DR_DEV_DEL(present, cp) 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_attached 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate #define DR_DEV_IS_ATTACHED(cp) DR_DEV_IS(attached, cp) 1537c478bd9Sstevel@tonic-gate #define DR_DEV_SET_ATTACHED(cp) DR_DEV_ADD(attached, cp) 1547c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_ATTACHED(cp) DR_DEV_DEL(attached, cp) 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate /* 1577c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_released 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate #define DR_DEV_IS_RELEASED(cp) DR_DEV_IS(released, cp) 1607c478bd9Sstevel@tonic-gate #define DR_DEV_SET_RELEASED(cp) DR_DEV_ADD(released, cp) 1617c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_RELEASED(cp) DR_DEV_DEL(released, cp) 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* 1647c478bd9Sstevel@tonic-gate * Ops for dr_board_t.b_dev_unreferenced 1657c478bd9Sstevel@tonic-gate */ 1667c478bd9Sstevel@tonic-gate #define DR_DEV_IS_UNREFERENCED(cp) DR_DEV_IS(unreferenced, cp) 1677c478bd9Sstevel@tonic-gate #define DR_DEV_SET_UNREFERENCED(cp) DR_DEV_ADD(unreferenced, cp) 1687c478bd9Sstevel@tonic-gate #define DR_DEV_CLR_UNREFERENCED(cp) DR_DEV_DEL(unreferenced, cp) 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate #define DR_DEVS_PRESENT(bp) \ 1717c478bd9Sstevel@tonic-gate ((bp)->b_dev_present) 1727c478bd9Sstevel@tonic-gate #define DR_DEVS_ATTACHED(bp) \ 1737c478bd9Sstevel@tonic-gate ((bp)->b_dev_attached) 1747c478bd9Sstevel@tonic-gate #define DR_DEVS_RELEASED(bp) \ 1757c478bd9Sstevel@tonic-gate ((bp)->b_dev_released) 1767c478bd9Sstevel@tonic-gate #define DR_DEVS_UNREFERENCED(bp) \ 1777c478bd9Sstevel@tonic-gate ((bp)->b_dev_unreferenced) 1787c478bd9Sstevel@tonic-gate #define DR_DEVS_UNATTACHED(bp) \ 1797c478bd9Sstevel@tonic-gate ((bp)->b_dev_present & ~(bp)->b_dev_attached) 1807c478bd9Sstevel@tonic-gate #define DR_DEVS_CONFIGURE(bp, devs) \ 1817c478bd9Sstevel@tonic-gate ((bp)->b_dev_attached = (devs)) 1827c478bd9Sstevel@tonic-gate #define DR_DEVS_DISCONNECT(bp, devs) \ 1837c478bd9Sstevel@tonic-gate ((bp)->b_dev_present &= ~(devs)) 1847c478bd9Sstevel@tonic-gate #define DR_DEVS_CANCEL(bp, devs) \ 1857c478bd9Sstevel@tonic-gate ((bp)->b_dev_released &= ~(devs), \ 1867c478bd9Sstevel@tonic-gate (bp)->b_dev_unreferenced &= ~(devs)) 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * CMP Specific Helpers 1907c478bd9Sstevel@tonic-gate */ 1917c478bd9Sstevel@tonic-gate #define DR_CMP_CORE_UNUM(cmp, core) (cmp + (core * 4)) 19225cf1a30Sjl /* 19325cf1a30Sjl * DR_UNUM2SBD_UNUM should be set to (unum & (max #of CMP on board - 1)) 19425cf1a30Sjl * for all the platforms. So far, all sun4u platforms supported have 19525cf1a30Sjl * the same limit so 0x3 works. One day we might have to make this 19625cf1a30Sjl * a platform specific macro. 19725cf1a30Sjl */ 19825cf1a30Sjl 19925cf1a30Sjl #define DR_UNUM2SBD_UNUM(n, d) ((d == SBD_COMP_IO) ? (n & 0xf) : \ 20025cf1a30Sjl (d == SBD_COMP_CPU) ? (n & 0x3) : \ 20125cf1a30Sjl (d == SBD_COMP_CMP) ? (n & 0x3) : \ 20225cf1a30Sjl (n)) 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* 2057c478bd9Sstevel@tonic-gate * Some stuff to assist in debug. 2067c478bd9Sstevel@tonic-gate */ 2077c478bd9Sstevel@tonic-gate #ifdef DEBUG 2087c478bd9Sstevel@tonic-gate #define DRDBG_STATE 0x00000001 2097c478bd9Sstevel@tonic-gate #define DRDBG_QR 0x00000002 2107c478bd9Sstevel@tonic-gate #define DRDBG_CPU 0x00000004 2117c478bd9Sstevel@tonic-gate #define DRDBG_MEM 0x00000008 2127c478bd9Sstevel@tonic-gate #define DRDBG_IO 0x00000010 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate #define PR_ALL if (dr_debug) printf 2157c478bd9Sstevel@tonic-gate #define PR_STATE if (dr_debug & DRDBG_STATE) printf 2167c478bd9Sstevel@tonic-gate #define PR_QR if (dr_debug & DRDBG_QR) prom_printf 2177c478bd9Sstevel@tonic-gate #define PR_CPU if (dr_debug & DRDBG_CPU) printf 2187c478bd9Sstevel@tonic-gate #define PR_MEM if (dr_debug & DRDBG_MEM) printf 2197c478bd9Sstevel@tonic-gate #define PR_IO if (dr_debug & DRDBG_IO) printf 2207c478bd9Sstevel@tonic-gate #define PR_MEMLIST_DUMP if (dr_debug & DRDBG_MEM) MEMLIST_DUMP 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate extern uint_t dr_debug; 2237c478bd9Sstevel@tonic-gate #else /* DEBUG */ 2247c478bd9Sstevel@tonic-gate #define PR_ALL _NOTE(CONSTANTCONDITION) if (0) printf 2257c478bd9Sstevel@tonic-gate #define PR_STATE PR_ALL 2267c478bd9Sstevel@tonic-gate #define PR_QR PR_ALL 2277c478bd9Sstevel@tonic-gate #define PR_CPU PR_ALL 2287c478bd9Sstevel@tonic-gate #define PR_MEM PR_ALL 2297c478bd9Sstevel@tonic-gate #define PR_IO PR_ALL 2307c478bd9Sstevel@tonic-gate #define PR_MEMLIST_DUMP _NOTE(CONSTANTCONDITION) if (0) MEMLIST_DUMP 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * dr_board_t b_sflags. 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate #define DR_BSLOCK 0x01 /* for blocking status (protected by b_slock) */ 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate typedef const char *fn_t; 24025cf1a30Sjl typedef uint64_t dr_devset_t; /* TODO: fix limitation */ 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate /* 2437c478bd9Sstevel@tonic-gate * Unsafe devices based on dr.conf prop "unsupported-io-drivers" 2447c478bd9Sstevel@tonic-gate */ 2457c478bd9Sstevel@tonic-gate typedef struct { 2467c478bd9Sstevel@tonic-gate char **devnames; 2477c478bd9Sstevel@tonic-gate uint_t ndevs; 2487c478bd9Sstevel@tonic-gate } dr_unsafe_devs_t; 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate /* 2517c478bd9Sstevel@tonic-gate * Device states. 2527c478bd9Sstevel@tonic-gate * PARTIAL state is really only relevant for board state. 2537c478bd9Sstevel@tonic-gate */ 2547c478bd9Sstevel@tonic-gate typedef enum { 2557c478bd9Sstevel@tonic-gate DR_STATE_EMPTY = 0, 2567c478bd9Sstevel@tonic-gate DR_STATE_OCCUPIED, 2577c478bd9Sstevel@tonic-gate DR_STATE_CONNECTED, 2587c478bd9Sstevel@tonic-gate DR_STATE_UNCONFIGURED, 2597c478bd9Sstevel@tonic-gate DR_STATE_PARTIAL, /* part connected, part configured */ 2607c478bd9Sstevel@tonic-gate DR_STATE_CONFIGURED, 2617c478bd9Sstevel@tonic-gate DR_STATE_RELEASE, 2627c478bd9Sstevel@tonic-gate DR_STATE_UNREFERENCED, 2637c478bd9Sstevel@tonic-gate DR_STATE_FATAL, 2647c478bd9Sstevel@tonic-gate DR_STATE_MAX 2657c478bd9Sstevel@tonic-gate } dr_state_t; 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate typedef struct dr_handle { 2687c478bd9Sstevel@tonic-gate struct dr_board *h_bd; 2697c478bd9Sstevel@tonic-gate sbd_error_t *h_err; 2707c478bd9Sstevel@tonic-gate int h_op_intr; /* nz if op interrupted */ 2717c478bd9Sstevel@tonic-gate dev_t h_dev; /* dev_t of opened device */ 2727c478bd9Sstevel@tonic-gate int h_cmd; /* PIM ioctl argument */ 2737c478bd9Sstevel@tonic-gate int h_mode; /* device open mode */ 274*d5ebc493SDan Cross sbd_cmd_t h_sbdcmd; /* copied-in ioctl cmd struct */ 2757c478bd9Sstevel@tonic-gate sbd_ioctl_arg_t *h_iap; /* ptr to caller-space cmd struct */ 2767c478bd9Sstevel@tonic-gate dr_devset_t h_devset; /* based on h_dev */ 2777c478bd9Sstevel@tonic-gate drmach_opts_t h_opts; /* command-line platform options */ 2787c478bd9Sstevel@tonic-gate } dr_handle_t; 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate typedef struct dr_common_unit { 2817c478bd9Sstevel@tonic-gate dr_state_t sbdev_state; 2827c478bd9Sstevel@tonic-gate sbd_state_t sbdev_ostate; 2837c478bd9Sstevel@tonic-gate sbd_cond_t sbdev_cond; 2847c478bd9Sstevel@tonic-gate time_t sbdev_time; 2857c478bd9Sstevel@tonic-gate int sbdev_busy; 2867c478bd9Sstevel@tonic-gate struct dr_board *sbdev_bp; 2877c478bd9Sstevel@tonic-gate int sbdev_unum; 2887c478bd9Sstevel@tonic-gate sbd_comp_type_t sbdev_type; 2897c478bd9Sstevel@tonic-gate drmachid_t sbdev_id; 2907c478bd9Sstevel@tonic-gate char sbdev_path[MAXNAMELEN]; 2917c478bd9Sstevel@tonic-gate sbd_error_t *sbdev_error; 2927c478bd9Sstevel@tonic-gate } dr_common_unit_t; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate typedef struct dr_mem_unit { 2957c478bd9Sstevel@tonic-gate dr_common_unit_t sbm_cm; /* mem-unit state */ 2967c478bd9Sstevel@tonic-gate uint_t sbm_flags; 2977c478bd9Sstevel@tonic-gate pfn_t sbm_basepfn; 2987c478bd9Sstevel@tonic-gate pgcnt_t sbm_npages; 2997c478bd9Sstevel@tonic-gate pgcnt_t sbm_pageslost; 3007c478bd9Sstevel@tonic-gate struct memlist *sbm_dyn_segs; /* kphysm_add_dynamic segs */ 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * The following fields are used during 3037c478bd9Sstevel@tonic-gate * the memory detach process only. sbm_mlist 3047c478bd9Sstevel@tonic-gate * will be used to store the board memlist 3057c478bd9Sstevel@tonic-gate * following a detach. The memlist will be 3067c478bd9Sstevel@tonic-gate * used to re-attach the board when configuring 3077c478bd9Sstevel@tonic-gate * the unit directly after an unconfigure. 3087c478bd9Sstevel@tonic-gate */ 3097c478bd9Sstevel@tonic-gate struct dr_mem_unit *sbm_peer; 3107c478bd9Sstevel@tonic-gate struct memlist *sbm_mlist; 3117c478bd9Sstevel@tonic-gate struct memlist *sbm_del_mlist; 3127c478bd9Sstevel@tonic-gate memhandle_t sbm_memhandle; 3137c478bd9Sstevel@tonic-gate pfn_t sbm_alignment_mask; 3147c478bd9Sstevel@tonic-gate pfn_t sbm_slice_offset; 3157c478bd9Sstevel@tonic-gate uint64_t sbm_slice_size; 3167c478bd9Sstevel@tonic-gate } dr_mem_unit_t; 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate /* 3197c478bd9Sstevel@tonic-gate * Currently only maintain state information for individual 3207c478bd9Sstevel@tonic-gate * components. 3217c478bd9Sstevel@tonic-gate */ 3227c478bd9Sstevel@tonic-gate typedef struct dr_cpu_unit { 3237c478bd9Sstevel@tonic-gate dr_common_unit_t sbc_cm; /* cpu-unit state */ 3247c478bd9Sstevel@tonic-gate processorid_t sbc_cpu_id; 3257c478bd9Sstevel@tonic-gate cpu_flag_t sbc_cpu_flags; /* snapshot of CPU flags */ 3267c478bd9Sstevel@tonic-gate ushort_t sbc_pad1; /* padded for compatibility */ 3277c478bd9Sstevel@tonic-gate int sbc_speed; 3287c478bd9Sstevel@tonic-gate int sbc_ecache; 3297c478bd9Sstevel@tonic-gate int sbc_cpu_impl; 3307c478bd9Sstevel@tonic-gate } dr_cpu_unit_t; 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate typedef struct dr_io_unit { 3337c478bd9Sstevel@tonic-gate dr_common_unit_t sbi_cm; /* io-unit state */ 3347c478bd9Sstevel@tonic-gate } dr_io_unit_t; 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate typedef union { 3377c478bd9Sstevel@tonic-gate dr_common_unit_t du_common; 3387c478bd9Sstevel@tonic-gate dr_mem_unit_t du_mem; 3397c478bd9Sstevel@tonic-gate dr_cpu_unit_t du_cpu; 3407c478bd9Sstevel@tonic-gate dr_io_unit_t du_io; 3417c478bd9Sstevel@tonic-gate } dr_dev_unit_t; 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate typedef struct dr_board { 3447c478bd9Sstevel@tonic-gate kmutex_t b_lock; /* lock for this board struct */ 3457c478bd9Sstevel@tonic-gate kmutex_t b_slock; /* lock for status on the board */ 3467c478bd9Sstevel@tonic-gate kcondvar_t b_scv; /* condvar for status on the board */ 3477c478bd9Sstevel@tonic-gate int b_sflags; /* for serializing status */ 3487c478bd9Sstevel@tonic-gate sbd_state_t b_rstate; /* board's cfgadm receptacle state */ 3497c478bd9Sstevel@tonic-gate sbd_state_t b_ostate; /* board's cfgadm occupant state */ 3507c478bd9Sstevel@tonic-gate sbd_cond_t b_cond; /* cfgadm condition */ 3517c478bd9Sstevel@tonic-gate int b_busy; 3527c478bd9Sstevel@tonic-gate int b_assigned; 3537c478bd9Sstevel@tonic-gate time_t b_time; /* time of last board operation */ 3547c478bd9Sstevel@tonic-gate char b_type[MAXNAMELEN]; 3557c478bd9Sstevel@tonic-gate drmachid_t b_id; 3567c478bd9Sstevel@tonic-gate int b_num; /* board number */ 3577c478bd9Sstevel@tonic-gate int b_ndev; /* # of devices on board */ 3587c478bd9Sstevel@tonic-gate dev_info_t *b_dip; /* dip for make-nodes */ 3597c478bd9Sstevel@tonic-gate dr_state_t b_state; /* board DR state */ 3607c478bd9Sstevel@tonic-gate dr_devset_t b_dev_present; /* present mask */ 3617c478bd9Sstevel@tonic-gate dr_devset_t b_dev_attached; /* attached mask */ 3627c478bd9Sstevel@tonic-gate dr_devset_t b_dev_released; /* released mask */ 3637c478bd9Sstevel@tonic-gate dr_devset_t b_dev_unreferenced; /* unreferenced mask */ 3647c478bd9Sstevel@tonic-gate char b_path[MAXNAMELEN]; 3657c478bd9Sstevel@tonic-gate dr_dev_unit_t *b_dev[DR_MAXNUM_NT]; 3667c478bd9Sstevel@tonic-gate } dr_board_t; 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* 3697c478bd9Sstevel@tonic-gate * dr_quiesce.c interfaces 3707c478bd9Sstevel@tonic-gate */ 3717c478bd9Sstevel@tonic-gate struct dr_sr_handle; 3727c478bd9Sstevel@tonic-gate typedef struct dr_sr_handle dr_sr_handle_t; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate extern dr_sr_handle_t *dr_get_sr_handle(dr_handle_t *handle); 3757c478bd9Sstevel@tonic-gate extern void dr_release_sr_handle(dr_sr_handle_t *srh); 3767c478bd9Sstevel@tonic-gate extern int dr_suspend(dr_sr_handle_t *srh); 3777c478bd9Sstevel@tonic-gate extern void dr_resume(dr_sr_handle_t *srh); 3787c478bd9Sstevel@tonic-gate extern void dr_check_devices(dev_info_t *dip, int *refcount, 379df3cd224SVijay S Balakrishna dr_handle_t *handle, uint64_t *arr, int *idx, 380df3cd224SVijay S Balakrishna int len, int *refcount_non_gldv3); 3817c478bd9Sstevel@tonic-gate extern int dr_pt_test_suspend(dr_handle_t *hp); 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* 3847c478bd9Sstevel@tonic-gate * dr_cpu.c interface 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate extern void dr_init_cpu_unit(dr_cpu_unit_t *cp); 3877c478bd9Sstevel@tonic-gate extern int dr_pre_attach_cpu(dr_handle_t *hp, 3887c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3897c478bd9Sstevel@tonic-gate extern void dr_attach_cpu(dr_handle_t *hp, dr_common_unit_t *cp); 3907c478bd9Sstevel@tonic-gate extern int dr_post_attach_cpu(dr_handle_t *hp, 3917c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3927c478bd9Sstevel@tonic-gate extern int dr_pre_release_cpu(dr_handle_t *hp, 3937c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3947c478bd9Sstevel@tonic-gate extern int dr_pre_detach_cpu(dr_handle_t *hp, 3957c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3967c478bd9Sstevel@tonic-gate extern void dr_detach_cpu(dr_handle_t *hp, dr_common_unit_t *cp); 3977c478bd9Sstevel@tonic-gate extern int dr_post_detach_cpu(dr_handle_t *hp, 3987c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 3997c478bd9Sstevel@tonic-gate extern int dr_cpu_status(dr_handle_t *hp, dr_devset_t devset, 4007c478bd9Sstevel@tonic-gate sbd_dev_stat_t *dsp); 4017c478bd9Sstevel@tonic-gate extern int dr_cancel_cpu(dr_cpu_unit_t *cp); 4027c478bd9Sstevel@tonic-gate extern int dr_disconnect_cpu(dr_cpu_unit_t *cp); 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate /* 4067c478bd9Sstevel@tonic-gate * dr_mem.c interface 4077c478bd9Sstevel@tonic-gate */ 4087c478bd9Sstevel@tonic-gate extern void dr_init_mem_unit(dr_mem_unit_t *mp); 4097c478bd9Sstevel@tonic-gate extern int dr_pre_attach_mem(dr_handle_t *hp, 4107c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4117c478bd9Sstevel@tonic-gate extern void dr_attach_mem(dr_handle_t *hp, dr_common_unit_t *cp); 4127c478bd9Sstevel@tonic-gate extern int dr_post_attach_mem(dr_handle_t *hp, 4137c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4147c478bd9Sstevel@tonic-gate extern int dr_pre_release_mem(dr_handle_t *hp, 4157c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4167c478bd9Sstevel@tonic-gate extern void dr_release_mem(dr_common_unit_t *cp); 4177c478bd9Sstevel@tonic-gate extern void dr_release_mem_done(dr_common_unit_t *cp); 4187c478bd9Sstevel@tonic-gate extern int dr_pre_detach_mem(dr_handle_t *hp, 4197c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4207c478bd9Sstevel@tonic-gate extern void dr_detach_mem(dr_handle_t *, dr_common_unit_t *); 4217c478bd9Sstevel@tonic-gate extern int dr_post_detach_mem(dr_handle_t *hp, 4227c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4237c478bd9Sstevel@tonic-gate extern int dr_mem_status(dr_handle_t *hp, dr_devset_t devset, 4247c478bd9Sstevel@tonic-gate sbd_dev_stat_t *dsp); 4257c478bd9Sstevel@tonic-gate extern int dr_cancel_mem(dr_mem_unit_t *mp); 4267c478bd9Sstevel@tonic-gate extern int dr_disconnect_mem(dr_mem_unit_t *mp); 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate /* 4297c478bd9Sstevel@tonic-gate * dr_io.c interface 4307c478bd9Sstevel@tonic-gate */ 4317c478bd9Sstevel@tonic-gate extern void dr_init_io_unit(dr_io_unit_t *io); 4327c478bd9Sstevel@tonic-gate extern int dr_disconnect_io(dr_io_unit_t *ip); 4337c478bd9Sstevel@tonic-gate extern int dr_pre_attach_io(dr_handle_t *hp, 4347c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4357c478bd9Sstevel@tonic-gate extern void dr_attach_io(dr_handle_t *hp, dr_common_unit_t *cp); 4367c478bd9Sstevel@tonic-gate extern int dr_post_attach_io(dr_handle_t *hp, 4377c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4387c478bd9Sstevel@tonic-gate extern int dr_pre_release_io(dr_handle_t *hp, 4397c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4407c478bd9Sstevel@tonic-gate extern int dr_pre_detach_io(dr_handle_t *hp, 4417c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4427c478bd9Sstevel@tonic-gate extern void dr_detach_io(dr_handle_t *hp, dr_common_unit_t *cp); 4437c478bd9Sstevel@tonic-gate extern int dr_post_detach_io(dr_handle_t *hp, 4447c478bd9Sstevel@tonic-gate dr_common_unit_t **devlist, int devnum); 4457c478bd9Sstevel@tonic-gate extern int dr_io_status(dr_handle_t *hp, dr_devset_t devset, 4467c478bd9Sstevel@tonic-gate sbd_dev_stat_t *dsp); 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate /* 4507c478bd9Sstevel@tonic-gate * dr.c interface 4517c478bd9Sstevel@tonic-gate */ 4527c478bd9Sstevel@tonic-gate extern void dr_op_err(int ce, dr_handle_t *hp, int code, char *fmt, ...); 4537c478bd9Sstevel@tonic-gate extern void dr_dev_err(int ce, dr_common_unit_t *cp, int code); 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate extern dr_cpu_unit_t *dr_get_cpu_unit(dr_board_t *bp, int unit_num); 4567c478bd9Sstevel@tonic-gate extern dr_mem_unit_t *dr_get_mem_unit(dr_board_t *bp, int unit_num); 4577c478bd9Sstevel@tonic-gate extern dr_io_unit_t *dr_get_io_unit(dr_board_t *bp, int unit_num); 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate extern dr_board_t *dr_lookup_board(int board_num); 4607c478bd9Sstevel@tonic-gate extern int dr_release_dev_done(dr_common_unit_t *cp); 4617c478bd9Sstevel@tonic-gate extern char *dr_nt_to_dev_type(int type); 4627c478bd9Sstevel@tonic-gate extern void dr_device_transition(dr_common_unit_t *cp, 4637c478bd9Sstevel@tonic-gate dr_state_t new_state); 4647c478bd9Sstevel@tonic-gate extern void dr_lock_status(dr_board_t *bp); 4657c478bd9Sstevel@tonic-gate extern void dr_unlock_status(dr_board_t *bp); 4667c478bd9Sstevel@tonic-gate extern int dr_cmd_flags(dr_handle_t *hp); 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4697c478bd9Sstevel@tonic-gate } 4707c478bd9Sstevel@tonic-gate #endif 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate #endif /* _SYS_DR_H */ 473