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
);
447 spin_unlock(&tiqn
->tiqn_tpg_lock
);
452 struct iscsi_tpg_np
*iscsit_tpg_add_network_portal(
453 struct iscsi_portal_group
*tpg
,
454 struct sockaddr_storage
*sockaddr
,
455 struct iscsi_tpg_np
*tpg_np_parent
,
456 int network_transport
)
459 struct iscsi_tpg_np
*tpg_np
;
461 if (!tpg_np_parent
) {
462 if (iscsit_tpg_check_network_portal(tpg
->tpg_tiqn
, sockaddr
,
463 network_transport
)) {
464 pr_err("Network Portal: %pISc already exists on a"
465 " different TPG on %s\n", sockaddr
,
466 tpg
->tpg_tiqn
->tiqn
);
467 return ERR_PTR(-EEXIST
);
471 tpg_np
= kzalloc(sizeof(struct iscsi_tpg_np
), GFP_KERNEL
);
473 pr_err("Unable to allocate memory for"
474 " struct iscsi_tpg_np.\n");
475 return ERR_PTR(-ENOMEM
);
478 np
= iscsit_add_np(sockaddr
, network_transport
);
484 INIT_LIST_HEAD(&tpg_np
->tpg_np_list
);
485 INIT_LIST_HEAD(&tpg_np
->tpg_np_child_list
);
486 INIT_LIST_HEAD(&tpg_np
->tpg_np_parent_list
);
487 spin_lock_init(&tpg_np
->tpg_np_parent_lock
);
488 init_completion(&tpg_np
->tpg_np_comp
);
489 kref_init(&tpg_np
->tpg_np_kref
);
493 spin_lock(&tpg
->tpg_np_lock
);
494 list_add_tail(&tpg_np
->tpg_np_list
, &tpg
->tpg_gnp_list
);
497 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
++;
498 spin_unlock(&tpg
->tpg_np_lock
);
501 tpg_np
->tpg_np_parent
= tpg_np_parent
;
502 spin_lock(&tpg_np_parent
->tpg_np_parent_lock
);
503 list_add_tail(&tpg_np
->tpg_np_child_list
,
504 &tpg_np_parent
->tpg_np_parent_list
);
505 spin_unlock(&tpg_np_parent
->tpg_np_parent_lock
);
508 pr_debug("CORE[%s] - Added Network Portal: %pISpc,%hu on %s\n",
509 tpg
->tpg_tiqn
->tiqn
, &np
->np_sockaddr
, tpg
->tpgt
,
510 np
->np_transport
->name
);
515 static int iscsit_tpg_release_np(
516 struct iscsi_tpg_np
*tpg_np
,
517 struct iscsi_portal_group
*tpg
,
520 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, true);
522 pr_debug("CORE[%s] - Removed Network Portal: %pISpc,%hu on %s\n",
523 tpg
->tpg_tiqn
->tiqn
, &np
->np_sockaddr
, tpg
->tpgt
,
524 np
->np_transport
->name
);
526 tpg_np
->tpg_np
= NULL
;
530 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
532 return iscsit_del_np(np
);
535 int iscsit_tpg_del_network_portal(
536 struct iscsi_portal_group
*tpg
,
537 struct iscsi_tpg_np
*tpg_np
)
540 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
545 pr_err("Unable to locate struct iscsi_np from"
546 " struct iscsi_tpg_np\n");
550 if (!tpg_np
->tpg_np_parent
) {
552 * We are the parent tpg network portal. Release all of the
553 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
556 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
557 &tpg_np
->tpg_np_parent_list
,
559 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np_child
);
561 pr_err("iscsit_tpg_del_network_portal()"
562 " failed: %d\n", ret
);
566 * We are not the parent ISCSI_TCP tpg network portal. Release
567 * our own network portals from the child list.
569 spin_lock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
570 list_del(&tpg_np
->tpg_np_child_list
);
571 spin_unlock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
574 spin_lock(&tpg
->tpg_np_lock
);
575 list_del(&tpg_np
->tpg_np_list
);
578 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
--;
579 spin_unlock(&tpg
->tpg_np_lock
);
581 return iscsit_tpg_release_np(tpg_np
, tpg
, np
);
584 int iscsit_ta_authentication(struct iscsi_portal_group
*tpg
, u32 authentication
)
586 unsigned char buf1
[256], buf2
[256], *none
= NULL
;
588 struct iscsi_param
*param
;
589 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
591 if ((authentication
!= 1) && (authentication
!= 0)) {
592 pr_err("Illegal value for authentication parameter:"
593 " %u, ignoring request.\n", authentication
);
597 memset(buf1
, 0, sizeof(buf1
));
598 memset(buf2
, 0, sizeof(buf2
));
600 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
604 if (authentication
) {
605 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
606 none
= strstr(buf1
, NONE
);
609 if (!strncmp(none
+ 4, ",", 1)) {
610 if (!strcmp(buf1
, none
))
611 sprintf(buf2
, "%s", none
+5);
615 len
= sprintf(buf2
, "%s", buf1
);
617 sprintf(buf2
+ len
, "%s", none
);
622 sprintf(buf2
, "%s", buf1
);
624 if (iscsi_update_param_value(param
, buf2
) < 0)
627 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
628 none
= strstr(buf1
, NONE
);
631 strlcat(buf1
, "," NONE
, sizeof(buf1
));
632 if (iscsi_update_param_value(param
, buf1
) < 0)
637 a
->authentication
= authentication
;
638 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
639 a
->authentication
? "Enforcing" : "Disabling", tpg
->tpgt
);
644 int iscsit_ta_login_timeout(
645 struct iscsi_portal_group
*tpg
,
648 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
650 if (login_timeout
> TA_LOGIN_TIMEOUT_MAX
) {
651 pr_err("Requested Login Timeout %u larger than maximum"
652 " %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MAX
);
654 } else if (login_timeout
< TA_LOGIN_TIMEOUT_MIN
) {
655 pr_err("Requested Logout Timeout %u smaller than"
656 " minimum %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MIN
);
660 a
->login_timeout
= login_timeout
;
661 pr_debug("Set Logout Timeout to %u for Target Portal Group"
662 " %hu\n", a
->login_timeout
, tpg
->tpgt
);
667 int iscsit_ta_netif_timeout(
668 struct iscsi_portal_group
*tpg
,
671 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
673 if (netif_timeout
> TA_NETIF_TIMEOUT_MAX
) {
674 pr_err("Requested Network Interface Timeout %u larger"
675 " than maximum %u\n", netif_timeout
,
676 TA_NETIF_TIMEOUT_MAX
);
678 } else if (netif_timeout
< TA_NETIF_TIMEOUT_MIN
) {
679 pr_err("Requested Network Interface Timeout %u smaller"
680 " than minimum %u\n", netif_timeout
,
681 TA_NETIF_TIMEOUT_MIN
);
685 a
->netif_timeout
= netif_timeout
;
686 pr_debug("Set Network Interface Timeout to %u for"
687 " Target Portal Group %hu\n", a
->netif_timeout
, tpg
->tpgt
);
692 int iscsit_ta_generate_node_acls(
693 struct iscsi_portal_group
*tpg
,
696 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
698 if ((flag
!= 0) && (flag
!= 1)) {
699 pr_err("Illegal value %d\n", flag
);
703 a
->generate_node_acls
= flag
;
704 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
705 tpg
->tpgt
, (a
->generate_node_acls
) ? "Enabled" : "Disabled");
707 if (flag
== 1 && a
->cache_dynamic_acls
== 0) {
708 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
709 "generate_node_acls=1\n");
710 a
->cache_dynamic_acls
= 1;
716 int iscsit_ta_default_cmdsn_depth(
717 struct iscsi_portal_group
*tpg
,
720 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
722 if (tcq_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
723 pr_err("Requested Default Queue Depth: %u larger"
724 " than maximum %u\n", tcq_depth
,
725 TA_DEFAULT_CMDSN_DEPTH_MAX
);
727 } else if (tcq_depth
< TA_DEFAULT_CMDSN_DEPTH_MIN
) {
728 pr_err("Requested Default Queue Depth: %u smaller"
729 " than minimum %u\n", tcq_depth
,
730 TA_DEFAULT_CMDSN_DEPTH_MIN
);
734 a
->default_cmdsn_depth
= tcq_depth
;
735 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
736 tpg
->tpgt
, a
->default_cmdsn_depth
);
741 int iscsit_ta_cache_dynamic_acls(
742 struct iscsi_portal_group
*tpg
,
745 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
747 if ((flag
!= 0) && (flag
!= 1)) {
748 pr_err("Illegal value %d\n", flag
);
752 if (a
->generate_node_acls
== 1 && flag
== 0) {
753 pr_debug("Skipping cache_dynamic_acls=0 when"
754 " generate_node_acls=1\n");
758 a
->cache_dynamic_acls
= flag
;
759 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
760 " ACLs %s\n", tpg
->tpgt
, (a
->cache_dynamic_acls
) ?
761 "Enabled" : "Disabled");
766 int iscsit_ta_demo_mode_write_protect(
767 struct iscsi_portal_group
*tpg
,
770 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
772 if ((flag
!= 0) && (flag
!= 1)) {
773 pr_err("Illegal value %d\n", flag
);
777 a
->demo_mode_write_protect
= flag
;
778 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
779 tpg
->tpgt
, (a
->demo_mode_write_protect
) ? "ON" : "OFF");
784 int iscsit_ta_prod_mode_write_protect(
785 struct iscsi_portal_group
*tpg
,
788 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
790 if ((flag
!= 0) && (flag
!= 1)) {
791 pr_err("Illegal value %d\n", flag
);
795 a
->prod_mode_write_protect
= flag
;
796 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
797 " %s\n", tpg
->tpgt
, (a
->prod_mode_write_protect
) ?
803 int iscsit_ta_demo_mode_discovery(
804 struct iscsi_portal_group
*tpg
,
807 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
809 if ((flag
!= 0) && (flag
!= 1)) {
810 pr_err("Illegal value %d\n", flag
);
814 a
->demo_mode_discovery
= flag
;
815 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
816 " %s\n", tpg
->tpgt
, (a
->demo_mode_discovery
) ?
822 int iscsit_ta_default_erl(
823 struct iscsi_portal_group
*tpg
,
826 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
828 if ((default_erl
!= 0) && (default_erl
!= 1) && (default_erl
!= 2)) {
829 pr_err("Illegal value for default_erl: %u\n", default_erl
);
833 a
->default_erl
= default_erl
;
834 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg
->tpgt
, a
->default_erl
);
839 int iscsit_ta_t10_pi(
840 struct iscsi_portal_group
*tpg
,
843 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
845 if ((flag
!= 0) && (flag
!= 1)) {
846 pr_err("Illegal value %d\n", flag
);
851 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
852 " %s\n", tpg
->tpgt
, (a
->t10_pi
) ?
858 int iscsit_ta_fabric_prot_type(
859 struct iscsi_portal_group
*tpg
,
862 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
864 if ((prot_type
!= 0) && (prot_type
!= 1) && (prot_type
!= 3)) {
865 pr_err("Illegal value for fabric_prot_type: %u\n", prot_type
);
869 a
->fabric_prot_type
= prot_type
;
870 pr_debug("iSCSI_TPG[%hu] - T10 Fabric Protection Type: %u\n",
871 tpg
->tpgt
, prot_type
);
876 int iscsit_ta_tpg_enabled_sendtargets(
877 struct iscsi_portal_group
*tpg
,
880 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
882 if ((flag
!= 0) && (flag
!= 1)) {
883 pr_err("Illegal value %d\n", flag
);
887 a
->tpg_enabled_sendtargets
= flag
;
888 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit required for SendTargets:"
889 " %s\n", tpg
->tpgt
, (a
->tpg_enabled_sendtargets
) ? "ON" : "OFF");
894 int iscsit_ta_login_keys_workaround(
895 struct iscsi_portal_group
*tpg
,
898 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
900 if ((flag
!= 0) && (flag
!= 1)) {
901 pr_err("Illegal value %d\n", flag
);
905 a
->login_keys_workaround
= flag
;
906 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
907 tpg
->tpgt
, (a
->login_keys_workaround
) ? "ON" : "OFF");