blob: 344e8448869c15c9e078ef708debf98cac1aae1a [file] [log] [blame]
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001/*******************************************************************************
2 * This file contains the configfs implementation for iSCSI Target mode
3 * from the LIO-Target Project.
4 *
Nicholas Bellinger4c762512013-09-05 15:29:12 -07005 * (c) Copyright 2007-2013 Datera, Inc.
Nicholas Bellingere48354c2011-07-23 06:43:04 +00006 *
7 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
8 *
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.
13 *
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 ****************************************************************************/
19
20#include <linux/configfs.h>
Jörn Engelad7babd2013-07-03 11:35:11 -040021#include <linux/ctype.h>
Paul Gortmakerc53181a2011-08-30 18:16:43 -040022#include <linux/export.h>
Stephen Rothwellc3bc93d2012-01-23 11:39:49 +110023#include <linux/inet.h>
Bart Van Assche8dcf07b2016-11-14 15:47:14 -080024#include <linux/module.h>
25#include <net/ipv6.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000026#include <target/target_core_base.h>
Christoph Hellwigc4795fb2011-11-16 09:46:48 -050027#include <target/target_core_fabric.h>
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -070028#include <target/iscsi/iscsi_transport.h>
Sagi Grimberg67f091f2015-01-07 14:57:31 +020029#include <target/iscsi/iscsi_target_core.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000030#include "iscsi_target_parameters.h"
31#include "iscsi_target_device.h"
32#include "iscsi_target_erl0.h"
33#include "iscsi_target_nodeattrib.h"
34#include "iscsi_target_tpg.h"
35#include "iscsi_target_util.h"
36#include "iscsi_target.h"
Sagi Grimberg67f091f2015-01-07 14:57:31 +020037#include <target/iscsi/iscsi_target_stat.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000038
Nicholas Bellingere48354c2011-07-23 06:43:04 +000039
Nicholas Bellingere48354c2011-07-23 06:43:04 +000040/* Start items for lio_target_portal_cit */
41
Christoph Hellwig2eafd722015-10-03 15:32:55 +020042static inline struct iscsi_tpg_np *to_iscsi_tpg_np(struct config_item *item)
Nicholas Bellingere48354c2011-07-23 06:43:04 +000043{
Christoph Hellwig2eafd722015-10-03 15:32:55 +020044 return container_of(to_tpg_np(item), struct iscsi_tpg_np, se_tpg_np);
45}
46
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070047static ssize_t lio_target_np_driver_show(struct config_item *item, char *page,
48 enum iscsit_transport_type type)
Christoph Hellwig2eafd722015-10-03 15:32:55 +020049{
50 struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070051 struct iscsi_tpg_np *tpg_np_new;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000052 ssize_t rb;
53
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070054 tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
55 if (tpg_np_new)
Nicholas Bellingere48354c2011-07-23 06:43:04 +000056 rb = sprintf(page, "1\n");
57 else
58 rb = sprintf(page, "0\n");
59
60 return rb;
61}
62
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070063static ssize_t lio_target_np_driver_store(struct config_item *item,
64 const char *page, size_t count, enum iscsit_transport_type type,
65 const char *mod_name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +000066{
Christoph Hellwig2eafd722015-10-03 15:32:55 +020067 struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +000068 struct iscsi_np *np;
69 struct iscsi_portal_group *tpg;
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070070 struct iscsi_tpg_np *tpg_np_new = NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000071 u32 op;
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070072 int rc;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000073
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070074 rc = kstrtou32(page, 0, &op);
75 if (rc)
76 return rc;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000077 if ((op != 1) && (op != 0)) {
78 pr_err("Illegal value for tpg_enable: %u\n", op);
79 return -EINVAL;
80 }
81 np = tpg_np->tpg_np;
82 if (!np) {
83 pr_err("Unable to locate struct iscsi_np from"
84 " struct iscsi_tpg_np\n");
85 return -EINVAL;
86 }
87
88 tpg = tpg_np->tpg;
89 if (iscsit_get_tpg(tpg) < 0)
90 return -EINVAL;
91
92 if (op) {
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070093 if (strlen(mod_name)) {
94 rc = request_module(mod_name);
95 if (rc != 0) {
96 pr_warn("Unable to request_module for %s\n",
97 mod_name);
98 rc = 0;
99 }
Andy Grover58bd0c62013-05-29 12:05:59 -0700100 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800101
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700102 tpg_np_new = iscsit_tpg_add_network_portal(tpg,
103 &np->np_sockaddr, tpg_np, type);
Varun Prakash83337e52016-12-11 22:05:56 +0530104 if (IS_ERR(tpg_np_new)) {
105 rc = PTR_ERR(tpg_np_new);
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800106 goto out;
Varun Prakash83337e52016-12-11 22:05:56 +0530107 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800108 } else {
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700109 tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
110 if (tpg_np_new) {
111 rc = iscsit_tpg_del_network_portal(tpg, tpg_np_new);
Andy Grover58bd0c62013-05-29 12:05:59 -0700112 if (rc < 0)
113 goto out;
114 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800115 }
116
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800117 iscsit_put_tpg(tpg);
118 return count;
119out:
120 iscsit_put_tpg(tpg);
Andy Grover58bd0c62013-05-29 12:05:59 -0700121 return rc;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800122}
123
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700124static ssize_t lio_target_np_iser_show(struct config_item *item, char *page)
Varun Prakash1c469602016-04-20 00:00:16 +0530125{
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700126 return lio_target_np_driver_show(item, page, ISCSI_INFINIBAND);
127}
Varun Prakash1c469602016-04-20 00:00:16 +0530128
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700129static ssize_t lio_target_np_iser_store(struct config_item *item,
130 const char *page, size_t count)
131{
132 return lio_target_np_driver_store(item, page, count,
133 ISCSI_INFINIBAND, "ib_isert");
134}
135CONFIGFS_ATTR(lio_target_np_, iser);
Varun Prakash1c469602016-04-20 00:00:16 +0530136
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700137static ssize_t lio_target_np_cxgbit_show(struct config_item *item, char *page)
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700138{
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700139 return lio_target_np_driver_show(item, page, ISCSI_CXGBIT);
Varun Prakash1c469602016-04-20 00:00:16 +0530140}
141
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700142static ssize_t lio_target_np_cxgbit_store(struct config_item *item,
143 const char *page, size_t count)
Varun Prakash1c469602016-04-20 00:00:16 +0530144{
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700145 return lio_target_np_driver_store(item, page, count,
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700146 ISCSI_CXGBIT, "cxgbit");
Varun Prakash1c469602016-04-20 00:00:16 +0530147}
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700148CONFIGFS_ATTR(lio_target_np_, cxgbit);
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800149
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000150static struct configfs_attribute *lio_target_portal_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200151 &lio_target_np_attr_iser,
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700152 &lio_target_np_attr_cxgbit,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000153 NULL,
154};
155
156/* Stop items for lio_target_portal_cit */
157
158/* Start items for lio_target_np_cit */
159
160#define MAX_PORTAL_LEN 256
161
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -0400162static struct se_tpg_np *lio_target_call_addnptotpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000163 struct se_portal_group *se_tpg,
164 struct config_group *group,
165 const char *name)
166{
167 struct iscsi_portal_group *tpg;
168 struct iscsi_tpg_np *tpg_np;
169 char *str, *str2, *ip_str, *port_str;
Andy Grover13a3cf02015-08-24 10:26:06 -0700170 struct sockaddr_storage sockaddr;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000171 struct sockaddr_in *sock_in;
172 struct sockaddr_in6 *sock_in6;
173 unsigned long port;
174 int ret;
175 char buf[MAX_PORTAL_LEN + 1];
176
177 if (strlen(name) > MAX_PORTAL_LEN) {
178 pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
179 (int)strlen(name), MAX_PORTAL_LEN);
180 return ERR_PTR(-EOVERFLOW);
181 }
182 memset(buf, 0, MAX_PORTAL_LEN + 1);
Nicholas Bellinger7bbb6542011-07-27 12:37:03 -0700183 snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000184
Andy Grover13a3cf02015-08-24 10:26:06 -0700185 memset(&sockaddr, 0, sizeof(struct sockaddr_storage));
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000186
187 str = strstr(buf, "[");
188 if (str) {
189 const char *end;
190
191 str2 = strstr(str, "]");
192 if (!str2) {
193 pr_err("Unable to locate trailing \"]\""
194 " in IPv6 iSCSI network portal address\n");
195 return ERR_PTR(-EINVAL);
196 }
197 str++; /* Skip over leading "[" */
Andy Grover76c28f12015-08-24 10:26:03 -0700198 *str2 = '\0'; /* Terminate the unbracketed IPv6 address */
199 str2++; /* Skip over the \0 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000200 port_str = strstr(str2, ":");
201 if (!port_str) {
202 pr_err("Unable to locate \":port\""
203 " in IPv6 iSCSI network portal address\n");
204 return ERR_PTR(-EINVAL);
205 }
206 *port_str = '\0'; /* Terminate string for IP */
207 port_str++; /* Skip over ":" */
208
Jingoo Han57103d72013-07-19 16:22:19 +0900209 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000210 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900211 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000212 return ERR_PTR(ret);
213 }
214 sock_in6 = (struct sockaddr_in6 *)&sockaddr;
215 sock_in6->sin6_family = AF_INET6;
216 sock_in6->sin6_port = htons((unsigned short)port);
Andy Groverdc58f762015-08-24 10:26:05 -0700217 ret = in6_pton(str, -1,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000218 (void *)&sock_in6->sin6_addr.in6_u, -1, &end);
219 if (ret <= 0) {
220 pr_err("in6_pton returned: %d\n", ret);
221 return ERR_PTR(-EINVAL);
222 }
223 } else {
224 str = ip_str = &buf[0];
225 port_str = strstr(ip_str, ":");
226 if (!port_str) {
227 pr_err("Unable to locate \":port\""
228 " in IPv4 iSCSI network portal address\n");
229 return ERR_PTR(-EINVAL);
230 }
231 *port_str = '\0'; /* Terminate string for IP */
232 port_str++; /* Skip over ":" */
233
Jingoo Han57103d72013-07-19 16:22:19 +0900234 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000235 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900236 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000237 return ERR_PTR(ret);
238 }
239 sock_in = (struct sockaddr_in *)&sockaddr;
240 sock_in->sin_family = AF_INET;
241 sock_in->sin_port = htons((unsigned short)port);
242 sock_in->sin_addr.s_addr = in_aton(ip_str);
243 }
244 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
245 ret = iscsit_get_tpg(tpg);
246 if (ret < 0)
247 return ERR_PTR(-EINVAL);
248
249 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
250 " PORTAL: %s\n",
251 config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
252 tpg->tpgt, name);
253 /*
254 * Assume ISCSI_TCP by default. Other network portals for other
255 * iSCSI fabrics:
256 *
257 * Traditional iSCSI over SCTP (initial support)
258 * iSER/TCP (TODO, hardware available)
259 * iSER/SCTP (TODO, software emulation with osc-iwarp)
260 * iSER/IB (TODO, hardware available)
261 *
Masanari Iida20879692012-08-27 22:46:00 +0900262 * can be enabled with attributes under
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000263 * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
264 *
265 */
Andy Grover76c28f12015-08-24 10:26:03 -0700266 tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, NULL,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000267 ISCSI_TCP);
268 if (IS_ERR(tpg_np)) {
269 iscsit_put_tpg(tpg);
Thomas Meyere1750ba2011-08-01 23:58:18 +0200270 return ERR_CAST(tpg_np);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000271 }
272 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
273
274 iscsit_put_tpg(tpg);
275 return &tpg_np->se_tpg_np;
276}
277
278static void lio_target_call_delnpfromtpg(
279 struct se_tpg_np *se_tpg_np)
280{
281 struct iscsi_portal_group *tpg;
282 struct iscsi_tpg_np *tpg_np;
283 struct se_portal_group *se_tpg;
284 int ret;
285
286 tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
287 tpg = tpg_np->tpg;
288 ret = iscsit_get_tpg(tpg);
289 if (ret < 0)
290 return;
291
292 se_tpg = &tpg->tpg_se_tpg;
293 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
Andy Grover69d75572015-08-24 10:26:04 -0700294 " PORTAL: %pISpc\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
295 tpg->tpgt, &tpg_np->tpg_np->np_sockaddr);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000296
297 ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
298 if (ret < 0)
299 goto out;
300
301 pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
302out:
303 iscsit_put_tpg(tpg);
304}
305
306/* End items for lio_target_np_cit */
307
308/* Start items for lio_target_nacl_attrib_cit */
309
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200310#define ISCSI_NACL_ATTR(name) \
311static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\
312 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000313{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200314 struct se_node_acl *se_nacl = attrib_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000315 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
316 se_node_acl); \
317 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700318 return sprintf(page, "%u\n", nacl->node_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000319} \
320 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200321static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\
322 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000323{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200324 struct se_node_acl *se_nacl = attrib_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000325 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
326 se_node_acl); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000327 u32 val; \
328 int ret; \
329 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400330 ret = kstrtou32(page, 0, &val); \
331 if (ret) \
332 return ret; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000333 ret = iscsit_na_##name(nacl, val); \
334 if (ret < 0) \
335 return ret; \
336 \
337 return count; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200338} \
339 \
340CONFIGFS_ATTR(iscsi_nacl_attrib_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000341
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200342ISCSI_NACL_ATTR(dataout_timeout);
343ISCSI_NACL_ATTR(dataout_timeout_retries);
344ISCSI_NACL_ATTR(default_erl);
345ISCSI_NACL_ATTR(nopin_timeout);
346ISCSI_NACL_ATTR(nopin_response_timeout);
347ISCSI_NACL_ATTR(random_datain_pdu_offsets);
348ISCSI_NACL_ATTR(random_datain_seq_offsets);
349ISCSI_NACL_ATTR(random_r2t_offsets);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000350
351static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200352 &iscsi_nacl_attrib_attr_dataout_timeout,
353 &iscsi_nacl_attrib_attr_dataout_timeout_retries,
354 &iscsi_nacl_attrib_attr_default_erl,
355 &iscsi_nacl_attrib_attr_nopin_timeout,
356 &iscsi_nacl_attrib_attr_nopin_response_timeout,
357 &iscsi_nacl_attrib_attr_random_datain_pdu_offsets,
358 &iscsi_nacl_attrib_attr_random_datain_seq_offsets,
359 &iscsi_nacl_attrib_attr_random_r2t_offsets,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000360 NULL,
361};
362
363/* End items for lio_target_nacl_attrib_cit */
364
365/* Start items for lio_target_nacl_auth_cit */
366
367#define __DEF_NACL_AUTH_STR(prefix, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200368static ssize_t __iscsi_##prefix##_##name##_show( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000369 struct iscsi_node_acl *nacl, \
370 char *page) \
371{ \
372 struct iscsi_node_auth *auth = &nacl->node_auth; \
373 \
374 if (!capable(CAP_SYS_ADMIN)) \
375 return -EPERM; \
376 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
377} \
378 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200379static ssize_t __iscsi_##prefix##_##name##_store( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000380 struct iscsi_node_acl *nacl, \
381 const char *page, \
382 size_t count) \
383{ \
384 struct iscsi_node_auth *auth = &nacl->node_auth; \
385 \
386 if (!capable(CAP_SYS_ADMIN)) \
387 return -EPERM; \
Eric Seppanen2306bfb2013-11-21 14:49:56 -0800388 if (count >= sizeof(auth->name)) \
389 return -EINVAL; \
Jörn Engel0fbfc462013-07-03 11:35:11 -0400390 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000391 if (!strncmp("NULL", auth->name, 4)) \
392 auth->naf_flags &= ~flags; \
393 else \
394 auth->naf_flags |= flags; \
395 \
396 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
397 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
398 auth->authenticate_target = 1; \
399 else \
400 auth->authenticate_target = 0; \
401 \
402 return count; \
403}
404
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200405#define DEF_NACL_AUTH_STR(name, flags) \
406 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
407static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
408 char *page) \
409{ \
410 struct se_node_acl *nacl = auth_to_nacl(item); \
411 return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
412 struct iscsi_node_acl, se_node_acl), page); \
413} \
414static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \
415 const char *page, size_t count) \
416{ \
417 struct se_node_acl *nacl = auth_to_nacl(item); \
418 return __iscsi_nacl_auth_##name##_store(container_of(nacl, \
419 struct iscsi_node_acl, se_node_acl), page, count); \
420} \
421 \
422CONFIGFS_ATTR(iscsi_nacl_auth_, name)
423
424/*
425 * One-way authentication userid
426 */
427DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
428DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
429DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
430DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
431
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000432#define __DEF_NACL_AUTH_INT(prefix, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200433static ssize_t __iscsi_##prefix##_##name##_show( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000434 struct iscsi_node_acl *nacl, \
435 char *page) \
436{ \
437 struct iscsi_node_auth *auth = &nacl->node_auth; \
438 \
439 if (!capable(CAP_SYS_ADMIN)) \
440 return -EPERM; \
441 \
442 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
443}
444
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000445#define DEF_NACL_AUTH_INT(name) \
446 __DEF_NACL_AUTH_INT(nacl_auth, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200447static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
448 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000449{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200450 struct se_node_acl *nacl = auth_to_nacl(item); \
451 return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
452 struct iscsi_node_acl, se_node_acl), page); \
453} \
454 \
455CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000456
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000457DEF_NACL_AUTH_INT(authenticate_target);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000458
459static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200460 &iscsi_nacl_auth_attr_userid,
461 &iscsi_nacl_auth_attr_password,
462 &iscsi_nacl_auth_attr_authenticate_target,
463 &iscsi_nacl_auth_attr_userid_mutual,
464 &iscsi_nacl_auth_attr_password_mutual,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000465 NULL,
466};
467
468/* End items for lio_target_nacl_auth_cit */
469
470/* Start items for lio_target_nacl_param_cit */
471
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200472#define ISCSI_NACL_PARAM(name) \
473static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \
474 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000475{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200476 struct se_node_acl *se_nacl = param_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000477 struct iscsi_session *sess; \
478 struct se_session *se_sess; \
479 ssize_t rb; \
480 \
481 spin_lock_bh(&se_nacl->nacl_sess_lock); \
482 se_sess = se_nacl->nacl_sess; \
483 if (!se_sess) { \
484 rb = snprintf(page, PAGE_SIZE, \
485 "No Active iSCSI Session\n"); \
486 } else { \
487 sess = se_sess->fabric_sess_ptr; \
488 rb = snprintf(page, PAGE_SIZE, "%u\n", \
489 (u32)sess->sess_ops->name); \
490 } \
491 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
492 \
493 return rb; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200494} \
495 \
496CONFIGFS_ATTR_RO(iscsi_nacl_param_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000497
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200498ISCSI_NACL_PARAM(MaxConnections);
499ISCSI_NACL_PARAM(InitialR2T);
500ISCSI_NACL_PARAM(ImmediateData);
501ISCSI_NACL_PARAM(MaxBurstLength);
502ISCSI_NACL_PARAM(FirstBurstLength);
503ISCSI_NACL_PARAM(DefaultTime2Wait);
504ISCSI_NACL_PARAM(DefaultTime2Retain);
505ISCSI_NACL_PARAM(MaxOutstandingR2T);
506ISCSI_NACL_PARAM(DataPDUInOrder);
507ISCSI_NACL_PARAM(DataSequenceInOrder);
508ISCSI_NACL_PARAM(ErrorRecoveryLevel);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000509
510static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200511 &iscsi_nacl_param_attr_MaxConnections,
512 &iscsi_nacl_param_attr_InitialR2T,
513 &iscsi_nacl_param_attr_ImmediateData,
514 &iscsi_nacl_param_attr_MaxBurstLength,
515 &iscsi_nacl_param_attr_FirstBurstLength,
516 &iscsi_nacl_param_attr_DefaultTime2Wait,
517 &iscsi_nacl_param_attr_DefaultTime2Retain,
518 &iscsi_nacl_param_attr_MaxOutstandingR2T,
519 &iscsi_nacl_param_attr_DataPDUInOrder,
520 &iscsi_nacl_param_attr_DataSequenceInOrder,
521 &iscsi_nacl_param_attr_ErrorRecoveryLevel,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000522 NULL,
523};
524
525/* End items for lio_target_nacl_param_cit */
526
527/* Start items for lio_target_acl_cit */
528
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200529static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000530{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200531 struct se_node_acl *se_nacl = acl_to_nacl(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000532 struct iscsi_session *sess;
533 struct iscsi_conn *conn;
534 struct se_session *se_sess;
535 ssize_t rb = 0;
Roland Dreier109e2382015-07-23 14:53:32 -0700536 u32 max_cmd_sn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000537
538 spin_lock_bh(&se_nacl->nacl_sess_lock);
539 se_sess = se_nacl->nacl_sess;
540 if (!se_sess) {
541 rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
542 " Endpoint: %s\n", se_nacl->initiatorname);
543 } else {
544 sess = se_sess->fabric_sess_ptr;
545
Joern Engelcb354842014-09-02 17:49:50 -0400546 rb += sprintf(page+rb, "InitiatorName: %s\n",
547 sess->sess_ops->InitiatorName);
548 rb += sprintf(page+rb, "InitiatorAlias: %s\n",
549 sess->sess_ops->InitiatorAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000550
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +0200551 rb += sprintf(page+rb,
552 "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
553 sess->sid, sess->isid, sess->tsih);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000554 rb += sprintf(page+rb, "SessionType: %s\n",
555 (sess->sess_ops->SessionType) ?
556 "Discovery" : "Normal");
557 rb += sprintf(page+rb, "Session State: ");
558 switch (sess->session_state) {
559 case TARG_SESS_STATE_FREE:
560 rb += sprintf(page+rb, "TARG_SESS_FREE\n");
561 break;
562 case TARG_SESS_STATE_ACTIVE:
563 rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
564 break;
565 case TARG_SESS_STATE_LOGGED_IN:
566 rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
567 break;
568 case TARG_SESS_STATE_FAILED:
569 rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
570 break;
571 case TARG_SESS_STATE_IN_CONTINUE:
572 rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
573 break;
574 default:
575 rb += sprintf(page+rb, "ERROR: Unknown Session"
576 " State!\n");
577 break;
578 }
579
580 rb += sprintf(page+rb, "---------------------[iSCSI Session"
581 " Values]-----------------------\n");
582 rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
583 " : MaxCmdSN : ITT : TTT\n");
Roland Dreier109e2382015-07-23 14:53:32 -0700584 max_cmd_sn = (u32) atomic_read(&sess->max_cmd_sn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000585 rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
586 " 0x%08x 0x%08x\n",
587 sess->cmdsn_window,
Roland Dreier109e2382015-07-23 14:53:32 -0700588 (max_cmd_sn - sess->exp_cmd_sn) + 1,
589 sess->exp_cmd_sn, max_cmd_sn,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000590 sess->init_task_tag, sess->targ_xfer_tag);
591 rb += sprintf(page+rb, "----------------------[iSCSI"
592 " Connections]-------------------------\n");
593
594 spin_lock(&sess->conn_lock);
595 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
596 rb += sprintf(page+rb, "CID: %hu Connection"
597 " State: ", conn->cid);
598 switch (conn->conn_state) {
599 case TARG_CONN_STATE_FREE:
600 rb += sprintf(page+rb,
601 "TARG_CONN_STATE_FREE\n");
602 break;
603 case TARG_CONN_STATE_XPT_UP:
604 rb += sprintf(page+rb,
605 "TARG_CONN_STATE_XPT_UP\n");
606 break;
607 case TARG_CONN_STATE_IN_LOGIN:
608 rb += sprintf(page+rb,
609 "TARG_CONN_STATE_IN_LOGIN\n");
610 break;
611 case TARG_CONN_STATE_LOGGED_IN:
612 rb += sprintf(page+rb,
613 "TARG_CONN_STATE_LOGGED_IN\n");
614 break;
615 case TARG_CONN_STATE_IN_LOGOUT:
616 rb += sprintf(page+rb,
617 "TARG_CONN_STATE_IN_LOGOUT\n");
618 break;
619 case TARG_CONN_STATE_LOGOUT_REQUESTED:
620 rb += sprintf(page+rb,
621 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
622 break;
623 case TARG_CONN_STATE_CLEANUP_WAIT:
624 rb += sprintf(page+rb,
625 "TARG_CONN_STATE_CLEANUP_WAIT\n");
626 break;
627 default:
628 rb += sprintf(page+rb,
629 "ERROR: Unknown Connection State!\n");
630 break;
631 }
632
Andy Groverdc58f762015-08-24 10:26:05 -0700633 rb += sprintf(page+rb, " Address %pISc %s", &conn->login_sockaddr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000634 (conn->network_transport == ISCSI_TCP) ?
635 "TCP" : "SCTP");
636 rb += sprintf(page+rb, " StatSN: 0x%08x\n",
637 conn->stat_sn);
638 }
639 spin_unlock(&sess->conn_lock);
640 }
641 spin_unlock_bh(&se_nacl->nacl_sess_lock);
642
643 return rb;
644}
645
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200646static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item,
647 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000648{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200649 return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000650}
651
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200652static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item,
653 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000654{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200655 struct se_node_acl *se_nacl = acl_to_nacl(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000656 struct se_portal_group *se_tpg = se_nacl->se_tpg;
657 struct iscsi_portal_group *tpg = container_of(se_tpg,
658 struct iscsi_portal_group, tpg_se_tpg);
659 struct config_item *acl_ci, *tpg_ci, *wwn_ci;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000660 u32 cmdsn_depth = 0;
661 int ret;
662
Jörn Engelad7babd2013-07-03 11:35:11 -0400663 ret = kstrtou32(page, 0, &cmdsn_depth);
664 if (ret)
665 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000666 if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
667 pr_err("Passed cmdsn_depth: %u exceeds"
668 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
669 TA_DEFAULT_CMDSN_DEPTH_MAX);
670 return -EINVAL;
671 }
672 acl_ci = &se_nacl->acl_group.cg_item;
673 if (!acl_ci) {
674 pr_err("Unable to locatel acl_ci\n");
675 return -EINVAL;
676 }
677 tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
678 if (!tpg_ci) {
679 pr_err("Unable to locate tpg_ci\n");
680 return -EINVAL;
681 }
682 wwn_ci = &tpg_ci->ci_group->cg_item;
683 if (!wwn_ci) {
684 pr_err("Unable to locate config_item wwn_ci\n");
685 return -EINVAL;
686 }
687
688 if (iscsit_get_tpg(tpg) < 0)
689 return -EINVAL;
Nicholas Bellingerd36ad772016-01-07 22:15:06 -0800690
691 ret = core_tpg_set_initiator_node_queue_depth(se_nacl, cmdsn_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000692
693 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
694 "InitiatorName: %s\n", config_item_name(wwn_ci),
695 config_item_name(tpg_ci), cmdsn_depth,
696 config_item_name(acl_ci));
697
698 iscsit_put_tpg(tpg);
699 return (!ret) ? count : (ssize_t)ret;
700}
701
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200702static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page)
Andy Grover79e62fc2012-12-11 16:30:53 -0800703{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200704 return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag);
Andy Grover79e62fc2012-12-11 16:30:53 -0800705}
706
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200707static ssize_t lio_target_nacl_tag_store(struct config_item *item,
708 const char *page, size_t count)
Andy Grover79e62fc2012-12-11 16:30:53 -0800709{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200710 struct se_node_acl *se_nacl = acl_to_nacl(item);
Andy Grover79e62fc2012-12-11 16:30:53 -0800711 int ret;
712
713 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
714
715 if (ret < 0)
716 return ret;
717 return count;
718}
719
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200720CONFIGFS_ATTR_RO(lio_target_nacl_, info);
721CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth);
722CONFIGFS_ATTR(lio_target_nacl_, tag);
Andy Grover79e62fc2012-12-11 16:30:53 -0800723
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000724static struct configfs_attribute *lio_target_initiator_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200725 &lio_target_nacl_attr_info,
726 &lio_target_nacl_attr_cmdsn_depth,
727 &lio_target_nacl_attr_tag,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000728 NULL,
729};
730
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200731static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
732 const char *name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000733{
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200734 struct iscsi_node_acl *acl =
735 container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000736
Andy Groverb7eec2c2013-10-09 11:05:57 -0700737 config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000738 "iscsi_sess_stats", &iscsi_stat_sess_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +0100739 configfs_add_default_group(&acl->node_stat_grps.iscsi_sess_stats_group,
740 &se_nacl->acl_fabric_stat_group);
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200741 return 0;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000742}
743
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000744/* End items for lio_target_acl_cit */
745
746/* Start items for lio_target_tpg_attrib_cit */
747
748#define DEF_TPG_ATTRIB(name) \
749 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200750static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \
751 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000752{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200753 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000754 struct iscsi_portal_group *tpg = container_of(se_tpg, \
755 struct iscsi_portal_group, tpg_se_tpg); \
756 ssize_t rb; \
757 \
758 if (iscsit_get_tpg(tpg) < 0) \
759 return -EINVAL; \
760 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700761 rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000762 iscsit_put_tpg(tpg); \
763 return rb; \
764} \
765 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200766static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\
767 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000768{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200769 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000770 struct iscsi_portal_group *tpg = container_of(se_tpg, \
771 struct iscsi_portal_group, tpg_se_tpg); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000772 u32 val; \
773 int ret; \
774 \
775 if (iscsit_get_tpg(tpg) < 0) \
776 return -EINVAL; \
777 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400778 ret = kstrtou32(page, 0, &val); \
779 if (ret) \
780 goto out; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000781 ret = iscsit_ta_##name(tpg, val); \
782 if (ret < 0) \
783 goto out; \
784 \
785 iscsit_put_tpg(tpg); \
786 return count; \
787out: \
788 iscsit_put_tpg(tpg); \
789 return ret; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200790} \
791CONFIGFS_ATTR(iscsi_tpg_attrib_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000792
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000793DEF_TPG_ATTRIB(authentication);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000794DEF_TPG_ATTRIB(login_timeout);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000795DEF_TPG_ATTRIB(netif_timeout);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000796DEF_TPG_ATTRIB(generate_node_acls);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000797DEF_TPG_ATTRIB(default_cmdsn_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000798DEF_TPG_ATTRIB(cache_dynamic_acls);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000799DEF_TPG_ATTRIB(demo_mode_write_protect);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000800DEF_TPG_ATTRIB(prod_mode_write_protect);
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +0200801DEF_TPG_ATTRIB(demo_mode_discovery);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -0800802DEF_TPG_ATTRIB(default_erl);
Sagi Grimberg80851762014-02-19 17:50:20 +0200803DEF_TPG_ATTRIB(t10_pi);
Nicholas Bellinger901c04a2015-03-29 19:36:16 -0700804DEF_TPG_ATTRIB(fabric_prot_type);
David Disseldorpa6415cd2015-08-01 00:10:12 -0700805DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000806
807static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200808 &iscsi_tpg_attrib_attr_authentication,
809 &iscsi_tpg_attrib_attr_login_timeout,
810 &iscsi_tpg_attrib_attr_netif_timeout,
811 &iscsi_tpg_attrib_attr_generate_node_acls,
812 &iscsi_tpg_attrib_attr_default_cmdsn_depth,
813 &iscsi_tpg_attrib_attr_cache_dynamic_acls,
814 &iscsi_tpg_attrib_attr_demo_mode_write_protect,
815 &iscsi_tpg_attrib_attr_prod_mode_write_protect,
816 &iscsi_tpg_attrib_attr_demo_mode_discovery,
817 &iscsi_tpg_attrib_attr_default_erl,
818 &iscsi_tpg_attrib_attr_t10_pi,
819 &iscsi_tpg_attrib_attr_fabric_prot_type,
820 &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000821 NULL,
822};
823
824/* End items for lio_target_tpg_attrib_cit */
825
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700826/* Start items for lio_target_tpg_auth_cit */
827
828#define __DEF_TPG_AUTH_STR(prefix, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200829static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
830 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700831{ \
832 struct iscsi_portal_group *tpg = container_of(se_tpg, \
833 struct iscsi_portal_group, tpg_se_tpg); \
834 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
835 \
836 if (!capable(CAP_SYS_ADMIN)) \
837 return -EPERM; \
838 \
839 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
840} \
841 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200842static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\
843 const char *page, size_t count) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700844{ \
845 struct iscsi_portal_group *tpg = container_of(se_tpg, \
846 struct iscsi_portal_group, tpg_se_tpg); \
847 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
848 \
849 if (!capable(CAP_SYS_ADMIN)) \
850 return -EPERM; \
851 \
Nicholas Bellinger37b32c62013-07-06 16:48:55 -0700852 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700853 if (!(strncmp("NULL", auth->name, 4))) \
854 auth->naf_flags &= ~flags; \
855 else \
856 auth->naf_flags |= flags; \
857 \
858 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
859 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
860 auth->authenticate_target = 1; \
861 else \
862 auth->authenticate_target = 0; \
863 \
864 return count; \
865}
866
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200867#define DEF_TPG_AUTH_STR(name, flags) \
868 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
869static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
870 char *page) \
871{ \
872 return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
873} \
874 \
875static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \
876 const char *page, size_t count) \
877{ \
878 return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \
879} \
880 \
881CONFIGFS_ATTR(iscsi_tpg_auth_, name);
882
883
884DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
885DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
886DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
887DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
888
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700889#define __DEF_TPG_AUTH_INT(prefix, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200890static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
891 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700892{ \
893 struct iscsi_portal_group *tpg = container_of(se_tpg, \
894 struct iscsi_portal_group, tpg_se_tpg); \
895 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
896 \
897 if (!capable(CAP_SYS_ADMIN)) \
898 return -EPERM; \
899 \
900 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
901}
902
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700903#define DEF_TPG_AUTH_INT(name) \
904 __DEF_TPG_AUTH_INT(tpg_auth, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200905static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
906 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700907{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200908 return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
909} \
910CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name);
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700911
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700912DEF_TPG_AUTH_INT(authenticate_target);
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700913
914static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200915 &iscsi_tpg_auth_attr_userid,
916 &iscsi_tpg_auth_attr_password,
917 &iscsi_tpg_auth_attr_authenticate_target,
918 &iscsi_tpg_auth_attr_userid_mutual,
919 &iscsi_tpg_auth_attr_password_mutual,
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700920 NULL,
921};
922
923/* End items for lio_target_tpg_auth_cit */
924
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000925/* Start items for lio_target_tpg_param_cit */
926
927#define DEF_TPG_PARAM(name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200928static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \
929 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000930{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200931 struct se_portal_group *se_tpg = param_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000932 struct iscsi_portal_group *tpg = container_of(se_tpg, \
933 struct iscsi_portal_group, tpg_se_tpg); \
934 struct iscsi_param *param; \
935 ssize_t rb; \
936 \
937 if (iscsit_get_tpg(tpg) < 0) \
938 return -EINVAL; \
939 \
940 param = iscsi_find_param_from_key(__stringify(name), \
941 tpg->param_list); \
942 if (!param) { \
943 iscsit_put_tpg(tpg); \
944 return -EINVAL; \
945 } \
946 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
947 \
948 iscsit_put_tpg(tpg); \
949 return rb; \
950} \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200951static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \
952 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000953{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200954 struct se_portal_group *se_tpg = param_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000955 struct iscsi_portal_group *tpg = container_of(se_tpg, \
956 struct iscsi_portal_group, tpg_se_tpg); \
957 char *buf; \
Jörn Engelad7babd2013-07-03 11:35:11 -0400958 int ret, len; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000959 \
960 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
961 if (!buf) \
962 return -ENOMEM; \
Jörn Engelad7babd2013-07-03 11:35:11 -0400963 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
964 if (isspace(buf[len-1])) \
965 buf[len-1] = '\0'; /* Kill newline */ \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000966 \
967 if (iscsit_get_tpg(tpg) < 0) { \
968 kfree(buf); \
969 return -EINVAL; \
970 } \
971 \
972 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
973 if (ret < 0) \
974 goto out; \
975 \
976 kfree(buf); \
977 iscsit_put_tpg(tpg); \
978 return count; \
979out: \
980 kfree(buf); \
981 iscsit_put_tpg(tpg); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200982 return -EINVAL; \
983} \
984CONFIGFS_ATTR(iscsi_tpg_param_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000985
986DEF_TPG_PARAM(AuthMethod);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000987DEF_TPG_PARAM(HeaderDigest);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000988DEF_TPG_PARAM(DataDigest);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000989DEF_TPG_PARAM(MaxConnections);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000990DEF_TPG_PARAM(TargetAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000991DEF_TPG_PARAM(InitialR2T);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000992DEF_TPG_PARAM(ImmediateData);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000993DEF_TPG_PARAM(MaxRecvDataSegmentLength);
Nicholas Bellingere004cb22012-09-29 21:47:16 -0700994DEF_TPG_PARAM(MaxXmitDataSegmentLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000995DEF_TPG_PARAM(MaxBurstLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000996DEF_TPG_PARAM(FirstBurstLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000997DEF_TPG_PARAM(DefaultTime2Wait);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000998DEF_TPG_PARAM(DefaultTime2Retain);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000999DEF_TPG_PARAM(MaxOutstandingR2T);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001000DEF_TPG_PARAM(DataPDUInOrder);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001001DEF_TPG_PARAM(DataSequenceInOrder);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001002DEF_TPG_PARAM(ErrorRecoveryLevel);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001003DEF_TPG_PARAM(IFMarker);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001004DEF_TPG_PARAM(OFMarker);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001005DEF_TPG_PARAM(IFMarkInt);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001006DEF_TPG_PARAM(OFMarkInt);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001007
1008static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001009 &iscsi_tpg_param_attr_AuthMethod,
1010 &iscsi_tpg_param_attr_HeaderDigest,
1011 &iscsi_tpg_param_attr_DataDigest,
1012 &iscsi_tpg_param_attr_MaxConnections,
1013 &iscsi_tpg_param_attr_TargetAlias,
1014 &iscsi_tpg_param_attr_InitialR2T,
1015 &iscsi_tpg_param_attr_ImmediateData,
1016 &iscsi_tpg_param_attr_MaxRecvDataSegmentLength,
1017 &iscsi_tpg_param_attr_MaxXmitDataSegmentLength,
1018 &iscsi_tpg_param_attr_MaxBurstLength,
1019 &iscsi_tpg_param_attr_FirstBurstLength,
1020 &iscsi_tpg_param_attr_DefaultTime2Wait,
1021 &iscsi_tpg_param_attr_DefaultTime2Retain,
1022 &iscsi_tpg_param_attr_MaxOutstandingR2T,
1023 &iscsi_tpg_param_attr_DataPDUInOrder,
1024 &iscsi_tpg_param_attr_DataSequenceInOrder,
1025 &iscsi_tpg_param_attr_ErrorRecoveryLevel,
1026 &iscsi_tpg_param_attr_IFMarker,
1027 &iscsi_tpg_param_attr_OFMarker,
1028 &iscsi_tpg_param_attr_IFMarkInt,
1029 &iscsi_tpg_param_attr_OFMarkInt,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001030 NULL,
1031};
1032
1033/* End items for lio_target_tpg_param_cit */
1034
1035/* Start items for lio_target_tpg_cit */
1036
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001037static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001038{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001039 struct se_portal_group *se_tpg = to_tpg(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001040 struct iscsi_portal_group *tpg = container_of(se_tpg,
1041 struct iscsi_portal_group, tpg_se_tpg);
1042 ssize_t len;
1043
1044 spin_lock(&tpg->tpg_state_lock);
1045 len = sprintf(page, "%d\n",
1046 (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
1047 spin_unlock(&tpg->tpg_state_lock);
1048
1049 return len;
1050}
1051
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001052static ssize_t lio_target_tpg_enable_store(struct config_item *item,
1053 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001054{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001055 struct se_portal_group *se_tpg = to_tpg(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001056 struct iscsi_portal_group *tpg = container_of(se_tpg,
1057 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001058 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001059 int ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001060
Jörn Engelad7babd2013-07-03 11:35:11 -04001061 ret = kstrtou32(page, 0, &op);
1062 if (ret)
1063 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001064 if ((op != 1) && (op != 0)) {
1065 pr_err("Illegal value for tpg_enable: %u\n", op);
1066 return -EINVAL;
1067 }
1068
1069 ret = iscsit_get_tpg(tpg);
1070 if (ret < 0)
1071 return -EINVAL;
1072
1073 if (op) {
1074 ret = iscsit_tpg_enable_portal_group(tpg);
1075 if (ret < 0)
1076 goto out;
1077 } else {
1078 /*
1079 * iscsit_tpg_disable_portal_group() assumes force=1
1080 */
1081 ret = iscsit_tpg_disable_portal_group(tpg, 1);
1082 if (ret < 0)
1083 goto out;
1084 }
1085
1086 iscsit_put_tpg(tpg);
1087 return count;
1088out:
1089 iscsit_put_tpg(tpg);
1090 return -EINVAL;
1091}
1092
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001093
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001094static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item,
1095 char *page)
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001096{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001097 return target_show_dynamic_sessions(to_tpg(item), page);
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001098}
1099
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001100CONFIGFS_ATTR(lio_target_tpg_, enable);
1101CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions);
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001102
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001103static struct configfs_attribute *lio_target_tpg_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001104 &lio_target_tpg_attr_enable,
1105 &lio_target_tpg_attr_dynamic_sessions,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001106 NULL,
1107};
1108
1109/* End items for lio_target_tpg_cit */
1110
1111/* Start items for lio_target_tiqn_cit */
1112
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001113static struct se_portal_group *lio_target_tiqn_addtpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001114 struct se_wwn *wwn,
1115 struct config_group *group,
1116 const char *name)
1117{
1118 struct iscsi_portal_group *tpg;
1119 struct iscsi_tiqn *tiqn;
Jörn Engelad7babd2013-07-03 11:35:11 -04001120 char *tpgt_str;
1121 int ret;
1122 u16 tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001123
1124 tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1125 /*
1126 * Only tpgt_# directory groups can be created below
1127 * target/iscsi/iqn.superturodiskarry/
Jörn Engelad7babd2013-07-03 11:35:11 -04001128 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001129 tpgt_str = strstr(name, "tpgt_");
1130 if (!tpgt_str) {
1131 pr_err("Unable to locate \"tpgt_#\" directory"
1132 " group\n");
1133 return NULL;
1134 }
1135 tpgt_str += 5; /* Skip ahead of "tpgt_" */
Jörn Engelad7babd2013-07-03 11:35:11 -04001136 ret = kstrtou16(tpgt_str, 0, &tpgt);
1137 if (ret)
1138 return NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001139
1140 tpg = iscsit_alloc_portal_group(tiqn, tpgt);
1141 if (!tpg)
1142 return NULL;
1143
Nicholas Bellingerbc0c94b2015-05-20 21:48:03 -07001144 ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001145 if (ret < 0)
1146 return NULL;
1147
1148 ret = iscsit_tpg_add_portal_group(tiqn, tpg);
1149 if (ret != 0)
1150 goto out;
1151
1152 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1153 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1154 name);
1155 return &tpg->tpg_se_tpg;
1156out:
1157 core_tpg_deregister(&tpg->tpg_se_tpg);
1158 kfree(tpg);
1159 return NULL;
1160}
1161
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001162static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001163{
1164 struct iscsi_portal_group *tpg;
1165 struct iscsi_tiqn *tiqn;
1166
1167 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1168 tiqn = tpg->tpg_tiqn;
1169 /*
1170 * iscsit_tpg_del_portal_group() assumes force=1
1171 */
1172 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1173 iscsit_tpg_del_portal_group(tiqn, tpg, 1);
1174}
1175
1176/* End items for lio_target_tiqn_cit */
1177
1178/* Start LIO-Target TIQN struct contig_item lio_target_cit */
1179
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001180static ssize_t lio_target_wwn_lio_version_show(struct config_item *item,
1181 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001182{
Nicholas Bellinger4c762512013-09-05 15:29:12 -07001183 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001184}
1185
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001186CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001187
1188static struct configfs_attribute *lio_target_wwn_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001189 &lio_target_wwn_attr_lio_version,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001190 NULL,
1191};
1192
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001193static struct se_wwn *lio_target_call_coreaddtiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001194 struct target_fabric_configfs *tf,
1195 struct config_group *group,
1196 const char *name)
1197{
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001198 struct iscsi_tiqn *tiqn;
1199
1200 tiqn = iscsit_add_tiqn((unsigned char *)name);
1201 if (IS_ERR(tiqn))
Thomas Meyere1750ba2011-08-01 23:58:18 +02001202 return ERR_CAST(tiqn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001203
Christoph Hellwig839559e2016-03-29 13:03:35 +02001204 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1205 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1206 " %s\n", name);
1207 return &tiqn->tiqn_wwn;
1208}
1209
1210static void lio_target_add_wwn_groups(struct se_wwn *wwn)
1211{
1212 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1213
Andy Groverb7eec2c2013-10-09 11:05:57 -07001214 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001215 "iscsi_instance", &iscsi_stat_instance_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001216 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
1217 &tiqn->tiqn_wwn.fabric_stat_group);
1218
Andy Groverb7eec2c2013-10-09 11:05:57 -07001219 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001220 "iscsi_sess_err", &iscsi_stat_sess_err_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001221 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
1222 &tiqn->tiqn_wwn.fabric_stat_group);
1223
Andy Groverb7eec2c2013-10-09 11:05:57 -07001224 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001225 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001226 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
1227 &tiqn->tiqn_wwn.fabric_stat_group);
1228
Andy Groverb7eec2c2013-10-09 11:05:57 -07001229 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001230 "iscsi_login_stats", &iscsi_stat_login_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001231 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
1232 &tiqn->tiqn_wwn.fabric_stat_group);
1233
Andy Groverb7eec2c2013-10-09 11:05:57 -07001234 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001235 "iscsi_logout_stats", &iscsi_stat_logout_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001236 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
1237 &tiqn->tiqn_wwn.fabric_stat_group);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001238}
1239
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001240static void lio_target_call_coredeltiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001241 struct se_wwn *wwn)
1242{
1243 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001244
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001245 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1246 tiqn->tiqn);
1247 iscsit_del_tiqn(tiqn);
1248}
1249
1250/* End LIO-Target TIQN struct contig_lio_target_cit */
1251
1252/* Start lio_target_discovery_auth_cit */
1253
1254#define DEF_DISC_AUTH_STR(name, flags) \
1255 __DEF_NACL_AUTH_STR(disc, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001256static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001257{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001258 return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001259 page); \
1260} \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001261static ssize_t iscsi_disc_##name##_store(struct config_item *item, \
1262 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001263{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001264 return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001265 page, count); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001266 \
1267} \
1268CONFIGFS_ATTR(iscsi_disc_, name)
1269
1270DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
1271DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
1272DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1273DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001274
1275#define DEF_DISC_AUTH_INT(name) \
1276 __DEF_NACL_AUTH_INT(disc, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001277static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001278{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001279 return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001280 page); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001281} \
1282CONFIGFS_ATTR_RO(iscsi_disc_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001283
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001284DEF_DISC_AUTH_INT(authenticate_target);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001285
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001286
1287static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item,
1288 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001289{
1290 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
1291
1292 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
1293}
1294
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001295static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1296 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001297{
1298 struct iscsi_param *param;
1299 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001300 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001301 int err;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001302
Jörn Engelad7babd2013-07-03 11:35:11 -04001303 err = kstrtou32(page, 0, &op);
1304 if (err)
1305 return -EINVAL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001306 if ((op != 1) && (op != 0)) {
1307 pr_err("Illegal value for enforce_discovery_auth:"
1308 " %u\n", op);
1309 return -EINVAL;
1310 }
1311
1312 if (!discovery_tpg) {
1313 pr_err("iscsit_global->discovery_tpg is NULL\n");
1314 return -EINVAL;
1315 }
1316
1317 param = iscsi_find_param_from_key(AUTHMETHOD,
1318 discovery_tpg->param_list);
1319 if (!param)
1320 return -EINVAL;
1321
1322 if (op) {
1323 /*
1324 * Reset the AuthMethod key to CHAP.
1325 */
1326 if (iscsi_update_param_value(param, CHAP) < 0)
1327 return -EINVAL;
1328
1329 discovery_tpg->tpg_attrib.authentication = 1;
1330 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
1331 pr_debug("LIO-CORE[0] Successfully enabled"
1332 " authentication enforcement for iSCSI"
1333 " Discovery TPG\n");
1334 } else {
1335 /*
1336 * Reset the AuthMethod key to CHAP,None
1337 */
1338 if (iscsi_update_param_value(param, "CHAP,None") < 0)
1339 return -EINVAL;
1340
1341 discovery_tpg->tpg_attrib.authentication = 0;
1342 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
1343 pr_debug("LIO-CORE[0] Successfully disabled"
1344 " authentication enforcement for iSCSI"
1345 " Discovery TPG\n");
1346 }
1347
1348 return count;
1349}
1350
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001351CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001352
1353static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001354 &iscsi_disc_attr_userid,
1355 &iscsi_disc_attr_password,
1356 &iscsi_disc_attr_authenticate_target,
1357 &iscsi_disc_attr_userid_mutual,
1358 &iscsi_disc_attr_password_mutual,
1359 &iscsi_disc_attr_enforce_discovery_auth,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001360 NULL,
1361};
1362
1363/* End lio_target_discovery_auth_cit */
1364
1365/* Start functions for target_core_fabric_ops */
1366
1367static char *iscsi_get_fabric_name(void)
1368{
1369 return "iSCSI";
1370}
1371
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001372static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1373{
1374 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1375
1376 return cmd->i_state;
1377}
1378
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001379static u32 lio_sess_get_index(struct se_session *se_sess)
1380{
1381 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1382
1383 return sess->session_index;
1384}
1385
1386static u32 lio_sess_get_initiator_sid(
1387 struct se_session *se_sess,
1388 unsigned char *buf,
1389 u32 size)
1390{
1391 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1392 /*
1393 * iSCSI Initiator Session Identifier from RFC-3720.
1394 */
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +02001395 return snprintf(buf, size, "%6phN", sess->isid);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001396}
1397
1398static int lio_queue_data_in(struct se_cmd *se_cmd)
1399{
1400 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellingera4467012016-10-30 17:30:08 -07001401 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001402
1403 cmd->i_state = ISTATE_SEND_DATAIN;
Nicholas Bellingera4467012016-10-30 17:30:08 -07001404 return conn->conn_transport->iscsit_queue_data_in(conn, cmd);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001405}
1406
1407static int lio_write_pending(struct se_cmd *se_cmd)
1408{
1409 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001410 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001411
1412 if (!cmd->immediate_data && !cmd->unsolicited_data)
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001413 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001414
1415 return 0;
1416}
1417
1418static int lio_write_pending_status(struct se_cmd *se_cmd)
1419{
1420 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1421 int ret;
1422
1423 spin_lock_bh(&cmd->istate_lock);
1424 ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
1425 spin_unlock_bh(&cmd->istate_lock);
1426
1427 return ret;
1428}
1429
1430static int lio_queue_status(struct se_cmd *se_cmd)
1431{
1432 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellingera4467012016-10-30 17:30:08 -07001433 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001434
1435 cmd->i_state = ISTATE_SEND_STATUS;
Nicholas Bellinger5e8e6b42013-11-12 17:54:56 -08001436
1437 if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
Nicholas Bellingera4467012016-10-30 17:30:08 -07001438 return iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
Nicholas Bellinger5e8e6b42013-11-12 17:54:56 -08001439 }
Nicholas Bellingera4467012016-10-30 17:30:08 -07001440 return conn->conn_transport->iscsit_queue_status(conn, cmd);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001441}
1442
Joern Engelb79fafa2013-07-03 11:22:17 -04001443static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001444{
1445 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1446
1447 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
1448 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001449}
1450
Nicholas Bellinger131e6ab2014-03-22 14:55:56 -07001451static void lio_aborted_task(struct se_cmd *se_cmd)
1452{
1453 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1454
1455 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
1456}
1457
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001458static inline struct iscsi_portal_group *iscsi_tpg(struct se_portal_group *se_tpg)
1459{
1460 return container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1461}
1462
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001463static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
1464{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001465 return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001466}
1467
1468static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
1469{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001470 return iscsi_tpg(se_tpg)->tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001471}
1472
1473static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
1474{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001475 return iscsi_tpg(se_tpg)->tpg_attrib.default_cmdsn_depth;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001476}
1477
1478static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
1479{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001480 return iscsi_tpg(se_tpg)->tpg_attrib.generate_node_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001481}
1482
1483static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
1484{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001485 return iscsi_tpg(se_tpg)->tpg_attrib.cache_dynamic_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001486}
1487
1488static int lio_tpg_check_demo_mode_write_protect(
1489 struct se_portal_group *se_tpg)
1490{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001491 return iscsi_tpg(se_tpg)->tpg_attrib.demo_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001492}
1493
1494static int lio_tpg_check_prod_mode_write_protect(
1495 struct se_portal_group *se_tpg)
1496{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001497 return iscsi_tpg(se_tpg)->tpg_attrib.prod_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001498}
1499
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001500static int lio_tpg_check_prot_fabric_only(
1501 struct se_portal_group *se_tpg)
1502{
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001503 /*
1504 * Only report fabric_prot_type if t10_pi has also been enabled
1505 * for incoming ib_isert sessions.
1506 */
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001507 if (!iscsi_tpg(se_tpg)->tpg_attrib.t10_pi)
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001508 return 0;
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001509 return iscsi_tpg(se_tpg)->tpg_attrib.fabric_prot_type;
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001510}
1511
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001512/*
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001513 * This function calls iscsit_inc_session_usage_count() on the
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001514 * struct iscsi_session in question.
1515 */
Christoph Hellwig44f33d02016-05-02 15:45:24 +02001516static void lio_tpg_close_session(struct se_session *se_sess)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001517{
1518 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001519 struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
Nicholas Bellinger26a99c12016-01-19 16:15:27 -08001520
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001521 spin_lock_bh(&se_tpg->session_lock);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001522 spin_lock(&sess->conn_lock);
1523 if (atomic_read(&sess->session_fall_back_to_erl0) ||
1524 atomic_read(&sess->session_logout) ||
1525 (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
1526 spin_unlock(&sess->conn_lock);
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001527 spin_unlock_bh(&se_tpg->session_lock);
Christoph Hellwig44f33d02016-05-02 15:45:24 +02001528 return;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001529 }
1530 atomic_set(&sess->session_reinstatement, 1);
1531 spin_unlock(&sess->conn_lock);
1532
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001533 iscsit_stop_time2retain_timer(sess);
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001534 spin_unlock_bh(&se_tpg->session_lock);
Nicholas Bellinger26a99c12016-01-19 16:15:27 -08001535
Nicholas Bellinger99367f02012-02-27 01:43:32 -08001536 iscsit_stop_session(sess, 1, 1);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001537 iscsit_close_session(sess);
1538}
1539
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001540static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
1541{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001542 return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn_index;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001543}
1544
1545static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
1546{
1547 struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
1548 se_node_acl);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001549 struct se_portal_group *se_tpg = se_acl->se_tpg;
1550 struct iscsi_portal_group *tpg = container_of(se_tpg,
1551 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001552
Andy Groverb7eec2c2013-10-09 11:05:57 -07001553 acl->node_attrib.nacl = acl;
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001554 iscsit_set_default_node_attribues(acl, tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001555}
1556
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001557static int lio_check_stop_free(struct se_cmd *se_cmd)
1558{
Bart Van Asscheafc16602015-04-27 13:52:36 +02001559 return target_put_sess_cmd(se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001560}
1561
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001562static void lio_release_cmd(struct se_cmd *se_cmd)
1563{
1564 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1565
Nicholas Bellingercdb72662013-03-06 22:09:17 -08001566 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
Nicholas Bellingerd703ce22013-08-17 14:27:56 -07001567 iscsit_release_cmd(cmd);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001568}
1569
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001570const struct target_core_fabric_ops iscsi_ops = {
1571 .module = THIS_MODULE,
1572 .name = "iscsi",
Christoph Hellwig144bc4c2015-04-13 19:51:16 +02001573 .node_acl_size = sizeof(struct iscsi_node_acl),
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001574 .get_fabric_name = iscsi_get_fabric_name,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001575 .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
1576 .tpg_get_tag = lio_tpg_get_tag,
1577 .tpg_get_default_depth = lio_tpg_get_default_depth,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001578 .tpg_check_demo_mode = lio_tpg_check_demo_mode,
1579 .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache,
1580 .tpg_check_demo_mode_write_protect =
1581 lio_tpg_check_demo_mode_write_protect,
1582 .tpg_check_prod_mode_write_protect =
1583 lio_tpg_check_prod_mode_write_protect,
1584 .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001585 .tpg_get_inst_index = lio_tpg_get_inst_index,
1586 .check_stop_free = lio_check_stop_free,
1587 .release_cmd = lio_release_cmd,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001588 .close_session = lio_tpg_close_session,
1589 .sess_get_index = lio_sess_get_index,
1590 .sess_get_initiator_sid = lio_sess_get_initiator_sid,
1591 .write_pending = lio_write_pending,
1592 .write_pending_status = lio_write_pending_status,
1593 .set_default_node_attributes = lio_set_default_node_attributes,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001594 .get_cmd_state = iscsi_get_cmd_state,
1595 .queue_data_in = lio_queue_data_in,
1596 .queue_status = lio_queue_status,
1597 .queue_tm_rsp = lio_queue_tm_rsp,
1598 .aborted_task = lio_aborted_task,
1599 .fabric_make_wwn = lio_target_call_coreaddtiqn,
1600 .fabric_drop_wwn = lio_target_call_coredeltiqn,
Christoph Hellwig839559e2016-03-29 13:03:35 +02001601 .add_wwn_groups = lio_target_add_wwn_groups,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001602 .fabric_make_tpg = lio_target_tiqn_addtpg,
1603 .fabric_drop_tpg = lio_target_tiqn_deltpg,
1604 .fabric_make_np = lio_target_call_addnptotpg,
1605 .fabric_drop_np = lio_target_call_delnpfromtpg,
Christoph Hellwigc7d6a802015-04-13 19:51:14 +02001606 .fabric_init_nodeacl = lio_target_init_nodeacl,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001607
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001608 .tfc_discovery_attrs = lio_target_discovery_auth_attrs,
1609 .tfc_wwn_attrs = lio_target_wwn_attrs,
1610 .tfc_tpg_base_attrs = lio_target_tpg_attrs,
1611 .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs,
1612 .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs,
1613 .tfc_tpg_param_attrs = lio_target_tpg_param_attrs,
1614 .tfc_tpg_np_base_attrs = lio_target_portal_attrs,
1615 .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs,
1616 .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
1617 .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
1618 .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
1619};