xref: /onnv-gate/usr/src/cmd/isns/isnsd/isns_dd.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM 
22*7836SJohn.Forte@Sun.COM /*
23*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
25*7836SJohn.Forte@Sun.COM  */
26*7836SJohn.Forte@Sun.COM 
27*7836SJohn.Forte@Sun.COM #ifndef	_ISNS_DD_H
28*7836SJohn.Forte@Sun.COM #define	_ISNS_DD_H
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM #include <synch.h>
31*7836SJohn.Forte@Sun.COM 
32*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
33*7836SJohn.Forte@Sun.COM extern "C" {
34*7836SJohn.Forte@Sun.COM #endif
35*7836SJohn.Forte@Sun.COM 
36*7836SJohn.Forte@Sun.COM typedef uint32_t bmp_t;
37*7836SJohn.Forte@Sun.COM 
38*7836SJohn.Forte@Sun.COM /*
39*7836SJohn.Forte@Sun.COM  * dd matrix
40*7836SJohn.Forte@Sun.COM  */
41*7836SJohn.Forte@Sun.COM typedef struct matrix {
42*7836SJohn.Forte@Sun.COM 	uint32_t x, y;
43*7836SJohn.Forte@Sun.COM 	/* uint32_t *z; */ /* obsoleted- map between uid & mid */
44*7836SJohn.Forte@Sun.COM 	/* rwlock_t l; */ /* obsoleted */
45*7836SJohn.Forte@Sun.COM 	bmp_t *m;
46*7836SJohn.Forte@Sun.COM 	struct cache *c;
47*7836SJohn.Forte@Sun.COM } matrix_t;
48*7836SJohn.Forte@Sun.COM 
49*7836SJohn.Forte@Sun.COM #define	MATRIX_X_HEADER		(1)
50*7836SJohn.Forte@Sun.COM #define	MATRIX_X_INFO(X)	(X[0])
51*7836SJohn.Forte@Sun.COM 
52*7836SJohn.Forte@Sun.COM #define	SIZEOF_X_UNIT(M)	(((M)->x + MATRIX_X_HEADER) * sizeof (bmp_t))
53*7836SJohn.Forte@Sun.COM #define	MATRIX_X_UNIT(M, N)	&(M)->m[(N) * ((M)->x + MATRIX_X_HEADER)]
54*7836SJohn.Forte@Sun.COM 
55*7836SJohn.Forte@Sun.COM #define	NUM_OF_MEMBER(M)	((M)->x * sizeof (bmp_t) * 8)
56*7836SJohn.Forte@Sun.COM #define	UID2MID(M, UID)		get_mid(M, UID)
57*7836SJohn.Forte@Sun.COM #define	NEW_MID(M, UID)		new_mid(M, UID)
58*7836SJohn.Forte@Sun.COM 
59*7836SJohn.Forte@Sun.COM #define	GET_PRIMARY(UID)	(UID) / (sizeof (bmp_t) * 8)
60*7836SJohn.Forte@Sun.COM #define	GET_SECOND(UID)		(UID) % (sizeof (bmp_t) * 8)
61*7836SJohn.Forte@Sun.COM #define	COMP_UID(PRI, SND)	((PRI) * sizeof (bmp_t) * 8 + (SND))
62*7836SJohn.Forte@Sun.COM 
63*7836SJohn.Forte@Sun.COM #define	SET_MEMBERSHIP(BMP, PRI, SND)	\
64*7836SJohn.Forte@Sun.COM 	(BMP)[(PRI) + MATRIX_X_HEADER] |= (0x1 << (SND))
65*7836SJohn.Forte@Sun.COM #define	CLEAR_MEMBERSHIP(BMP, PRI, SND)	\
66*7836SJohn.Forte@Sun.COM 	(BMP)[(PRI) + MATRIX_X_HEADER] &= ~(0x1 << (SND))
67*7836SJohn.Forte@Sun.COM 
68*7836SJohn.Forte@Sun.COM #define	TEST_MEMBERSHIP(BMP, PRI, SEC) \
69*7836SJohn.Forte@Sun.COM 	((BMP)[(PRI) + MATRIX_X_HEADER] & (0x1 << (SEC)))
70*7836SJohn.Forte@Sun.COM 
71*7836SJohn.Forte@Sun.COM #define	FOR_EACH_MEMBER(BMP, NUM, UID, STMT) \
72*7836SJohn.Forte@Sun.COM {\
73*7836SJohn.Forte@Sun.COM 	int i1624 = 0;\
74*7836SJohn.Forte@Sun.COM 	while (i1624 < (NUM)) {\
75*7836SJohn.Forte@Sun.COM 		int j1624 = 0;\
76*7836SJohn.Forte@Sun.COM 		while (j1624 < 8 * sizeof ((BMP)[0])) {\
77*7836SJohn.Forte@Sun.COM 			if (((BMP)[i1624] & (1 << j1624)) != 0) {\
78*7836SJohn.Forte@Sun.COM 				UID = COMP_UID(i1624, j1624);\
79*7836SJohn.Forte@Sun.COM 				STMT\
80*7836SJohn.Forte@Sun.COM 			}\
81*7836SJohn.Forte@Sun.COM 			j1624 ++;\
82*7836SJohn.Forte@Sun.COM 		}\
83*7836SJohn.Forte@Sun.COM 		i1624 ++;\
84*7836SJohn.Forte@Sun.COM 	}\
85*7836SJohn.Forte@Sun.COM }
86*7836SJohn.Forte@Sun.COM 
87*7836SJohn.Forte@Sun.COM /* functions */
88*7836SJohn.Forte@Sun.COM int dd_matrix_init(struct cache *);
89*7836SJohn.Forte@Sun.COM int create_dd_object(isns_tlv_t *, uint16_t, isns_obj_t **);
90*7836SJohn.Forte@Sun.COM int create_dds_object(isns_tlv_t *, uint16_t, isns_obj_t **);
91*7836SJohn.Forte@Sun.COM int adm_create_dd(isns_obj_t **, uchar_t *, uint32_t, uint32_t);
92*7836SJohn.Forte@Sun.COM int adm_create_dds(isns_obj_t **, uchar_t *, uint32_t, uint32_t);
93*7836SJohn.Forte@Sun.COM int update_dd_name(uint32_t, uint32_t, uchar_t *);
94*7836SJohn.Forte@Sun.COM int update_dds_name(uint32_t, uint32_t, uchar_t *);
95*7836SJohn.Forte@Sun.COM int update_dd_features(uint32_t, uint32_t);
96*7836SJohn.Forte@Sun.COM int update_dds_status(uint32_t, uint32_t);
97*7836SJohn.Forte@Sun.COM uint32_t get_dd_id(uint32_t, uint32_t);
98*7836SJohn.Forte@Sun.COM uint32_t get_dds_id(uint32_t, uint32_t);
99*7836SJohn.Forte@Sun.COM uint32_t get_common_dd(uint32_t, uint32_t, uint32_t);
100*7836SJohn.Forte@Sun.COM int remove_dd_object(uint32_t);
101*7836SJohn.Forte@Sun.COM int remove_dds_object(uint32_t);
102*7836SJohn.Forte@Sun.COM int add_dd_member(isns_obj_t *);
103*7836SJohn.Forte@Sun.COM int add_dds_member(isns_obj_t *);
104*7836SJohn.Forte@Sun.COM int remove_dd_member(isns_obj_t *);
105*7836SJohn.Forte@Sun.COM int remove_dds_member(uint32_t, uint32_t);
106*7836SJohn.Forte@Sun.COM int get_dd_matrix(const uint32_t, bmp_t **, uint32_t *);
107*7836SJohn.Forte@Sun.COM int get_dds_matrix(const uint32_t, bmp_t **, uint32_t *);
108*7836SJohn.Forte@Sun.COM int get_scope(uchar_t *, bmp_t **, uint32_t *);
109*7836SJohn.Forte@Sun.COM int cb_clone_attrs(void *, void *);
110*7836SJohn.Forte@Sun.COM int is_dd_active(uint32_t);
111*7836SJohn.Forte@Sun.COM int update_ddd(void *, const uchar_t);
112*7836SJohn.Forte@Sun.COM int verify_ddd(void);
113*7836SJohn.Forte@Sun.COM 
114*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
115*7836SJohn.Forte@Sun.COM }
116*7836SJohn.Forte@Sun.COM #endif
117*7836SJohn.Forte@Sun.COM 
118*7836SJohn.Forte@Sun.COM #endif /* _ISNS_DD_H */
119