xref: /titanic_44/usr/src/lib/libstmf/common/libstmf.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte 
26*fcf3ce44SJohn Forte #ifndef	_LIBSTMF_H
27*fcf3ce44SJohn Forte #define	_LIBSTMF_H
28*fcf3ce44SJohn Forte 
29*fcf3ce44SJohn Forte #include <time.h>
30*fcf3ce44SJohn Forte #include <sys/param.h>
31*fcf3ce44SJohn Forte #include <libnvpair.h>
32*fcf3ce44SJohn Forte 
33*fcf3ce44SJohn Forte #ifdef	__cplusplus
34*fcf3ce44SJohn Forte extern "C" {
35*fcf3ce44SJohn Forte #endif
36*fcf3ce44SJohn Forte 
37*fcf3ce44SJohn Forte /* Constants and Types */
38*fcf3ce44SJohn Forte 
39*fcf3ce44SJohn Forte /* LU and Local Port states */
40*fcf3ce44SJohn Forte #define	STMF_LOGICAL_UNIT_OFFLINE	0
41*fcf3ce44SJohn Forte #define	STMF_LOGICAL_UNIT_OFFLINING	1
42*fcf3ce44SJohn Forte #define	STMF_LOGICAL_UNIT_ONLINE	2
43*fcf3ce44SJohn Forte #define	STMF_LOGICAL_UNIT_ONLINING	3
44*fcf3ce44SJohn Forte #define	STMF_LOGICAL_UNIT_UNREGISTERED	4
45*fcf3ce44SJohn Forte #define	STMF_TARGET_PORT_OFFLINE	5
46*fcf3ce44SJohn Forte #define	STMF_TARGET_PORT_OFFLINING	6
47*fcf3ce44SJohn Forte #define	STMF_TARGET_PORT_ONLINE		7
48*fcf3ce44SJohn Forte #define	STMF_TARGET_PORT_ONLINING	8
49*fcf3ce44SJohn Forte #define	STMF_SERVICE_STATE_ONLINE	9
50*fcf3ce44SJohn Forte #define	STMF_SERVICE_STATE_OFFLINE	10
51*fcf3ce44SJohn Forte #define	STMF_SERVICE_STATE_ONLINING	11
52*fcf3ce44SJohn Forte #define	STMF_SERVICE_STATE_OFFLINING	12
53*fcf3ce44SJohn Forte #define	STMF_SERVICE_STATE_UNKNOWN	13
54*fcf3ce44SJohn Forte #define	STMF_CONFIG_STATE_NONE		14
55*fcf3ce44SJohn Forte #define	STMF_CONFIG_STATE_INIT		15
56*fcf3ce44SJohn Forte #define	STMF_CONFIG_STATE_INIT_DONE	16
57*fcf3ce44SJohn Forte #define	STMF_CONFIG_STATE_UNKNOWN	17
58*fcf3ce44SJohn Forte 
59*fcf3ce44SJohn Forte #define	STMF_IDENT_LENGTH   255
60*fcf3ce44SJohn Forte 
61*fcf3ce44SJohn Forte /* API status return values */
62*fcf3ce44SJohn Forte #define	STMF_STATUS_SUCCESS	    0x0000
63*fcf3ce44SJohn Forte #define	STMF_STATUS_ERROR	    0x8000
64*fcf3ce44SJohn Forte #define	STMF_ERROR_BUSY			(STMF_STATUS_ERROR | 0x01)
65*fcf3ce44SJohn Forte #define	STMF_ERROR_NOT_FOUND		(STMF_STATUS_ERROR | 0x02)
66*fcf3ce44SJohn Forte #define	STMF_ERROR_MEMBER_NOT_FOUND	(STMF_STATUS_ERROR | 0x03)
67*fcf3ce44SJohn Forte #define	STMF_ERROR_GROUP_NOT_FOUND	(STMF_STATUS_ERROR | 0x04)
68*fcf3ce44SJohn Forte #define	STMF_ERROR_PERM			(STMF_STATUS_ERROR | 0x05)
69*fcf3ce44SJohn Forte #define	STMF_ERROR_NOMEM		(STMF_STATUS_ERROR | 0x06)
70*fcf3ce44SJohn Forte #define	STMF_ERROR_INVALID_ARG		(STMF_STATUS_ERROR | 0x07)
71*fcf3ce44SJohn Forte #define	STMF_ERROR_EXISTS		(STMF_STATUS_ERROR | 0x08)
72*fcf3ce44SJohn Forte #define	STMF_ERROR_SERVICE_NOT_FOUND	(STMF_STATUS_ERROR | 0x09)
73*fcf3ce44SJohn Forte #define	STMF_ERROR_SERVICE_ONLINE	(STMF_STATUS_ERROR | 0x0a)
74*fcf3ce44SJohn Forte #define	STMF_ERROR_SERVICE_OFFLINE	(STMF_STATUS_ERROR | 0x0b)
75*fcf3ce44SJohn Forte #define	STMF_ERROR_GROUP_IN_USE		(STMF_STATUS_ERROR | 0x0c)
76*fcf3ce44SJohn Forte #define	STMF_ERROR_LUN_IN_USE		(STMF_STATUS_ERROR | 0x0d)
77*fcf3ce44SJohn Forte #define	STMF_ERROR_VE_CONFLICT		(STMF_STATUS_ERROR | 0x0e)
78*fcf3ce44SJohn Forte #define	STMF_ERROR_CONFIG_NONE		(STMF_STATUS_ERROR | 0x0f)
79*fcf3ce44SJohn Forte #define	STMF_ERROR_SERVICE_DATA_VERSION (STMF_STATUS_ERROR | 0x10)
80*fcf3ce44SJohn Forte #define	STMF_ERROR_INVALID_HG		(STMF_STATUS_ERROR | 0x11)
81*fcf3ce44SJohn Forte #define	STMF_ERROR_INVALID_TG		(STMF_STATUS_ERROR | 0x12)
82*fcf3ce44SJohn Forte #define	STMF_ERROR_PROV_DATA_STALE	(STMF_STATUS_ERROR | 0x13)
83*fcf3ce44SJohn Forte 
84*fcf3ce44SJohn Forte /* Initiator Name Types */
85*fcf3ce44SJohn Forte #define	STMF_FC_PORT_WWN	    1
86*fcf3ce44SJohn Forte #define	STMF_ISCSI_NAME		    2
87*fcf3ce44SJohn Forte 
88*fcf3ce44SJohn Forte /* protected data flag for provider store */
89*fcf3ce44SJohn Forte #define	STMF_PROTECTED_DATA	0x0001
90*fcf3ce44SJohn Forte 
91*fcf3ce44SJohn Forte /* provider types */
92*fcf3ce44SJohn Forte #define	STMF_LU_PROVIDER_TYPE	1
93*fcf3ce44SJohn Forte #define	STMF_PORT_PROVIDER_TYPE	2
94*fcf3ce44SJohn Forte 
95*fcf3ce44SJohn Forte 
96*fcf3ce44SJohn Forte /* devid code set and name types */
97*fcf3ce44SJohn Forte #define	EUI_64_TYPE	2
98*fcf3ce44SJohn Forte #define	NAA_TYPE	3
99*fcf3ce44SJohn Forte #define	SCSI_NAME_TYPE	8
100*fcf3ce44SJohn Forte 
101*fcf3ce44SJohn Forte #define	BINARY_CODE_SET	1
102*fcf3ce44SJohn Forte #define	ASCII_CODE_SET	2
103*fcf3ce44SJohn Forte #define	UTF_8_CODE_SET	3
104*fcf3ce44SJohn Forte 
105*fcf3ce44SJohn Forte typedef enum _stmfProtocol
106*fcf3ce44SJohn Forte {
107*fcf3ce44SJohn Forte 	STMF_PROTOCOL_FIBRE_CHANNEL =	0,
108*fcf3ce44SJohn Forte 	STMF_PROTOCOL_ISCSI =		1,
109*fcf3ce44SJohn Forte 	STMF_PROTOCOL_SAS =		2
110*fcf3ce44SJohn Forte } stmfProtocol;
111*fcf3ce44SJohn Forte 
112*fcf3ce44SJohn Forte 
113*fcf3ce44SJohn Forte typedef struct _stmfGuid
114*fcf3ce44SJohn Forte {
115*fcf3ce44SJohn Forte 	uchar_t	guid[16];
116*fcf3ce44SJohn Forte } stmfGuid;
117*fcf3ce44SJohn Forte 
118*fcf3ce44SJohn Forte typedef struct _stmfGuidList
119*fcf3ce44SJohn Forte {
120*fcf3ce44SJohn Forte 	uint32_t cnt;
121*fcf3ce44SJohn Forte 	stmfGuid guid[1];
122*fcf3ce44SJohn Forte } stmfGuidList;
123*fcf3ce44SJohn Forte 
124*fcf3ce44SJohn Forte typedef struct _stmfState
125*fcf3ce44SJohn Forte {
126*fcf3ce44SJohn Forte 	int operationalState;
127*fcf3ce44SJohn Forte 	int configState;
128*fcf3ce44SJohn Forte } stmfState;
129*fcf3ce44SJohn Forte 
130*fcf3ce44SJohn Forte typedef struct _stmfDevid
131*fcf3ce44SJohn Forte {
132*fcf3ce44SJohn Forte 	uint8_t identLength;	/* length of ident */
133*fcf3ce44SJohn Forte 	uint8_t	ident[STMF_IDENT_LENGTH]; /* SCSI name string ident */
134*fcf3ce44SJohn Forte } stmfDevid;
135*fcf3ce44SJohn Forte 
136*fcf3ce44SJohn Forte typedef struct _stmfDevidList
137*fcf3ce44SJohn Forte {
138*fcf3ce44SJohn Forte 	uint32_t cnt;
139*fcf3ce44SJohn Forte 	stmfDevid devid[1];
140*fcf3ce44SJohn Forte } stmfDevidList;
141*fcf3ce44SJohn Forte 
142*fcf3ce44SJohn Forte typedef char stmfGroupName[256];
143*fcf3ce44SJohn Forte typedef char stmfProviderName[256];
144*fcf3ce44SJohn Forte 
145*fcf3ce44SJohn Forte typedef struct _stmfGroupList
146*fcf3ce44SJohn Forte {
147*fcf3ce44SJohn Forte 	uint32_t cnt;
148*fcf3ce44SJohn Forte 	stmfGroupName name[1];
149*fcf3ce44SJohn Forte } stmfGroupList;
150*fcf3ce44SJohn Forte 
151*fcf3ce44SJohn Forte typedef struct _stmfProvider
152*fcf3ce44SJohn Forte {
153*fcf3ce44SJohn Forte 	int providerType;
154*fcf3ce44SJohn Forte 	stmfProviderName name;
155*fcf3ce44SJohn Forte } stmfProvider;
156*fcf3ce44SJohn Forte 
157*fcf3ce44SJohn Forte typedef struct _stmfProviderList
158*fcf3ce44SJohn Forte {
159*fcf3ce44SJohn Forte 	uint32_t cnt;
160*fcf3ce44SJohn Forte 	stmfProvider provider[1];
161*fcf3ce44SJohn Forte } stmfProviderList;
162*fcf3ce44SJohn Forte 
163*fcf3ce44SJohn Forte typedef struct _stmfSession
164*fcf3ce44SJohn Forte {
165*fcf3ce44SJohn Forte 	stmfDevid initiator;
166*fcf3ce44SJohn Forte 	char alias[256];
167*fcf3ce44SJohn Forte 	time_t creationTime;
168*fcf3ce44SJohn Forte } stmfSession;
169*fcf3ce44SJohn Forte 
170*fcf3ce44SJohn Forte typedef struct _stmfSessionList
171*fcf3ce44SJohn Forte {
172*fcf3ce44SJohn Forte 	uint32_t cnt;
173*fcf3ce44SJohn Forte 	stmfSession session[1];
174*fcf3ce44SJohn Forte } stmfSessionList;
175*fcf3ce44SJohn Forte 
176*fcf3ce44SJohn Forte 
177*fcf3ce44SJohn Forte typedef struct _stmfViewEntry
178*fcf3ce44SJohn Forte {
179*fcf3ce44SJohn Forte 	boolean_t	veIndexValid;	/* if B_TRUE, veIndex is valid value */
180*fcf3ce44SJohn Forte 	uint32_t	veIndex;	/* View Entry index */
181*fcf3ce44SJohn Forte 	boolean_t	allHosts;	/* all initiator ports */
182*fcf3ce44SJohn Forte 	stmfGroupName   hostGroup;	/* Host Group Name */
183*fcf3ce44SJohn Forte 	boolean_t	allTargets;	/* B_TRUE = targetGroup is invalid */
184*fcf3ce44SJohn Forte 	stmfGroupName	targetGroup;	/* Target Group Name */
185*fcf3ce44SJohn Forte 	boolean_t	luNbrValid;	/* if B_TRUE, luNbr is a valid value */
186*fcf3ce44SJohn Forte 	uchar_t		luNbr[8];	/* LU number for this view entry */
187*fcf3ce44SJohn Forte } stmfViewEntry;
188*fcf3ce44SJohn Forte 
189*fcf3ce44SJohn Forte typedef struct _stmfViewEntryList
190*fcf3ce44SJohn Forte {
191*fcf3ce44SJohn Forte 	uint32_t cnt;
192*fcf3ce44SJohn Forte 	stmfViewEntry ve[1];
193*fcf3ce44SJohn Forte } stmfViewEntryList;
194*fcf3ce44SJohn Forte 
195*fcf3ce44SJohn Forte typedef struct _stmfViewEntryProperties
196*fcf3ce44SJohn Forte {
197*fcf3ce44SJohn Forte 	stmfGuid	associatedLogicalUnitGuid;
198*fcf3ce44SJohn Forte 	stmfViewEntry	viewEntry;
199*fcf3ce44SJohn Forte } stmfViewEntryProperties;
200*fcf3ce44SJohn Forte 
201*fcf3ce44SJohn Forte typedef struct _stmfGroupProperties
202*fcf3ce44SJohn Forte {
203*fcf3ce44SJohn Forte 	uint32_t	cnt;
204*fcf3ce44SJohn Forte 	stmfDevid	name[1];
205*fcf3ce44SJohn Forte } stmfGroupProperties;
206*fcf3ce44SJohn Forte 
207*fcf3ce44SJohn Forte typedef struct _stmfTargetProperties
208*fcf3ce44SJohn Forte {
209*fcf3ce44SJohn Forte 	stmfProviderName providerName;
210*fcf3ce44SJohn Forte 	char		 alias[256];
211*fcf3ce44SJohn Forte 	uint16_t	 status;
212*fcf3ce44SJohn Forte 	stmfProtocol	 protocol;
213*fcf3ce44SJohn Forte 	stmfDevid	 devid;
214*fcf3ce44SJohn Forte } stmfTargetProperties;
215*fcf3ce44SJohn Forte 
216*fcf3ce44SJohn Forte typedef struct _stmfLogicalUnitProperties
217*fcf3ce44SJohn Forte {
218*fcf3ce44SJohn Forte 	char	    alias[256];
219*fcf3ce44SJohn Forte 	uchar_t	    vendor[8];
220*fcf3ce44SJohn Forte 	uchar_t	    product[16];
221*fcf3ce44SJohn Forte 	uchar_t	    revision[4];
222*fcf3ce44SJohn Forte 	uint32_t    status;
223*fcf3ce44SJohn Forte 	char	    providerName[256];
224*fcf3ce44SJohn Forte 	stmfGuid    luid;
225*fcf3ce44SJohn Forte } stmfLogicalUnitProperties;
226*fcf3ce44SJohn Forte 
227*fcf3ce44SJohn Forte typedef struct _stmfLogicalUnitProviderProperties
228*fcf3ce44SJohn Forte {
229*fcf3ce44SJohn Forte 	char	    providerName[MAXPATHLEN];
230*fcf3ce44SJohn Forte 	uint32_t    instance;
231*fcf3ce44SJohn Forte 	uint32_t    status;
232*fcf3ce44SJohn Forte 	uchar_t	    rsvd[64];
233*fcf3ce44SJohn Forte } stmfLogicalUnitProviderProperties;
234*fcf3ce44SJohn Forte 
235*fcf3ce44SJohn Forte typedef struct _stmfLocalPortProviderProperties
236*fcf3ce44SJohn Forte {
237*fcf3ce44SJohn Forte 	char	    providerName[MAXPATHLEN];
238*fcf3ce44SJohn Forte 	uint32_t    instance;
239*fcf3ce44SJohn Forte 	uint32_t    status;
240*fcf3ce44SJohn Forte 	uchar_t	    rsvd[64];
241*fcf3ce44SJohn Forte } stmfLocalPortProviderProperties;
242*fcf3ce44SJohn Forte 
243*fcf3ce44SJohn Forte 
244*fcf3ce44SJohn Forte /* API prototypes */
245*fcf3ce44SJohn Forte int stmfAddToHostGroup(stmfGroupName *hostGroupName, stmfDevid *name);
246*fcf3ce44SJohn Forte int stmfAddToTargetGroup(stmfGroupName *targetGroupName, stmfDevid *targetName);
247*fcf3ce44SJohn Forte int stmfAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry);
248*fcf3ce44SJohn Forte int stmfClearProviderData(char *providerName, int providerType);
249*fcf3ce44SJohn Forte int stmfCreateHostGroup(stmfGroupName *hostGroupName);
250*fcf3ce44SJohn Forte int stmfCreateTargetGroup(stmfGroupName *targetGroupName);
251*fcf3ce44SJohn Forte int stmfDeleteHostGroup(stmfGroupName *hostGroupName);
252*fcf3ce44SJohn Forte int stmfDeleteTargetGroup(stmfGroupName *targetGroupName);
253*fcf3ce44SJohn Forte int stmfDevidFromIscsiName(char *iscsiName, stmfDevid *devid);
254*fcf3ce44SJohn Forte int stmfDevidFromWwn(uchar_t wwn[8], stmfDevid *devid);
255*fcf3ce44SJohn Forte void stmfFreeMemory(void *);
256*fcf3ce44SJohn Forte int stmfGetHostGroupList(stmfGroupList **initiatorGroupList);
257*fcf3ce44SJohn Forte int stmfGetHostGroupMembers(stmfGroupName *hostGroupName,
258*fcf3ce44SJohn Forte     stmfGroupProperties **groupProperties);
259*fcf3ce44SJohn Forte int stmfGetLocalPortProviderList(stmfProviderList **localPortProviderList);
260*fcf3ce44SJohn Forte int stmfGetLocalPortProviderProperties(stmfProviderName *providerName,
261*fcf3ce44SJohn Forte     stmfLocalPortProviderProperties *providerProperties);
262*fcf3ce44SJohn Forte int stmfGetLogicalUnitList(stmfGuidList **logicalUnitList);
263*fcf3ce44SJohn Forte int stmfGetLogicalUnitProperties(stmfGuid *logicalUnit,
264*fcf3ce44SJohn Forte     stmfLogicalUnitProperties *logicalUnitProps);
265*fcf3ce44SJohn Forte int stmfGetLogicalUnitProviderList(stmfProviderList **logicalUnitProviderList);
266*fcf3ce44SJohn Forte int stmfGetLogicalUnitProviderProperties(stmfProviderName *providerName,
267*fcf3ce44SJohn Forte     stmfLogicalUnitProviderProperties *providerProperties);
268*fcf3ce44SJohn Forte int stmfGetProviderData(char *providerName, nvlist_t **nvl, int providerType);
269*fcf3ce44SJohn Forte int stmfGetProviderDataProt(char *providerName, nvlist_t **nvl,
270*fcf3ce44SJohn Forte     int providerType, uint64_t *setToken);
271*fcf3ce44SJohn Forte int stmfGetSessionList(stmfDevid *target, stmfSessionList **sessionList);
272*fcf3ce44SJohn Forte int stmfGetState(stmfState *);
273*fcf3ce44SJohn Forte int stmfGetTargetGroupList(stmfGroupList **targetGroupList);
274*fcf3ce44SJohn Forte int stmfGetTargetGroupMembers(stmfGroupName *targetGroupName,
275*fcf3ce44SJohn Forte     stmfGroupProperties **groupProperties);
276*fcf3ce44SJohn Forte int stmfGetTargetList(stmfDevidList **targetList);
277*fcf3ce44SJohn Forte int stmfGetTargetProperties(stmfDevid *target,
278*fcf3ce44SJohn Forte     stmfTargetProperties *targetProps);
279*fcf3ce44SJohn Forte int stmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList);
280*fcf3ce44SJohn Forte int stmfLoadConfig(void);
281*fcf3ce44SJohn Forte int stmfOffline(void);
282*fcf3ce44SJohn Forte int stmfOfflineTarget(stmfDevid *devid);
283*fcf3ce44SJohn Forte int stmfOfflineLogicalUnit(stmfGuid *logicalUnit);
284*fcf3ce44SJohn Forte int stmfOnline(void);
285*fcf3ce44SJohn Forte int stmfOnlineTarget(stmfDevid *devid);
286*fcf3ce44SJohn Forte int stmfOnlineLogicalUnit(stmfGuid *logicalUnit);
287*fcf3ce44SJohn Forte int stmfRemoveFromHostGroup(stmfGroupName *hostGroupName,
288*fcf3ce44SJohn Forte     stmfDevid *initiatorName);
289*fcf3ce44SJohn Forte int stmfRemoveFromTargetGroup(stmfGroupName *targetGroupName,
290*fcf3ce44SJohn Forte     stmfDevid *targetName);
291*fcf3ce44SJohn Forte int stmfRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex);
292*fcf3ce44SJohn Forte int stmfSetProviderData(char *providerName, nvlist_t *nvl, int providerType);
293*fcf3ce44SJohn Forte int stmfSetProviderDataProt(char *providerName, nvlist_t *nvl,
294*fcf3ce44SJohn Forte     int providerType, uint64_t *setToken);
295*fcf3ce44SJohn Forte 
296*fcf3ce44SJohn Forte #ifdef	__cplusplus
297*fcf3ce44SJohn Forte }
298*fcf3ce44SJohn Forte #endif
299*fcf3ce44SJohn Forte 
300*fcf3ce44SJohn Forte #endif	/* _LIBSTMF_H */
301