xref: /titanic_50/usr/src/uts/common/sys/damap.h (revision 4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6)
1*4c06356bSdh142964 /*
2*4c06356bSdh142964  * CDDL HEADER START
3*4c06356bSdh142964  *
4*4c06356bSdh142964  * The contents of this file are subject to the terms of the
5*4c06356bSdh142964  * Common Development and Distribution License (the "License").
6*4c06356bSdh142964  * You may not use this file except in compliance with the License.
7*4c06356bSdh142964  *
8*4c06356bSdh142964  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*4c06356bSdh142964  * or http://www.opensolaris.org/os/licensing.
10*4c06356bSdh142964  * See the License for the specific language governing permissions
11*4c06356bSdh142964  * and limitations under the License.
12*4c06356bSdh142964  *
13*4c06356bSdh142964  * When distributing Covered Code, include this CDDL HEADER in each
14*4c06356bSdh142964  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*4c06356bSdh142964  * If applicable, add the following below this CDDL HEADER, with the
16*4c06356bSdh142964  * fields enclosed by brackets "[]" replaced with your own identifying
17*4c06356bSdh142964  * information: Portions Copyright [yyyy] [name of copyright owner]
18*4c06356bSdh142964  *
19*4c06356bSdh142964  * CDDL HEADER END
20*4c06356bSdh142964  */
21*4c06356bSdh142964 
22*4c06356bSdh142964 /*
23*4c06356bSdh142964  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*4c06356bSdh142964  * Use is subject to license terms.
25*4c06356bSdh142964  */
26*4c06356bSdh142964 
27*4c06356bSdh142964 #ifndef	_SYS_DAMAP_H
28*4c06356bSdh142964 #define	_SYS_DAMAP_H
29*4c06356bSdh142964 
30*4c06356bSdh142964 #ifdef	__cplusplus
31*4c06356bSdh142964 extern "C" {
32*4c06356bSdh142964 #endif
33*4c06356bSdh142964 
34*4c06356bSdh142964 /*
35*4c06356bSdh142964  * Delta (device) Address Map Interfaces
36*4c06356bSdh142964  *
37*4c06356bSdh142964  * These interfaces provide time-stablized sets of 'addresses',
38*4c06356bSdh142964  * where addresses are string representations of device
39*4c06356bSdh142964  * or bus-specific address.  The mechanisms include interfaces to
40*4c06356bSdh142964  * report and remove address from a map, time stabilization, callouts
41*4c06356bSdh142964  * to higher-level configuration and unconfiguration actions, and
42*4c06356bSdh142964  * address lookup functions.
43*4c06356bSdh142964  *
44*4c06356bSdh142964  * Per Address Reports
45*4c06356bSdh142964  * With per-address reporting, the caller reports the addition and removal
46*4c06356bSdh142964  * each address visible to it. Each report is independently time stabilized;
47*4c06356bSdh142964  * Once a report has stabilized, the reported address is either
48*4c06356bSdh142964  * activated & configured, or unconfigured & released.
49*4c06356bSdh142964  *
50*4c06356bSdh142964  * Full Set Reports
51*4c06356bSdh142964  * When using fullset reporting, the report provider enumerates the entire
52*4c06356bSdh142964  * set of addresses visible to the provider at a given point in time.
53*4c06356bSdh142964  * The entire set is then stabilized.
54*4c06356bSdh142964  * Upon stabilizing, any newly reported addresses are activated & configured
55*4c06356bSdh142964  * and any previously active addresses which are no longer visible are
56*4c06356bSdh142964  * automatically unconfigured and released, freeing the provider from
57*4c06356bSdh142964  * the need to explicitly unconfigure addresses no longer present.
58*4c06356bSdh142964  *
59*4c06356bSdh142964  * Stabilization
60*4c06356bSdh142964  * Once an address has been reported (or reported as removed), the report
61*4c06356bSdh142964  * is time stabilized before the framework initiates a configuration
62*4c06356bSdh142964  * or unconfiguration action.  If the address is re-reported while undergoing
63*4c06356bSdh142964  * stabilization, the timer is reset for either the address or the full
64*4c06356bSdh142964  * set of addresses reported to the map.
65*4c06356bSdh142964  *
66*4c06356bSdh142964  * Activation/Release
67*4c06356bSdh142964  * Once a reported address has passed its stabilization, the address is
68*4c06356bSdh142964  * 'activated' by the framework.  Once activated, the address is passed
69*4c06356bSdh142964  * to a configuration callout to perform whatever actions are necessary.
70*4c06356bSdh142964  * If a reported address is deleted or fails to stabilize, the address
71*4c06356bSdh142964  * is released by the map.
72*4c06356bSdh142964  * A report provider may register callback functions to be invoked
73*4c06356bSdh142964  * as part of the address activation & release process.  In addition to
74*4c06356bSdh142964  * the callbacks, a provider can also supply a handle to provider-private
75*4c06356bSdh142964  * data at the time an address is reported.  This handle is returned to
76*4c06356bSdh142964  * provider as an argument to the activation & release callbacks.
77*4c06356bSdh142964  *
78*4c06356bSdh142964  * Lookup/Access
79*4c06356bSdh142964  * The set of stable addresses contained in a map can be obtained by
80*4c06356bSdh142964  * calling interfaces to lookup either a single address or the full
81*4c06356bSdh142964  * list of stable addresses.
82*4c06356bSdh142964  */
83*4c06356bSdh142964 
84*4c06356bSdh142964 /*
85*4c06356bSdh142964  * damap_t:		Handle to a delta address map
86*4c06356bSdh142964  * damap_id_t:  	Handle to an entry of damap_t
87*4c06356bSdh142964  * damap_id_list_t:	List of damap_id_handles
88*4c06356bSdh142964  */
89*4c06356bSdh142964 typedef struct __damap_dm *damap_t;
90*4c06356bSdh142964 typedef struct __damap_id_list *damap_id_list_t;
91*4c06356bSdh142964 typedef id_t damap_id_t;
92*4c06356bSdh142964 
93*4c06356bSdh142964 #define	NODAM (damap_id_t)0
94*4c06356bSdh142964 
95*4c06356bSdh142964 /*
96*4c06356bSdh142964  * activate_cb:		Provider callback when reported address is activated
97*4c06356bSdh142964  * deactivate_cb:	Provider callback when address has been released
98*4c06356bSdh142964  *
99*4c06356bSdh142964  * configure_cb:	Class callout to configure newly activated addresses
100*4c06356bSdh142964  * unconfig_cb:		Class callout to unconfigure deactivated addresses
101*4c06356bSdh142964  */
102*4c06356bSdh142964 typedef void (*damap_activate_cb_t)(void *, char *, int, void **);
103*4c06356bSdh142964 typedef void (*damap_deactivate_cb_t)(void *, char *, int, void *);
104*4c06356bSdh142964 
105*4c06356bSdh142964 typedef void (*damap_configure_cb_t)(void *, damap_t *, damap_id_list_t);
106*4c06356bSdh142964 typedef void (*damap_unconfig_cb_t)(void *, damap_t *, damap_id_list_t);
107*4c06356bSdh142964 
108*4c06356bSdh142964 /*
109*4c06356bSdh142964  * Map reporting mode
110*4c06356bSdh142964  */
111*4c06356bSdh142964 typedef enum {DAMAP_REPORT_PERADDR, DAMAP_REPORT_FULLSET} damap_rptmode_t;
112*4c06356bSdh142964 
113*4c06356bSdh142964 #define	DAMAP_RESET 1		/* flag to damap_addrset_end */
114*4c06356bSdh142964 
115*4c06356bSdh142964 int	damap_create(char *, size_t, damap_rptmode_t, clock_t,
116*4c06356bSdh142964 	    void *, damap_activate_cb_t, damap_deactivate_cb_t,
117*4c06356bSdh142964 	    void *, damap_configure_cb_t, damap_unconfig_cb_t,
118*4c06356bSdh142964 	    damap_t **);
119*4c06356bSdh142964 void	damap_destroy(damap_t *);
120*4c06356bSdh142964 
121*4c06356bSdh142964 char	*damap_name(damap_t *);
122*4c06356bSdh142964 int	damap_sync(damap_t *);
123*4c06356bSdh142964 
124*4c06356bSdh142964 int	damap_addr_add(damap_t *, char *, damap_id_t *, nvlist_t *, void *);
125*4c06356bSdh142964 int	damap_addr_del(damap_t *, char *);
126*4c06356bSdh142964 int	damap_addrid_del(damap_t *, int);
127*4c06356bSdh142964 
128*4c06356bSdh142964 int	damap_addrset_begin(damap_t *);
129*4c06356bSdh142964 int	damap_addrset_add(damap_t *, char *, damap_id_t *, nvlist_t *, void *);
130*4c06356bSdh142964 int	damap_addrset_end(damap_t *, int);
131*4c06356bSdh142964 int	damap_addrset_reset(damap_t *, int);
132*4c06356bSdh142964 
133*4c06356bSdh142964 damap_id_t	damap_id_next(damap_t *, damap_id_list_t, damap_id_t);
134*4c06356bSdh142964 char		*damap_id2addr(damap_t *, damap_id_t);
135*4c06356bSdh142964 nvlist_t	*damap_id2nvlist(damap_t *, damap_id_t);
136*4c06356bSdh142964 int		damap_id_hold(damap_t *, damap_id_t);
137*4c06356bSdh142964 void		damap_id_rele(damap_t *, damap_id_t);
138*4c06356bSdh142964 int		damap_id_ref(damap_t *, damap_id_t);
139*4c06356bSdh142964 void		damap_id_list_rele(damap_t *, damap_id_list_t);
140*4c06356bSdh142964 void		*damap_id_priv_get(damap_t *, damap_id_t);
141*4c06356bSdh142964 void		damap_id_priv_set(damap_t *, damap_id_t, void *);
142*4c06356bSdh142964 damap_id_t	damap_lookup(damap_t *, char *);
143*4c06356bSdh142964 int		damap_lookup_all(damap_t *, damap_id_list_t *);
144*4c06356bSdh142964 
145*4c06356bSdh142964 #define	DAM_SUCCESS	0
146*4c06356bSdh142964 #define	DAM_EEXIST	1
147*4c06356bSdh142964 #define	DAM_MAPFULL	2
148*4c06356bSdh142964 #define	DAM_EINVAL	3
149*4c06356bSdh142964 #define	DAM_FAILURE	4
150*4c06356bSdh142964 #define	DAM_SHAME	5
151*4c06356bSdh142964 
152*4c06356bSdh142964 #ifdef	__cplusplus
153*4c06356bSdh142964 }
154*4c06356bSdh142964 #endif
155*4c06356bSdh142964 
156*4c06356bSdh142964 #endif	/* _SYS_DAMAP_H */
157