1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26 #ifndef _SYS_DAMAP_IMPL_H 27 #define _SYS_DAMAP_IMPL_H 28 29 #include <sys/isa_defs.h> 30 #include <sys/dditypes.h> 31 #include <sys/time.h> 32 #include <sys/cmn_err.h> 33 #include <sys/ddi_impldefs.h> 34 #include <sys/ddi_implfuncs.h> 35 #include <sys/ddi_isa.h> 36 #include <sys/model.h> 37 #include <sys/devctl.h> 38 #include <sys/nvpair.h> 39 #include <sys/sysevent.h> 40 #include <sys/bitset.h> 41 #include <sys/sdt.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 typedef struct dam dam_t; 48 49 /* 50 * activate_cb: Provider callback when reported address is activated 51 * deactivate_cb: Provider callback when address has been released 52 * 53 * configure_cb: Class callout to configure newly activated addresses 54 * unconfig_cb: Class callout to unconfigure deactivated addresses 55 */ 56 typedef void (*activate_cb_t)(void *, char *addr, int idx, void **privp); 57 typedef void (*deactivate_cb_t)(void *, char *addr, int idx, void *priv, 58 damap_deact_rsn_t deact_rsn); 59 60 typedef int (*configure_cb_t)(void *, dam_t *mapp, id_t map_id); 61 typedef int (*unconfig_cb_t)(void *, dam_t *mapp, id_t map_id); 62 63 64 struct dam { 65 char *dam_name; 66 int dam_flags; /* map state and cv flags */ 67 int dam_options; /* map options */ 68 int dam_rptmode; /* report mode */ 69 clock_t dam_stable_ticks; /* stabilization */ 70 uint_t dam_size; /* max index for addr hash */ 71 id_t dam_high; /* highest index allocated */ 72 timeout_id_t dam_tid; /* timeout(9F) ID */ 73 74 void *dam_activate_arg; /* activation private */ 75 activate_cb_t dam_activate_cb; /* activation callback */ 76 deactivate_cb_t dam_deactivate_cb; /* deactivation callback */ 77 78 void *dam_config_arg; /* config-private */ 79 configure_cb_t dam_configure_cb; /* configure callout */ 80 unconfig_cb_t dam_unconfig_cb; /* unconfigure callout */ 81 82 ddi_strid *dam_addr_hash; /* addresss to ID hash */ 83 bitset_t dam_active_set; /* activated address set */ 84 bitset_t dam_stable_set; /* stable address set */ 85 bitset_t dam_report_set; /* reported address set */ 86 void *dam_da; /* per-address soft state */ 87 hrtime_t dam_last_update; /* last map update */ 88 hrtime_t dam_last_stable; /* last map stable */ 89 int dam_stable_cnt; /* # of times map stabilized */ 90 int dam_stable_overrun; 91 kcondvar_t dam_sync_cv; 92 kmutex_t dam_lock; 93 kstat_t *dam_kstatsp; 94 int dam_sync_to_cnt; 95 }; 96 97 #define DAM_SPEND 0x10 /* stable pending */ 98 #define DAM_DESTROYPEND 0x20 /* in process of being destroyed */ 99 #define DAM_SETADD 0x100 /* fullset update pending */ 100 101 /* 102 * per address softstate stucture 103 */ 104 typedef struct { 105 uint_t da_flags; /* flags */ 106 int da_jitter; /* address re-report count */ 107 int da_ref; /* refcount on address */ 108 void *da_ppriv; /* stable provider private */ 109 void *da_cfg_priv; /* config/unconfig private */ 110 nvlist_t *da_nvl; /* stable nvlist */ 111 void *da_ppriv_rpt; /* reported provider-private */ 112 nvlist_t *da_nvl_rpt; /* reported nvlist */ 113 int64_t da_deadline; /* ddi_get_lbolt64 value when stable */ 114 hrtime_t da_last_report; /* timestamp of last report */ 115 int da_report_cnt; /* # of times address reported */ 116 hrtime_t da_last_stable; /* timestamp of last stable address */ 117 int da_stable_cnt; /* # of times address has stabilized */ 118 char *da_addr; /* string in dam_addr_hash (for mdb) */ 119 } dam_da_t; 120 121 /* 122 * dam_da_t.da_flags 123 */ 124 #define DA_INIT 0x1 /* address initizized */ 125 #define DA_FAILED_CONFIG 0x2 /* address failed configure */ 126 #define DA_RELE 0x4 /* adddress released */ 127 128 129 /* 130 * report type 131 */ 132 #define RPT_ADDR_ADD 0 133 #define RPT_ADDR_DEL 1 134 135 #define DAM_IN_REPORT(m, i) (bitset_in_set(&(m)->dam_report_set, (i))) 136 #define DAM_IS_STABLE(m, i) (bitset_in_set(&(m)->dam_active_set, (i))) 137 138 /* 139 * DAM statistics 140 */ 141 struct dam_kstats { 142 struct kstat_named dam_cycles; 143 struct kstat_named dam_overrun; 144 struct kstat_named dam_jitter; 145 struct kstat_named dam_active; 146 }; 147 148 #ifdef __cplusplus 149 } 150 #endif 151 152 #endif /* _SYS_DAMAP_IMPL_H */ 153