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