1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H 27 #define _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL) 34 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 35 #endif /* _BIT_FIELDS_LTOH */ 36 37 38 #include <sys/scsi/adapters/mpapi_impl.h> 39 40 #define MPAPI_SCSI_MAXPCLASSLEN 25 41 42 /* Structure for MP_OID (kernel level only) */ 43 44 typedef struct mp_oid { 45 #if defined(_BIT_FIELDS_HTOL) 46 uint32_t tstamp; 47 uint32_t type:8, 48 seq_id:24; 49 #else 50 uint32_t seq_id:24, 51 type:8; 52 uint32_t tstamp; 53 #endif 54 } mp_oid_t; 55 56 typedef union mpoid { 57 uint64_t raw_oid; /* raw oid */ 58 mp_oid_t disc_oid; /* discrete oid */ 59 } mpoid_t; 60 61 62 /* 63 * MP API item - A generic one to use in a list setup 64 * in a common way for all types of elements of 65 * Object type items required for mpapi. 66 */ 67 68 typedef struct mpapi_item { 69 mpoid_t oid; 70 void *idata; /* item data */ 71 kmutex_t item_mutex; 72 } mpapi_item_t; 73 74 typedef struct mpapi_item_list { 75 mpapi_item_t *item; 76 struct mpapi_item_list *next; 77 } mpapi_item_list_t; 78 79 /* 80 * MP API item header definition. 81 */ 82 83 typedef struct mpapi_list_header { 84 mpapi_item_list_t *head; 85 mpapi_item_list_t *tail; 86 } mpapi_list_header_t; 87 88 /* 89 * Structure to maintain mpapi initiator data. 90 */ 91 typedef struct mpapi_initiator_data { 92 void *resp; /* initiator-port prop */ 93 mpapi_list_header_t *path_list; 94 int valid; 95 mp_init_port_prop_t prop; 96 } mpapi_initiator_data_t; 97 98 /* 99 * Structure to maintain mpapi lu data. 100 */ 101 typedef struct mpapi_lu_data { 102 void *resp; /* vlun */ 103 mpapi_list_header_t *path_list; 104 mpapi_list_header_t *tpg_list; 105 int valid; 106 mp_logical_unit_prop_t prop; 107 } mpapi_lu_data_t; 108 109 /* 110 * Structure to maintain mpapi path data. 111 * 112 * The hide flag is set when pip was detroyed or should 113 * have been destroyed(MDI_PATHINFO_FLAGS_DEVICE_REMOVED). 114 * The valid flag is set to 0 when the path is neither online 115 * nor standby state. When hide flag is set the valid flag set 116 * to 0 also. 117 */ 118 typedef struct mpapi_path_data { 119 void *resp; /* pip */ 120 char *path_name; 121 int valid; 122 int hide; 123 char pclass[MPAPI_SCSI_MAXPCLASSLEN]; 124 mp_path_prop_t prop; 125 } mpapi_path_data_t; 126 127 /* 128 * Structure to maintain mpapi tpg data. 129 */ 130 typedef struct mpapi_tpg_data { 131 void *resp; 132 mpapi_list_header_t *tport_list; 133 mpapi_list_header_t *lu_list; /* mpath lu or lun list */ 134 int valid; 135 char pclass[MPAPI_SCSI_MAXPCLASSLEN]; 136 mp_tpg_prop_t prop; 137 } mpapi_tpg_data_t; 138 139 /* 140 * Structure to maintain mpapi tport data. 141 */ 142 typedef struct mpapi_tport_data { 143 void *resp; /* target port prop */ 144 mpapi_list_header_t *path_list; 145 int valid; 146 mp_target_port_prop_t prop; 147 } mpapi_tport_data_t; 148 149 150 /* Structure for mpapi private data */ 151 152 typedef struct mpapi_priv { 153 154 /* 155 * Will be initialized with tod(time of day) 156 * This will enable detection of stale OIDs used by the upper layers. 157 */ 158 uint32_t tstamp; 159 /* 160 * The Sequence number space is unique within an Object Type - 161 * that is there can be a seq# 2 in Object Type "initiator port" 162 * and also a seq#2 in object type 'Path LU'. 163 * Even though the Seq# space collides, the Object type field 164 * will make the OIDs unique. 165 * The following field will indicate what the next sequence number 166 * that can be used for a particular type of Object type - 167 * Object type will be used to index into the array element. 168 */ 169 uint32_t oid_seq[MP_MAX_OBJECT_TYPE]; 170 171 /* 172 * One list for each type of object. 173 */ 174 mpapi_list_header_t *obj_hdr_list[MP_MAX_OBJECT_TYPE]; 175 176 } mpapi_priv_t; 177 178 #ifdef __cplusplus 179 } 180 #endif 181 182 #endif /* _SYS_SCSI_ADAPTERS_MPAPI_SCSI_VHCI_H */ 183