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>
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 ret
= core_tpg_register(&iscsi_ops
, NULL
, &tpg
->tpg_se_tpg
, -1);
76 tpg
->sid
= 1; /* First Assigned LIO Session ID */
77 iscsit_set_default_tpg_attribs(tpg
);
79 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
82 * By default we disable authentication for discovery sessions,
83 * this can be changed with:
85 * /sys/kernel/config/target/iscsi/discovery_auth/enforce_discovery_auth
87 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
91 if (iscsi_update_param_value(param
, "CHAP,None") < 0)
94 tpg
->tpg_attrib
.authentication
= 0;
96 spin_lock(&tpg
->tpg_state_lock
);
97 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
98 spin_unlock(&tpg
->tpg_state_lock
);
100 iscsit_global
->discovery_tpg
= tpg
;
101 pr_debug("CORE[0] - Allocated Discovery TPG\n");
106 core_tpg_deregister(&tpg
->tpg_se_tpg
);
111 void iscsit_release_discovery_tpg(void)
113 struct iscsi_portal_group
*tpg
= iscsit_global
->discovery_tpg
;
118 core_tpg_deregister(&tpg
->tpg_se_tpg
);
121 iscsit_global
->discovery_tpg
= NULL
;
124 struct iscsi_portal_group
*iscsit_get_tpg_from_np(
125 struct iscsi_tiqn
*tiqn
,
127 struct iscsi_tpg_np
**tpg_np_out
)
129 struct iscsi_portal_group
*tpg
= NULL
;
130 struct iscsi_tpg_np
*tpg_np
;
132 spin_lock(&tiqn
->tiqn_tpg_lock
);
133 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
135 spin_lock(&tpg
->tpg_state_lock
);
136 if (tpg
->tpg_state
!= TPG_STATE_ACTIVE
) {
137 spin_unlock(&tpg
->tpg_state_lock
);
140 spin_unlock(&tpg
->tpg_state_lock
);
142 spin_lock(&tpg
->tpg_np_lock
);
143 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
144 if (tpg_np
->tpg_np
== np
) {
145 *tpg_np_out
= tpg_np
;
146 kref_get(&tpg_np
->tpg_np_kref
);
147 spin_unlock(&tpg
->tpg_np_lock
);
148 spin_unlock(&tiqn
->tiqn_tpg_lock
);
152 spin_unlock(&tpg
->tpg_np_lock
);
154 spin_unlock(&tiqn
->tiqn_tpg_lock
);
160 struct iscsi_portal_group
*tpg
)
162 return mutex_lock_interruptible(&tpg
->tpg_access_lock
);
165 void iscsit_put_tpg(struct iscsi_portal_group
*tpg
)
167 mutex_unlock(&tpg
->tpg_access_lock
);
170 static void iscsit_clear_tpg_np_login_thread(
171 struct iscsi_tpg_np
*tpg_np
,
172 struct iscsi_portal_group
*tpg
,
175 if (!tpg_np
->tpg_np
) {
176 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
181 tpg_np
->tpg_np
->enabled
= false;
182 iscsit_reset_np_thread(tpg_np
->tpg_np
, tpg_np
, tpg
, shutdown
);
185 static void iscsit_clear_tpg_np_login_threads(
186 struct iscsi_portal_group
*tpg
,
189 struct iscsi_tpg_np
*tpg_np
;
191 spin_lock(&tpg
->tpg_np_lock
);
192 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
193 if (!tpg_np
->tpg_np
) {
194 pr_err("struct iscsi_tpg_np->tpg_np is NULL!\n");
197 spin_unlock(&tpg
->tpg_np_lock
);
198 iscsit_clear_tpg_np_login_thread(tpg_np
, tpg
, shutdown
);
199 spin_lock(&tpg
->tpg_np_lock
);
201 spin_unlock(&tpg
->tpg_np_lock
);
204 void iscsit_tpg_dump_params(struct iscsi_portal_group
*tpg
)
206 iscsi_print_params(tpg
->param_list
);
209 static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group
*tpg
)
211 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
213 a
->authentication
= TA_AUTHENTICATION
;
214 a
->login_timeout
= TA_LOGIN_TIMEOUT
;
215 a
->netif_timeout
= TA_NETIF_TIMEOUT
;
216 a
->default_cmdsn_depth
= TA_DEFAULT_CMDSN_DEPTH
;
217 a
->generate_node_acls
= TA_GENERATE_NODE_ACLS
;
218 a
->cache_dynamic_acls
= TA_CACHE_DYNAMIC_ACLS
;
219 a
->demo_mode_write_protect
= TA_DEMO_MODE_WRITE_PROTECT
;
220 a
->prod_mode_write_protect
= TA_PROD_MODE_WRITE_PROTECT
;
221 a
->demo_mode_discovery
= TA_DEMO_MODE_DISCOVERY
;
222 a
->default_erl
= TA_DEFAULT_ERL
;
223 a
->t10_pi
= TA_DEFAULT_T10_PI
;
224 a
->fabric_prot_type
= TA_DEFAULT_FABRIC_PROT_TYPE
;
227 int iscsit_tpg_add_portal_group(struct iscsi_tiqn
*tiqn
, struct iscsi_portal_group
*tpg
)
229 if (tpg
->tpg_state
!= TPG_STATE_FREE
) {
230 pr_err("Unable to add iSCSI Target Portal Group: %d"
231 " while not in TPG_STATE_FREE state.\n", tpg
->tpgt
);
234 iscsit_set_default_tpg_attribs(tpg
);
236 if (iscsi_create_default_params(&tpg
->param_list
) < 0)
239 tpg
->tpg_attrib
.tpg
= tpg
;
241 spin_lock(&tpg
->tpg_state_lock
);
242 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
243 spin_unlock(&tpg
->tpg_state_lock
);
245 spin_lock(&tiqn
->tiqn_tpg_lock
);
246 list_add_tail(&tpg
->tpg_list
, &tiqn
->tiqn_tpg_list
);
248 pr_debug("CORE[%s]_TPG[%hu] - Added iSCSI Target Portal Group\n",
249 tiqn
->tiqn
, tpg
->tpgt
);
250 spin_unlock(&tiqn
->tiqn_tpg_lock
);
254 if (tpg
->param_list
) {
255 iscsi_release_param_list(tpg
->param_list
);
256 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 spin_lock(&tpg
->tpg_state_lock
);
311 if (tpg
->tpg_state
== TPG_STATE_ACTIVE
) {
312 pr_err("iSCSI target portal group: %hu is already"
313 " active, ignoring request.\n", tpg
->tpgt
);
314 spin_unlock(&tpg
->tpg_state_lock
);
318 * Make sure that AuthMethod does not contain None as an option
319 * unless explictly disabled. Set the default to CHAP if authentication
320 * is enforced (as per default), and remove the NONE option.
322 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
324 spin_unlock(&tpg
->tpg_state_lock
);
328 if (tpg
->tpg_attrib
.authentication
) {
329 if (!strcmp(param
->value
, NONE
)) {
330 ret
= iscsi_update_param_value(param
, CHAP
);
335 ret
= iscsit_ta_authentication(tpg
, 1);
340 tpg
->tpg_state
= TPG_STATE_ACTIVE
;
341 spin_unlock(&tpg
->tpg_state_lock
);
343 spin_lock(&tiqn
->tiqn_tpg_lock
);
344 tiqn
->tiqn_active_tpgs
++;
345 pr_debug("iSCSI_TPG[%hu] - Enabled iSCSI Target Portal Group\n",
347 spin_unlock(&tiqn
->tiqn_tpg_lock
);
352 spin_unlock(&tpg
->tpg_state_lock
);
356 int iscsit_tpg_disable_portal_group(struct iscsi_portal_group
*tpg
, int force
)
358 struct iscsi_tiqn
*tiqn
;
359 u8 old_state
= tpg
->tpg_state
;
361 spin_lock(&tpg
->tpg_state_lock
);
362 if (tpg
->tpg_state
== TPG_STATE_INACTIVE
) {
363 pr_err("iSCSI Target Portal Group: %hu is already"
364 " inactive, ignoring request.\n", tpg
->tpgt
);
365 spin_unlock(&tpg
->tpg_state_lock
);
368 tpg
->tpg_state
= TPG_STATE_INACTIVE
;
369 spin_unlock(&tpg
->tpg_state_lock
);
371 iscsit_clear_tpg_np_login_threads(tpg
, false);
373 if (iscsit_release_sessions_for_tpg(tpg
, force
) < 0) {
374 spin_lock(&tpg
->tpg_state_lock
);
375 tpg
->tpg_state
= old_state
;
376 spin_unlock(&tpg
->tpg_state_lock
);
377 pr_err("Unable to disable iSCSI Target Portal Group:"
378 " %hu while active sessions exist, and force=0\n",
383 tiqn
= tpg
->tpg_tiqn
;
384 if (!tiqn
|| (tpg
== iscsit_global
->discovery_tpg
))
387 spin_lock(&tiqn
->tiqn_tpg_lock
);
388 tiqn
->tiqn_active_tpgs
--;
389 pr_debug("iSCSI_TPG[%hu] - Disabled iSCSI Target Portal Group\n",
391 spin_unlock(&tiqn
->tiqn_tpg_lock
);
396 struct iscsi_node_attrib
*iscsit_tpg_get_node_attrib(
397 struct iscsi_session
*sess
)
399 struct se_session
*se_sess
= sess
->se_sess
;
400 struct se_node_acl
*se_nacl
= se_sess
->se_node_acl
;
401 struct iscsi_node_acl
*acl
= container_of(se_nacl
, struct iscsi_node_acl
,
404 return &acl
->node_attrib
;
407 struct iscsi_tpg_np
*iscsit_tpg_locate_child_np(
408 struct iscsi_tpg_np
*tpg_np
,
409 int network_transport
)
411 struct iscsi_tpg_np
*tpg_np_child
, *tpg_np_child_tmp
;
413 spin_lock(&tpg_np
->tpg_np_parent_lock
);
414 list_for_each_entry_safe(tpg_np_child
, tpg_np_child_tmp
,
415 &tpg_np
->tpg_np_parent_list
, tpg_np_child_list
) {
416 if (tpg_np_child
->tpg_np
->np_network_transport
==
418 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
422 spin_unlock(&tpg_np
->tpg_np_parent_lock
);
427 static bool iscsit_tpg_check_network_portal(
428 struct iscsi_tiqn
*tiqn
,
429 struct __kernel_sockaddr_storage
*sockaddr
,
430 int network_transport
)
432 struct iscsi_portal_group
*tpg
;
433 struct iscsi_tpg_np
*tpg_np
;
437 spin_lock(&tiqn
->tiqn_tpg_lock
);
438 list_for_each_entry(tpg
, &tiqn
->tiqn_tpg_list
, tpg_list
) {
440 spin_lock(&tpg
->tpg_np_lock
);
441 list_for_each_entry(tpg_np
, &tpg
->tpg_gnp_list
, tpg_np_list
) {
444 match
= iscsit_check_np_match(sockaddr
, np
,
449 spin_unlock(&tpg
->tpg_np_lock
);
451 spin_unlock(&tiqn
->tiqn_tpg_lock
);
456 struct iscsi_tpg_np
*iscsit_tpg_add_network_portal(
457 struct iscsi_portal_group
*tpg
,
458 struct __kernel_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: %s already exists on a"
470 " different TPG on %s\n", ip_str
,
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
, ip_str
, 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: %s:%hu,%hu on %s\n",
514 tpg
->tpg_tiqn
->tiqn
, np
->np_ip
, np
->np_port
, 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: %s:%hu,%hu on %s\n",
528 tpg
->tpg_tiqn
->tiqn
, np
->np_ip
, np
->np_port
, 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_tpg_set_initiator_node_queue_depth(
590 struct iscsi_portal_group
*tpg
,
591 unsigned char *initiatorname
,
595 return core_tpg_set_initiator_node_queue_depth(&tpg
->tpg_se_tpg
,
596 initiatorname
, queue_depth
, force
);
599 int iscsit_ta_authentication(struct iscsi_portal_group
*tpg
, u32 authentication
)
601 unsigned char buf1
[256], buf2
[256], *none
= NULL
;
603 struct iscsi_param
*param
;
604 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
606 if ((authentication
!= 1) && (authentication
!= 0)) {
607 pr_err("Illegal value for authentication parameter:"
608 " %u, ignoring request.\n", authentication
);
612 memset(buf1
, 0, sizeof(buf1
));
613 memset(buf2
, 0, sizeof(buf2
));
615 param
= iscsi_find_param_from_key(AUTHMETHOD
, tpg
->param_list
);
619 if (authentication
) {
620 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
621 none
= strstr(buf1
, NONE
);
624 if (!strncmp(none
+ 4, ",", 1)) {
625 if (!strcmp(buf1
, none
))
626 sprintf(buf2
, "%s", none
+5);
630 len
= sprintf(buf2
, "%s", buf1
);
632 sprintf(buf2
+ len
, "%s", none
);
637 sprintf(buf2
, "%s", buf1
);
639 if (iscsi_update_param_value(param
, buf2
) < 0)
642 snprintf(buf1
, sizeof(buf1
), "%s", param
->value
);
643 none
= strstr(buf1
, NONE
);
646 strncat(buf1
, ",", strlen(","));
647 strncat(buf1
, NONE
, strlen(NONE
));
648 if (iscsi_update_param_value(param
, buf1
) < 0)
653 a
->authentication
= authentication
;
654 pr_debug("%s iSCSI Authentication Methods for TPG: %hu.\n",
655 a
->authentication
? "Enforcing" : "Disabling", tpg
->tpgt
);
660 int iscsit_ta_login_timeout(
661 struct iscsi_portal_group
*tpg
,
664 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
666 if (login_timeout
> TA_LOGIN_TIMEOUT_MAX
) {
667 pr_err("Requested Login Timeout %u larger than maximum"
668 " %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MAX
);
670 } else if (login_timeout
< TA_LOGIN_TIMEOUT_MIN
) {
671 pr_err("Requested Logout Timeout %u smaller than"
672 " minimum %u\n", login_timeout
, TA_LOGIN_TIMEOUT_MIN
);
676 a
->login_timeout
= login_timeout
;
677 pr_debug("Set Logout Timeout to %u for Target Portal Group"
678 " %hu\n", a
->login_timeout
, tpg
->tpgt
);
683 int iscsit_ta_netif_timeout(
684 struct iscsi_portal_group
*tpg
,
687 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
689 if (netif_timeout
> TA_NETIF_TIMEOUT_MAX
) {
690 pr_err("Requested Network Interface Timeout %u larger"
691 " than maximum %u\n", netif_timeout
,
692 TA_NETIF_TIMEOUT_MAX
);
694 } else if (netif_timeout
< TA_NETIF_TIMEOUT_MIN
) {
695 pr_err("Requested Network Interface Timeout %u smaller"
696 " than minimum %u\n", netif_timeout
,
697 TA_NETIF_TIMEOUT_MIN
);
701 a
->netif_timeout
= netif_timeout
;
702 pr_debug("Set Network Interface Timeout to %u for"
703 " Target Portal Group %hu\n", a
->netif_timeout
, tpg
->tpgt
);
708 int iscsit_ta_generate_node_acls(
709 struct iscsi_portal_group
*tpg
,
712 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
714 if ((flag
!= 0) && (flag
!= 1)) {
715 pr_err("Illegal value %d\n", flag
);
719 a
->generate_node_acls
= flag
;
720 pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n",
721 tpg
->tpgt
, (a
->generate_node_acls
) ? "Enabled" : "Disabled");
723 if (flag
== 1 && a
->cache_dynamic_acls
== 0) {
724 pr_debug("Explicitly setting cache_dynamic_acls=1 when "
725 "generate_node_acls=1\n");
726 a
->cache_dynamic_acls
= 1;
732 int iscsit_ta_default_cmdsn_depth(
733 struct iscsi_portal_group
*tpg
,
736 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
738 if (tcq_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
739 pr_err("Requested Default Queue Depth: %u larger"
740 " than maximum %u\n", tcq_depth
,
741 TA_DEFAULT_CMDSN_DEPTH_MAX
);
743 } else if (tcq_depth
< TA_DEFAULT_CMDSN_DEPTH_MIN
) {
744 pr_err("Requested Default Queue Depth: %u smaller"
745 " than minimum %u\n", tcq_depth
,
746 TA_DEFAULT_CMDSN_DEPTH_MIN
);
750 a
->default_cmdsn_depth
= tcq_depth
;
751 pr_debug("iSCSI_TPG[%hu] - Set Default CmdSN TCQ Depth to %u\n",
752 tpg
->tpgt
, a
->default_cmdsn_depth
);
757 int iscsit_ta_cache_dynamic_acls(
758 struct iscsi_portal_group
*tpg
,
761 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
763 if ((flag
!= 0) && (flag
!= 1)) {
764 pr_err("Illegal value %d\n", flag
);
768 if (a
->generate_node_acls
== 1 && flag
== 0) {
769 pr_debug("Skipping cache_dynamic_acls=0 when"
770 " generate_node_acls=1\n");
774 a
->cache_dynamic_acls
= flag
;
775 pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group"
776 " ACLs %s\n", tpg
->tpgt
, (a
->cache_dynamic_acls
) ?
777 "Enabled" : "Disabled");
782 int iscsit_ta_demo_mode_write_protect(
783 struct iscsi_portal_group
*tpg
,
786 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
788 if ((flag
!= 0) && (flag
!= 1)) {
789 pr_err("Illegal value %d\n", flag
);
793 a
->demo_mode_write_protect
= flag
;
794 pr_debug("iSCSI_TPG[%hu] - Demo Mode Write Protect bit: %s\n",
795 tpg
->tpgt
, (a
->demo_mode_write_protect
) ? "ON" : "OFF");
800 int iscsit_ta_prod_mode_write_protect(
801 struct iscsi_portal_group
*tpg
,
804 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
806 if ((flag
!= 0) && (flag
!= 1)) {
807 pr_err("Illegal value %d\n", flag
);
811 a
->prod_mode_write_protect
= flag
;
812 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:"
813 " %s\n", tpg
->tpgt
, (a
->prod_mode_write_protect
) ?
819 int iscsit_ta_demo_mode_discovery(
820 struct iscsi_portal_group
*tpg
,
823 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
825 if ((flag
!= 0) && (flag
!= 1)) {
826 pr_err("Illegal value %d\n", flag
);
830 a
->demo_mode_discovery
= flag
;
831 pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:"
832 " %s\n", tpg
->tpgt
, (a
->demo_mode_discovery
) ?
838 int iscsit_ta_default_erl(
839 struct iscsi_portal_group
*tpg
,
842 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
844 if ((default_erl
!= 0) && (default_erl
!= 1) && (default_erl
!= 2)) {
845 pr_err("Illegal value for default_erl: %u\n", default_erl
);
849 a
->default_erl
= default_erl
;
850 pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg
->tpgt
, a
->default_erl
);
855 int iscsit_ta_t10_pi(
856 struct iscsi_portal_group
*tpg
,
859 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
861 if ((flag
!= 0) && (flag
!= 1)) {
862 pr_err("Illegal value %d\n", flag
);
867 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
868 " %s\n", tpg
->tpgt
, (a
->t10_pi
) ?
874 int iscsit_ta_fabric_prot_type(
875 struct iscsi_portal_group
*tpg
,
878 struct iscsi_tpg_attrib
*a
= &tpg
->tpg_attrib
;
880 if ((prot_type
!= 0) && (prot_type
!= 1) && (prot_type
!= 3)) {
881 pr_err("Illegal value for fabric_prot_type: %u\n", prot_type
);
885 a
->fabric_prot_type
= prot_type
;
886 pr_debug("iSCSI_TPG[%hu] - T10 Fabric Protection Type: %u\n",
887 tpg
->tpgt
, prot_type
);