1 /*******************************************************************************
2 * This file contains the configfs implementation for iSCSI Target mode
3 * from the LIO-Target Project.
5 * (c) Copyright 2007-2013 Datera, Inc.
7 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 ****************************************************************************/
20 #include <linux/configfs.h>
21 #include <linux/ctype.h>
22 #include <linux/export.h>
23 #include <linux/inet.h>
24 #include <target/target_core_base.h>
25 #include <target/target_core_fabric.h>
26 #include <target/target_core_fabric_configfs.h>
27 #include <target/target_core_configfs.h>
28 #include <target/configfs_macros.h>
29 #include <target/iscsi/iscsi_transport.h>
31 #include "iscsi_target_core.h"
32 #include "iscsi_target_parameters.h"
33 #include "iscsi_target_device.h"
34 #include "iscsi_target_erl0.h"
35 #include "iscsi_target_nodeattrib.h"
36 #include "iscsi_target_tpg.h"
37 #include "iscsi_target_util.h"
38 #include "iscsi_target.h"
39 #include "iscsi_target_stat.h"
40 #include "iscsi_target_configfs.h"
42 struct target_fabric_configfs
*lio_target_fabric_configfs
;
44 struct lio_target_configfs_attribute
{
45 struct configfs_attribute attr
;
46 ssize_t (*show
)(void *, char *);
47 ssize_t (*store
)(void *, const char *, size_t);
50 /* Start items for lio_target_portal_cit */
52 static ssize_t
lio_target_np_show_sctp(
53 struct se_tpg_np
*se_tpg_np
,
56 struct iscsi_tpg_np
*tpg_np
= container_of(se_tpg_np
,
57 struct iscsi_tpg_np
, se_tpg_np
);
58 struct iscsi_tpg_np
*tpg_np_sctp
;
61 tpg_np_sctp
= iscsit_tpg_locate_child_np(tpg_np
, ISCSI_SCTP_TCP
);
63 rb
= sprintf(page
, "1\n");
65 rb
= sprintf(page
, "0\n");
70 static ssize_t
lio_target_np_store_sctp(
71 struct se_tpg_np
*se_tpg_np
,
76 struct iscsi_portal_group
*tpg
;
77 struct iscsi_tpg_np
*tpg_np
= container_of(se_tpg_np
,
78 struct iscsi_tpg_np
, se_tpg_np
);
79 struct iscsi_tpg_np
*tpg_np_sctp
= NULL
;
83 ret
= kstrtou32(page
, 0, &op
);
86 if ((op
!= 1) && (op
!= 0)) {
87 pr_err("Illegal value for tpg_enable: %u\n", op
);
92 pr_err("Unable to locate struct iscsi_np from"
93 " struct iscsi_tpg_np\n");
98 if (iscsit_get_tpg(tpg
) < 0)
103 * Use existing np->np_sockaddr for SCTP network portal reference
105 tpg_np_sctp
= iscsit_tpg_add_network_portal(tpg
, &np
->np_sockaddr
,
106 np
->np_ip
, tpg_np
, ISCSI_SCTP_TCP
);
107 if (!tpg_np_sctp
|| IS_ERR(tpg_np_sctp
))
110 tpg_np_sctp
= iscsit_tpg_locate_child_np(tpg_np
, ISCSI_SCTP_TCP
);
114 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np_sctp
);
126 TF_NP_BASE_ATTR(lio_target
, sctp
, S_IRUGO
| S_IWUSR
);
128 static ssize_t
lio_target_np_show_iser(
129 struct se_tpg_np
*se_tpg_np
,
132 struct iscsi_tpg_np
*tpg_np
= container_of(se_tpg_np
,
133 struct iscsi_tpg_np
, se_tpg_np
);
134 struct iscsi_tpg_np
*tpg_np_iser
;
137 tpg_np_iser
= iscsit_tpg_locate_child_np(tpg_np
, ISCSI_INFINIBAND
);
139 rb
= sprintf(page
, "1\n");
141 rb
= sprintf(page
, "0\n");
146 static ssize_t
lio_target_np_store_iser(
147 struct se_tpg_np
*se_tpg_np
,
152 struct iscsi_portal_group
*tpg
;
153 struct iscsi_tpg_np
*tpg_np
= container_of(se_tpg_np
,
154 struct iscsi_tpg_np
, se_tpg_np
);
155 struct iscsi_tpg_np
*tpg_np_iser
= NULL
;
160 op
= simple_strtoul(page
, &endptr
, 0);
161 if ((op
!= 1) && (op
!= 0)) {
162 pr_err("Illegal value for tpg_enable: %u\n", op
);
167 pr_err("Unable to locate struct iscsi_np from"
168 " struct iscsi_tpg_np\n");
173 if (iscsit_get_tpg(tpg
) < 0)
177 rc
= request_module("ib_isert");
179 pr_warn("Unable to request_module for ib_isert\n");
183 tpg_np_iser
= iscsit_tpg_add_network_portal(tpg
, &np
->np_sockaddr
,
184 np
->np_ip
, tpg_np
, ISCSI_INFINIBAND
);
185 if (IS_ERR(tpg_np_iser
)) {
186 rc
= PTR_ERR(tpg_np_iser
);
190 tpg_np_iser
= iscsit_tpg_locate_child_np(tpg_np
, ISCSI_INFINIBAND
);
192 rc
= iscsit_tpg_del_network_portal(tpg
, tpg_np_iser
);
205 TF_NP_BASE_ATTR(lio_target
, iser
, S_IRUGO
| S_IWUSR
);
207 static struct configfs_attribute
*lio_target_portal_attrs
[] = {
208 &lio_target_np_sctp
.attr
,
209 &lio_target_np_iser
.attr
,
213 /* Stop items for lio_target_portal_cit */
215 /* Start items for lio_target_np_cit */
217 #define MAX_PORTAL_LEN 256
219 static struct se_tpg_np
*lio_target_call_addnptotpg(
220 struct se_portal_group
*se_tpg
,
221 struct config_group
*group
,
224 struct iscsi_portal_group
*tpg
;
225 struct iscsi_tpg_np
*tpg_np
;
226 char *str
, *str2
, *ip_str
, *port_str
;
227 struct __kernel_sockaddr_storage sockaddr
;
228 struct sockaddr_in
*sock_in
;
229 struct sockaddr_in6
*sock_in6
;
232 char buf
[MAX_PORTAL_LEN
+ 1];
234 if (strlen(name
) > MAX_PORTAL_LEN
) {
235 pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
236 (int)strlen(name
), MAX_PORTAL_LEN
);
237 return ERR_PTR(-EOVERFLOW
);
239 memset(buf
, 0, MAX_PORTAL_LEN
+ 1);
240 snprintf(buf
, MAX_PORTAL_LEN
+ 1, "%s", name
);
242 memset(&sockaddr
, 0, sizeof(struct __kernel_sockaddr_storage
));
244 str
= strstr(buf
, "[");
248 str2
= strstr(str
, "]");
250 pr_err("Unable to locate trailing \"]\""
251 " in IPv6 iSCSI network portal address\n");
252 return ERR_PTR(-EINVAL
);
254 str
++; /* Skip over leading "[" */
255 *str2
= '\0'; /* Terminate the IPv6 address */
256 str2
++; /* Skip over the "]" */
257 port_str
= strstr(str2
, ":");
259 pr_err("Unable to locate \":port\""
260 " in IPv6 iSCSI network portal address\n");
261 return ERR_PTR(-EINVAL
);
263 *port_str
= '\0'; /* Terminate string for IP */
264 port_str
++; /* Skip over ":" */
266 ret
= kstrtoul(port_str
, 0, &port
);
268 pr_err("kstrtoul() failed for port_str: %d\n", ret
);
271 sock_in6
= (struct sockaddr_in6
*)&sockaddr
;
272 sock_in6
->sin6_family
= AF_INET6
;
273 sock_in6
->sin6_port
= htons((unsigned short)port
);
274 ret
= in6_pton(str
, IPV6_ADDRESS_SPACE
,
275 (void *)&sock_in6
->sin6_addr
.in6_u
, -1, &end
);
277 pr_err("in6_pton returned: %d\n", ret
);
278 return ERR_PTR(-EINVAL
);
281 str
= ip_str
= &buf
[0];
282 port_str
= strstr(ip_str
, ":");
284 pr_err("Unable to locate \":port\""
285 " in IPv4 iSCSI network portal address\n");
286 return ERR_PTR(-EINVAL
);
288 *port_str
= '\0'; /* Terminate string for IP */
289 port_str
++; /* Skip over ":" */
291 ret
= kstrtoul(port_str
, 0, &port
);
293 pr_err("kstrtoul() failed for port_str: %d\n", ret
);
296 sock_in
= (struct sockaddr_in
*)&sockaddr
;
297 sock_in
->sin_family
= AF_INET
;
298 sock_in
->sin_port
= htons((unsigned short)port
);
299 sock_in
->sin_addr
.s_addr
= in_aton(ip_str
);
301 tpg
= container_of(se_tpg
, struct iscsi_portal_group
, tpg_se_tpg
);
302 ret
= iscsit_get_tpg(tpg
);
304 return ERR_PTR(-EINVAL
);
306 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
308 config_item_name(&se_tpg
->se_tpg_wwn
->wwn_group
.cg_item
),
311 * Assume ISCSI_TCP by default. Other network portals for other
314 * Traditional iSCSI over SCTP (initial support)
315 * iSER/TCP (TODO, hardware available)
316 * iSER/SCTP (TODO, software emulation with osc-iwarp)
317 * iSER/IB (TODO, hardware available)
319 * can be enabled with attributes under
320 * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
323 tpg_np
= iscsit_tpg_add_network_portal(tpg
, &sockaddr
, str
, NULL
,
325 if (IS_ERR(tpg_np
)) {
327 return ERR_CAST(tpg_np
);
329 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
332 return &tpg_np
->se_tpg_np
;
335 static void lio_target_call_delnpfromtpg(
336 struct se_tpg_np
*se_tpg_np
)
338 struct iscsi_portal_group
*tpg
;
339 struct iscsi_tpg_np
*tpg_np
;
340 struct se_portal_group
*se_tpg
;
343 tpg_np
= container_of(se_tpg_np
, struct iscsi_tpg_np
, se_tpg_np
);
345 ret
= iscsit_get_tpg(tpg
);
349 se_tpg
= &tpg
->tpg_se_tpg
;
350 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
351 " PORTAL: %s:%hu\n", config_item_name(&se_tpg
->se_tpg_wwn
->wwn_group
.cg_item
),
352 tpg
->tpgt
, tpg_np
->tpg_np
->np_ip
, tpg_np
->tpg_np
->np_port
);
354 ret
= iscsit_tpg_del_network_portal(tpg
, tpg_np
);
358 pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
363 /* End items for lio_target_np_cit */
365 /* Start items for lio_target_nacl_attrib_cit */
367 #define DEF_NACL_ATTRIB(name) \
368 static ssize_t iscsi_nacl_attrib_show_##name( \
369 struct se_node_acl *se_nacl, \
372 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
375 return sprintf(page, "%u\n", ISCSI_NODE_ATTRIB(nacl)->name); \
378 static ssize_t iscsi_nacl_attrib_store_##name( \
379 struct se_node_acl *se_nacl, \
383 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
388 ret = kstrtou32(page, 0, &val); \
391 ret = iscsit_na_##name(nacl, val); \
398 #define NACL_ATTR(_name, _mode) TF_NACL_ATTRIB_ATTR(iscsi, _name, _mode);
400 * Define iscsi_node_attrib_s_dataout_timeout
402 DEF_NACL_ATTRIB(dataout_timeout
);
403 NACL_ATTR(dataout_timeout
, S_IRUGO
| S_IWUSR
);
405 * Define iscsi_node_attrib_s_dataout_timeout_retries
407 DEF_NACL_ATTRIB(dataout_timeout_retries
);
408 NACL_ATTR(dataout_timeout_retries
, S_IRUGO
| S_IWUSR
);
410 * Define iscsi_node_attrib_s_default_erl
412 DEF_NACL_ATTRIB(default_erl
);
413 NACL_ATTR(default_erl
, S_IRUGO
| S_IWUSR
);
415 * Define iscsi_node_attrib_s_nopin_timeout
417 DEF_NACL_ATTRIB(nopin_timeout
);
418 NACL_ATTR(nopin_timeout
, S_IRUGO
| S_IWUSR
);
420 * Define iscsi_node_attrib_s_nopin_response_timeout
422 DEF_NACL_ATTRIB(nopin_response_timeout
);
423 NACL_ATTR(nopin_response_timeout
, S_IRUGO
| S_IWUSR
);
425 * Define iscsi_node_attrib_s_random_datain_pdu_offsets
427 DEF_NACL_ATTRIB(random_datain_pdu_offsets
);
428 NACL_ATTR(random_datain_pdu_offsets
, S_IRUGO
| S_IWUSR
);
430 * Define iscsi_node_attrib_s_random_datain_seq_offsets
432 DEF_NACL_ATTRIB(random_datain_seq_offsets
);
433 NACL_ATTR(random_datain_seq_offsets
, S_IRUGO
| S_IWUSR
);
435 * Define iscsi_node_attrib_s_random_r2t_offsets
437 DEF_NACL_ATTRIB(random_r2t_offsets
);
438 NACL_ATTR(random_r2t_offsets
, S_IRUGO
| S_IWUSR
);
440 static struct configfs_attribute
*lio_target_nacl_attrib_attrs
[] = {
441 &iscsi_nacl_attrib_dataout_timeout
.attr
,
442 &iscsi_nacl_attrib_dataout_timeout_retries
.attr
,
443 &iscsi_nacl_attrib_default_erl
.attr
,
444 &iscsi_nacl_attrib_nopin_timeout
.attr
,
445 &iscsi_nacl_attrib_nopin_response_timeout
.attr
,
446 &iscsi_nacl_attrib_random_datain_pdu_offsets
.attr
,
447 &iscsi_nacl_attrib_random_datain_seq_offsets
.attr
,
448 &iscsi_nacl_attrib_random_r2t_offsets
.attr
,
452 /* End items for lio_target_nacl_attrib_cit */
454 /* Start items for lio_target_nacl_auth_cit */
456 #define __DEF_NACL_AUTH_STR(prefix, name, flags) \
457 static ssize_t __iscsi_##prefix##_show_##name( \
458 struct iscsi_node_acl *nacl, \
461 struct iscsi_node_auth *auth = &nacl->node_auth; \
463 if (!capable(CAP_SYS_ADMIN)) \
465 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
468 static ssize_t __iscsi_##prefix##_store_##name( \
469 struct iscsi_node_acl *nacl, \
473 struct iscsi_node_auth *auth = &nacl->node_auth; \
475 if (!capable(CAP_SYS_ADMIN)) \
478 snprintf(auth->name, sizeof(auth->name), "%s", page); \
479 if (!strncmp("NULL", auth->name, 4)) \
480 auth->naf_flags &= ~flags; \
482 auth->naf_flags |= flags; \
484 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
485 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
486 auth->authenticate_target = 1; \
488 auth->authenticate_target = 0; \
493 #define __DEF_NACL_AUTH_INT(prefix, name) \
494 static ssize_t __iscsi_##prefix##_show_##name( \
495 struct iscsi_node_acl *nacl, \
498 struct iscsi_node_auth *auth = &nacl->node_auth; \
500 if (!capable(CAP_SYS_ADMIN)) \
503 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
506 #define DEF_NACL_AUTH_STR(name, flags) \
507 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
508 static ssize_t iscsi_nacl_auth_show_##name( \
509 struct se_node_acl *nacl, \
512 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
513 struct iscsi_node_acl, se_node_acl), page); \
515 static ssize_t iscsi_nacl_auth_store_##name( \
516 struct se_node_acl *nacl, \
520 return __iscsi_nacl_auth_store_##name(container_of(nacl, \
521 struct iscsi_node_acl, se_node_acl), page, count); \
524 #define DEF_NACL_AUTH_INT(name) \
525 __DEF_NACL_AUTH_INT(nacl_auth, name) \
526 static ssize_t iscsi_nacl_auth_show_##name( \
527 struct se_node_acl *nacl, \
530 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
531 struct iscsi_node_acl, se_node_acl), page); \
534 #define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode);
535 #define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name);
538 * One-way authentication userid
540 DEF_NACL_AUTH_STR(userid
, NAF_USERID_SET
);
541 AUTH_ATTR(userid
, S_IRUGO
| S_IWUSR
);
543 * One-way authentication password
545 DEF_NACL_AUTH_STR(password
, NAF_PASSWORD_SET
);
546 AUTH_ATTR(password
, S_IRUGO
| S_IWUSR
);
548 * Enforce mutual authentication
550 DEF_NACL_AUTH_INT(authenticate_target
);
551 AUTH_ATTR_RO(authenticate_target
);
553 * Mutual authentication userid
555 DEF_NACL_AUTH_STR(userid_mutual
, NAF_USERID_IN_SET
);
556 AUTH_ATTR(userid_mutual
, S_IRUGO
| S_IWUSR
);
558 * Mutual authentication password
560 DEF_NACL_AUTH_STR(password_mutual
, NAF_PASSWORD_IN_SET
);
561 AUTH_ATTR(password_mutual
, S_IRUGO
| S_IWUSR
);
563 static struct configfs_attribute
*lio_target_nacl_auth_attrs
[] = {
564 &iscsi_nacl_auth_userid
.attr
,
565 &iscsi_nacl_auth_password
.attr
,
566 &iscsi_nacl_auth_authenticate_target
.attr
,
567 &iscsi_nacl_auth_userid_mutual
.attr
,
568 &iscsi_nacl_auth_password_mutual
.attr
,
572 /* End items for lio_target_nacl_auth_cit */
574 /* Start items for lio_target_nacl_param_cit */
576 #define DEF_NACL_PARAM(name) \
577 static ssize_t iscsi_nacl_param_show_##name( \
578 struct se_node_acl *se_nacl, \
581 struct iscsi_session *sess; \
582 struct se_session *se_sess; \
585 spin_lock_bh(&se_nacl->nacl_sess_lock); \
586 se_sess = se_nacl->nacl_sess; \
588 rb = snprintf(page, PAGE_SIZE, \
589 "No Active iSCSI Session\n"); \
591 sess = se_sess->fabric_sess_ptr; \
592 rb = snprintf(page, PAGE_SIZE, "%u\n", \
593 (u32)sess->sess_ops->name); \
595 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
600 #define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name);
602 DEF_NACL_PARAM(MaxConnections
);
603 NACL_PARAM_ATTR(MaxConnections
);
605 DEF_NACL_PARAM(InitialR2T
);
606 NACL_PARAM_ATTR(InitialR2T
);
608 DEF_NACL_PARAM(ImmediateData
);
609 NACL_PARAM_ATTR(ImmediateData
);
611 DEF_NACL_PARAM(MaxBurstLength
);
612 NACL_PARAM_ATTR(MaxBurstLength
);
614 DEF_NACL_PARAM(FirstBurstLength
);
615 NACL_PARAM_ATTR(FirstBurstLength
);
617 DEF_NACL_PARAM(DefaultTime2Wait
);
618 NACL_PARAM_ATTR(DefaultTime2Wait
);
620 DEF_NACL_PARAM(DefaultTime2Retain
);
621 NACL_PARAM_ATTR(DefaultTime2Retain
);
623 DEF_NACL_PARAM(MaxOutstandingR2T
);
624 NACL_PARAM_ATTR(MaxOutstandingR2T
);
626 DEF_NACL_PARAM(DataPDUInOrder
);
627 NACL_PARAM_ATTR(DataPDUInOrder
);
629 DEF_NACL_PARAM(DataSequenceInOrder
);
630 NACL_PARAM_ATTR(DataSequenceInOrder
);
632 DEF_NACL_PARAM(ErrorRecoveryLevel
);
633 NACL_PARAM_ATTR(ErrorRecoveryLevel
);
635 static struct configfs_attribute
*lio_target_nacl_param_attrs
[] = {
636 &iscsi_nacl_param_MaxConnections
.attr
,
637 &iscsi_nacl_param_InitialR2T
.attr
,
638 &iscsi_nacl_param_ImmediateData
.attr
,
639 &iscsi_nacl_param_MaxBurstLength
.attr
,
640 &iscsi_nacl_param_FirstBurstLength
.attr
,
641 &iscsi_nacl_param_DefaultTime2Wait
.attr
,
642 &iscsi_nacl_param_DefaultTime2Retain
.attr
,
643 &iscsi_nacl_param_MaxOutstandingR2T
.attr
,
644 &iscsi_nacl_param_DataPDUInOrder
.attr
,
645 &iscsi_nacl_param_DataSequenceInOrder
.attr
,
646 &iscsi_nacl_param_ErrorRecoveryLevel
.attr
,
650 /* End items for lio_target_nacl_param_cit */
652 /* Start items for lio_target_acl_cit */
654 static ssize_t
lio_target_nacl_show_info(
655 struct se_node_acl
*se_nacl
,
658 struct iscsi_session
*sess
;
659 struct iscsi_conn
*conn
;
660 struct se_session
*se_sess
;
663 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
664 se_sess
= se_nacl
->nacl_sess
;
666 rb
+= sprintf(page
+rb
, "No active iSCSI Session for Initiator"
667 " Endpoint: %s\n", se_nacl
->initiatorname
);
669 sess
= se_sess
->fabric_sess_ptr
;
671 if (sess
->sess_ops
->InitiatorName
)
672 rb
+= sprintf(page
+rb
, "InitiatorName: %s\n",
673 sess
->sess_ops
->InitiatorName
);
674 if (sess
->sess_ops
->InitiatorAlias
)
675 rb
+= sprintf(page
+rb
, "InitiatorAlias: %s\n",
676 sess
->sess_ops
->InitiatorAlias
);
678 rb
+= sprintf(page
+rb
, "LIO Session ID: %u "
679 "ISID: 0x%02x %02x %02x %02x %02x %02x "
680 "TSIH: %hu ", sess
->sid
,
681 sess
->isid
[0], sess
->isid
[1], sess
->isid
[2],
682 sess
->isid
[3], sess
->isid
[4], sess
->isid
[5],
684 rb
+= sprintf(page
+rb
, "SessionType: %s\n",
685 (sess
->sess_ops
->SessionType
) ?
686 "Discovery" : "Normal");
687 rb
+= sprintf(page
+rb
, "Session State: ");
688 switch (sess
->session_state
) {
689 case TARG_SESS_STATE_FREE
:
690 rb
+= sprintf(page
+rb
, "TARG_SESS_FREE\n");
692 case TARG_SESS_STATE_ACTIVE
:
693 rb
+= sprintf(page
+rb
, "TARG_SESS_STATE_ACTIVE\n");
695 case TARG_SESS_STATE_LOGGED_IN
:
696 rb
+= sprintf(page
+rb
, "TARG_SESS_STATE_LOGGED_IN\n");
698 case TARG_SESS_STATE_FAILED
:
699 rb
+= sprintf(page
+rb
, "TARG_SESS_STATE_FAILED\n");
701 case TARG_SESS_STATE_IN_CONTINUE
:
702 rb
+= sprintf(page
+rb
, "TARG_SESS_STATE_IN_CONTINUE\n");
705 rb
+= sprintf(page
+rb
, "ERROR: Unknown Session"
710 rb
+= sprintf(page
+rb
, "---------------------[iSCSI Session"
711 " Values]-----------------------\n");
712 rb
+= sprintf(page
+rb
, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
713 " : MaxCmdSN : ITT : TTT\n");
714 rb
+= sprintf(page
+rb
, " 0x%08x 0x%08x 0x%08x 0x%08x"
717 (sess
->max_cmd_sn
- sess
->exp_cmd_sn
) + 1,
718 sess
->exp_cmd_sn
, sess
->max_cmd_sn
,
719 sess
->init_task_tag
, sess
->targ_xfer_tag
);
720 rb
+= sprintf(page
+rb
, "----------------------[iSCSI"
721 " Connections]-------------------------\n");
723 spin_lock(&sess
->conn_lock
);
724 list_for_each_entry(conn
, &sess
->sess_conn_list
, conn_list
) {
725 rb
+= sprintf(page
+rb
, "CID: %hu Connection"
726 " State: ", conn
->cid
);
727 switch (conn
->conn_state
) {
728 case TARG_CONN_STATE_FREE
:
729 rb
+= sprintf(page
+rb
,
730 "TARG_CONN_STATE_FREE\n");
732 case TARG_CONN_STATE_XPT_UP
:
733 rb
+= sprintf(page
+rb
,
734 "TARG_CONN_STATE_XPT_UP\n");
736 case TARG_CONN_STATE_IN_LOGIN
:
737 rb
+= sprintf(page
+rb
,
738 "TARG_CONN_STATE_IN_LOGIN\n");
740 case TARG_CONN_STATE_LOGGED_IN
:
741 rb
+= sprintf(page
+rb
,
742 "TARG_CONN_STATE_LOGGED_IN\n");
744 case TARG_CONN_STATE_IN_LOGOUT
:
745 rb
+= sprintf(page
+rb
,
746 "TARG_CONN_STATE_IN_LOGOUT\n");
748 case TARG_CONN_STATE_LOGOUT_REQUESTED
:
749 rb
+= sprintf(page
+rb
,
750 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
752 case TARG_CONN_STATE_CLEANUP_WAIT
:
753 rb
+= sprintf(page
+rb
,
754 "TARG_CONN_STATE_CLEANUP_WAIT\n");
757 rb
+= sprintf(page
+rb
,
758 "ERROR: Unknown Connection State!\n");
762 rb
+= sprintf(page
+rb
, " Address %s %s", conn
->login_ip
,
763 (conn
->network_transport
== ISCSI_TCP
) ?
765 rb
+= sprintf(page
+rb
, " StatSN: 0x%08x\n",
768 spin_unlock(&sess
->conn_lock
);
770 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
775 TF_NACL_BASE_ATTR_RO(lio_target
, info
);
777 static ssize_t
lio_target_nacl_show_cmdsn_depth(
778 struct se_node_acl
*se_nacl
,
781 return sprintf(page
, "%u\n", se_nacl
->queue_depth
);
784 static ssize_t
lio_target_nacl_store_cmdsn_depth(
785 struct se_node_acl
*se_nacl
,
789 struct se_portal_group
*se_tpg
= se_nacl
->se_tpg
;
790 struct iscsi_portal_group
*tpg
= container_of(se_tpg
,
791 struct iscsi_portal_group
, tpg_se_tpg
);
792 struct config_item
*acl_ci
, *tpg_ci
, *wwn_ci
;
796 ret
= kstrtou32(page
, 0, &cmdsn_depth
);
799 if (cmdsn_depth
> TA_DEFAULT_CMDSN_DEPTH_MAX
) {
800 pr_err("Passed cmdsn_depth: %u exceeds"
801 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth
,
802 TA_DEFAULT_CMDSN_DEPTH_MAX
);
805 acl_ci
= &se_nacl
->acl_group
.cg_item
;
807 pr_err("Unable to locatel acl_ci\n");
810 tpg_ci
= &acl_ci
->ci_parent
->ci_group
->cg_item
;
812 pr_err("Unable to locate tpg_ci\n");
815 wwn_ci
= &tpg_ci
->ci_group
->cg_item
;
817 pr_err("Unable to locate config_item wwn_ci\n");
821 if (iscsit_get_tpg(tpg
) < 0)
824 * iscsit_tpg_set_initiator_node_queue_depth() assumes force=1
826 ret
= iscsit_tpg_set_initiator_node_queue_depth(tpg
,
827 config_item_name(acl_ci
), cmdsn_depth
, 1);
829 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
830 "InitiatorName: %s\n", config_item_name(wwn_ci
),
831 config_item_name(tpg_ci
), cmdsn_depth
,
832 config_item_name(acl_ci
));
835 return (!ret
) ? count
: (ssize_t
)ret
;
838 TF_NACL_BASE_ATTR(lio_target
, cmdsn_depth
, S_IRUGO
| S_IWUSR
);
840 static ssize_t
lio_target_nacl_show_tag(
841 struct se_node_acl
*se_nacl
,
844 return snprintf(page
, PAGE_SIZE
, "%s", se_nacl
->acl_tag
);
847 static ssize_t
lio_target_nacl_store_tag(
848 struct se_node_acl
*se_nacl
,
854 ret
= core_tpg_set_initiator_node_tag(se_nacl
->se_tpg
, se_nacl
, page
);
861 TF_NACL_BASE_ATTR(lio_target
, tag
, S_IRUGO
| S_IWUSR
);
863 static struct configfs_attribute
*lio_target_initiator_attrs
[] = {
864 &lio_target_nacl_info
.attr
,
865 &lio_target_nacl_cmdsn_depth
.attr
,
866 &lio_target_nacl_tag
.attr
,
870 static struct se_node_acl
*lio_tpg_alloc_fabric_acl(
871 struct se_portal_group
*se_tpg
)
873 struct iscsi_node_acl
*acl
;
875 acl
= kzalloc(sizeof(struct iscsi_node_acl
), GFP_KERNEL
);
877 pr_err("Unable to allocate memory for struct iscsi_node_acl\n");
881 return &acl
->se_node_acl
;
884 static struct se_node_acl
*lio_target_make_nodeacl(
885 struct se_portal_group
*se_tpg
,
886 struct config_group
*group
,
889 struct config_group
*stats_cg
;
890 struct iscsi_node_acl
*acl
;
891 struct se_node_acl
*se_nacl_new
, *se_nacl
;
892 struct iscsi_portal_group
*tpg
= container_of(se_tpg
,
893 struct iscsi_portal_group
, tpg_se_tpg
);
896 se_nacl_new
= lio_tpg_alloc_fabric_acl(se_tpg
);
898 return ERR_PTR(-ENOMEM
);
900 cmdsn_depth
= ISCSI_TPG_ATTRIB(tpg
)->default_cmdsn_depth
;
902 * se_nacl_new may be released by core_tpg_add_initiator_node_acl()
903 * when converting a NdoeACL from demo mode -> explict
905 se_nacl
= core_tpg_add_initiator_node_acl(se_tpg
, se_nacl_new
,
910 acl
= container_of(se_nacl
, struct iscsi_node_acl
, se_node_acl
);
911 stats_cg
= &se_nacl
->acl_fabric_stat_group
;
913 stats_cg
->default_groups
= kmalloc(sizeof(struct config_group
*) * 2,
915 if (!stats_cg
->default_groups
) {
916 pr_err("Unable to allocate memory for"
917 " stats_cg->default_groups\n");
918 core_tpg_del_initiator_node_acl(se_tpg
, se_nacl
, 1);
920 return ERR_PTR(-ENOMEM
);
923 stats_cg
->default_groups
[0] = &NODE_STAT_GRPS(acl
)->iscsi_sess_stats_group
;
924 stats_cg
->default_groups
[1] = NULL
;
925 config_group_init_type_name(&NODE_STAT_GRPS(acl
)->iscsi_sess_stats_group
,
926 "iscsi_sess_stats", &iscsi_stat_sess_cit
);
931 static void lio_target_drop_nodeacl(
932 struct se_node_acl
*se_nacl
)
934 struct se_portal_group
*se_tpg
= se_nacl
->se_tpg
;
935 struct iscsi_node_acl
*acl
= container_of(se_nacl
,
936 struct iscsi_node_acl
, se_node_acl
);
937 struct config_item
*df_item
;
938 struct config_group
*stats_cg
;
941 stats_cg
= &acl
->se_node_acl
.acl_fabric_stat_group
;
942 for (i
= 0; stats_cg
->default_groups
[i
]; i
++) {
943 df_item
= &stats_cg
->default_groups
[i
]->cg_item
;
944 stats_cg
->default_groups
[i
] = NULL
;
945 config_item_put(df_item
);
947 kfree(stats_cg
->default_groups
);
949 core_tpg_del_initiator_node_acl(se_tpg
, se_nacl
, 1);
953 /* End items for lio_target_acl_cit */
955 /* Start items for lio_target_tpg_attrib_cit */
957 #define DEF_TPG_ATTRIB(name) \
959 static ssize_t iscsi_tpg_attrib_show_##name( \
960 struct se_portal_group *se_tpg, \
963 struct iscsi_portal_group *tpg = container_of(se_tpg, \
964 struct iscsi_portal_group, tpg_se_tpg); \
967 if (iscsit_get_tpg(tpg) < 0) \
970 rb = sprintf(page, "%u\n", ISCSI_TPG_ATTRIB(tpg)->name); \
971 iscsit_put_tpg(tpg); \
975 static ssize_t iscsi_tpg_attrib_store_##name( \
976 struct se_portal_group *se_tpg, \
980 struct iscsi_portal_group *tpg = container_of(se_tpg, \
981 struct iscsi_portal_group, tpg_se_tpg); \
985 if (iscsit_get_tpg(tpg) < 0) \
988 ret = kstrtou32(page, 0, &val); \
991 ret = iscsit_ta_##name(tpg, val); \
995 iscsit_put_tpg(tpg); \
998 iscsit_put_tpg(tpg); \
1002 #define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode);
1005 * Define iscsi_tpg_attrib_s_authentication
1007 DEF_TPG_ATTRIB(authentication
);
1008 TPG_ATTR(authentication
, S_IRUGO
| S_IWUSR
);
1010 * Define iscsi_tpg_attrib_s_login_timeout
1012 DEF_TPG_ATTRIB(login_timeout
);
1013 TPG_ATTR(login_timeout
, S_IRUGO
| S_IWUSR
);
1015 * Define iscsi_tpg_attrib_s_netif_timeout
1017 DEF_TPG_ATTRIB(netif_timeout
);
1018 TPG_ATTR(netif_timeout
, S_IRUGO
| S_IWUSR
);
1020 * Define iscsi_tpg_attrib_s_generate_node_acls
1022 DEF_TPG_ATTRIB(generate_node_acls
);
1023 TPG_ATTR(generate_node_acls
, S_IRUGO
| S_IWUSR
);
1025 * Define iscsi_tpg_attrib_s_default_cmdsn_depth
1027 DEF_TPG_ATTRIB(default_cmdsn_depth
);
1028 TPG_ATTR(default_cmdsn_depth
, S_IRUGO
| S_IWUSR
);
1030 Define iscsi_tpg_attrib_s_cache_dynamic_acls
1032 DEF_TPG_ATTRIB(cache_dynamic_acls
);
1033 TPG_ATTR(cache_dynamic_acls
, S_IRUGO
| S_IWUSR
);
1035 * Define iscsi_tpg_attrib_s_demo_mode_write_protect
1037 DEF_TPG_ATTRIB(demo_mode_write_protect
);
1038 TPG_ATTR(demo_mode_write_protect
, S_IRUGO
| S_IWUSR
);
1040 * Define iscsi_tpg_attrib_s_prod_mode_write_protect
1042 DEF_TPG_ATTRIB(prod_mode_write_protect
);
1043 TPG_ATTR(prod_mode_write_protect
, S_IRUGO
| S_IWUSR
);
1045 static struct configfs_attribute
*lio_target_tpg_attrib_attrs
[] = {
1046 &iscsi_tpg_attrib_authentication
.attr
,
1047 &iscsi_tpg_attrib_login_timeout
.attr
,
1048 &iscsi_tpg_attrib_netif_timeout
.attr
,
1049 &iscsi_tpg_attrib_generate_node_acls
.attr
,
1050 &iscsi_tpg_attrib_default_cmdsn_depth
.attr
,
1051 &iscsi_tpg_attrib_cache_dynamic_acls
.attr
,
1052 &iscsi_tpg_attrib_demo_mode_write_protect
.attr
,
1053 &iscsi_tpg_attrib_prod_mode_write_protect
.attr
,
1057 /* End items for lio_target_tpg_attrib_cit */
1059 /* Start items for lio_target_tpg_auth_cit */
1061 #define __DEF_TPG_AUTH_STR(prefix, name, flags) \
1062 static ssize_t __iscsi_##prefix##_show_##name( \
1063 struct se_portal_group *se_tpg, \
1066 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1067 struct iscsi_portal_group, tpg_se_tpg); \
1068 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1070 if (!capable(CAP_SYS_ADMIN)) \
1073 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
1076 static ssize_t __iscsi_##prefix##_store_##name( \
1077 struct se_portal_group *se_tpg, \
1081 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1082 struct iscsi_portal_group, tpg_se_tpg); \
1083 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1085 if (!capable(CAP_SYS_ADMIN)) \
1088 snprintf(auth->name, sizeof(auth->name), "%s", page); \
1089 if (!(strncmp("NULL", auth->name, 4))) \
1090 auth->naf_flags &= ~flags; \
1092 auth->naf_flags |= flags; \
1094 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
1095 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
1096 auth->authenticate_target = 1; \
1098 auth->authenticate_target = 0; \
1103 #define __DEF_TPG_AUTH_INT(prefix, name) \
1104 static ssize_t __iscsi_##prefix##_show_##name( \
1105 struct se_portal_group *se_tpg, \
1108 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1109 struct iscsi_portal_group, tpg_se_tpg); \
1110 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1112 if (!capable(CAP_SYS_ADMIN)) \
1115 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
1118 #define DEF_TPG_AUTH_STR(name, flags) \
1119 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
1120 static ssize_t iscsi_tpg_auth_show_##name( \
1121 struct se_portal_group *se_tpg, \
1124 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1127 static ssize_t iscsi_tpg_auth_store_##name( \
1128 struct se_portal_group *se_tpg, \
1132 return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \
1135 #define DEF_TPG_AUTH_INT(name) \
1136 __DEF_TPG_AUTH_INT(tpg_auth, name) \
1137 static ssize_t iscsi_tpg_auth_show_##name( \
1138 struct se_portal_group *se_tpg, \
1141 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1144 #define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode);
1145 #define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name);
1148 * * One-way authentication userid
1150 DEF_TPG_AUTH_STR(userid
, NAF_USERID_SET
);
1151 TPG_AUTH_ATTR(userid
, S_IRUGO
| S_IWUSR
);
1153 * * One-way authentication password
1155 DEF_TPG_AUTH_STR(password
, NAF_PASSWORD_SET
);
1156 TPG_AUTH_ATTR(password
, S_IRUGO
| S_IWUSR
);
1158 * * Enforce mutual authentication
1160 DEF_TPG_AUTH_INT(authenticate_target
);
1161 TPG_AUTH_ATTR_RO(authenticate_target
);
1163 * * Mutual authentication userid
1165 DEF_TPG_AUTH_STR(userid_mutual
, NAF_USERID_IN_SET
);
1166 TPG_AUTH_ATTR(userid_mutual
, S_IRUGO
| S_IWUSR
);
1168 * * Mutual authentication password
1170 DEF_TPG_AUTH_STR(password_mutual
, NAF_PASSWORD_IN_SET
);
1171 TPG_AUTH_ATTR(password_mutual
, S_IRUGO
| S_IWUSR
);
1173 static struct configfs_attribute
*lio_target_tpg_auth_attrs
[] = {
1174 &iscsi_tpg_auth_userid
.attr
,
1175 &iscsi_tpg_auth_password
.attr
,
1176 &iscsi_tpg_auth_authenticate_target
.attr
,
1177 &iscsi_tpg_auth_userid_mutual
.attr
,
1178 &iscsi_tpg_auth_password_mutual
.attr
,
1182 /* End items for lio_target_tpg_auth_cit */
1184 /* Start items for lio_target_tpg_param_cit */
1186 #define DEF_TPG_PARAM(name) \
1187 static ssize_t iscsi_tpg_param_show_##name( \
1188 struct se_portal_group *se_tpg, \
1191 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1192 struct iscsi_portal_group, tpg_se_tpg); \
1193 struct iscsi_param *param; \
1196 if (iscsit_get_tpg(tpg) < 0) \
1199 param = iscsi_find_param_from_key(__stringify(name), \
1202 iscsit_put_tpg(tpg); \
1205 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
1207 iscsit_put_tpg(tpg); \
1210 static ssize_t iscsi_tpg_param_store_##name( \
1211 struct se_portal_group *se_tpg, \
1215 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1216 struct iscsi_portal_group, tpg_se_tpg); \
1220 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
1223 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
1224 if (isspace(buf[len-1])) \
1225 buf[len-1] = '\0'; /* Kill newline */ \
1227 if (iscsit_get_tpg(tpg) < 0) { \
1232 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
1237 iscsit_put_tpg(tpg); \
1241 iscsit_put_tpg(tpg); \
1245 #define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode);
1247 DEF_TPG_PARAM(AuthMethod
);
1248 TPG_PARAM_ATTR(AuthMethod
, S_IRUGO
| S_IWUSR
);
1250 DEF_TPG_PARAM(HeaderDigest
);
1251 TPG_PARAM_ATTR(HeaderDigest
, S_IRUGO
| S_IWUSR
);
1253 DEF_TPG_PARAM(DataDigest
);
1254 TPG_PARAM_ATTR(DataDigest
, S_IRUGO
| S_IWUSR
);
1256 DEF_TPG_PARAM(MaxConnections
);
1257 TPG_PARAM_ATTR(MaxConnections
, S_IRUGO
| S_IWUSR
);
1259 DEF_TPG_PARAM(TargetAlias
);
1260 TPG_PARAM_ATTR(TargetAlias
, S_IRUGO
| S_IWUSR
);
1262 DEF_TPG_PARAM(InitialR2T
);
1263 TPG_PARAM_ATTR(InitialR2T
, S_IRUGO
| S_IWUSR
);
1265 DEF_TPG_PARAM(ImmediateData
);
1266 TPG_PARAM_ATTR(ImmediateData
, S_IRUGO
| S_IWUSR
);
1268 DEF_TPG_PARAM(MaxRecvDataSegmentLength
);
1269 TPG_PARAM_ATTR(MaxRecvDataSegmentLength
, S_IRUGO
| S_IWUSR
);
1271 DEF_TPG_PARAM(MaxXmitDataSegmentLength
);
1272 TPG_PARAM_ATTR(MaxXmitDataSegmentLength
, S_IRUGO
| S_IWUSR
);
1274 DEF_TPG_PARAM(MaxBurstLength
);
1275 TPG_PARAM_ATTR(MaxBurstLength
, S_IRUGO
| S_IWUSR
);
1277 DEF_TPG_PARAM(FirstBurstLength
);
1278 TPG_PARAM_ATTR(FirstBurstLength
, S_IRUGO
| S_IWUSR
);
1280 DEF_TPG_PARAM(DefaultTime2Wait
);
1281 TPG_PARAM_ATTR(DefaultTime2Wait
, S_IRUGO
| S_IWUSR
);
1283 DEF_TPG_PARAM(DefaultTime2Retain
);
1284 TPG_PARAM_ATTR(DefaultTime2Retain
, S_IRUGO
| S_IWUSR
);
1286 DEF_TPG_PARAM(MaxOutstandingR2T
);
1287 TPG_PARAM_ATTR(MaxOutstandingR2T
, S_IRUGO
| S_IWUSR
);
1289 DEF_TPG_PARAM(DataPDUInOrder
);
1290 TPG_PARAM_ATTR(DataPDUInOrder
, S_IRUGO
| S_IWUSR
);
1292 DEF_TPG_PARAM(DataSequenceInOrder
);
1293 TPG_PARAM_ATTR(DataSequenceInOrder
, S_IRUGO
| S_IWUSR
);
1295 DEF_TPG_PARAM(ErrorRecoveryLevel
);
1296 TPG_PARAM_ATTR(ErrorRecoveryLevel
, S_IRUGO
| S_IWUSR
);
1298 DEF_TPG_PARAM(IFMarker
);
1299 TPG_PARAM_ATTR(IFMarker
, S_IRUGO
| S_IWUSR
);
1301 DEF_TPG_PARAM(OFMarker
);
1302 TPG_PARAM_ATTR(OFMarker
, S_IRUGO
| S_IWUSR
);
1304 DEF_TPG_PARAM(IFMarkInt
);
1305 TPG_PARAM_ATTR(IFMarkInt
, S_IRUGO
| S_IWUSR
);
1307 DEF_TPG_PARAM(OFMarkInt
);
1308 TPG_PARAM_ATTR(OFMarkInt
, S_IRUGO
| S_IWUSR
);
1310 static struct configfs_attribute
*lio_target_tpg_param_attrs
[] = {
1311 &iscsi_tpg_param_AuthMethod
.attr
,
1312 &iscsi_tpg_param_HeaderDigest
.attr
,
1313 &iscsi_tpg_param_DataDigest
.attr
,
1314 &iscsi_tpg_param_MaxConnections
.attr
,
1315 &iscsi_tpg_param_TargetAlias
.attr
,
1316 &iscsi_tpg_param_InitialR2T
.attr
,
1317 &iscsi_tpg_param_ImmediateData
.attr
,
1318 &iscsi_tpg_param_MaxRecvDataSegmentLength
.attr
,
1319 &iscsi_tpg_param_MaxXmitDataSegmentLength
.attr
,
1320 &iscsi_tpg_param_MaxBurstLength
.attr
,
1321 &iscsi_tpg_param_FirstBurstLength
.attr
,
1322 &iscsi_tpg_param_DefaultTime2Wait
.attr
,
1323 &iscsi_tpg_param_DefaultTime2Retain
.attr
,
1324 &iscsi_tpg_param_MaxOutstandingR2T
.attr
,
1325 &iscsi_tpg_param_DataPDUInOrder
.attr
,
1326 &iscsi_tpg_param_DataSequenceInOrder
.attr
,
1327 &iscsi_tpg_param_ErrorRecoveryLevel
.attr
,
1328 &iscsi_tpg_param_IFMarker
.attr
,
1329 &iscsi_tpg_param_OFMarker
.attr
,
1330 &iscsi_tpg_param_IFMarkInt
.attr
,
1331 &iscsi_tpg_param_OFMarkInt
.attr
,
1335 /* End items for lio_target_tpg_param_cit */
1337 /* Start items for lio_target_tpg_cit */
1339 static ssize_t
lio_target_tpg_show_enable(
1340 struct se_portal_group
*se_tpg
,
1343 struct iscsi_portal_group
*tpg
= container_of(se_tpg
,
1344 struct iscsi_portal_group
, tpg_se_tpg
);
1347 spin_lock(&tpg
->tpg_state_lock
);
1348 len
= sprintf(page
, "%d\n",
1349 (tpg
->tpg_state
== TPG_STATE_ACTIVE
) ? 1 : 0);
1350 spin_unlock(&tpg
->tpg_state_lock
);
1355 static ssize_t
lio_target_tpg_store_enable(
1356 struct se_portal_group
*se_tpg
,
1360 struct iscsi_portal_group
*tpg
= container_of(se_tpg
,
1361 struct iscsi_portal_group
, tpg_se_tpg
);
1365 ret
= kstrtou32(page
, 0, &op
);
1368 if ((op
!= 1) && (op
!= 0)) {
1369 pr_err("Illegal value for tpg_enable: %u\n", op
);
1373 ret
= iscsit_get_tpg(tpg
);
1378 ret
= iscsit_tpg_enable_portal_group(tpg
);
1383 * iscsit_tpg_disable_portal_group() assumes force=1
1385 ret
= iscsit_tpg_disable_portal_group(tpg
, 1);
1390 iscsit_put_tpg(tpg
);
1393 iscsit_put_tpg(tpg
);
1397 TF_TPG_BASE_ATTR(lio_target
, enable
, S_IRUGO
| S_IWUSR
);
1399 static struct configfs_attribute
*lio_target_tpg_attrs
[] = {
1400 &lio_target_tpg_enable
.attr
,
1404 /* End items for lio_target_tpg_cit */
1406 /* Start items for lio_target_tiqn_cit */
1408 static struct se_portal_group
*lio_target_tiqn_addtpg(
1410 struct config_group
*group
,
1413 struct iscsi_portal_group
*tpg
;
1414 struct iscsi_tiqn
*tiqn
;
1419 tiqn
= container_of(wwn
, struct iscsi_tiqn
, tiqn_wwn
);
1421 * Only tpgt_# directory groups can be created below
1422 * target/iscsi/iqn.superturodiskarry/
1424 tpgt_str
= strstr(name
, "tpgt_");
1426 pr_err("Unable to locate \"tpgt_#\" directory"
1430 tpgt_str
+= 5; /* Skip ahead of "tpgt_" */
1431 ret
= kstrtou16(tpgt_str
, 0, &tpgt
);
1435 tpg
= iscsit_alloc_portal_group(tiqn
, tpgt
);
1439 ret
= core_tpg_register(
1440 &lio_target_fabric_configfs
->tf_ops
,
1441 wwn
, &tpg
->tpg_se_tpg
, tpg
,
1442 TRANSPORT_TPG_TYPE_NORMAL
);
1446 ret
= iscsit_tpg_add_portal_group(tiqn
, tpg
);
1450 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn
->tiqn
);
1451 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1453 return &tpg
->tpg_se_tpg
;
1455 core_tpg_deregister(&tpg
->tpg_se_tpg
);
1460 static void lio_target_tiqn_deltpg(struct se_portal_group
*se_tpg
)
1462 struct iscsi_portal_group
*tpg
;
1463 struct iscsi_tiqn
*tiqn
;
1465 tpg
= container_of(se_tpg
, struct iscsi_portal_group
, tpg_se_tpg
);
1466 tiqn
= tpg
->tpg_tiqn
;
1468 * iscsit_tpg_del_portal_group() assumes force=1
1470 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1471 iscsit_tpg_del_portal_group(tiqn
, tpg
, 1);
1474 /* End items for lio_target_tiqn_cit */
1476 /* Start LIO-Target TIQN struct contig_item lio_target_cit */
1478 static ssize_t
lio_target_wwn_show_attr_lio_version(
1479 struct target_fabric_configfs
*tf
,
1482 return sprintf(page
, "Datera Inc. iSCSI Target "ISCSIT_VERSION
"\n");
1485 TF_WWN_ATTR_RO(lio_target
, lio_version
);
1487 static struct configfs_attribute
*lio_target_wwn_attrs
[] = {
1488 &lio_target_wwn_lio_version
.attr
,
1492 static struct se_wwn
*lio_target_call_coreaddtiqn(
1493 struct target_fabric_configfs
*tf
,
1494 struct config_group
*group
,
1497 struct config_group
*stats_cg
;
1498 struct iscsi_tiqn
*tiqn
;
1500 tiqn
= iscsit_add_tiqn((unsigned char *)name
);
1502 return ERR_CAST(tiqn
);
1504 * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group.
1506 stats_cg
= &tiqn
->tiqn_wwn
.fabric_stat_group
;
1508 stats_cg
->default_groups
= kmalloc(sizeof(struct config_group
*) * 6,
1510 if (!stats_cg
->default_groups
) {
1511 pr_err("Unable to allocate memory for"
1512 " stats_cg->default_groups\n");
1513 iscsit_del_tiqn(tiqn
);
1514 return ERR_PTR(-ENOMEM
);
1517 stats_cg
->default_groups
[0] = &WWN_STAT_GRPS(tiqn
)->iscsi_instance_group
;
1518 stats_cg
->default_groups
[1] = &WWN_STAT_GRPS(tiqn
)->iscsi_sess_err_group
;
1519 stats_cg
->default_groups
[2] = &WWN_STAT_GRPS(tiqn
)->iscsi_tgt_attr_group
;
1520 stats_cg
->default_groups
[3] = &WWN_STAT_GRPS(tiqn
)->iscsi_login_stats_group
;
1521 stats_cg
->default_groups
[4] = &WWN_STAT_GRPS(tiqn
)->iscsi_logout_stats_group
;
1522 stats_cg
->default_groups
[5] = NULL
;
1523 config_group_init_type_name(&WWN_STAT_GRPS(tiqn
)->iscsi_instance_group
,
1524 "iscsi_instance", &iscsi_stat_instance_cit
);
1525 config_group_init_type_name(&WWN_STAT_GRPS(tiqn
)->iscsi_sess_err_group
,
1526 "iscsi_sess_err", &iscsi_stat_sess_err_cit
);
1527 config_group_init_type_name(&WWN_STAT_GRPS(tiqn
)->iscsi_tgt_attr_group
,
1528 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit
);
1529 config_group_init_type_name(&WWN_STAT_GRPS(tiqn
)->iscsi_login_stats_group
,
1530 "iscsi_login_stats", &iscsi_stat_login_cit
);
1531 config_group_init_type_name(&WWN_STAT_GRPS(tiqn
)->iscsi_logout_stats_group
,
1532 "iscsi_logout_stats", &iscsi_stat_logout_cit
);
1534 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn
->tiqn
);
1535 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1537 return &tiqn
->tiqn_wwn
;
1540 static void lio_target_call_coredeltiqn(
1543 struct iscsi_tiqn
*tiqn
= container_of(wwn
, struct iscsi_tiqn
, tiqn_wwn
);
1544 struct config_item
*df_item
;
1545 struct config_group
*stats_cg
;
1548 stats_cg
= &tiqn
->tiqn_wwn
.fabric_stat_group
;
1549 for (i
= 0; stats_cg
->default_groups
[i
]; i
++) {
1550 df_item
= &stats_cg
->default_groups
[i
]->cg_item
;
1551 stats_cg
->default_groups
[i
] = NULL
;
1552 config_item_put(df_item
);
1554 kfree(stats_cg
->default_groups
);
1556 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1558 iscsit_del_tiqn(tiqn
);
1561 /* End LIO-Target TIQN struct contig_lio_target_cit */
1563 /* Start lio_target_discovery_auth_cit */
1565 #define DEF_DISC_AUTH_STR(name, flags) \
1566 __DEF_NACL_AUTH_STR(disc, name, flags) \
1567 static ssize_t iscsi_disc_show_##name( \
1568 struct target_fabric_configfs *tf, \
1571 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1574 static ssize_t iscsi_disc_store_##name( \
1575 struct target_fabric_configfs *tf, \
1579 return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \
1583 #define DEF_DISC_AUTH_INT(name) \
1584 __DEF_NACL_AUTH_INT(disc, name) \
1585 static ssize_t iscsi_disc_show_##name( \
1586 struct target_fabric_configfs *tf, \
1589 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1593 #define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode)
1594 #define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name)
1597 * One-way authentication userid
1599 DEF_DISC_AUTH_STR(userid
, NAF_USERID_SET
);
1600 DISC_AUTH_ATTR(userid
, S_IRUGO
| S_IWUSR
);
1602 * One-way authentication password
1604 DEF_DISC_AUTH_STR(password
, NAF_PASSWORD_SET
);
1605 DISC_AUTH_ATTR(password
, S_IRUGO
| S_IWUSR
);
1607 * Enforce mutual authentication
1609 DEF_DISC_AUTH_INT(authenticate_target
);
1610 DISC_AUTH_ATTR_RO(authenticate_target
);
1612 * Mutual authentication userid
1614 DEF_DISC_AUTH_STR(userid_mutual
, NAF_USERID_IN_SET
);
1615 DISC_AUTH_ATTR(userid_mutual
, S_IRUGO
| S_IWUSR
);
1617 * Mutual authentication password
1619 DEF_DISC_AUTH_STR(password_mutual
, NAF_PASSWORD_IN_SET
);
1620 DISC_AUTH_ATTR(password_mutual
, S_IRUGO
| S_IWUSR
);
1623 * enforce_discovery_auth
1625 static ssize_t
iscsi_disc_show_enforce_discovery_auth(
1626 struct target_fabric_configfs
*tf
,
1629 struct iscsi_node_auth
*discovery_auth
= &iscsit_global
->discovery_acl
.node_auth
;
1631 return sprintf(page
, "%d\n", discovery_auth
->enforce_discovery_auth
);
1634 static ssize_t
iscsi_disc_store_enforce_discovery_auth(
1635 struct target_fabric_configfs
*tf
,
1639 struct iscsi_param
*param
;
1640 struct iscsi_portal_group
*discovery_tpg
= iscsit_global
->discovery_tpg
;
1644 err
= kstrtou32(page
, 0, &op
);
1647 if ((op
!= 1) && (op
!= 0)) {
1648 pr_err("Illegal value for enforce_discovery_auth:"
1653 if (!discovery_tpg
) {
1654 pr_err("iscsit_global->discovery_tpg is NULL\n");
1658 param
= iscsi_find_param_from_key(AUTHMETHOD
,
1659 discovery_tpg
->param_list
);
1665 * Reset the AuthMethod key to CHAP.
1667 if (iscsi_update_param_value(param
, CHAP
) < 0)
1670 discovery_tpg
->tpg_attrib
.authentication
= 1;
1671 iscsit_global
->discovery_acl
.node_auth
.enforce_discovery_auth
= 1;
1672 pr_debug("LIO-CORE[0] Successfully enabled"
1673 " authentication enforcement for iSCSI"
1674 " Discovery TPG\n");
1677 * Reset the AuthMethod key to CHAP,None
1679 if (iscsi_update_param_value(param
, "CHAP,None") < 0)
1682 discovery_tpg
->tpg_attrib
.authentication
= 0;
1683 iscsit_global
->discovery_acl
.node_auth
.enforce_discovery_auth
= 0;
1684 pr_debug("LIO-CORE[0] Successfully disabled"
1685 " authentication enforcement for iSCSI"
1686 " Discovery TPG\n");
1692 DISC_AUTH_ATTR(enforce_discovery_auth
, S_IRUGO
| S_IWUSR
);
1694 static struct configfs_attribute
*lio_target_discovery_auth_attrs
[] = {
1695 &iscsi_disc_userid
.attr
,
1696 &iscsi_disc_password
.attr
,
1697 &iscsi_disc_authenticate_target
.attr
,
1698 &iscsi_disc_userid_mutual
.attr
,
1699 &iscsi_disc_password_mutual
.attr
,
1700 &iscsi_disc_enforce_discovery_auth
.attr
,
1704 /* End lio_target_discovery_auth_cit */
1706 /* Start functions for target_core_fabric_ops */
1708 static char *iscsi_get_fabric_name(void)
1713 static u32
iscsi_get_task_tag(struct se_cmd
*se_cmd
)
1715 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1717 /* only used for printks or comparism with ->ref_task_tag */
1718 return (__force u32
)cmd
->init_task_tag
;
1721 static int iscsi_get_cmd_state(struct se_cmd
*se_cmd
)
1723 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1725 return cmd
->i_state
;
1728 static u32
lio_sess_get_index(struct se_session
*se_sess
)
1730 struct iscsi_session
*sess
= se_sess
->fabric_sess_ptr
;
1732 return sess
->session_index
;
1735 static u32
lio_sess_get_initiator_sid(
1736 struct se_session
*se_sess
,
1740 struct iscsi_session
*sess
= se_sess
->fabric_sess_ptr
;
1742 * iSCSI Initiator Session Identifier from RFC-3720.
1744 return snprintf(buf
, size
, "%02x%02x%02x%02x%02x%02x",
1745 sess
->isid
[0], sess
->isid
[1], sess
->isid
[2],
1746 sess
->isid
[3], sess
->isid
[4], sess
->isid
[5]);
1749 static int lio_queue_data_in(struct se_cmd
*se_cmd
)
1751 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1753 cmd
->i_state
= ISTATE_SEND_DATAIN
;
1754 cmd
->conn
->conn_transport
->iscsit_queue_data_in(cmd
->conn
, cmd
);
1759 static int lio_write_pending(struct se_cmd
*se_cmd
)
1761 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1762 struct iscsi_conn
*conn
= cmd
->conn
;
1764 if (!cmd
->immediate_data
&& !cmd
->unsolicited_data
)
1765 return conn
->conn_transport
->iscsit_get_dataout(conn
, cmd
, false);
1770 static int lio_write_pending_status(struct se_cmd
*se_cmd
)
1772 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1775 spin_lock_bh(&cmd
->istate_lock
);
1776 ret
= !(cmd
->cmd_flags
& ICF_GOT_LAST_DATAOUT
);
1777 spin_unlock_bh(&cmd
->istate_lock
);
1782 static int lio_queue_status(struct se_cmd
*se_cmd
)
1784 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1786 cmd
->i_state
= ISTATE_SEND_STATUS
;
1788 if (cmd
->se_cmd
.scsi_status
|| cmd
->sense_reason
) {
1789 iscsit_add_cmd_to_response_queue(cmd
, cmd
->conn
, cmd
->i_state
);
1792 cmd
->conn
->conn_transport
->iscsit_queue_status(cmd
->conn
, cmd
);
1797 static void lio_queue_tm_rsp(struct se_cmd
*se_cmd
)
1799 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1801 cmd
->i_state
= ISTATE_SEND_TASKMGTRSP
;
1802 iscsit_add_cmd_to_response_queue(cmd
, cmd
->conn
, cmd
->i_state
);
1805 static char *lio_tpg_get_endpoint_wwn(struct se_portal_group
*se_tpg
)
1807 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1809 return &tpg
->tpg_tiqn
->tiqn
[0];
1812 static u16
lio_tpg_get_tag(struct se_portal_group
*se_tpg
)
1814 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1819 static u32
lio_tpg_get_default_depth(struct se_portal_group
*se_tpg
)
1821 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1823 return ISCSI_TPG_ATTRIB(tpg
)->default_cmdsn_depth
;
1826 static int lio_tpg_check_demo_mode(struct se_portal_group
*se_tpg
)
1828 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1830 return ISCSI_TPG_ATTRIB(tpg
)->generate_node_acls
;
1833 static int lio_tpg_check_demo_mode_cache(struct se_portal_group
*se_tpg
)
1835 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1837 return ISCSI_TPG_ATTRIB(tpg
)->cache_dynamic_acls
;
1840 static int lio_tpg_check_demo_mode_write_protect(
1841 struct se_portal_group
*se_tpg
)
1843 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1845 return ISCSI_TPG_ATTRIB(tpg
)->demo_mode_write_protect
;
1848 static int lio_tpg_check_prod_mode_write_protect(
1849 struct se_portal_group
*se_tpg
)
1851 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1853 return ISCSI_TPG_ATTRIB(tpg
)->prod_mode_write_protect
;
1856 static void lio_tpg_release_fabric_acl(
1857 struct se_portal_group
*se_tpg
,
1858 struct se_node_acl
*se_acl
)
1860 struct iscsi_node_acl
*acl
= container_of(se_acl
,
1861 struct iscsi_node_acl
, se_node_acl
);
1866 * Called with spin_lock_bh(struct se_portal_group->session_lock) held..
1868 * Also, this function calls iscsit_inc_session_usage_count() on the
1869 * struct iscsi_session in question.
1871 static int lio_tpg_shutdown_session(struct se_session
*se_sess
)
1873 struct iscsi_session
*sess
= se_sess
->fabric_sess_ptr
;
1875 spin_lock(&sess
->conn_lock
);
1876 if (atomic_read(&sess
->session_fall_back_to_erl0
) ||
1877 atomic_read(&sess
->session_logout
) ||
1878 (sess
->time2retain_timer_flags
& ISCSI_TF_EXPIRED
)) {
1879 spin_unlock(&sess
->conn_lock
);
1882 atomic_set(&sess
->session_reinstatement
, 1);
1883 spin_unlock(&sess
->conn_lock
);
1885 iscsit_stop_time2retain_timer(sess
);
1886 iscsit_stop_session(sess
, 1, 1);
1892 * Calls iscsit_dec_session_usage_count() as inverse of
1893 * lio_tpg_shutdown_session()
1895 static void lio_tpg_close_session(struct se_session
*se_sess
)
1897 struct iscsi_session
*sess
= se_sess
->fabric_sess_ptr
;
1899 * If the iSCSI Session for the iSCSI Initiator Node exists,
1900 * forcefully shutdown the iSCSI NEXUS.
1902 iscsit_close_session(sess
);
1905 static u32
lio_tpg_get_inst_index(struct se_portal_group
*se_tpg
)
1907 struct iscsi_portal_group
*tpg
= se_tpg
->se_tpg_fabric_ptr
;
1909 return tpg
->tpg_tiqn
->tiqn_index
;
1912 static void lio_set_default_node_attributes(struct se_node_acl
*se_acl
)
1914 struct iscsi_node_acl
*acl
= container_of(se_acl
, struct iscsi_node_acl
,
1917 ISCSI_NODE_ATTRIB(acl
)->nacl
= acl
;
1918 iscsit_set_default_node_attribues(acl
);
1921 static int lio_check_stop_free(struct se_cmd
*se_cmd
)
1923 return target_put_sess_cmd(se_cmd
->se_sess
, se_cmd
);
1926 static void lio_release_cmd(struct se_cmd
*se_cmd
)
1928 struct iscsi_cmd
*cmd
= container_of(se_cmd
, struct iscsi_cmd
, se_cmd
);
1930 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd
);
1931 iscsit_release_cmd(cmd
);
1934 /* End functions for target_core_fabric_ops */
1936 int iscsi_target_register_configfs(void)
1938 struct target_fabric_configfs
*fabric
;
1941 lio_target_fabric_configfs
= NULL
;
1942 fabric
= target_fabric_configfs_init(THIS_MODULE
, "iscsi");
1943 if (IS_ERR(fabric
)) {
1944 pr_err("target_fabric_configfs_init() for"
1945 " LIO-Target failed!\n");
1946 return PTR_ERR(fabric
);
1949 * Setup the fabric API of function pointers used by target_core_mod..
1951 fabric
->tf_ops
.get_fabric_name
= &iscsi_get_fabric_name
;
1952 fabric
->tf_ops
.get_fabric_proto_ident
= &iscsi_get_fabric_proto_ident
;
1953 fabric
->tf_ops
.tpg_get_wwn
= &lio_tpg_get_endpoint_wwn
;
1954 fabric
->tf_ops
.tpg_get_tag
= &lio_tpg_get_tag
;
1955 fabric
->tf_ops
.tpg_get_default_depth
= &lio_tpg_get_default_depth
;
1956 fabric
->tf_ops
.tpg_get_pr_transport_id
= &iscsi_get_pr_transport_id
;
1957 fabric
->tf_ops
.tpg_get_pr_transport_id_len
=
1958 &iscsi_get_pr_transport_id_len
;
1959 fabric
->tf_ops
.tpg_parse_pr_out_transport_id
=
1960 &iscsi_parse_pr_out_transport_id
;
1961 fabric
->tf_ops
.tpg_check_demo_mode
= &lio_tpg_check_demo_mode
;
1962 fabric
->tf_ops
.tpg_check_demo_mode_cache
=
1963 &lio_tpg_check_demo_mode_cache
;
1964 fabric
->tf_ops
.tpg_check_demo_mode_write_protect
=
1965 &lio_tpg_check_demo_mode_write_protect
;
1966 fabric
->tf_ops
.tpg_check_prod_mode_write_protect
=
1967 &lio_tpg_check_prod_mode_write_protect
;
1968 fabric
->tf_ops
.tpg_alloc_fabric_acl
= &lio_tpg_alloc_fabric_acl
;
1969 fabric
->tf_ops
.tpg_release_fabric_acl
= &lio_tpg_release_fabric_acl
;
1970 fabric
->tf_ops
.tpg_get_inst_index
= &lio_tpg_get_inst_index
;
1971 fabric
->tf_ops
.check_stop_free
= &lio_check_stop_free
,
1972 fabric
->tf_ops
.release_cmd
= &lio_release_cmd
;
1973 fabric
->tf_ops
.shutdown_session
= &lio_tpg_shutdown_session
;
1974 fabric
->tf_ops
.close_session
= &lio_tpg_close_session
;
1975 fabric
->tf_ops
.sess_get_index
= &lio_sess_get_index
;
1976 fabric
->tf_ops
.sess_get_initiator_sid
= &lio_sess_get_initiator_sid
;
1977 fabric
->tf_ops
.write_pending
= &lio_write_pending
;
1978 fabric
->tf_ops
.write_pending_status
= &lio_write_pending_status
;
1979 fabric
->tf_ops
.set_default_node_attributes
=
1980 &lio_set_default_node_attributes
;
1981 fabric
->tf_ops
.get_task_tag
= &iscsi_get_task_tag
;
1982 fabric
->tf_ops
.get_cmd_state
= &iscsi_get_cmd_state
;
1983 fabric
->tf_ops
.queue_data_in
= &lio_queue_data_in
;
1984 fabric
->tf_ops
.queue_status
= &lio_queue_status
;
1985 fabric
->tf_ops
.queue_tm_rsp
= &lio_queue_tm_rsp
;
1987 * Setup function pointers for generic logic in target_core_fabric_configfs.c
1989 fabric
->tf_ops
.fabric_make_wwn
= &lio_target_call_coreaddtiqn
;
1990 fabric
->tf_ops
.fabric_drop_wwn
= &lio_target_call_coredeltiqn
;
1991 fabric
->tf_ops
.fabric_make_tpg
= &lio_target_tiqn_addtpg
;
1992 fabric
->tf_ops
.fabric_drop_tpg
= &lio_target_tiqn_deltpg
;
1993 fabric
->tf_ops
.fabric_post_link
= NULL
;
1994 fabric
->tf_ops
.fabric_pre_unlink
= NULL
;
1995 fabric
->tf_ops
.fabric_make_np
= &lio_target_call_addnptotpg
;
1996 fabric
->tf_ops
.fabric_drop_np
= &lio_target_call_delnpfromtpg
;
1997 fabric
->tf_ops
.fabric_make_nodeacl
= &lio_target_make_nodeacl
;
1998 fabric
->tf_ops
.fabric_drop_nodeacl
= &lio_target_drop_nodeacl
;
2000 * Setup default attribute lists for various fabric->tf_cit_tmpl
2001 * sturct config_item_type's
2003 TF_CIT_TMPL(fabric
)->tfc_discovery_cit
.ct_attrs
= lio_target_discovery_auth_attrs
;
2004 TF_CIT_TMPL(fabric
)->tfc_wwn_cit
.ct_attrs
= lio_target_wwn_attrs
;
2005 TF_CIT_TMPL(fabric
)->tfc_tpg_base_cit
.ct_attrs
= lio_target_tpg_attrs
;
2006 TF_CIT_TMPL(fabric
)->tfc_tpg_attrib_cit
.ct_attrs
= lio_target_tpg_attrib_attrs
;
2007 TF_CIT_TMPL(fabric
)->tfc_tpg_auth_cit
.ct_attrs
= lio_target_tpg_auth_attrs
;
2008 TF_CIT_TMPL(fabric
)->tfc_tpg_param_cit
.ct_attrs
= lio_target_tpg_param_attrs
;
2009 TF_CIT_TMPL(fabric
)->tfc_tpg_np_base_cit
.ct_attrs
= lio_target_portal_attrs
;
2010 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_base_cit
.ct_attrs
= lio_target_initiator_attrs
;
2011 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_attrib_cit
.ct_attrs
= lio_target_nacl_attrib_attrs
;
2012 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_auth_cit
.ct_attrs
= lio_target_nacl_auth_attrs
;
2013 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_param_cit
.ct_attrs
= lio_target_nacl_param_attrs
;
2015 ret
= target_fabric_configfs_register(fabric
);
2017 pr_err("target_fabric_configfs_register() for"
2018 " LIO-Target failed!\n");
2019 target_fabric_configfs_free(fabric
);
2023 lio_target_fabric_configfs
= fabric
;
2024 pr_debug("LIO_TARGET[0] - Set fabric ->"
2025 " lio_target_fabric_configfs\n");
2030 void iscsi_target_deregister_configfs(void)
2032 if (!lio_target_fabric_configfs
)
2035 * Shutdown discovery sessions and disable discovery TPG
2037 if (iscsit_global
->discovery_tpg
)
2038 iscsit_tpg_disable_portal_group(iscsit_global
->discovery_tpg
, 1);
2040 target_fabric_configfs_deregister(lio_target_fabric_configfs
);
2041 lio_target_fabric_configfs
= NULL
;
2042 pr_debug("LIO_TARGET[0] - Cleared"
2043 " lio_target_fabric_configfs\n");