17836SJohn.Forte@Sun.COM /* 27836SJohn.Forte@Sun.COM * CDDL HEADER START 37836SJohn.Forte@Sun.COM * 47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 77836SJohn.Forte@Sun.COM * 87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 117836SJohn.Forte@Sun.COM * and limitations under the License. 127836SJohn.Forte@Sun.COM * 137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187836SJohn.Forte@Sun.COM * 197836SJohn.Forte@Sun.COM * CDDL HEADER END 207836SJohn.Forte@Sun.COM */ 217836SJohn.Forte@Sun.COM /* 22*10691STim.Szeto@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237836SJohn.Forte@Sun.COM * Use is subject to license terms. 247836SJohn.Forte@Sun.COM */ 257836SJohn.Forte@Sun.COM #ifndef _LUN_MAP_H 267836SJohn.Forte@Sun.COM #define _LUN_MAP_H 277836SJohn.Forte@Sun.COM 287836SJohn.Forte@Sun.COM #include <sys/stmf_defines.h> 297836SJohn.Forte@Sun.COM 307836SJohn.Forte@Sun.COM #ifdef __cplusplus 317836SJohn.Forte@Sun.COM extern "C" { 327836SJohn.Forte@Sun.COM #endif 337836SJohn.Forte@Sun.COM 347836SJohn.Forte@Sun.COM typedef struct stmf_lun_map { 357836SJohn.Forte@Sun.COM uint32_t lm_nluns; 367836SJohn.Forte@Sun.COM uint32_t lm_nentries; 377836SJohn.Forte@Sun.COM void **lm_plus; /* this can be lun or view entry */ 387836SJohn.Forte@Sun.COM } stmf_lun_map_t; 397836SJohn.Forte@Sun.COM 407836SJohn.Forte@Sun.COM struct stmf_itl_data; 417836SJohn.Forte@Sun.COM 427836SJohn.Forte@Sun.COM typedef struct stmf_lun_map_ent { 437836SJohn.Forte@Sun.COM struct stmf_lu *ent_lu; 447836SJohn.Forte@Sun.COM struct stmf_itl_data *ent_itl_datap; 457836SJohn.Forte@Sun.COM } stmf_lun_map_ent_t; 467836SJohn.Forte@Sun.COM 477836SJohn.Forte@Sun.COM void stmf_view_init(); 487836SJohn.Forte@Sun.COM void stmf_view_clear_config(); 497836SJohn.Forte@Sun.COM stmf_status_t stmf_session_create_lun_map(stmf_i_local_port_t *ilport, 507836SJohn.Forte@Sun.COM stmf_i_scsi_session_t *iss); 517836SJohn.Forte@Sun.COM stmf_status_t stmf_session_destroy_lun_map(stmf_i_local_port_t *ilport, 527836SJohn.Forte@Sun.COM stmf_i_scsi_session_t *iss); 537836SJohn.Forte@Sun.COM stmf_xfer_data_t *stmf_session_prepare_report_lun_data(stmf_lun_map_t *sm); 547836SJohn.Forte@Sun.COM void stmf_add_lu_to_active_sessions(stmf_lu_t *lu); 557836SJohn.Forte@Sun.COM void stmf_session_lu_unmapall(stmf_lu_t *lu); 567836SJohn.Forte@Sun.COM void *stmf_get_ent_from_map(stmf_lun_map_t *sm, uint16_t lun_num); 577836SJohn.Forte@Sun.COM 587836SJohn.Forte@Sun.COM 597836SJohn.Forte@Sun.COM /* 607836SJohn.Forte@Sun.COM * Common struct used to maintain an Identifer's data. That Identifier 617836SJohn.Forte@Sun.COM * can be a Host group, Target group or LU GUID data. Note that a LU is 627836SJohn.Forte@Sun.COM * different from LU GUID data because either can be there without 637836SJohn.Forte@Sun.COM * its counterpart being present in the system. 647836SJohn.Forte@Sun.COM * id_impl_specific pointer to: 657836SJohn.Forte@Sun.COM * case LUID, a list of stmf_view_entry 667836SJohn.Forte@Sun.COM * case initiator group, a list of initiators 677836SJohn.Forte@Sun.COM * case target group, a list of targets 687836SJohn.Forte@Sun.COM * id_pt_to_object pointer to stmf_i_lu_t instance for LU. 697836SJohn.Forte@Sun.COM */ 707836SJohn.Forte@Sun.COM typedef struct stmf_id_data { 717836SJohn.Forte@Sun.COM struct stmf_id_data *id_next; 727836SJohn.Forte@Sun.COM struct stmf_id_data *id_prev; 737836SJohn.Forte@Sun.COM uint32_t id_refcnt; 747836SJohn.Forte@Sun.COM uint16_t id_type; 757836SJohn.Forte@Sun.COM uint16_t id_data_size; 767836SJohn.Forte@Sun.COM uint8_t *id_data; 777836SJohn.Forte@Sun.COM uint32_t id_total_alloc_size; 787836SJohn.Forte@Sun.COM uint32_t id_rsvd; 797836SJohn.Forte@Sun.COM void *id_pt_to_object; 807836SJohn.Forte@Sun.COM void *id_impl_specific; 817836SJohn.Forte@Sun.COM } stmf_id_data_t; 827836SJohn.Forte@Sun.COM 837836SJohn.Forte@Sun.COM typedef enum { 847836SJohn.Forte@Sun.COM STMF_ID_TYPE_HOST, 857836SJohn.Forte@Sun.COM STMF_ID_TYPE_TARGET, 867836SJohn.Forte@Sun.COM STMF_ID_TYPE_LU_GUID, 877836SJohn.Forte@Sun.COM STMF_ID_TYPE_HOST_GROUP, 887836SJohn.Forte@Sun.COM STMF_ID_TYPE_TARGET_GROUP 897836SJohn.Forte@Sun.COM } stmf_id_type_t; 907836SJohn.Forte@Sun.COM 917836SJohn.Forte@Sun.COM typedef struct stmf_id_list { 927836SJohn.Forte@Sun.COM stmf_id_data_t *idl_head; 937836SJohn.Forte@Sun.COM stmf_id_data_t *idl_tail; 947836SJohn.Forte@Sun.COM uint32_t id_count; 957836SJohn.Forte@Sun.COM } stmf_id_list_t; 967836SJohn.Forte@Sun.COM 977836SJohn.Forte@Sun.COM typedef struct stmf_view_entry { 987836SJohn.Forte@Sun.COM struct stmf_view_entry *ve_next; 997836SJohn.Forte@Sun.COM struct stmf_view_entry *ve_prev; 1007836SJohn.Forte@Sun.COM uint32_t ve_id; 1017836SJohn.Forte@Sun.COM stmf_id_data_t *ve_hg; 1027836SJohn.Forte@Sun.COM stmf_id_data_t *ve_tg; 1037836SJohn.Forte@Sun.COM stmf_id_data_t *ve_luid; 1047836SJohn.Forte@Sun.COM uint8_t ve_lun[8]; 1057836SJohn.Forte@Sun.COM } stmf_view_entry_t; 1067836SJohn.Forte@Sun.COM 1077836SJohn.Forte@Sun.COM /* 1087836SJohn.Forte@Sun.COM * Following structs are used as an alternate representation of view entries 1097836SJohn.Forte@Sun.COM * in a LU ID. 1107836SJohn.Forte@Sun.COM * ver_tg_root--->ver_tg_t +-> ver_tg_t .... 1117836SJohn.Forte@Sun.COM * | | 1127836SJohn.Forte@Sun.COM * vert_next-+ 1137836SJohn.Forte@Sun.COM * | 1147836SJohn.Forte@Sun.COM * vert_verh_list --> ver_hg_t +-> ver_hg_t .... 1157836SJohn.Forte@Sun.COM * | | 1167836SJohn.Forte@Sun.COM * verh_next-+ 1177836SJohn.Forte@Sun.COM * | 1187836SJohn.Forte@Sun.COM * verh_ve_map (view entry map for this 1197836SJohn.Forte@Sun.COM * target group + host group ) 1207836SJohn.Forte@Sun.COM */ 1217836SJohn.Forte@Sun.COM 1227836SJohn.Forte@Sun.COM typedef struct ver_hg { 1237836SJohn.Forte@Sun.COM struct ver_hg *verh_next; 1247836SJohn.Forte@Sun.COM stmf_id_data_t *verh_hg_ref; /* ref. to the host group */ 1257836SJohn.Forte@Sun.COM stmf_lun_map_t verh_ve_map; 1267836SJohn.Forte@Sun.COM } stmf_ver_hg_t; 1277836SJohn.Forte@Sun.COM 1287836SJohn.Forte@Sun.COM typedef struct ver_tg { 1297836SJohn.Forte@Sun.COM struct ver_tg *vert_next; 1307836SJohn.Forte@Sun.COM stmf_id_data_t *vert_tg_ref; /* ref to target group */ 1317836SJohn.Forte@Sun.COM stmf_ver_hg_t *vert_verh_list; 1327836SJohn.Forte@Sun.COM } stmf_ver_tg_t; 1337836SJohn.Forte@Sun.COM 1347836SJohn.Forte@Sun.COM /* 1357836SJohn.Forte@Sun.COM * flag which define how the merging of maps is to be done. 1367836SJohn.Forte@Sun.COM */ 1377836SJohn.Forte@Sun.COM typedef enum { 1387836SJohn.Forte@Sun.COM MERGE_FLAG_NO_DUPLICATE = 0x01, /* fail upon duplicate */ 1397836SJohn.Forte@Sun.COM MERGE_FLAG_RETURN_NEW_MAP = 0x02, /* Does not modify dst */ 1407836SJohn.Forte@Sun.COM MERGE_FLAG_NONE = 0 1417836SJohn.Forte@Sun.COM } stmf_merge_flags_t; 1427836SJohn.Forte@Sun.COM 1437836SJohn.Forte@Sun.COM int stmf_add_group_member(uint8_t *grpname, uint16_t grpname_size, 1447836SJohn.Forte@Sun.COM uint8_t *entry_ident, uint16_t entry_size, 1457836SJohn.Forte@Sun.COM stmf_id_type_t entry_type, uint32_t *err_detail); 1467836SJohn.Forte@Sun.COM int stmf_remove_group_member(uint8_t *grpname, uint16_t grpname_size, 1477836SJohn.Forte@Sun.COM uint8_t *entry_ident, uint16_t entry_size, 1487836SJohn.Forte@Sun.COM stmf_id_type_t entry_type, uint32_t *err_detail); 1497836SJohn.Forte@Sun.COM int stmf_remove_group(uint8_t *grpname, uint16_t grpname_size, 1507836SJohn.Forte@Sun.COM stmf_id_type_t group_type, uint32_t *err_detail); 1517836SJohn.Forte@Sun.COM int stmf_add_group(uint8_t *grpname, uint16_t grpname_size, 1527836SJohn.Forte@Sun.COM stmf_id_type_t group_type, uint32_t *err_detail); 1537836SJohn.Forte@Sun.COM int stmf_add_ve(uint8_t *hgname, uint16_t hgname_size, uint8_t *tgname, 1547836SJohn.Forte@Sun.COM uint16_t tgname_size, uint8_t *lu_guid, uint32_t *ve_id, 1557836SJohn.Forte@Sun.COM uint8_t *luNbr, uint32_t *err_detail); 156*10691STim.Szeto@Sun.COM int stmf_validate_lun_ve(uint8_t *hgname, uint16_t hgname_size, uint8_t *tgname, 157*10691STim.Szeto@Sun.COM uint16_t tgname_size, uint8_t *luNbr, uint32_t *err_detail); 1587836SJohn.Forte@Sun.COM int stmf_remove_ve_by_id(uint8_t *guid, uint32_t veid, uint32_t *err_detail); 1597836SJohn.Forte@Sun.COM stmf_id_data_t *stmf_lookup_id(stmf_id_list_t *idlist, uint16_t id_size, 1607836SJohn.Forte@Sun.COM uint8_t *data); 1617836SJohn.Forte@Sun.COM stmf_id_data_t *stmf_lookup_group_for_target(uint8_t *ident, 1627836SJohn.Forte@Sun.COM uint16_t ident_size); 1637836SJohn.Forte@Sun.COM 1647836SJohn.Forte@Sun.COM #ifdef __cplusplus 1657836SJohn.Forte@Sun.COM } 1667836SJohn.Forte@Sun.COM #endif 1677836SJohn.Forte@Sun.COM 1687836SJohn.Forte@Sun.COM #endif /* _LUN_MAP_H */ 169