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 STMF_LU_PROP_HOST_ID 152 }; 153 154 155 /* devid code set and name types */ 156 #define EUI_64_TYPE 2 157 #define NAA_TYPE 3 158 #define SCSI_NAME_TYPE 8 159 160 #define BINARY_CODE_SET 1 161 #define ASCII_CODE_SET 2 162 #define UTF_8_CODE_SET 3 163 164 typedef enum _stmfProtocol 165 { 166 STMF_PROTOCOL_FIBRE_CHANNEL = 0, 167 STMF_PROTOCOL_SCSI = 1, 168 STMF_PROTOCOL_SSA = 2, 169 STMF_PROTOCOL_IEEE_1394 = 3, 170 STMF_PROTOCOL_SRP = 4, 171 STMF_PROTOCOL_ISCSI = 5, 172 STMF_PROTOCOL_SAS = 6 173 } stmfProtocol; 174 175 176 typedef struct _stmfGuid 177 { 178 uchar_t guid[16]; 179 } stmfGuid; 180 181 typedef struct _stmfGuidList 182 { 183 uint32_t cnt; 184 stmfGuid guid[1]; 185 } stmfGuidList; 186 187 typedef struct _stmfState 188 { 189 int operationalState; 190 int configState; 191 } stmfState; 192 193 typedef struct _stmfDevid 194 { 195 uint8_t identLength; /* length of ident */ 196 uint8_t ident[STMF_IDENT_LENGTH]; /* SCSI name string ident */ 197 } stmfDevid; 198 199 typedef struct _stmfDevidList 200 { 201 uint32_t cnt; 202 stmfDevid devid[1]; 203 } stmfDevidList; 204 205 typedef char stmfGroupName[256]; 206 typedef char stmfProviderName[256]; 207 208 typedef struct _stmfGroupList 209 { 210 uint32_t cnt; 211 stmfGroupName name[1]; 212 } stmfGroupList; 213 214 typedef struct _stmfProvider 215 { 216 int providerType; 217 stmfProviderName name; 218 } stmfProvider; 219 220 typedef struct _stmfProviderList 221 { 222 uint32_t cnt; 223 stmfProvider provider[1]; 224 } stmfProviderList; 225 226 typedef struct _stmfSession 227 { 228 stmfDevid initiator; 229 char alias[256]; 230 time_t creationTime; 231 } stmfSession; 232 233 typedef struct _stmfSessionList 234 { 235 uint32_t cnt; 236 stmfSession session[1]; 237 } stmfSessionList; 238 239 240 typedef struct _stmfViewEntry 241 { 242 boolean_t veIndexValid; /* if B_TRUE, veIndex is valid value */ 243 uint32_t veIndex; /* View Entry index */ 244 boolean_t allHosts; /* all initiator ports */ 245 stmfGroupName hostGroup; /* Host Group Name */ 246 boolean_t allTargets; /* B_TRUE = targetGroup is invalid */ 247 stmfGroupName targetGroup; /* Target Group Name */ 248 boolean_t luNbrValid; /* if B_TRUE, luNbr is a valid value */ 249 uchar_t luNbr[8]; /* LU number for this view entry */ 250 } stmfViewEntry; 251 252 typedef struct _stmfViewEntryList 253 { 254 uint32_t cnt; 255 stmfViewEntry ve[1]; 256 } stmfViewEntryList; 257 258 typedef struct _stmfViewEntryProperties 259 { 260 stmfGuid associatedLogicalUnitGuid; 261 stmfViewEntry viewEntry; 262 } stmfViewEntryProperties; 263 264 typedef struct _stmfGroupProperties 265 { 266 uint32_t cnt; 267 stmfDevid name[1]; 268 } stmfGroupProperties; 269 270 typedef struct _stmfTargetProperties 271 { 272 stmfProviderName providerName; 273 char alias[256]; 274 uint16_t status; 275 stmfProtocol protocol; 276 stmfDevid devid; 277 } stmfTargetProperties; 278 279 typedef struct _stmfLogicalUnitProperties 280 { 281 char alias[256]; 282 uchar_t vendor[8]; 283 uchar_t product[16]; 284 uchar_t revision[4]; 285 uint32_t status; 286 char providerName[256]; 287 stmfGuid luid; 288 } stmfLogicalUnitProperties; 289 290 typedef void * luResource; 291 292 typedef struct _stmfLogicalUnitProviderProperties 293 { 294 char providerName[MAXPATHLEN]; 295 uint32_t instance; 296 uint32_t status; 297 uchar_t rsvd[64]; 298 } stmfLogicalUnitProviderProperties; 299 300 typedef struct _stmfLocalPortProviderProperties 301 { 302 char providerName[MAXPATHLEN]; 303 uint32_t instance; 304 uint32_t status; 305 uchar_t rsvd[64]; 306 } stmfLocalPortProviderProperties; 307 308 /* API prototypes */ 309 int stmfAddToHostGroup(stmfGroupName *hostGroupName, stmfDevid *name); 310 int stmfAddToTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName); 311 int stmfAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry); 312 int stmfClearProviderData(char *providerName, int providerType); 313 int stmfCreateHostGroup(stmfGroupName *hostGroupName); 314 int stmfCreateLu(luResource hdl, stmfGuid *luGuid); 315 int stmfCreateLuResource(uint16_t dType, luResource *hdl); 316 int stmfCreateTargetGroup(stmfGroupName *targetGroupName); 317 int stmfDeleteHostGroup(stmfGroupName *hostGroupName); 318 int stmfDeleteLu(stmfGuid *luGuid); 319 int stmfDeleteTargetGroup(stmfGroupName *targetGroupName); 320 void stmfDestroyProxyDoor(int hdl); 321 int stmfDevidFromIscsiName(char *iscsiName, stmfDevid *devid); 322 int stmfDevidFromWwn(uchar_t wwn[8], stmfDevid *devid); 323 int stmfFreeLuResource(luResource hdl); 324 void stmfFreeMemory(void *); 325 int stmfGetAluaState(boolean_t *enabled, uint32_t *node); 326 int stmfGetGlobalLuProp(uint16_t dType, uint32_t prop, char *propVal, 327 size_t *propLen); 328 int stmfGetHostGroupList(stmfGroupList **initiatorGroupList); 329 int stmfGetHostGroupMembers(stmfGroupName *hostGroupName, 330 stmfGroupProperties **groupProperties); 331 int stmfGetLocalPortProviderList(stmfProviderList **localPortProviderList); 332 int stmfGetLocalPortProviderProperties(stmfProviderName *providerName, 333 stmfLocalPortProviderProperties *providerProperties); 334 int stmfGetLogicalUnitList(stmfGuidList **logicalUnitList); 335 int stmfGetLogicalUnitProperties(stmfGuid *logicalUnit, 336 stmfLogicalUnitProperties *logicalUnitProps); 337 int stmfGetLogicalUnitProviderList(stmfProviderList **logicalUnitProviderList); 338 int stmfGetLogicalUnitProviderProperties(stmfProviderName *providerName, 339 stmfLogicalUnitProviderProperties *providerProperties); 340 int stmfGetLuProp(luResource hdl, uint32_t propType, char *prop, 341 size_t *propLen); 342 int stmfGetLuResource(stmfGuid *luGuid, luResource *hdl); 343 int stmfGetPersistMethod(uint8_t *persistType, boolean_t serviceState); 344 int stmfGetProviderData(char *providerName, nvlist_t **nvl, int providerType); 345 int stmfGetProviderDataProt(char *providerName, nvlist_t **nvl, 346 int providerType, uint64_t *setToken); 347 int stmfGetSessionList(stmfDevid *target, stmfSessionList **sessionList); 348 int stmfGetState(stmfState *); 349 int stmfGetTargetGroupList(stmfGroupList **targetGroupList); 350 int stmfGetTargetGroupMembers(stmfGroupName *targetGroupName, 351 stmfGroupProperties **groupProperties); 352 int stmfGetTargetList(stmfDevidList **targetList); 353 int stmfGetTargetProperties(stmfDevid *target, 354 stmfTargetProperties *targetProps); 355 int stmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList); 356 int stmfImportLu(uint16_t dType, char *fname, stmfGuid *luGuid); 357 int stmfInitProxyDoor(int *hdl, int fd); 358 int stmfLoadConfig(void); 359 int stmfLuStandby(stmfGuid *luGuid); 360 int stmfModifyLu(stmfGuid *luGuid, uint32_t prop, const char *propVal); 361 int stmfModifyLuByFname(uint16_t dType, const char *fname, uint32_t prop, 362 const char *propVal); 363 int stmfOffline(void); 364 int stmfOfflineTarget(stmfDevid *devid); 365 int stmfOfflineLogicalUnit(stmfGuid *logicalUnit); 366 int stmfOnline(void); 367 int stmfOnlineTarget(stmfDevid *devid); 368 int stmfOnlineLogicalUnit(stmfGuid *logicalUnit); 369 int stmfPostProxyMsg(int hdl, void *buf, uint32_t buflen); 370 int stmfRemoveFromHostGroup(stmfGroupName *hostGroupName, 371 stmfDevid *initiatorName); 372 int stmfRemoveFromTargetGroup(stmfGroupName *targetGroupName, 373 stmfDevid *targetName); 374 int stmfRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex); 375 int stmfSetAluaState(boolean_t enabled, uint32_t node); 376 int stmfSetGlobalLuProp(uint16_t dType, uint32_t propType, const char *propVal); 377 int stmfSetLuProp(luResource hdl, uint32_t propType, const char *propVal); 378 int stmfSetPersistMethod(uint8_t persistType, boolean_t serviceSet); 379 int stmfSetProviderData(char *providerName, nvlist_t *nvl, int providerType); 380 int stmfSetProviderDataProt(char *providerName, nvlist_t *nvl, 381 int providerType, uint64_t *setToken); 382 int stmfValidateView(stmfViewEntry *viewEntry); 383 384 #ifdef __cplusplus 385 } 386 #endif 387 388 #endif /* _LIBSTMF_H */ 389