1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*******************************************************************************
3 * This file contains main functions related to iSCSI Parameter negotiation.
5 * (c) Copyright 2007-2013 Datera, Inc.
7 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
9 ******************************************************************************/
11 #include <linux/slab.h>
12 #include <linux/uio.h> /* struct kvec */
13 #include <target/iscsi/iscsi_target_core.h>
14 #include "iscsi_target_util.h"
15 #include "iscsi_target_parameters.h"
17 int iscsi_login_rx_data(
18 struct iscsi_conn *conn,
25 memset(&iov, 0, sizeof(struct kvec));
29 rx_got = rx_data(conn, &iov, 1, length);
30 if (rx_got != length) {
31 pr_err("rx_data returned %d, expecting %d.\n",
39 int iscsi_login_tx_data(
40 struct iscsi_conn *conn,
45 int length, tx_sent, iov_cnt = 1;
48 length = (ISCSI_HDR_LEN + text_length);
50 memset(&iov[0], 0, 2 * sizeof(struct kvec));
51 iov[0].iov_len = ISCSI_HDR_LEN;
52 iov[0].iov_base = pdu_buf;
54 if (text_buf && text_length) {
55 iov[1].iov_len = text_length;
56 iov[1].iov_base = text_buf;
60 tx_sent = tx_data(conn, &iov[0], iov_cnt, length);
61 if (tx_sent != length) {
62 pr_err("tx_data returned %d, expecting %d.\n",
70 void iscsi_dump_conn_ops(struct iscsi_conn_ops *conn_ops)
72 pr_debug("HeaderDigest: %s\n", (conn_ops->HeaderDigest) ?
74 pr_debug("DataDigest: %s\n", (conn_ops->DataDigest) ?
76 pr_debug("MaxRecvDataSegmentLength: %u\n",
77 conn_ops->MaxRecvDataSegmentLength);
80 void iscsi_dump_sess_ops(struct iscsi_sess_ops *sess_ops)
82 pr_debug("InitiatorName: %s\n", sess_ops->InitiatorName);
83 pr_debug("InitiatorAlias: %s\n", sess_ops->InitiatorAlias);
84 pr_debug("TargetName: %s\n", sess_ops->TargetName);
85 pr_debug("TargetAlias: %s\n", sess_ops->TargetAlias);
86 pr_debug("TargetPortalGroupTag: %hu\n",
87 sess_ops->TargetPortalGroupTag);
88 pr_debug("MaxConnections: %hu\n", sess_ops->MaxConnections);
89 pr_debug("InitialR2T: %s\n",
90 (sess_ops->InitialR2T) ? "Yes" : "No");
91 pr_debug("ImmediateData: %s\n", (sess_ops->ImmediateData) ?
93 pr_debug("MaxBurstLength: %u\n", sess_ops->MaxBurstLength);
94 pr_debug("FirstBurstLength: %u\n", sess_ops->FirstBurstLength);
95 pr_debug("DefaultTime2Wait: %hu\n", sess_ops->DefaultTime2Wait);
96 pr_debug("DefaultTime2Retain: %hu\n",
97 sess_ops->DefaultTime2Retain);
98 pr_debug("MaxOutstandingR2T: %hu\n",
99 sess_ops->MaxOutstandingR2T);
100 pr_debug("DataPDUInOrder: %s\n",
101 (sess_ops->DataPDUInOrder) ? "Yes" : "No");
102 pr_debug("DataSequenceInOrder: %s\n",
103 (sess_ops->DataSequenceInOrder) ? "Yes" : "No");
104 pr_debug("ErrorRecoveryLevel: %hu\n",
105 sess_ops->ErrorRecoveryLevel);
106 pr_debug("SessionType: %s\n", (sess_ops->SessionType) ?
107 "Discovery" : "Normal");
110 void iscsi_print_params(struct iscsi_param_list *param_list)
112 struct iscsi_param *param;
114 list_for_each_entry(param, ¶m_list->param_list, p_list)
115 pr_debug("%s: %s\n", param->name, param->value);
118 static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *param_list,
119 char *name, char *value, u8 phase, u8 scope, u8 sender,
120 u16 type_range, u8 use)
122 struct iscsi_param *param = NULL;
124 param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
126 pr_err("Unable to allocate memory for parameter.\n");
129 INIT_LIST_HEAD(¶m->p_list);
131 param->name = kstrdup(name, GFP_KERNEL);
133 pr_err("Unable to allocate memory for parameter name.\n");
137 param->value = kstrdup(value, GFP_KERNEL);
139 pr_err("Unable to allocate memory for parameter value.\n");
143 param->phase = phase;
144 param->scope = scope;
145 param->sender = sender;
147 param->type_range = type_range;
149 switch (param->type_range) {
150 case TYPERANGE_BOOL_AND:
151 param->type = TYPE_BOOL_AND;
153 case TYPERANGE_BOOL_OR:
154 param->type = TYPE_BOOL_OR;
156 case TYPERANGE_0_TO_2:
157 case TYPERANGE_0_TO_3600:
158 case TYPERANGE_0_TO_32767:
159 case TYPERANGE_0_TO_65535:
160 case TYPERANGE_1_TO_65535:
161 case TYPERANGE_2_TO_3600:
162 case TYPERANGE_512_TO_16777215:
163 param->type = TYPE_NUMBER;
166 case TYPERANGE_DIGEST:
167 param->type = TYPE_VALUE_LIST | TYPE_STRING;
169 case TYPERANGE_ISCSINAME:
170 case TYPERANGE_SESSIONTYPE:
171 case TYPERANGE_TARGETADDRESS:
173 param->type = TYPE_STRING;
176 pr_err("Unknown type_range 0x%02x\n",
180 list_add_tail(¶m->p_list, ¶m_list->param_list);
193 /* #warning Add extension keys */
194 int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
196 struct iscsi_param *param = NULL;
197 struct iscsi_param_list *pl;
199 pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
201 pr_err("Unable to allocate memory for"
202 " struct iscsi_param_list.\n");
205 INIT_LIST_HEAD(&pl->param_list);
206 INIT_LIST_HEAD(&pl->extra_response_list);
209 * The format for setting the initial parameter definitions are:
219 param = iscsi_set_default_param(pl, AUTHMETHOD, INITIAL_AUTHMETHOD,
220 PHASE_SECURITY, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
221 TYPERANGE_AUTH, USE_INITIAL_ONLY);
225 param = iscsi_set_default_param(pl, HEADERDIGEST, INITIAL_HEADERDIGEST,
226 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
227 TYPERANGE_DIGEST, USE_INITIAL_ONLY);
231 param = iscsi_set_default_param(pl, DATADIGEST, INITIAL_DATADIGEST,
232 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
233 TYPERANGE_DIGEST, USE_INITIAL_ONLY);
237 param = iscsi_set_default_param(pl, MAXCONNECTIONS,
238 INITIAL_MAXCONNECTIONS, PHASE_OPERATIONAL,
239 SCOPE_SESSION_WIDE, SENDER_BOTH,
240 TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
244 param = iscsi_set_default_param(pl, SENDTARGETS, INITIAL_SENDTARGETS,
245 PHASE_FFP0, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
250 param = iscsi_set_default_param(pl, TARGETNAME, INITIAL_TARGETNAME,
251 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_BOTH,
252 TYPERANGE_ISCSINAME, USE_ALL);
256 param = iscsi_set_default_param(pl, INITIATORNAME,
257 INITIAL_INITIATORNAME, PHASE_DECLARATIVE,
258 SCOPE_SESSION_WIDE, SENDER_INITIATOR,
259 TYPERANGE_ISCSINAME, USE_INITIAL_ONLY);
263 param = iscsi_set_default_param(pl, TARGETALIAS, INITIAL_TARGETALIAS,
264 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
265 TYPERANGE_UTF8, USE_ALL);
269 param = iscsi_set_default_param(pl, INITIATORALIAS,
270 INITIAL_INITIATORALIAS, PHASE_DECLARATIVE,
271 SCOPE_SESSION_WIDE, SENDER_INITIATOR, TYPERANGE_UTF8,
276 param = iscsi_set_default_param(pl, TARGETADDRESS,
277 INITIAL_TARGETADDRESS, PHASE_DECLARATIVE,
278 SCOPE_SESSION_WIDE, SENDER_TARGET,
279 TYPERANGE_TARGETADDRESS, USE_ALL);
283 param = iscsi_set_default_param(pl, TARGETPORTALGROUPTAG,
284 INITIAL_TARGETPORTALGROUPTAG,
285 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
286 TYPERANGE_0_TO_65535, USE_INITIAL_ONLY);
290 param = iscsi_set_default_param(pl, INITIALR2T, INITIAL_INITIALR2T,
291 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
292 TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
296 param = iscsi_set_default_param(pl, IMMEDIATEDATA,
297 INITIAL_IMMEDIATEDATA, PHASE_OPERATIONAL,
298 SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_AND,
303 param = iscsi_set_default_param(pl, MAXXMITDATASEGMENTLENGTH,
304 INITIAL_MAXXMITDATASEGMENTLENGTH,
305 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
306 TYPERANGE_512_TO_16777215, USE_ALL);
310 param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH,
311 INITIAL_MAXRECVDATASEGMENTLENGTH,
312 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
313 TYPERANGE_512_TO_16777215, USE_ALL);
317 param = iscsi_set_default_param(pl, MAXBURSTLENGTH,
318 INITIAL_MAXBURSTLENGTH, PHASE_OPERATIONAL,
319 SCOPE_SESSION_WIDE, SENDER_BOTH,
320 TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
324 param = iscsi_set_default_param(pl, FIRSTBURSTLENGTH,
325 INITIAL_FIRSTBURSTLENGTH,
326 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
327 TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
331 param = iscsi_set_default_param(pl, DEFAULTTIME2WAIT,
332 INITIAL_DEFAULTTIME2WAIT,
333 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
334 TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
338 param = iscsi_set_default_param(pl, DEFAULTTIME2RETAIN,
339 INITIAL_DEFAULTTIME2RETAIN,
340 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
341 TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
345 param = iscsi_set_default_param(pl, MAXOUTSTANDINGR2T,
346 INITIAL_MAXOUTSTANDINGR2T,
347 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
348 TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
352 param = iscsi_set_default_param(pl, DATAPDUINORDER,
353 INITIAL_DATAPDUINORDER, PHASE_OPERATIONAL,
354 SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_OR,
359 param = iscsi_set_default_param(pl, DATASEQUENCEINORDER,
360 INITIAL_DATASEQUENCEINORDER,
361 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
362 TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
366 param = iscsi_set_default_param(pl, ERRORRECOVERYLEVEL,
367 INITIAL_ERRORRECOVERYLEVEL,
368 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
369 TYPERANGE_0_TO_2, USE_LEADING_ONLY);
373 param = iscsi_set_default_param(pl, SESSIONTYPE, INITIAL_SESSIONTYPE,
374 PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
375 TYPERANGE_SESSIONTYPE, USE_LEADING_ONLY);
379 param = iscsi_set_default_param(pl, IFMARKER, INITIAL_IFMARKER,
380 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
381 TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
385 param = iscsi_set_default_param(pl, OFMARKER, INITIAL_OFMARKER,
386 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
387 TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
391 param = iscsi_set_default_param(pl, IFMARKINT, INITIAL_IFMARKINT,
392 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
393 TYPERANGE_UTF8, USE_INITIAL_ONLY);
397 param = iscsi_set_default_param(pl, OFMARKINT, INITIAL_OFMARKINT,
398 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
399 TYPERANGE_UTF8, USE_INITIAL_ONLY);
404 * Extra parameters for ISER from RFC-5046
406 param = iscsi_set_default_param(pl, RDMAEXTENSIONS, INITIAL_RDMAEXTENSIONS,
407 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
408 TYPERANGE_BOOL_AND, USE_LEADING_ONLY);
412 param = iscsi_set_default_param(pl, INITIATORRECVDATASEGMENTLENGTH,
413 INITIAL_INITIATORRECVDATASEGMENTLENGTH,
414 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
415 TYPERANGE_512_TO_16777215, USE_ALL);
419 param = iscsi_set_default_param(pl, TARGETRECVDATASEGMENTLENGTH,
420 INITIAL_TARGETRECVDATASEGMENTLENGTH,
421 PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
422 TYPERANGE_512_TO_16777215, USE_ALL);
426 *param_list_ptr = pl;
429 iscsi_release_param_list(pl);
433 int iscsi_set_keys_to_negotiate(
434 struct iscsi_param_list *param_list,
437 struct iscsi_param *param;
439 param_list->iser = iser;
441 list_for_each_entry(param, ¶m_list->param_list, p_list) {
443 if (!strcmp(param->name, AUTHMETHOD)) {
444 SET_PSTATE_NEGOTIATE(param);
445 } else if (!strcmp(param->name, HEADERDIGEST)) {
447 SET_PSTATE_NEGOTIATE(param);
448 } else if (!strcmp(param->name, DATADIGEST)) {
450 SET_PSTATE_NEGOTIATE(param);
451 } else if (!strcmp(param->name, MAXCONNECTIONS)) {
452 SET_PSTATE_NEGOTIATE(param);
453 } else if (!strcmp(param->name, TARGETNAME)) {
455 } else if (!strcmp(param->name, INITIATORNAME)) {
457 } else if (!strcmp(param->name, TARGETALIAS)) {
459 SET_PSTATE_NEGOTIATE(param);
460 } else if (!strcmp(param->name, INITIATORALIAS)) {
462 } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
463 SET_PSTATE_NEGOTIATE(param);
464 } else if (!strcmp(param->name, INITIALR2T)) {
465 SET_PSTATE_NEGOTIATE(param);
466 } else if (!strcmp(param->name, IMMEDIATEDATA)) {
467 SET_PSTATE_NEGOTIATE(param);
468 } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
470 SET_PSTATE_NEGOTIATE(param);
471 } else if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
473 } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
474 SET_PSTATE_NEGOTIATE(param);
475 } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
476 SET_PSTATE_NEGOTIATE(param);
477 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
478 SET_PSTATE_NEGOTIATE(param);
479 } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
480 SET_PSTATE_NEGOTIATE(param);
481 } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
482 SET_PSTATE_NEGOTIATE(param);
483 } else if (!strcmp(param->name, DATAPDUINORDER)) {
484 SET_PSTATE_NEGOTIATE(param);
485 } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
486 SET_PSTATE_NEGOTIATE(param);
487 } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
488 SET_PSTATE_NEGOTIATE(param);
489 } else if (!strcmp(param->name, SESSIONTYPE)) {
490 SET_PSTATE_NEGOTIATE(param);
491 } else if (!strcmp(param->name, IFMARKER)) {
492 SET_PSTATE_REJECT(param);
493 } else if (!strcmp(param->name, OFMARKER)) {
494 SET_PSTATE_REJECT(param);
495 } else if (!strcmp(param->name, IFMARKINT)) {
496 SET_PSTATE_REJECT(param);
497 } else if (!strcmp(param->name, OFMARKINT)) {
498 SET_PSTATE_REJECT(param);
499 } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
501 SET_PSTATE_NEGOTIATE(param);
502 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
504 SET_PSTATE_NEGOTIATE(param);
505 } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
507 SET_PSTATE_NEGOTIATE(param);
514 int iscsi_set_keys_irrelevant_for_discovery(
515 struct iscsi_param_list *param_list)
517 struct iscsi_param *param;
519 list_for_each_entry(param, ¶m_list->param_list, p_list) {
520 if (!strcmp(param->name, MAXCONNECTIONS))
521 param->state &= ~PSTATE_NEGOTIATE;
522 else if (!strcmp(param->name, INITIALR2T))
523 param->state &= ~PSTATE_NEGOTIATE;
524 else if (!strcmp(param->name, IMMEDIATEDATA))
525 param->state &= ~PSTATE_NEGOTIATE;
526 else if (!strcmp(param->name, MAXBURSTLENGTH))
527 param->state &= ~PSTATE_NEGOTIATE;
528 else if (!strcmp(param->name, FIRSTBURSTLENGTH))
529 param->state &= ~PSTATE_NEGOTIATE;
530 else if (!strcmp(param->name, MAXOUTSTANDINGR2T))
531 param->state &= ~PSTATE_NEGOTIATE;
532 else if (!strcmp(param->name, DATAPDUINORDER))
533 param->state &= ~PSTATE_NEGOTIATE;
534 else if (!strcmp(param->name, DATASEQUENCEINORDER))
535 param->state &= ~PSTATE_NEGOTIATE;
536 else if (!strcmp(param->name, ERRORRECOVERYLEVEL))
537 param->state &= ~PSTATE_NEGOTIATE;
538 else if (!strcmp(param->name, DEFAULTTIME2WAIT))
539 param->state &= ~PSTATE_NEGOTIATE;
540 else if (!strcmp(param->name, DEFAULTTIME2RETAIN))
541 param->state &= ~PSTATE_NEGOTIATE;
542 else if (!strcmp(param->name, IFMARKER))
543 param->state &= ~PSTATE_NEGOTIATE;
544 else if (!strcmp(param->name, OFMARKER))
545 param->state &= ~PSTATE_NEGOTIATE;
546 else if (!strcmp(param->name, IFMARKINT))
547 param->state &= ~PSTATE_NEGOTIATE;
548 else if (!strcmp(param->name, OFMARKINT))
549 param->state &= ~PSTATE_NEGOTIATE;
550 else if (!strcmp(param->name, RDMAEXTENSIONS))
551 param->state &= ~PSTATE_NEGOTIATE;
552 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH))
553 param->state &= ~PSTATE_NEGOTIATE;
554 else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH))
555 param->state &= ~PSTATE_NEGOTIATE;
561 int iscsi_copy_param_list(
562 struct iscsi_param_list **dst_param_list,
563 struct iscsi_param_list *src_param_list,
566 struct iscsi_param *param = NULL;
567 struct iscsi_param *new_param = NULL;
568 struct iscsi_param_list *param_list = NULL;
570 param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
572 pr_err("Unable to allocate memory for struct iscsi_param_list.\n");
575 INIT_LIST_HEAD(¶m_list->param_list);
576 INIT_LIST_HEAD(¶m_list->extra_response_list);
578 list_for_each_entry(param, &src_param_list->param_list, p_list) {
579 if (!leading && (param->scope & SCOPE_SESSION_WIDE)) {
580 if ((strcmp(param->name, "TargetName") != 0) &&
581 (strcmp(param->name, "InitiatorName") != 0) &&
582 (strcmp(param->name, "TargetPortalGroupTag") != 0))
586 new_param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
588 pr_err("Unable to allocate memory for struct iscsi_param.\n");
592 new_param->name = kstrdup(param->name, GFP_KERNEL);
593 new_param->value = kstrdup(param->value, GFP_KERNEL);
594 if (!new_param->value || !new_param->name) {
595 kfree(new_param->value);
596 kfree(new_param->name);
598 pr_err("Unable to allocate memory for parameter name/value.\n");
602 new_param->set_param = param->set_param;
603 new_param->phase = param->phase;
604 new_param->scope = param->scope;
605 new_param->sender = param->sender;
606 new_param->type = param->type;
607 new_param->use = param->use;
608 new_param->type_range = param->type_range;
610 list_add_tail(&new_param->p_list, ¶m_list->param_list);
613 if (!list_empty(¶m_list->param_list)) {
614 *dst_param_list = param_list;
616 pr_err("No parameters allocated.\n");
623 iscsi_release_param_list(param_list);
627 static void iscsi_release_extra_responses(struct iscsi_param_list *param_list)
629 struct iscsi_extra_response *er, *er_tmp;
631 list_for_each_entry_safe(er, er_tmp, ¶m_list->extra_response_list,
633 list_del(&er->er_list);
638 void iscsi_release_param_list(struct iscsi_param_list *param_list)
640 struct iscsi_param *param, *param_tmp;
642 list_for_each_entry_safe(param, param_tmp, ¶m_list->param_list,
644 list_del(¶m->p_list);
651 iscsi_release_extra_responses(param_list);
656 struct iscsi_param *iscsi_find_param_from_key(
658 struct iscsi_param_list *param_list)
660 struct iscsi_param *param;
662 if (!key || !param_list) {
663 pr_err("Key or parameter list pointer is NULL.\n");
667 list_for_each_entry(param, ¶m_list->param_list, p_list) {
668 if (!strcmp(key, param->name))
672 pr_err("Unable to locate key \"%s\".\n", key);
675 EXPORT_SYMBOL(iscsi_find_param_from_key);
677 int iscsi_extract_key_value(char *textbuf, char **key, char **value)
679 *value = strchr(textbuf, '=');
681 pr_err("Unable to locate \"=\" separator for key,"
682 " ignoring request.\n");
693 int iscsi_update_param_value(struct iscsi_param *param, char *value)
697 param->value = kstrdup(value, GFP_KERNEL);
699 pr_err("Unable to allocate memory for value.\n");
703 pr_debug("iSCSI Parameter updated to %s=%s\n",
704 param->name, param->value);
708 static int iscsi_add_notunderstood_response(
711 struct iscsi_param_list *param_list)
713 struct iscsi_extra_response *extra_response;
715 if (strlen(value) > VALUE_MAXLEN) {
716 pr_err("Value for notunderstood key \"%s\" exceeds %d,"
717 " protocol error.\n", key, VALUE_MAXLEN);
721 extra_response = kzalloc(sizeof(struct iscsi_extra_response), GFP_KERNEL);
722 if (!extra_response) {
723 pr_err("Unable to allocate memory for"
724 " struct iscsi_extra_response.\n");
727 INIT_LIST_HEAD(&extra_response->er_list);
729 strlcpy(extra_response->key, key, sizeof(extra_response->key));
730 strlcpy(extra_response->value, NOTUNDERSTOOD,
731 sizeof(extra_response->value));
733 list_add_tail(&extra_response->er_list,
734 ¶m_list->extra_response_list);
738 static int iscsi_check_for_auth_key(char *key)
743 if (!strcmp(key, "CHAP_A") || !strcmp(key, "CHAP_I") ||
744 !strcmp(key, "CHAP_C") || !strcmp(key, "CHAP_N") ||
745 !strcmp(key, "CHAP_R"))
751 if (!strcmp(key, "SRP_U") || !strcmp(key, "SRP_N") ||
752 !strcmp(key, "SRP_g") || !strcmp(key, "SRP_s") ||
753 !strcmp(key, "SRP_A") || !strcmp(key, "SRP_B") ||
754 !strcmp(key, "SRP_M") || !strcmp(key, "SRP_HM"))
760 static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param,
761 bool keys_workaround)
763 if (IS_TYPE_BOOL_AND(param)) {
764 if (!strcmp(param->value, NO))
765 SET_PSTATE_REPLY_OPTIONAL(param);
766 } else if (IS_TYPE_BOOL_OR(param)) {
767 if (!strcmp(param->value, YES))
768 SET_PSTATE_REPLY_OPTIONAL(param);
770 if (keys_workaround) {
772 * Required for gPXE iSCSI boot client
774 if (!strcmp(param->name, IMMEDIATEDATA))
775 SET_PSTATE_REPLY_OPTIONAL(param);
777 } else if (IS_TYPE_NUMBER(param)) {
778 if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
779 SET_PSTATE_REPLY_OPTIONAL(param);
781 if (keys_workaround) {
783 * Required for Mellanox Flexboot PXE boot ROM
785 if (!strcmp(param->name, FIRSTBURSTLENGTH))
786 SET_PSTATE_REPLY_OPTIONAL(param);
789 * Required for gPXE iSCSI boot client
791 if (!strcmp(param->name, MAXCONNECTIONS))
792 SET_PSTATE_REPLY_OPTIONAL(param);
794 } else if (IS_PHASE_DECLARATIVE(param))
795 SET_PSTATE_REPLY_OPTIONAL(param);
798 static int iscsi_check_boolean_value(struct iscsi_param *param, char *value)
800 if (strcmp(value, YES) && strcmp(value, NO)) {
801 pr_err("Illegal value for \"%s\", must be either"
802 " \"%s\" or \"%s\".\n", param->name, YES, NO);
809 static int iscsi_check_numerical_value(struct iscsi_param *param, char *value_ptr)
814 value = simple_strtoul(value_ptr, &tmpptr, 0);
816 if (IS_TYPERANGE_0_TO_2(param)) {
817 if ((value < 0) || (value > 2)) {
818 pr_err("Illegal value for \"%s\", must be"
819 " between 0 and 2.\n", param->name);
824 if (IS_TYPERANGE_0_TO_3600(param)) {
825 if ((value < 0) || (value > 3600)) {
826 pr_err("Illegal value for \"%s\", must be"
827 " between 0 and 3600.\n", param->name);
832 if (IS_TYPERANGE_0_TO_32767(param)) {
833 if ((value < 0) || (value > 32767)) {
834 pr_err("Illegal value for \"%s\", must be"
835 " between 0 and 32767.\n", param->name);
840 if (IS_TYPERANGE_0_TO_65535(param)) {
841 if ((value < 0) || (value > 65535)) {
842 pr_err("Illegal value for \"%s\", must be"
843 " between 0 and 65535.\n", param->name);
848 if (IS_TYPERANGE_1_TO_65535(param)) {
849 if ((value < 1) || (value > 65535)) {
850 pr_err("Illegal value for \"%s\", must be"
851 " between 1 and 65535.\n", param->name);
856 if (IS_TYPERANGE_2_TO_3600(param)) {
857 if ((value < 2) || (value > 3600)) {
858 pr_err("Illegal value for \"%s\", must be"
859 " between 2 and 3600.\n", param->name);
864 if (IS_TYPERANGE_512_TO_16777215(param)) {
865 if ((value < 512) || (value > 16777215)) {
866 pr_err("Illegal value for \"%s\", must be"
867 " between 512 and 16777215.\n", param->name);
876 static int iscsi_check_string_or_list_value(struct iscsi_param *param, char *value)
878 if (IS_PSTATE_PROPOSER(param))
881 if (IS_TYPERANGE_AUTH_PARAM(param)) {
882 if (strcmp(value, KRB5) && strcmp(value, SPKM1) &&
883 strcmp(value, SPKM2) && strcmp(value, SRP) &&
884 strcmp(value, CHAP) && strcmp(value, NONE)) {
885 pr_err("Illegal value for \"%s\", must be"
886 " \"%s\", \"%s\", \"%s\", \"%s\", \"%s\""
887 " or \"%s\".\n", param->name, KRB5,
888 SPKM1, SPKM2, SRP, CHAP, NONE);
892 if (IS_TYPERANGE_DIGEST_PARAM(param)) {
893 if (strcmp(value, CRC32C) && strcmp(value, NONE)) {
894 pr_err("Illegal value for \"%s\", must be"
895 " \"%s\" or \"%s\".\n", param->name,
900 if (IS_TYPERANGE_SESSIONTYPE(param)) {
901 if (strcmp(value, DISCOVERY) && strcmp(value, NORMAL)) {
902 pr_err("Illegal value for \"%s\", must be"
903 " \"%s\" or \"%s\".\n", param->name,
912 static char *iscsi_check_valuelist_for_support(
913 struct iscsi_param *param,
916 char *tmp1 = NULL, *tmp2 = NULL;
917 char *acceptor_values = NULL, *proposer_values = NULL;
919 acceptor_values = param->value;
920 proposer_values = value;
923 if (!proposer_values)
925 tmp1 = strchr(proposer_values, ',');
928 acceptor_values = param->value;
930 if (!acceptor_values) {
935 tmp2 = strchr(acceptor_values, ',');
938 if (!strcmp(acceptor_values, proposer_values)) {
946 acceptor_values = tmp2;
947 } while (acceptor_values);
950 proposer_values = tmp1;
951 } while (proposer_values);
954 return proposer_values;
957 static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
958 struct iscsi_conn *conn)
960 u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;
961 char *negotiated_value = NULL;
963 if (IS_PSTATE_ACCEPTOR(param)) {
964 pr_err("Received key \"%s\" twice, protocol error.\n",
969 if (IS_PSTATE_REJECT(param))
972 if (IS_TYPE_BOOL_AND(param)) {
973 if (!strcmp(value, YES))
974 proposer_boolean_value = 1;
975 if (!strcmp(param->value, YES))
976 acceptor_boolean_value = 1;
977 if (acceptor_boolean_value && proposer_boolean_value)
980 if (iscsi_update_param_value(param, NO) < 0)
982 if (!proposer_boolean_value)
983 SET_PSTATE_REPLY_OPTIONAL(param);
985 } else if (IS_TYPE_BOOL_OR(param)) {
986 if (!strcmp(value, YES))
987 proposer_boolean_value = 1;
988 if (!strcmp(param->value, YES))
989 acceptor_boolean_value = 1;
990 if (acceptor_boolean_value || proposer_boolean_value) {
991 if (iscsi_update_param_value(param, YES) < 0)
993 if (proposer_boolean_value)
994 SET_PSTATE_REPLY_OPTIONAL(param);
996 } else if (IS_TYPE_NUMBER(param)) {
997 char *tmpptr, buf[11];
998 u32 acceptor_value = simple_strtoul(param->value, &tmpptr, 0);
999 u32 proposer_value = simple_strtoul(value, &tmpptr, 0);
1001 memset(buf, 0, sizeof(buf));
1003 if (!strcmp(param->name, MAXCONNECTIONS) ||
1004 !strcmp(param->name, MAXBURSTLENGTH) ||
1005 !strcmp(param->name, FIRSTBURSTLENGTH) ||
1006 !strcmp(param->name, MAXOUTSTANDINGR2T) ||
1007 !strcmp(param->name, DEFAULTTIME2RETAIN) ||
1008 !strcmp(param->name, ERRORRECOVERYLEVEL)) {
1009 if (proposer_value > acceptor_value) {
1010 sprintf(buf, "%u", acceptor_value);
1011 if (iscsi_update_param_value(param,
1015 if (iscsi_update_param_value(param, value) < 0)
1018 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
1019 if (acceptor_value > proposer_value) {
1020 sprintf(buf, "%u", acceptor_value);
1021 if (iscsi_update_param_value(param,
1025 if (iscsi_update_param_value(param, value) < 0)
1029 if (iscsi_update_param_value(param, value) < 0)
1033 if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
1034 struct iscsi_param *param_mxdsl;
1035 unsigned long long tmp;
1038 rc = kstrtoull(param->value, 0, &tmp);
1042 conn->conn_ops->MaxRecvDataSegmentLength = tmp;
1043 pr_debug("Saving op->MaxRecvDataSegmentLength from"
1044 " original initiator received value: %u\n",
1045 conn->conn_ops->MaxRecvDataSegmentLength);
1047 param_mxdsl = iscsi_find_param_from_key(
1048 MAXXMITDATASEGMENTLENGTH,
1053 rc = iscsi_update_param_value(param,
1054 param_mxdsl->value);
1058 pr_debug("Updated %s to target MXDSL value: %s\n",
1059 param->name, param->value);
1061 } else if (IS_TYPE_VALUE_LIST(param)) {
1062 negotiated_value = iscsi_check_valuelist_for_support(
1064 if (!negotiated_value) {
1065 pr_err("Proposer's value list \"%s\" contains"
1066 " no valid values from Acceptor's value list"
1067 " \"%s\".\n", value, param->value);
1070 if (iscsi_update_param_value(param, negotiated_value) < 0)
1072 } else if (IS_PHASE_DECLARATIVE(param)) {
1073 if (iscsi_update_param_value(param, value) < 0)
1075 SET_PSTATE_REPLY_OPTIONAL(param);
1081 static int iscsi_check_proposer_state(struct iscsi_param *param, char *value)
1083 if (IS_PSTATE_RESPONSE_GOT(param)) {
1084 pr_err("Received key \"%s\" twice, protocol error.\n",
1089 if (IS_TYPE_VALUE_LIST(param)) {
1090 char *comma_ptr = NULL, *tmp_ptr = NULL;
1092 comma_ptr = strchr(value, ',');
1094 pr_err("Illegal \",\" in response for \"%s\".\n",
1099 tmp_ptr = iscsi_check_valuelist_for_support(param, value);
1104 if (iscsi_update_param_value(param, value) < 0)
1110 static int iscsi_check_value(struct iscsi_param *param, char *value)
1112 char *comma_ptr = NULL;
1114 if (!strcmp(value, REJECT)) {
1115 if (!strcmp(param->name, IFMARKINT) ||
1116 !strcmp(param->name, OFMARKINT)) {
1118 * Reject is not fatal for [I,O]FMarkInt, and causes
1119 * [I,O]FMarker to be reset to No. (See iSCSI v20 A.3.2)
1121 SET_PSTATE_REJECT(param);
1124 pr_err("Received %s=%s\n", param->name, value);
1127 if (!strcmp(value, IRRELEVANT)) {
1128 pr_debug("Received %s=%s\n", param->name, value);
1129 SET_PSTATE_IRRELEVANT(param);
1132 if (!strcmp(value, NOTUNDERSTOOD)) {
1133 if (!IS_PSTATE_PROPOSER(param)) {
1134 pr_err("Received illegal offer %s=%s\n",
1135 param->name, value);
1139 /* #warning FIXME: Add check for X-ExtensionKey here */
1140 pr_err("Standard iSCSI key \"%s\" cannot be answered"
1141 " with \"%s\", protocol error.\n", param->name, value);
1147 comma_ptr = strchr(value, ',');
1149 if (comma_ptr && !IS_TYPE_VALUE_LIST(param)) {
1150 pr_err("Detected value separator \",\", but"
1151 " key \"%s\" does not allow a value list,"
1152 " protocol error.\n", param->name);
1158 if (strlen(value) > VALUE_MAXLEN) {
1159 pr_err("Value for key \"%s\" exceeds %d,"
1160 " protocol error.\n", param->name,
1165 if (IS_TYPE_BOOL_AND(param) || IS_TYPE_BOOL_OR(param)) {
1166 if (iscsi_check_boolean_value(param, value) < 0)
1168 } else if (IS_TYPE_NUMBER(param)) {
1169 if (iscsi_check_numerical_value(param, value) < 0)
1171 } else if (IS_TYPE_STRING(param) || IS_TYPE_VALUE_LIST(param)) {
1172 if (iscsi_check_string_or_list_value(param, value) < 0)
1175 pr_err("Huh? 0x%02x\n", param->type);
1188 static struct iscsi_param *__iscsi_check_key(
1191 struct iscsi_param_list *param_list)
1193 struct iscsi_param *param;
1195 if (strlen(key) > KEY_MAXLEN) {
1196 pr_err("Length of key name \"%s\" exceeds %d.\n",
1201 param = iscsi_find_param_from_key(key, param_list);
1205 if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
1206 pr_err("Key \"%s\" may not be sent to %s,"
1207 " protocol error.\n", param->name,
1208 (sender & SENDER_RECEIVER) ? "target" : "initiator");
1212 if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
1213 pr_err("Key \"%s\" may not be sent to %s,"
1214 " protocol error.\n", param->name,
1215 (sender & SENDER_RECEIVER) ? "initiator" : "target");
1222 static struct iscsi_param *iscsi_check_key(
1226 struct iscsi_param_list *param_list)
1228 struct iscsi_param *param;
1230 * Key name length must not exceed 63 bytes. (See iSCSI v20 5.1)
1232 if (strlen(key) > KEY_MAXLEN) {
1233 pr_err("Length of key name \"%s\" exceeds %d.\n",
1238 param = iscsi_find_param_from_key(key, param_list);
1242 if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
1243 pr_err("Key \"%s\" may not be sent to %s,"
1244 " protocol error.\n", param->name,
1245 (sender & SENDER_RECEIVER) ? "target" : "initiator");
1248 if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
1249 pr_err("Key \"%s\" may not be sent to %s,"
1250 " protocol error.\n", param->name,
1251 (sender & SENDER_RECEIVER) ? "initiator" : "target");
1255 if (IS_PSTATE_ACCEPTOR(param)) {
1256 pr_err("Key \"%s\" received twice, protocol error.\n",
1264 if (!(param->phase & phase)) {
1268 case PHASE_SECURITY:
1269 phase_name = "Security";
1271 case PHASE_OPERATIONAL:
1272 phase_name = "Operational";
1275 phase_name = "Unknown";
1277 pr_err("Key \"%s\" may not be negotiated during %s phase.\n",
1278 param->name, phase_name);
1285 static int iscsi_enforce_integrity_rules(
1287 struct iscsi_param_list *param_list)
1290 u8 DataSequenceInOrder = 0;
1291 u8 ErrorRecoveryLevel = 0, SessionType = 0;
1292 u32 FirstBurstLength = 0, MaxBurstLength = 0;
1293 struct iscsi_param *param = NULL;
1295 list_for_each_entry(param, ¶m_list->param_list, p_list) {
1296 if (!(param->phase & phase))
1298 if (!strcmp(param->name, SESSIONTYPE))
1299 if (!strcmp(param->value, NORMAL))
1301 if (!strcmp(param->name, ERRORRECOVERYLEVEL))
1302 ErrorRecoveryLevel = simple_strtoul(param->value,
1304 if (!strcmp(param->name, DATASEQUENCEINORDER))
1305 if (!strcmp(param->value, YES))
1306 DataSequenceInOrder = 1;
1307 if (!strcmp(param->name, MAXBURSTLENGTH))
1308 MaxBurstLength = simple_strtoul(param->value,
1312 list_for_each_entry(param, ¶m_list->param_list, p_list) {
1313 if (!(param->phase & phase))
1315 if (!SessionType && !IS_PSTATE_ACCEPTOR(param))
1317 if (!strcmp(param->name, MAXOUTSTANDINGR2T) &&
1318 DataSequenceInOrder && (ErrorRecoveryLevel > 0)) {
1319 if (strcmp(param->value, "1")) {
1320 if (iscsi_update_param_value(param, "1") < 0)
1322 pr_debug("Reset \"%s\" to \"%s\".\n",
1323 param->name, param->value);
1326 if (!strcmp(param->name, MAXCONNECTIONS) && !SessionType) {
1327 if (strcmp(param->value, "1")) {
1328 if (iscsi_update_param_value(param, "1") < 0)
1330 pr_debug("Reset \"%s\" to \"%s\".\n",
1331 param->name, param->value);
1334 if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
1335 FirstBurstLength = simple_strtoul(param->value,
1337 if (FirstBurstLength > MaxBurstLength) {
1339 memset(tmpbuf, 0, sizeof(tmpbuf));
1340 sprintf(tmpbuf, "%u", MaxBurstLength);
1341 if (iscsi_update_param_value(param, tmpbuf))
1343 pr_debug("Reset \"%s\" to \"%s\".\n",
1344 param->name, param->value);
1352 int iscsi_decode_text_input(
1357 struct iscsi_conn *conn)
1359 struct iscsi_param_list *param_list = conn->param_list;
1360 char *tmpbuf, *start = NULL, *end = NULL;
1362 tmpbuf = kzalloc(length + 1, GFP_KERNEL);
1364 pr_err("Unable to allocate %u + 1 bytes for tmpbuf.\n", length);
1368 memcpy(tmpbuf, textbuf, length);
1369 tmpbuf[length] = '\0';
1371 end = (start + length);
1373 while (start < end) {
1375 struct iscsi_param *param;
1377 if (iscsi_extract_key_value(start, &key, &value) < 0)
1380 pr_debug("Got key: %s=%s\n", key, value);
1382 if (phase & PHASE_SECURITY) {
1383 if (iscsi_check_for_auth_key(key) > 0) {
1389 param = iscsi_check_key(key, phase, sender, param_list);
1391 if (iscsi_add_notunderstood_response(key, value,
1395 start += strlen(key) + strlen(value) + 2;
1398 if (iscsi_check_value(param, value) < 0)
1401 start += strlen(key) + strlen(value) + 2;
1403 if (IS_PSTATE_PROPOSER(param)) {
1404 if (iscsi_check_proposer_state(param, value) < 0)
1407 SET_PSTATE_RESPONSE_GOT(param);
1409 if (iscsi_check_acceptor_state(param, value, conn) < 0)
1412 SET_PSTATE_ACCEPTOR(param);
1424 int iscsi_encode_text_output(
1429 struct iscsi_param_list *param_list,
1430 bool keys_workaround)
1432 char *output_buf = NULL;
1433 struct iscsi_extra_response *er;
1434 struct iscsi_param *param;
1436 output_buf = textbuf + *length;
1438 if (iscsi_enforce_integrity_rules(phase, param_list) < 0)
1441 list_for_each_entry(param, ¶m_list->param_list, p_list) {
1442 if (!(param->sender & sender))
1444 if (IS_PSTATE_ACCEPTOR(param) &&
1445 !IS_PSTATE_RESPONSE_SENT(param) &&
1446 !IS_PSTATE_REPLY_OPTIONAL(param) &&
1447 (param->phase & phase)) {
1448 *length += sprintf(output_buf, "%s=%s",
1449 param->name, param->value);
1451 output_buf = textbuf + *length;
1452 SET_PSTATE_RESPONSE_SENT(param);
1453 pr_debug("Sending key: %s=%s\n",
1454 param->name, param->value);
1457 if (IS_PSTATE_NEGOTIATE(param) &&
1458 !IS_PSTATE_ACCEPTOR(param) &&
1459 !IS_PSTATE_PROPOSER(param) &&
1460 (param->phase & phase)) {
1461 *length += sprintf(output_buf, "%s=%s",
1462 param->name, param->value);
1464 output_buf = textbuf + *length;
1465 SET_PSTATE_PROPOSER(param);
1466 iscsi_check_proposer_for_optional_reply(param,
1468 pr_debug("Sending key: %s=%s\n",
1469 param->name, param->value);
1473 list_for_each_entry(er, ¶m_list->extra_response_list, er_list) {
1474 *length += sprintf(output_buf, "%s=%s", er->key, er->value);
1476 output_buf = textbuf + *length;
1477 pr_debug("Sending key: %s=%s\n", er->key, er->value);
1479 iscsi_release_extra_responses(param_list);
1484 int iscsi_check_negotiated_keys(struct iscsi_param_list *param_list)
1487 struct iscsi_param *param;
1489 list_for_each_entry(param, ¶m_list->param_list, p_list) {
1490 if (IS_PSTATE_NEGOTIATE(param) &&
1491 IS_PSTATE_PROPOSER(param) &&
1492 !IS_PSTATE_RESPONSE_GOT(param) &&
1493 !IS_PSTATE_REPLY_OPTIONAL(param) &&
1494 !IS_PHASE_DECLARATIVE(param)) {
1495 pr_err("No response for proposed key \"%s\".\n",
1504 int iscsi_change_param_value(
1506 struct iscsi_param_list *param_list,
1509 char *key = NULL, *value = NULL;
1510 struct iscsi_param *param;
1513 if (iscsi_extract_key_value(keyvalue, &key, &value) < 0)
1517 param = __iscsi_check_key(keyvalue, sender, param_list);
1521 param = iscsi_check_key(keyvalue, 0, sender, param_list);
1525 param->set_param = 1;
1526 if (iscsi_check_value(param, value) < 0) {
1527 param->set_param = 0;
1530 param->set_param = 0;
1533 if (iscsi_update_param_value(param, value) < 0)
1539 void iscsi_set_connection_parameters(
1540 struct iscsi_conn_ops *ops,
1541 struct iscsi_param_list *param_list)
1544 struct iscsi_param *param;
1546 pr_debug("---------------------------------------------------"
1547 "---------------\n");
1548 list_for_each_entry(param, ¶m_list->param_list, p_list) {
1550 * Special case to set MAXXMITDATASEGMENTLENGTH from the
1551 * target requested MaxRecvDataSegmentLength, even though
1552 * this key is not sent over the wire.
1554 if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
1555 ops->MaxXmitDataSegmentLength =
1556 simple_strtoul(param->value, &tmpptr, 0);
1557 pr_debug("MaxXmitDataSegmentLength: %s\n",
1561 if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
1563 if (!strcmp(param->name, AUTHMETHOD)) {
1564 pr_debug("AuthMethod: %s\n",
1566 } else if (!strcmp(param->name, HEADERDIGEST)) {
1567 ops->HeaderDigest = !strcmp(param->value, CRC32C);
1568 pr_debug("HeaderDigest: %s\n",
1570 } else if (!strcmp(param->name, DATADIGEST)) {
1571 ops->DataDigest = !strcmp(param->value, CRC32C);
1572 pr_debug("DataDigest: %s\n",
1574 } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
1576 * At this point iscsi_check_acceptor_state() will have
1577 * set ops->MaxRecvDataSegmentLength from the original
1578 * initiator provided value.
1580 pr_debug("MaxRecvDataSegmentLength: %u\n",
1581 ops->MaxRecvDataSegmentLength);
1582 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
1583 ops->InitiatorRecvDataSegmentLength =
1584 simple_strtoul(param->value, &tmpptr, 0);
1585 pr_debug("InitiatorRecvDataSegmentLength: %s\n",
1587 ops->MaxRecvDataSegmentLength =
1588 ops->InitiatorRecvDataSegmentLength;
1589 pr_debug("Set MRDSL from InitiatorRecvDataSegmentLength\n");
1590 } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
1591 ops->TargetRecvDataSegmentLength =
1592 simple_strtoul(param->value, &tmpptr, 0);
1593 pr_debug("TargetRecvDataSegmentLength: %s\n",
1595 ops->MaxXmitDataSegmentLength =
1596 ops->TargetRecvDataSegmentLength;
1597 pr_debug("Set MXDSL from TargetRecvDataSegmentLength\n");
1600 pr_debug("----------------------------------------------------"
1601 "--------------\n");
1604 void iscsi_set_session_parameters(
1605 struct iscsi_sess_ops *ops,
1606 struct iscsi_param_list *param_list,
1610 struct iscsi_param *param;
1612 pr_debug("----------------------------------------------------"
1613 "--------------\n");
1614 list_for_each_entry(param, ¶m_list->param_list, p_list) {
1615 if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
1617 if (!strcmp(param->name, INITIATORNAME)) {
1621 snprintf(ops->InitiatorName,
1622 sizeof(ops->InitiatorName),
1623 "%s", param->value);
1624 pr_debug("InitiatorName: %s\n",
1626 } else if (!strcmp(param->name, INITIATORALIAS)) {
1629 snprintf(ops->InitiatorAlias,
1630 sizeof(ops->InitiatorAlias),
1631 "%s", param->value);
1632 pr_debug("InitiatorAlias: %s\n",
1634 } else if (!strcmp(param->name, TARGETNAME)) {
1638 snprintf(ops->TargetName,
1639 sizeof(ops->TargetName),
1640 "%s", param->value);
1641 pr_debug("TargetName: %s\n",
1643 } else if (!strcmp(param->name, TARGETALIAS)) {
1646 snprintf(ops->TargetAlias, sizeof(ops->TargetAlias),
1647 "%s", param->value);
1648 pr_debug("TargetAlias: %s\n",
1650 } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
1651 ops->TargetPortalGroupTag =
1652 simple_strtoul(param->value, &tmpptr, 0);
1653 pr_debug("TargetPortalGroupTag: %s\n",
1655 } else if (!strcmp(param->name, MAXCONNECTIONS)) {
1656 ops->MaxConnections =
1657 simple_strtoul(param->value, &tmpptr, 0);
1658 pr_debug("MaxConnections: %s\n",
1660 } else if (!strcmp(param->name, INITIALR2T)) {
1661 ops->InitialR2T = !strcmp(param->value, YES);
1662 pr_debug("InitialR2T: %s\n",
1664 } else if (!strcmp(param->name, IMMEDIATEDATA)) {
1665 ops->ImmediateData = !strcmp(param->value, YES);
1666 pr_debug("ImmediateData: %s\n",
1668 } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
1669 ops->MaxBurstLength =
1670 simple_strtoul(param->value, &tmpptr, 0);
1671 pr_debug("MaxBurstLength: %s\n",
1673 } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
1674 ops->FirstBurstLength =
1675 simple_strtoul(param->value, &tmpptr, 0);
1676 pr_debug("FirstBurstLength: %s\n",
1678 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
1679 ops->DefaultTime2Wait =
1680 simple_strtoul(param->value, &tmpptr, 0);
1681 pr_debug("DefaultTime2Wait: %s\n",
1683 } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
1684 ops->DefaultTime2Retain =
1685 simple_strtoul(param->value, &tmpptr, 0);
1686 pr_debug("DefaultTime2Retain: %s\n",
1688 } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
1689 ops->MaxOutstandingR2T =
1690 simple_strtoul(param->value, &tmpptr, 0);
1691 pr_debug("MaxOutstandingR2T: %s\n",
1693 } else if (!strcmp(param->name, DATAPDUINORDER)) {
1694 ops->DataPDUInOrder = !strcmp(param->value, YES);
1695 pr_debug("DataPDUInOrder: %s\n",
1697 } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
1698 ops->DataSequenceInOrder = !strcmp(param->value, YES);
1699 pr_debug("DataSequenceInOrder: %s\n",
1701 } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
1702 ops->ErrorRecoveryLevel =
1703 simple_strtoul(param->value, &tmpptr, 0);
1704 pr_debug("ErrorRecoveryLevel: %s\n",
1706 } else if (!strcmp(param->name, SESSIONTYPE)) {
1707 ops->SessionType = !strcmp(param->value, DISCOVERY);
1708 pr_debug("SessionType: %s\n",
1710 } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
1711 ops->RDMAExtensions = !strcmp(param->value, YES);
1712 pr_debug("RDMAExtensions: %s\n",
1716 pr_debug("----------------------------------------------------"
1717 "--------------\n");