Linux 3.11-rc3
[cris-mirror.git] / drivers / target / iscsi / iscsi_target_parameters.c
blob35fd6439eb010d08d84c2529416005f4e69950d0
1 /*******************************************************************************
2 * This file contains main functions related to iSCSI Parameter negotiation.
4 * \u00a9 Copyright 2007-2011 RisingTide Systems LLC.
6 * Licensed to the Linux Foundation under the General Public License (GPL) version 2.
8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 ******************************************************************************/
21 #include <linux/slab.h>
23 #include "iscsi_target_core.h"
24 #include "iscsi_target_util.h"
25 #include "iscsi_target_parameters.h"
27 int iscsi_login_rx_data(
28 struct iscsi_conn *conn,
29 char *buf,
30 int length)
32 int rx_got;
33 struct kvec iov;
35 memset(&iov, 0, sizeof(struct kvec));
36 iov.iov_len = length;
37 iov.iov_base = buf;
40 * Initial Marker-less Interval.
41 * Add the values regardless of IFMarker/OFMarker, considering
42 * it may not be negoitated yet.
44 conn->of_marker += length;
46 rx_got = rx_data(conn, &iov, 1, length);
47 if (rx_got != length) {
48 pr_err("rx_data returned %d, expecting %d.\n",
49 rx_got, length);
50 return -1;
53 return 0 ;
56 int iscsi_login_tx_data(
57 struct iscsi_conn *conn,
58 char *pdu_buf,
59 char *text_buf,
60 int text_length)
62 int length, tx_sent, iov_cnt = 1;
63 struct kvec iov[2];
65 length = (ISCSI_HDR_LEN + text_length);
67 memset(&iov[0], 0, 2 * sizeof(struct kvec));
68 iov[0].iov_len = ISCSI_HDR_LEN;
69 iov[0].iov_base = pdu_buf;
71 if (text_buf && text_length) {
72 iov[1].iov_len = text_length;
73 iov[1].iov_base = text_buf;
74 iov_cnt++;
78 * Initial Marker-less Interval.
79 * Add the values regardless of IFMarker/OFMarker, considering
80 * it may not be negoitated yet.
82 conn->if_marker += length;
84 tx_sent = tx_data(conn, &iov[0], iov_cnt, length);
85 if (tx_sent != length) {
86 pr_err("tx_data returned %d, expecting %d.\n",
87 tx_sent, length);
88 return -1;
91 return 0;
94 void iscsi_dump_conn_ops(struct iscsi_conn_ops *conn_ops)
96 pr_debug("HeaderDigest: %s\n", (conn_ops->HeaderDigest) ?
97 "CRC32C" : "None");
98 pr_debug("DataDigest: %s\n", (conn_ops->DataDigest) ?
99 "CRC32C" : "None");
100 pr_debug("MaxRecvDataSegmentLength: %u\n",
101 conn_ops->MaxRecvDataSegmentLength);
102 pr_debug("OFMarker: %s\n", (conn_ops->OFMarker) ? "Yes" : "No");
103 pr_debug("IFMarker: %s\n", (conn_ops->IFMarker) ? "Yes" : "No");
104 if (conn_ops->OFMarker)
105 pr_debug("OFMarkInt: %u\n", conn_ops->OFMarkInt);
106 if (conn_ops->IFMarker)
107 pr_debug("IFMarkInt: %u\n", conn_ops->IFMarkInt);
110 void iscsi_dump_sess_ops(struct iscsi_sess_ops *sess_ops)
112 pr_debug("InitiatorName: %s\n", sess_ops->InitiatorName);
113 pr_debug("InitiatorAlias: %s\n", sess_ops->InitiatorAlias);
114 pr_debug("TargetName: %s\n", sess_ops->TargetName);
115 pr_debug("TargetAlias: %s\n", sess_ops->TargetAlias);
116 pr_debug("TargetPortalGroupTag: %hu\n",
117 sess_ops->TargetPortalGroupTag);
118 pr_debug("MaxConnections: %hu\n", sess_ops->MaxConnections);
119 pr_debug("InitialR2T: %s\n",
120 (sess_ops->InitialR2T) ? "Yes" : "No");
121 pr_debug("ImmediateData: %s\n", (sess_ops->ImmediateData) ?
122 "Yes" : "No");
123 pr_debug("MaxBurstLength: %u\n", sess_ops->MaxBurstLength);
124 pr_debug("FirstBurstLength: %u\n", sess_ops->FirstBurstLength);
125 pr_debug("DefaultTime2Wait: %hu\n", sess_ops->DefaultTime2Wait);
126 pr_debug("DefaultTime2Retain: %hu\n",
127 sess_ops->DefaultTime2Retain);
128 pr_debug("MaxOutstandingR2T: %hu\n",
129 sess_ops->MaxOutstandingR2T);
130 pr_debug("DataPDUInOrder: %s\n",
131 (sess_ops->DataPDUInOrder) ? "Yes" : "No");
132 pr_debug("DataSequenceInOrder: %s\n",
133 (sess_ops->DataSequenceInOrder) ? "Yes" : "No");
134 pr_debug("ErrorRecoveryLevel: %hu\n",
135 sess_ops->ErrorRecoveryLevel);
136 pr_debug("SessionType: %s\n", (sess_ops->SessionType) ?
137 "Discovery" : "Normal");
140 void iscsi_print_params(struct iscsi_param_list *param_list)
142 struct iscsi_param *param;
144 list_for_each_entry(param, &param_list->param_list, p_list)
145 pr_debug("%s: %s\n", param->name, param->value);
148 static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *param_list,
149 char *name, char *value, u8 phase, u8 scope, u8 sender,
150 u16 type_range, u8 use)
152 struct iscsi_param *param = NULL;
154 param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
155 if (!param) {
156 pr_err("Unable to allocate memory for parameter.\n");
157 goto out;
159 INIT_LIST_HEAD(&param->p_list);
161 param->name = kstrdup(name, GFP_KERNEL);
162 if (!param->name) {
163 pr_err("Unable to allocate memory for parameter name.\n");
164 goto out;
167 param->value = kstrdup(value, GFP_KERNEL);
168 if (!param->value) {
169 pr_err("Unable to allocate memory for parameter value.\n");
170 goto out;
173 param->phase = phase;
174 param->scope = scope;
175 param->sender = sender;
176 param->use = use;
177 param->type_range = type_range;
179 switch (param->type_range) {
180 case TYPERANGE_BOOL_AND:
181 param->type = TYPE_BOOL_AND;
182 break;
183 case TYPERANGE_BOOL_OR:
184 param->type = TYPE_BOOL_OR;
185 break;
186 case TYPERANGE_0_TO_2:
187 case TYPERANGE_0_TO_3600:
188 case TYPERANGE_0_TO_32767:
189 case TYPERANGE_0_TO_65535:
190 case TYPERANGE_1_TO_65535:
191 case TYPERANGE_2_TO_3600:
192 case TYPERANGE_512_TO_16777215:
193 param->type = TYPE_NUMBER;
194 break;
195 case TYPERANGE_AUTH:
196 case TYPERANGE_DIGEST:
197 param->type = TYPE_VALUE_LIST | TYPE_STRING;
198 break;
199 case TYPERANGE_MARKINT:
200 param->type = TYPE_NUMBER_RANGE;
201 param->type_range |= TYPERANGE_1_TO_65535;
202 break;
203 case TYPERANGE_ISCSINAME:
204 case TYPERANGE_SESSIONTYPE:
205 case TYPERANGE_TARGETADDRESS:
206 case TYPERANGE_UTF8:
207 param->type = TYPE_STRING;
208 break;
209 default:
210 pr_err("Unknown type_range 0x%02x\n",
211 param->type_range);
212 goto out;
214 list_add_tail(&param->p_list, &param_list->param_list);
216 return param;
217 out:
218 if (param) {
219 kfree(param->value);
220 kfree(param->name);
221 kfree(param);
224 return NULL;
227 /* #warning Add extension keys */
228 int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
230 struct iscsi_param *param = NULL;
231 struct iscsi_param_list *pl;
233 pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
234 if (!pl) {
235 pr_err("Unable to allocate memory for"
236 " struct iscsi_param_list.\n");
237 return -1 ;
239 INIT_LIST_HEAD(&pl->param_list);
240 INIT_LIST_HEAD(&pl->extra_response_list);
243 * The format for setting the initial parameter definitions are:
245 * Parameter name:
246 * Initial value:
247 * Allowable phase:
248 * Scope:
249 * Allowable senders:
250 * Typerange:
251 * Use:
253 param = iscsi_set_default_param(pl, AUTHMETHOD, INITIAL_AUTHMETHOD,
254 PHASE_SECURITY, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
255 TYPERANGE_AUTH, USE_INITIAL_ONLY);
256 if (!param)
257 goto out;
259 param = iscsi_set_default_param(pl, HEADERDIGEST, INITIAL_HEADERDIGEST,
260 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
261 TYPERANGE_DIGEST, USE_INITIAL_ONLY);
262 if (!param)
263 goto out;
265 param = iscsi_set_default_param(pl, DATADIGEST, INITIAL_DATADIGEST,
266 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
267 TYPERANGE_DIGEST, USE_INITIAL_ONLY);
268 if (!param)
269 goto out;
271 param = iscsi_set_default_param(pl, MAXCONNECTIONS,
272 INITIAL_MAXCONNECTIONS, PHASE_OPERATIONAL,
273 SCOPE_SESSION_WIDE, SENDER_BOTH,
274 TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
275 if (!param)
276 goto out;
278 param = iscsi_set_default_param(pl, SENDTARGETS, INITIAL_SENDTARGETS,
279 PHASE_FFP0, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
280 TYPERANGE_UTF8, 0);
281 if (!param)
282 goto out;
284 param = iscsi_set_default_param(pl, TARGETNAME, INITIAL_TARGETNAME,
285 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_BOTH,
286 TYPERANGE_ISCSINAME, USE_ALL);
287 if (!param)
288 goto out;
290 param = iscsi_set_default_param(pl, INITIATORNAME,
291 INITIAL_INITIATORNAME, PHASE_DECLARATIVE,
292 SCOPE_SESSION_WIDE, SENDER_INITIATOR,
293 TYPERANGE_ISCSINAME, USE_INITIAL_ONLY);
294 if (!param)
295 goto out;
297 param = iscsi_set_default_param(pl, TARGETALIAS, INITIAL_TARGETALIAS,
298 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
299 TYPERANGE_UTF8, USE_ALL);
300 if (!param)
301 goto out;
303 param = iscsi_set_default_param(pl, INITIATORALIAS,
304 INITIAL_INITIATORALIAS, PHASE_DECLARATIVE,
305 SCOPE_SESSION_WIDE, SENDER_INITIATOR, TYPERANGE_UTF8,
306 USE_ALL);
307 if (!param)
308 goto out;
310 param = iscsi_set_default_param(pl, TARGETADDRESS,
311 INITIAL_TARGETADDRESS, PHASE_DECLARATIVE,
312 SCOPE_SESSION_WIDE, SENDER_TARGET,
313 TYPERANGE_TARGETADDRESS, USE_ALL);
314 if (!param)
315 goto out;
317 param = iscsi_set_default_param(pl, TARGETPORTALGROUPTAG,
318 INITIAL_TARGETPORTALGROUPTAG,
319 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
320 TYPERANGE_0_TO_65535, USE_INITIAL_ONLY);
321 if (!param)
322 goto out;
324 param = iscsi_set_default_param(pl, INITIALR2T, INITIAL_INITIALR2T,
325 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
326 TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
327 if (!param)
328 goto out;
330 param = iscsi_set_default_param(pl, IMMEDIATEDATA,
331 INITIAL_IMMEDIATEDATA, PHASE_OPERATIONAL,
332 SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_AND,
333 USE_LEADING_ONLY);
334 if (!param)
335 goto out;
337 param = iscsi_set_default_param(pl, MAXXMITDATASEGMENTLENGTH,
338 INITIAL_MAXXMITDATASEGMENTLENGTH,
339 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
340 TYPERANGE_512_TO_16777215, USE_ALL);
341 if (!param)
342 goto out;
344 param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH,
345 INITIAL_MAXRECVDATASEGMENTLENGTH,
346 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
347 TYPERANGE_512_TO_16777215, USE_ALL);
348 if (!param)
349 goto out;
351 param = iscsi_set_default_param(pl, MAXBURSTLENGTH,
352 INITIAL_MAXBURSTLENGTH, PHASE_OPERATIONAL,
353 SCOPE_SESSION_WIDE, SENDER_BOTH,
354 TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
355 if (!param)
356 goto out;
358 param = iscsi_set_default_param(pl, FIRSTBURSTLENGTH,
359 INITIAL_FIRSTBURSTLENGTH,
360 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
361 TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
362 if (!param)
363 goto out;
365 param = iscsi_set_default_param(pl, DEFAULTTIME2WAIT,
366 INITIAL_DEFAULTTIME2WAIT,
367 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
368 TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
369 if (!param)
370 goto out;
372 param = iscsi_set_default_param(pl, DEFAULTTIME2RETAIN,
373 INITIAL_DEFAULTTIME2RETAIN,
374 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
375 TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
376 if (!param)
377 goto out;
379 param = iscsi_set_default_param(pl, MAXOUTSTANDINGR2T,
380 INITIAL_MAXOUTSTANDINGR2T,
381 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
382 TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
383 if (!param)
384 goto out;
386 param = iscsi_set_default_param(pl, DATAPDUINORDER,
387 INITIAL_DATAPDUINORDER, PHASE_OPERATIONAL,
388 SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_OR,
389 USE_LEADING_ONLY);
390 if (!param)
391 goto out;
393 param = iscsi_set_default_param(pl, DATASEQUENCEINORDER,
394 INITIAL_DATASEQUENCEINORDER,
395 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
396 TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
397 if (!param)
398 goto out;
400 param = iscsi_set_default_param(pl, ERRORRECOVERYLEVEL,
401 INITIAL_ERRORRECOVERYLEVEL,
402 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
403 TYPERANGE_0_TO_2, USE_LEADING_ONLY);
404 if (!param)
405 goto out;
407 param = iscsi_set_default_param(pl, SESSIONTYPE, INITIAL_SESSIONTYPE,
408 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
409 TYPERANGE_SESSIONTYPE, USE_LEADING_ONLY);
410 if (!param)
411 goto out;
413 param = iscsi_set_default_param(pl, IFMARKER, INITIAL_IFMARKER,
414 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
415 TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
416 if (!param)
417 goto out;
419 param = iscsi_set_default_param(pl, OFMARKER, INITIAL_OFMARKER,
420 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
421 TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
422 if (!param)
423 goto out;
425 param = iscsi_set_default_param(pl, IFMARKINT, INITIAL_IFMARKINT,
426 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
427 TYPERANGE_MARKINT, USE_INITIAL_ONLY);
428 if (!param)
429 goto out;
431 param = iscsi_set_default_param(pl, OFMARKINT, INITIAL_OFMARKINT,
432 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
433 TYPERANGE_MARKINT, USE_INITIAL_ONLY);
434 if (!param)
435 goto out;
437 * Extra parameters for ISER from RFC-5046
439 param = iscsi_set_default_param(pl, RDMAEXTENSIONS, INITIAL_RDMAEXTENSIONS,
440 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
441 TYPERANGE_BOOL_AND, USE_LEADING_ONLY);
442 if (!param)
443 goto out;
445 param = iscsi_set_default_param(pl, INITIATORRECVDATASEGMENTLENGTH,
446 INITIAL_INITIATORRECVDATASEGMENTLENGTH,
447 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
448 TYPERANGE_512_TO_16777215, USE_ALL);
449 if (!param)
450 goto out;
452 param = iscsi_set_default_param(pl, TARGETRECVDATASEGMENTLENGTH,
453 INITIAL_TARGETRECVDATASEGMENTLENGTH,
454 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
455 TYPERANGE_512_TO_16777215, USE_ALL);
456 if (!param)
457 goto out;
459 *param_list_ptr = pl;
460 return 0;
461 out:
462 iscsi_release_param_list(pl);
463 return -1;
466 int iscsi_set_keys_to_negotiate(
467 struct iscsi_param_list *param_list,
468 bool iser)
470 struct iscsi_param *param;
472 param_list->iser = iser;
474 list_for_each_entry(param, &param_list->param_list, p_list) {
475 param->state = 0;
476 if (!strcmp(param->name, AUTHMETHOD)) {
477 SET_PSTATE_NEGOTIATE(param);
478 } else if (!strcmp(param->name, HEADERDIGEST)) {
479 if (iser == false)
480 SET_PSTATE_NEGOTIATE(param);
481 } else if (!strcmp(param->name, DATADIGEST)) {
482 if (iser == false)
483 SET_PSTATE_NEGOTIATE(param);
484 } else if (!strcmp(param->name, MAXCONNECTIONS)) {
485 SET_PSTATE_NEGOTIATE(param);
486 } else if (!strcmp(param->name, TARGETNAME)) {
487 continue;
488 } else if (!strcmp(param->name, INITIATORNAME)) {
489 continue;
490 } else if (!strcmp(param->name, TARGETALIAS)) {
491 if (param->value)
492 SET_PSTATE_NEGOTIATE(param);
493 } else if (!strcmp(param->name, INITIATORALIAS)) {
494 continue;
495 } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
496 SET_PSTATE_NEGOTIATE(param);
497 } else if (!strcmp(param->name, INITIALR2T)) {
498 SET_PSTATE_NEGOTIATE(param);
499 } else if (!strcmp(param->name, IMMEDIATEDATA)) {
500 SET_PSTATE_NEGOTIATE(param);
501 } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
502 if (iser == false)
503 SET_PSTATE_NEGOTIATE(param);
504 } else if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
505 continue;
506 } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
507 SET_PSTATE_NEGOTIATE(param);
508 } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
509 SET_PSTATE_NEGOTIATE(param);
510 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
511 SET_PSTATE_NEGOTIATE(param);
512 } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
513 SET_PSTATE_NEGOTIATE(param);
514 } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
515 SET_PSTATE_NEGOTIATE(param);
516 } else if (!strcmp(param->name, DATAPDUINORDER)) {
517 SET_PSTATE_NEGOTIATE(param);
518 } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
519 SET_PSTATE_NEGOTIATE(param);
520 } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
521 SET_PSTATE_NEGOTIATE(param);
522 } else if (!strcmp(param->name, SESSIONTYPE)) {
523 SET_PSTATE_NEGOTIATE(param);
524 } else if (!strcmp(param->name, IFMARKER)) {
525 SET_PSTATE_NEGOTIATE(param);
526 } else if (!strcmp(param->name, OFMARKER)) {
527 SET_PSTATE_NEGOTIATE(param);
528 } else if (!strcmp(param->name, IFMARKINT)) {
529 SET_PSTATE_NEGOTIATE(param);
530 } else if (!strcmp(param->name, OFMARKINT)) {
531 SET_PSTATE_NEGOTIATE(param);
532 } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
533 if (iser == true)
534 SET_PSTATE_NEGOTIATE(param);
535 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
536 if (iser == true)
537 SET_PSTATE_NEGOTIATE(param);
538 } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
539 if (iser == true)
540 SET_PSTATE_NEGOTIATE(param);
544 return 0;
547 int iscsi_set_keys_irrelevant_for_discovery(
548 struct iscsi_param_list *param_list)
550 struct iscsi_param *param;
552 list_for_each_entry(param, &param_list->param_list, p_list) {
553 if (!strcmp(param->name, MAXCONNECTIONS))
554 param->state &= ~PSTATE_NEGOTIATE;
555 else if (!strcmp(param->name, INITIALR2T))
556 param->state &= ~PSTATE_NEGOTIATE;
557 else if (!strcmp(param->name, IMMEDIATEDATA))
558 param->state &= ~PSTATE_NEGOTIATE;
559 else if (!strcmp(param->name, MAXBURSTLENGTH))
560 param->state &= ~PSTATE_NEGOTIATE;
561 else if (!strcmp(param->name, FIRSTBURSTLENGTH))
562 param->state &= ~PSTATE_NEGOTIATE;
563 else if (!strcmp(param->name, MAXOUTSTANDINGR2T))
564 param->state &= ~PSTATE_NEGOTIATE;
565 else if (!strcmp(param->name, DATAPDUINORDER))
566 param->state &= ~PSTATE_NEGOTIATE;
567 else if (!strcmp(param->name, DATASEQUENCEINORDER))
568 param->state &= ~PSTATE_NEGOTIATE;
569 else if (!strcmp(param->name, ERRORRECOVERYLEVEL))
570 param->state &= ~PSTATE_NEGOTIATE;
571 else if (!strcmp(param->name, DEFAULTTIME2WAIT))
572 param->state &= ~PSTATE_NEGOTIATE;
573 else if (!strcmp(param->name, DEFAULTTIME2RETAIN))
574 param->state &= ~PSTATE_NEGOTIATE;
575 else if (!strcmp(param->name, IFMARKER))
576 param->state &= ~PSTATE_NEGOTIATE;
577 else if (!strcmp(param->name, OFMARKER))
578 param->state &= ~PSTATE_NEGOTIATE;
579 else if (!strcmp(param->name, IFMARKINT))
580 param->state &= ~PSTATE_NEGOTIATE;
581 else if (!strcmp(param->name, OFMARKINT))
582 param->state &= ~PSTATE_NEGOTIATE;
583 else if (!strcmp(param->name, RDMAEXTENSIONS))
584 param->state &= ~PSTATE_NEGOTIATE;
585 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH))
586 param->state &= ~PSTATE_NEGOTIATE;
587 else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH))
588 param->state &= ~PSTATE_NEGOTIATE;
591 return 0;
594 int iscsi_copy_param_list(
595 struct iscsi_param_list **dst_param_list,
596 struct iscsi_param_list *src_param_list,
597 int leading)
599 struct iscsi_param *param = NULL;
600 struct iscsi_param *new_param = NULL;
601 struct iscsi_param_list *param_list = NULL;
603 param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
604 if (!param_list) {
605 pr_err("Unable to allocate memory for struct iscsi_param_list.\n");
606 goto err_out;
608 INIT_LIST_HEAD(&param_list->param_list);
609 INIT_LIST_HEAD(&param_list->extra_response_list);
611 list_for_each_entry(param, &src_param_list->param_list, p_list) {
612 if (!leading && (param->scope & SCOPE_SESSION_WIDE)) {
613 if ((strcmp(param->name, "TargetName") != 0) &&
614 (strcmp(param->name, "InitiatorName") != 0) &&
615 (strcmp(param->name, "TargetPortalGroupTag") != 0))
616 continue;
619 new_param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
620 if (!new_param) {
621 pr_err("Unable to allocate memory for struct iscsi_param.\n");
622 goto err_out;
625 new_param->name = kstrdup(param->name, GFP_KERNEL);
626 new_param->value = kstrdup(param->value, GFP_KERNEL);
627 if (!new_param->value || !new_param->name) {
628 kfree(new_param->value);
629 kfree(new_param->name);
630 kfree(new_param);
631 pr_err("Unable to allocate memory for parameter name/value.\n");
632 goto err_out;
635 new_param->set_param = param->set_param;
636 new_param->phase = param->phase;
637 new_param->scope = param->scope;
638 new_param->sender = param->sender;
639 new_param->type = param->type;
640 new_param->use = param->use;
641 new_param->type_range = param->type_range;
643 list_add_tail(&new_param->p_list, &param_list->param_list);
646 if (!list_empty(&param_list->param_list)) {
647 *dst_param_list = param_list;
648 } else {
649 pr_err("No parameters allocated.\n");
650 goto err_out;
653 return 0;
655 err_out:
656 iscsi_release_param_list(param_list);
657 return -1;
660 static void iscsi_release_extra_responses(struct iscsi_param_list *param_list)
662 struct iscsi_extra_response *er, *er_tmp;
664 list_for_each_entry_safe(er, er_tmp, &param_list->extra_response_list,
665 er_list) {
666 list_del(&er->er_list);
667 kfree(er);
671 void iscsi_release_param_list(struct iscsi_param_list *param_list)
673 struct iscsi_param *param, *param_tmp;
675 list_for_each_entry_safe(param, param_tmp, &param_list->param_list,
676 p_list) {
677 list_del(&param->p_list);
679 kfree(param->name);
680 kfree(param->value);
681 kfree(param);
684 iscsi_release_extra_responses(param_list);
686 kfree(param_list);
689 struct iscsi_param *iscsi_find_param_from_key(
690 char *key,
691 struct iscsi_param_list *param_list)
693 struct iscsi_param *param;
695 if (!key || !param_list) {
696 pr_err("Key or parameter list pointer is NULL.\n");
697 return NULL;
700 list_for_each_entry(param, &param_list->param_list, p_list) {
701 if (!strcmp(key, param->name))
702 return param;
705 pr_err("Unable to locate key \"%s\".\n", key);
706 return NULL;
709 int iscsi_extract_key_value(char *textbuf, char **key, char **value)
711 *value = strchr(textbuf, '=');
712 if (!*value) {
713 pr_err("Unable to locate \"=\" separator for key,"
714 " ignoring request.\n");
715 return -1;
718 *key = textbuf;
719 **value = '\0';
720 *value = *value + 1;
722 return 0;
725 int iscsi_update_param_value(struct iscsi_param *param, char *value)
727 kfree(param->value);
729 param->value = kstrdup(value, GFP_KERNEL);
730 if (!param->value) {
731 pr_err("Unable to allocate memory for value.\n");
732 return -ENOMEM;
735 pr_debug("iSCSI Parameter updated to %s=%s\n",
736 param->name, param->value);
737 return 0;
740 static int iscsi_add_notunderstood_response(
741 char *key,
742 char *value,
743 struct iscsi_param_list *param_list)
745 struct iscsi_extra_response *extra_response;
747 if (strlen(value) > VALUE_MAXLEN) {
748 pr_err("Value for notunderstood key \"%s\" exceeds %d,"
749 " protocol error.\n", key, VALUE_MAXLEN);
750 return -1;
753 extra_response = kzalloc(sizeof(struct iscsi_extra_response), GFP_KERNEL);
754 if (!extra_response) {
755 pr_err("Unable to allocate memory for"
756 " struct iscsi_extra_response.\n");
757 return -1;
759 INIT_LIST_HEAD(&extra_response->er_list);
761 strlcpy(extra_response->key, key, sizeof(extra_response->key));
762 strlcpy(extra_response->value, NOTUNDERSTOOD,
763 sizeof(extra_response->value));
765 list_add_tail(&extra_response->er_list,
766 &param_list->extra_response_list);
767 return 0;
770 static int iscsi_check_for_auth_key(char *key)
773 * RFC 1994
775 if (!strcmp(key, "CHAP_A") || !strcmp(key, "CHAP_I") ||
776 !strcmp(key, "CHAP_C") || !strcmp(key, "CHAP_N") ||
777 !strcmp(key, "CHAP_R"))
778 return 1;
781 * RFC 2945
783 if (!strcmp(key, "SRP_U") || !strcmp(key, "SRP_N") ||
784 !strcmp(key, "SRP_g") || !strcmp(key, "SRP_s") ||
785 !strcmp(key, "SRP_A") || !strcmp(key, "SRP_B") ||
786 !strcmp(key, "SRP_M") || !strcmp(key, "SRP_HM"))
787 return 1;
789 return 0;
792 static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
794 if (IS_TYPE_BOOL_AND(param)) {
795 if (!strcmp(param->value, NO))
796 SET_PSTATE_REPLY_OPTIONAL(param);
797 } else if (IS_TYPE_BOOL_OR(param)) {
798 if (!strcmp(param->value, YES))
799 SET_PSTATE_REPLY_OPTIONAL(param);
801 * Required for gPXE iSCSI boot client
803 if (!strcmp(param->name, IMMEDIATEDATA))
804 SET_PSTATE_REPLY_OPTIONAL(param);
805 } else if (IS_TYPE_NUMBER(param)) {
806 if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
807 SET_PSTATE_REPLY_OPTIONAL(param);
809 * The GlobalSAN iSCSI Initiator for MacOSX does
810 * not respond to MaxBurstLength, FirstBurstLength,
811 * DefaultTime2Wait or DefaultTime2Retain parameter keys.
812 * So, we set them to 'reply optional' here, and assume the
813 * the defaults from iscsi_parameters.h if the initiator
814 * is not RFC compliant and the keys are not negotiated.
816 if (!strcmp(param->name, MAXBURSTLENGTH))
817 SET_PSTATE_REPLY_OPTIONAL(param);
818 if (!strcmp(param->name, FIRSTBURSTLENGTH))
819 SET_PSTATE_REPLY_OPTIONAL(param);
820 if (!strcmp(param->name, DEFAULTTIME2WAIT))
821 SET_PSTATE_REPLY_OPTIONAL(param);
822 if (!strcmp(param->name, DEFAULTTIME2RETAIN))
823 SET_PSTATE_REPLY_OPTIONAL(param);
825 * Required for gPXE iSCSI boot client
827 if (!strcmp(param->name, MAXCONNECTIONS))
828 SET_PSTATE_REPLY_OPTIONAL(param);
829 } else if (IS_PHASE_DECLARATIVE(param))
830 SET_PSTATE_REPLY_OPTIONAL(param);
833 static int iscsi_check_boolean_value(struct iscsi_param *param, char *value)
835 if (strcmp(value, YES) && strcmp(value, NO)) {
836 pr_err("Illegal value for \"%s\", must be either"
837 " \"%s\" or \"%s\".\n", param->name, YES, NO);
838 return -1;
841 return 0;
844 static int iscsi_check_numerical_value(struct iscsi_param *param, char *value_ptr)
846 char *tmpptr;
847 int value = 0;
849 value = simple_strtoul(value_ptr, &tmpptr, 0);
851 if (IS_TYPERANGE_0_TO_2(param)) {
852 if ((value < 0) || (value > 2)) {
853 pr_err("Illegal value for \"%s\", must be"
854 " between 0 and 2.\n", param->name);
855 return -1;
857 return 0;
859 if (IS_TYPERANGE_0_TO_3600(param)) {
860 if ((value < 0) || (value > 3600)) {
861 pr_err("Illegal value for \"%s\", must be"
862 " between 0 and 3600.\n", param->name);
863 return -1;
865 return 0;
867 if (IS_TYPERANGE_0_TO_32767(param)) {
868 if ((value < 0) || (value > 32767)) {
869 pr_err("Illegal value for \"%s\", must be"
870 " between 0 and 32767.\n", param->name);
871 return -1;
873 return 0;
875 if (IS_TYPERANGE_0_TO_65535(param)) {
876 if ((value < 0) || (value > 65535)) {
877 pr_err("Illegal value for \"%s\", must be"
878 " between 0 and 65535.\n", param->name);
879 return -1;
881 return 0;
883 if (IS_TYPERANGE_1_TO_65535(param)) {
884 if ((value < 1) || (value > 65535)) {
885 pr_err("Illegal value for \"%s\", must be"
886 " between 1 and 65535.\n", param->name);
887 return -1;
889 return 0;
891 if (IS_TYPERANGE_2_TO_3600(param)) {
892 if ((value < 2) || (value > 3600)) {
893 pr_err("Illegal value for \"%s\", must be"
894 " between 2 and 3600.\n", param->name);
895 return -1;
897 return 0;
899 if (IS_TYPERANGE_512_TO_16777215(param)) {
900 if ((value < 512) || (value > 16777215)) {
901 pr_err("Illegal value for \"%s\", must be"
902 " between 512 and 16777215.\n", param->name);
903 return -1;
905 return 0;
908 return 0;
911 static int iscsi_check_numerical_range_value(struct iscsi_param *param, char *value)
913 char *left_val_ptr = NULL, *right_val_ptr = NULL;
914 char *tilde_ptr = NULL;
915 u32 left_val, right_val, local_left_val;
917 if (strcmp(param->name, IFMARKINT) &&
918 strcmp(param->name, OFMARKINT)) {
919 pr_err("Only parameters \"%s\" or \"%s\" may contain a"
920 " numerical range value.\n", IFMARKINT, OFMARKINT);
921 return -1;
924 if (IS_PSTATE_PROPOSER(param))
925 return 0;
927 tilde_ptr = strchr(value, '~');
928 if (!tilde_ptr) {
929 pr_err("Unable to locate numerical range indicator"
930 " \"~\" for \"%s\".\n", param->name);
931 return -1;
933 *tilde_ptr = '\0';
935 left_val_ptr = value;
936 right_val_ptr = value + strlen(left_val_ptr) + 1;
938 if (iscsi_check_numerical_value(param, left_val_ptr) < 0)
939 return -1;
940 if (iscsi_check_numerical_value(param, right_val_ptr) < 0)
941 return -1;
943 left_val = simple_strtoul(left_val_ptr, NULL, 0);
944 right_val = simple_strtoul(right_val_ptr, NULL, 0);
945 *tilde_ptr = '~';
947 if (right_val < left_val) {
948 pr_err("Numerical range for parameter \"%s\" contains"
949 " a right value which is less than the left.\n",
950 param->name);
951 return -1;
955 * For now, enforce reasonable defaults for [I,O]FMarkInt.
957 tilde_ptr = strchr(param->value, '~');
958 if (!tilde_ptr) {
959 pr_err("Unable to locate numerical range indicator"
960 " \"~\" for \"%s\".\n", param->name);
961 return -1;
963 *tilde_ptr = '\0';
965 left_val_ptr = param->value;
966 right_val_ptr = param->value + strlen(left_val_ptr) + 1;
968 local_left_val = simple_strtoul(left_val_ptr, NULL, 0);
969 *tilde_ptr = '~';
971 if (param->set_param) {
972 if ((left_val < local_left_val) ||
973 (right_val < local_left_val)) {
974 pr_err("Passed value range \"%u~%u\" is below"
975 " minimum left value \"%u\" for key \"%s\","
976 " rejecting.\n", left_val, right_val,
977 local_left_val, param->name);
978 return -1;
980 } else {
981 if ((left_val < local_left_val) &&
982 (right_val < local_left_val)) {
983 pr_err("Received value range \"%u~%u\" is"
984 " below minimum left value \"%u\" for key"
985 " \"%s\", rejecting.\n", left_val, right_val,
986 local_left_val, param->name);
987 SET_PSTATE_REJECT(param);
988 if (iscsi_update_param_value(param, REJECT) < 0)
989 return -1;
993 return 0;
996 static int iscsi_check_string_or_list_value(struct iscsi_param *param, char *value)
998 if (IS_PSTATE_PROPOSER(param))
999 return 0;
1001 if (IS_TYPERANGE_AUTH_PARAM(param)) {
1002 if (strcmp(value, KRB5) && strcmp(value, SPKM1) &&
1003 strcmp(value, SPKM2) && strcmp(value, SRP) &&
1004 strcmp(value, CHAP) && strcmp(value, NONE)) {
1005 pr_err("Illegal value for \"%s\", must be"
1006 " \"%s\", \"%s\", \"%s\", \"%s\", \"%s\""
1007 " or \"%s\".\n", param->name, KRB5,
1008 SPKM1, SPKM2, SRP, CHAP, NONE);
1009 return -1;
1012 if (IS_TYPERANGE_DIGEST_PARAM(param)) {
1013 if (strcmp(value, CRC32C) && strcmp(value, NONE)) {
1014 pr_err("Illegal value for \"%s\", must be"
1015 " \"%s\" or \"%s\".\n", param->name,
1016 CRC32C, NONE);
1017 return -1;
1020 if (IS_TYPERANGE_SESSIONTYPE(param)) {
1021 if (strcmp(value, DISCOVERY) && strcmp(value, NORMAL)) {
1022 pr_err("Illegal value for \"%s\", must be"
1023 " \"%s\" or \"%s\".\n", param->name,
1024 DISCOVERY, NORMAL);
1025 return -1;
1029 return 0;
1033 * This function is used to pick a value range number, currently just
1034 * returns the lesser of both right values.
1036 static char *iscsi_get_value_from_number_range(
1037 struct iscsi_param *param,
1038 char *value)
1040 char *end_ptr, *tilde_ptr1 = NULL, *tilde_ptr2 = NULL;
1041 u32 acceptor_right_value, proposer_right_value;
1043 tilde_ptr1 = strchr(value, '~');
1044 if (!tilde_ptr1)
1045 return NULL;
1046 *tilde_ptr1++ = '\0';
1047 proposer_right_value = simple_strtoul(tilde_ptr1, &end_ptr, 0);
1049 tilde_ptr2 = strchr(param->value, '~');
1050 if (!tilde_ptr2)
1051 return NULL;
1052 *tilde_ptr2++ = '\0';
1053 acceptor_right_value = simple_strtoul(tilde_ptr2, &end_ptr, 0);
1055 return (acceptor_right_value >= proposer_right_value) ?
1056 tilde_ptr1 : tilde_ptr2;
1059 static char *iscsi_check_valuelist_for_support(
1060 struct iscsi_param *param,
1061 char *value)
1063 char *tmp1 = NULL, *tmp2 = NULL;
1064 char *acceptor_values = NULL, *proposer_values = NULL;
1066 acceptor_values = param->value;
1067 proposer_values = value;
1069 do {
1070 if (!proposer_values)
1071 return NULL;
1072 tmp1 = strchr(proposer_values, ',');
1073 if (tmp1)
1074 *tmp1 = '\0';
1075 acceptor_values = param->value;
1076 do {
1077 if (!acceptor_values) {
1078 if (tmp1)
1079 *tmp1 = ',';
1080 return NULL;
1082 tmp2 = strchr(acceptor_values, ',');
1083 if (tmp2)
1084 *tmp2 = '\0';
1085 if (!strcmp(acceptor_values, proposer_values)) {
1086 if (tmp2)
1087 *tmp2 = ',';
1088 goto out;
1090 if (tmp2)
1091 *tmp2++ = ',';
1093 acceptor_values = tmp2;
1094 } while (acceptor_values);
1095 if (tmp1)
1096 *tmp1++ = ',';
1097 proposer_values = tmp1;
1098 } while (proposer_values);
1100 out:
1101 return proposer_values;
1104 static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
1105 struct iscsi_conn *conn)
1107 u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;
1108 char *negoitated_value = NULL;
1110 if (IS_PSTATE_ACCEPTOR(param)) {
1111 pr_err("Received key \"%s\" twice, protocol error.\n",
1112 param->name);
1113 return -1;
1116 if (IS_PSTATE_REJECT(param))
1117 return 0;
1119 if (IS_TYPE_BOOL_AND(param)) {
1120 if (!strcmp(value, YES))
1121 proposer_boolean_value = 1;
1122 if (!strcmp(param->value, YES))
1123 acceptor_boolean_value = 1;
1124 if (acceptor_boolean_value && proposer_boolean_value)
1125 do {} while (0);
1126 else {
1127 if (iscsi_update_param_value(param, NO) < 0)
1128 return -1;
1129 if (!proposer_boolean_value)
1130 SET_PSTATE_REPLY_OPTIONAL(param);
1132 } else if (IS_TYPE_BOOL_OR(param)) {
1133 if (!strcmp(value, YES))
1134 proposer_boolean_value = 1;
1135 if (!strcmp(param->value, YES))
1136 acceptor_boolean_value = 1;
1137 if (acceptor_boolean_value || proposer_boolean_value) {
1138 if (iscsi_update_param_value(param, YES) < 0)
1139 return -1;
1140 if (proposer_boolean_value)
1141 SET_PSTATE_REPLY_OPTIONAL(param);
1143 } else if (IS_TYPE_NUMBER(param)) {
1144 char *tmpptr, buf[11];
1145 u32 acceptor_value = simple_strtoul(param->value, &tmpptr, 0);
1146 u32 proposer_value = simple_strtoul(value, &tmpptr, 0);
1148 memset(buf, 0, sizeof(buf));
1150 if (!strcmp(param->name, MAXCONNECTIONS) ||
1151 !strcmp(param->name, MAXBURSTLENGTH) ||
1152 !strcmp(param->name, FIRSTBURSTLENGTH) ||
1153 !strcmp(param->name, MAXOUTSTANDINGR2T) ||
1154 !strcmp(param->name, DEFAULTTIME2RETAIN) ||
1155 !strcmp(param->name, ERRORRECOVERYLEVEL)) {
1156 if (proposer_value > acceptor_value) {
1157 sprintf(buf, "%u", acceptor_value);
1158 if (iscsi_update_param_value(param,
1159 &buf[0]) < 0)
1160 return -1;
1161 } else {
1162 if (iscsi_update_param_value(param, value) < 0)
1163 return -1;
1165 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
1166 if (acceptor_value > proposer_value) {
1167 sprintf(buf, "%u", acceptor_value);
1168 if (iscsi_update_param_value(param,
1169 &buf[0]) < 0)
1170 return -1;
1171 } else {
1172 if (iscsi_update_param_value(param, value) < 0)
1173 return -1;
1175 } else {
1176 if (iscsi_update_param_value(param, value) < 0)
1177 return -1;
1180 if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
1181 struct iscsi_param *param_mxdsl;
1182 unsigned long long tmp;
1183 int rc;
1185 rc = strict_strtoull(param->value, 0, &tmp);
1186 if (rc < 0)
1187 return -1;
1189 conn->conn_ops->MaxRecvDataSegmentLength = tmp;
1190 pr_debug("Saving op->MaxRecvDataSegmentLength from"
1191 " original initiator received value: %u\n",
1192 conn->conn_ops->MaxRecvDataSegmentLength);
1194 param_mxdsl = iscsi_find_param_from_key(
1195 MAXXMITDATASEGMENTLENGTH,
1196 conn->param_list);
1197 if (!param_mxdsl)
1198 return -1;
1200 rc = iscsi_update_param_value(param,
1201 param_mxdsl->value);
1202 if (rc < 0)
1203 return -1;
1205 pr_debug("Updated %s to target MXDSL value: %s\n",
1206 param->name, param->value);
1209 } else if (IS_TYPE_NUMBER_RANGE(param)) {
1210 negoitated_value = iscsi_get_value_from_number_range(
1211 param, value);
1212 if (!negoitated_value)
1213 return -1;
1214 if (iscsi_update_param_value(param, negoitated_value) < 0)
1215 return -1;
1216 } else if (IS_TYPE_VALUE_LIST(param)) {
1217 negoitated_value = iscsi_check_valuelist_for_support(
1218 param, value);
1219 if (!negoitated_value) {
1220 pr_err("Proposer's value list \"%s\" contains"
1221 " no valid values from Acceptor's value list"
1222 " \"%s\".\n", value, param->value);
1223 return -1;
1225 if (iscsi_update_param_value(param, negoitated_value) < 0)
1226 return -1;
1227 } else if (IS_PHASE_DECLARATIVE(param)) {
1228 if (iscsi_update_param_value(param, value) < 0)
1229 return -1;
1230 SET_PSTATE_REPLY_OPTIONAL(param);
1233 return 0;
1236 static int iscsi_check_proposer_state(struct iscsi_param *param, char *value)
1238 if (IS_PSTATE_RESPONSE_GOT(param)) {
1239 pr_err("Received key \"%s\" twice, protocol error.\n",
1240 param->name);
1241 return -1;
1244 if (IS_TYPE_NUMBER_RANGE(param)) {
1245 u32 left_val = 0, right_val = 0, recieved_value = 0;
1246 char *left_val_ptr = NULL, *right_val_ptr = NULL;
1247 char *tilde_ptr = NULL;
1249 if (!strcmp(value, IRRELEVANT) || !strcmp(value, REJECT)) {
1250 if (iscsi_update_param_value(param, value) < 0)
1251 return -1;
1252 return 0;
1255 tilde_ptr = strchr(value, '~');
1256 if (tilde_ptr) {
1257 pr_err("Illegal \"~\" in response for \"%s\".\n",
1258 param->name);
1259 return -1;
1261 tilde_ptr = strchr(param->value, '~');
1262 if (!tilde_ptr) {
1263 pr_err("Unable to locate numerical range"
1264 " indicator \"~\" for \"%s\".\n", param->name);
1265 return -1;
1267 *tilde_ptr = '\0';
1269 left_val_ptr = param->value;
1270 right_val_ptr = param->value + strlen(left_val_ptr) + 1;
1271 left_val = simple_strtoul(left_val_ptr, NULL, 0);
1272 right_val = simple_strtoul(right_val_ptr, NULL, 0);
1273 recieved_value = simple_strtoul(value, NULL, 0);
1275 *tilde_ptr = '~';
1277 if ((recieved_value < left_val) ||
1278 (recieved_value > right_val)) {
1279 pr_err("Illegal response \"%s=%u\", value must"
1280 " be between %u and %u.\n", param->name,
1281 recieved_value, left_val, right_val);
1282 return -1;
1284 } else if (IS_TYPE_VALUE_LIST(param)) {
1285 char *comma_ptr = NULL, *tmp_ptr = NULL;
1287 comma_ptr = strchr(value, ',');
1288 if (comma_ptr) {
1289 pr_err("Illegal \",\" in response for \"%s\".\n",
1290 param->name);
1291 return -1;
1294 tmp_ptr = iscsi_check_valuelist_for_support(param, value);
1295 if (!tmp_ptr)
1296 return -1;
1299 if (iscsi_update_param_value(param, value) < 0)
1300 return -1;
1302 return 0;
1305 static int iscsi_check_value(struct iscsi_param *param, char *value)
1307 char *comma_ptr = NULL;
1309 if (!strcmp(value, REJECT)) {
1310 if (!strcmp(param->name, IFMARKINT) ||
1311 !strcmp(param->name, OFMARKINT)) {
1313 * Reject is not fatal for [I,O]FMarkInt, and causes
1314 * [I,O]FMarker to be reset to No. (See iSCSI v20 A.3.2)
1316 SET_PSTATE_REJECT(param);
1317 return 0;
1319 pr_err("Received %s=%s\n", param->name, value);
1320 return -1;
1322 if (!strcmp(value, IRRELEVANT)) {
1323 pr_debug("Received %s=%s\n", param->name, value);
1324 SET_PSTATE_IRRELEVANT(param);
1325 return 0;
1327 if (!strcmp(value, NOTUNDERSTOOD)) {
1328 if (!IS_PSTATE_PROPOSER(param)) {
1329 pr_err("Received illegal offer %s=%s\n",
1330 param->name, value);
1331 return -1;
1334 /* #warning FIXME: Add check for X-ExtensionKey here */
1335 pr_err("Standard iSCSI key \"%s\" cannot be answered"
1336 " with \"%s\", protocol error.\n", param->name, value);
1337 return -1;
1340 do {
1341 comma_ptr = NULL;
1342 comma_ptr = strchr(value, ',');
1344 if (comma_ptr && !IS_TYPE_VALUE_LIST(param)) {
1345 pr_err("Detected value separator \",\", but"
1346 " key \"%s\" does not allow a value list,"
1347 " protocol error.\n", param->name);
1348 return -1;
1350 if (comma_ptr)
1351 *comma_ptr = '\0';
1353 if (strlen(value) > VALUE_MAXLEN) {
1354 pr_err("Value for key \"%s\" exceeds %d,"
1355 " protocol error.\n", param->name,
1356 VALUE_MAXLEN);
1357 return -1;
1360 if (IS_TYPE_BOOL_AND(param) || IS_TYPE_BOOL_OR(param)) {
1361 if (iscsi_check_boolean_value(param, value) < 0)
1362 return -1;
1363 } else if (IS_TYPE_NUMBER(param)) {
1364 if (iscsi_check_numerical_value(param, value) < 0)
1365 return -1;
1366 } else if (IS_TYPE_NUMBER_RANGE(param)) {
1367 if (iscsi_check_numerical_range_value(param, value) < 0)
1368 return -1;
1369 } else if (IS_TYPE_STRING(param) || IS_TYPE_VALUE_LIST(param)) {
1370 if (iscsi_check_string_or_list_value(param, value) < 0)
1371 return -1;
1372 } else {
1373 pr_err("Huh? 0x%02x\n", param->type);
1374 return -1;
1377 if (comma_ptr)
1378 *comma_ptr++ = ',';
1380 value = comma_ptr;
1381 } while (value);
1383 return 0;
1386 static struct iscsi_param *__iscsi_check_key(
1387 char *key,
1388 int sender,
1389 struct iscsi_param_list *param_list)
1391 struct iscsi_param *param;
1393 if (strlen(key) > KEY_MAXLEN) {
1394 pr_err("Length of key name \"%s\" exceeds %d.\n",
1395 key, KEY_MAXLEN);
1396 return NULL;
1399 param = iscsi_find_param_from_key(key, param_list);
1400 if (!param)
1401 return NULL;
1403 if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
1404 pr_err("Key \"%s\" may not be sent to %s,"
1405 " protocol error.\n", param->name,
1406 (sender & SENDER_RECEIVER) ? "target" : "initiator");
1407 return NULL;
1410 if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
1411 pr_err("Key \"%s\" may not be sent to %s,"
1412 " protocol error.\n", param->name,
1413 (sender & SENDER_RECEIVER) ? "initiator" : "target");
1414 return NULL;
1417 return param;
1420 static struct iscsi_param *iscsi_check_key(
1421 char *key,
1422 int phase,
1423 int sender,
1424 struct iscsi_param_list *param_list)
1426 struct iscsi_param *param;
1428 * Key name length must not exceed 63 bytes. (See iSCSI v20 5.1)
1430 if (strlen(key) > KEY_MAXLEN) {
1431 pr_err("Length of key name \"%s\" exceeds %d.\n",
1432 key, KEY_MAXLEN);
1433 return NULL;
1436 param = iscsi_find_param_from_key(key, param_list);
1437 if (!param)
1438 return NULL;
1440 if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
1441 pr_err("Key \"%s\" may not be sent to %s,"
1442 " protocol error.\n", param->name,
1443 (sender & SENDER_RECEIVER) ? "target" : "initiator");
1444 return NULL;
1446 if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
1447 pr_err("Key \"%s\" may not be sent to %s,"
1448 " protocol error.\n", param->name,
1449 (sender & SENDER_RECEIVER) ? "initiator" : "target");
1450 return NULL;
1453 if (IS_PSTATE_ACCEPTOR(param)) {
1454 pr_err("Key \"%s\" received twice, protocol error.\n",
1455 key);
1456 return NULL;
1459 if (!phase)
1460 return param;
1462 if (!(param->phase & phase)) {
1463 pr_err("Key \"%s\" may not be negotiated during ",
1464 param->name);
1465 switch (phase) {
1466 case PHASE_SECURITY:
1467 pr_debug("Security phase.\n");
1468 break;
1469 case PHASE_OPERATIONAL:
1470 pr_debug("Operational phase.\n");
1471 break;
1472 default:
1473 pr_debug("Unknown phase.\n");
1475 return NULL;
1478 return param;
1481 static int iscsi_enforce_integrity_rules(
1482 u8 phase,
1483 struct iscsi_param_list *param_list)
1485 char *tmpptr;
1486 u8 DataSequenceInOrder = 0;
1487 u8 ErrorRecoveryLevel = 0, SessionType = 0;
1488 u8 IFMarker = 0, OFMarker = 0;
1489 u8 IFMarkInt_Reject = 1, OFMarkInt_Reject = 1;
1490 u32 FirstBurstLength = 0, MaxBurstLength = 0;
1491 struct iscsi_param *param = NULL;
1493 list_for_each_entry(param, &param_list->param_list, p_list) {
1494 if (!(param->phase & phase))
1495 continue;
1496 if (!strcmp(param->name, SESSIONTYPE))
1497 if (!strcmp(param->value, NORMAL))
1498 SessionType = 1;
1499 if (!strcmp(param->name, ERRORRECOVERYLEVEL))
1500 ErrorRecoveryLevel = simple_strtoul(param->value,
1501 &tmpptr, 0);
1502 if (!strcmp(param->name, DATASEQUENCEINORDER))
1503 if (!strcmp(param->value, YES))
1504 DataSequenceInOrder = 1;
1505 if (!strcmp(param->name, MAXBURSTLENGTH))
1506 MaxBurstLength = simple_strtoul(param->value,
1507 &tmpptr, 0);
1508 if (!strcmp(param->name, IFMARKER))
1509 if (!strcmp(param->value, YES))
1510 IFMarker = 1;
1511 if (!strcmp(param->name, OFMARKER))
1512 if (!strcmp(param->value, YES))
1513 OFMarker = 1;
1514 if (!strcmp(param->name, IFMARKINT))
1515 if (!strcmp(param->value, REJECT))
1516 IFMarkInt_Reject = 1;
1517 if (!strcmp(param->name, OFMARKINT))
1518 if (!strcmp(param->value, REJECT))
1519 OFMarkInt_Reject = 1;
1522 list_for_each_entry(param, &param_list->param_list, p_list) {
1523 if (!(param->phase & phase))
1524 continue;
1525 if (!SessionType && (!IS_PSTATE_ACCEPTOR(param) &&
1526 (strcmp(param->name, IFMARKER) &&
1527 strcmp(param->name, OFMARKER) &&
1528 strcmp(param->name, IFMARKINT) &&
1529 strcmp(param->name, OFMARKINT))))
1530 continue;
1531 if (!strcmp(param->name, MAXOUTSTANDINGR2T) &&
1532 DataSequenceInOrder && (ErrorRecoveryLevel > 0)) {
1533 if (strcmp(param->value, "1")) {
1534 if (iscsi_update_param_value(param, "1") < 0)
1535 return -1;
1536 pr_debug("Reset \"%s\" to \"%s\".\n",
1537 param->name, param->value);
1540 if (!strcmp(param->name, MAXCONNECTIONS) && !SessionType) {
1541 if (strcmp(param->value, "1")) {
1542 if (iscsi_update_param_value(param, "1") < 0)
1543 return -1;
1544 pr_debug("Reset \"%s\" to \"%s\".\n",
1545 param->name, param->value);
1548 if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
1549 FirstBurstLength = simple_strtoul(param->value,
1550 &tmpptr, 0);
1551 if (FirstBurstLength > MaxBurstLength) {
1552 char tmpbuf[11];
1553 memset(tmpbuf, 0, sizeof(tmpbuf));
1554 sprintf(tmpbuf, "%u", MaxBurstLength);
1555 if (iscsi_update_param_value(param, tmpbuf))
1556 return -1;
1557 pr_debug("Reset \"%s\" to \"%s\".\n",
1558 param->name, param->value);
1561 if (!strcmp(param->name, IFMARKER) && IFMarkInt_Reject) {
1562 if (iscsi_update_param_value(param, NO) < 0)
1563 return -1;
1564 IFMarker = 0;
1565 pr_debug("Reset \"%s\" to \"%s\".\n",
1566 param->name, param->value);
1568 if (!strcmp(param->name, OFMARKER) && OFMarkInt_Reject) {
1569 if (iscsi_update_param_value(param, NO) < 0)
1570 return -1;
1571 OFMarker = 0;
1572 pr_debug("Reset \"%s\" to \"%s\".\n",
1573 param->name, param->value);
1575 if (!strcmp(param->name, IFMARKINT) && !IFMarker) {
1576 if (!strcmp(param->value, REJECT))
1577 continue;
1578 param->state &= ~PSTATE_NEGOTIATE;
1579 if (iscsi_update_param_value(param, IRRELEVANT) < 0)
1580 return -1;
1581 pr_debug("Reset \"%s\" to \"%s\".\n",
1582 param->name, param->value);
1584 if (!strcmp(param->name, OFMARKINT) && !OFMarker) {
1585 if (!strcmp(param->value, REJECT))
1586 continue;
1587 param->state &= ~PSTATE_NEGOTIATE;
1588 if (iscsi_update_param_value(param, IRRELEVANT) < 0)
1589 return -1;
1590 pr_debug("Reset \"%s\" to \"%s\".\n",
1591 param->name, param->value);
1595 return 0;
1598 int iscsi_decode_text_input(
1599 u8 phase,
1600 u8 sender,
1601 char *textbuf,
1602 u32 length,
1603 struct iscsi_conn *conn)
1605 struct iscsi_param_list *param_list = conn->param_list;
1606 char *tmpbuf, *start = NULL, *end = NULL;
1608 tmpbuf = kzalloc(length + 1, GFP_KERNEL);
1609 if (!tmpbuf) {
1610 pr_err("Unable to allocate memory for tmpbuf.\n");
1611 return -1;
1614 memcpy(tmpbuf, textbuf, length);
1615 tmpbuf[length] = '\0';
1616 start = tmpbuf;
1617 end = (start + length);
1619 while (start < end) {
1620 char *key, *value;
1621 struct iscsi_param *param;
1623 if (iscsi_extract_key_value(start, &key, &value) < 0) {
1624 kfree(tmpbuf);
1625 return -1;
1628 pr_debug("Got key: %s=%s\n", key, value);
1630 if (phase & PHASE_SECURITY) {
1631 if (iscsi_check_for_auth_key(key) > 0) {
1632 kfree(tmpbuf);
1633 return 1;
1637 param = iscsi_check_key(key, phase, sender, param_list);
1638 if (!param) {
1639 if (iscsi_add_notunderstood_response(key,
1640 value, param_list) < 0) {
1641 kfree(tmpbuf);
1642 return -1;
1644 start += strlen(key) + strlen(value) + 2;
1645 continue;
1647 if (iscsi_check_value(param, value) < 0) {
1648 kfree(tmpbuf);
1649 return -1;
1652 start += strlen(key) + strlen(value) + 2;
1654 if (IS_PSTATE_PROPOSER(param)) {
1655 if (iscsi_check_proposer_state(param, value) < 0) {
1656 kfree(tmpbuf);
1657 return -1;
1659 SET_PSTATE_RESPONSE_GOT(param);
1660 } else {
1661 if (iscsi_check_acceptor_state(param, value, conn) < 0) {
1662 kfree(tmpbuf);
1663 return -1;
1665 SET_PSTATE_ACCEPTOR(param);
1669 kfree(tmpbuf);
1670 return 0;
1673 int iscsi_encode_text_output(
1674 u8 phase,
1675 u8 sender,
1676 char *textbuf,
1677 u32 *length,
1678 struct iscsi_param_list *param_list)
1680 char *output_buf = NULL;
1681 struct iscsi_extra_response *er;
1682 struct iscsi_param *param;
1684 output_buf = textbuf + *length;
1686 if (iscsi_enforce_integrity_rules(phase, param_list) < 0)
1687 return -1;
1689 list_for_each_entry(param, &param_list->param_list, p_list) {
1690 if (!(param->sender & sender))
1691 continue;
1692 if (IS_PSTATE_ACCEPTOR(param) &&
1693 !IS_PSTATE_RESPONSE_SENT(param) &&
1694 !IS_PSTATE_REPLY_OPTIONAL(param) &&
1695 (param->phase & phase)) {
1696 *length += sprintf(output_buf, "%s=%s",
1697 param->name, param->value);
1698 *length += 1;
1699 output_buf = textbuf + *length;
1700 SET_PSTATE_RESPONSE_SENT(param);
1701 pr_debug("Sending key: %s=%s\n",
1702 param->name, param->value);
1703 continue;
1705 if (IS_PSTATE_NEGOTIATE(param) &&
1706 !IS_PSTATE_ACCEPTOR(param) &&
1707 !IS_PSTATE_PROPOSER(param) &&
1708 (param->phase & phase)) {
1709 *length += sprintf(output_buf, "%s=%s",
1710 param->name, param->value);
1711 *length += 1;
1712 output_buf = textbuf + *length;
1713 SET_PSTATE_PROPOSER(param);
1714 iscsi_check_proposer_for_optional_reply(param);
1715 pr_debug("Sending key: %s=%s\n",
1716 param->name, param->value);
1720 list_for_each_entry(er, &param_list->extra_response_list, er_list) {
1721 *length += sprintf(output_buf, "%s=%s", er->key, er->value);
1722 *length += 1;
1723 output_buf = textbuf + *length;
1724 pr_debug("Sending key: %s=%s\n", er->key, er->value);
1726 iscsi_release_extra_responses(param_list);
1728 return 0;
1731 int iscsi_check_negotiated_keys(struct iscsi_param_list *param_list)
1733 int ret = 0;
1734 struct iscsi_param *param;
1736 list_for_each_entry(param, &param_list->param_list, p_list) {
1737 if (IS_PSTATE_NEGOTIATE(param) &&
1738 IS_PSTATE_PROPOSER(param) &&
1739 !IS_PSTATE_RESPONSE_GOT(param) &&
1740 !IS_PSTATE_REPLY_OPTIONAL(param) &&
1741 !IS_PHASE_DECLARATIVE(param)) {
1742 pr_err("No response for proposed key \"%s\".\n",
1743 param->name);
1744 ret = -1;
1748 return ret;
1751 int iscsi_change_param_value(
1752 char *keyvalue,
1753 struct iscsi_param_list *param_list,
1754 int check_key)
1756 char *key = NULL, *value = NULL;
1757 struct iscsi_param *param;
1758 int sender = 0;
1760 if (iscsi_extract_key_value(keyvalue, &key, &value) < 0)
1761 return -1;
1763 if (!check_key) {
1764 param = __iscsi_check_key(keyvalue, sender, param_list);
1765 if (!param)
1766 return -1;
1767 } else {
1768 param = iscsi_check_key(keyvalue, 0, sender, param_list);
1769 if (!param)
1770 return -1;
1772 param->set_param = 1;
1773 if (iscsi_check_value(param, value) < 0) {
1774 param->set_param = 0;
1775 return -1;
1777 param->set_param = 0;
1780 if (iscsi_update_param_value(param, value) < 0)
1781 return -1;
1783 return 0;
1786 void iscsi_set_connection_parameters(
1787 struct iscsi_conn_ops *ops,
1788 struct iscsi_param_list *param_list)
1790 char *tmpptr;
1791 struct iscsi_param *param;
1793 pr_debug("---------------------------------------------------"
1794 "---------------\n");
1795 list_for_each_entry(param, &param_list->param_list, p_list) {
1797 * Special case to set MAXXMITDATASEGMENTLENGTH from the
1798 * target requested MaxRecvDataSegmentLength, even though
1799 * this key is not sent over the wire.
1801 if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
1802 ops->MaxXmitDataSegmentLength =
1803 simple_strtoul(param->value, &tmpptr, 0);
1804 pr_debug("MaxXmitDataSegmentLength: %s\n",
1805 param->value);
1808 if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
1809 continue;
1810 if (!strcmp(param->name, AUTHMETHOD)) {
1811 pr_debug("AuthMethod: %s\n",
1812 param->value);
1813 } else if (!strcmp(param->name, HEADERDIGEST)) {
1814 ops->HeaderDigest = !strcmp(param->value, CRC32C);
1815 pr_debug("HeaderDigest: %s\n",
1816 param->value);
1817 } else if (!strcmp(param->name, DATADIGEST)) {
1818 ops->DataDigest = !strcmp(param->value, CRC32C);
1819 pr_debug("DataDigest: %s\n",
1820 param->value);
1821 } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
1823 * At this point iscsi_check_acceptor_state() will have
1824 * set ops->MaxRecvDataSegmentLength from the original
1825 * initiator provided value.
1827 pr_debug("MaxRecvDataSegmentLength: %u\n",
1828 ops->MaxRecvDataSegmentLength);
1829 } else if (!strcmp(param->name, OFMARKER)) {
1830 ops->OFMarker = !strcmp(param->value, YES);
1831 pr_debug("OFMarker: %s\n",
1832 param->value);
1833 } else if (!strcmp(param->name, IFMARKER)) {
1834 ops->IFMarker = !strcmp(param->value, YES);
1835 pr_debug("IFMarker: %s\n",
1836 param->value);
1837 } else if (!strcmp(param->name, OFMARKINT)) {
1838 ops->OFMarkInt =
1839 simple_strtoul(param->value, &tmpptr, 0);
1840 pr_debug("OFMarkInt: %s\n",
1841 param->value);
1842 } else if (!strcmp(param->name, IFMARKINT)) {
1843 ops->IFMarkInt =
1844 simple_strtoul(param->value, &tmpptr, 0);
1845 pr_debug("IFMarkInt: %s\n",
1846 param->value);
1847 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
1848 ops->InitiatorRecvDataSegmentLength =
1849 simple_strtoul(param->value, &tmpptr, 0);
1850 pr_debug("InitiatorRecvDataSegmentLength: %s\n",
1851 param->value);
1852 ops->MaxRecvDataSegmentLength =
1853 ops->InitiatorRecvDataSegmentLength;
1854 pr_debug("Set MRDSL from InitiatorRecvDataSegmentLength\n");
1855 } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
1856 ops->TargetRecvDataSegmentLength =
1857 simple_strtoul(param->value, &tmpptr, 0);
1858 pr_debug("TargetRecvDataSegmentLength: %s\n",
1859 param->value);
1860 ops->MaxXmitDataSegmentLength =
1861 ops->TargetRecvDataSegmentLength;
1862 pr_debug("Set MXDSL from TargetRecvDataSegmentLength\n");
1865 pr_debug("----------------------------------------------------"
1866 "--------------\n");
1869 void iscsi_set_session_parameters(
1870 struct iscsi_sess_ops *ops,
1871 struct iscsi_param_list *param_list,
1872 int leading)
1874 char *tmpptr;
1875 struct iscsi_param *param;
1877 pr_debug("----------------------------------------------------"
1878 "--------------\n");
1879 list_for_each_entry(param, &param_list->param_list, p_list) {
1880 if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
1881 continue;
1882 if (!strcmp(param->name, INITIATORNAME)) {
1883 if (!param->value)
1884 continue;
1885 if (leading)
1886 snprintf(ops->InitiatorName,
1887 sizeof(ops->InitiatorName),
1888 "%s", param->value);
1889 pr_debug("InitiatorName: %s\n",
1890 param->value);
1891 } else if (!strcmp(param->name, INITIATORALIAS)) {
1892 if (!param->value)
1893 continue;
1894 snprintf(ops->InitiatorAlias,
1895 sizeof(ops->InitiatorAlias),
1896 "%s", param->value);
1897 pr_debug("InitiatorAlias: %s\n",
1898 param->value);
1899 } else if (!strcmp(param->name, TARGETNAME)) {
1900 if (!param->value)
1901 continue;
1902 if (leading)
1903 snprintf(ops->TargetName,
1904 sizeof(ops->TargetName),
1905 "%s", param->value);
1906 pr_debug("TargetName: %s\n",
1907 param->value);
1908 } else if (!strcmp(param->name, TARGETALIAS)) {
1909 if (!param->value)
1910 continue;
1911 snprintf(ops->TargetAlias, sizeof(ops->TargetAlias),
1912 "%s", param->value);
1913 pr_debug("TargetAlias: %s\n",
1914 param->value);
1915 } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
1916 ops->TargetPortalGroupTag =
1917 simple_strtoul(param->value, &tmpptr, 0);
1918 pr_debug("TargetPortalGroupTag: %s\n",
1919 param->value);
1920 } else if (!strcmp(param->name, MAXCONNECTIONS)) {
1921 ops->MaxConnections =
1922 simple_strtoul(param->value, &tmpptr, 0);
1923 pr_debug("MaxConnections: %s\n",
1924 param->value);
1925 } else if (!strcmp(param->name, INITIALR2T)) {
1926 ops->InitialR2T = !strcmp(param->value, YES);
1927 pr_debug("InitialR2T: %s\n",
1928 param->value);
1929 } else if (!strcmp(param->name, IMMEDIATEDATA)) {
1930 ops->ImmediateData = !strcmp(param->value, YES);
1931 pr_debug("ImmediateData: %s\n",
1932 param->value);
1933 } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
1934 ops->MaxBurstLength =
1935 simple_strtoul(param->value, &tmpptr, 0);
1936 pr_debug("MaxBurstLength: %s\n",
1937 param->value);
1938 } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
1939 ops->FirstBurstLength =
1940 simple_strtoul(param->value, &tmpptr, 0);
1941 pr_debug("FirstBurstLength: %s\n",
1942 param->value);
1943 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
1944 ops->DefaultTime2Wait =
1945 simple_strtoul(param->value, &tmpptr, 0);
1946 pr_debug("DefaultTime2Wait: %s\n",
1947 param->value);
1948 } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
1949 ops->DefaultTime2Retain =
1950 simple_strtoul(param->value, &tmpptr, 0);
1951 pr_debug("DefaultTime2Retain: %s\n",
1952 param->value);
1953 } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
1954 ops->MaxOutstandingR2T =
1955 simple_strtoul(param->value, &tmpptr, 0);
1956 pr_debug("MaxOutstandingR2T: %s\n",
1957 param->value);
1958 } else if (!strcmp(param->name, DATAPDUINORDER)) {
1959 ops->DataPDUInOrder = !strcmp(param->value, YES);
1960 pr_debug("DataPDUInOrder: %s\n",
1961 param->value);
1962 } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
1963 ops->DataSequenceInOrder = !strcmp(param->value, YES);
1964 pr_debug("DataSequenceInOrder: %s\n",
1965 param->value);
1966 } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
1967 ops->ErrorRecoveryLevel =
1968 simple_strtoul(param->value, &tmpptr, 0);
1969 pr_debug("ErrorRecoveryLevel: %s\n",
1970 param->value);
1971 } else if (!strcmp(param->name, SESSIONTYPE)) {
1972 ops->SessionType = !strcmp(param->value, DISCOVERY);
1973 pr_debug("SessionType: %s\n",
1974 param->value);
1975 } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
1976 ops->RDMAExtensions = !strcmp(param->value, YES);
1977 pr_debug("RDMAExtensions: %s\n",
1978 param->value);
1981 pr_debug("----------------------------------------------------"
1982 "--------------\n");