xref: /illumos-gate/usr/src/cmd/iscsiadm/iscsiadm.h (revision aff4bce5)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
221a1a84a3SPeter Dunlap  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #ifndef	_ISCSIADM_H
27fcf3ce44SJohn Forte #define	_ISCSIADM_H
28fcf3ce44SJohn Forte 
29fcf3ce44SJohn Forte #ifdef	__cplusplus
30fcf3ce44SJohn Forte extern "C" {
31fcf3ce44SJohn Forte #endif
32fcf3ce44SJohn Forte 
331a1a84a3SPeter Dunlap #include <sys/iscsi_protocol.h>
34fcf3ce44SJohn Forte #include <sys/scsi/adapters/iscsi_if.h>
35fcf3ce44SJohn Forte #include <ima.h>
36fcf3ce44SJohn Forte 
37fcf3ce44SJohn Forte #include <cmdparse.h>
38fcf3ce44SJohn Forte 
39fcf3ce44SJohn Forte #define	ADD	SUBCOMMAND(0)
40fcf3ce44SJohn Forte #define	LIST	SUBCOMMAND(1)
41fcf3ce44SJohn Forte #define	MODIFY	SUBCOMMAND(2)
42fcf3ce44SJohn Forte #define	REMOVE	SUBCOMMAND(3)
43fcf3ce44SJohn Forte 
44fcf3ce44SJohn Forte #define	TARGET			OBJECT(0)
45fcf3ce44SJohn Forte #define	NODE			OBJECT(1)
46fcf3ce44SJohn Forte #define	INITIATOR		OBJECT(2)
47fcf3ce44SJohn Forte #define	STATIC_CONFIG		OBJECT(3)
48fcf3ce44SJohn Forte #define	DISCOVERY_ADDRESS	OBJECT(4)
49fcf3ce44SJohn Forte #define	DISCOVERY		OBJECT(5)
50fcf3ce44SJohn Forte #define	TARGET_PARAM		OBJECT(6)
51fcf3ce44SJohn Forte #define	ISNS_SERVER_ADDRESS	OBJECT(7)
52fcf3ce44SJohn Forte 
53fcf3ce44SJohn Forte #define	DATA_SEQ_IN_ORDER	0x01
54fcf3ce44SJohn Forte #define	DEFAULT_TIME_2_RETAIN	0x02
55fcf3ce44SJohn Forte #define	DEFAULT_TIME_2_WAIT	0x03
56fcf3ce44SJohn Forte #define	FIRST_BURST_LENGTH	0x04
57fcf3ce44SJohn Forte #define	IMMEDIATE_DATA		0x05
58fcf3ce44SJohn Forte #define	INITIAL_R2T		0x06
59fcf3ce44SJohn Forte #define	MAX_BURST_LENGTH	0x07
60fcf3ce44SJohn Forte #define	DATA_PDU_IN_ORDER	0x08
61fcf3ce44SJohn Forte #define	MAX_OUTSTANDING_R2T	0x09
62fcf3ce44SJohn Forte #define	MAX_RECV_DATA_SEG_LEN	0x0a
63fcf3ce44SJohn Forte #define	HEADER_DIGEST		0x0b
64fcf3ce44SJohn Forte #define	DATA_DIGEST		0x0c
65fcf3ce44SJohn Forte #define	MAX_CONNECTIONS		0x0d
66fcf3ce44SJohn Forte #define	ERROR_RECOVERY_LEVEL	0x0e
67*aff4bce5Syi zhang - Sun Microsystems - Beijing China #define	RECV_LOGIN_RSP_TIMEOUT  0x0f
68*aff4bce5Syi zhang - Sun Microsystems - Beijing China #define	CONN_LOGIN_MAX		0x10
69*aff4bce5Syi zhang - Sun Microsystems - Beijing China #define	POLLING_LOGIN_DELAY	0x11
70fcf3ce44SJohn Forte 
71fcf3ce44SJohn Forte #define	AUTH_NAME		0x01
72fcf3ce44SJohn Forte #define	AUTH_PASSWORD		0x02
73fcf3ce44SJohn Forte 
74fcf3ce44SJohn Forte #define	ISCSIADM_ARG_ENABLE	"enable"
75fcf3ce44SJohn Forte #define	ISCSIADM_ARG_DISABLE	"disable"
76fcf3ce44SJohn Forte /*
77fcf3ce44SJohn Forte  * This object type is not defined by IMA.
78fcf3ce44SJohn Forte  */
79fcf3ce44SJohn Forte #define	SUN_IMA_OBJECT_TYPE_CONN  13	/* Currently not defined in IMA */
80fcf3ce44SJohn Forte #define	SUN_IMA_NODE_ALIAS_LEN	256
81fcf3ce44SJohn Forte 
82fcf3ce44SJohn Forte #define	MAKE_IMA_ERROR(x)	((IMA_STATUS)(IMA_STATUS_ERROR | (x)))
83fcf3ce44SJohn Forte #define	SUN_IMA_SYSTEM_ERROR(status) (((IMA_STATUS)(status) & \
84fcf3ce44SJohn Forte 	(IMA_STATUS)SUN_IMA_ERROR_SYSTEM_ERROR) == 0x8FFF0000 \
85fcf3ce44SJohn Forte 	? IMA_TRUE : IMA_FALSE)
86fcf3ce44SJohn Forte #define	SUN_GET_SYSTEM_ERROR(x)	(((IMA_STATUS)(x) & 0x0000FFFF))
87fcf3ce44SJohn Forte #define	SUN_IMA_ERROR_SYSTEM_ERROR MAKE_IMA_ERROR(0x0fff0000)
88fcf3ce44SJohn Forte 
89fcf3ce44SJohn Forte typedef struct _parameterTbl {
90fcf3ce44SJohn Forte 	char *name;
91fcf3ce44SJohn Forte 	int val;
92fcf3ce44SJohn Forte } parameterTbl_t;
93fcf3ce44SJohn Forte 
94fcf3ce44SJohn Forte /*
95fcf3ce44SJohn Forte  * The following interfaces are not defined in IMA 1.1. Some of them
96fcf3ce44SJohn Forte  * are requirement candidates for the next IMA release.
97fcf3ce44SJohn Forte  */
98fcf3ce44SJohn Forte 
99fcf3ce44SJohn Forte #define	SUN_IMA_MAX_DIGEST_ALGORITHMS	2	/* NONE and CRC 32 */
100fcf3ce44SJohn Forte #define	SUN_IMA_IP_ADDRESS_PORT_LEN	256
101fcf3ce44SJohn Forte #define	SUN_IMA_MAX_RADIUS_SECRET_LEN	128
102fcf3ce44SJohn Forte 
103fcf3ce44SJohn Forte /* Currently not defined in  IMA_TARGET_DISCOVERY_METHOD enum */
104fcf3ce44SJohn Forte #define	IMA_TARGET_DISCOVERY_METHOD_UNKNOWN  0
105fcf3ce44SJohn Forte 
106fcf3ce44SJohn Forte typedef enum
107fcf3ce44SJohn Forte {
108fcf3ce44SJohn Forte     SUN_IMA_DIGEST_NONE = 0,
109fcf3ce44SJohn Forte     SUN_IMA_DIGEST_CRC32 = 1
110fcf3ce44SJohn Forte } SUN_IMA_DIGEST_ALGORITHM;
111fcf3ce44SJohn Forte 
112fcf3ce44SJohn Forte typedef struct _SUN_IMA_DIGEST_ALGORITHM_VALUE
113fcf3ce44SJohn Forte {
114fcf3ce44SJohn Forte     IMA_UINT defaultAlgorithmCount;
115fcf3ce44SJohn Forte     SUN_IMA_DIGEST_ALGORITHM defaultAlgorithms[SUN_IMA_MAX_DIGEST_ALGORITHMS];
116fcf3ce44SJohn Forte 
117fcf3ce44SJohn Forte     IMA_BOOL currentValid;
118fcf3ce44SJohn Forte     IMA_UINT currentAlgorithmCount;
119fcf3ce44SJohn Forte     SUN_IMA_DIGEST_ALGORITHM currentAlgorithms[SUN_IMA_MAX_DIGEST_ALGORITHMS];
120fcf3ce44SJohn Forte 
121fcf3ce44SJohn Forte     IMA_BOOL negotiatedValid;
122fcf3ce44SJohn Forte     IMA_UINT negotiatedAlgorithmCount;
123fcf3ce44SJohn Forte     SUN_IMA_DIGEST_ALGORITHM
124fcf3ce44SJohn Forte 	negotiatedAlgorithms[SUN_IMA_MAX_DIGEST_ALGORITHMS];
125fcf3ce44SJohn Forte } SUN_IMA_DIGEST_ALGORITHM_VALUE;
126fcf3ce44SJohn Forte 
127fcf3ce44SJohn Forte typedef struct _SUN_IMA_DISC_ADDR_PROP_LIST
128fcf3ce44SJohn Forte {
129fcf3ce44SJohn Forte     IMA_UINT discAddrCount;
130fcf3ce44SJohn Forte     IMA_DISCOVERY_ADDRESS_PROPERTIES props[1];
131fcf3ce44SJohn Forte } SUN_IMA_DISC_ADDR_PROP_LIST;
132fcf3ce44SJohn Forte 
133fcf3ce44SJohn Forte typedef struct _SUN_IMA_RADIUS_CONFIG
134fcf3ce44SJohn Forte {
135fcf3ce44SJohn Forte 	char hostnameIpAddress[SUN_IMA_IP_ADDRESS_PORT_LEN];
136fcf3ce44SJohn Forte 	IMA_BOOL isIpv6;
137fcf3ce44SJohn Forte 	IMA_UINT16 port;
138fcf3ce44SJohn Forte 	IMA_BOOL sharedSecretValid;
139fcf3ce44SJohn Forte 	IMA_UINT sharedSecretLength;
140fcf3ce44SJohn Forte 	IMA_BYTE sharedSecret[SUN_IMA_MAX_RADIUS_SECRET_LEN];
141fcf3ce44SJohn Forte } SUN_IMA_RADIUS_CONFIG;
142fcf3ce44SJohn Forte 
143fcf3ce44SJohn Forte 
144fcf3ce44SJohn Forte typedef struct _SUN_IMA_DISC_ADDRESS_KEY
145fcf3ce44SJohn Forte {
146fcf3ce44SJohn Forte 	IMA_NODE_NAME name;
147fcf3ce44SJohn Forte 	IMA_ADDRESS_KEY	address;
148fcf3ce44SJohn Forte 	IMA_UINT16 tpgt;
149fcf3ce44SJohn Forte } SUN_IMA_DISC_ADDRESS_KEY;
150fcf3ce44SJohn Forte 
151fcf3ce44SJohn Forte typedef struct _SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES
152fcf3ce44SJohn Forte {
153fcf3ce44SJohn Forte 	IMA_UINT keyCount;
154fcf3ce44SJohn Forte 	SUN_IMA_DISC_ADDRESS_KEY keys[1];
155fcf3ce44SJohn Forte } SUN_IMA_DISC_ADDRESS_KEY_PROPERTIES;
156fcf3ce44SJohn Forte 
157fcf3ce44SJohn Forte typedef struct _SUN_IMA_TARGET_ADDRESS
158fcf3ce44SJohn Forte {
159fcf3ce44SJohn Forte     IMA_TARGET_ADDRESS imaStruct;
160fcf3ce44SJohn Forte 	IMA_BOOL	defaultTpgt;	/* If true, tpgt becomes irrelvant */
161fcf3ce44SJohn Forte 	IMA_UINT16	tpgt;
162fcf3ce44SJohn Forte } SUN_IMA_TARGET_ADDRESS;
163fcf3ce44SJohn Forte 
164fcf3ce44SJohn Forte typedef struct _SUN_IMA_STATIC_DISCOVERY_TARGET
165fcf3ce44SJohn Forte {
166fcf3ce44SJohn Forte 	IMA_NODE_NAME	targetName;
167fcf3ce44SJohn Forte 	SUN_IMA_TARGET_ADDRESS  targetAddress;
168fcf3ce44SJohn Forte } SUN_IMA_STATIC_DISCOVERY_TARGET;
169fcf3ce44SJohn Forte 
170fcf3ce44SJohn Forte typedef struct _SUN_IMA_STATIC_DISCOVERY_TARGET_PROPERTIES
171fcf3ce44SJohn Forte {
172fcf3ce44SJohn Forte 	IMA_OID	associatedNodeOid;
173fcf3ce44SJohn Forte 	IMA_OID	associatedLhbaOid;
174fcf3ce44SJohn Forte 	SUN_IMA_STATIC_DISCOVERY_TARGET   staticTarget;
175fcf3ce44SJohn Forte } SUN_IMA_STATIC_DISCOVERY_TARGET_PROPERTIES;
176fcf3ce44SJohn Forte 
177fcf3ce44SJohn Forte typedef struct _SUN_IMA_CONN_PROPERTIES {
178fcf3ce44SJohn Forte 	IMA_UINT32	connectionID;
179fcf3ce44SJohn Forte 	IMA_ADDRESS_KEY	local;
180fcf3ce44SJohn Forte 	IMA_ADDRESS_KEY	peer;
181fcf3ce44SJohn Forte 
182fcf3ce44SJohn Forte 	IMA_BOOL   valuesValid;
183fcf3ce44SJohn Forte 	IMA_UINT32 defaultTime2Retain;
184fcf3ce44SJohn Forte 	IMA_UINT32 defaultTime2Wait;
185fcf3ce44SJohn Forte 	IMA_UINT32 errorRecoveryLevel;
186fcf3ce44SJohn Forte 	IMA_UINT32 firstBurstLength;
187fcf3ce44SJohn Forte 	IMA_UINT32 maxBurstLength;
188fcf3ce44SJohn Forte 	IMA_UINT32 maxConnections;
189fcf3ce44SJohn Forte 	IMA_UINT32 maxOutstandingR2T;
190fcf3ce44SJohn Forte 	IMA_UINT32 maxRecvDataSegmentLength;
191fcf3ce44SJohn Forte 
192fcf3ce44SJohn Forte 	IMA_BOOL dataPduInOrder;
193fcf3ce44SJohn Forte 	IMA_BOOL dataSequenceInOrder;
194fcf3ce44SJohn Forte 	IMA_BOOL immediateData;
195fcf3ce44SJohn Forte 	IMA_BOOL initialR2T;
196fcf3ce44SJohn Forte 
197fcf3ce44SJohn Forte 	IMA_UINT headerDigest;
198fcf3ce44SJohn Forte 	IMA_UINT dataDigest;
199fcf3ce44SJohn Forte 
200fcf3ce44SJohn Forte } SUN_IMA_CONN_PROPERTIES;
201fcf3ce44SJohn Forte 
202fcf3ce44SJohn Forte 
203fcf3ce44SJohn Forte #define	SUN_IMA_LU_VENDOR_ID_LEN	ISCSI_INQ_VID_BUF_LEN
204fcf3ce44SJohn Forte #define	SUN_IMA_LU_PRODUCT_ID_LEN	ISCSI_INQ_PID_BUF_LEN
205fcf3ce44SJohn Forte typedef struct _SUN_IMA_LU_PROPERTIES
206fcf3ce44SJohn Forte {
207fcf3ce44SJohn Forte     IMA_LU_PROPERTIES imaProps;
208fcf3ce44SJohn Forte     IMA_CHAR	vendorId[SUN_IMA_LU_VENDOR_ID_LEN];
209fcf3ce44SJohn Forte     IMA_CHAR	productId[SUN_IMA_LU_PRODUCT_ID_LEN];
210fcf3ce44SJohn Forte } SUN_IMA_LU_PROPERTIES;
211fcf3ce44SJohn Forte 
212fcf3ce44SJohn Forte typedef struct _SUN_IMA_TARGET_PROPERTIES
213fcf3ce44SJohn Forte {
214fcf3ce44SJohn Forte     IMA_TARGET_PROPERTIES imaProps;
215fcf3ce44SJohn Forte     IMA_BOOL defaultTpgtConf;	/* If true, tpgtConf is irrelevant */
216fcf3ce44SJohn Forte     IMA_UINT16 tpgtConf;
217fcf3ce44SJohn Forte     IMA_BOOL defaultTpgtNego;	/* If true, tpgtNego is not connected */
218fcf3ce44SJohn Forte     IMA_UINT16 tpgtNego;
219fcf3ce44SJohn Forte     IMA_BYTE isid[ISCSI_ISID_LEN];
220fcf3ce44SJohn Forte } SUN_IMA_TARGET_PROPERTIES;
221fcf3ce44SJohn Forte 
222fcf3ce44SJohn Forte typedef struct _SUN_IMA_CONFIG_SESSIONS {
223fcf3ce44SJohn Forte 	/* True if sessions are bound to an interface */
224fcf3ce44SJohn Forte 	IMA_BOOL	bound;	/* OUT */
225fcf3ce44SJohn Forte 	/*
226fcf3ce44SJohn Forte 	 * Memory allocated from caller.  In addition
227fcf3ce44SJohn Forte 	 * on a Set this is the number of configured
228fcf3ce44SJohn Forte 	 * sessions.
229fcf3ce44SJohn Forte 	 */
230fcf3ce44SJohn Forte 	IMA_UINT	in;	/* IN */
231fcf3ce44SJohn Forte 	/* Number of Configured sessions on Get */
232fcf3ce44SJohn Forte 	IMA_UINT	out;	/* OUT */
233fcf3ce44SJohn Forte 	IMA_ADDRESS_KEY	bindings[1];	/* IN/OUT */
234fcf3ce44SJohn Forte } SUN_IMA_CONFIG_SESSIONS;
235fcf3ce44SJohn Forte 
236fcf3ce44SJohn Forte typedef struct _SUN_IMA_STATIC_TARGET_PROPERTIES
237fcf3ce44SJohn Forte {
238fcf3ce44SJohn Forte 	IMA_OID	associatedNodeOid;
239fcf3ce44SJohn Forte 	IMA_OID	associatedLhbaOid;
240fcf3ce44SJohn Forte 	SUN_IMA_STATIC_DISCOVERY_TARGET   staticTarget;
241fcf3ce44SJohn Forte } SUN_IMA_STATIC_TARGET_PROPERTIES;
242fcf3ce44SJohn Forte 
243fcf3ce44SJohn Forte #ifdef	__cplusplus
244fcf3ce44SJohn Forte }
245fcf3ce44SJohn Forte #endif
246fcf3ce44SJohn Forte 
247fcf3ce44SJohn Forte #endif	/* _ISCSIADM_H */
248