summaryrefslogtreecommitdiff
path: root/usr/src/lib/libstmf/common/libstmf.h
blob: f9d05adb36edca83758b98ff172b7e74c115c0ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef	_LIBSTMF_H
#define	_LIBSTMF_H

#include <time.h>
#include <sys/param.h>
#include <libnvpair.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Constants and Types */

/* LU and Local Port states */
#define	STMF_LOGICAL_UNIT_OFFLINE	0
#define	STMF_LOGICAL_UNIT_OFFLINING	1
#define	STMF_LOGICAL_UNIT_ONLINE	2
#define	STMF_LOGICAL_UNIT_ONLINING	3
#define	STMF_LOGICAL_UNIT_UNREGISTERED	4
#define	STMF_TARGET_PORT_OFFLINE	5
#define	STMF_TARGET_PORT_OFFLINING	6
#define	STMF_TARGET_PORT_ONLINE		7
#define	STMF_TARGET_PORT_ONLINING	8
#define	STMF_SERVICE_STATE_ONLINE	9
#define	STMF_SERVICE_STATE_OFFLINE	10
#define	STMF_SERVICE_STATE_ONLINING	11
#define	STMF_SERVICE_STATE_OFFLINING	12
#define	STMF_SERVICE_STATE_UNKNOWN	13
#define	STMF_CONFIG_STATE_NONE		14
#define	STMF_CONFIG_STATE_INIT		15
#define	STMF_CONFIG_STATE_INIT_DONE	16
#define	STMF_CONFIG_STATE_UNKNOWN	17
#define	STMF_DEFAULT_LU_STATE		18
#define	STMF_DEFAULT_TARGET_PORT_STATE	19

#define	STMF_IDENT_LENGTH   255

/* API status return values */
#define	STMF_STATUS_SUCCESS	    0x0000
#define	STMF_STATUS_ERROR	    0x8000
#define	STMF_ERROR_BUSY			(STMF_STATUS_ERROR | 0x01)
#define	STMF_ERROR_NOT_FOUND		(STMF_STATUS_ERROR | 0x02)
#define	STMF_ERROR_MEMBER_NOT_FOUND	(STMF_STATUS_ERROR | 0x03)
#define	STMF_ERROR_GROUP_NOT_FOUND	(STMF_STATUS_ERROR | 0x04)
#define	STMF_ERROR_PERM			(STMF_STATUS_ERROR | 0x05)
#define	STMF_ERROR_NOMEM		(STMF_STATUS_ERROR | 0x06)
#define	STMF_ERROR_INVALID_ARG		(STMF_STATUS_ERROR | 0x07)
#define	STMF_ERROR_EXISTS		(STMF_STATUS_ERROR | 0x08)
#define	STMF_ERROR_SERVICE_NOT_FOUND	(STMF_STATUS_ERROR | 0x09)
#define	STMF_ERROR_SERVICE_ONLINE	(STMF_STATUS_ERROR | 0x0a)
#define	STMF_ERROR_SERVICE_OFFLINE	(STMF_STATUS_ERROR | 0x0b)
#define	STMF_ERROR_GROUP_IN_USE		(STMF_STATUS_ERROR | 0x0c)
#define	STMF_ERROR_LUN_IN_USE		(STMF_STATUS_ERROR | 0x0d)
#define	STMF_ERROR_VE_CONFLICT		(STMF_STATUS_ERROR | 0x0e)
#define	STMF_ERROR_CONFIG_NONE		(STMF_STATUS_ERROR | 0x0f)
#define	STMF_ERROR_SERVICE_DATA_VERSION (STMF_STATUS_ERROR | 0x10)
#define	STMF_ERROR_INVALID_HG		(STMF_STATUS_ERROR | 0x11)
#define	STMF_ERROR_INVALID_TG		(STMF_STATUS_ERROR | 0x12)
#define	STMF_ERROR_PROV_DATA_STALE	(STMF_STATUS_ERROR | 0x13)
#define	STMF_ERROR_NO_PROP		(STMF_STATUS_ERROR | 0x14)
#define	STMF_ERROR_NO_PROP_VAL		(STMF_STATUS_ERROR | 0x15)
#define	STMF_ERROR_MISSING_PROP_VAL	(STMF_STATUS_ERROR | 0x16)
#define	STMF_ERROR_INVALID_BLOCKSIZE	(STMF_STATUS_ERROR | 0x17)
#define	STMF_ERROR_FILE_ALREADY		(STMF_STATUS_ERROR | 0x18)
#define	STMF_ERROR_INVALID_PROPSIZE	(STMF_STATUS_ERROR | 0x19)
#define	STMF_ERROR_INVALID_PROP		(STMF_STATUS_ERROR | 0x20)
#define	STMF_ERROR_PERSIST_TYPE		(STMF_STATUS_ERROR | 0x21)
#define	STMF_ERROR_TG_ONLINE		(STMF_STATUS_ERROR | 0x22)
#define	STMF_ERROR_ACCESS_STATE_SET	(STMF_STATUS_ERROR | 0x23)
#define	STMF_ERROR_NO_PROP_STANDBY	(STMF_STATUS_ERROR | 0x24)
#define	STMF_ERROR_POST_MSG_FAILED	(STMF_STATUS_ERROR | 0x25)
#define	STMF_ERROR_DOOR_INSTALLED	(STMF_STATUS_ERROR | 0x26)

