1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte /* 22*63ed874aStim szeto * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23fcf3ce44SJohn Forte * Use is subject to license terms. 24fcf3ce44SJohn Forte */ 25fcf3ce44SJohn Forte #ifndef _LUN_MAP_H 26fcf3ce44SJohn Forte #define _LUN_MAP_H 27fcf3ce44SJohn Forte 28fcf3ce44SJohn Forte #include <sys/stmf_defines.h> 29fcf3ce44SJohn Forte 30fcf3ce44SJohn Forte #ifdef __cplusplus 31fcf3ce44SJohn Forte extern "C" { 32fcf3ce44SJohn Forte #endif 33fcf3ce44SJohn Forte 34fcf3ce44SJohn Forte typedef struct stmf_lun_map { 35fcf3ce44SJohn Forte uint32_t lm_nluns; 36fcf3ce44SJohn Forte uint32_t lm_nentries; 37fcf3ce44SJohn Forte void **lm_plus; /* this can be lun or view entry */ 38fcf3ce44SJohn Forte } stmf_lun_map_t; 39fcf3ce44SJohn Forte 40fcf3ce44SJohn Forte struct stmf_itl_data; 41fcf3ce44SJohn Forte 42fcf3ce44SJohn Forte typedef struct stmf_lun_map_ent { 43fcf3ce44SJohn Forte struct stmf_lu *ent_lu; 44fcf3ce44SJohn Forte struct stmf_itl_data *ent_itl_datap; 45fcf3ce44SJohn Forte } stmf_lun_map_ent_t; 46fcf3ce44SJohn Forte 47fcf3ce44SJohn Forte void stmf_view_init(); 48fcf3ce44SJohn Forte void stmf_view_clear_config(); 49fcf3ce44SJohn Forte stmf_status_t stmf_session_create_lun_map(stmf_i_local_port_t *ilport, 50fcf3ce44SJohn Forte stmf_i_scsi_session_t *iss); 51fcf3ce44SJohn Forte stmf_xfer_data_t *stmf_session_prepare_report_lun_data(stmf_lun_map_t *sm); 52fcf3ce44SJohn Forte void stmf_add_lu_to_active_sessions(stmf_lu_t *lu); 53fcf3ce44SJohn Forte void stmf_session_lu_unmapall(stmf_lu_t *lu); 54fcf3ce44SJohn Forte void *stmf_get_ent_from_map(stmf_lun_map_t *sm, uint16_t lun_num); 55fcf3ce44SJohn Forte 56fcf3ce44SJohn Forte 57fcf3ce44SJohn Forte /* 58fcf3ce44SJohn Forte * Common struct used to maintain an Identifer's data. That Identifier 59fcf3ce44SJohn Forte * can be a Host group, Target group or LU GUID data. Note that a LU is 60fcf3ce44SJohn Forte * different from LU GUID data because either can be there without 61fcf3ce44SJohn Forte * its counterpart being present in the system. 62fcf3ce44SJohn Forte * id_impl_specific pointer to: 63fcf3ce44SJohn Forte * case LUID, a list of stmf_view_entry 64fcf3ce44SJohn Forte * case initiator group, a list of initiators 65fcf3ce44SJohn Forte * case target group, a list of targets 66fcf3ce44SJohn Forte * id_pt_to_object pointer to stmf_i_lu_t instance for LU. 67fcf3ce44SJohn Forte */ 68fcf3ce44SJohn Forte typedef struct stmf_id_data { 69fcf3ce44SJohn Forte struct stmf_id_data *id_next; 70fcf3ce44SJohn Forte struct stmf_id_data *id_prev; 71fcf3ce44SJohn Forte uint32_t id_refcnt; 72fcf3ce44SJohn Forte uint16_t id_type; 73fcf3ce44SJohn Forte uint16_t id_data_size; 74fcf3ce44SJohn Forte uint8_t *id_data; 75fcf3ce44SJohn Forte uint32_t id_total_alloc_size; 76fcf3ce44SJohn Forte uint32_t id_rsvd; 77fcf3ce44SJohn Forte void *id_pt_to_object; 78fcf3ce44SJohn Forte void *id_impl_specific; 79fcf3ce44SJohn Forte } stmf_id_data_t; 80fcf3ce44SJohn Forte 81fcf3ce44SJohn Forte typedef enum { 82fcf3ce44SJohn Forte STMF_ID_TYPE_HOST, 83fcf3ce44SJohn Forte STMF_ID_TYPE_TARGET, 84fcf3ce44SJohn Forte STMF_ID_TYPE_LU_GUID, 85fcf3ce44SJohn Forte STMF_ID_TYPE_HOST_GROUP, 86fcf3ce44SJohn Forte STMF_ID_TYPE_TARGET_GROUP 87fcf3ce44SJohn Forte } stmf_id_type_t; 88fcf3ce44SJohn Forte 89fcf3ce44SJohn Forte typedef struct stmf_id_list { 90fcf3ce44SJohn Forte stmf_id_data_t *idl_head; 91fcf3ce44SJohn Forte stmf_id_data_t *idl_tail; 92fcf3ce44SJohn Forte uint32_t id_count; 93fcf3ce44SJohn Forte } stmf_id_list_t; 94fcf3ce44SJohn Forte 95fcf3ce44SJohn Forte typedef struct stmf_view_entry { 96fcf3ce44SJohn Forte struct stmf_view_entry *ve_next; 97fcf3ce44SJohn Forte struct stmf_view_entry *ve_prev; 98fcf3ce44SJohn Forte uint32_t ve_id; 99fcf3ce44SJohn Forte stmf_id_data_t *ve_hg; 100fcf3ce44SJohn Forte stmf_id_data_t *ve_tg; 101fcf3ce44SJohn Forte stmf_id_data_t *ve_luid; 102fcf3ce44SJohn Forte uint8_t ve_lun[8]; 103fcf3ce44SJohn Forte } stmf_view_entry_t; 104fcf3ce44SJohn Forte 105fcf3ce44SJohn Forte /* 106fcf3ce44SJohn Forte * Following structs are used as an alternate representation of view entries 107fcf3ce44SJohn Forte * in a LU ID. 108fcf3ce44SJohn Forte * ver_tg_root--->ver_tg_t +-> ver_tg_t .... 109fcf3ce44SJohn Forte * | | 110fcf3ce44SJohn Forte * vert_next-+ 111fcf3ce44SJohn Forte * | 112fcf3ce44SJohn Forte * vert_verh_list --> ver_hg_t +-> ver_hg_t .... 113fcf3ce44SJohn Forte * | | 114fcf3ce44SJohn Forte * verh_next-+ 115fcf3ce44SJohn Forte * | 116fcf3ce44SJohn Forte * verh_ve_map (view entry map for this 117fcf3ce44SJohn Forte * target group + host group ) 118fcf3ce44SJohn Forte */ 119fcf3ce44SJohn Forte 120fcf3ce44SJohn Forte typedef struct ver_hg { 121fcf3ce44SJohn Forte struct ver_hg *verh_next; 122fcf3ce44SJohn Forte stmf_id_data_t *verh_hg_ref; /* ref. to the host group */ 123fcf3ce44SJohn Forte stmf_lun_map_t verh_ve_map; 124fcf3ce44SJohn Forte } stmf_ver_hg_t; 125fcf3ce44SJohn Forte 126fcf3ce44SJohn Forte typedef struct ver_tg { 127fcf3ce44SJohn Forte struct ver_tg *vert_next; 128fcf3ce44SJohn Forte stmf_id_data_t *vert_tg_ref; /* ref to target group */ 129fcf3ce44SJohn Forte stmf_ver_hg_t *vert_verh_list; 130fcf3ce44SJohn Forte } stmf_ver_tg_t; 131fcf3ce44SJohn Forte 132fcf3ce44SJohn Forte /* 133fcf3ce44SJohn Forte * flag which define how the merging of maps is to be done. 134fcf3ce44SJohn Forte */ 135fcf3ce44SJohn Forte typedef enum { 136fcf3ce44SJohn Forte MERGE_FLAG_NO_DUPLICATE = 0x01, /* fail upon duplicate */ 137fcf3ce44SJohn Forte MERGE_FLAG_RETURN_NEW_MAP = 0x02, /* Does not modify dst */ 138fcf3ce44SJohn Forte MERGE_FLAG_NONE = 0 139fcf3ce44SJohn Forte } stmf_merge_flags_t; 140fcf3ce44SJohn Forte 141fcf3ce44SJohn Forte int stmf_add_group_member(uint8_t *grpname, uint16_t grpname_size, 142fcf3ce44SJohn Forte uint8_t *entry_ident, uint16_t entry_size, 143fcf3ce44SJohn Forte stmf_id_type_t entry_type, uint32_t *err_detail); 144fcf3ce44SJohn Forte int stmf_remove_group_member(uint8_t *grpname, uint16_t grpname_size, 145fcf3ce44SJohn Forte uint8_t *entry_ident, uint16_t entry_size, 146fcf3ce44SJohn Forte stmf_id_type_t entry_type, uint32_t *err_detail); 147fcf3ce44SJohn Forte int stmf_remove_group(uint8_t *grpname, uint16_t grpname_size, 148fcf3ce44SJohn Forte stmf_id_type_t group_type, uint32_t *err_detail); 149fcf3ce44SJohn Forte int stmf_add_group(uint8_t *grpname, uint16_t grpname_size, 150fcf3ce44SJohn Forte stmf_id_type_t group_type, uint32_t *err_detail); 151fcf3ce44SJohn Forte int stmf_add_ve(uint8_t *hgname, uint16_t hgname_size, uint8_t *tgname, 152fcf3ce44SJohn Forte uint16_t tgname_size, uint8_t *lu_guid, uint32_t *ve_id, 153fcf3ce44SJohn Forte uint8_t *luNbr, uint32_t *err_detail); 154*63ed874aStim szeto int stmf_validate_lun_ve(uint8_t *hgname, uint16_t hgname_size, uint8_t *tgname, 155*63ed874aStim szeto uint16_t tgname_size, uint8_t *luNbr, uint32_t *err_detail); 156fcf3ce44SJohn Forte int stmf_remove_ve_by_id(uint8_t *guid, uint32_t veid, uint32_t *err_detail); 157fcf3ce44SJohn Forte stmf_id_data_t *stmf_lookup_id(stmf_id_list_t *idlist, uint16_t id_size, 158fcf3ce44SJohn Forte uint8_t *data); 159fcf3ce44SJohn Forte stmf_id_data_t *stmf_lookup_group_for_target(uint8_t *ident, 160fcf3ce44SJohn Forte uint16_t ident_size); 161fcf3ce44SJohn Forte 162fcf3ce44SJohn Forte #ifdef __cplusplus 163fcf3ce44SJohn Forte } 164fcf3ce44SJohn Forte #endif 165fcf3ce44SJohn Forte 166fcf3ce44SJohn Forte #endif /* _LUN_MAP_H */ 167