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.
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.
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]
23 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
26 #ifndef _SYS_DAMAP_IMPL_H
27 #define _SYS_DAMAP_IMPL_H
29 #include <sys/isa_defs.h>
30 #include <sys/dditypes.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>
47 typedef struct dam dam_t
;
50 * activate_cb: Provider callback when reported address is activated
51 * deactivate_cb: Provider callback when address has been released
53 * configure_cb: Class callout to configure newly activated addresses
54 * unconfig_cb: Class callout to unconfigure deactivated addresses
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
);
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
);
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 */
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 */
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 */
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
;
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 */
102 * per address softstate stucture
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) */
124 #define DA_INIT 0x1 /* address initizized */
125 #define DA_FAILED_CONFIG 0x2 /* address failed configure */
126 #define DA_RELE 0x4 /* adddress released */
132 #define RPT_ADDR_ADD 0
133 #define RPT_ADDR_DEL 1
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)))
142 struct kstat_named dam_cycles
;
143 struct kstat_named dam_overrun
;
144 struct kstat_named dam_jitter
;
145 struct kstat_named dam_active
;
152 #endif /* _SYS_DAMAP_IMPL_H */