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");
187 tpg_np->tpg_np->enabled = false;
188 iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown);
191 void iscsit_clear_tpg_np_login_threads(
192 struct iscsi_portal_group *tpg,
195 struct iscsi_tpg_np *tpg_np;
197 spin_lock(&tpg->tpg_np_lock);
198 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
199 if (!tpg_np->tpg_np) {
200 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
203 spin_unlock(&tpg->tpg_np_lock);
204 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, shutdown);
205 spin_lock(&tpg->tpg_np_lock);
207 spin_unlock(&tpg->tpg_np_lock);
210 void iscsit_tpg_dump_params(struct iscsi_portal_group *tpg)
212 iscsi_print_params(tpg->param_list);
215 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg)
217 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
219 a->authentication = TA_AUTHENTICATION;
220 a->login_timeout = TA_LOGIN_TIMEOUT;
221 a->netif_timeout = TA_NETIF_TIMEOUT;
222 a->default_cmdsn_depth = TA_DEFAULT_CMDSN_DEPTH;
223 a->generate_node_acls = TA_GENERATE_NODE_ACLS;
224 a->cache_dynamic_acls = TA_CACHE_DYNAMIC_ACLS;
225 a->demo_mode_write_protect = TA_DEMO_MODE_WRITE_PROTECT;
226 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT;
227 a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY;
228 a->default_erl = TA_DEFAULT_ERL;
229 a->t10_pi = TA_DEFAULT_T10_PI;
232 int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
234 if (tpg->tpg_state != TPG_STATE_FREE) {
235 pr_err("Unable to add iSCSI Target Portal Group: %d"
236 " while not in TPG_STATE_FREE state.\n", tpg->tpgt);
239 iscsit_set_default_tpg_attribs(tpg);
241 if (iscsi_create_default_params(&tpg->param_list) < 0)
244 tpg->tpg_attrib.tpg = tpg;
246 spin_lock(&tpg->tpg_state_lock);
247 tpg->tpg_state = TPG_STATE_INACTIVE;
248 spin_unlock(&tpg->tpg_state_lock);
250 spin_lock(&tiqn->tiqn_tpg_lock);
251 list_add_tail(&tpg->tpg_list, &tiqn->tiqn_tpg_list);
253 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
254 tiqn->tiqn, tpg->tpgt);
255 spin_unlock(&tiqn->tiqn_tpg_lock);
259 if (tpg->param_list) {
260 iscsi_release_param_list(tpg->param_list);
261 tpg->param_list = NULL;
267 int iscsit_tpg_del_portal_group(
268 struct iscsi_tiqn *tiqn,
269 struct iscsi_portal_group *tpg,
272 u8 old_state = tpg->tpg_state;
274 spin_lock(&tpg->tpg_state_lock);
275 tpg->tpg_state = TPG_STATE_INACTIVE;
276 spin_unlock(&tpg->tpg_state_lock);
278 iscsit_clear_tpg_np_login_threads(tpg, true);
280 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
281 pr_err("Unable to delete iSCSI Target Portal Group:"
282 " %hu while active sessions exist, and force=0\n",
284 tpg->tpg_state = old_state;
288 core_tpg_clear_object_luns(&tpg->tpg_se_tpg);
290 if (tpg->param_list) {
291 iscsi_release_param_list(tpg->param_list);
292 tpg->param_list = NULL;
295 core_tpg_deregister(&tpg->tpg_se_tpg);
297 spin_lock(&tpg->tpg_state_lock);
298 tpg->tpg_state = TPG_STATE_FREE;
299 spin_unlock(&tpg->tpg_state_lock);
301 spin_lock(&tiqn->tiqn_tpg_lock);
303 list_del(&tpg->tpg_list);
304 spin_unlock(&tiqn->tiqn_tpg_lock);
306 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
307 tiqn->tiqn, tpg->tpgt);
313 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
315 struct iscsi_param *param;
316 struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
319 spin_lock(&tpg->tpg_state_lock);
320 if (tpg->tpg_state == TPG_STATE_ACTIVE) {
321 pr_err("iSCSI target portal group: %hu is already"
322 " active, ignoring request.\n", tpg->tpgt);
323 spin_unlock(&tpg->tpg_state_lock);
327 * Make sure that AuthMethod does not contain None as an option
328 * unless explictly disabled. Set the default to CHAP if authentication
329 * is enforced (as per default), and remove the NONE option.
331 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
333 spin_unlock(&tpg->tpg_state_lock);
337 if (tpg->tpg_attrib.authentication) {
338 if (!strcmp(param->value, NONE)) {
339 ret = iscsi_update_param_value(param, CHAP);
344 ret = iscsit_ta_authentication(tpg, 1);
349 tpg->tpg_state = TPG_STATE_ACTIVE;
350 spin_unlock(&tpg->tpg_state_lock);
352 spin_lock(&tiqn->tiqn_tpg_lock);
353 tiqn->tiqn_active_tpgs++;
354 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
356 spin_unlock(&tiqn->tiqn_tpg_lock);
361 spin_unlock(&tpg->tpg_state_lock);
365 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force)
367 struct iscsi_tiqn *tiqn;
368 u8 old_state = tpg->tpg_state;
370 spin_lock(&tpg->tpg_state_lock);
371 if (tpg->tpg_state == TPG_STATE_INACTIVE) {
372 pr_err("iSCSI Target Portal Group: %hu is already"
373 " inactive, ignoring request.\n", tpg->tpgt);
374 spin_unlock(&tpg->tpg_state_lock);
377 tpg->tpg_state = TPG_STATE_INACTIVE;
378 spin_unlock(&tpg->tpg_state_lock);
380 iscsit_clear_tpg_np_login_threads(tpg, false);
382 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
383 spin_lock(&tpg->tpg_state_lock);
384 tpg->tpg_state = old_state;
385 spin_unlock(&tpg->tpg_state_lock);
386 pr_err("Unable to disable iSCSI Target Portal Group:"
387 " %hu while active sessions exist, and force=0\n",
392 tiqn = tpg->tpg_tiqn;
393 if (!tiqn || (tpg == iscsit_global->discovery_tpg))
396 spin_lock(&tiqn->tiqn_tpg_lock);
397 tiqn->tiqn_active_tpgs--;
398 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
400 spin_unlock(&tiqn->tiqn_tpg_lock);
405 struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(
406 struct iscsi_session *sess)
408 struct se_session *se_sess = sess->se_sess;
409 struct se_node_acl *se_nacl = se_sess->se_node_acl;
410 struct iscsi_node_acl *acl = container_of(se_nacl, struct iscsi_node_acl,
413 return &acl->node_attrib;
416 struct iscsi_tpg_np *iscsit_tpg_locate_child_np(
417 struct iscsi_tpg_np *tpg_np,
418 int network_transport)
420 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
422 spin_lock(&tpg_np->tpg_np_parent_lock);
423 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
424 &tpg_np->tpg_np_parent_list, tpg_np_child_list) {
425 if (tpg_np_child->tpg_np->np_network_transport ==
427 spin_unlock(&tpg_np->tpg_np_parent_lock);
431 spin_unlock(&tpg_np->tpg_np_parent_lock);
436 static bool iscsit_tpg_check_network_portal(
437 struct iscsi_tiqn *tiqn,
438 struct __kernel_sockaddr_storage *sockaddr,
439 int network_transport)
441 struct iscsi_portal_group *tpg;
442 struct iscsi_tpg_np *tpg_np;
446 spin_lock(&tiqn->tiqn_tpg_lock);
447 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
449 spin_lock(&tpg->tpg_np_lock);
450 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
453 match = iscsit_check_np_match(sockaddr, np,
458 spin_unlock(&tpg->tpg_np_lock);
460 spin_unlock(&tiqn->tiqn_tpg_lock);
465 struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
466 struct iscsi_portal_group *tpg,
467 struct __kernel_sockaddr_storage *sockaddr,
469 struct iscsi_tpg_np *tpg_np_parent,
470 int network_transport)
473 struct iscsi_tpg_np *tpg_np;
475 if (!tpg_np_parent) {
476 if (iscsit_tpg_check_network_portal(tpg->tpg_tiqn, sockaddr,
477 network_transport) == true) {
478 pr_err("Network Portal: %s already exists on a"
479 " different TPG on %s\n", ip_str,
480 tpg->tpg_tiqn->tiqn);
481 return ERR_PTR(-EEXIST);
485 tpg_np = kzalloc(sizeof(struct iscsi_tpg_np), GFP_KERNEL);
487 pr_err("Unable to allocate memory for"
488 " struct iscsi_tpg_np.\n");
489 return ERR_PTR(-ENOMEM);
492 np = iscsit_add_np(sockaddr, ip_str, network_transport);
498 INIT_LIST_HEAD(&tpg_np->tpg_np_list);
499 INIT_LIST_HEAD(&tpg_np->tpg_np_child_list);
500 INIT_LIST_HEAD(&tpg_np->tpg_np_parent_list);
501 spin_lock_init(&tpg_np->tpg_np_parent_lock);
502 init_completion(&tpg_np->tpg_np_comp);
503 kref_init(&tpg_np->tpg_np_kref);
508 spin_lock(&tpg->tpg_np_lock);
509 list_add_tail(&tpg_np->tpg_np_list, &tpg->tpg_gnp_list);
512 tpg->tpg_tiqn->tiqn_num_tpg_nps++;
513 spin_unlock(&tpg->tpg_np_lock);
516 tpg_np->tpg_np_parent = tpg_np_parent;
517 spin_lock(&tpg_np_parent->tpg_np_parent_lock);
518 list_add_tail(&tpg_np->tpg_np_child_list,
519 &tpg_np_parent->tpg_np_parent_list);
520 spin_unlock(&tpg_np_parent->tpg_np_parent_lock);
523 pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n",
524 tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
525 np->np_transport->name);
530 static int iscsit_tpg_release_np(
531 struct iscsi_tpg_np *tpg_np,
532 struct iscsi_portal_group *tpg,
535 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, true);
537 pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n",
538 tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
539 np->np_transport->name);
541 tpg_np->tpg_np = NULL;
545 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
547 return iscsit_del_np(np);
550 int iscsit_tpg_del_network_portal(
551 struct iscsi_portal_group *tpg,
552 struct iscsi_tpg_np *tpg_np)
555 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
560 pr_err("Unable to locate struct iscsi_np from"
561 " struct iscsi_tpg_np\n");
565 if (!tpg_np->tpg_np_parent) {
567 * We are the parent tpg network portal. Release all of the
568 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
571 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
572 &tpg_np->tpg_np_parent_list,
574 ret = iscsit_tpg_del_network_portal(tpg, tpg_np_child);
576 pr_err("iscsit_tpg_del_network_portal()"
577 " failed: %d\n", ret);
581 * We are not the parent ISCSI_TCP tpg network portal. Release
582 * our own network portals from the child list.
584 spin_lock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
585 list_del(&tpg_np->tpg_np_child_list);
586 spin_unlock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
589 spin_lock(&tpg->tpg_np_lock);
590 list_del(&tpg_np->tpg_np_list);
593 tpg->tpg_tiqn->tiqn_num_tpg_nps--;
594 spin_unlock(&tpg->tpg_np_lock);
596 return iscsit_tpg_release_np(tpg_np, tpg, np);
599 int iscsit_tpg_set_initiator_node_queue_depth(
600 struct iscsi_portal_group *tpg,
601 unsigned char *initiatorname,
605 return core_tpg_set_initiator_node_queue_depth(&tpg->tpg_se_tpg,
606 initiatorname, queue_depth, force);
609 int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
611 unsigned char buf1[256], buf2[256], *none = NULL;
613 struct iscsi_param *param;
614 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
616 if ((authentication != 1) && (authentication != 0)) {
617 pr_err("Illegal value for authentication parameter:"
618 " %u, ignoring request.\n", authentication);
622 memset(buf1, 0, sizeof(buf1));
623 memset(buf2, 0, sizeof(buf2));
625 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
629 if (authentication) {
630 snprintf(buf1, sizeof(buf1), "%s", param->value);
631 none = strstr(buf1, NONE);
634 if (!strncmp(none + 4, ",", 1)) {
635 if (!strcmp(buf1, none))
636 sprintf(buf2, "%s", none+5);
640 len = sprintf(buf2, "%s", buf1);
642 sprintf(buf2 + len, "%s", none);
647 sprintf(buf2, "%s", buf1);
649 if (iscsi_update_param_value(param, buf2) < 0)
652 snprintf(buf1, sizeof(buf1), "%s", param->value);
653 none = strstr(buf1, NONE);
656 strncat(buf1, ",", strlen(","));
657 strncat(buf1, NONE, strlen(NONE));
658 if (iscsi_update_param_value(param, buf1) < 0)
663 a->authentication = authentication;
664 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
665 a->authentication ? "Enforcing" : "Disabling", tpg->tpgt);
670 int iscsit_ta_login_timeout(
671 struct iscsi_portal_group *tpg,
674 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
676 if (login_timeout > TA_LOGIN_TIMEOUT_MAX) {
677 pr_err("Requested Login Timeout %u larger than maximum"
678 " %u\n", login_timeout, TA_LOGIN_TIMEOUT_MAX);
680 } else if (login_timeout < TA_LOGIN_TIMEOUT_MIN) {
681 pr_err("Requested Logout Timeout %u smaller than"
682 " minimum %u\n", login_timeout, TA_LOGIN_TIMEOUT_MIN);
686 a->login_timeout = login_timeout;
687 pr_debug("Set Logout Timeout to %u for Target Portal Group"
688 " %hu\n", a->login_timeout, tpg->tpgt);
693 int iscsit_ta_netif_timeout(
694 struct iscsi_portal_group *tpg,
697 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
699 if (netif_timeout > TA_NETIF_TIMEOUT_MAX) {
700 pr_err("Requested Network Interface Timeout %u larger"
701 " than maximum %u\n", netif_timeout,
702 TA_NETIF_TIMEOUT_MAX);
704 } else if (netif_timeout < TA_NETIF_TIMEOUT_MIN) {
705 pr_err("Requested Network Interface Timeout %u smaller"
706 " than minimum %u\n", netif_timeout,
707 TA_NETIF_TIMEOUT_MIN);
711 a->netif_timeout = netif_timeout;
712 pr_debug("Set Network Interface Timeout to %u for"
713 " Target Portal Group %hu\n", a->netif_timeout, tpg->tpgt);
718 int iscsit_ta_generate_node_acls(
719 struct iscsi_portal_group *tpg,
722 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
724 if ((flag != 0) && (flag != 1)) {
725 pr_err("Illegal value %d\n", flag);
729 a->generate_node_acls = flag;
730 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
731 tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled");
733 if (flag == 1 && a->cache_dynamic_acls == 0) {
734 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
735 "generate_node_acls=1\n");
736 a->cache_dynamic_acls = 1;
742 int iscsit_ta_default_cmdsn_depth(
743 struct iscsi_portal_group *tpg,
746 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
748 if (tcq_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
749 pr_err("Requested Default Queue Depth: %u larger"
750 " than maximum %u\n", tcq_depth,
751 TA_DEFAULT_CMDSN_DEPTH_MAX);
753 } else if (tcq_depth < TA_DEFAULT_CMDSN_DEPTH_MIN) {
754 pr_err("Requested Default Queue Depth: %u smaller"
755 " than minimum %u\n", tcq_depth,
756 TA_DEFAULT_CMDSN_DEPTH_MIN);
760 a->default_cmdsn_depth = tcq_depth;
761 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
762 tpg->tpgt, a->default_cmdsn_depth);
767 int iscsit_ta_cache_dynamic_acls(
768 struct iscsi_portal_group *tpg,
771 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
773 if ((flag != 0) && (flag != 1)) {
774 pr_err("Illegal value %d\n", flag);
778 if (a->generate_node_acls == 1 && flag == 0) {
779 pr_debug("Skipping cache_dynamic_acls=0 when"
780 " generate_node_acls=1\n");
784 a->cache_dynamic_acls = flag;
785 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
786 " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ?
787 "Enabled" : "Disabled");
792 int iscsit_ta_demo_mode_write_protect(
793 struct iscsi_portal_group *tpg,
796 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
798 if ((flag != 0) && (flag != 1)) {
799 pr_err("Illegal value %d\n", flag);
803 a->demo_mode_write_protect = flag;
804 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
805 tpg->tpgt, (a->demo_mode_write_protect) ? "ON" : "OFF");
810 int iscsit_ta_prod_mode_write_protect(
811 struct iscsi_portal_group *tpg,
814 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
816 if ((flag != 0) && (flag != 1)) {
817 pr_err("Illegal value %d\n", flag);
821 a->prod_mode_write_protect = flag;
822 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
823 " %s\n", tpg->tpgt, (a->prod_mode_write_protect) ?
829 int iscsit_ta_demo_mode_discovery(
830 struct iscsi_portal_group *tpg,
833 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
835 if ((flag != 0) && (flag != 1)) {
836 pr_err("Illegal value %d\n", flag);
840 a->demo_mode_discovery = flag;
841 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
842 " %s\n", tpg->tpgt, (a->demo_mode_discovery) ?
848 int iscsit_ta_default_erl(
849 struct iscsi_portal_group *tpg,
852 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
854 if ((default_erl != 0) && (default_erl != 1) && (default_erl != 2)) {
855 pr_err("Illegal value for default_erl: %u\n", default_erl);
859 a->default_erl = default_erl;
860 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg->tpgt, a->default_erl);
865 int iscsit_ta_t10_pi(
866 struct iscsi_portal_group *tpg,
869 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
871 if ((flag != 0) && (flag != 1)) {
872 pr_err("Illegal value %d\n", flag);
877 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
878 " %s\n", tpg->tpgt, (a->t10_pi) ?