fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _ISNS_DD_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _ISNS_DD_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <synch.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef uint32_t bmp_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dd matrix
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct matrix {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x, y;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* uint32_t *z; */ /* obsoleted- map between uid & mid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rwlock_t l; */ /* obsoleted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *m;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct cache *c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} matrix_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MATRIX_X_HEADER (1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MATRIX_X_INFO(X) (X[0])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SIZEOF_X_UNIT(M) (((M)->x + MATRIX_X_HEADER) * sizeof (bmp_t))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MATRIX_X_UNIT(M, N) &(M)->m[(N) * ((M)->x + MATRIX_X_HEADER)]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NUM_OF_MEMBER(M) ((M)->x * sizeof (bmp_t) * 8)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define UID2MID(M, UID) get_mid(M, UID)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NEW_MID(M, UID) new_mid(M, UID)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define GET_PRIMARY(UID) (UID) / (sizeof (bmp_t) * 8)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define GET_SECOND(UID) (UID) % (sizeof (bmp_t) * 8)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define COMP_UID(PRI, SND) ((PRI) * sizeof (bmp_t) * 8 + (SND))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SET_MEMBERSHIP(BMP, PRI, SND) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (BMP)[(PRI) + MATRIX_X_HEADER] |= (0x1 << (SND))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CLEAR_MEMBERSHIP(BMP, PRI, SND) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (BMP)[(PRI) + MATRIX_X_HEADER] &= ~(0x1 << (SND))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define TEST_MEMBERSHIP(BMP, PRI, SEC) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((BMP)[(PRI) + MATRIX_X_HEADER] & (0x1 << (SEC)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FOR_EACH_MEMBER(BMP, NUM, UID, STMT) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i1624 = 0;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i1624 < (NUM)) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j1624 = 0;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (j1624 < 8 * sizeof ((BMP)[0])) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((BMP)[i1624] & (1 << j1624)) != 0) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UID = COMP_UID(i1624, j1624);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMT\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j1624 ++;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i1624 ++;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint dd_matrix_init(struct cache *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint create_dd_object(isns_tlv_t *, uint16_t, isns_obj_t **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint create_dds_object(isns_tlv_t *, uint16_t, isns_obj_t **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint adm_create_dd(isns_obj_t **, uchar_t *, uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint adm_create_dds(isns_obj_t **, uchar_t *, uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint update_dd_name(uint32_t, uint32_t, uchar_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint update_dds_name(uint32_t, uint32_t, uchar_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint update_dd_features(uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint update_dds_status(uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t get_dd_id(uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t get_dds_id(uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t get_common_dd(uint32_t, uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint remove_dd_object(uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint remove_dds_object(uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint add_dd_member(isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint add_dds_member(isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint remove_dd_member(isns_obj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint remove_dds_member(uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint get_dd_matrix(const uint32_t, bmp_t **, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint get_dds_matrix(const uint32_t, bmp_t **, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint get_scope(uchar_t *, bmp_t **, uint32_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint cb_clone_attrs(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint is_dd_active(uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint update_ddd(void *, const uchar_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint verify_ddd(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _ISNS_DD_H */