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