1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*******************************************************************************
3 * This file contains iSCSI Target Portal Group related functions.
5 * (c) Copyright 2007-2013 Datera, Inc.
7 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
9 ******************************************************************************/
11 #include <linux/slab.h>
12 #include <target/target_core_base.h>
13 #include <target/target_core_fabric.h>
14 #include <target/iscsi/iscsi_target_core.h>
15 #include "iscsi_target_erl0.h"
16 #include "iscsi_target_login.h"
17 #include "iscsi_target_nodeattrib.h"
18 #include "iscsi_target_tpg.h"
19 #include "iscsi_target_util.h"
20 #include "iscsi_target.h"
21 #include "iscsi_target_parameters.h"
23 #include <target/iscsi/iscsi_transport.h>
25 struct iscsi_portal_group
*iscsit_alloc_portal_group(struct iscsi_tiqn
*tiqn
, u16 tpgt
)
27 struct iscsi_portal_group
*tpg
;
29 tpg
= kzalloc(sizeof(struct iscsi_portal_group
), GFP_KERNEL
);
31 pr_err("Unable to allocate struct iscsi_portal_group\n");
36 tpg
->tpg_state
= TPG_STATE_FREE
;
38 INIT_LIST_HEAD(&tpg
->tpg_gnp_list
);
39 INIT_LIST_HEAD(&tpg
->tpg_list
);
40 mutex_init(&tpg
->tpg_access_lock
);
41 sema_init(&tpg
->np_login_sem
, 1);
42 spin_lock_init(&tpg
->tpg_state_lock
);
43 spin_lock_init(&tpg
->tpg_np_lock
);
48 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*);
50 int iscsit_load_discovery_tpg(void)
52 struct iscsi_param
*param
;
53 struct iscsi_portal_group
*tpg
;
56 tpg
= iscsit_alloc_portal_group(NULL
, 1);
58 pr_err("Unable to allocate struct iscsi_portal_group\n");
62 * Save iscsi_ops pointer for special case discovery TPG that
63 * doesn't exist as se_wwn->wwn_group within configfs.
65 tpg
->tpg_se_tpg
.se_tpg_tfo
= &iscsi_ops
;
66 ret
= core_tpg_register(NULL
, &tpg
->tpg_se_tpg
, -1);
72 tpg
->sid
= 1; /* First Assigned LIO Session ID */
73 iscsit_set_default_tpg_attribs(tpg
);
75 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
78 * By default we disable authentication for discovery sessions,
79 * this can be changed with:
81 * /sys/kernel/config/target/iscsi/discovery_auth/enforce_discovery_auth
83 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
87 if (iscsi_update_param_value(param
, "CHAP,None") < 0)
90 tpg
->tpg_attrib
.authentication
= 0;
92 spin_lock(&tpg
->tpg_state_lock
);
93 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
94 spin_unlock(&tpg
->tpg_state_lock
);
96 iscsit_global
->discovery_tpg
= tpg
;
97 pr_debug("CORE[0] - Allocated Discovery TPG\n");
101 iscsi_release_param_list(tpg
->param_list
);
104 core_tpg_deregister(&tpg
->tpg_se_tpg
);
109 void iscsit_release_discovery_tpg(void)
111 struct iscsi_portal_group
*tpg
= iscsit_global
->discovery_tpg
;
116 iscsi_release_param_list(tpg
->param_list
);
117 core_tpg_deregister(&tpg
->tpg_se_tpg
);
120 iscsit_global
->discovery_tpg
= NULL
;
123 struct iscsi_portal_group
*iscsit_get_tpg_from_np(
124 struct iscsi_tiqn
*tiqn
,
126 struct iscsi_tpg_np
**tpg_np_out
)
128 struct iscsi_portal_group
*tpg
= NULL
;
129 struct iscsi_tpg_np
*tpg_np
;
131 spin_lock(&tiqn
->tiqn_tpg_lock
);
132 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
134 spin_lock(&tpg
->tpg_state_lock
);
135 if (tpg
->tpg_state
!= TPG_STATE_ACTIVE
) {
136 spin_unlock(&tpg
->tpg_state_lock
);
139 spin_unlock(&tpg
->tpg_state_lock
);
141 spin_lock(&tpg
->tpg_np_lock
);
142 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
143 if (tpg_np
->tpg_np
== np
) {
144 *tpg_np_out
= tpg_np
;
145 kref_get(&tpg_np
->tpg_np_kref
);
146 spin_unlock(&tpg
->tpg_np_lock
);
147 spin_unlock(&tiqn
->tiqn_tpg_lock
);
151 spin_unlock(&tpg
->tpg_np_lock
);
153 spin_unlock(&tiqn
->tiqn_tpg_lock
);
159 struct iscsi_portal_group
*tpg
)
161 return mutex_lock_interruptible(&tpg
->tpg_access_lock
);
164 void iscsit_put_tpg(struct iscsi_portal_group
*tpg
)
166 mutex_unlock(&tpg
->tpg_access_lock
);
169 static void iscsit_clear_tpg_np_login_thread(
170 struct iscsi_tpg_np
*tpg_np
,
171 struct iscsi_portal_group
*tpg
,
174 if (!tpg_np
->tpg_np
) {
175 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
180 tpg_np
->tpg_np
->enabled
= false;
181 iscsit_reset_np_thread(tpg_np
->tpg_np
, tpg_np
, tpg
, shutdown
);
184 static void iscsit_clear_tpg_np_login_threads(
185 struct iscsi_portal_group
*tpg
,
188 struct iscsi_tpg_np
*tpg_np
;
190 spin_lock(&tpg
->tpg_np_lock
);
191 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
192 if (!tpg_np
->tpg_np
) {
193 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
196 spin_unlock(&tpg
->tpg_np_lock
);
197 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, shutdown
);
198 spin_lock(&tpg
->tpg_np_lock
);
200 spin_unlock(&tpg
->tpg_np_lock
);
203 void iscsit_tpg_dump_params(struct iscsi_portal_group
*tpg
)
205 iscsi_print_params(tpg
->param_list
);
208 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*tpg
)
210 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
212 a
->authentication
= TA_AUTHENTICATION
;
213 a
->login_timeout
= TA_LOGIN_TIMEOUT
;
214 a
->default_cmdsn_depth
= TA_DEFAULT_CMDSN_DEPTH
;
215 a
->generate_node_acls
= TA_GENERATE_NODE_ACLS
;
216 a
->cache_dynamic_acls
= TA_CACHE_DYNAMIC_ACLS
;
217 a
->demo_mode_write_protect
= TA_DEMO_MODE_WRITE_PROTECT
;
218 a
->prod_mode_write_protect
= TA_PROD_MODE_WRITE_PROTECT
;
219 a
->demo_mode_discovery
= TA_DEMO_MODE_DISCOVERY
;
220 a
->default_erl
= TA_DEFAULT_ERL
;
221 a
->t10_pi
= TA_DEFAULT_T10_PI
;
222 a
->fabric_prot_type
= TA_DEFAULT_FABRIC_PROT_TYPE
;
223 a
->tpg_enabled_sendtargets
= TA_DEFAULT_TPG_ENABLED_SENDTARGETS
;
224 a
->login_keys_workaround
= TA_DEFAULT_LOGIN_KEYS_WORKAROUND
;
227 int iscsit_tpg_add_portal_group(struct iscsi_tiqn
*tiqn
, struct iscsi_portal_group
*tpg
)
229 if (tpg
->tpg_state
!= TPG_STATE_FREE
) {
230 pr_err("Unable to add iSCSI Target Portal Group: %d"
231 " while not in TPG_STATE_FREE state.\n", tpg
->tpgt
);
234 iscsit_set_default_tpg_attribs(tpg
);
236 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
239 tpg
->tpg_attrib
.tpg
= tpg
;
241 spin_lock(&tpg
->tpg_state_lock
);
242 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
243 spin_unlock(&tpg
->tpg_state_lock
);
245 spin_lock(&tiqn
->tiqn_tpg_lock
);
246 list_add_tail(&tpg
->tpg_list
, &tiqn
->tiqn_tpg_list
);
248 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
249 tiqn
->tiqn
, tpg
->tpgt
);
250 spin_unlock(&tiqn
->tiqn_tpg_lock
);
254 if (tpg
->param_list
) {
255 iscsi_release_param_list(tpg
->param_list
);
256 tpg
->param_list
= NULL
;
261 int iscsit_tpg_del_portal_group(
262 struct iscsi_tiqn
*tiqn
,
263 struct iscsi_portal_group
*tpg
,
266 u8 old_state
= tpg
->tpg_state
;
268 spin_lock(&tpg
->tpg_state_lock
);
269 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
270 spin_unlock(&tpg
->tpg_state_lock
);
272 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
273 pr_err("Unable to delete iSCSI Target Portal Group:"
274 " %hu while active sessions exist, and force=0\n",
276 tpg
->tpg_state
= old_state
;
280 if (tpg
->param_list
) {
281 iscsi_release_param_list(tpg
->param_list
);
282 tpg
->param_list
= NULL
;
285 core_tpg_deregister(&tpg
->tpg_se_tpg
);
287 spin_lock(&tpg
->tpg_state_lock
);
288 tpg
->tpg_state
= TPG_STATE_FREE
;
289 spin_unlock(&tpg
->tpg_state_lock
);
291 spin_lock(&tiqn
->tiqn_tpg_lock
);
293 list_del(&tpg
->tpg_list
);
294 spin_unlock(&tiqn
->tiqn_tpg_lock
);
296 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
297 tiqn
->tiqn
, tpg
->tpgt
);
303 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group
*tpg
)
305 struct iscsi_param
*param
;
306 struct iscsi_tiqn
*tiqn
= tpg
->tpg_tiqn
;
309 if (tpg
->tpg_state
== TPG_STATE_ACTIVE
) {
310 pr_err("iSCSI target portal group: %hu is already"
311 " active, ignoring request.\n", tpg
->tpgt
);
315 * Make sure that AuthMethod does not contain None as an option
316 * unless explictly disabled. Set the default to CHAP if authentication
317 * is enforced (as per default), and remove the NONE option.
319 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
323 if (tpg
->tpg_attrib
.authentication
) {
324 if (!strcmp(param
->value
, NONE
)) {
325 ret
= iscsi_update_param_value(param
, CHAP
);
330 ret
= iscsit_ta_authentication(tpg
, 1);
335 spin_lock(&tpg
->tpg_state_lock
);
336 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
337 spin_unlock(&tpg
->tpg_state_lock
);
339 spin_lock(&tiqn
->tiqn_tpg_lock
);
340 tiqn
->tiqn_active_tpgs
++;
341 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
343 spin_unlock(&tiqn
->tiqn_tpg_lock
);
351 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group
*tpg
, int force
)
353 struct iscsi_tiqn
*tiqn
;
354 u8 old_state
= tpg
->tpg_state
;
356 spin_lock(&tpg
->tpg_state_lock
);
357 if (tpg
->tpg_state
== TPG_STATE_INACTIVE
) {
358 pr_err("iSCSI Target Portal Group: %hu is already"
359 " inactive, ignoring request.\n", tpg
->tpgt
);
360 spin_unlock(&tpg
->tpg_state_lock
);
363 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
364 spin_unlock(&tpg
->tpg_state_lock
);
366 iscsit_clear_tpg_np_login_threads(tpg
, false);
368 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
369 spin_lock(&tpg
->tpg_state_lock
);
370 tpg
->tpg_state
= old_state
;
371 spin_unlock(&tpg
->tpg_state_lock
);
372 pr_err("Unable to disable iSCSI Target Portal Group:"
373 " %hu while active sessions exist, and force=0\n",
378 tiqn
= tpg
->tpg_tiqn
;
379 if (!tiqn
|| (tpg
== iscsit_global
->discovery_tpg
))
382 spin_lock(&tiqn
->tiqn_tpg_lock
);
383 tiqn
->tiqn_active_tpgs
--;
384 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
386 spin_unlock(&tiqn
->tiqn_tpg_lock
);
391 struct iscsi_node_attrib
*iscsit_tpg_get_node_attrib(
392 struct iscsit_session
*sess
)
394 struct se_session
*se_sess
= sess
->se_sess
;
395 struct se_node_acl
*se_nacl
= se_sess
->se_node_acl
;
396 struct iscsi_node_acl
*acl
= to_iscsi_nacl(se_nacl
);
398 return &acl
->node_attrib
;
401 struct iscsi_tpg_np
*iscsit_tpg_locate_child_np(
402 struct iscsi_tpg_np
*tpg_np
,
403 int network_transport
)
405 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
407 spin_lock(&tpg_np
->tpg_np_parent_lock
);
408 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
409 &tpg_np
->tpg_np_parent_list
, tpg_np_child_list
) {
410 if (tpg_np_child
->tpg_np
->np_network_transport
==
412 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
416 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
421 static bool iscsit_tpg_check_network_portal(
422 struct iscsi_tiqn
*tiqn
,
423 struct sockaddr_storage
*sockaddr
,
424 int network_transport
)
426 struct iscsi_portal_group
*tpg
;
427 struct iscsi_tpg_np
*tpg_np
;
431 spin_lock(&tiqn
->tiqn_tpg_lock
);
432 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
434 spin_lock(&tpg
->tpg_np_lock
);
435 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
438 match
= iscsit_check_np_match(sockaddr
, np
,
443 spin_unlock(&tpg
->tpg_np_lock
);
448 spin_unlock(&tiqn
->tiqn_tpg_lock
);
453 struct iscsi_tpg_np
*iscsit_tpg_add_network_portal(
454 struct iscsi_portal_group
*tpg
,
455 struct sockaddr_storage
*sockaddr
,
456 struct iscsi_tpg_np
*tpg_np_parent
,
457 int network_transport
)
460 struct iscsi_tpg_np
*tpg_np
;
462 if (!tpg_np_parent
) {
463 if (iscsit_tpg_check_network_portal(tpg
->tpg_tiqn
, sockaddr
,
464 network_transport
)) {
465 pr_err("Network Portal: %pISc already exists on a"
466 " different TPG on %s\n", sockaddr
,
467 tpg
->tpg_tiqn
->tiqn
);
468 return ERR_PTR(-EEXIST
);
472 tpg_np
= kzalloc(sizeof(struct iscsi_tpg_np
), GFP_KERNEL
);
474 pr_err("Unable to allocate memory for"
475 " struct iscsi_tpg_np.\n");
476 return ERR_PTR(-ENOMEM
);
479 np
= iscsit_add_np(sockaddr
, network_transport
);
485 INIT_LIST_HEAD(&tpg_np
->tpg_np_list
);
486 INIT_LIST_HEAD(&tpg_np
->tpg_np_child_list
);
487 INIT_LIST_HEAD(&tpg_np
->tpg_np_parent_list
);
488 spin_lock_init(&tpg_np
->tpg_np_parent_lock
);
489 init_completion(&tpg_np
->tpg_np_comp
);
490 kref_init(&tpg_np
->tpg_np_kref
);
494 spin_lock(&tpg
->tpg_np_lock
);
495 list_add_tail(&tpg_np
->tpg_np_list
, &tpg
->tpg_gnp_list
);
498 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
++;
499 spin_unlock(&tpg
->tpg_np_lock
);
502 tpg_np
->tpg_np_parent
= tpg_np_parent
;
503 spin_lock(&tpg_np_parent
->tpg_np_parent_lock
);
504 list_add_tail(&tpg_np
->tpg_np_child_list
,
505 &tpg_np_parent
->tpg_np_parent_list
);
506 spin_unlock(&tpg_np_parent
->tpg_np_parent_lock
);
509 pr_debug("CORE[%s] - Added Network Portal: %pISpc,%hu on %s\n",
510 tpg
->tpg_tiqn
->tiqn
, &np
->np_sockaddr
, tpg
->tpgt
,
511 np
->np_transport
->name
);
516 static int iscsit_tpg_release_np(
517 struct iscsi_tpg_np
*tpg_np
,
518 struct iscsi_portal_group
*tpg
,
521 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, true);
523 pr_debug("CORE[%s] - Removed Network Portal: %pISpc,%hu on %s\n",
524 tpg
->tpg_tiqn
->tiqn
, &np
->np_sockaddr
, tpg
->tpgt
,
525 np
->np_transport
->name
);
527 tpg_np
->tpg_np
= NULL
;
531 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
533 return iscsit_del_np(np
);
536 int iscsit_tpg_del_network_portal(
537 struct iscsi_portal_group
*tpg
,
538 struct iscsi_tpg_np
*tpg_np
)
541 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
546 pr_err("Unable to locate struct iscsi_np from"
547 " struct iscsi_tpg_np\n");
551 if (!tpg_np
->tpg_np_parent
) {
553 * We are the parent tpg network portal. Release all of the
554 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
557 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
558 &tpg_np
->tpg_np_parent_list
,
560 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np_child
);
562 pr_err("iscsit_tpg_del_network_portal()"
563 " failed: %d\n", ret
);
567 * We are not the parent ISCSI_TCP tpg network portal. Release
568 * our own network portals from the child list.
570 spin_lock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
571 list_del(&tpg_np
->tpg_np_child_list
);
572 spin_unlock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
575 spin_lock(&tpg
->tpg_np_lock
);
576 list_del(&tpg_np
->tpg_np_list
);
579 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
--;
580 spin_unlock(&tpg
->tpg_np_lock
);
582 return iscsit_tpg_release_np(tpg_np
, tpg
, np
);
585 int iscsit_ta_authentication(struct iscsi_portal_group
*tpg
, u32 authentication
)
587 unsigned char buf1
[256], buf2
[256], *none
= NULL
;
589 struct iscsi_param
*param
;
590 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
592 if ((authentication
!= 1) && (authentication
!= 0)) {
593 pr_err("Illegal value for authentication parameter:"
594 " %u, ignoring request.\n", authentication
);
598 memset(buf1
, 0, sizeof(buf1
));
599 memset(buf2
, 0, sizeof(buf2
));
601 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
605 if (authentication
) {
606 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
607 none
= strstr(buf1
, NONE
);
610 if (!strncmp(none
+ 4, ",", 1)) {
611 if (!strcmp(buf1
, none
))
612 sprintf(buf2
, "%s", none
+5);
616 len
= sprintf(buf2
, "%s", buf1
);
618 sprintf(buf2
+ len
, "%s", none
);
623 sprintf(buf2
, "%s", buf1
);
625 if (iscsi_update_param_value(param
, buf2
) < 0)
628 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
629 none
= strstr(buf1
, NONE
);
632 strlcat(buf1
, "," NONE
, sizeof(buf1
));
633 if (iscsi_update_param_value(param
, buf1
) < 0)
638 a
->authentication
= authentication
;
639 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
640 a
->authentication
? "Enforcing" : "Disabling", tpg
->tpgt
);
645 int iscsit_ta_login_timeout(
646 struct iscsi_portal_group
*tpg
,
649 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
651 if (login_timeout
> TA_LOGIN_TIMEOUT_MAX
) {
652 pr_err("Requested Login Timeout %u larger than maximum"
653 " %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MAX
);
655 } else if (login_timeout
< TA_LOGIN_TIMEOUT_MIN
) {
656 pr_err("Requested Logout Timeout %u smaller than"
657 " minimum %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MIN
);
661 a
->login_timeout
= login_timeout
;
662 pr_debug("Set Logout Timeout to %u for Target Portal Group"
663 " %hu\n", a
->login_timeout
, tpg
->tpgt
);
668 int iscsit_ta_generate_node_acls(
669 struct iscsi_portal_group
*tpg
,
672 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
674 if ((flag
!= 0) && (flag
!= 1)) {
675 pr_err("Illegal value %d\n", flag
);
679 a
->generate_node_acls
= flag
;
680 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
681 tpg
->tpgt
, (a
->generate_node_acls
) ? "Enabled" : "Disabled");
683 if (flag
== 1 && a
->cache_dynamic_acls
== 0) {
684 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
685 "generate_node_acls=1\n");
686 a
->cache_dynamic_acls
= 1;
692 int iscsit_ta_default_cmdsn_depth(
693 struct iscsi_portal_group
*tpg
,
696 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
698 if (tcq_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
699 pr_err("Requested Default Queue Depth: %u larger"
700 " than maximum %u\n", tcq_depth
,
701 TA_DEFAULT_CMDSN_DEPTH_MAX
);
703 } else if (tcq_depth
< TA_DEFAULT_CMDSN_DEPTH_MIN
) {
704 pr_err("Requested Default Queue Depth: %u smaller"
705 " than minimum %u\n", tcq_depth
,
706 TA_DEFAULT_CMDSN_DEPTH_MIN
);
710 a
->default_cmdsn_depth
= tcq_depth
;
711 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
712 tpg
->tpgt
, a
->default_cmdsn_depth
);
717 int iscsit_ta_cache_dynamic_acls(
718 struct iscsi_portal_group
*tpg
,
721 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
723 if ((flag
!= 0) && (flag
!= 1)) {
724 pr_err("Illegal value %d\n", flag
);
728 if (a
->generate_node_acls
== 1 && flag
== 0) {
729 pr_debug("Skipping cache_dynamic_acls=0 when"
730 " generate_node_acls=1\n");
734 a
->cache_dynamic_acls
= flag
;
735 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
736 " ACLs %s\n", tpg
->tpgt
, (a
->cache_dynamic_acls
) ?
737 "Enabled" : "Disabled");
742 int iscsit_ta_demo_mode_write_protect(
743 struct iscsi_portal_group
*tpg
,
746 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
748 if ((flag
!= 0) && (flag
!= 1)) {
749 pr_err("Illegal value %d\n", flag
);
753 a
->demo_mode_write_protect
= flag
;
754 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
755 tpg
->tpgt
, (a
->demo_mode_write_protect
) ? "ON" : "OFF");
760 int iscsit_ta_prod_mode_write_protect(
761 struct iscsi_portal_group
*tpg
,
764 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
766 if ((flag
!= 0) && (flag
!= 1)) {
767 pr_err("Illegal value %d\n", flag
);
771 a
->prod_mode_write_protect
= flag
;
772 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
773 " %s\n", tpg
->tpgt
, (a
->prod_mode_write_protect
) ?
779 int iscsit_ta_demo_mode_discovery(
780 struct iscsi_portal_group
*tpg
,
783 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
785 if ((flag
!= 0) && (flag
!= 1)) {
786 pr_err("Illegal value %d\n", flag
);
790 a
->demo_mode_discovery
= flag
;
791 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
792 " %s\n", tpg
->tpgt
, (a
->demo_mode_discovery
) ?
798 int iscsit_ta_default_erl(
799 struct iscsi_portal_group
*tpg
,
802 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
804 if ((default_erl
!= 0) && (default_erl
!= 1) && (default_erl
!= 2)) {
805 pr_err("Illegal value for default_erl: %u\n", default_erl
);
809 a
->default_erl
= default_erl
;
810 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg
->tpgt
, a
->default_erl
);
815 int iscsit_ta_t10_pi(
816 struct iscsi_portal_group
*tpg
,
819 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
821 if ((flag
!= 0) && (flag
!= 1)) {
822 pr_err("Illegal value %d\n", flag
);
827 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
828 " %s\n", tpg
->tpgt
, (a
->t10_pi
) ?
834 int iscsit_ta_fabric_prot_type(
835 struct iscsi_portal_group
*tpg
,
838 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
840 if ((prot_type
!= 0) && (prot_type
!= 1) && (prot_type
!= 3)) {
841 pr_err("Illegal value for fabric_prot_type: %u\n", prot_type
);
845 a
->fabric_prot_type
= prot_type
;
846 pr_debug("iSCSI_TPG[%hu] - T10 Fabric Protection Type: %u\n",
847 tpg
->tpgt
, prot_type
);
852 int iscsit_ta_tpg_enabled_sendtargets(
853 struct iscsi_portal_group
*tpg
,
856 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
858 if ((flag
!= 0) && (flag
!= 1)) {
859 pr_err("Illegal value %d\n", flag
);
863 a
->tpg_enabled_sendtargets
= flag
;
864 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit required for SendTargets:"
865 " %s\n", tpg
->tpgt
, (a
->tpg_enabled_sendtargets
) ? "ON" : "OFF");
870 int iscsit_ta_login_keys_workaround(
871 struct iscsi_portal_group
*tpg
,
874 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
876 if ((flag
!= 0) && (flag
!= 1)) {
877 pr_err("Illegal value %d\n", flag
);
881 a
->login_keys_workaround
= flag
;
882 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
883 tpg
->tpgt
, (a
->login_keys_workaround
) ? "ON" : "OFF");