xref: /linux/drivers/target/iscsi/iscsi_target_parameters.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 #ifndef ISCSI_PARAMETERS_H
2 #define ISCSI_PARAMETERS_H
3 
4 #include <scsi/iscsi_proto.h>
5 
6 struct iscsi_extra_response {
7 	char key[KEY_MAXLEN];
8 	char value[32];
9 	struct list_head er_list;
10 } ____cacheline_aligned;
11 
12 struct iscsi_param {
13 	char *name;
14 	char *value;
15 	u8 set_param;
16 	u8 phase;
17 	u8 scope;
18 	u8 sender;
19 	u8 type;
20 	u8 use;
21 	u16 type_range;
22 	u32 state;
23 	struct list_head p_list;
24 } ____cacheline_aligned;
25 
26 extern int iscsi_login_rx_data(struct iscsi_conn *, char *, int);
27 extern int iscsi_login_tx_data(struct iscsi_conn *, char *, char *, int);
28 extern void iscsi_dump_conn_ops(struct iscsi_conn_ops *);
29 extern void iscsi_dump_sess_ops(struct iscsi_sess_ops *);
30 extern void iscsi_print_params(struct iscsi_param_list *);
31 extern int iscsi_create_default_params(struct iscsi_param_list **);
32 extern int iscsi_set_keys_to_negotiate(struct iscsi_param_list *, bool);
33 extern int iscsi_set_keys_irrelevant_for_discovery(struct iscsi_param_list *);
34 extern int iscsi_copy_param_list(struct iscsi_param_list **,
35 			struct iscsi_param_list *, int);
36 extern int iscsi_change_param_value(char *, struct iscsi_param_list *, int);
37 extern void iscsi_release_param_list(struct iscsi_param_list *);
38 extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *);
39 extern int iscsi_extract_key_value(char *, char **, char **);
40 extern int iscsi_update_param_value(struct iscsi_param *, char *);
41 extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);
42 extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
43 			struct iscsi_param_list *);
44 extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
45 extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
46 			struct iscsi_param_list *);
47 extern void iscsi_set_session_parameters(struct iscsi_sess_ops *,
48 			struct iscsi_param_list *, int);
49 
50 #define YES				"Yes"
51 #define NO				"No"
52 #define ALL				"All"
53 #define IRRELEVANT			"Irrelevant"
54 #define NONE				"None"
55 #define NOTUNDERSTOOD			"NotUnderstood"
56 #define REJECT				"Reject"
57 
58 /*
59  * The Parameter Names.
60  */
61 #define AUTHMETHOD			"AuthMethod"
62 #define HEADERDIGEST			"HeaderDigest"
63 #define DATADIGEST			"DataDigest"
64 #define MAXCONNECTIONS			"MaxConnections"
65 #define SENDTARGETS			"SendTargets"
66 #define TARGETNAME			"TargetName"
67 #define INITIATORNAME			"InitiatorName"
68 #define TARGETALIAS			"TargetAlias"
69 #define INITIATORALIAS			"InitiatorAlias"
70 #define TARGETADDRESS			"TargetAddress"
71 #define TARGETPORTALGROUPTAG		"TargetPortalGroupTag"
72 #define INITIALR2T			"InitialR2T"
73 #define IMMEDIATEDATA			"ImmediateData"
74 #define MAXRECVDATASEGMENTLENGTH	"MaxRecvDataSegmentLength"
75 #define MAXXMITDATASEGMENTLENGTH	"MaxXmitDataSegmentLength"
76 #define MAXBURSTLENGTH			"MaxBurstLength"
77 #define FIRSTBURSTLENGTH		"FirstBurstLength"
78 #define DEFAULTTIME2WAIT		"DefaultTime2Wait"
79 #define DEFAULTTIME2RETAIN		"DefaultTime2Retain"
80 #define MAXOUTSTANDINGR2T		"MaxOutstandingR2T"
81 #define DATAPDUINORDER			"DataPDUInOrder"
82 #define DATASEQUENCEINORDER		"DataSequenceInOrder"
83 #define ERRORRECOVERYLEVEL		"ErrorRecoveryLevel"
84 #define SESSIONTYPE			"SessionType"
85 #define IFMARKER			"IFMarker"
86 #define OFMARKER			"OFMarker"
87 #define IFMARKINT			"IFMarkInt"
88 #define OFMARKINT			"OFMarkInt"
89 #define X_EXTENSIONKEY			"X-com.sbei.version"
90 #define X_EXTENSIONKEY_CISCO_NEW	"X-com.cisco.protocol"
91 #define X_EXTENSIONKEY_CISCO_OLD	"X-com.cisco.iscsi.draft"
92 
93 /*
94  * Parameter names of iSCSI Extentions for RDMA (iSER).  See RFC-5046
95  */
96 #define RDMAEXTENSIONS			"RDMAExtensions"
97 #define INITIATORRECVDATASEGMENTLENGTH	"InitiatorRecvDataSegmentLength"
98 #define TARGETRECVDATASEGMENTLENGTH	"TargetRecvDataSegmentLength"
99 
100 /*
101  * For AuthMethod.
102  */
103 #define KRB5				"KRB5"
104 #define SPKM1				"SPKM1"
105 #define SPKM2				"SPKM2"
106 #define SRP				"SRP"
107 #define CHAP				"CHAP"
108 
109 /*
110  * Initial values for Parameter Negotiation.
111  */
112 #define INITIAL_AUTHMETHOD			CHAP
113 #define INITIAL_HEADERDIGEST			"CRC32C,None"
114 #define INITIAL_DATADIGEST			"CRC32C,None"
115 #define INITIAL_MAXCONNECTIONS			"1"
116 #define INITIAL_SENDTARGETS			ALL
117 #define INITIAL_TARGETNAME			"LIO.Target"
118 #define INITIAL_INITIATORNAME			"LIO.Initiator"
119 #define INITIAL_TARGETALIAS			"LIO Target"
120 #define INITIAL_INITIATORALIAS			"LIO Initiator"
121 #define INITIAL_TARGETADDRESS			"0.0.0.0:0000,0"
122 #define INITIAL_TARGETPORTALGROUPTAG		"1"
123 #define INITIAL_INITIALR2T			YES
124 #define INITIAL_IMMEDIATEDATA			YES
125 #define INITIAL_MAXRECVDATASEGMENTLENGTH	"8192"
126 /*
127  * Match outgoing MXDSL default to incoming Open-iSCSI default
128  */
129 #define INITIAL_MAXXMITDATASEGMENTLENGTH	"262144"
130 #define INITIAL_MAXBURSTLENGTH			"262144"
131 #define INITIAL_FIRSTBURSTLENGTH		"65536"
132 #define INITIAL_DEFAULTTIME2WAIT		"2"
133 #define INITIAL_DEFAULTTIME2RETAIN		"20"
134 #define INITIAL_MAXOUTSTANDINGR2T		"1"
135 #define INITIAL_DATAPDUINORDER			YES
136 #define INITIAL_DATASEQUENCEINORDER		YES
137 #define INITIAL_ERRORRECOVERYLEVEL		"0"
138 #define INITIAL_SESSIONTYPE			NORMAL
139 #define INITIAL_IFMARKER			NO
140 #define INITIAL_OFMARKER			NO
141 #define INITIAL_IFMARKINT			REJECT
142 #define INITIAL_OFMARKINT			REJECT
143 
144 /*
145  * Initial values for iSER parameters following RFC-5046 Section 6
146  */
147 #define INITIAL_RDMAEXTENSIONS			NO
148 #define INITIAL_INITIATORRECVDATASEGMENTLENGTH	"262144"
149 #define INITIAL_TARGETRECVDATASEGMENTLENGTH	"8192"
150 
151 /*
152  * For [Header,Data]Digests.
153  */
154 #define CRC32C				"CRC32C"
155 
156 /*
157  * For SessionType.
158  */
159 #define DISCOVERY			"Discovery"
160 #define NORMAL				"Normal"
161 
162 /*
163  * struct iscsi_param->use
164  */
165 #define USE_LEADING_ONLY		0x01
166 #define USE_INITIAL_ONLY		0x02
167 #define USE_ALL				0x04
168 
169 #define IS_USE_LEADING_ONLY(p)		((p)->use & USE_LEADING_ONLY)
170 #define IS_USE_INITIAL_ONLY(p)		((p)->use & USE_INITIAL_ONLY)
171 #define IS_USE_ALL(p)			((p)->use & USE_ALL)
172 
173 #define SET_USE_INITIAL_ONLY(p)		((p)->use |= USE_INITIAL_ONLY)
174 
175 /*
176  * struct iscsi_param->sender
177  */
178 #define	SENDER_INITIATOR		0x01
179 #define SENDER_TARGET			0x02
180 #define SENDER_BOTH			0x03
181 /* Used in iscsi_check_key() */
182 #define SENDER_RECEIVER			0x04
183 
184 #define IS_SENDER_INITIATOR(p)		((p)->sender & SENDER_INITIATOR)
185 #define IS_SENDER_TARGET(p)		((p)->sender & SENDER_TARGET)
186 #define IS_SENDER_BOTH(p)		((p)->sender & SENDER_BOTH)
187 
188 /*
189  * struct iscsi_param->scope
190  */
191 #define SCOPE_CONNECTION_ONLY		0x01
192 #define SCOPE_SESSION_WIDE		0x02
193 
194 #define IS_SCOPE_CONNECTION_ONLY(p)	((p)->scope & SCOPE_CONNECTION_ONLY)
195 #define IS_SCOPE_SESSION_WIDE(p)	((p)->scope & SCOPE_SESSION_WIDE)
196 
197 /*
198  * struct iscsi_param->phase
199  */
200 #define PHASE_SECURITY			0x01
201 #define PHASE_OPERATIONAL		0x02
202 #define PHASE_DECLARATIVE		0x04
203 #define PHASE_FFP0			0x08
204 
205 #define IS_PHASE_SECURITY(p)		((p)->phase & PHASE_SECURITY)
206 #define IS_PHASE_OPERATIONAL(p)		((p)->phase & PHASE_OPERATIONAL)
207 #define IS_PHASE_DECLARATIVE(p)		((p)->phase & PHASE_DECLARATIVE)
208 #define IS_PHASE_FFP0(p)		((p)->phase & PHASE_FFP0)
209 
210 /*
211  * struct iscsi_param->type
212  */
213 #define TYPE_BOOL_AND			0x01
214 #define TYPE_BOOL_OR			0x02
215 #define TYPE_NUMBER			0x04
216 #define TYPE_NUMBER_RANGE		0x08
217 #define TYPE_STRING			0x10
218 #define TYPE_VALUE_LIST			0x20
219 
220 #define IS_TYPE_BOOL_AND(p)		((p)->type & TYPE_BOOL_AND)
221 #define IS_TYPE_BOOL_OR(p)		((p)->type & TYPE_BOOL_OR)
222 #define IS_TYPE_NUMBER(p)		((p)->type & TYPE_NUMBER)
223 #define IS_TYPE_NUMBER_RANGE(p)		((p)->type & TYPE_NUMBER_RANGE)
224 #define IS_TYPE_STRING(p)		((p)->type & TYPE_STRING)
225 #define IS_TYPE_VALUE_LIST(p)		((p)->type & TYPE_VALUE_LIST)
226 
227 /*
228  * struct iscsi_param->type_range
229  */
230 #define TYPERANGE_BOOL_AND		0x0001
231 #define TYPERANGE_BOOL_OR		0x0002
232 #define TYPERANGE_0_TO_2		0x0004
233 #define TYPERANGE_0_TO_3600		0x0008
234 #define TYPERANGE_0_TO_32767		0x0010
235 #define TYPERANGE_0_TO_65535		0x0020
236 #define TYPERANGE_1_TO_65535		0x0040
237 #define TYPERANGE_2_TO_3600		0x0080
238 #define TYPERANGE_512_TO_16777215	0x0100
239 #define TYPERANGE_AUTH			0x0200
240 #define TYPERANGE_DIGEST		0x0400
241 #define TYPERANGE_ISCSINAME		0x0800
242 #define TYPERANGE_SESSIONTYPE		0x1000
243 #define TYPERANGE_TARGETADDRESS		0x2000
244 #define TYPERANGE_UTF8			0x4000
245 
246 #define IS_TYPERANGE_0_TO_2(p)		((p)->type_range & TYPERANGE_0_TO_2)
247 #define IS_TYPERANGE_0_TO_3600(p)	((p)->type_range & TYPERANGE_0_TO_3600)
248 #define IS_TYPERANGE_0_TO_32767(p)	((p)->type_range & TYPERANGE_0_TO_32767)
249 #define IS_TYPERANGE_0_TO_65535(p)	((p)->type_range & TYPERANGE_0_TO_65535)
250 #define IS_TYPERANGE_1_TO_65535(p)	((p)->type_range & TYPERANGE_1_TO_65535)
251 #define IS_TYPERANGE_2_TO_3600(p)	((p)->type_range & TYPERANGE_2_TO_3600)
252 #define IS_TYPERANGE_512_TO_16777215(p)	((p)->type_range & \
253 						TYPERANGE_512_TO_16777215)
254 #define IS_TYPERANGE_AUTH_PARAM(p)	((p)->type_range & TYPERANGE_AUTH)
255 #define IS_TYPERANGE_DIGEST_PARAM(p)	((p)->type_range & TYPERANGE_DIGEST)
256 #define IS_TYPERANGE_SESSIONTYPE(p)	((p)->type_range & \
257 						TYPERANGE_SESSIONTYPE)
258 
259 /*
260  * struct iscsi_param->state
261  */
262 #define PSTATE_ACCEPTOR			0x01
263 #define PSTATE_NEGOTIATE		0x02
264 #define PSTATE_PROPOSER			0x04
265 #define PSTATE_IRRELEVANT		0x08
266 #define PSTATE_REJECT			0x10
267 #define PSTATE_REPLY_OPTIONAL		0x20
268 #define PSTATE_RESPONSE_GOT		0x40
269 #define PSTATE_RESPONSE_SENT		0x80
270 
271 #define IS_PSTATE_ACCEPTOR(p)		((p)->state & PSTATE_ACCEPTOR)
272 #define IS_PSTATE_NEGOTIATE(p)		((p)->state & PSTATE_NEGOTIATE)
273 #define IS_PSTATE_PROPOSER(p)		((p)->state & PSTATE_PROPOSER)
274 #define IS_PSTATE_IRRELEVANT(p)		((p)->state & PSTATE_IRRELEVANT)
275 #define IS_PSTATE_REJECT(p)		((p)->state & PSTATE_REJECT)
276 #define IS_PSTATE_REPLY_OPTIONAL(p)	((p)->state & PSTATE_REPLY_OPTIONAL)
277 #define IS_PSTATE_RESPONSE_GOT(p)	((p)->state & PSTATE_RESPONSE_GOT)
278 #define IS_PSTATE_RESPONSE_SENT(p)	((p)->state & PSTATE_RESPONSE_SENT)
279 
280 #define SET_PSTATE_ACCEPTOR(p)		((p)->state |= PSTATE_ACCEPTOR)
281 #define SET_PSTATE_NEGOTIATE(p)		((p)->state |= PSTATE_NEGOTIATE)
282 #define SET_PSTATE_PROPOSER(p)		((p)->state |= PSTATE_PROPOSER)
283 #define SET_PSTATE_IRRELEVANT(p)	((p)->state |= PSTATE_IRRELEVANT)
284 #define SET_PSTATE_REJECT(p)		((p)->state |= PSTATE_REJECT)
285 #define SET_PSTATE_REPLY_OPTIONAL(p)	((p)->state |= PSTATE_REPLY_OPTIONAL)
286 #define SET_PSTATE_RESPONSE_GOT(p)	((p)->state |= PSTATE_RESPONSE_GOT)
287 #define SET_PSTATE_RESPONSE_SENT(p)	((p)->state |= PSTATE_RESPONSE_SENT)
288 
289 #endif /* ISCSI_PARAMETERS_H */
290