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 <linux/slab.h>
20 #include <target/target_core_base.h>
21 #include <target/target_core_fabric.h>
22 #include <target/iscsi/iscsi_target_core.h>
23 #include "iscsi_target_erl0.h"
24 #include "iscsi_target_login.h"
25 #include "iscsi_target_nodeattrib.h"
26 #include "iscsi_target_tpg.h"
27 #include "iscsi_target_util.h"
28 #include "iscsi_target.h"
29 #include "iscsi_target_parameters.h"
31 #include <target/iscsi/iscsi_transport.h>
33 struct iscsi_portal_group
*iscsit_alloc_portal_group(struct iscsi_tiqn
*tiqn
, u16 tpgt
)
35 struct iscsi_portal_group
*tpg
;
37 tpg
= kzalloc(sizeof(struct iscsi_portal_group
), GFP_KERNEL
);
39 pr_err("Unable to allocate struct iscsi_portal_group\n");
44 tpg
->tpg_state
= TPG_STATE_FREE
;
46 INIT_LIST_HEAD(&tpg
->tpg_gnp_list
);
47 INIT_LIST_HEAD(&tpg
->tpg_list
);
48 mutex_init(&tpg
->tpg_access_lock
);
49 sema_init(&tpg
->np_login_sem
, 1);
50 spin_lock_init(&tpg
->tpg_state_lock
);
51 spin_lock_init(&tpg
->tpg_np_lock
);
56 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*);
58 int iscsit_load_discovery_tpg(void)
60 struct iscsi_param
*param
;
61 struct iscsi_portal_group
*tpg
;
64 tpg
= iscsit_alloc_portal_group(NULL
, 1);
66 pr_err("Unable to allocate struct iscsi_portal_group\n");
70 * Save iscsi_ops pointer for special case discovery TPG that
71 * doesn't exist as se_wwn->wwn_group within configfs.
73 tpg
->tpg_se_tpg
.se_tpg_tfo
= &iscsi_ops
;
74 ret
= core_tpg_register(NULL
, &tpg
->tpg_se_tpg
, -1);
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
)
166 return mutex_lock_interruptible(&tpg
->tpg_access_lock
);
169 void iscsit_put_tpg(struct iscsi_portal_group
*tpg
)
171 mutex_unlock(&tpg
->tpg_access_lock
);
174 static void iscsit_clear_tpg_np_login_thread(
175 struct iscsi_tpg_np
*tpg_np
,
176 struct iscsi_portal_group
*tpg
,
179 if (!tpg_np
->tpg_np
) {
180 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
185 tpg_np
->tpg_np
->enabled
= false;
186 iscsit_reset_np_thread(tpg_np
->tpg_np
, tpg_np
, tpg
, shutdown
);
189 static void iscsit_clear_tpg_np_login_threads(
190 struct iscsi_portal_group
*tpg
,
193 struct iscsi_tpg_np
*tpg_np
;
195 spin_lock(&tpg
->tpg_np_lock
);
196 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
197 if (!tpg_np
->tpg_np
) {
198 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
201 spin_unlock(&tpg
->tpg_np_lock
);
202 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, shutdown
);
203 spin_lock(&tpg
->tpg_np_lock
);
205 spin_unlock(&tpg
->tpg_np_lock
);
208 void iscsit_tpg_dump_params(struct iscsi_portal_group
*tpg
)
210 iscsi_print_params(tpg
->param_list
);
213 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*tpg
)
215 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
217 a
->authentication
= TA_AUTHENTICATION
;
218 a
->login_timeout
= TA_LOGIN_TIMEOUT
;
219 a
->netif_timeout
= TA_NETIF_TIMEOUT
;
220 a
->default_cmdsn_depth
= TA_DEFAULT_CMDSN_DEPTH
;
221 a
->generate_node_acls
= TA_GENERATE_NODE_ACLS
;
222 a
->cache_dynamic_acls
= TA_CACHE_DYNAMIC_ACLS
;
223 a
->demo_mode_write_protect
= TA_DEMO_MODE_WRITE_PROTECT
;
224 a
->prod_mode_write_protect
= TA_PROD_MODE_WRITE_PROTECT
;
225 a
->demo_mode_discovery
= TA_DEMO_MODE_DISCOVERY
;
226 a
->default_erl
= TA_DEFAULT_ERL
;
227 a
->t10_pi
= TA_DEFAULT_T10_PI
;
228 a
->fabric_prot_type
= TA_DEFAULT_FABRIC_PROT_TYPE
;
229 a
->tpg_enabled_sendtargets
= TA_DEFAULT_TPG_ENABLED_SENDTARGETS
;
230 a
->login_keys_workaround
= TA_DEFAULT_LOGIN_KEYS_WORKAROUND
;
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
;
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 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
279 pr_err("Unable to delete iSCSI Target Portal Group:"
280 " %hu while active sessions exist, and force=0\n",
282 tpg
->tpg_state
= old_state
;
286 if (tpg
->param_list
) {
287 iscsi_release_param_list(tpg
->param_list
);
288 tpg
->param_list
= NULL
;
291 core_tpg_deregister(&tpg
->tpg_se_tpg
);
293 spin_lock(&tpg
->tpg_state_lock
);
294 tpg
->tpg_state
= TPG_STATE_FREE
;
295 spin_unlock(&tpg
->tpg_state_lock
);
297 spin_lock(&tiqn
->tiqn_tpg_lock
);
299 list_del(&tpg
->tpg_list
);
300 spin_unlock(&tiqn
->tiqn_tpg_lock
);
302 pr_debug("CORE[%s]_TPG[%hu] - Deleted iSCSI Target Portal Group\n",
303 tiqn
->tiqn
, tpg
->tpgt
);
309 int iscsit_tpg_enable_portal_group(struct iscsi_portal_group
*tpg
)
311 struct iscsi_param
*param
;
312 struct iscsi_tiqn
*tiqn
= tpg
->tpg_tiqn
;
315 if (tpg
->tpg_state
== TPG_STATE_ACTIVE
) {
316 pr_err("iSCSI target portal group: %hu is already"
317 " active, ignoring request.\n", tpg
->tpgt
);
321 * Make sure that AuthMethod does not contain None as an option
322 * unless explictly disabled. Set the default to CHAP if authentication
323 * is enforced (as per default), and remove the NONE option.
325 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
329 if (tpg
->tpg_attrib
.authentication
) {
330 if (!strcmp(param
->value
, NONE
)) {
331 ret
= iscsi_update_param_value(param
, CHAP
);
336 ret
= iscsit_ta_authentication(tpg
, 1);
341 spin_lock(&tpg
->tpg_state_lock
);
342 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
343 spin_unlock(&tpg
->tpg_state_lock
);
345 spin_lock(&tiqn
->tiqn_tpg_lock
);
346 tiqn
->tiqn_active_tpgs
++;
347 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
349 spin_unlock(&tiqn
->tiqn_tpg_lock
);
357 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group
*tpg
, int force
)
359 struct iscsi_tiqn
*tiqn
;
360 u8 old_state
= tpg
->tpg_state
;
362 spin_lock(&tpg
->tpg_state_lock
);
363 if (tpg
->tpg_state
== TPG_STATE_INACTIVE
) {
364 pr_err("iSCSI Target Portal Group: %hu is already"
365 " inactive, ignoring request.\n", tpg
->tpgt
);
366 spin_unlock(&tpg
->tpg_state_lock
);
369 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
370 spin_unlock(&tpg
->tpg_state_lock
);
372 iscsit_clear_tpg_np_login_threads(tpg
, false);
374 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
375 spin_lock(&tpg
->tpg_state_lock
);
376 tpg
->tpg_state
= old_state
;
377 spin_unlock(&tpg
->tpg_state_lock
);
378 pr_err("Unable to disable iSCSI Target Portal Group:"
379 " %hu while active sessions exist, and force=0\n",
384 tiqn
= tpg
->tpg_tiqn
;
385 if (!tiqn
|| (tpg
== iscsit_global
->discovery_tpg
))
388 spin_lock(&tiqn
->tiqn_tpg_lock
);
389 tiqn
->tiqn_active_tpgs
--;
390 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
392 spin_unlock(&tiqn
->tiqn_tpg_lock
);
397 struct iscsi_node_attrib
*iscsit_tpg_get_node_attrib(
398 struct iscsi_session
*sess
)
400 struct se_session
*se_sess
= sess
->se_sess
;
401 struct se_node_acl
*se_nacl
= se_sess
->se_node_acl
;
402 struct iscsi_node_acl
*acl
= container_of(se_nacl
, struct iscsi_node_acl
,
405 return &acl
->node_attrib
;
408 struct iscsi_tpg_np
*iscsit_tpg_locate_child_np(
409 struct iscsi_tpg_np
*tpg_np
,
410 int network_transport
)
412 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
414 spin_lock(&tpg_np
->tpg_np_parent_lock
);
415 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
416 &tpg_np
->tpg_np_parent_list
, tpg_np_child_list
) {
417 if (tpg_np_child
->tpg_np
->np_network_transport
==
419 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
423 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
428 static bool iscsit_tpg_check_network_portal(
429 struct iscsi_tiqn
*tiqn
,
430 struct sockaddr_storage
*sockaddr
,
431 int network_transport
)
433 struct iscsi_portal_group
*tpg
;
434 struct iscsi_tpg_np
*tpg_np
;
438 spin_lock(&tiqn
->tiqn_tpg_lock
);
439 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
441 spin_lock(&tpg
->tpg_np_lock
);
442 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
445 match
= iscsit_check_np_match(sockaddr
, np
,
450 spin_unlock(&tpg
->tpg_np_lock
);
452 spin_unlock(&tiqn
->tiqn_tpg_lock
);
457 struct iscsi_tpg_np
*iscsit_tpg_add_network_portal(
458 struct iscsi_portal_group
*tpg
,
459 struct sockaddr_storage
*sockaddr
,
460 struct iscsi_tpg_np
*tpg_np_parent
,
461 int network_transport
)
464 struct iscsi_tpg_np
*tpg_np
;
466 if (!tpg_np_parent
) {
467 if (iscsit_tpg_check_network_portal(tpg
->tpg_tiqn
, sockaddr
,
468 network_transport
)) {
469 pr_err("Network Portal: %pISc already exists on a"
470 " different TPG on %s\n", sockaddr
,
471 tpg
->tpg_tiqn
->tiqn
);
472 return ERR_PTR(-EEXIST
);
476 tpg_np
= kzalloc(sizeof(struct iscsi_tpg_np
), GFP_KERNEL
);
478 pr_err("Unable to allocate memory for"
479 " struct iscsi_tpg_np.\n");
480 return ERR_PTR(-ENOMEM
);
483 np
= iscsit_add_np(sockaddr
, network_transport
);
489 INIT_LIST_HEAD(&tpg_np
->tpg_np_list
);
490 INIT_LIST_HEAD(&tpg_np
->tpg_np_child_list
);
491 INIT_LIST_HEAD(&tpg_np
->tpg_np_parent_list
);
492 spin_lock_init(&tpg_np
->tpg_np_parent_lock
);
493 init_completion(&tpg_np
->tpg_np_comp
);
494 kref_init(&tpg_np
->tpg_np_kref
);
498 spin_lock(&tpg
->tpg_np_lock
);
499 list_add_tail(&tpg_np
->tpg_np_list
, &tpg
->tpg_gnp_list
);
502 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
++;
503 spin_unlock(&tpg
->tpg_np_lock
);
506 tpg_np
->tpg_np_parent
= tpg_np_parent
;
507 spin_lock(&tpg_np_parent
->tpg_np_parent_lock
);
508 list_add_tail(&tpg_np
->tpg_np_child_list
,
509 &tpg_np_parent
->tpg_np_parent_list
);
510 spin_unlock(&tpg_np_parent
->tpg_np_parent_lock
);
513 pr_debug("CORE[%s] - Added Network Portal: %pISpc,%hu on %s\n",
514 tpg
->tpg_tiqn
->tiqn
, &np
->np_sockaddr
, tpg
->tpgt
,
515 np
->np_transport
->name
);
520 static int iscsit_tpg_release_np(
521 struct iscsi_tpg_np
*tpg_np
,
522 struct iscsi_portal_group
*tpg
,
525 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, true);
527 pr_debug("CORE[%s] - Removed Network Portal: %pISpc,%hu on %s\n",
528 tpg
->tpg_tiqn
->tiqn
, &np
->np_sockaddr
, tpg
->tpgt
,
529 np
->np_transport
->name
);
531 tpg_np
->tpg_np
= NULL
;
535 * iscsit_del_np() will shutdown struct iscsi_np when last TPG reference is released.
537 return iscsit_del_np(np
);
540 int iscsit_tpg_del_network_portal(
541 struct iscsi_portal_group
*tpg
,
542 struct iscsi_tpg_np
*tpg_np
)
545 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
550 pr_err("Unable to locate struct iscsi_np from"
551 " struct iscsi_tpg_np\n");
555 if (!tpg_np
->tpg_np_parent
) {
557 * We are the parent tpg network portal. Release all of the
558 * child tpg_np's (eg: the non ISCSI_TCP ones) on our parent
561 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
562 &tpg_np
->tpg_np_parent_list
,
564 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np_child
);
566 pr_err("iscsit_tpg_del_network_portal()"
567 " failed: %d\n", ret
);
571 * We are not the parent ISCSI_TCP tpg network portal. Release
572 * our own network portals from the child list.
574 spin_lock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
575 list_del(&tpg_np
->tpg_np_child_list
);
576 spin_unlock(&tpg_np
->tpg_np_parent
->tpg_np_parent_lock
);
579 spin_lock(&tpg
->tpg_np_lock
);
580 list_del(&tpg_np
->tpg_np_list
);
583 tpg
->tpg_tiqn
->tiqn_num_tpg_nps
--;
584 spin_unlock(&tpg
->tpg_np_lock
);
586 return iscsit_tpg_release_np(tpg_np
, tpg
, np
);
589 int iscsit_ta_authentication(struct iscsi_portal_group
*tpg
, u32 authentication
)
591 unsigned char buf1
[256], buf2
[256], *none
= NULL
;
593 struct iscsi_param
*param
;
594 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
596 if ((authentication
!= 1) && (authentication
!= 0)) {
597 pr_err("Illegal value for authentication parameter:"
598 " %u, ignoring request.\n", authentication
);
602 memset(buf1
, 0, sizeof(buf1
));
603 memset(buf2
, 0, sizeof(buf2
));
605 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
609 if (authentication
) {
610 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
611 none
= strstr(buf1
, NONE
);
614 if (!strncmp(none
+ 4, ",", 1)) {
615 if (!strcmp(buf1
, none
))
616 sprintf(buf2
, "%s", none
+5);
620 len
= sprintf(buf2
, "%s", buf1
);
622 sprintf(buf2
+ len
, "%s", none
);
627 sprintf(buf2
, "%s", buf1
);
629 if (iscsi_update_param_value(param
, buf2
) < 0)
632 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
633 none
= strstr(buf1
, NONE
);
636 strncat(buf1
, ",", strlen(","));
637 strncat(buf1
, NONE
, strlen(NONE
));
638 if (iscsi_update_param_value(param
, buf1
) < 0)
643 a
->authentication
= authentication
;
644 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
645 a
->authentication
? "Enforcing" : "Disabling", tpg
->tpgt
);
650 int iscsit_ta_login_timeout(
651 struct iscsi_portal_group
*tpg
,
654 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
656 if (login_timeout
> TA_LOGIN_TIMEOUT_MAX
) {
657 pr_err("Requested Login Timeout %u larger than maximum"
658 " %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MAX
);
660 } else if (login_timeout
< TA_LOGIN_TIMEOUT_MIN
) {
661 pr_err("Requested Logout Timeout %u smaller than"
662 " minimum %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MIN
);
666 a
->login_timeout
= login_timeout
;
667 pr_debug("Set Logout Timeout to %u for Target Portal Group"
668 " %hu\n", a
->login_timeout
, tpg
->tpgt
);
673 int iscsit_ta_netif_timeout(
674 struct iscsi_portal_group
*tpg
,
677 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
679 if (netif_timeout
> TA_NETIF_TIMEOUT_MAX
) {
680 pr_err("Requested Network Interface Timeout %u larger"
681 " than maximum %u\n", netif_timeout
,
682 TA_NETIF_TIMEOUT_MAX
);
684 } else if (netif_timeout
< TA_NETIF_TIMEOUT_MIN
) {
685 pr_err("Requested Network Interface Timeout %u smaller"
686 " than minimum %u\n", netif_timeout
,
687 TA_NETIF_TIMEOUT_MIN
);
691 a
->netif_timeout
= netif_timeout
;
692 pr_debug("Set Network Interface Timeout to %u for"
693 " Target Portal Group %hu\n", a
->netif_timeout
, tpg
->tpgt
);
698 int iscsit_ta_generate_node_acls(
699 struct iscsi_portal_group
*tpg
,
702 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
704 if ((flag
!= 0) && (flag
!= 1)) {
705 pr_err("Illegal value %d\n", flag
);
709 a
->generate_node_acls
= flag
;
710 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
711 tpg
->tpgt
, (a
->generate_node_acls
) ? "Enabled" : "Disabled");
713 if (flag
== 1 && a
->cache_dynamic_acls
== 0) {
714 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
715 "generate_node_acls=1\n");
716 a
->cache_dynamic_acls
= 1;
722 int iscsit_ta_default_cmdsn_depth(
723 struct iscsi_portal_group
*tpg
,
726 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
728 if (tcq_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
729 pr_err("Requested Default Queue Depth: %u larger"
730 " than maximum %u\n", tcq_depth
,
731 TA_DEFAULT_CMDSN_DEPTH_MAX
);
733 } else if (tcq_depth
< TA_DEFAULT_CMDSN_DEPTH_MIN
) {
734 pr_err("Requested Default Queue Depth: %u smaller"
735 " than minimum %u\n", tcq_depth
,
736 TA_DEFAULT_CMDSN_DEPTH_MIN
);
740 a
->default_cmdsn_depth
= tcq_depth
;
741 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
742 tpg
->tpgt
, a
->default_cmdsn_depth
);
747 int iscsit_ta_cache_dynamic_acls(
748 struct iscsi_portal_group
*tpg
,
751 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
753 if ((flag
!= 0) && (flag
!= 1)) {
754 pr_err("Illegal value %d\n", flag
);
758 if (a
->generate_node_acls
== 1 && flag
== 0) {
759 pr_debug("Skipping cache_dynamic_acls=0 when"
760 " generate_node_acls=1\n");
764 a
->cache_dynamic_acls
= flag
;
765 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
766 " ACLs %s\n", tpg
->tpgt
, (a
->cache_dynamic_acls
) ?
767 "Enabled" : "Disabled");
772 int iscsit_ta_demo_mode_write_protect(
773 struct iscsi_portal_group
*tpg
,
776 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
778 if ((flag
!= 0) && (flag
!= 1)) {
779 pr_err("Illegal value %d\n", flag
);
783 a
->demo_mode_write_protect
= flag
;
784 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
785 tpg
->tpgt
, (a
->demo_mode_write_protect
) ? "ON" : "OFF");
790 int iscsit_ta_prod_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
->prod_mode_write_protect
= flag
;
802 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
803 " %s\n", tpg
->tpgt
, (a
->prod_mode_write_protect
) ?
809 int iscsit_ta_demo_mode_discovery(
810 struct iscsi_portal_group
*tpg
,
813 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
815 if ((flag
!= 0) && (flag
!= 1)) {
816 pr_err("Illegal value %d\n", flag
);
820 a
->demo_mode_discovery
= flag
;
821 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
822 " %s\n", tpg
->tpgt
, (a
->demo_mode_discovery
) ?
828 int iscsit_ta_default_erl(
829 struct iscsi_portal_group
*tpg
,
832 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
834 if ((default_erl
!= 0) && (default_erl
!= 1) && (default_erl
!= 2)) {
835 pr_err("Illegal value for default_erl: %u\n", default_erl
);
839 a
->default_erl
= default_erl
;
840 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg
->tpgt
, a
->default_erl
);
845 int iscsit_ta_t10_pi(
846 struct iscsi_portal_group
*tpg
,
849 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
851 if ((flag
!= 0) && (flag
!= 1)) {
852 pr_err("Illegal value %d\n", flag
);
857 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
858 " %s\n", tpg
->tpgt
, (a
->t10_pi
) ?
864 int iscsit_ta_fabric_prot_type(
865 struct iscsi_portal_group
*tpg
,
868 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
870 if ((prot_type
!= 0) && (prot_type
!= 1) && (prot_type
!= 3)) {
871 pr_err("Illegal value for fabric_prot_type: %u\n", prot_type
);
875 a
->fabric_prot_type
= prot_type
;
876 pr_debug("iSCSI_TPG[%hu] - T10 Fabric Protection Type: %u\n",
877 tpg
->tpgt
, prot_type
);
882 int iscsit_ta_tpg_enabled_sendtargets(
883 struct iscsi_portal_group
*tpg
,
886 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
888 if ((flag
!= 0) && (flag
!= 1)) {
889 pr_err("Illegal value %d\n", flag
);
893 a
->tpg_enabled_sendtargets
= flag
;
894 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit required for SendTargets:"
895 " %s\n", tpg
->tpgt
, (a
->tpg_enabled_sendtargets
) ? "ON" : "OFF");
900 int iscsit_ta_login_keys_workaround(
901 struct iscsi_portal_group
*tpg
,
904 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
906 if ((flag
!= 0) && (flag
!= 1)) {
907 pr_err("Illegal value %d\n", flag
);
911 a
->login_keys_workaround
= flag
;
912 pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
913 tpg
->tpgt
, (a
->login_keys_workaround
) ? "ON" : "OFF");