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/*
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _LUN_MAP_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _LUN_MAP_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stmf_defines.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct stmf_lun_map {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t lm_nluns;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t lm_nentries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void **lm_plus; /* this can be lun or view entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_lun_map_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct stmf_itl_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct stmf_lun_map_ent {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_lu *ent_lu;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_itl_data *ent_itl_datap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_lun_map_ent_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid stmf_view_init();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid stmf_view_clear_config();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_status_t stmf_session_create_lun_map(stmf_i_local_port_t *ilport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_i_scsi_session_t *iss);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_status_t stmf_session_destroy_lun_map(stmf_i_local_port_t *ilport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_i_scsi_session_t *iss);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_xfer_data_t *stmf_session_prepare_report_lun_data(stmf_lun_map_t *sm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid stmf_add_lu_to_active_sessions(stmf_lu_t *lu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid stmf_session_lu_unmapall(stmf_lu_t *lu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *stmf_get_ent_from_map(stmf_lun_map_t *sm, uint16_t lun_num);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common struct used to maintain an Identifer's data. That Identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * can be a Host group, Target group or LU GUID data. Note that a LU is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * different from LU GUID data because either can be there without
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * its counterpart being present in the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * id_impl_specific pointer to:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * case LUID, a list of stmf_view_entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * case initiator group, a list of initiators
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * case target group, a list of targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * id_pt_to_object pointer to stmf_i_lu_t instance for LU.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct stmf_id_data {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_id_data *id_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_id_data *id_prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id_refcnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t id_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t id_data_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *id_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id_total_alloc_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id_rsvd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *id_pt_to_object;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *id_impl_specific;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_id_data_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_ID_TYPE_HOST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_ID_TYPE_TARGET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_ID_TYPE_LU_GUID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_ID_TYPE_HOST_GROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_ID_TYPE_TARGET_GROUP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_id_type_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct stmf_id_list {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *idl_head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *idl_tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_id_list_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct stmf_view_entry {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_view_entry *ve_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stmf_view_entry *ve_prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ve_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *ve_hg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *ve_tg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *ve_luid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t ve_lun[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_view_entry_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Following structs are used as an alternate representation of view entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in a LU ID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ver_tg_root--->ver_tg_t +-> ver_tg_t ....
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * vert_next-+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * vert_verh_list --> ver_hg_t +-> ver_hg_t ....
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verh_next-+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verh_ve_map (view entry map for this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target group + host group )
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct ver_hg {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct ver_hg *verh_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *verh_hg_ref; /* ref. to the host group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_lun_map_t verh_ve_map;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_ver_hg_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct ver_tg {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct ver_tg *vert_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_data_t *vert_tg_ref; /* ref to target group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_ver_hg_t *vert_verh_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_ver_tg_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag which define how the merging of maps is to be done.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MERGE_FLAG_NO_DUPLICATE = 0x01, /* fail upon duplicate */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MERGE_FLAG_RETURN_NEW_MAP = 0x02, /* Does not modify dst */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MERGE_FLAG_NONE = 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} stmf_merge_flags_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint stmf_add_group_member(uint8_t *grpname, uint16_t grpname_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *entry_ident, uint16_t entry_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_type_t entry_type, uint32_t *err_detail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint stmf_remove_group_member(uint8_t *grpname, uint16_t grpname_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *entry_ident, uint16_t entry_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_type_t entry_type, uint32_t *err_detail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint stmf_remove_group(uint8_t *grpname, uint16_t grpname_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_type_t group_type, uint32_t *err_detail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint stmf_add_group(uint8_t *grpname, uint16_t grpname_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmf_id_type_t group_type, uint32_t *err_detail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint stmf_add_ve(uint8_t *hgname, uint16_t hgname_size, uint8_t *tgname,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tgname_size, uint8_t *lu_guid, uint32_t *ve_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *luNbr, uint32_t *err_detail);
63ed874a56e20df7e4ec98ba42582352d87386c5tim szetoint stmf_validate_lun_ve(uint8_t *hgname, uint16_t hgname_size, uint8_t *tgname,
63ed874a56e20df7e4ec98ba42582352d87386c5tim szeto uint16_t tgname_size, uint8_t *luNbr, uint32_t *err_detail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint stmf_remove_ve_by_id(uint8_t *guid, uint32_t veid, uint32_t *err_detail);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_id_data_t *stmf_lookup_id(stmf_id_list_t *idlist, uint16_t id_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *data);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_id_data_t *stmf_lookup_group_for_target(uint8_t *ident,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t ident_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _LUN_MAP_H */