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 _LIBSTMF_H 27 #define _LIBSTMF_H 28 29 #include <time.h> 30 #include <sys/param.h> 31 #include <libnvpair.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* Constants and Types */ 38 39 /* LU and Local Port states */ 40 #define STMF_LOGICAL_UNIT_OFFLINE 0 41 #define STMF_LOGICAL_UNIT_OFFLINING 1 42 #define STMF_LOGICAL_UNIT_ONLINE 2 43 #define STMF_LOGICAL_UNIT_ONLINING 3 44 #define STMF_LOGICAL_UNIT_UNREGISTERED 4 45 #define STMF_TARGET_PORT_OFFLINE 5 46 #define STMF_TARGET_PORT_OFFLINING 6 47 #define STMF_TARGET_PORT_ONLINE 7 48 #define STMF_TARGET_PORT_ONLINING 8 49 #define STMF_SERVICE_STATE_ONLINE 9 50 #define STMF_SERVICE_STATE_OFFLINE 10 51 #define STMF_SERVICE_STATE_ONLINING 11 52 #define STMF_SERVICE_STATE_OFFLINING 12 53 #define STMF_SERVICE_STATE_UNKNOWN 13 54 #define STMF_CONFIG_STATE_NONE 14 55 #define STMF_CONFIG_STATE_INIT 15 56 #define STMF_CONFIG_STATE_INIT_DONE 16 57 #define STMF_CONFIG_STATE_UNKNOWN 17 58 59 #define STMF_IDENT_LENGTH 255 60 61 /* API status return values */ 62 #define STMF_STATUS_SUCCESS 0x0000 63 #define STMF_STATUS_ERROR 0x8000 64 #define STMF_ERROR_BUSY (STMF_STATUS_ERROR | 0x01) 65 #define STMF_ERROR_NOT_FOUND (STMF_STATUS_ERROR | 0x02) 66 #define STMF_ERROR_MEMBER_NOT_FOUND (STMF_STATUS_ERROR | 0x03) 67 #define STMF_ERROR_GROUP_NOT_FOUND (STMF_STATUS_ERROR | 0x04) 68 #define STMF_ERROR_PERM (STMF_STATUS_ERROR | 0x05) 69 #define STMF_ERROR_NOMEM (STMF_STATUS_ERROR | 0x06) 70 #define STMF_ERROR_INVALID_ARG (STMF_STATUS_ERROR | 0x07) 71 #define STMF_ERROR_EXISTS (STMF_STATUS_ERROR | 0x08) 72 #define STMF_ERROR_SERVICE_NOT_FOUND (STMF_STATUS_ERROR | 0x09) 73 #define STMF_ERROR_SERVICE_ONLINE (STMF_STATUS_ERROR | 0x0a) 74 #define STMF_ERROR_SERVICE_OFFLINE (STMF_STATUS_ERROR | 0x0b) 75 #define STMF_ERROR_GROUP_IN_USE (STMF_STATUS_ERROR | 0x0c) 76 #define STMF_ERROR_LUN_IN_USE (STMF_STATUS_ERROR | 0x0d) 77 #define STMF_ERROR_VE_CONFLICT (STMF_STATUS_ERROR | 0x0e) 78 #define STMF_ERROR_CONFIG_NONE (STMF_STATUS_ERROR | 0x0f) 79 #define STMF_ERROR_SERVICE_DATA_VERSION (STMF_STATUS_ERROR | 0x10) 80 #define STMF_ERROR_INVALID_HG (STMF_STATUS_ERROR | 0x11) 81 #define STMF_ERROR_INVALID_TG (STMF_STATUS_ERROR | 0x12) 82 #define STMF_ERROR_PROV_DATA_STALE (STMF_STATUS_ERROR | 0x13) 83 #define STMF_ERROR_NO_PROP (STMF_STATUS_ERROR | 0x14) 84 #define STMF_ERROR_NO_PROP_VAL (STMF_STATUS_ERROR | 0x15) 85 #define STMF_ERROR_MISSING_PROP_VAL (STMF_STATUS_ERROR | 0x16) 86 #define STMF_ERROR_INVALID_BLOCKSIZE (STMF_STATUS_ERROR | 0x17) 87 #define STMF_ERROR_FILE_ALREADY (STMF_STATUS_ERROR | 0x18) 88 #define STMF_ERROR_INVALID_PROPSIZE (STMF_STATUS_ERROR | 0x19) 89 #define STMF_ERROR_INVALID_PROP (STMF_STATUS_ERROR | 0x20) 90 #define STMF_ERROR_PERSIST_TYPE (STMF_STATUS_ERROR | 0x21) 91 #define STMF_ERROR_TG_ONLINE (STMF_STATUS_ERROR | 0x22) 92 #define STMF_ERROR_ACCESS_STATE_SET (STMF_STATUS_ERROR | 0x23) 93 #define STMF_ERROR_NO_PROP_STANDBY (STMF_STATUS_ERROR | 0x24) 94 #define STMF_ERROR_POST_MSG_FAILED (STMF_STATUS_ERROR | 0x25) 95 #define STMF_ERROR_DOOR_INSTALLED (STMF_STATUS_ERROR | 0x26) 96 97 /* Failures for stmfCreateLu */ 98 #define STMF_ERROR_FILE_IN_USE (STMF_STATUS_ERROR | 0x100) 99 #define STMF_ERROR_INVALID_BLKSIZE (STMF_STATUS_ERROR | 0x101) 100 #define STMF_ERROR_GUID_IN_USE (STMF_STATUS_ERROR | 0x102) 101 #define STMF_ERROR_META_FILE_NAME (STMF_STATUS_ERROR | 0x103) 102 #define STMF_ERROR_DATA_FILE_NAME (STMF_STATUS_ERROR | 0x104) 103 #define STMF_ERROR_SIZE_OUT_OF_RANGE (STMF_STATUS_ERROR | 0x105) 104 #define STMF_ERROR_LU_BUSY (STMF_STATUS_ERROR | 0x106) 105 #define STMF_ERROR_META_CREATION (STMF_STATUS_ERROR | 0x107) 106 #define STMF_ERROR_FILE_SIZE_INVALID (STMF_STATUS_ERROR | 0x108) 107 #define STMF_ERROR_WRITE_CACHE_SET (STMF_STATUS_ERROR | 0x109) 108 109 /* Initiator Name Types */ 110 #define STMF_FC_PORT_WWN 1 111 #define STMF_ISCSI_NAME 2 112 113 114 /* provider types */ 115 #define STMF_LU_PROVIDER_TYPE 1 116 #define STMF_PORT_PROVIDER_TYPE 2 117 118 /* LU Resource types */ 119 #define STMF_DISK 0 120 121 /* Persistence methods */ 122 #define STMF_PERSIST_SMF 1 123 #define STMF_PERSIST_NONE 2 124 125 /* Logical unit access states */ 126 #define STMF_ACCESS_ACTIVE "0" 127 #define STMF_ACCESS_ACTIVE_TO_STANDBY "1" 128 #define STMF_ACCESS_STANDBY "2" 129 #define STMF_ACCESS_STANDBY_TO_ACTIVE "3" 130 131 /* 132 * LU Disk Properties 133 */ 134 135 enum { 136 STMF_LU_PROP_ALIAS = 1, 137 STMF_LU_PROP_BLOCK_SIZE, 138 STMF_LU_PROP_COMPANY_ID, 139 STMF_LU_PROP_FILENAME, 140 STMF_LU_PROP_GUID, 141 STMF_LU_PROP_META_FILENAME, 142 STMF_LU_PROP_MGMT_URL, 143 STMF_LU_PROP_NEW, 144 STMF_LU_PROP_SIZE, 145 STMF_LU_PROP_WRITE_PROTECT, 146 STMF_LU_PROP_WRITE_CACHE_DISABLE, 147 STMF_LU_PROP_VID, 148 STMF_LU_PROP_PID, 149 STMF_LU_PROP_SERIAL_NUM, 150 STMF_LU_PROP_ACCESS_STATE 151 }; 152 153 154 /* devid code set and name types */ 155 #define EUI_64_TYPE 2 156 #define NAA_TYPE 3 157 #define SCSI_NAME_TYPE 8 158 159 #define BINARY_CODE_SET 1 160 #define ASCII_CODE_SET 2 161 #define UTF_8_CODE_SET 3 162 163 typedef enum _stmfProtocol 164 { 165 STMF_PROTOCOL_FIBRE_CHANNEL = 0, 166 STMF_PROTOCOL_SCSI = 1, 167 STMF_PROTOCOL_SSA = 2, 168 STMF_PROTOCOL_IEEE_1394 = 3, 169 STMF_PROTOCOL_SRP = 4, 170 STMF_PROTOCOL_ISCSI = 5, 171 STMF_PROTOCOL_SAS = 6 172 } stmfProtocol; 173 174 175 typedef struct _stmfGuid 176 { 177 uchar_t guid[16]; 178 } stmfGuid; 179 180 typedef struct _stmfGuidList 181 { 182 uint32_t cnt; 183 stmfGuid guid[1]; 184 } stmfGuidList; 185 186 typedef struct _stmfState 187 { 188 int operationalState; 189 int configState; 190 } stmfState; 191 192 typedef struct _stmfDevid 193 { 194 uint8_t identLength; /* length of ident */ 195 uint8_t ident[STMF_IDENT_LENGTH]; /* SCSI name string ident */ 196 } stmfDevid; 197 198 typedef struct _stmfDevidList 199 { 200 uint32_t cnt; 201 stmfDevid devid[1]; 202 } stmfDevidList; 203 204 typedef char stmfGroupName[256]; 205 typedef char stmfProviderName[256]; 206 207 typedef struct _stmfGroupList 208 { 209 uint32_t cnt; 210 stmfGroupName name[1]; 211 } stmfGroupList; 212 213 typedef struct _stmfProvider 214 { 215 int providerType; 216 stmfProviderName name; 217 } stmfProvider; 218 219 typedef struct _stmfProviderList 220 { 221 uint32_t cnt; 222 stmfProvider provider[1]; 223 } stmfProviderList; 224 225 typedef struct _stmfSession 226 { 227 stmfDevid initiator; 228 char alias[256]; 229 time_t creationTime; 230 } stmfSession; 231 232 typedef struct _stmfSessionList 233 { 234 uint32_t cnt; 235 stmfSession session[1]; 236 } stmfSessionList; 237 238 239 typedef struct _stmfViewEntry 240 { 241 boolean_t veIndexValid; /* if B_TRUE, veIndex is valid value */ 242 uint32_t veIndex; /* View Entry index */ 243 boolean_t allHosts; /* all initiator ports */ 244 stmfGroupName hostGroup; /* Host Group Name */ 245 boolean_t allTargets; /* B_TRUE = targetGroup is invalid */ 246 stmfGroupName targetGroup; /* Target Group Name */ 247 boolean_t luNbrValid; /* if B_TRUE, luNbr is a valid value */ 248 uchar_t luNbr[8]; /* LU number for this view entry */ 249 } stmfViewEntry; 250 251 typedef struct _stmfViewEntryList 252 { 253 uint32_t cnt; 254 stmfViewEntry ve[1]; 255 } stmfViewEntryList; 256 257 typedef struct _stmfViewEntryProperties 258 { 259 stmfGuid associatedLogicalUnitGuid; 260 stmfViewEntry viewEntry; 261 } stmfViewEntryProperties; 262 263 typedef struct _stmfGroupProperties 264 { 265 uint32_t cnt; 266 stmfDevid name[1]; 267 } stmfGroupProperties; 268 269 typedef struct _stmfTargetProperties 270 { 271 stmfProviderName providerName; 272 char alias[256]; 273 uint16_t status; 274 stmfProtocol protocol; 275 stmfDevid devid; 276 } stmfTargetProperties; 277 278 typedef struct _stmfLogicalUnitProperties 279 { 280 char alias[256]; 281 uchar_t vendor[8]; 282 uchar_t product[16]; 283 uchar_t revision[4]; 284 uint32_t status; 285 char providerName[256]; 286 stmfGuid luid; 287 } stmfLogicalUnitProperties; 288 289 typedef void * luResource; 290 291 typedef struct _stmfLogicalUnitProviderProperties 292 { 293 char providerName[MAXPATHLEN]; 294 uint32_t instance; 295 uint32_t status; 296 uchar_t rsvd[64]; 297 } stmfLogicalUnitProviderProperties; 298 299 typedef struct _stmfLocalPortProviderProperties 300 { 301 char providerName[MAXPATHLEN]; 302 uint32_t instance; 303 uint32_t status; 304 uchar_t rsvd[64]; 305 } stmfLocalPortProviderProperties; 306 307 /* API prototypes */ 308 int stmfAddToHostGroup(stmfGroupName *hostGroupName, stmfDevid *name); 309 int stmfAddToTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName); 310 int stmfAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry); 311 int stmfClearProviderData(char *providerName, int providerType); 312 int stmfCreateHostGroup(stmfGroupName *hostGroupName); 313 int stmfCreateLu(luResource hdl, stmfGuid *luGuid); 314 int stmfCreateLuResource(uint16_t dType, luResource *hdl); 315 int stmfCreateTargetGroup(stmfGroupName *targetGroupName); 316 int stmfDeleteHostGroup(stmfGroupName *hostGroupName); 317 int stmfDeleteLu(stmfGuid *luGuid); 318 int stmfDeleteTargetGroup(stmfGroupName *targetGroupName); 319 void stmfDestroyProxyDoor(int hdl); 320 int stmfDevidFromIscsiName(char *iscsiName, stmfDevid *devid); 321 int stmfDevidFromWwn(uchar_t wwn[8], stmfDevid *devid); 322 int stmfFreeLuResource(luResource hdl); 323 void stmfFreeMemory(void *); 324 int stmfGetAluaState(boolean_t *enabled, uint32_t *node); 325 int stmfGetHostGroupList(stmfGroupList **initiatorGroupList); 326 int stmfGetHostGroupMembers(stmfGroupName *hostGroupName, 327 stmfGroupProperties **groupProperties); 328 int stmfGetLocalPortProviderList(stmfProviderList **localPortProviderList); 329 int stmfGetLocalPortProviderProperties(stmfProviderName *providerName, 330 stmfLocalPortProviderProperties *providerProperties); 331 int stmfGetLogicalUnitList(stmfGuidList **logicalUnitList); 332 int stmfGetLogicalUnitProperties(stmfGuid *logicalUnit, 333 stmfLogicalUnitProperties *logicalUnitProps); 334 int stmfGetLogicalUnitProviderList(stmfProviderList **logicalUnitProviderList); 335 int stmfGetLogicalUnitProviderProperties(stmfProviderName *providerName, 336 stmfLogicalUnitProviderProperties *providerProperties); 337 int stmfGetLuProp(luResource hdl, uint32_t propType, char *prop, 338 size_t *propLen); 339 int stmfGetLuResource(stmfGuid *luGuid, luResource *hdl); 340 int stmfGetPersistMethod(uint8_t *persistType, boolean_t serviceState); 341 int stmfGetProviderData(char *providerName, nvlist_t **nvl, int providerType); 342 int stmfGetProviderDataProt(char *providerName, nvlist_t **nvl, 343 int providerType, uint64_t *setToken); 344 int stmfGetSessionList(stmfDevid *target, stmfSessionList **sessionList); 345 int stmfGetState(stmfState *); 346 int stmfGetTargetGroupList(stmfGroupList **targetGroupList); 347 int stmfGetTargetGroupMembers(stmfGroupName *targetGroupName, 348 stmfGroupProperties **groupProperties); 349 int stmfGetTargetList(stmfDevidList **targetList); 350 int stmfGetTargetProperties(stmfDevid *target, 351 stmfTargetProperties *targetProps); 352 int stmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList); 353 int stmfImportLu(uint16_t dType, char *fname, stmfGuid *luGuid); 354 int stmfInitProxyDoor(int *hdl, int fd); 355 int stmfLoadConfig(void); 356 int stmfLuStandby(stmfGuid *luGuid); 357 int stmfModifyLu(stmfGuid *luGuid, uint32_t prop, const char *propVal); 358 int stmfModifyLuByFname(uint16_t dType, const char *fname, uint32_t prop, 359 const char *propVal); 360 int stmfOffline(void); 361 int stmfOfflineTarget(stmfDevid *devid); 362 int stmfOfflineLogicalUnit(stmfGuid *logicalUnit); 363 int stmfOnline(void); 364 int stmfOnlineTarget(stmfDevid *devid); 365 int stmfOnlineLogicalUnit(stmfGuid *logicalUnit); 366 int stmfPostProxyMsg(int hdl, void *buf, uint32_t buflen); 367 int stmfRemoveFromHostGroup(stmfGroupName *hostGroupName, 368 stmfDevid *initiatorName); 369 int stmfRemoveFromTargetGroup(stmfGroupName *targetGroupName, 370 stmfDevid *targetName); 371 int stmfRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex); 372 int stmfSetAluaState(boolean_t enabled, uint32_t node); 373 int stmfSetLuProp(luResource hdl, uint32_t propType, const char *propVal); 374 int stmfSetPersistMethod(uint8_t persistType, boolean_t serviceSet); 375 int stmfSetProviderData(char *providerName, nvlist_t *nvl, int providerType); 376 int stmfSetProviderDataProt(char *providerName, nvlist_t *nvl, 377 int providerType, uint64_t *setToken); 378 int stmfValidateView(stmfViewEntry *viewEntry); 379 380 #ifdef __cplusplus 381 } 382 #endif 383 384 #endif /* _LIBSTMF_H */ 385