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