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 <target/iscsi/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 <target/iscsi/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", nacl->node_attrib.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)) \
477 if (count >= sizeof(auth->name)) \
479 snprintf(auth->name, sizeof(auth->name), "%s", page); \
480 if (!strncmp("NULL", auth->name, 4)) \
481 auth->naf_flags &= ~flags; \
483 auth->naf_flags |= flags; \
485 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
486 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
487 auth->authenticate_target = 1; \
489 auth->authenticate_target = 0; \
494 #define __DEF_NACL_AUTH_INT(prefix, name) \
495 static ssize_t __iscsi_##prefix##_show_##name( \
496 struct iscsi_node_acl *nacl, \
499 struct iscsi_node_auth *auth = &nacl->node_auth; \
501 if (!capable(CAP_SYS_ADMIN)) \
504 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
507 #define DEF_NACL_AUTH_STR(name, flags) \
508 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
509 static ssize_t iscsi_nacl_auth_show_##name( \
510 struct se_node_acl *nacl, \
513 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
514 struct iscsi_node_acl, se_node_acl), page); \
516 static ssize_t iscsi_nacl_auth_store_##name( \
517 struct se_node_acl *nacl, \
521 return __iscsi_nacl_auth_store_##name(container_of(nacl, \
522 struct iscsi_node_acl, se_node_acl), page, count); \
525 #define DEF_NACL_AUTH_INT(name) \
526 __DEF_NACL_AUTH_INT(nacl_auth, name) \
527 static ssize_t iscsi_nacl_auth_show_##name( \
528 struct se_node_acl *nacl, \
531 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
532 struct iscsi_node_acl, se_node_acl), page); \
535 #define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode);
536 #define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name);
539 * One-way authentication userid
541 DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
542 AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
544 * One-way authentication password
546 DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
547 AUTH_ATTR(password, S_IRUGO | S_IWUSR);
549 * Enforce mutual authentication
551 DEF_NACL_AUTH_INT(authenticate_target);
552 AUTH_ATTR_RO(authenticate_target);
554 * Mutual authentication userid
556 DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
557 AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
559 * Mutual authentication password
561 DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
562 AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
564 static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
565 &iscsi_nacl_auth_userid.attr,
566 &iscsi_nacl_auth_password.attr,
567 &iscsi_nacl_auth_authenticate_target.attr,
568 &iscsi_nacl_auth_userid_mutual.attr,
569 &iscsi_nacl_auth_password_mutual.attr,
573 /* End items for lio_target_nacl_auth_cit */
575 /* Start items for lio_target_nacl_param_cit */
577 #define DEF_NACL_PARAM(name) \
578 static ssize_t iscsi_nacl_param_show_##name( \
579 struct se_node_acl *se_nacl, \
582 struct iscsi_session *sess; \
583 struct se_session *se_sess; \
586 spin_lock_bh(&se_nacl->nacl_sess_lock); \
587 se_sess = se_nacl->nacl_sess; \
589 rb = snprintf(page, PAGE_SIZE, \
590 "No Active iSCSI Session\n"); \
592 sess = se_sess->fabric_sess_ptr; \
593 rb = snprintf(page, PAGE_SIZE, "%u\n", \
594 (u32)sess->sess_ops->name); \
596 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
601 #define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name);
603 DEF_NACL_PARAM(MaxConnections);
604 NACL_PARAM_ATTR(MaxConnections);
606 DEF_NACL_PARAM(InitialR2T);
607 NACL_PARAM_ATTR(InitialR2T);
609 DEF_NACL_PARAM(ImmediateData);
610 NACL_PARAM_ATTR(ImmediateData);
612 DEF_NACL_PARAM(MaxBurstLength);
613 NACL_PARAM_ATTR(MaxBurstLength);
615 DEF_NACL_PARAM(FirstBurstLength);
616 NACL_PARAM_ATTR(FirstBurstLength);
618 DEF_NACL_PARAM(DefaultTime2Wait);
619 NACL_PARAM_ATTR(DefaultTime2Wait);
621 DEF_NACL_PARAM(DefaultTime2Retain);
622 NACL_PARAM_ATTR(DefaultTime2Retain);
624 DEF_NACL_PARAM(MaxOutstandingR2T);
625 NACL_PARAM_ATTR(MaxOutstandingR2T);
627 DEF_NACL_PARAM(DataPDUInOrder);
628 NACL_PARAM_ATTR(DataPDUInOrder);
630 DEF_NACL_PARAM(DataSequenceInOrder);
631 NACL_PARAM_ATTR(DataSequenceInOrder);
633 DEF_NACL_PARAM(ErrorRecoveryLevel);
634 NACL_PARAM_ATTR(ErrorRecoveryLevel);
636 static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
637 &iscsi_nacl_param_MaxConnections.attr,
638 &iscsi_nacl_param_InitialR2T.attr,
639 &iscsi_nacl_param_ImmediateData.attr,
640 &iscsi_nacl_param_MaxBurstLength.attr,
641 &iscsi_nacl_param_FirstBurstLength.attr,
642 &iscsi_nacl_param_DefaultTime2Wait.attr,
643 &iscsi_nacl_param_DefaultTime2Retain.attr,
644 &iscsi_nacl_param_MaxOutstandingR2T.attr,
645 &iscsi_nacl_param_DataPDUInOrder.attr,
646 &iscsi_nacl_param_DataSequenceInOrder.attr,
647 &iscsi_nacl_param_ErrorRecoveryLevel.attr,
651 /* End items for lio_target_nacl_param_cit */
653 /* Start items for lio_target_acl_cit */
655 static ssize_t lio_target_nacl_show_info(
656 struct se_node_acl *se_nacl,
659 struct iscsi_session *sess;
660 struct iscsi_conn *conn;
661 struct se_session *se_sess;
664 spin_lock_bh(&se_nacl->nacl_sess_lock);
665 se_sess = se_nacl->nacl_sess;
667 rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
668 " Endpoint: %s\n", se_nacl->initiatorname);
670 sess = se_sess->fabric_sess_ptr;
672 rb += sprintf(page+rb, "InitiatorName: %s\n",
673 sess->sess_ops->InitiatorName);
674 rb += sprintf(page+rb, "InitiatorAlias: %s\n",
675 sess->sess_ops->InitiatorAlias);
677 rb += sprintf(page+rb,
678 "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
679 sess->sid, sess->isid, sess->tsih);
680 rb += sprintf(page+rb, "SessionType: %s\n",
681 (sess->sess_ops->SessionType) ?
682 "Discovery" : "Normal");
683 rb += sprintf(page+rb, "Session State: ");
684 switch (sess->session_state) {
685 case TARG_SESS_STATE_FREE:
686 rb += sprintf(page+rb, "TARG_SESS_FREE\n");
688 case TARG_SESS_STATE_ACTIVE:
689 rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
691 case TARG_SESS_STATE_LOGGED_IN:
692 rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
694 case TARG_SESS_STATE_FAILED:
695 rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
697 case TARG_SESS_STATE_IN_CONTINUE:
698 rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
701 rb += sprintf(page+rb, "ERROR: Unknown Session"
706 rb += sprintf(page+rb, "---------------------[iSCSI Session"
707 " Values]-----------------------\n");
708 rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
709 " : MaxCmdSN : ITT : TTT\n");
710 rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
713 (sess->max_cmd_sn - sess->exp_cmd_sn) + 1,
714 sess->exp_cmd_sn, sess->max_cmd_sn,
715 sess->init_task_tag, sess->targ_xfer_tag);
716 rb += sprintf(page+rb, "----------------------[iSCSI"
717 " Connections]-------------------------\n");
719 spin_lock(&sess->conn_lock);
720 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
721 rb += sprintf(page+rb, "CID: %hu Connection"
722 " State: ", conn->cid);
723 switch (conn->conn_state) {
724 case TARG_CONN_STATE_FREE:
725 rb += sprintf(page+rb,
726 "TARG_CONN_STATE_FREE\n");
728 case TARG_CONN_STATE_XPT_UP:
729 rb += sprintf(page+rb,
730 "TARG_CONN_STATE_XPT_UP\n");
732 case TARG_CONN_STATE_IN_LOGIN:
733 rb += sprintf(page+rb,
734 "TARG_CONN_STATE_IN_LOGIN\n");
736 case TARG_CONN_STATE_LOGGED_IN:
737 rb += sprintf(page+rb,
738 "TARG_CONN_STATE_LOGGED_IN\n");
740 case TARG_CONN_STATE_IN_LOGOUT:
741 rb += sprintf(page+rb,
742 "TARG_CONN_STATE_IN_LOGOUT\n");
744 case TARG_CONN_STATE_LOGOUT_REQUESTED:
745 rb += sprintf(page+rb,
746 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
748 case TARG_CONN_STATE_CLEANUP_WAIT:
749 rb += sprintf(page+rb,
750 "TARG_CONN_STATE_CLEANUP_WAIT\n");
753 rb += sprintf(page+rb,
754 "ERROR: Unknown Connection State!\n");
758 rb += sprintf(page+rb, " Address %s %s", conn->login_ip,
759 (conn->network_transport == ISCSI_TCP) ?
761 rb += sprintf(page+rb, " StatSN: 0x%08x\n",
764 spin_unlock(&sess->conn_lock);
766 spin_unlock_bh(&se_nacl->nacl_sess_lock);
771 TF_NACL_BASE_ATTR_RO(lio_target, info);
773 static ssize_t lio_target_nacl_show_cmdsn_depth(
774 struct se_node_acl *se_nacl,
777 return sprintf(page, "%u\n", se_nacl->queue_depth);
780 static ssize_t lio_target_nacl_store_cmdsn_depth(
781 struct se_node_acl *se_nacl,
785 struct se_portal_group *se_tpg = se_nacl->se_tpg;
786 struct iscsi_portal_group *tpg = container_of(se_tpg,
787 struct iscsi_portal_group, tpg_se_tpg);
788 struct config_item *acl_ci, *tpg_ci, *wwn_ci;
792 ret = kstrtou32(page, 0, &cmdsn_depth);
795 if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
796 pr_err("Passed cmdsn_depth: %u exceeds"
797 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
798 TA_DEFAULT_CMDSN_DEPTH_MAX);
801 acl_ci = &se_nacl->acl_group.cg_item;
803 pr_err("Unable to locatel acl_ci\n");
806 tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
808 pr_err("Unable to locate tpg_ci\n");
811 wwn_ci = &tpg_ci->ci_group->cg_item;
813 pr_err("Unable to locate config_item wwn_ci\n");
817 if (iscsit_get_tpg(tpg) < 0)
820 * iscsit_tpg_set_initiator_node_queue_depth() assumes force=1
822 ret = iscsit_tpg_set_initiator_node_queue_depth(tpg,
823 config_item_name(acl_ci), cmdsn_depth, 1);
825 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
826 "InitiatorName: %s\n", config_item_name(wwn_ci),
827 config_item_name(tpg_ci), cmdsn_depth,
828 config_item_name(acl_ci));
831 return (!ret) ? count : (ssize_t)ret;
834 TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR);
836 static ssize_t lio_target_nacl_show_tag(
837 struct se_node_acl *se_nacl,
840 return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag);
843 static ssize_t lio_target_nacl_store_tag(
844 struct se_node_acl *se_nacl,
850 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
857 TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR);
859 static struct configfs_attribute *lio_target_initiator_attrs[] = {
860 &lio_target_nacl_info.attr,
861 &lio_target_nacl_cmdsn_depth.attr,
862 &lio_target_nacl_tag.attr,
866 static struct se_node_acl *lio_tpg_alloc_fabric_acl(
867 struct se_portal_group *se_tpg)
869 struct iscsi_node_acl *acl;
871 acl = kzalloc(sizeof(struct iscsi_node_acl), GFP_KERNEL);
873 pr_err("Unable to allocate memory for struct iscsi_node_acl\n");
877 return &acl->se_node_acl;
880 static struct se_node_acl *lio_target_make_nodeacl(
881 struct se_portal_group *se_tpg,
882 struct config_group *group,
885 struct config_group *stats_cg;
886 struct iscsi_node_acl *acl;
887 struct se_node_acl *se_nacl_new, *se_nacl;
888 struct iscsi_portal_group *tpg = container_of(se_tpg,
889 struct iscsi_portal_group, tpg_se_tpg);
892 se_nacl_new = lio_tpg_alloc_fabric_acl(se_tpg);
894 return ERR_PTR(-ENOMEM);
896 cmdsn_depth = tpg->tpg_attrib.default_cmdsn_depth;
898 * se_nacl_new may be released by core_tpg_add_initiator_node_acl()
899 * when converting a NdoeACL from demo mode -> explict
901 se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
906 acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
907 stats_cg = &se_nacl->acl_fabric_stat_group;
909 stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
911 if (!stats_cg->default_groups) {
912 pr_err("Unable to allocate memory for"
913 " stats_cg->default_groups\n");
914 core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
916 return ERR_PTR(-ENOMEM);
919 stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group;
920 stats_cg->default_groups[1] = NULL;
921 config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
922 "iscsi_sess_stats", &iscsi_stat_sess_cit);
927 static void lio_target_drop_nodeacl(
928 struct se_node_acl *se_nacl)
930 struct se_portal_group *se_tpg = se_nacl->se_tpg;
931 struct iscsi_node_acl *acl = container_of(se_nacl,
932 struct iscsi_node_acl, se_node_acl);
933 struct config_item *df_item;
934 struct config_group *stats_cg;
937 stats_cg = &acl->se_node_acl.acl_fabric_stat_group;
938 for (i = 0; stats_cg->default_groups[i]; i++) {
939 df_item = &stats_cg->default_groups[i]->cg_item;
940 stats_cg->default_groups[i] = NULL;
941 config_item_put(df_item);
943 kfree(stats_cg->default_groups);
945 core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
949 /* End items for lio_target_acl_cit */
951 /* Start items for lio_target_tpg_attrib_cit */
953 #define DEF_TPG_ATTRIB(name) \
955 static ssize_t iscsi_tpg_attrib_show_##name( \
956 struct se_portal_group *se_tpg, \
959 struct iscsi_portal_group *tpg = container_of(se_tpg, \
960 struct iscsi_portal_group, tpg_se_tpg); \
963 if (iscsit_get_tpg(tpg) < 0) \
966 rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
967 iscsit_put_tpg(tpg); \
971 static ssize_t iscsi_tpg_attrib_store_##name( \
972 struct se_portal_group *se_tpg, \
976 struct iscsi_portal_group *tpg = container_of(se_tpg, \
977 struct iscsi_portal_group, tpg_se_tpg); \
981 if (iscsit_get_tpg(tpg) < 0) \
984 ret = kstrtou32(page, 0, &val); \
987 ret = iscsit_ta_##name(tpg, val); \
991 iscsit_put_tpg(tpg); \
994 iscsit_put_tpg(tpg); \
998 #define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode);
1001 * Define iscsi_tpg_attrib_s_authentication
1003 DEF_TPG_ATTRIB(authentication);
1004 TPG_ATTR(authentication, S_IRUGO | S_IWUSR);
1006 * Define iscsi_tpg_attrib_s_login_timeout
1008 DEF_TPG_ATTRIB(login_timeout);
1009 TPG_ATTR(login_timeout, S_IRUGO | S_IWUSR);
1011 * Define iscsi_tpg_attrib_s_netif_timeout
1013 DEF_TPG_ATTRIB(netif_timeout);
1014 TPG_ATTR(netif_timeout, S_IRUGO | S_IWUSR);
1016 * Define iscsi_tpg_attrib_s_generate_node_acls
1018 DEF_TPG_ATTRIB(generate_node_acls);
1019 TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR);
1021 * Define iscsi_tpg_attrib_s_default_cmdsn_depth
1023 DEF_TPG_ATTRIB(default_cmdsn_depth);
1024 TPG_ATTR(default_cmdsn_depth, S_IRUGO | S_IWUSR);
1026 Define iscsi_tpg_attrib_s_cache_dynamic_acls
1028 DEF_TPG_ATTRIB(cache_dynamic_acls);
1029 TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR);
1031 * Define iscsi_tpg_attrib_s_demo_mode_write_protect
1033 DEF_TPG_ATTRIB(demo_mode_write_protect);
1034 TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR);
1036 * Define iscsi_tpg_attrib_s_prod_mode_write_protect
1038 DEF_TPG_ATTRIB(prod_mode_write_protect);
1039 TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR);
1041 * Define iscsi_tpg_attrib_s_demo_mode_discovery,
1043 DEF_TPG_ATTRIB(demo_mode_discovery);
1044 TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR);
1046 * Define iscsi_tpg_attrib_s_default_erl
1048 DEF_TPG_ATTRIB(default_erl);
1049 TPG_ATTR(default_erl, S_IRUGO | S_IWUSR);
1051 * Define iscsi_tpg_attrib_s_t10_pi
1053 DEF_TPG_ATTRIB(t10_pi);
1054 TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR);
1056 static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
1057 &iscsi_tpg_attrib_authentication.attr,
1058 &iscsi_tpg_attrib_login_timeout.attr,
1059 &iscsi_tpg_attrib_netif_timeout.attr,
1060 &iscsi_tpg_attrib_generate_node_acls.attr,
1061 &iscsi_tpg_attrib_default_cmdsn_depth.attr,
1062 &iscsi_tpg_attrib_cache_dynamic_acls.attr,
1063 &iscsi_tpg_attrib_demo_mode_write_protect.attr,
1064 &iscsi_tpg_attrib_prod_mode_write_protect.attr,
1065 &iscsi_tpg_attrib_demo_mode_discovery.attr,
1066 &iscsi_tpg_attrib_default_erl.attr,
1067 &iscsi_tpg_attrib_t10_pi.attr,
1071 /* End items for lio_target_tpg_attrib_cit */
1073 /* Start items for lio_target_tpg_auth_cit */
1075 #define __DEF_TPG_AUTH_STR(prefix, name, flags) \
1076 static ssize_t __iscsi_##prefix##_show_##name( \
1077 struct se_portal_group *se_tpg, \
1080 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1081 struct iscsi_portal_group, tpg_se_tpg); \
1082 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1084 if (!capable(CAP_SYS_ADMIN)) \
1087 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
1090 static ssize_t __iscsi_##prefix##_store_##name( \
1091 struct se_portal_group *se_tpg, \
1095 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1096 struct iscsi_portal_group, tpg_se_tpg); \
1097 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1099 if (!capable(CAP_SYS_ADMIN)) \
1102 snprintf(auth->name, sizeof(auth->name), "%s", page); \
1103 if (!(strncmp("NULL", auth->name, 4))) \
1104 auth->naf_flags &= ~flags; \
1106 auth->naf_flags |= flags; \
1108 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
1109 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
1110 auth->authenticate_target = 1; \
1112 auth->authenticate_target = 0; \
1117 #define __DEF_TPG_AUTH_INT(prefix, name) \
1118 static ssize_t __iscsi_##prefix##_show_##name( \
1119 struct se_portal_group *se_tpg, \
1122 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1123 struct iscsi_portal_group, tpg_se_tpg); \
1124 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1126 if (!capable(CAP_SYS_ADMIN)) \
1129 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
1132 #define DEF_TPG_AUTH_STR(name, flags) \
1133 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
1134 static ssize_t iscsi_tpg_auth_show_##name( \
1135 struct se_portal_group *se_tpg, \
1138 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1141 static ssize_t iscsi_tpg_auth_store_##name( \
1142 struct se_portal_group *se_tpg, \
1146 return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \
1149 #define DEF_TPG_AUTH_INT(name) \
1150 __DEF_TPG_AUTH_INT(tpg_auth, name) \
1151 static ssize_t iscsi_tpg_auth_show_##name( \
1152 struct se_portal_group *se_tpg, \
1155 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1158 #define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode);
1159 #define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name);
1162 * * One-way authentication userid
1164 DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
1165 TPG_AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
1167 * * One-way authentication password
1169 DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
1170 TPG_AUTH_ATTR(password, S_IRUGO | S_IWUSR);
1172 * * Enforce mutual authentication
1174 DEF_TPG_AUTH_INT(authenticate_target);
1175 TPG_AUTH_ATTR_RO(authenticate_target);
1177 * * Mutual authentication userid
1179 DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1180 TPG_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
1182 * * Mutual authentication password
1184 DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
1185 TPG_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
1187 static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
1188 &iscsi_tpg_auth_userid.attr,
1189 &iscsi_tpg_auth_password.attr,
1190 &iscsi_tpg_auth_authenticate_target.attr,
1191 &iscsi_tpg_auth_userid_mutual.attr,
1192 &iscsi_tpg_auth_password_mutual.attr,
1196 /* End items for lio_target_tpg_auth_cit */
1198 /* Start items for lio_target_tpg_param_cit */
1200 #define DEF_TPG_PARAM(name) \
1201 static ssize_t iscsi_tpg_param_show_##name( \
1202 struct se_portal_group *se_tpg, \
1205 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1206 struct iscsi_portal_group, tpg_se_tpg); \
1207 struct iscsi_param *param; \
1210 if (iscsit_get_tpg(tpg) < 0) \
1213 param = iscsi_find_param_from_key(__stringify(name), \
1216 iscsit_put_tpg(tpg); \
1219 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
1221 iscsit_put_tpg(tpg); \
1224 static ssize_t iscsi_tpg_param_store_##name( \
1225 struct se_portal_group *se_tpg, \
1229 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1230 struct iscsi_portal_group, tpg_se_tpg); \
1234 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
1237 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
1238 if (isspace(buf[len-1])) \
1239 buf[len-1] = '\0'; /* Kill newline */ \
1241 if (iscsit_get_tpg(tpg) < 0) { \
1246 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
1251 iscsit_put_tpg(tpg); \
1255 iscsit_put_tpg(tpg); \
1259 #define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode);
1261 DEF_TPG_PARAM(AuthMethod);
1262 TPG_PARAM_ATTR(AuthMethod, S_IRUGO | S_IWUSR);
1264 DEF_TPG_PARAM(HeaderDigest);
1265 TPG_PARAM_ATTR(HeaderDigest, S_IRUGO | S_IWUSR);
1267 DEF_TPG_PARAM(DataDigest);
1268 TPG_PARAM_ATTR(DataDigest, S_IRUGO | S_IWUSR);
1270 DEF_TPG_PARAM(MaxConnections);
1271 TPG_PARAM_ATTR(MaxConnections, S_IRUGO | S_IWUSR);
1273 DEF_TPG_PARAM(TargetAlias);
1274 TPG_PARAM_ATTR(TargetAlias, S_IRUGO | S_IWUSR);
1276 DEF_TPG_PARAM(InitialR2T);
1277 TPG_PARAM_ATTR(InitialR2T, S_IRUGO | S_IWUSR);
1279 DEF_TPG_PARAM(ImmediateData);
1280 TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR);
1282 DEF_TPG_PARAM(MaxRecvDataSegmentLength);
1283 TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR);
1285 DEF_TPG_PARAM(MaxXmitDataSegmentLength);
1286 TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR);
1288 DEF_TPG_PARAM(MaxBurstLength);
1289 TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR);
1291 DEF_TPG_PARAM(FirstBurstLength);
1292 TPG_PARAM_ATTR(FirstBurstLength, S_IRUGO | S_IWUSR);
1294 DEF_TPG_PARAM(DefaultTime2Wait);
1295 TPG_PARAM_ATTR(DefaultTime2Wait, S_IRUGO | S_IWUSR);
1297 DEF_TPG_PARAM(DefaultTime2Retain);
1298 TPG_PARAM_ATTR(DefaultTime2Retain, S_IRUGO | S_IWUSR);
1300 DEF_TPG_PARAM(MaxOutstandingR2T);
1301 TPG_PARAM_ATTR(MaxOutstandingR2T, S_IRUGO | S_IWUSR);
1303 DEF_TPG_PARAM(DataPDUInOrder);
1304 TPG_PARAM_ATTR(DataPDUInOrder, S_IRUGO | S_IWUSR);
1306 DEF_TPG_PARAM(DataSequenceInOrder);
1307 TPG_PARAM_ATTR(DataSequenceInOrder, S_IRUGO | S_IWUSR);
1309 DEF_TPG_PARAM(ErrorRecoveryLevel);
1310 TPG_PARAM_ATTR(ErrorRecoveryLevel, S_IRUGO | S_IWUSR);
1312 DEF_TPG_PARAM(IFMarker);
1313 TPG_PARAM_ATTR(IFMarker, S_IRUGO | S_IWUSR);
1315 DEF_TPG_PARAM(OFMarker);
1316 TPG_PARAM_ATTR(OFMarker, S_IRUGO | S_IWUSR);
1318 DEF_TPG_PARAM(IFMarkInt);
1319 TPG_PARAM_ATTR(IFMarkInt, S_IRUGO | S_IWUSR);
1321 DEF_TPG_PARAM(OFMarkInt);
1322 TPG_PARAM_ATTR(OFMarkInt, S_IRUGO | S_IWUSR);
1324 static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
1325 &iscsi_tpg_param_AuthMethod.attr,
1326 &iscsi_tpg_param_HeaderDigest.attr,
1327 &iscsi_tpg_param_DataDigest.attr,
1328 &iscsi_tpg_param_MaxConnections.attr,
1329 &iscsi_tpg_param_TargetAlias.attr,
1330 &iscsi_tpg_param_InitialR2T.attr,
1331 &iscsi_tpg_param_ImmediateData.attr,
1332 &iscsi_tpg_param_MaxRecvDataSegmentLength.attr,
1333 &iscsi_tpg_param_MaxXmitDataSegmentLength.attr,
1334 &iscsi_tpg_param_MaxBurstLength.attr,
1335 &iscsi_tpg_param_FirstBurstLength.attr,
1336 &iscsi_tpg_param_DefaultTime2Wait.attr,
1337 &iscsi_tpg_param_DefaultTime2Retain.attr,
1338 &iscsi_tpg_param_MaxOutstandingR2T.attr,
1339 &iscsi_tpg_param_DataPDUInOrder.attr,
1340 &iscsi_tpg_param_DataSequenceInOrder.attr,
1341 &iscsi_tpg_param_ErrorRecoveryLevel.attr,
1342 &iscsi_tpg_param_IFMarker.attr,
1343 &iscsi_tpg_param_OFMarker.attr,
1344 &iscsi_tpg_param_IFMarkInt.attr,
1345 &iscsi_tpg_param_OFMarkInt.attr,
1349 /* End items for lio_target_tpg_param_cit */
1351 /* Start items for lio_target_tpg_cit */
1353 static ssize_t lio_target_tpg_show_enable(
1354 struct se_portal_group *se_tpg,
1357 struct iscsi_portal_group *tpg = container_of(se_tpg,
1358 struct iscsi_portal_group, tpg_se_tpg);
1361 spin_lock(&tpg->tpg_state_lock);
1362 len = sprintf(page, "%d\n",
1363 (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
1364 spin_unlock(&tpg->tpg_state_lock);
1369 static ssize_t lio_target_tpg_store_enable(
1370 struct se_portal_group *se_tpg,
1374 struct iscsi_portal_group *tpg = container_of(se_tpg,
1375 struct iscsi_portal_group, tpg_se_tpg);
1379 ret = kstrtou32(page, 0, &op);
1382 if ((op != 1) && (op != 0)) {
1383 pr_err("Illegal value for tpg_enable: %u\n", op);
1387 ret = iscsit_get_tpg(tpg);
1392 ret = iscsit_tpg_enable_portal_group(tpg);
1397 * iscsit_tpg_disable_portal_group() assumes force=1
1399 ret = iscsit_tpg_disable_portal_group(tpg, 1);
1404 iscsit_put_tpg(tpg);
1407 iscsit_put_tpg(tpg);
1411 TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR);
1413 static struct configfs_attribute *lio_target_tpg_attrs[] = {
1414 &lio_target_tpg_enable.attr,
1418 /* End items for lio_target_tpg_cit */
1420 /* Start items for lio_target_tiqn_cit */
1422 static struct se_portal_group *lio_target_tiqn_addtpg(
1424 struct config_group *group,
1427 struct iscsi_portal_group *tpg;
1428 struct iscsi_tiqn *tiqn;
1433 tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1435 * Only tpgt_# directory groups can be created below
1436 * target/iscsi/iqn.superturodiskarry/
1438 tpgt_str = strstr(name, "tpgt_");
1440 pr_err("Unable to locate \"tpgt_#\" directory"
1444 tpgt_str += 5; /* Skip ahead of "tpgt_" */
1445 ret = kstrtou16(tpgt_str, 0, &tpgt);
1449 tpg = iscsit_alloc_portal_group(tiqn, tpgt);
1453 ret = core_tpg_register(
1454 &lio_target_fabric_configfs->tf_ops,
1455 wwn, &tpg->tpg_se_tpg, tpg,
1456 TRANSPORT_TPG_TYPE_NORMAL);
1460 ret = iscsit_tpg_add_portal_group(tiqn, tpg);
1464 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1465 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1467 return &tpg->tpg_se_tpg;
1469 core_tpg_deregister(&tpg->tpg_se_tpg);
1474 static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
1476 struct iscsi_portal_group *tpg;
1477 struct iscsi_tiqn *tiqn;
1479 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1480 tiqn = tpg->tpg_tiqn;
1482 * iscsit_tpg_del_portal_group() assumes force=1
1484 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1485 iscsit_tpg_del_portal_group(tiqn, tpg, 1);
1488 /* End items for lio_target_tiqn_cit */
1490 /* Start LIO-Target TIQN struct contig_item lio_target_cit */
1492 static ssize_t lio_target_wwn_show_attr_lio_version(
1493 struct target_fabric_configfs *tf,
1496 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
1499 TF_WWN_ATTR_RO(lio_target, lio_version);
1501 static struct configfs_attribute *lio_target_wwn_attrs[] = {
1502 &lio_target_wwn_lio_version.attr,
1506 static struct se_wwn *lio_target_call_coreaddtiqn(
1507 struct target_fabric_configfs *tf,
1508 struct config_group *group,
1511 struct config_group *stats_cg;
1512 struct iscsi_tiqn *tiqn;
1514 tiqn = iscsit_add_tiqn((unsigned char *)name);
1516 return ERR_CAST(tiqn);
1518 * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group.
1520 stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
1522 stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6,
1524 if (!stats_cg->default_groups) {
1525 pr_err("Unable to allocate memory for"
1526 " stats_cg->default_groups\n");
1527 iscsit_del_tiqn(tiqn);
1528 return ERR_PTR(-ENOMEM);
1531 stats_cg->default_groups[0] = &tiqn->tiqn_stat_grps.iscsi_instance_group;
1532 stats_cg->default_groups[1] = &tiqn->tiqn_stat_grps.iscsi_sess_err_group;
1533 stats_cg->default_groups[2] = &tiqn->tiqn_stat_grps.iscsi_tgt_attr_group;
1534 stats_cg->default_groups[3] = &tiqn->tiqn_stat_grps.iscsi_login_stats_group;
1535 stats_cg->default_groups[4] = &tiqn->tiqn_stat_grps.iscsi_logout_stats_group;
1536 stats_cg->default_groups[5] = NULL;
1537 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
1538 "iscsi_instance", &iscsi_stat_instance_cit);
1539 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
1540 "iscsi_sess_err", &iscsi_stat_sess_err_cit);
1541 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
1542 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
1543 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
1544 "iscsi_login_stats", &iscsi_stat_login_cit);
1545 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
1546 "iscsi_logout_stats", &iscsi_stat_logout_cit);
1548 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1549 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1551 return &tiqn->tiqn_wwn;
1554 static void lio_target_call_coredeltiqn(
1557 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1558 struct config_item *df_item;
1559 struct config_group *stats_cg;
1562 stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
1563 for (i = 0; stats_cg->default_groups[i]; i++) {
1564 df_item = &stats_cg->default_groups[i]->cg_item;
1565 stats_cg->default_groups[i] = NULL;
1566 config_item_put(df_item);
1568 kfree(stats_cg->default_groups);
1570 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1572 iscsit_del_tiqn(tiqn);
1575 /* End LIO-Target TIQN struct contig_lio_target_cit */
1577 /* Start lio_target_discovery_auth_cit */
1579 #define DEF_DISC_AUTH_STR(name, flags) \
1580 __DEF_NACL_AUTH_STR(disc, name, flags) \
1581 static ssize_t iscsi_disc_show_##name( \
1582 struct target_fabric_configfs *tf, \
1585 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1588 static ssize_t iscsi_disc_store_##name( \
1589 struct target_fabric_configfs *tf, \
1593 return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \
1597 #define DEF_DISC_AUTH_INT(name) \
1598 __DEF_NACL_AUTH_INT(disc, name) \
1599 static ssize_t iscsi_disc_show_##name( \
1600 struct target_fabric_configfs *tf, \
1603 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1607 #define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode)
1608 #define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name)
1611 * One-way authentication userid
1613 DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
1614 DISC_AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
1616 * One-way authentication password
1618 DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
1619 DISC_AUTH_ATTR(password, S_IRUGO | S_IWUSR);
1621 * Enforce mutual authentication
1623 DEF_DISC_AUTH_INT(authenticate_target);
1624 DISC_AUTH_ATTR_RO(authenticate_target);
1626 * Mutual authentication userid
1628 DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1629 DISC_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
1631 * Mutual authentication password
1633 DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
1634 DISC_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
1637 * enforce_discovery_auth
1639 static ssize_t iscsi_disc_show_enforce_discovery_auth(
1640 struct target_fabric_configfs *tf,
1643 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
1645 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
1648 static ssize_t iscsi_disc_store_enforce_discovery_auth(
1649 struct target_fabric_configfs *tf,
1653 struct iscsi_param *param;
1654 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
1658 err = kstrtou32(page, 0, &op);
1661 if ((op != 1) && (op != 0)) {
1662 pr_err("Illegal value for enforce_discovery_auth:"
1667 if (!discovery_tpg) {
1668 pr_err("iscsit_global->discovery_tpg is NULL\n");
1672 param = iscsi_find_param_from_key(AUTHMETHOD,
1673 discovery_tpg->param_list);
1679 * Reset the AuthMethod key to CHAP.
1681 if (iscsi_update_param_value(param, CHAP) < 0)
1684 discovery_tpg->tpg_attrib.authentication = 1;
1685 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
1686 pr_debug("LIO-CORE[0] Successfully enabled"
1687 " authentication enforcement for iSCSI"
1688 " Discovery TPG\n");
1691 * Reset the AuthMethod key to CHAP,None
1693 if (iscsi_update_param_value(param, "CHAP,None") < 0)
1696 discovery_tpg->tpg_attrib.authentication = 0;
1697 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
1698 pr_debug("LIO-CORE[0] Successfully disabled"
1699 " authentication enforcement for iSCSI"
1700 " Discovery TPG\n");
1706 DISC_AUTH_ATTR(enforce_discovery_auth, S_IRUGO | S_IWUSR);
1708 static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
1709 &iscsi_disc_userid.attr,
1710 &iscsi_disc_password.attr,
1711 &iscsi_disc_authenticate_target.attr,
1712 &iscsi_disc_userid_mutual.attr,
1713 &iscsi_disc_password_mutual.attr,
1714 &iscsi_disc_enforce_discovery_auth.attr,
1718 /* End lio_target_discovery_auth_cit */
1720 /* Start functions for target_core_fabric_ops */
1722 static char *iscsi_get_fabric_name(void)
1727 static u32 iscsi_get_task_tag(struct se_cmd *se_cmd)
1729 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1731 /* only used for printks or comparism with ->ref_task_tag */
1732 return (__force u32)cmd->init_task_tag;
1735 static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1737 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1739 return cmd->i_state;
1742 static u32 lio_sess_get_index(struct se_session *se_sess)
1744 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1746 return sess->session_index;
1749 static u32 lio_sess_get_initiator_sid(
1750 struct se_session *se_sess,
1754 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1756 * iSCSI Initiator Session Identifier from RFC-3720.
1758 return snprintf(buf, size, "%6phN", sess->isid);
1761 static int lio_queue_data_in(struct se_cmd *se_cmd)
1763 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1765 cmd->i_state = ISTATE_SEND_DATAIN;
1766 cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd);
1771 static int lio_write_pending(struct se_cmd *se_cmd)
1773 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1774 struct iscsi_conn *conn = cmd->conn;
1776 if (!cmd->immediate_data && !cmd->unsolicited_data)
1777 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
1782 static int lio_write_pending_status(struct se_cmd *se_cmd)
1784 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1787 spin_lock_bh(&cmd->istate_lock);
1788 ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
1789 spin_unlock_bh(&cmd->istate_lock);
1794 static int lio_queue_status(struct se_cmd *se_cmd)
1796 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1798 cmd->i_state = ISTATE_SEND_STATUS;
1800 if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
1801 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
1804 cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd);
1809 static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
1811 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1813 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
1814 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
1817 static void lio_aborted_task(struct se_cmd *se_cmd)
1819 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1821 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
1824 static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
1826 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1828 return &tpg->tpg_tiqn->tiqn[0];
1831 static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
1833 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1838 static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
1840 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1842 return tpg->tpg_attrib.default_cmdsn_depth;
1845 static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
1847 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1849 return tpg->tpg_attrib.generate_node_acls;
1852 static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
1854 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1856 return tpg->tpg_attrib.cache_dynamic_acls;
1859 static int lio_tpg_check_demo_mode_write_protect(
1860 struct se_portal_group *se_tpg)
1862 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1864 return tpg->tpg_attrib.demo_mode_write_protect;
1867 static int lio_tpg_check_prod_mode_write_protect(
1868 struct se_portal_group *se_tpg)
1870 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1872 return tpg->tpg_attrib.prod_mode_write_protect;
1875 static void lio_tpg_release_fabric_acl(
1876 struct se_portal_group *se_tpg,
1877 struct se_node_acl *se_acl)
1879 struct iscsi_node_acl *acl = container_of(se_acl,
1880 struct iscsi_node_acl, se_node_acl);
1885 * Called with spin_lock_bh(struct se_portal_group->session_lock) held..
1887 * Also, this function calls iscsit_inc_session_usage_count() on the
1888 * struct iscsi_session in question.
1890 static int lio_tpg_shutdown_session(struct se_session *se_sess)
1892 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1894 spin_lock(&sess->conn_lock);
1895 if (atomic_read(&sess->session_fall_back_to_erl0) ||
1896 atomic_read(&sess->session_logout) ||
1897 (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
1898 spin_unlock(&sess->conn_lock);
1901 atomic_set(&sess->session_reinstatement, 1);
1902 spin_unlock(&sess->conn_lock);
1904 iscsit_stop_time2retain_timer(sess);
1905 iscsit_stop_session(sess, 1, 1);
1911 * Calls iscsit_dec_session_usage_count() as inverse of
1912 * lio_tpg_shutdown_session()
1914 static void lio_tpg_close_session(struct se_session *se_sess)
1916 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1918 * If the iSCSI Session for the iSCSI Initiator Node exists,
1919 * forcefully shutdown the iSCSI NEXUS.
1921 iscsit_close_session(sess);
1924 static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
1926 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1928 return tpg->tpg_tiqn->tiqn_index;
1931 static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
1933 struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
1935 struct se_portal_group *se_tpg = se_acl->se_tpg;
1936 struct iscsi_portal_group *tpg = container_of(se_tpg,
1937 struct iscsi_portal_group, tpg_se_tpg);
1939 acl->node_attrib.nacl = acl;
1940 iscsit_set_default_node_attribues(acl, tpg);
1943 static int lio_check_stop_free(struct se_cmd *se_cmd)
1945 return target_put_sess_cmd(se_cmd->se_sess, se_cmd);
1948 static void lio_release_cmd(struct se_cmd *se_cmd)
1950 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1952 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
1953 iscsit_release_cmd(cmd);
1956 /* End functions for target_core_fabric_ops */
1958 int iscsi_target_register_configfs(void)
1960 struct target_fabric_configfs *fabric;
1963 lio_target_fabric_configfs = NULL;
1964 fabric = target_fabric_configfs_init(THIS_MODULE, "iscsi");
1965 if (IS_ERR(fabric)) {
1966 pr_err("target_fabric_configfs_init() for"
1967 " LIO-Target failed!\n");
1968 return PTR_ERR(fabric);
1971 * Setup the fabric API of function pointers used by target_core_mod..
1973 fabric->tf_ops.get_fabric_name = &iscsi_get_fabric_name;
1974 fabric->tf_ops.get_fabric_proto_ident = &iscsi_get_fabric_proto_ident;
1975 fabric->tf_ops.tpg_get_wwn = &lio_tpg_get_endpoint_wwn;
1976 fabric->tf_ops.tpg_get_tag = &lio_tpg_get_tag;
1977 fabric->tf_ops.tpg_get_default_depth = &lio_tpg_get_default_depth;
1978 fabric->tf_ops.tpg_get_pr_transport_id = &iscsi_get_pr_transport_id;
1979 fabric->tf_ops.tpg_get_pr_transport_id_len =
1980 &iscsi_get_pr_transport_id_len;
1981 fabric->tf_ops.tpg_parse_pr_out_transport_id =
1982 &iscsi_parse_pr_out_transport_id;
1983 fabric->tf_ops.tpg_check_demo_mode = &lio_tpg_check_demo_mode;
1984 fabric->tf_ops.tpg_check_demo_mode_cache =
1985 &lio_tpg_check_demo_mode_cache;
1986 fabric->tf_ops.tpg_check_demo_mode_write_protect =
1987 &lio_tpg_check_demo_mode_write_protect;
1988 fabric->tf_ops.tpg_check_prod_mode_write_protect =
1989 &lio_tpg_check_prod_mode_write_protect;
1990 fabric->tf_ops.tpg_alloc_fabric_acl = &lio_tpg_alloc_fabric_acl;
1991 fabric->tf_ops.tpg_release_fabric_acl = &lio_tpg_release_fabric_acl;
1992 fabric->tf_ops.tpg_get_inst_index = &lio_tpg_get_inst_index;
1993 fabric->tf_ops.check_stop_free = &lio_check_stop_free,
1994 fabric->tf_ops.release_cmd = &lio_release_cmd;
1995 fabric->tf_ops.shutdown_session = &lio_tpg_shutdown_session;
1996 fabric->tf_ops.close_session = &lio_tpg_close_session;
1997 fabric->tf_ops.sess_get_index = &lio_sess_get_index;
1998 fabric->tf_ops.sess_get_initiator_sid = &lio_sess_get_initiator_sid;
1999 fabric->tf_ops.write_pending = &lio_write_pending;
2000 fabric->tf_ops.write_pending_status = &lio_write_pending_status;
2001 fabric->tf_ops.set_default_node_attributes =
2002 &lio_set_default_node_attributes;
2003 fabric->tf_ops.get_task_tag = &iscsi_get_task_tag;
2004 fabric->tf_ops.get_cmd_state = &iscsi_get_cmd_state;
2005 fabric->tf_ops.queue_data_in = &lio_queue_data_in;
2006 fabric->tf_ops.queue_status = &lio_queue_status;
2007 fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp;
2008 fabric->tf_ops.aborted_task = &lio_aborted_task;
2010 * Setup function pointers for generic logic in target_core_fabric_configfs.c
2012 fabric->tf_ops.fabric_make_wwn = &lio_target_call_coreaddtiqn;
2013 fabric->tf_ops.fabric_drop_wwn = &lio_target_call_coredeltiqn;
2014 fabric->tf_ops.fabric_make_tpg = &lio_target_tiqn_addtpg;
2015 fabric->tf_ops.fabric_drop_tpg = &lio_target_tiqn_deltpg;
2016 fabric->tf_ops.fabric_post_link = NULL;
2017 fabric->tf_ops.fabric_pre_unlink = NULL;
2018 fabric->tf_ops.fabric_make_np = &lio_target_call_addnptotpg;
2019 fabric->tf_ops.fabric_drop_np = &lio_target_call_delnpfromtpg;
2020 fabric->tf_ops.fabric_make_nodeacl = &lio_target_make_nodeacl;
2021 fabric->tf_ops.fabric_drop_nodeacl = &lio_target_drop_nodeacl;
2023 * Setup default attribute lists for various fabric->tf_cit_tmpl
2024 * sturct config_item_type's
2026 fabric->tf_cit_tmpl.tfc_discovery_cit.ct_attrs = lio_target_discovery_auth_attrs;
2027 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = lio_target_wwn_attrs;
2028 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = lio_target_tpg_attrs;
2029 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = lio_target_tpg_attrib_attrs;
2030 fabric->tf_cit_tmpl.tfc_tpg_auth_cit.ct_attrs = lio_target_tpg_auth_attrs;
2031 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = lio_target_tpg_param_attrs;
2032 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = lio_target_portal_attrs;
2033 fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = lio_target_initiator_attrs;
2034 fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = lio_target_nacl_attrib_attrs;
2035 fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = lio_target_nacl_auth_attrs;
2036 fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = lio_target_nacl_param_attrs;
2038 ret = target_fabric_configfs_register(fabric);
2040 pr_err("target_fabric_configfs_register() for"
2041 " LIO-Target failed!\n");
2042 target_fabric_configfs_free(fabric);
2046 lio_target_fabric_configfs = fabric;
2047 pr_debug("LIO_TARGET[0] - Set fabric ->"
2048 " lio_target_fabric_configfs\n");
2053 void iscsi_target_deregister_configfs(void)
2055 if (!lio_target_fabric_configfs)
2058 * Shutdown discovery sessions and disable discovery TPG
2060 if (iscsit_global->discovery_tpg)
2061 iscsit_tpg_disable_portal_group(iscsit_global->discovery_tpg, 1);
2063 target_fabric_configfs_deregister(lio_target_fabric_configfs);
2064 lio_target_fabric_configfs = NULL;
2065 pr_debug("LIO_TARGET[0] - Cleared"
2066 " lio_target_fabric_configfs\n");