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->netif_timeout = TA_NETIF_TIMEOUT;
215 a->default_cmdsn_depth = TA_DEFAULT_CMDSN_DEPTH;
216 a->generate_node_acls = TA_GENERATE_NODE_ACLS;
217 a->cache_dynamic_acls = TA_CACHE_DYNAMIC_ACLS;
218 a->demo_mode_write_protect = TA_DEMO_MODE_WRITE_PROTECT;
219 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT;
220 a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY;
221 a->default_erl = TA_DEFAULT_ERL;
222 a->t10_pi = TA_DEFAULT_T10_PI;
223 a->fabric_prot_type = TA_DEFAULT_FABRIC_PROT_TYPE;
224 a->tpg_enabled_sendtargets = TA_DEFAULT_TPG_ENABLED_SENDTARGETS;
225 a->login_keys_workaround = TA_DEFAULT_LOGIN_KEYS_WORKAROUND;
228 int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
230 if (tpg->tpg_state != TPG_STATE_FREE) {
231 pr_err("Unable to add iSCSI Target Portal Group: %d"
232 " while not in TPG_STATE_FREE state.\n", tpg->tpgt);
235 iscsit_set_default_tpg_attribs(tpg);
237 if (iscsi_create_default_params(&tpg->param_list) < 0)
240 tpg->tpg_attrib.tpg = tpg;
242 spin_lock(&tpg->tpg_state_lock);
243 tpg->tpg_state = TPG_STATE_INACTIVE;
244 spin_unlock(&tpg->tpg_state_lock);
246 spin_lock(&tiqn->tiqn_tpg_lock);
247 list_add_tail(&tpg->tpg_list, &tiqn->tiqn_tpg_list);
249 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
250 tiqn->tiqn, tpg->tpgt);
251 spin_unlock(&tiqn->tiqn_tpg_lock);
255 if (tpg->param_list) {
256 iscsi_release_param_list(tpg->param_list);
257 tpg->param_list = NULL;
262 int iscsit_tpg_del_portal_group(
263 struct iscsi_tiqn *tiqn,
264 struct iscsi_portal_group *tpg,
267 u8 old_state = tpg->tpg_state;
269 spin_lock(&tpg->tpg_state_lock);
270 tpg->tpg_state = TPG_STATE_INACTIVE;
271 spin_unlock(&tpg->tpg_state_lock);
273 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
274 pr_err("Unable to delete iSCSI Target Portal Group:"
275 " %hu while active sessions exist, and force=0\n",
277 tpg->tpg_state = old_state;
281 if (tpg->param_list) {
282 iscsi_release_param_list(tpg->param_list);
283 tpg->param_list = NULL;
286 core_tpg_deregister(&tpg->tpg_se_tpg);
288 spin_lock(&tpg->tpg_state_lock);
289 tpg->tpg_state = TPG_STATE_FREE;
290 spin_unlock(&tpg->tpg_state_lock);
292 spin_lock(&tiqn->tiqn_tpg_lock);
294 list_del(&tpg->tpg_list);
295 spin_unlock(&tiqn->tiqn_tpg_lock);
297 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
298 tiqn->tiqn, tpg->tpgt);
304 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
306 struct iscsi_param *param;
307 struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
310 if (tpg->tpg_state == TPG_STATE_ACTIVE) {
311 pr_err("iSCSI target portal group: %hu is already"
312 " active, ignoring request.\n", tpg->tpgt);
316 * Make sure that AuthMethod does not contain None as an option
317 * unless explictly disabled. Set the default to CHAP if authentication
318 * is enforced (as per default), and remove the NONE option.
320 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
324 if (tpg->tpg_attrib.authentication) {
325 if (!strcmp(param->value, NONE)) {
326 ret = iscsi_update_param_value(param, CHAP);
331 ret = iscsit_ta_authentication(tpg, 1);
336 spin_lock(&tpg->tpg_state_lock);
337 tpg->tpg_state = TPG_STATE_ACTIVE;
338 spin_unlock(&tpg->tpg_state_lock);
340 spin_lock(&tiqn->tiqn_tpg_lock);
341 tiqn->tiqn_active_tpgs++;
342 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
344 spin_unlock(&tiqn->tiqn_tpg_lock);
352 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force)
354 struct iscsi_tiqn *tiqn;
355 u8 old_state = tpg->tpg_state;
357 spin_lock(&tpg->tpg_state_lock);
358 if (tpg->tpg_state == TPG_STATE_INACTIVE) {
359 pr_err("iSCSI Target Portal Group: %hu is already"
360 " inactive, ignoring request.\n", tpg->tpgt);
361 spin_unlock(&tpg->tpg_state_lock);
364 tpg->tpg_state = TPG_STATE_INACTIVE;
365 spin_unlock(&tpg->tpg_state_lock);
367 iscsit_clear_tpg_np_login_threads(tpg, false);
369 if (iscsit_release_sessions_for_tpg(tpg, force) < 0) {
370 spin_lock(&tpg->tpg_state_lock);
371 tpg->tpg_state = old_state;
372 spin_unlock(&tpg->tpg_state_lock);
373 pr_err("Unable to disable iSCSI Target Portal Group:"
374 " %hu while active sessions exist, and force=0\n",
379 tiqn = tpg->tpg_tiqn;
380 if (!tiqn || (tpg == iscsit_global->discovery_tpg))
383 spin_lock(&tiqn->tiqn_tpg_lock);
384 tiqn->tiqn_active_tpgs--;
385 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
387 spin_unlock(&tiqn->tiqn_tpg_lock);
392 struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(
393 struct iscsi_session *sess)
395 struct se_session *se_sess = sess->se_sess;
396 struct se_node_acl *se_nacl = se_sess->se_node_acl;
397 struct iscsi_node_acl *acl = container_of(se_nacl, struct iscsi_node_acl,
400 return &acl->node_attrib;
403 struct iscsi_tpg_np *iscsit_tpg_locate_child_np(
404 struct iscsi_tpg_np *tpg_np,
405 int network_transport)
407 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
409 spin_lock(&tpg_np->tpg_np_parent_lock);
410 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
411 &tpg_np->tpg_np_parent_list, tpg_np_child_list) {
412 if (tpg_np_child->tpg_np->np_network_transport ==
414 spin_unlock(&tpg_np->tpg_np_parent_lock);
418 spin_unlock(&tpg_np->tpg_np_parent_lock);
423 static bool iscsit_tpg_check_network_portal(
424 struct iscsi_tiqn *tiqn,
425 struct sockaddr_storage *sockaddr,
426 int network_transport)
428 struct iscsi_portal_group *tpg;
429 struct iscsi_tpg_np *tpg_np;
433 spin_lock(&tiqn->tiqn_tpg_lock);
434 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
436 spin_lock(&tpg->tpg_np_lock);
437 list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) {
440 match = iscsit_check_np_match(sockaddr, np,
445 spin_unlock(&tpg->tpg_np_lock);
450 spin_unlock(&tiqn->tiqn_tpg_lock);
455 struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
456 struct iscsi_portal_group *tpg,
457 struct sockaddr_storage *sockaddr,
458 struct iscsi_tpg_np *tpg_np_parent,
459 int network_transport)
462 struct iscsi_tpg_np *tpg_np;
464 if (!tpg_np_parent) {
465 if (iscsit_tpg_check_network_portal(tpg->tpg_tiqn, sockaddr,
466 network_transport)) {
467 pr_err("Network Portal: %pISc already exists on a"
468 " different TPG on %s\n", sockaddr,
469 tpg->tpg_tiqn->tiqn);
470 return ERR_PTR(-EEXIST);
474 tpg_np = kzalloc(sizeof(struct iscsi_tpg_np), GFP_KERNEL);
476 pr_err("Unable to allocate memory for"
477 " struct iscsi_tpg_np.\n");
478 return ERR_PTR(-ENOMEM);
481 np = iscsit_add_np(sockaddr, network_transport);
487 INIT_LIST_HEAD(&tpg_np->tpg_np_list);
488 INIT_LIST_HEAD(&tpg_np->tpg_np_child_list);
489 INIT_LIST_HEAD(&tpg_np->tpg_np_parent_list);
490 spin_lock_init(&tpg_np->tpg_np_parent_lock);
491 init_completion(&tpg_np->tpg_np_comp);
492 kref_init(&tpg_np->tpg_np_kref);
496 spin_lock(&tpg->tpg_np_lock);
497 list_add_tail(&tpg_np->tpg_np_list, &tpg->tpg_gnp_list);
500 tpg->tpg_tiqn->tiqn_num_tpg_nps++;
501 spin_unlock(&tpg->tpg_np_lock);
504 tpg_np->tpg_np_parent = tpg_np_parent;
505 spin_lock(&tpg_np_parent->tpg_np_parent_lock);
506 list_add_tail(&tpg_np->tpg_np_child_list,
507 &tpg_np_parent->tpg_np_parent_list);
508 spin_unlock(&tpg_np_parent->tpg_np_parent_lock);
511 pr_debug("CORE[%s] - Added Network Portal: %pISpc,%hu on %s\n",
512 tpg->tpg_tiqn->tiqn, &np->np_sockaddr, tpg->tpgt,
513 np->np_transport->name);
518 static int iscsit_tpg_release_np(
519 struct iscsi_tpg_np *tpg_np,
520 struct iscsi_portal_group *tpg,
523 iscsit_clear_tpg_np_login_thread(tpg_np, tpg, true);
525 pr_debug("CORE[%s] - Removed Network Portal: %pISpc,%hu on %s\n",
526 tpg->tpg_tiqn->tiqn, &np->np_sockaddr, tpg->tpgt,
527 np->np_transport->name);
529 tpg_np->tpg_np = NULL;
533 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
535 return iscsit_del_np(np);
538 int iscsit_tpg_del_network_portal(
539 struct iscsi_portal_group *tpg,
540 struct iscsi_tpg_np *tpg_np)
543 struct iscsi_tpg_np *tpg_np_child, *tpg_np_child_tmp;
548 pr_err("Unable to locate struct iscsi_np from"
549 " struct iscsi_tpg_np\n");
553 if (!tpg_np->tpg_np_parent) {
555 * We are the parent tpg network portal. Release all of the
556 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
559 list_for_each_entry_safe(tpg_np_child, tpg_np_child_tmp,
560 &tpg_np->tpg_np_parent_list,
562 ret = iscsit_tpg_del_network_portal(tpg, tpg_np_child);
564 pr_err("iscsit_tpg_del_network_portal()"
565 " failed: %d\n", ret);
569 * We are not the parent ISCSI_TCP tpg network portal. Release
570 * our own network portals from the child list.
572 spin_lock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
573 list_del(&tpg_np->tpg_np_child_list);
574 spin_unlock(&tpg_np->tpg_np_parent->tpg_np_parent_lock);
577 spin_lock(&tpg->tpg_np_lock);
578 list_del(&tpg_np->tpg_np_list);
581 tpg->tpg_tiqn->tiqn_num_tpg_nps--;
582 spin_unlock(&tpg->tpg_np_lock);
584 return iscsit_tpg_release_np(tpg_np, tpg, np);
587 int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
589 unsigned char buf1[256], buf2[256], *none = NULL;
591 struct iscsi_param *param;
592 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
594 if ((authentication != 1) && (authentication != 0)) {
595 pr_err("Illegal value for authentication parameter:"
596 " %u, ignoring request.\n", authentication);
600 memset(buf1, 0, sizeof(buf1));
601 memset(buf2, 0, sizeof(buf2));
603 param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
607 if (authentication) {
608 snprintf(buf1, sizeof(buf1), "%s", param->value);
609 none = strstr(buf1, NONE);
612 if (!strncmp(none + 4, ",", 1)) {
613 if (!strcmp(buf1, none))
614 sprintf(buf2, "%s", none+5);
618 len = sprintf(buf2, "%s", buf1);
620 sprintf(buf2 + len, "%s", none);
625 sprintf(buf2, "%s", buf1);
627 if (iscsi_update_param_value(param, buf2) < 0)
630 snprintf(buf1, sizeof(buf1), "%s", param->value);
631 none = strstr(buf1, NONE);
634 strlcat(buf1, "," NONE, sizeof(buf1));
635 if (iscsi_update_param_value(param, buf1) < 0)
640 a->authentication = authentication;
641 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
642 a->authentication ? "Enforcing" : "Disabling", tpg->tpgt);
647 int iscsit_ta_login_timeout(
648 struct iscsi_portal_group *tpg,
651 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
653 if (login_timeout > TA_LOGIN_TIMEOUT_MAX) {
654 pr_err("Requested Login Timeout %u larger than maximum"
655 " %u\n", login_timeout, TA_LOGIN_TIMEOUT_MAX);
657 } else if (login_timeout < TA_LOGIN_TIMEOUT_MIN) {
658 pr_err("Requested Logout Timeout %u smaller than"
659 " minimum %u\n", login_timeout, TA_LOGIN_TIMEOUT_MIN);
663 a->login_timeout = login_timeout;
664 pr_debug("Set Logout Timeout to %u for Target Portal Group"
665 " %hu\n", a->login_timeout, tpg->tpgt);
670 int iscsit_ta_netif_timeout(
671 struct iscsi_portal_group *tpg,
674 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
676 if (netif_timeout > TA_NETIF_TIMEOUT_MAX) {
677 pr_err("Requested Network Interface Timeout %u larger"
678 " than maximum %u\n", netif_timeout,
679 TA_NETIF_TIMEOUT_MAX);
681 } else if (netif_timeout < TA_NETIF_TIMEOUT_MIN) {
682 pr_err("Requested Network Interface Timeout %u smaller"
683 " than minimum %u\n", netif_timeout,
684 TA_NETIF_TIMEOUT_MIN);
688 a->netif_timeout = netif_timeout;
689 pr_debug("Set Network Interface Timeout to %u for"
690 " Target Portal Group %hu\n", a->netif_timeout, tpg->tpgt);
695 int iscsit_ta_generate_node_acls(
696 struct iscsi_portal_group *tpg,
699 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
701 if ((flag != 0) && (flag != 1)) {
702 pr_err("Illegal value %d\n", flag);
706 a->generate_node_acls = flag;
707 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
708 tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled");
710 if (flag == 1 && a->cache_dynamic_acls == 0) {
711 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
712 "generate_node_acls=1\n");
713 a->cache_dynamic_acls = 1;
719 int iscsit_ta_default_cmdsn_depth(
720 struct iscsi_portal_group *tpg,
723 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
725 if (tcq_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
726 pr_err("Requested Default Queue Depth: %u larger"
727 " than maximum %u\n", tcq_depth,
728 TA_DEFAULT_CMDSN_DEPTH_MAX);
730 } else if (tcq_depth < TA_DEFAULT_CMDSN_DEPTH_MIN) {
731 pr_err("Requested Default Queue Depth: %u smaller"
732 " than minimum %u\n", tcq_depth,
733 TA_DEFAULT_CMDSN_DEPTH_MIN);
737 a->default_cmdsn_depth = tcq_depth;
738 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
739 tpg->tpgt, a->default_cmdsn_depth);
744 int iscsit_ta_cache_dynamic_acls(
745 struct iscsi_portal_group *tpg,
748 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
750 if ((flag != 0) && (flag != 1)) {
751 pr_err("Illegal value %d\n", flag);
755 if (a->generate_node_acls == 1 && flag == 0) {
756 pr_debug("Skipping cache_dynamic_acls=0 when"
757 " generate_node_acls=1\n");
761 a->cache_dynamic_acls = flag;
762 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
763 " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ?
764 "Enabled" : "Disabled");
769 int iscsit_ta_demo_mode_write_protect(
770 struct iscsi_portal_group *tpg,
773 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
775 if ((flag != 0) && (flag != 1)) {
776 pr_err("Illegal value %d\n", flag);
780 a->demo_mode_write_protect = flag;
781 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
782 tpg->tpgt, (a->demo_mode_write_protect) ? "ON" : "OFF");
787 int iscsit_ta_prod_mode_write_protect(
788 struct iscsi_portal_group *tpg,
791 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
793 if ((flag != 0) && (flag != 1)) {
794 pr_err("Illegal value %d\n", flag);
798 a->prod_mode_write_protect = flag;
799 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
800 " %s\n", tpg->tpgt, (a->prod_mode_write_protect) ?
806 int iscsit_ta_demo_mode_discovery(
807 struct iscsi_portal_group *tpg,
810 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
812 if ((flag != 0) && (flag != 1)) {
813 pr_err("Illegal value %d\n", flag);
817 a->demo_mode_discovery = flag;
818 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
819 " %s\n", tpg->tpgt, (a->demo_mode_discovery) ?
825 int iscsit_ta_default_erl(
826 struct iscsi_portal_group *tpg,
829 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
831 if ((default_erl != 0) && (default_erl != 1) && (default_erl != 2)) {
832 pr_err("Illegal value for default_erl: %u\n", default_erl);
836 a->default_erl = default_erl;
837 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg->tpgt, a->default_erl);
842 int iscsit_ta_t10_pi(
843 struct iscsi_portal_group *tpg,
846 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
848 if ((flag != 0) && (flag != 1)) {
849 pr_err("Illegal value %d\n", flag);
854 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
855 " %s\n", tpg->tpgt, (a->t10_pi) ?
861 int iscsit_ta_fabric_prot_type(
862 struct iscsi_portal_group *tpg,
865 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
867 if ((prot_type != 0) && (prot_type != 1) && (prot_type != 3)) {
868 pr_err("Illegal value for fabric_prot_type: %u\n", prot_type);
872 a->fabric_prot_type = prot_type;
873 pr_debug("iSCSI_TPG[%hu] - T10 Fabric Protection Type: %u\n",
874 tpg->tpgt, prot_type);
879 int iscsit_ta_tpg_enabled_sendtargets(
880 struct iscsi_portal_group *tpg,
883 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
885 if ((flag != 0) && (flag != 1)) {
886 pr_err("Illegal value %d\n", flag);
890 a->tpg_enabled_sendtargets = flag;
891 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit required for SendTargets:"
892 " %s\n", tpg->tpgt, (a->tpg_enabled_sendtargets) ? "ON" : "OFF");
897 int iscsit_ta_login_keys_workaround(
898 struct iscsi_portal_group *tpg,
901 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
903 if ((flag != 0) && (flag != 1)) {
904 pr_err("Illegal value %d\n", flag);
908 a->login_keys_workaround = flag;
909 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
910 tpg->tpgt, (a->login_keys_workaround) ? "ON" : "OFF");