1 /*******************************************************************************
2 * This file contains iSCSI Target Portal Group related functions.
4 * (c) Copyright 2007-2013 Datera, Inc.
6 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 ******************************************************************************/
19 #include <target/target_core_base.h>
20 #include <target/target_core_fabric.h>
21 #include <target/target_core_configfs.h>
23 #include "iscsi_target_core.h"
24 #include "iscsi_target_erl0.h"
25 #include "iscsi_target_login.h"
26 #include "iscsi_target_nodeattrib.h"
27 #include "iscsi_target_tpg.h"
28 #include "iscsi_target_util.h"
29 #include "iscsi_target.h"
30 #include "iscsi_target_parameters.h"
32 #include <target/iscsi/iscsi_transport.h>
34 struct iscsi_portal_group *iscsit_alloc_portal_group(struct iscsi_tiqn *tiqn, u16 tpgt)
36 struct iscsi_portal_group *tpg;
38 tpg = kzalloc(sizeof(struct iscsi_portal_group), GFP_KERNEL);
40 pr_err("Unable to allocate struct iscsi_portal_group\n");
45 tpg->tpg_state = TPG_STATE_FREE;
47 INIT_LIST_HEAD(&tpg->tpg_gnp_list);
48 INIT_LIST_HEAD(&tpg->tpg_list);
49 mutex_init(&tpg->tpg_access_lock);
50 sema_init(&tpg->np_login_sem, 1);
51 spin_lock_init(&tpg->tpg_state_lock);
52 spin_lock_init(&tpg->tpg_np_lock);
57 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *);
59 int iscsit_load_discovery_tpg(void)
61 struct iscsi_param *param;
62 struct iscsi_portal_group *tpg;
65 tpg = iscsit_alloc_portal_group(NULL, 1);
67 pr_err("Unable to allocate struct iscsi_portal_group\n");
71 ret = core_tpg_register(
72 &lio_target_fabric_configfs->tf_ops,
73 NULL, &tpg->tpg_se_tpg, tpg,
74 TRANSPORT_TPG_TYPE_DISCOVERY);
80 tpg->sid = 1; /* First Assigned LIO Session ID */
81 iscsit_set_default_tpg_attribs(tpg);
83 if (iscsi_create_default_params(&tpg->param_list) < 0)
86 * By default we disable authentication for discovery sessions,
87 * this can be changed with:
89 * /sys/kernel/config/target/iscsi/discovery_auth/enforce_discovery_auth
91 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
95 if (iscsi_update_param_value(param, "CHAP,None") < 0)
98 tpg->tpg_attrib.authentication = 0;
100 spin_lock(&tpg->tpg_state_lock);
101 tpg->tpg_state = TPG_STATE_ACTIVE;
102 spin_unlock(&tpg->tpg_state_lock);
104 iscsit_global->discovery_tpg = tpg;
105 pr_debug("CORE[0] - Allocated Discovery TPG\n");
110 core_tpg_deregister(&tpg->tpg_se_tpg);
115 void iscsit_release_discovery_tpg(void)
117 struct iscsi_portal_group *tpg = iscsit_global->discovery_tpg;
122 core_tpg_deregister(&tpg->tpg_se_tpg);
125 iscsit_global->discovery_tpg = NULL;
128 struct iscsi_portal_group *iscsit_get_tpg_from_np(
129 struct iscsi_tiqn *tiqn,
131 struct iscsi_tpg_np **tpg_np_out)
133 struct iscsi_portal_group *tpg = NULL;
134 struct iscsi_tpg_np *tpg_np;
136 spin_lock(&tiqn->tiqn_tpg_lock);
137 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
139 spin_lock(&tpg->tpg_state_lock);
140 if (tpg->tpg_state != TPG_STATE_ACTIVE) {
141 spin_unlock(&tpg->tpg_state_lock);
144 spin_unlock(&tpg->tpg_state_lock);
146 spin_lock(&tpg->tpg_np_lock);
147 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
148 if (tpg_np->tpg_np == np) {
149 *tpg_np_out = tpg_np;
150 kref_get(&tpg_np->tpg_np_kref);
151 spin_unlock(&tpg->tpg_np_lock);
152 spin_unlock(&tiqn->tiqn_tpg_lock);
156 spin_unlock(&tpg->tpg_np_lock);
158 spin_unlock(&tiqn->tiqn_tpg_lock);
164 struct iscsi_portal_group *tpg)
168 ret = mutex_lock_interruptible(&tpg->tpg_access_lock);
169 return ((ret != 0) || signal_pending(current)) ? -1 : 0;
172 void iscsit_put_tpg(struct iscsi_portal_group *tpg)
174 mutex_unlock(&tpg->tpg_access_lock);
177 static void iscsit_clear_tpg_np_login_thread(
178 struct iscsi_tpg_np *tpg_np,
179 struct iscsi_portal_group *tpg,
182 if (!tpg_np->tpg_np) {
183 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
188 tpg_np->tpg_np->enabled = false;
189 iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown);
192 static void iscsit_clear_tpg_np_login_threads(
193 struct iscsi_portal_group *tpg,
196 struct iscsi_tpg_np *tpg_np;
198 spin_lock(&tpg->tpg_np_lock);
199 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
200 if (!tpg_np->tpg_np) {
201 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
204 spin_unlock(&tpg->tpg_np_lock);
205 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, shutdown);
206 spin_lock(&tpg->tpg_np_lock);
208 spin_unlock(&tpg->tpg_np_lock);
211 void iscsit_tpg_dump_params(struct iscsi_portal_group *tpg)
213 iscsi_print_params(tpg->param_list);
216 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg)
218 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
220 a->authentication = TA_AUTHENTICATION;
221 a->login_timeout = TA_LOGIN_TIMEOUT;
222 a->netif_timeout = TA_NETIF_TIMEOUT;
223 a->default_cmdsn_depth = TA_DEFAULT_CMDSN_DEPTH;
224 a->generate_node_acls = TA_GENERATE_NODE_ACLS;
225 a->cache_dynamic_acls = TA_CACHE_DYNAMIC_ACLS;
226 a->demo_mode_write_protect = TA_DEMO_MODE_WRITE_PROTECT;
227 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT;
228 a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY;
229 a->default_erl = TA_DEFAULT_ERL;
230 a->t10_pi = TA_DEFAULT_T10_PI;
233 int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
235 if (tpg->tpg_state != TPG_STATE_FREE) {
236 pr_err("Unable to add iSCSI Target Portal Group: %d"
237 " while not in TPG_STATE_FREE state.\n", tpg->tpgt);
240 iscsit_set_default_tpg_attribs(tpg);
242 if (iscsi_create_default_params(&tpg->param_list) < 0)
245 tpg->tpg_attrib.tpg = tpg;
247 spin_lock(&tpg->tpg_state_lock);
248 tpg->tpg_state = TPG_STATE_INACTIVE;
249 spin_unlock(&tpg->tpg_state_lock);
251 spin_lock(&tiqn->tiqn_tpg_lock);
252 list_add_tail(&tpg->tpg_list, &tiqn->tiqn_tpg_list);
254 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
255 tiqn->tiqn, tpg->tpgt);
256 spin_unlock(&tiqn->tiqn_tpg_lock);
260 if (tpg->param_list) {
261 iscsi_release_param_list(tpg->param_list);
262 tpg->param_list = NULL;
268 int iscsit_tpg_del_portal_group(
269 struct iscsi_tiqn *tiqn,
270 struct iscsi_portal_group *tpg,
273 u8 old_state = tpg->tpg_state;
275 spin_lock(&tpg->tpg_state_lock);
276 tpg->tpg_state = TPG_STATE_INACTIVE;
277 spin_unlock(&tpg->tpg_state_lock);
279 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
280 pr_err("Unable to delete iSCSI Target Portal Group:"
281 " %hu while active sessions exist, and force=0\n",
283 tpg->tpg_state = old_state;
287 core_tpg_clear_object_luns(&tpg->tpg_se_tpg);
289 if (tpg->param_list) {
290 iscsi_release_param_list(tpg->param_list);
291 tpg->param_list = NULL;
294 core_tpg_deregister(&tpg->tpg_se_tpg);
296 spin_lock(&tpg->tpg_state_lock);
297 tpg->tpg_state = TPG_STATE_FREE;
298 spin_unlock(&tpg->tpg_state_lock);
300 spin_lock(&tiqn->tiqn_tpg_lock);
302 list_del(&tpg->tpg_list);
303 spin_unlock(&tiqn->tiqn_tpg_lock);
305 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
306 tiqn->tiqn, tpg->tpgt);
312 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
314 struct iscsi_param *param;
315 struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
318 spin_lock(&tpg->tpg_state_lock);
319 if (tpg->tpg_state == TPG_STATE_ACTIVE) {
320 pr_err("iSCSI target portal group: %hu is already"
321 " active, ignoring request.\n", tpg->tpgt);
322 spin_unlock(&tpg->tpg_state_lock);
326 * Make sure that AuthMethod does not contain None as an option
327 * unless explictly disabled. Set the default to CHAP if authentication
328 * is enforced (as per default), and remove the NONE option.
330 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
332 spin_unlock(&tpg->tpg_state_lock);
336 if (tpg->tpg_attrib.authentication) {
337 if (!strcmp(param->value, NONE)) {
338 ret = iscsi_update_param_value(param, CHAP);
343 ret = iscsit_ta_authentication(tpg, 1);
348 tpg->tpg_state = TPG_STATE_ACTIVE;
349 spin_unlock(&tpg->tpg_state_lock);
351 spin_lock(&tiqn->tiqn_tpg_lock);
352 tiqn->tiqn_active_tpgs++;
353 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
355 spin_unlock(&tiqn->tiqn_tpg_lock);
360 spin_unlock(&tpg->tpg_state_lock);
364 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force)
366 struct iscsi_tiqn *tiqn;
367 u8 old_state = tpg->tpg_state;
369 spin_lock(&tpg->tpg_state_lock);
370 if (tpg->tpg_state == TPG_STATE_INACTIVE) {
371 pr_err("iSCSI Target Portal Group: %hu is already"
372 " inactive, ignoring request.\n", tpg->tpgt);
373 spin_unlock(&tpg->tpg_state_lock);
376 tpg->tpg_state = TPG_STATE_INACTIVE;
377 spin_unlock(&tpg->tpg_state_lock);
379 iscsit_clear_tpg_np_login_threads(tpg, false);
381 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
382 spin_lock(&tpg->tpg_state_lock);
383 tpg->tpg_state = old_state;
384 spin_unlock(&tpg->tpg_state_lock);
385 pr_err("Unable to disable iSCSI Target Portal Group:"
386 " %hu while active sessions exist, and force=0\n",
391 tiqn = tpg->tpg_tiqn;
392 if (!tiqn || (tpg == iscsit_global->discovery_tpg))
395 spin_lock(&tiqn->tiqn_tpg_lock);
396 tiqn->tiqn_active_tpgs--;
397 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
399 spin_unlock(&tiqn->tiqn_tpg_lock);
404 struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(
405 struct iscsi_session *sess)
407 struct se_session *se_sess = sess->se_sess;
408 struct se_node_acl *se_nacl = se_sess->se_node_acl;
409 struct iscsi_node_acl *acl = container_of(se_nacl, struct iscsi_node_acl,
412 return &acl->node_attrib;
415 struct iscsi_tpg_np *iscsit_tpg_locate_child_np(
416 struct iscsi_tpg_np *tpg_np,
417 int network_transport)
419 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
421 spin_lock(&tpg_np->tpg_np_parent_lock);
422 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
423 &tpg_np->tpg_np_parent_list, tpg_np_child_list) {
424 if (tpg_np_child->tpg_np->np_network_transport ==
426 spin_unlock(&tpg_np->tpg_np_parent_lock);
430 spin_unlock(&tpg_np->tpg_np_parent_lock);
435 static bool iscsit_tpg_check_network_portal(
436 struct iscsi_tiqn *tiqn,
437 struct __kernel_sockaddr_storage *sockaddr,
438 int network_transport)
440 struct iscsi_portal_group *tpg;
441 struct iscsi_tpg_np *tpg_np;
445 spin_lock(&tiqn->tiqn_tpg_lock);
446 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
448 spin_lock(&tpg->tpg_np_lock);
449 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
452 match = iscsit_check_np_match(sockaddr, np,
457 spin_unlock(&tpg->tpg_np_lock);
459 spin_unlock(&tiqn->tiqn_tpg_lock);
464 struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
465 struct iscsi_portal_group *tpg,
466 struct __kernel_sockaddr_storage *sockaddr,
468 struct iscsi_tpg_np *tpg_np_parent,
469 int network_transport)
472 struct iscsi_tpg_np *tpg_np;
474 if (!tpg_np_parent) {
475 if (iscsit_tpg_check_network_portal(tpg->tpg_tiqn, sockaddr,
476 network_transport)) {
477 pr_err("Network Portal: %s already exists on a"
478 " different TPG on %s\n", ip_str,
479 tpg->tpg_tiqn->tiqn);
480 return ERR_PTR(-EEXIST);
484 tpg_np = kzalloc(sizeof(struct iscsi_tpg_np), GFP_KERNEL);
486 pr_err("Unable to allocate memory for"
487 " struct iscsi_tpg_np.\n");
488 return ERR_PTR(-ENOMEM);
491 np = iscsit_add_np(sockaddr, ip_str, network_transport);
497 INIT_LIST_HEAD(&tpg_np->tpg_np_list);
498 INIT_LIST_HEAD(&tpg_np->tpg_np_child_list);
499 INIT_LIST_HEAD(&tpg_np->tpg_np_parent_list);
500 spin_lock_init(&tpg_np->tpg_np_parent_lock);
501 init_completion(&tpg_np->tpg_np_comp);
502 kref_init(&tpg_np->tpg_np_kref);
506 spin_lock(&tpg->tpg_np_lock);
507 list_add_tail(&tpg_np->tpg_np_list, &tpg->tpg_gnp_list);
510 tpg->tpg_tiqn->tiqn_num_tpg_nps++;
511 spin_unlock(&tpg->tpg_np_lock);
514 tpg_np->tpg_np_parent = tpg_np_parent;
515 spin_lock(&tpg_np_parent->tpg_np_parent_lock);
516 list_add_tail(&tpg_np->tpg_np_child_list,
517 &tpg_np_parent->tpg_np_parent_list);
518 spin_unlock(&tpg_np_parent->tpg_np_parent_lock);
521 pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n",
522 tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
523 np->np_transport->name);
528 static int iscsit_tpg_release_np(
529 struct iscsi_tpg_np *tpg_np,
530 struct iscsi_portal_group *tpg,
533 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, true);
535 pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n",
536 tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
537 np->np_transport->name);
539 tpg_np->tpg_np = NULL;
543 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
545 return iscsit_del_np(np);
548 int iscsit_tpg_del_network_portal(
549 struct iscsi_portal_group *tpg,
550 struct iscsi_tpg_np *tpg_np)
553 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
558 pr_err("Unable to locate struct iscsi_np from"
559 " struct iscsi_tpg_np\n");
563 if (!tpg_np->tpg_np_parent) {
565 * We are the parent tpg network portal. Release all of the
566 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
569 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
570 &tpg_np->tpg_np_parent_list,
572 ret = iscsit_tpg_del_network_portal(tpg, tpg_np_child);
574 pr_err("iscsit_tpg_del_network_portal()"
575 " failed: %d\n", ret);
579 * We are not the parent ISCSI_TCP tpg network portal. Release
580 * our own network portals from the child list.
582 spin_lock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
583 list_del(&tpg_np->tpg_np_child_list);
584 spin_unlock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
587 spin_lock(&tpg->tpg_np_lock);
588 list_del(&tpg_np->tpg_np_list);
591 tpg->tpg_tiqn->tiqn_num_tpg_nps--;
592 spin_unlock(&tpg->tpg_np_lock);
594 return iscsit_tpg_release_np(tpg_np, tpg, np);
597 int iscsit_tpg_set_initiator_node_queue_depth(
598 struct iscsi_portal_group *tpg,
599 unsigned char *initiatorname,
603 return core_tpg_set_initiator_node_queue_depth(&tpg->tpg_se_tpg,
604 initiatorname, queue_depth, force);
607 int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
609 unsigned char buf1[256], buf2[256], *none = NULL;
611 struct iscsi_param *param;
612 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
614 if ((authentication != 1) && (authentication != 0)) {
615 pr_err("Illegal value for authentication parameter:"
616 " %u, ignoring request.\n", authentication);
620 memset(buf1, 0, sizeof(buf1));
621 memset(buf2, 0, sizeof(buf2));
623 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
627 if (authentication) {
628 snprintf(buf1, sizeof(buf1), "%s", param->value);
629 none = strstr(buf1, NONE);
632 if (!strncmp(none + 4, ",", 1)) {
633 if (!strcmp(buf1, none))
634 sprintf(buf2, "%s", none+5);
638 len = sprintf(buf2, "%s", buf1);
640 sprintf(buf2 + len, "%s", none);
645 sprintf(buf2, "%s", buf1);
647 if (iscsi_update_param_value(param, buf2) < 0)
650 snprintf(buf1, sizeof(buf1), "%s", param->value);
651 none = strstr(buf1, NONE);
654 strncat(buf1, ",", strlen(","));
655 strncat(buf1, NONE, strlen(NONE));
656 if (iscsi_update_param_value(param, buf1) < 0)
661 a->authentication = authentication;
662 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
663 a->authentication ? "Enforcing" : "Disabling", tpg->tpgt);
668 int iscsit_ta_login_timeout(
669 struct iscsi_portal_group *tpg,
672 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
674 if (login_timeout > TA_LOGIN_TIMEOUT_MAX) {
675 pr_err("Requested Login Timeout %u larger than maximum"
676 " %u\n", login_timeout, TA_LOGIN_TIMEOUT_MAX);
678 } else if (login_timeout < TA_LOGIN_TIMEOUT_MIN) {
679 pr_err("Requested Logout Timeout %u smaller than"
680 " minimum %u\n", login_timeout, TA_LOGIN_TIMEOUT_MIN);
684 a->login_timeout = login_timeout;
685 pr_debug("Set Logout Timeout to %u for Target Portal Group"
686 " %hu\n", a->login_timeout, tpg->tpgt);
691 int iscsit_ta_netif_timeout(
692 struct iscsi_portal_group *tpg,
695 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
697 if (netif_timeout > TA_NETIF_TIMEOUT_MAX) {
698 pr_err("Requested Network Interface Timeout %u larger"
699 " than maximum %u\n", netif_timeout,
700 TA_NETIF_TIMEOUT_MAX);
702 } else if (netif_timeout < TA_NETIF_TIMEOUT_MIN) {
703 pr_err("Requested Network Interface Timeout %u smaller"
704 " than minimum %u\n", netif_timeout,
705 TA_NETIF_TIMEOUT_MIN);
709 a->netif_timeout = netif_timeout;
710 pr_debug("Set Network Interface Timeout to %u for"
711 " Target Portal Group %hu\n", a->netif_timeout, tpg->tpgt);
716 int iscsit_ta_generate_node_acls(
717 struct iscsi_portal_group *tpg,
720 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
722 if ((flag != 0) && (flag != 1)) {
723 pr_err("Illegal value %d\n", flag);
727 a->generate_node_acls = flag;
728 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
729 tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled");
731 if (flag == 1 && a->cache_dynamic_acls == 0) {
732 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
733 "generate_node_acls=1\n");
734 a->cache_dynamic_acls = 1;
740 int iscsit_ta_default_cmdsn_depth(
741 struct iscsi_portal_group *tpg,
744 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
746 if (tcq_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
747 pr_err("Requested Default Queue Depth: %u larger"
748 " than maximum %u\n", tcq_depth,
749 TA_DEFAULT_CMDSN_DEPTH_MAX);
751 } else if (tcq_depth < TA_DEFAULT_CMDSN_DEPTH_MIN) {
752 pr_err("Requested Default Queue Depth: %u smaller"
753 " than minimum %u\n", tcq_depth,
754 TA_DEFAULT_CMDSN_DEPTH_MIN);
758 a->default_cmdsn_depth = tcq_depth;
759 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
760 tpg->tpgt, a->default_cmdsn_depth);
765 int iscsit_ta_cache_dynamic_acls(
766 struct iscsi_portal_group *tpg,
769 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
771 if ((flag != 0) && (flag != 1)) {
772 pr_err("Illegal value %d\n", flag);
776 if (a->generate_node_acls == 1 && flag == 0) {
777 pr_debug("Skipping cache_dynamic_acls=0 when"
778 " generate_node_acls=1\n");
782 a->cache_dynamic_acls = flag;
783 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
784 " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ?
785 "Enabled" : "Disabled");
790 int iscsit_ta_demo_mode_write_protect(
791 struct iscsi_portal_group *tpg,
794 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
796 if ((flag != 0) && (flag != 1)) {
797 pr_err("Illegal value %d\n", flag);
801 a->demo_mode_write_protect = flag;
802 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
803 tpg->tpgt, (a->demo_mode_write_protect) ? "ON" : "OFF");
808 int iscsit_ta_prod_mode_write_protect(
809 struct iscsi_portal_group *tpg,
812 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
814 if ((flag != 0) && (flag != 1)) {
815 pr_err("Illegal value %d\n", flag);
819 a->prod_mode_write_protect = flag;
820 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
821 " %s\n", tpg->tpgt, (a->prod_mode_write_protect) ?
827 int iscsit_ta_demo_mode_discovery(
828 struct iscsi_portal_group *tpg,
831 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
833 if ((flag != 0) && (flag != 1)) {
834 pr_err("Illegal value %d\n", flag);
838 a->demo_mode_discovery = flag;
839 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
840 " %s\n", tpg->tpgt, (a->demo_mode_discovery) ?
846 int iscsit_ta_default_erl(
847 struct iscsi_portal_group *tpg,
850 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
852 if ((default_erl != 0) && (default_erl != 1) && (default_erl != 2)) {
853 pr_err("Illegal value for default_erl: %u\n", default_erl);
857 a->default_erl = default_erl;
858 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg->tpgt, a->default_erl);
863 int iscsit_ta_t10_pi(
864 struct iscsi_portal_group *tpg,
867 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
869 if ((flag != 0) && (flag != 1)) {
870 pr_err("Illegal value %d\n", flag);
875 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
876 " %s\n", tpg->tpgt, (a->t10_pi) ?