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