/* Failures for stmfCreateLu */
#define	STMF_ERROR_FILE_IN_USE		(STMF_STATUS_ERROR | 0x100)
#define	STMF_ERROR_INVALID_BLKSIZE	(STMF_STATUS_ERROR | 0x101)
#define	STMF_ERROR_GUID_IN_USE		(STMF_STATUS_ERROR | 0x102)
#define	STMF_ERROR_META_FILE_NAME	(STMF_STATUS_ERROR | 0x103)
#define	STMF_ERROR_DATA_FILE_NAME	(STMF_STATUS_ERROR | 0x104)
#define	STMF_ERROR_SIZE_OUT_OF_RANGE	(STMF_STATUS_ERROR | 0x105)
#define	STMF_ERROR_LU_BUSY		(STMF_STATUS_ERROR | 0x106)
#define	STMF_ERROR_META_CREATION	(STMF_STATUS_ERROR | 0x107)
#define	STMF_ERROR_FILE_SIZE_INVALID	(STMF_STATUS_ERROR | 0x108)
#define	STMF_ERROR_WRITE_CACHE_SET	(STMF_STATUS_ERROR | 0x109)

/* Initiator Name Types */
#define	STMF_FC_PORT_WWN	    1
#define	STMF_ISCSI_NAME		    2


/* provider types */
#define	STMF_LU_PROVIDER_TYPE	1
#define	STMF_PORT_PROVIDER_TYPE	2

/* LU Resource types */
#define	STMF_DISK   0

/* Persistence methods */
#define	STMF_PERSIST_SMF	1
#define	STMF_PERSIST_NONE	2

/* Logical unit access states */
#define	STMF_ACCESS_ACTIVE		"0"
#define	STMF_ACCESS_ACTIVE_TO_STANDBY   "1"
#define	STMF_ACCESS_STANDBY		"2"
#define	STMF_ACCESS_STANDBY_TO_ACTIVE	"3"

/*
 * LU Disk Properties
 */

enum {
	STMF_LU_PROP_ALIAS = 1,
	STMF_LU_PROP_BLOCK_SIZE,
	STMF_LU_PROP_COMPANY_ID,
	STMF_LU_PROP_FILENAME,
	STMF_LU_PROP_GUID,
	STMF_LU_PROP_META_FILENAME,
	STMF_LU_PROP_MGMT_URL,
	STMF_LU_PROP_NEW,
	STMF_LU_PROP_SIZE,
	STMF_LU_PROP_WRITE_PROTECT,
	STMF_LU_PROP_WRITE_CACHE_DISABLE,
	STMF_LU_PROP_VID,
	STMF_LU_PROP_PID,
	STMF_LU_PROP_SERIAL_NUM,
	STMF_LU_PROP_ACCESS_STATE,
	STMF_LU_PROP_HOST_ID
};


/* devid code set and name types */
#define	EUI_64_TYPE	2
#define	NAA_TYPE	3
#define	SCSI_NAME_TYPE	8

#define	BINARY_CODE_SET	1
#define	ASCII_CODE_SET	2
#define	UTF_8_CODE_SET	3

typedef enum _stmfProtocol
{
	STMF_PROTOCOL_FIBRE_CHANNEL =	0,
	STMF_PROTOCOL_SCSI =		1,
	STMF_PROTOCOL_SSA =		2,
	STMF_PROTOCOL_IEEE_1394 =	3,
	STMF_PROTOCOL_SRP =		4,
	STMF_PROTOCOL_ISCSI =		5,
	STMF_PROTOCOL_SAS =		6
} stmfProtocol;


