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.
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.
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]
22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
29 #include <sys/param.h>
30 #include <libnvpair.h>
36 /* Constants and Types */
38 /* LU and Local Port states */
39 #define STMF_LOGICAL_UNIT_OFFLINE 0
40 #define STMF_LOGICAL_UNIT_OFFLINING 1
41 #define STMF_LOGICAL_UNIT_ONLINE 2
42 #define STMF_LOGICAL_UNIT_ONLINING 3
43 #define STMF_LOGICAL_UNIT_UNREGISTERED 4
44 #define STMF_TARGET_PORT_OFFLINE 5
45 #define STMF_TARGET_PORT_OFFLINING 6
46 #define STMF_TARGET_PORT_ONLINE 7
47 #define STMF_TARGET_PORT_ONLINING 8
48 #define STMF_SERVICE_STATE_ONLINE 9
49 #define STMF_SERVICE_STATE_OFFLINE 10
50 #define STMF_SERVICE_STATE_ONLINING 11
51 #define STMF_SERVICE_STATE_OFFLINING 12
52 #define STMF_SERVICE_STATE_UNKNOWN 13
53 #define STMF_CONFIG_STATE_NONE 14
54 #define STMF_CONFIG_STATE_INIT 15
55 #define STMF_CONFIG_STATE_INIT_DONE 16
56 #define STMF_CONFIG_STATE_UNKNOWN 17
57 #define STMF_DEFAULT_LU_STATE 18
58 #define STMF_DEFAULT_TARGET_PORT_STATE 19
60 #define STMF_IDENT_LENGTH 255
62 /* API status return values */
63 #define STMF_STATUS_SUCCESS 0x0000
64 #define STMF_STATUS_ERROR 0x8000
65 #define STMF_ERROR_BUSY (STMF_STATUS_ERROR | 0x01)
66 #define STMF_ERROR_NOT_FOUND (STMF_STATUS_ERROR | 0x02)
67 #define STMF_ERROR_MEMBER_NOT_FOUND (STMF_STATUS_ERROR | 0x03)
68 #define STMF_ERROR_GROUP_NOT_FOUND (STMF_STATUS_ERROR | 0x04)
69 #define STMF_ERROR_PERM (STMF_STATUS_ERROR | 0x05)
70 #define STMF_ERROR_NOMEM (STMF_STATUS_ERROR | 0x06)
71 #define STMF_ERROR_INVALID_ARG (STMF_STATUS_ERROR | 0x07)
72 #define STMF_ERROR_EXISTS (STMF_STATUS_ERROR | 0x08)
73 #define STMF_ERROR_SERVICE_NOT_FOUND (STMF_STATUS_ERROR | 0x09)
74 #define STMF_ERROR_SERVICE_ONLINE (STMF_STATUS_ERROR | 0x0a)
75 #define STMF_ERROR_SERVICE_OFFLINE (STMF_STATUS_ERROR | 0x0b)
76 #define STMF_ERROR_GROUP_IN_USE (STMF_STATUS_ERROR | 0x0c)
77 #define STMF_ERROR_LUN_IN_USE (STMF_STATUS_ERROR | 0x0d)
78 #define STMF_ERROR_VE_CONFLICT (STMF_STATUS_ERROR | 0x0e)
79 #define STMF_ERROR_CONFIG_NONE (STMF_STATUS_ERROR | 0x0f)
80 #define STMF_ERROR_SERVICE_DATA_VERSION (STMF_STATUS_ERROR | 0x10)
81 #define STMF_ERROR_INVALID_HG (STMF_STATUS_ERROR | 0x11)
82 #define STMF_ERROR_INVALID_TG (STMF_STATUS_ERROR | 0x12)
83 #define STMF_ERROR_PROV_DATA_STALE (STMF_STATUS_ERROR | 0x13)
84 #define STMF_ERROR_NO_PROP (STMF_STATUS_ERROR | 0x14)
85 #define STMF_ERROR_NO_PROP_VAL (STMF_STATUS_ERROR | 0x15)
86 #define STMF_ERROR_MISSING_PROP_VAL (STMF_STATUS_ERROR | 0x16)
87 #define STMF_ERROR_INVALID_BLOCKSIZE (STMF_STATUS_ERROR | 0x17)
88 #define STMF_ERROR_FILE_ALREADY (STMF_STATUS_ERROR | 0x18)
89 #define STMF_ERROR_INVALID_PROPSIZE (STMF_STATUS_ERROR | 0x19)
90 #define STMF_ERROR_INVALID_PROP (STMF_STATUS_ERROR | 0x20)
91 #define STMF_ERROR_PERSIST_TYPE (STMF_STATUS_ERROR | 0x21)
92 #define STMF_ERROR_TG_ONLINE (STMF_STATUS_ERROR | 0x22)
93 #define STMF_ERROR_ACCESS_STATE_SET (STMF_STATUS_ERROR | 0x23)
94 #define STMF_ERROR_NO_PROP_STANDBY (STMF_STATUS_ERROR | 0x24)
95 #define STMF_ERROR_POST_MSG_FAILED (STMF_STATUS_ERROR | 0x25)
96 #define STMF_ERROR_DOOR_INSTALLED (STMF_STATUS_ERROR | 0x26)
98 /* Failures for stmfCreateLu */
99 #define STMF_ERROR_FILE_IN_USE (STMF_STATUS_ERROR | 0x100)
100 #define STMF_ERROR_INVALID_BLKSIZE (STMF_STATUS_ERROR | 0x101)
101 #define STMF_ERROR_GUID_IN_USE (STMF_STATUS_ERROR | 0x102)
102 #define STMF_ERROR_META_FILE_NAME (STMF_STATUS_ERROR | 0x103)
103 #define STMF_ERROR_DATA_FILE_NAME (STMF_STATUS_ERROR | 0x104)
104 #define STMF_ERROR_SIZE_OUT_OF_RANGE (STMF_STATUS_ERROR | 0x105)
105 #define STMF_ERROR_LU_BUSY (STMF_STATUS_ERROR | 0x106)
106 #define STMF_ERROR_META_CREATION (STMF_STATUS_ERROR | 0x107)
107 #define STMF_ERROR_FILE_SIZE_INVALID (STMF_STATUS_ERROR | 0x108)
108 #define STMF_ERROR_WRITE_CACHE_SET (STMF_STATUS_ERROR | 0x109)
110 /* Initiator Name Types */
111 #define STMF_FC_PORT_WWN 1
112 #define STMF_ISCSI_NAME 2
116 #define STMF_LU_PROVIDER_TYPE 1
117 #define STMF_PORT_PROVIDER_TYPE 2
119 /* LU Resource types */
122 /* Persistence methods */
123 #define STMF_PERSIST_SMF 1
124 #define STMF_PERSIST_NONE 2
126 /* Logical unit access states */
127 #define STMF_ACCESS_ACTIVE "0"
128 #define STMF_ACCESS_ACTIVE_TO_STANDBY "1"
129 #define STMF_ACCESS_STANDBY "2"
130 #define STMF_ACCESS_STANDBY_TO_ACTIVE "3"
137 STMF_LU_PROP_ALIAS
= 1,
138 STMF_LU_PROP_BLOCK_SIZE
,
139 STMF_LU_PROP_COMPANY_ID
,
140 STMF_LU_PROP_FILENAME
,
142 STMF_LU_PROP_META_FILENAME
,
143 STMF_LU_PROP_MGMT_URL
,
146 STMF_LU_PROP_WRITE_PROTECT
,
147 STMF_LU_PROP_WRITE_CACHE_DISABLE
,
150 STMF_LU_PROP_SERIAL_NUM
,
151 STMF_LU_PROP_ACCESS_STATE
,
156 /* devid code set and name types */
157 #define EUI_64_TYPE 2
159 #define SCSI_NAME_TYPE 8
161 #define BINARY_CODE_SET 1
162 #define ASCII_CODE_SET 2
163 #define UTF_8_CODE_SET 3
165 typedef enum _stmfProtocol
167 STMF_PROTOCOL_FIBRE_CHANNEL
= 0,
168 STMF_PROTOCOL_SCSI
= 1,
169 STMF_PROTOCOL_SSA
= 2,
170 STMF_PROTOCOL_IEEE_1394
= 3,
171 STMF_PROTOCOL_SRP
= 4,
172 STMF_PROTOCOL_ISCSI
= 5,
173 STMF_PROTOCOL_SAS
= 6
177 typedef struct _stmfGuid
182 typedef struct _stmfGuidList
188 typedef struct _stmfState
190 int operationalState
;
194 typedef struct _stmfDevid
196 uint8_t identLength
; /* length of ident */
197 uint8_t ident
[STMF_IDENT_LENGTH
]; /* SCSI name string ident */
200 typedef struct _stmfDevidList
206 typedef char stmfGroupName
[256];
207 typedef char stmfProviderName
[256];
209 typedef struct _stmfGroupList
212 stmfGroupName name
[1];
215 typedef struct _stmfProvider
218 stmfProviderName name
;
221 typedef struct _stmfProviderList
224 stmfProvider provider
[1];
227 typedef struct _stmfSession
234 typedef struct _stmfSessionList
237 stmfSession session
[1];
241 typedef struct _stmfViewEntry
243 boolean_t veIndexValid
; /* if B_TRUE, veIndex is valid value */
244 uint32_t veIndex
; /* View Entry index */
245 boolean_t allHosts
; /* all initiator ports */
246 stmfGroupName hostGroup
; /* Host Group Name */
247 boolean_t allTargets
; /* B_TRUE = targetGroup is invalid */
248 stmfGroupName targetGroup
; /* Target Group Name */
249 boolean_t luNbrValid
; /* if B_TRUE, luNbr is a valid value */
250 uchar_t luNbr
[8]; /* LU number for this view entry */
253 typedef struct _stmfViewEntryList
259 typedef struct _stmfViewEntryProperties
261 stmfGuid associatedLogicalUnitGuid
;
262 stmfViewEntry viewEntry
;
263 } stmfViewEntryProperties
;
265 typedef struct _stmfGroupProperties
269 } stmfGroupProperties
;
271 typedef struct _stmfTargetProperties
273 stmfProviderName providerName
;
276 stmfProtocol protocol
;
278 } stmfTargetProperties
;
280 typedef struct _stmfLogicalUnitProperties
287 char providerName
[256];
289 } stmfLogicalUnitProperties
;
291 typedef void * luResource
;
293 typedef struct _stmfLogicalUnitProviderProperties
295 char providerName
[MAXPATHLEN
];
299 } stmfLogicalUnitProviderProperties
;
301 typedef struct _stmfLocalPortProviderProperties
303 char providerName
[MAXPATHLEN
];
307 } stmfLocalPortProviderProperties
;
310 int stmfAddToHostGroup(stmfGroupName
*hostGroupName
, stmfDevid
*name
);
311 int stmfAddToTargetGroup(stmfGroupName
*targetGroupName
, stmfDevid
*targetName
);
312 int stmfAddViewEntry(stmfGuid
*lu
, stmfViewEntry
*viewEntry
);
313 int stmfClearProviderData(char *providerName
, int providerType
);
314 int stmfCreateHostGroup(stmfGroupName
*hostGroupName
);
315 int stmfCreateLu(luResource hdl
, stmfGuid
*luGuid
);
316 int stmfCreateLuResource(uint16_t dType
, luResource
*hdl
);
317 int stmfCreateTargetGroup(stmfGroupName
*targetGroupName
);
318 int stmfDeleteHostGroup(stmfGroupName
*hostGroupName
);
319 int stmfDeleteLu(stmfGuid
*luGuid
);
320 int stmfDeleteTargetGroup(stmfGroupName
*targetGroupName
);
321 void stmfDestroyProxyDoor(int hdl
);
322 int stmfDevidFromIscsiName(char *iscsiName
, stmfDevid
*devid
);
323 int stmfDevidFromWwn(uchar_t wwn
[8], stmfDevid
*devid
);
324 int stmfFreeLuResource(luResource hdl
);
325 void stmfFreeMemory(void *);
326 int stmfGetAluaState(boolean_t
*enabled
, uint32_t *node
);
327 int stmfGetGlobalLuProp(uint16_t dType
, uint32_t prop
, char *propVal
,
329 int stmfGetHostGroupList(stmfGroupList
**initiatorGroupList
);
330 int stmfGetHostGroupMembers(stmfGroupName
*hostGroupName
,
331 stmfGroupProperties
**groupProperties
);
332 int stmfGetLocalPortProviderList(stmfProviderList
**localPortProviderList
);
333 int stmfGetLocalPortProviderProperties(stmfProviderName
*providerName
,
334 stmfLocalPortProviderProperties
*providerProperties
);
335 int stmfGetLogicalUnitList(stmfGuidList
**logicalUnitList
);
336 int stmfGetLogicalUnitProperties(stmfGuid
*logicalUnit
,
337 stmfLogicalUnitProperties
*logicalUnitProps
);
338 int stmfGetLogicalUnitProviderList(stmfProviderList
**logicalUnitProviderList
);
339 int stmfGetLogicalUnitProviderProperties(stmfProviderName
*providerName
,
340 stmfLogicalUnitProviderProperties
*providerProperties
);
341 int stmfGetLuProp(luResource hdl
, uint32_t propType
, char *prop
,
343 int stmfGetLuResource(stmfGuid
*luGuid
, luResource
*hdl
);
344 int stmfGetPersistMethod(uint8_t *persistType
, boolean_t serviceState
);
345 int stmfGetProviderData(char *providerName
, nvlist_t
**nvl
, int providerType
);
346 int stmfGetProviderDataProt(char *providerName
, nvlist_t
**nvl
,
347 int providerType
, uint64_t *setToken
);
348 int stmfGetSessionList(stmfDevid
*target
, stmfSessionList
**sessionList
);
349 int stmfGetState(stmfState
*);
350 int stmfGetTargetGroupList(stmfGroupList
**targetGroupList
);
351 int stmfGetTargetGroupMembers(stmfGroupName
*targetGroupName
,
352 stmfGroupProperties
**groupProperties
);
353 int stmfGetTargetList(stmfDevidList
**targetList
);
354 int stmfGetTargetProperties(stmfDevid
*target
,
355 stmfTargetProperties
*targetProps
);
356 int stmfGetViewEntryList(stmfGuid
*lu
, stmfViewEntryList
**viewEntryList
);
357 int stmfImportLu(uint16_t dType
, char *fname
, stmfGuid
*luGuid
);
358 int stmfInitProxyDoor(int *hdl
, int fd
);
359 int stmfLoadConfig(void);
360 int stmfLuStandby(stmfGuid
*luGuid
);
361 int stmfModifyLu(stmfGuid
*luGuid
, uint32_t prop
, const char *propVal
);
362 int stmfModifyLuByFname(uint16_t dType
, const char *fname
, uint32_t prop
,
363 const char *propVal
);
364 int stmfOffline(void);
365 int stmfOfflineTarget(stmfDevid
*devid
);
366 int stmfOfflineLogicalUnit(stmfGuid
*logicalUnit
);
367 int stmfOnline(void);
368 int stmfOnlineTarget(stmfDevid
*devid
);
369 int stmfOnlineLogicalUnit(stmfGuid
*logicalUnit
);
370 int stmfPostProxyMsg(int hdl
, void *buf
, uint32_t buflen
);
371 int stmfRemoveFromHostGroup(stmfGroupName
*hostGroupName
,
372 stmfDevid
*initiatorName
);
373 int stmfRemoveFromTargetGroup(stmfGroupName
*targetGroupName
,
374 stmfDevid
*targetName
);
375 int stmfRemoveViewEntry(stmfGuid
*lu
, uint32_t viewEntryIndex
);
376 int stmfSetAluaState(boolean_t enabled
, uint32_t node
);
377 int stmfSetGlobalLuProp(uint16_t dType
, uint32_t propType
, const char *propVal
);
378 int stmfSetLuProp(luResource hdl
, uint32_t propType
, const char *propVal
);
379 int stmfSetPersistMethod(uint8_t persistType
, boolean_t serviceSet
);
380 int stmfSetProviderData(char *providerName
, nvlist_t
*nvl
, int providerType
);
381 int stmfSetProviderDataProt(char *providerName
, nvlist_t
*nvl
,
382 int providerType
, uint64_t *setToken
);
383 int stmfValidateView(stmfViewEntry
*viewEntry
);
384 int stmfSetStmfProp(uint8_t propType
, char *propVal
);
385 int stmfGetStmfProp(uint8_t propType
, char *propVal
, size_t *propLen
);
386 int stmfLoadStmfProps(void);
392 #endif /* _LIBSTMF_H */