1*83c4dfe9Sjg /* 2*83c4dfe9Sjg * CDDL HEADER START 3*83c4dfe9Sjg * 4*83c4dfe9Sjg * The contents of this file are subject to the terms of the 5*83c4dfe9Sjg * Common Development and Distribution License (the "License"). 6*83c4dfe9Sjg * You may not use this file except in compliance with the License. 7*83c4dfe9Sjg * 8*83c4dfe9Sjg * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*83c4dfe9Sjg * or http://www.opensolaris.org/os/licensing. 10*83c4dfe9Sjg * See the License for the specific language governing permissions 11*83c4dfe9Sjg * and limitations under the License. 12*83c4dfe9Sjg * 13*83c4dfe9Sjg * When distributing Covered Code, include this CDDL HEADER in each 14*83c4dfe9Sjg * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*83c4dfe9Sjg * If applicable, add the following below this CDDL HEADER, with the 16*83c4dfe9Sjg * fields enclosed by brackets "[]" replaced with your own identifying 17*83c4dfe9Sjg * information: Portions Copyright [yyyy] [name of copyright owner] 18*83c4dfe9Sjg * 19*83c4dfe9Sjg * CDDL HEADER END 20*83c4dfe9Sjg */ 21*83c4dfe9Sjg /* 22*83c4dfe9Sjg * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*83c4dfe9Sjg * Use is subject to license terms. 24*83c4dfe9Sjg */ 25*83c4dfe9Sjg 26*83c4dfe9Sjg #ifndef _SYS_DEVID_CACHE_H 27*83c4dfe9Sjg #define _SYS_DEVID_CACHE_H 28*83c4dfe9Sjg 29*83c4dfe9Sjg #pragma ident "%Z%%M% %I% %E% SMI" 30*83c4dfe9Sjg 31*83c4dfe9Sjg #ifdef __cplusplus 32*83c4dfe9Sjg extern "C" { 33*83c4dfe9Sjg #endif 34*83c4dfe9Sjg 35*83c4dfe9Sjg #include <sys/list.h> 36*83c4dfe9Sjg 37*83c4dfe9Sjg /* 38*83c4dfe9Sjg * The top-level nvpair identifiers in the 39*83c4dfe9Sjg * /etc/devices/devid_cache nvlist format 40*83c4dfe9Sjg */ 41*83c4dfe9Sjg #define DP_DEVID_ID "devid" 42*83c4dfe9Sjg 43*83c4dfe9Sjg #ifdef _KERNEL 44*83c4dfe9Sjg 45*83c4dfe9Sjg /* devid-specific list element */ 46*83c4dfe9Sjg typedef struct nvp_devid { 47*83c4dfe9Sjg int nvp_flags; 48*83c4dfe9Sjg char *nvp_devpath; 49*83c4dfe9Sjg dev_info_t *nvp_dip; 50*83c4dfe9Sjg ddi_devid_t nvp_devid; 51*83c4dfe9Sjg list_node_t nvp_link; /* link to next element */ 52*83c4dfe9Sjg } nvp_devid_t; 53*83c4dfe9Sjg 54*83c4dfe9Sjg 55*83c4dfe9Sjg /* 56*83c4dfe9Sjg * nvp_flags - devid 57*83c4dfe9Sjg */ 58*83c4dfe9Sjg #define NVP_DEVID_REGISTERED 0x01 /* devid registered on this boot */ 59*83c4dfe9Sjg #define NVP_DEVID_DIP 0x02 /* devinfo valid for this devid */ 60*83c4dfe9Sjg 61*83c4dfe9Sjg /* 62*83c4dfe9Sjg * tunables - see devid_cache.c for more details 63*83c4dfe9Sjg */ 64*83c4dfe9Sjg extern int devid_discovery_boot; 65*83c4dfe9Sjg extern int devid_discovery_postboot; 66*83c4dfe9Sjg extern int devid_discovery_postboot_always; 67*83c4dfe9Sjg extern int devid_discovery_secs; 68*83c4dfe9Sjg 69*83c4dfe9Sjg extern int devid_cache_read_disable; 70*83c4dfe9Sjg extern int devid_cache_write_disable; 71*83c4dfe9Sjg 72*83c4dfe9Sjg /* 73*83c4dfe9Sjg * More thorough error reporting available both debug & 74*83c4dfe9Sjg * non-debug kernels, but turned off by default. 75*83c4dfe9Sjg */ 76*83c4dfe9Sjg extern int devid_report_error; /* devid cache operations */ 77*83c4dfe9Sjg 78*83c4dfe9Sjg 79*83c4dfe9Sjg /* 80*83c4dfe9Sjg * function prototypes 81*83c4dfe9Sjg */ 82*83c4dfe9Sjg static int devid_cache_pack_list(nvf_handle_t, nvlist_t **); 83*83c4dfe9Sjg static int devid_cache_unpack_nvlist(nvf_handle_t, nvlist_t *, char *); 84*83c4dfe9Sjg static void devid_list_free(nvf_handle_t); 85*83c4dfe9Sjg 86*83c4dfe9Sjg 87*83c4dfe9Sjg #ifdef DEBUG 88*83c4dfe9Sjg 89*83c4dfe9Sjg #define DEVID_DEBUG(args) { if (devid_debug) cmn_err args; } 90*83c4dfe9Sjg #define DEVID_DEBUG1(args) { if (devid_debug > 1) cmn_err args; } 91*83c4dfe9Sjg #define DEVID_DEBUG2(args) { if (devid_debug > 2) cmn_err args; } 92*83c4dfe9Sjg #define DEVID_DUMP(args) { if (devid_debug > 2) args; } 93*83c4dfe9Sjg #define DEVID_LOG_REG(args) { if (devid_log_registers) devid_log args; } 94*83c4dfe9Sjg #define DEVID_LOG_FIND(args) { if (devid_log_finds) devid_log args; } 95*83c4dfe9Sjg #define DEVID_LOG_LOOKUP(args) { if (devid_log_lookups) cmn_err args; } 96*83c4dfe9Sjg #define DEVID_LOG_MATCH(args) { if (devid_log_matches) devid_log args; } 97*83c4dfe9Sjg #define DEVID_LOG_PATHS(args) { if (devid_log_paths) cmn_err args; } 98*83c4dfe9Sjg #define DEVID_LOG_ERR(args) { if (devid_log_failures) devid_log args; } 99*83c4dfe9Sjg #define DEVID_LOG_DISC(args) { if (devid_log_discovery) cmn_err args; } 100*83c4dfe9Sjg #define DEVID_LOG_HOLD(args) { if (devid_log_hold) cmn_err args; } 101*83c4dfe9Sjg #define DEVID_LOG_UNREG(args) { if (devid_log_unregisters) cmn_err args; } 102*83c4dfe9Sjg #define DEVID_LOG_REMOVE(args) { if (devid_log_removes) cmn_err args; } 103*83c4dfe9Sjg #define DEVID_LOG_STALE(args) { if (devid_log_stale) devid_log args; } 104*83c4dfe9Sjg #define DEVID_LOG_DETACH(args) { if (devid_log_detaches) cmn_err args; } 105*83c4dfe9Sjg 106*83c4dfe9Sjg 107*83c4dfe9Sjg #define NVP_DEVID_DEBUG_PATH(arg) { \ 108*83c4dfe9Sjg if (nvp_devid_debug) \ 109*83c4dfe9Sjg cmn_err(CE_CONT, "%s\n", arg); \ 110*83c4dfe9Sjg } 111*83c4dfe9Sjg 112*83c4dfe9Sjg #define NVP_DEVID_DEBUG_DEVID(arg) { \ 113*83c4dfe9Sjg if (nvp_devid_debug) { \ 114*83c4dfe9Sjg char *ds = ddi_devid_str_encode(arg, NULL); \ 115*83c4dfe9Sjg cmn_err(CE_CONT, "devid: %s\n", ds); \ 116*83c4dfe9Sjg ddi_devid_str_free(ds); \ 117*83c4dfe9Sjg } \ 118*83c4dfe9Sjg } 119*83c4dfe9Sjg 120*83c4dfe9Sjg static void devid_log(char *, ddi_devid_t, char *); 121*83c4dfe9Sjg 122*83c4dfe9Sjg #else 123*83c4dfe9Sjg 124*83c4dfe9Sjg #define DEVID_DEBUG(args) 125*83c4dfe9Sjg #define DEVID_DEBUG1(args) 126*83c4dfe9Sjg #define DEVID_DEBUG2(args) 127*83c4dfe9Sjg #define DEVID_DUMP(args) 128*83c4dfe9Sjg #define DEVID_LOG_REG(args) 129*83c4dfe9Sjg #define DEVID_LOG_FIND(args) 130*83c4dfe9Sjg #define DEVID_LOG_LOOKUP(args) 131*83c4dfe9Sjg #define DEVID_LOG_MATCH(args) 132*83c4dfe9Sjg #define DEVID_LOG_PATHS(args) 133*83c4dfe9Sjg #define DEVID_LOG_ERR(args) 134*83c4dfe9Sjg #define DEVID_LOG_DISC(args) 135*83c4dfe9Sjg #define DEVID_LOG_HOLD(args) 136*83c4dfe9Sjg #define DEVID_LOG_UNREG(args) 137*83c4dfe9Sjg #define DEVID_LOG_REMOVE(args) 138*83c4dfe9Sjg #define DEVID_LOG_STALE(args) 139*83c4dfe9Sjg #define DEVID_LOG_DETACH(args) 140*83c4dfe9Sjg #define NVP_DEVID_DEBUG_PATH(arg) 141*83c4dfe9Sjg #define NVP_DEVID_DEBUG_DEVID(arg) 142*83c4dfe9Sjg 143*83c4dfe9Sjg #endif /* DEBUG */ 144*83c4dfe9Sjg 145*83c4dfe9Sjg #define DEVIDERR(args) { if (devid_report_error) cmn_err args; } 146*83c4dfe9Sjg 147*83c4dfe9Sjg #endif /* _KERNEL */ 148*83c4dfe9Sjg 149*83c4dfe9Sjg #ifdef __cplusplus 150*83c4dfe9Sjg } 151*83c4dfe9Sjg #endif 152*83c4dfe9Sjg 153*83c4dfe9Sjg #endif /* _SYS_DEVID_CACHE_H */ 154