typedef struct _stmfGuid
{
	uchar_t	guid[16];
} stmfGuid;

typedef struct _stmfGuidList
{
	uint32_t cnt;
	stmfGuid guid[1];
} stmfGuidList;

typedef struct _stmfState
{
	int operationalState;
	int configState;
} stmfState;

typedef struct _stmfDevid
{
	uint8_t identLength;	/* length of ident */
	uint8_t	ident[STMF_IDENT_LENGTH]; /* SCSI name string ident */
} stmfDevid;

typedef struct _stmfDevidList
{
	uint32_t cnt;
	stmfDevid devid[1];
} stmfDevidList;

typedef char stmfGroupName[256];
typedef char stmfProviderName[256];

typedef struct _stmfGroupList
{
	uint32_t cnt;
	stmfGroupName name[1];
} stmfGroupList;

typedef struct _stmfProvider
{
	int providerType;
	stmfProviderName name;
} stmfProvider;

typedef struct _stmfProviderList
{
	uint32_t cnt;
	stmfProvider provider[1];
} stmfProviderList;

typedef struct _stmfSession
{
	stmfDevid initiator;
	char alias[256];
	time_t creationTime;
} stmfSession;

typedef struct _stmfSessionList
{
	uint32_t cnt;
	stmfSession session[1];
} stmfSessionList;


typedef struct _stmfViewEntry
{
	boolean_t	veIndexValid;	/* if B_TRUE, veIndex is valid value */
	uint32_t	veIndex;	/* View Entry index */
	boolean_t	allHosts;	/* all initiator ports */
	stmfGroupName   hostGroup;	/* Host Group Name */
	boolean_t	allTargets;	/* B_TRUE = targetGroup is invalid */
	stmfGroupName	targetGroup;	/* Target Group Name */
	boolean_t	luNbrValid;	/* if B_TRUE, luNbr is a valid value */
	uchar_t		luNbr[8];	/* LU number for this view entry */
} stmfViewEntry;

typedef struct _stmfViewEntryList
{
	uint32_t cnt;
	stmfViewEntry ve[1];
} stmfViewEntryList;

typedef struct _stmfViewEntryProperties
{
	stmfGuid	associatedLogicalUnitGuid;
	stmfViewEntry	viewEntry;
} stmfViewEntryProperties;

typedef struct _stmfGroupProperties
{
	uint32_t	cnt;
	stmfDevid	name[1];
} stmfGroupProperties;

typedef struct _stmfTargetProperties
{
	stmfProviderName providerName;
	char		 alias[256];
	uint16_t	 status;
	stmfProtocol	 protocol;
	stmfDevid	 devid;
} stmfTargetProperties;

typedef struct _stmfLogicalUnitProperties
{
	char	    alias[256];
	uchar_t	    vendor[8];
	uchar_t	    product[16];
	uchar_t	    revision[4];
	uint32_t    status;
	char	    providerName[256];
	stmfGuid    luid;
} stmfLogicalUnitProperties;

typedef void * luResource;

typedef struct _stmfLogicalUnitProviderProperties
{
	char	    providerName[MAXPATHLEN];
	uint32_t    instance;
	uint32_t    status;
	uchar_t	    rsvd[64];
} stmfLogicalUnitProviderProperties;

typedef struct _stmfLocalPortProviderProperties
{
	char	    providerName[MAXPATHLEN];
	uint32_t    instance;
	uint32_t    status;
	uchar_t	    rsvd[64];
} stmfLocalPortProviderProperties;

/* API prototypes */
int stmfAddToHostGroup(stmfGroupName *hostGroupName, stmfDevid *name);
int stmfAddToTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName);
int stmfAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry);
int stmfClearProviderData(char *providerName, int providerType);
int stmfCreateHostGroup(stmfGroupName *hostGroupName);
int stmfCreateLu(luResource hdl, stmfGuid *luGuid);
int stmfCreateLuResource(uint16_t dType, luResource *hdl);
int stmfCreateTargetGroup(stmfGroupName *targetGroupName);
int stmfDeleteHostGroup(stmfGroupName *hostGroupName);
int stmfDeleteLu(stmfGuid *luGuid);
int stmfDeleteTargetGroup(stmfGroupName *targetGroupName);
void stmfDestroyProxyDoor(int hdl);
int stmfDevidFromIscsiName(char *iscsiName, stmfDevid *devid);
int stmfDevidFromWwn(uchar_t wwn[8], stmfDevid *devid);
int stmfFreeLuResource(luResource hdl);
void stmfFreeMemory(void *);
int stmfGetAluaState(boolean_t *enabled, uint32_t *node);
int stmfGetGlobalLuProp(uint16_t dType, uint32_t prop, char *propVal,
    size_t *propLen);
