xref: /titanic_44/usr/src/cmd/isns/isnsd/isns_dd.h (revision bde3d612a7c090234c60e6e4578821237a5db135)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_ISNS_DD_H
28 #define	_ISNS_DD_H
29 
30 #include <synch.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef uint32_t bmp_t;
37 
38 /*
39  * dd matrix
40  */
41 typedef struct matrix {
42 	uint32_t x, y;
43 	/* uint32_t *z; */ /* obsoleted- map between uid & mid */
44 	/* rwlock_t l; */ /* obsoleted */
45 	bmp_t *m;
46 	struct cache *c;
47 } matrix_t;
48 
49 #define	MATRIX_X_HEADER		(1)
50 #define	MATRIX_X_INFO(X)	(X[0])
51 
52 #define	SIZEOF_X_UNIT(M)	(((M)->x + MATRIX_X_HEADER) * sizeof (bmp_t))
53 #define	MATRIX_X_UNIT(M, N)	&(M)->m[(N) * ((M)->x + MATRIX_X_HEADER)]
54 
55 #define	NUM_OF_MEMBER(M)	((M)->x * sizeof (bmp_t) * 8)
56 #define	UID2MID(M, UID)		get_mid(M, UID)
57 #define	NEW_MID(M, UID)		new_mid(M, UID)
58 
59 #define	GET_PRIMARY(UID)	(UID) / (sizeof (bmp_t) * 8)
60 #define	GET_SECOND(UID)		(UID) % (sizeof (bmp_t) * 8)
61 #define	COMP_UID(PRI, SND)	((PRI) * sizeof (bmp_t) * 8 + (SND))
62 
63 #define	SET_MEMBERSHIP(BMP, PRI, SND)	\
64 	(BMP)[(PRI) + MATRIX_X_HEADER] |= (0x1 << (SND))
65 #define	CLEAR_MEMBERSHIP(BMP, PRI, SND)	\
66 	(BMP)[(PRI) + MATRIX_X_HEADER] &= ~(0x1 << (SND))
67 
68 #define	TEST_MEMBERSHIP(BMP, PRI, SEC) \
69 	((BMP)[(PRI) + MATRIX_X_HEADER] & (0x1 << (SEC)))
70 
71 #define	FOR_EACH_MEMBER(BMP, NUM, UID, STMT) \
72 {\
73 	int i1624 = 0;\
74 	while (i1624 < (NUM)) {\
75 		int j1624 = 0;\
76 		while (j1624 < 8 * sizeof ((BMP)[0])) {\
77 			if (((BMP)[i1624] & (1 << j1624)) != 0) {\
78 				UID = COMP_UID(i1624, j1624);\
79 				STMT\
80 			}\
81 			j1624 ++;\
82 		}\
83 		i1624 ++;\
84 	}\
85 }
86 
87 /* functions */
88 int dd_matrix_init(struct cache *);
89 int create_dd_object(isns_tlv_t *, uint16_t, isns_obj_t **);
90 int create_dds_object(isns_tlv_t *, uint16_t, isns_obj_t **);
91 int adm_create_dd(isns_obj_t **, uchar_t *, uint32_t, uint32_t);
92 int adm_create_dds(isns_obj_t **, uchar_t *, uint32_t, uint32_t);
93 int update_dd_name(uint32_t, uint32_t, uchar_t *);
94 int update_dds_name(uint32_t, uint32_t, uchar_t *);
95 int update_dd_features(uint32_t, uint32_t);
96 int update_dds_status(uint32_t, uint32_t);
97 uint32_t get_dd_id(uint32_t, uint32_t);
98 uint32_t get_dds_id(uint32_t, uint32_t);
99 uint32_t get_common_dd(uint32_t, uint32_t, uint32_t);
100 int remove_dd_object(uint32_t);
101 int remove_dds_object(uint32_t);
102 int add_dd_member(isns_obj_t *);
103 int add_dds_member(isns_obj_t *);
104 int remove_dd_member(isns_obj_t *);
105 int remove_dds_member(uint32_t, uint32_t);
106 int get_dd_matrix(const uint32_t, bmp_t **, uint32_t *);
107 int get_dds_matrix(const uint32_t, bmp_t **, uint32_t *);
108 int get_scope(uchar_t *, bmp_t **, uint32_t *);
109 int cb_clone_attrs(void *, void *);
110 int is_dd_active(uint32_t);
111 int update_ddd(void *, const uchar_t);
112 int verify_ddd(void);
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* _ISNS_DD_H */
119