int stmfGetHostGroupList(stmfGroupList **initiatorGroupList);
int stmfGetHostGroupMembers(stmfGroupName *hostGroupName,
    stmfGroupProperties **groupProperties);
int stmfGetLocalPortProviderList(stmfProviderList **localPortProviderList);
int stmfGetLocalPortProviderProperties(stmfProviderName *providerName,
    stmfLocalPortProviderProperties *providerProperties);
int stmfGetLogicalUnitList(stmfGuidList **logicalUnitList);
int stmfGetLogicalUnitProperties(stmfGuid *logicalUnit,
    stmfLogicalUnitProperties *logicalUnitProps);
int stmfGetLogicalUnitProviderList(stmfProviderList **logicalUnitProviderList);
int stmfGetLogicalUnitProviderProperties(stmfProviderName *providerName,
    stmfLogicalUnitProviderProperties *providerProperties);
int stmfGetLuProp(luResource hdl, uint32_t propType, char *prop,
    size_t *propLen);
int stmfGetLuResource(stmfGuid *luGuid, luResource *hdl);
int stmfGetPersistMethod(uint8_t *persistType, boolean_t serviceState);
int stmfGetProviderData(char *providerName, nvlist_t **nvl, int providerType);
int stmfGetProviderDataProt(char *providerName, nvlist_t **nvl,
    int providerType, uint64_t *setToken);
int stmfGetSessionList(stmfDevid *target, stmfSessionList **sessionList);
int stmfGetState(stmfState *);
int stmfGetTargetGroupList(stmfGroupList **targetGroupList);
int stmfGetTargetGroupMembers(stmfGroupName *targetGroupName,
    stmfGroupProperties **groupProperties);
int stmfGetTargetList(stmfDevidList **targetList);
int stmfGetTargetProperties(stmfDevid *target,
    stmfTargetProperties *targetProps);
int stmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList);
int stmfImportLu(uint16_t dType, char *fname, stmfGuid *luGuid);
int stmfInitProxyDoor(int *hdl, int fd);
int stmfLoadConfig(void);
int stmfLuStandby(stmfGuid *luGuid);
int stmfModifyLu(stmfGuid *luGuid, uint32_t prop, const char *propVal);
int stmfModifyLuByFname(uint16_t dType, const char *fname, uint32_t prop,
    const char *propVal);
int stmfOffline(void);
int stmfOfflineTarget(stmfDevid *devid);
int stmfOfflineLogicalUnit(stmfGuid *logicalUnit);
int stmfOnline(void);
int stmfOnlineTarget(stmfDevid *devid);
int stmfOnlineLogicalUnit(stmfGuid *logicalUnit);
int stmfPostProxyMsg(int hdl, void *buf, uint32_t buflen);
int stmfRemoveFromHostGroup(stmfGroupName *hostGroupName,
    stmfDevid *initiatorName);
int stmfRemoveFromTargetGroup(stmfGroupName *targetGroupName,
    stmfDevid *targetName);
int stmfRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex);
int stmfSetAluaState(boolean_t enabled, uint32_t node);
int stmfSetGlobalLuProp(uint16_t dType, uint32_t propType, const char *propVal);
int stmfSetLuProp(luResource hdl, uint32_t propType, const char *propVal);
int stmfSetPersistMethod(uint8_t persistType, boolean_t serviceSet);
int stmfSetProviderData(char *providerName, nvlist_t *nvl, int providerType);
int stmfSetProviderDataProt(char *providerName, nvlist_t *nvl,
    int providerType, uint64_t *setToken);
int stmfValidateView(stmfViewEntry *viewEntry);
int stmfSetStmfProp(uint8_t propType, char *propVal);
int stmfGetStmfProp(uint8_t propType, char *propVal, size_t *propLen);
int stmfLoadStmfProps(void);

#ifdef	__cplusplus
}
#endif

#endif	/* _LIBSTMF_H */