blob: 7bfb16d407b99b254ca981d8be8e13a5f28a41e0 [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);
104 if (IS_ERR(tpg_np_new))
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800105 goto out;
106 } else {
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700107 tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
108 if (tpg_np_new) {
109 rc = iscsit_tpg_del_network_portal(tpg, tpg_np_new);
Andy Grover58bd0c62013-05-29 12:05:59 -0700110 if (rc < 0)
111 goto out;
112 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800113 }
114
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800115 iscsit_put_tpg(tpg);
116 return count;
117out:
118 iscsit_put_tpg(tpg);
Andy Grover58bd0c62013-05-29 12:05:59 -0700119 return rc;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800120}
121
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700122static ssize_t lio_target_np_iser_show(struct config_item *item, char *page)
Varun Prakash1c469602016-04-20 00:00:16 +0530123{
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700124 return lio_target_np_driver_show(item, page, ISCSI_INFINIBAND);
125}
Varun Prakash1c469602016-04-20 00:00:16 +0530126
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700127static ssize_t lio_target_np_iser_store(struct config_item *item,
128 const char *page, size_t count)
129{
130 return lio_target_np_driver_store(item, page, count,
131 ISCSI_INFINIBAND, "ib_isert");
132}
133CONFIGFS_ATTR(lio_target_np_, iser);
Varun Prakash1c469602016-04-20 00:00:16 +0530134
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700135static ssize_t lio_target_np_cxgbit_show(struct config_item *item, char *page)
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700136{
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700137 return lio_target_np_driver_show(item, page, ISCSI_CXGBIT);
Varun Prakash1c469602016-04-20 00:00:16 +0530138}
139
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700140static ssize_t lio_target_np_cxgbit_store(struct config_item *item,
141 const char *page, size_t count)
Varun Prakash1c469602016-04-20 00:00:16 +0530142{
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700143 return lio_target_np_driver_store(item, page, count,
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700144 ISCSI_CXGBIT, "cxgbit");
Varun Prakash1c469602016-04-20 00:00:16 +0530145}
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700146CONFIGFS_ATTR(lio_target_np_, cxgbit);
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800147
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000148static struct configfs_attribute *lio_target_portal_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200149 &lio_target_np_attr_iser,
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700150 &lio_target_np_attr_cxgbit,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000151 NULL,
152};
153
154/* Stop items for lio_target_portal_cit */
155
156/* Start items for lio_target_np_cit */
157
158#define MAX_PORTAL_LEN 256
159
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -0400160static struct se_tpg_np *lio_target_call_addnptotpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000161 struct se_portal_group *se_tpg,
162 struct config_group *group,
163 const char *name)
164{
165 struct iscsi_portal_group *tpg;
166 struct iscsi_tpg_np *tpg_np;
167 char *str, *str2, *ip_str, *port_str;
Andy Grover13a3cf02015-08-24 10:26:06 -0700168 struct sockaddr_storage sockaddr;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000169 struct sockaddr_in *sock_in;
170 struct sockaddr_in6 *sock_in6;
171 unsigned long port;
172 int ret;
173 char buf[MAX_PORTAL_LEN + 1];
174
175 if (strlen(name) > MAX_PORTAL_LEN) {
176 pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
177 (int)strlen(name), MAX_PORTAL_LEN);
178 return ERR_PTR(-EOVERFLOW);
179 }
180 memset(buf, 0, MAX_PORTAL_LEN + 1);
Nicholas Bellinger7bbb6542011-07-27 12:37:03 -0700181 snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000182
Andy Grover13a3cf02015-08-24 10:26:06 -0700183 memset(&sockaddr, 0, sizeof(struct sockaddr_storage));
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000184
185 str = strstr(buf, "[");
186 if (str) {
187 const char *end;
188
189 str2 = strstr(str, "]");
190 if (!str2) {
191 pr_err("Unable to locate trailing \"]\""
192 " in IPv6 iSCSI network portal address\n");
193 return ERR_PTR(-EINVAL);
194 }
195 str++; /* Skip over leading "[" */
Andy Grover76c28f12015-08-24 10:26:03 -0700196 *str2 = '\0'; /* Terminate the unbracketed IPv6 address */
197 str2++; /* Skip over the \0 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000198 port_str = strstr(str2, ":");
199 if (!port_str) {
200 pr_err("Unable to locate \":port\""
201 " in IPv6 iSCSI network portal address\n");
202 return ERR_PTR(-EINVAL);
203 }
204 *port_str = '\0'; /* Terminate string for IP */
205 port_str++; /* Skip over ":" */
206
Jingoo Han57103d72013-07-19 16:22:19 +0900207 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000208 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900209 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000210 return ERR_PTR(ret);
211 }
212 sock_in6 = (struct sockaddr_in6 *)&sockaddr;
213 sock_in6->sin6_family = AF_INET6;
214 sock_in6->sin6_port = htons((unsigned short)port);
Andy Groverdc58f762015-08-24 10:26:05 -0700215 ret = in6_pton(str, -1,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000216 (void *)&sock_in6->sin6_addr.in6_u, -1, &end);
217 if (ret <= 0) {
218 pr_err("in6_pton returned: %d\n", ret);
219 return ERR_PTR(-EINVAL);
220 }
221 } else {
222 str = ip_str = &buf[0];
223 port_str = strstr(ip_str, ":");
224 if (!port_str) {
225 pr_err("Unable to locate \":port\""
226 " in IPv4 iSCSI network portal address\n");
227 return ERR_PTR(-EINVAL);
228 }
229 *port_str = '\0'; /* Terminate string for IP */
230 port_str++; /* Skip over ":" */
231
Jingoo Han57103d72013-07-19 16:22:19 +0900232 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000233 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900234 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000235 return ERR_PTR(ret);
236 }
237 sock_in = (struct sockaddr_in *)&sockaddr;
238 sock_in->sin_family = AF_INET;
239 sock_in->sin_port = htons((unsigned short)port);
240 sock_in->sin_addr.s_addr = in_aton(ip_str);
241 }
242 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
243 ret = iscsit_get_tpg(tpg);
244 if (ret < 0)
245 return ERR_PTR(-EINVAL);
246
247 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
248 " PORTAL: %s\n",
249 config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
250 tpg->tpgt, name);
251 /*
252 * Assume ISCSI_TCP by default. Other network portals for other
253 * iSCSI fabrics:
254 *
255 * Traditional iSCSI over SCTP (initial support)
256 * iSER/TCP (TODO, hardware available)
257 * iSER/SCTP (TODO, software emulation with osc-iwarp)
258 * iSER/IB (TODO, hardware available)
259 *
Masanari Iida20879692012-08-27 22:46:00 +0900260 * can be enabled with attributes under
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000261 * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
262 *
263 */
Andy Grover76c28f12015-08-24 10:26:03 -0700264 tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, NULL,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000265 ISCSI_TCP);
266 if (IS_ERR(tpg_np)) {
267 iscsit_put_tpg(tpg);
Thomas Meyere1750ba2011-08-01 23:58:18 +0200268 return ERR_CAST(tpg_np);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000269 }
270 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
271
272 iscsit_put_tpg(tpg);
273 return &tpg_np->se_tpg_np;
274}
275
276static void lio_target_call_delnpfromtpg(
277 struct se_tpg_np *se_tpg_np)
278{
279 struct iscsi_portal_group *tpg;
280 struct iscsi_tpg_np *tpg_np;
281 struct se_portal_group *se_tpg;
282 int ret;
283
284 tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
285 tpg = tpg_np->tpg;
286 ret = iscsit_get_tpg(tpg);
287 if (ret < 0)
288 return;
289
290 se_tpg = &tpg->tpg_se_tpg;
291 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
Andy Grover69d75572015-08-24 10:26:04 -0700292 " PORTAL: %pISpc\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
293 tpg->tpgt, &tpg_np->tpg_np->np_sockaddr);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000294
295 ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
296 if (ret < 0)
297 goto out;
298
299 pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
300out:
301 iscsit_put_tpg(tpg);
302}
303
304/* End items for lio_target_np_cit */
305
306/* Start items for lio_target_nacl_attrib_cit */
307
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200308#define ISCSI_NACL_ATTR(name) \
309static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\
310 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000311{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200312 struct se_node_acl *se_nacl = attrib_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000313 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
314 se_node_acl); \
315 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700316 return sprintf(page, "%u\n", nacl->node_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000317} \
318 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200319static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\
320 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000321{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200322 struct se_node_acl *se_nacl = attrib_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000323 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
324 se_node_acl); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000325 u32 val; \
326 int ret; \
327 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400328 ret = kstrtou32(page, 0, &val); \
329 if (ret) \
330 return ret; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000331 ret = iscsit_na_##name(nacl, val); \
332 if (ret < 0) \
333 return ret; \
334 \
335 return count; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200336} \
337 \
338CONFIGFS_ATTR(iscsi_nacl_attrib_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000339
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200340ISCSI_NACL_ATTR(dataout_timeout);
341ISCSI_NACL_ATTR(dataout_timeout_retries);
342ISCSI_NACL_ATTR(default_erl);
343ISCSI_NACL_ATTR(nopin_timeout);
344ISCSI_NACL_ATTR(nopin_response_timeout);
345ISCSI_NACL_ATTR(random_datain_pdu_offsets);
346ISCSI_NACL_ATTR(random_datain_seq_offsets);
347ISCSI_NACL_ATTR(random_r2t_offsets);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000348
349static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200350 &iscsi_nacl_attrib_attr_dataout_timeout,
351 &iscsi_nacl_attrib_attr_dataout_timeout_retries,
352 &iscsi_nacl_attrib_attr_default_erl,
353 &iscsi_nacl_attrib_attr_nopin_timeout,
354 &iscsi_nacl_attrib_attr_nopin_response_timeout,
355 &iscsi_nacl_attrib_attr_random_datain_pdu_offsets,
356 &iscsi_nacl_attrib_attr_random_datain_seq_offsets,
357 &iscsi_nacl_attrib_attr_random_r2t_offsets,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000358 NULL,
359};
360
361/* End items for lio_target_nacl_attrib_cit */
362
363/* Start items for lio_target_nacl_auth_cit */
364
365#define __DEF_NACL_AUTH_STR(prefix, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200366static ssize_t __iscsi_##prefix##_##name##_show( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000367 struct iscsi_node_acl *nacl, \
368 char *page) \
369{ \
370 struct iscsi_node_auth *auth = &nacl->node_auth; \
371 \
372 if (!capable(CAP_SYS_ADMIN)) \
373 return -EPERM; \
374 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
375} \
376 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200377static ssize_t __iscsi_##prefix##_##name##_store( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000378 struct iscsi_node_acl *nacl, \
379 const char *page, \
380 size_t count) \
381{ \
382 struct iscsi_node_auth *auth = &nacl->node_auth; \
383 \
384 if (!capable(CAP_SYS_ADMIN)) \
385 return -EPERM; \
Eric Seppanen2306bfb2013-11-21 14:49:56 -0800386 if (count >= sizeof(auth->name)) \
387 return -EINVAL; \
Jörn Engel0fbfc462013-07-03 11:35:11 -0400388 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000389 if (!strncmp("NULL", auth->name, 4)) \
390 auth->naf_flags &= ~flags; \
391 else \
392 auth->naf_flags |= flags; \
393 \
394 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
395 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
396 auth->authenticate_target = 1; \
397 else \
398 auth->authenticate_target = 0; \
399 \
400 return count; \
401}
402
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200403#define DEF_NACL_AUTH_STR(name, flags) \
404 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
405static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
406 char *page) \
407{ \
408 struct se_node_acl *nacl = auth_to_nacl(item); \
409 return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
410 struct iscsi_node_acl, se_node_acl), page); \
411} \
412static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \
413 const char *page, size_t count) \
414{ \
415 struct se_node_acl *nacl = auth_to_nacl(item); \
416 return __iscsi_nacl_auth_##name##_store(container_of(nacl, \
417 struct iscsi_node_acl, se_node_acl), page, count); \
418} \
419 \
420CONFIGFS_ATTR(iscsi_nacl_auth_, name)
421
422/*
423 * One-way authentication userid
424 */
425DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
426DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
427DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
428DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
429
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000430#define __DEF_NACL_AUTH_INT(prefix, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200431static ssize_t __iscsi_##prefix##_##name##_show( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000432 struct iscsi_node_acl *nacl, \
433 char *page) \
434{ \
435 struct iscsi_node_auth *auth = &nacl->node_auth; \
436 \
437 if (!capable(CAP_SYS_ADMIN)) \
438 return -EPERM; \
439 \
440 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
441}
442
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000443#define DEF_NACL_AUTH_INT(name) \
444 __DEF_NACL_AUTH_INT(nacl_auth, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200445static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
446 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000447{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200448 struct se_node_acl *nacl = auth_to_nacl(item); \
449 return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
450 struct iscsi_node_acl, se_node_acl), page); \
451} \
452 \
453CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000454
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000455DEF_NACL_AUTH_INT(authenticate_target);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000456
457static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200458 &iscsi_nacl_auth_attr_userid,
459 &iscsi_nacl_auth_attr_password,
460 &iscsi_nacl_auth_attr_authenticate_target,
461 &iscsi_nacl_auth_attr_userid_mutual,
462 &iscsi_nacl_auth_attr_password_mutual,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000463 NULL,
464};
465
466/* End items for lio_target_nacl_auth_cit */
467
468/* Start items for lio_target_nacl_param_cit */
469
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200470#define ISCSI_NACL_PARAM(name) \
471static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \
472 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000473{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200474 struct se_node_acl *se_nacl = param_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000475 struct iscsi_session *sess; \
476 struct se_session *se_sess; \
477 ssize_t rb; \
478 \
479 spin_lock_bh(&se_nacl->nacl_sess_lock); \
480 se_sess = se_nacl->nacl_sess; \
481 if (!se_sess) { \
482 rb = snprintf(page, PAGE_SIZE, \
483 "No Active iSCSI Session\n"); \
484 } else { \
485 sess = se_sess->fabric_sess_ptr; \
486 rb = snprintf(page, PAGE_SIZE, "%u\n", \
487 (u32)sess->sess_ops->name); \
488 } \
489 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
490 \
491 return rb; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200492} \
493 \
494CONFIGFS_ATTR_RO(iscsi_nacl_param_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000495
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200496ISCSI_NACL_PARAM(MaxConnections);
497ISCSI_NACL_PARAM(InitialR2T);
498ISCSI_NACL_PARAM(ImmediateData);
499ISCSI_NACL_PARAM(MaxBurstLength);
500ISCSI_NACL_PARAM(FirstBurstLength);
501ISCSI_NACL_PARAM(DefaultTime2Wait);
502ISCSI_NACL_PARAM(DefaultTime2Retain);
503ISCSI_NACL_PARAM(MaxOutstandingR2T);
504ISCSI_NACL_PARAM(DataPDUInOrder);
505ISCSI_NACL_PARAM(DataSequenceInOrder);
506ISCSI_NACL_PARAM(ErrorRecoveryLevel);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000507
508static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200509 &iscsi_nacl_param_attr_MaxConnections,
510 &iscsi_nacl_param_attr_InitialR2T,
511 &iscsi_nacl_param_attr_ImmediateData,
512 &iscsi_nacl_param_attr_MaxBurstLength,
513 &iscsi_nacl_param_attr_FirstBurstLength,
514 &iscsi_nacl_param_attr_DefaultTime2Wait,
515 &iscsi_nacl_param_attr_DefaultTime2Retain,
516 &iscsi_nacl_param_attr_MaxOutstandingR2T,
517 &iscsi_nacl_param_attr_DataPDUInOrder,
518 &iscsi_nacl_param_attr_DataSequenceInOrder,
519 &iscsi_nacl_param_attr_ErrorRecoveryLevel,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000520 NULL,
521};
522
523/* End items for lio_target_nacl_param_cit */
524
525/* Start items for lio_target_acl_cit */
526
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200527static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000528{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200529 struct se_node_acl *se_nacl = acl_to_nacl(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000530 struct iscsi_session *sess;
531 struct iscsi_conn *conn;
532 struct se_session *se_sess;
533 ssize_t rb = 0;
Roland Dreier109e2382015-07-23 14:53:32 -0700534 u32 max_cmd_sn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000535
536 spin_lock_bh(&se_nacl->nacl_sess_lock);
537 se_sess = se_nacl->nacl_sess;
538 if (!se_sess) {
539 rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
540 " Endpoint: %s\n", se_nacl->initiatorname);
541 } else {
542 sess = se_sess->fabric_sess_ptr;
543
Joern Engelcb354842014-09-02 17:49:50 -0400544 rb += sprintf(page+rb, "InitiatorName: %s\n",
545 sess->sess_ops->InitiatorName);
546 rb += sprintf(page+rb, "InitiatorAlias: %s\n",
547 sess->sess_ops->InitiatorAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000548
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +0200549 rb += sprintf(page+rb,
550 "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
551 sess->sid, sess->isid, sess->tsih);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000552 rb += sprintf(page+rb, "SessionType: %s\n",
553 (sess->sess_ops->SessionType) ?
554 "Discovery" : "Normal");
555 rb += sprintf(page+rb, "Session State: ");
556 switch (sess->session_state) {
557 case TARG_SESS_STATE_FREE:
558 rb += sprintf(page+rb, "TARG_SESS_FREE\n");
559 break;
560 case TARG_SESS_STATE_ACTIVE:
561 rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
562 break;
563 case TARG_SESS_STATE_LOGGED_IN:
564 rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
565 break;
566 case TARG_SESS_STATE_FAILED:
567 rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
568 break;
569 case TARG_SESS_STATE_IN_CONTINUE:
570 rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
571 break;
572 default:
573 rb += sprintf(page+rb, "ERROR: Unknown Session"
574 " State!\n");
575 break;
576 }
577
578 rb += sprintf(page+rb, "---------------------[iSCSI Session"
579 " Values]-----------------------\n");
580 rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
581 " : MaxCmdSN : ITT : TTT\n");
Roland Dreier109e2382015-07-23 14:53:32 -0700582 max_cmd_sn = (u32) atomic_read(&sess->max_cmd_sn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000583 rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
584 " 0x%08x 0x%08x\n",
585 sess->cmdsn_window,
Roland Dreier109e2382015-07-23 14:53:32 -0700586 (max_cmd_sn - sess->exp_cmd_sn) + 1,
587 sess->exp_cmd_sn, max_cmd_sn,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000588 sess->init_task_tag, sess->targ_xfer_tag);
589 rb += sprintf(page+rb, "----------------------[iSCSI"
590 " Connections]-------------------------\n");
591
592 spin_lock(&sess->conn_lock);
593 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
594 rb += sprintf(page+rb, "CID: %hu Connection"
595 " State: ", conn->cid);
596 switch (conn->conn_state) {
597 case TARG_CONN_STATE_FREE:
598 rb += sprintf(page+rb,
599 "TARG_CONN_STATE_FREE\n");
600 break;
601 case TARG_CONN_STATE_XPT_UP:
602 rb += sprintf(page+rb,
603 "TARG_CONN_STATE_XPT_UP\n");
604 break;
605 case TARG_CONN_STATE_IN_LOGIN:
606 rb += sprintf(page+rb,
607 "TARG_CONN_STATE_IN_LOGIN\n");
608 break;
609 case TARG_CONN_STATE_LOGGED_IN:
610 rb += sprintf(page+rb,
611 "TARG_CONN_STATE_LOGGED_IN\n");
612 break;
613 case TARG_CONN_STATE_IN_LOGOUT:
614 rb += sprintf(page+rb,
615 "TARG_CONN_STATE_IN_LOGOUT\n");
616 break;
617 case TARG_CONN_STATE_LOGOUT_REQUESTED:
618 rb += sprintf(page+rb,
619 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
620 break;
621 case TARG_CONN_STATE_CLEANUP_WAIT:
622 rb += sprintf(page+rb,
623 "TARG_CONN_STATE_CLEANUP_WAIT\n");
624 break;
625 default:
626 rb += sprintf(page+rb,
627 "ERROR: Unknown Connection State!\n");
628 break;
629 }
630
Andy Groverdc58f762015-08-24 10:26:05 -0700631 rb += sprintf(page+rb, " Address %pISc %s", &conn->login_sockaddr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000632 (conn->network_transport == ISCSI_TCP) ?
633 "TCP" : "SCTP");
634 rb += sprintf(page+rb, " StatSN: 0x%08x\n",
635 conn->stat_sn);
636 }
637 spin_unlock(&sess->conn_lock);
638 }
639 spin_unlock_bh(&se_nacl->nacl_sess_lock);
640
641 return rb;
642}
643
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200644static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item,
645 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000646{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200647 return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000648}
649
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200650static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item,
651 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000652{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200653 struct se_node_acl *se_nacl = acl_to_nacl(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000654 struct se_portal_group *se_tpg = se_nacl->se_tpg;
655 struct iscsi_portal_group *tpg = container_of(se_tpg,
656 struct iscsi_portal_group, tpg_se_tpg);
657 struct config_item *acl_ci, *tpg_ci, *wwn_ci;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000658 u32 cmdsn_depth = 0;
659 int ret;
660
Jörn Engelad7babd2013-07-03 11:35:11 -0400661 ret = kstrtou32(page, 0, &cmdsn_depth);
662 if (ret)
663 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000664 if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
665 pr_err("Passed cmdsn_depth: %u exceeds"
666 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
667 TA_DEFAULT_CMDSN_DEPTH_MAX);
668 return -EINVAL;
669 }
670 acl_ci = &se_nacl->acl_group.cg_item;
671 if (!acl_ci) {
672 pr_err("Unable to locatel acl_ci\n");
673 return -EINVAL;
674 }
675 tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
676 if (!tpg_ci) {
677 pr_err("Unable to locate tpg_ci\n");
678 return -EINVAL;
679 }
680 wwn_ci = &tpg_ci->ci_group->cg_item;
681 if (!wwn_ci) {
682 pr_err("Unable to locate config_item wwn_ci\n");
683 return -EINVAL;
684 }
685
686 if (iscsit_get_tpg(tpg) < 0)
687 return -EINVAL;
Nicholas Bellingerd36ad772016-01-07 22:15:06 -0800688
689 ret = core_tpg_set_initiator_node_queue_depth(se_nacl, cmdsn_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000690
691 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
692 "InitiatorName: %s\n", config_item_name(wwn_ci),
693 config_item_name(tpg_ci), cmdsn_depth,
694 config_item_name(acl_ci));
695
696 iscsit_put_tpg(tpg);
697 return (!ret) ? count : (ssize_t)ret;
698}
699
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200700static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page)
Andy Grover79e62fc2012-12-11 16:30:53 -0800701{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200702 return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag);
Andy Grover79e62fc2012-12-11 16:30:53 -0800703}
704
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200705static ssize_t lio_target_nacl_tag_store(struct config_item *item,
706 const char *page, size_t count)
Andy Grover79e62fc2012-12-11 16:30:53 -0800707{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200708 struct se_node_acl *se_nacl = acl_to_nacl(item);
Andy Grover79e62fc2012-12-11 16:30:53 -0800709 int ret;
710
711 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
712
713 if (ret < 0)
714 return ret;
715 return count;
716}
717
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200718CONFIGFS_ATTR_RO(lio_target_nacl_, info);
719CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth);
720CONFIGFS_ATTR(lio_target_nacl_, tag);
Andy Grover79e62fc2012-12-11 16:30:53 -0800721
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000722static struct configfs_attribute *lio_target_initiator_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200723 &lio_target_nacl_attr_info,
724 &lio_target_nacl_attr_cmdsn_depth,
725 &lio_target_nacl_attr_tag,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000726 NULL,
727};
728
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200729static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
730 const char *name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000731{
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200732 struct iscsi_node_acl *acl =
733 container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000734
Andy Groverb7eec2c2013-10-09 11:05:57 -0700735 config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000736 "iscsi_sess_stats", &iscsi_stat_sess_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +0100737 configfs_add_default_group(&acl->node_stat_grps.iscsi_sess_stats_group,
738 &se_nacl->acl_fabric_stat_group);
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200739 return 0;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000740}
741
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000742/* End items for lio_target_acl_cit */
743
744/* Start items for lio_target_tpg_attrib_cit */
745
746#define DEF_TPG_ATTRIB(name) \
747 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200748static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \
749 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000750{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200751 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000752 struct iscsi_portal_group *tpg = container_of(se_tpg, \
753 struct iscsi_portal_group, tpg_se_tpg); \
754 ssize_t rb; \
755 \
756 if (iscsit_get_tpg(tpg) < 0) \
757 return -EINVAL; \
758 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700759 rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000760 iscsit_put_tpg(tpg); \
761 return rb; \
762} \
763 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200764static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\
765 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000766{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200767 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000768 struct iscsi_portal_group *tpg = container_of(se_tpg, \
769 struct iscsi_portal_group, tpg_se_tpg); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000770 u32 val; \
771 int ret; \
772 \
773 if (iscsit_get_tpg(tpg) < 0) \
774 return -EINVAL; \
775 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400776 ret = kstrtou32(page, 0, &val); \
777 if (ret) \
778 goto out; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000779 ret = iscsit_ta_##name(tpg, val); \
780 if (ret < 0) \
781 goto out; \
782 \
783 iscsit_put_tpg(tpg); \
784 return count; \
785out: \
786 iscsit_put_tpg(tpg); \
787 return ret; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200788} \
789CONFIGFS_ATTR(iscsi_tpg_attrib_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000790
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000791DEF_TPG_ATTRIB(authentication);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000792DEF_TPG_ATTRIB(login_timeout);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000793DEF_TPG_ATTRIB(netif_timeout);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000794DEF_TPG_ATTRIB(generate_node_acls);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000795DEF_TPG_ATTRIB(default_cmdsn_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000796DEF_TPG_ATTRIB(cache_dynamic_acls);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000797DEF_TPG_ATTRIB(demo_mode_write_protect);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000798DEF_TPG_ATTRIB(prod_mode_write_protect);
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +0200799DEF_TPG_ATTRIB(demo_mode_discovery);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -0800800DEF_TPG_ATTRIB(default_erl);
Sagi Grimberg80851762014-02-19 17:50:20 +0200801DEF_TPG_ATTRIB(t10_pi);
Nicholas Bellinger901c04a2015-03-29 19:36:16 -0700802DEF_TPG_ATTRIB(fabric_prot_type);
David Disseldorpa6415cd2015-08-01 00:10:12 -0700803DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000804
805static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200806 &iscsi_tpg_attrib_attr_authentication,
807 &iscsi_tpg_attrib_attr_login_timeout,
808 &iscsi_tpg_attrib_attr_netif_timeout,
809 &iscsi_tpg_attrib_attr_generate_node_acls,
810 &iscsi_tpg_attrib_attr_default_cmdsn_depth,
811 &iscsi_tpg_attrib_attr_cache_dynamic_acls,
812 &iscsi_tpg_attrib_attr_demo_mode_write_protect,
813 &iscsi_tpg_attrib_attr_prod_mode_write_protect,
814 &iscsi_tpg_attrib_attr_demo_mode_discovery,
815 &iscsi_tpg_attrib_attr_default_erl,
816 &iscsi_tpg_attrib_attr_t10_pi,
817 &iscsi_tpg_attrib_attr_fabric_prot_type,
818 &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000819 NULL,
820};
821
822/* End items for lio_target_tpg_attrib_cit */
823
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700824/* Start items for lio_target_tpg_auth_cit */
825
826#define __DEF_TPG_AUTH_STR(prefix, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200827static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
828 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700829{ \
830 struct iscsi_portal_group *tpg = container_of(se_tpg, \
831 struct iscsi_portal_group, tpg_se_tpg); \
832 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
833 \
834 if (!capable(CAP_SYS_ADMIN)) \
835 return -EPERM; \
836 \
837 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
838} \
839 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200840static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\
841 const char *page, size_t count) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700842{ \
843 struct iscsi_portal_group *tpg = container_of(se_tpg, \
844 struct iscsi_portal_group, tpg_se_tpg); \
845 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
846 \
847 if (!capable(CAP_SYS_ADMIN)) \
848 return -EPERM; \
849 \
Nicholas Bellinger37b32c62013-07-06 16:48:55 -0700850 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700851 if (!(strncmp("NULL", auth->name, 4))) \
852 auth->naf_flags &= ~flags; \
853 else \
854 auth->naf_flags |= flags; \
855 \
856 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
857 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
858 auth->authenticate_target = 1; \
859 else \
860 auth->authenticate_target = 0; \
861 \
862 return count; \
863}
864
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200865#define DEF_TPG_AUTH_STR(name, flags) \
866 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
867static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
868 char *page) \
869{ \
870 return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
871} \
872 \
873static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \
874 const char *page, size_t count) \
875{ \
876 return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \
877} \
878 \
879CONFIGFS_ATTR(iscsi_tpg_auth_, name);
880
881
882DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
883DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
884DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
885DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
886
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700887#define __DEF_TPG_AUTH_INT(prefix, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200888static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
889 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700890{ \
891 struct iscsi_portal_group *tpg = container_of(se_tpg, \
892 struct iscsi_portal_group, tpg_se_tpg); \
893 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
894 \
895 if (!capable(CAP_SYS_ADMIN)) \
896 return -EPERM; \
897 \
898 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
899}
900
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700901#define DEF_TPG_AUTH_INT(name) \
902 __DEF_TPG_AUTH_INT(tpg_auth, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200903static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
904 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700905{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200906 return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
907} \
908CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name);
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700909
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700910DEF_TPG_AUTH_INT(authenticate_target);
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700911
912static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200913 &iscsi_tpg_auth_attr_userid,
914 &iscsi_tpg_auth_attr_password,
915 &iscsi_tpg_auth_attr_authenticate_target,
916 &iscsi_tpg_auth_attr_userid_mutual,
917 &iscsi_tpg_auth_attr_password_mutual,
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700918 NULL,
919};
920
921/* End items for lio_target_tpg_auth_cit */
922
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000923/* Start items for lio_target_tpg_param_cit */
924
925#define DEF_TPG_PARAM(name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200926static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \
927 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000928{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200929 struct se_portal_group *se_tpg = param_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000930 struct iscsi_portal_group *tpg = container_of(se_tpg, \
931 struct iscsi_portal_group, tpg_se_tpg); \
932 struct iscsi_param *param; \
933 ssize_t rb; \
934 \
935 if (iscsit_get_tpg(tpg) < 0) \
936 return -EINVAL; \
937 \
938 param = iscsi_find_param_from_key(__stringify(name), \
939 tpg->param_list); \
940 if (!param) { \
941 iscsit_put_tpg(tpg); \
942 return -EINVAL; \
943 } \
944 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
945 \
946 iscsit_put_tpg(tpg); \
947 return rb; \
948} \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200949static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \
950 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000951{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200952 struct se_portal_group *se_tpg = param_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000953 struct iscsi_portal_group *tpg = container_of(se_tpg, \
954 struct iscsi_portal_group, tpg_se_tpg); \
955 char *buf; \
Jörn Engelad7babd2013-07-03 11:35:11 -0400956 int ret, len; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000957 \
958 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
959 if (!buf) \
960 return -ENOMEM; \
Jörn Engelad7babd2013-07-03 11:35:11 -0400961 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
962 if (isspace(buf[len-1])) \
963 buf[len-1] = '\0'; /* Kill newline */ \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000964 \
965 if (iscsit_get_tpg(tpg) < 0) { \
966 kfree(buf); \
967 return -EINVAL; \
968 } \
969 \
970 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
971 if (ret < 0) \
972 goto out; \
973 \
974 kfree(buf); \
975 iscsit_put_tpg(tpg); \
976 return count; \
977out: \
978 kfree(buf); \
979 iscsit_put_tpg(tpg); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200980 return -EINVAL; \
981} \
982CONFIGFS_ATTR(iscsi_tpg_param_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000983
984DEF_TPG_PARAM(AuthMethod);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000985DEF_TPG_PARAM(HeaderDigest);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000986DEF_TPG_PARAM(DataDigest);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000987DEF_TPG_PARAM(MaxConnections);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000988DEF_TPG_PARAM(TargetAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000989DEF_TPG_PARAM(InitialR2T);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000990DEF_TPG_PARAM(ImmediateData);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000991DEF_TPG_PARAM(MaxRecvDataSegmentLength);
Nicholas Bellingere004cb22012-09-29 21:47:16 -0700992DEF_TPG_PARAM(MaxXmitDataSegmentLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000993DEF_TPG_PARAM(MaxBurstLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000994DEF_TPG_PARAM(FirstBurstLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000995DEF_TPG_PARAM(DefaultTime2Wait);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000996DEF_TPG_PARAM(DefaultTime2Retain);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000997DEF_TPG_PARAM(MaxOutstandingR2T);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000998DEF_TPG_PARAM(DataPDUInOrder);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000999DEF_TPG_PARAM(DataSequenceInOrder);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001000DEF_TPG_PARAM(ErrorRecoveryLevel);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001001DEF_TPG_PARAM(IFMarker);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001002DEF_TPG_PARAM(OFMarker);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001003DEF_TPG_PARAM(IFMarkInt);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001004DEF_TPG_PARAM(OFMarkInt);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001005
1006static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001007 &iscsi_tpg_param_attr_AuthMethod,
1008 &iscsi_tpg_param_attr_HeaderDigest,
1009 &iscsi_tpg_param_attr_DataDigest,
1010 &iscsi_tpg_param_attr_MaxConnections,
1011 &iscsi_tpg_param_attr_TargetAlias,
1012 &iscsi_tpg_param_attr_InitialR2T,
1013 &iscsi_tpg_param_attr_ImmediateData,
1014 &iscsi_tpg_param_attr_MaxRecvDataSegmentLength,
1015 &iscsi_tpg_param_attr_MaxXmitDataSegmentLength,
1016 &iscsi_tpg_param_attr_MaxBurstLength,
1017 &iscsi_tpg_param_attr_FirstBurstLength,
1018 &iscsi_tpg_param_attr_DefaultTime2Wait,
1019 &iscsi_tpg_param_attr_DefaultTime2Retain,
1020 &iscsi_tpg_param_attr_MaxOutstandingR2T,
1021 &iscsi_tpg_param_attr_DataPDUInOrder,
1022 &iscsi_tpg_param_attr_DataSequenceInOrder,
1023 &iscsi_tpg_param_attr_ErrorRecoveryLevel,
1024 &iscsi_tpg_param_attr_IFMarker,
1025 &iscsi_tpg_param_attr_OFMarker,
1026 &iscsi_tpg_param_attr_IFMarkInt,
1027 &iscsi_tpg_param_attr_OFMarkInt,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001028 NULL,
1029};
1030
1031/* End items for lio_target_tpg_param_cit */
1032
1033/* Start items for lio_target_tpg_cit */
1034
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001035static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001036{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001037 struct se_portal_group *se_tpg = to_tpg(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001038 struct iscsi_portal_group *tpg = container_of(se_tpg,
1039 struct iscsi_portal_group, tpg_se_tpg);
1040 ssize_t len;
1041
1042 spin_lock(&tpg->tpg_state_lock);
1043 len = sprintf(page, "%d\n",
1044 (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
1045 spin_unlock(&tpg->tpg_state_lock);
1046
1047 return len;
1048}
1049
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001050static ssize_t lio_target_tpg_enable_store(struct config_item *item,
1051 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001052{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001053 struct se_portal_group *se_tpg = to_tpg(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001054 struct iscsi_portal_group *tpg = container_of(se_tpg,
1055 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001056 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001057 int ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001058
Jörn Engelad7babd2013-07-03 11:35:11 -04001059 ret = kstrtou32(page, 0, &op);
1060 if (ret)
1061 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001062 if ((op != 1) && (op != 0)) {
1063 pr_err("Illegal value for tpg_enable: %u\n", op);
1064 return -EINVAL;
1065 }
1066
1067 ret = iscsit_get_tpg(tpg);
1068 if (ret < 0)
1069 return -EINVAL;
1070
1071 if (op) {
1072 ret = iscsit_tpg_enable_portal_group(tpg);
1073 if (ret < 0)
1074 goto out;
1075 } else {
1076 /*
1077 * iscsit_tpg_disable_portal_group() assumes force=1
1078 */
1079 ret = iscsit_tpg_disable_portal_group(tpg, 1);
1080 if (ret < 0)
1081 goto out;
1082 }
1083
1084 iscsit_put_tpg(tpg);
1085 return count;
1086out:
1087 iscsit_put_tpg(tpg);
1088 return -EINVAL;
1089}
1090
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001091
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001092static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item,
1093 char *page)
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001094{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001095 return target_show_dynamic_sessions(to_tpg(item), page);
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001096}
1097
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001098CONFIGFS_ATTR(lio_target_tpg_, enable);
1099CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions);
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001100
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001101static struct configfs_attribute *lio_target_tpg_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001102 &lio_target_tpg_attr_enable,
1103 &lio_target_tpg_attr_dynamic_sessions,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001104 NULL,
1105};
1106
1107/* End items for lio_target_tpg_cit */
1108
1109/* Start items for lio_target_tiqn_cit */
1110
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001111static struct se_portal_group *lio_target_tiqn_addtpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001112 struct se_wwn *wwn,
1113 struct config_group *group,
1114 const char *name)
1115{
1116 struct iscsi_portal_group *tpg;
1117 struct iscsi_tiqn *tiqn;
Jörn Engelad7babd2013-07-03 11:35:11 -04001118 char *tpgt_str;
1119 int ret;
1120 u16 tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001121
1122 tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1123 /*
1124 * Only tpgt_# directory groups can be created below
1125 * target/iscsi/iqn.superturodiskarry/
Jörn Engelad7babd2013-07-03 11:35:11 -04001126 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001127 tpgt_str = strstr(name, "tpgt_");
1128 if (!tpgt_str) {
1129 pr_err("Unable to locate \"tpgt_#\" directory"
1130 " group\n");
1131 return NULL;
1132 }
1133 tpgt_str += 5; /* Skip ahead of "tpgt_" */
Jörn Engelad7babd2013-07-03 11:35:11 -04001134 ret = kstrtou16(tpgt_str, 0, &tpgt);
1135 if (ret)
1136 return NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001137
1138 tpg = iscsit_alloc_portal_group(tiqn, tpgt);
1139 if (!tpg)
1140 return NULL;
1141
Nicholas Bellingerbc0c94b2015-05-20 21:48:03 -07001142 ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001143 if (ret < 0)
1144 return NULL;
1145
1146 ret = iscsit_tpg_add_portal_group(tiqn, tpg);
1147 if (ret != 0)
1148 goto out;
1149
1150 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1151 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1152 name);
1153 return &tpg->tpg_se_tpg;
1154out:
1155 core_tpg_deregister(&tpg->tpg_se_tpg);
1156 kfree(tpg);
1157 return NULL;
1158}
1159
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001160static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001161{
1162 struct iscsi_portal_group *tpg;
1163 struct iscsi_tiqn *tiqn;
1164
1165 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1166 tiqn = tpg->tpg_tiqn;
1167 /*
1168 * iscsit_tpg_del_portal_group() assumes force=1
1169 */
1170 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1171 iscsit_tpg_del_portal_group(tiqn, tpg, 1);
1172}
1173
1174/* End items for lio_target_tiqn_cit */
1175
1176/* Start LIO-Target TIQN struct contig_item lio_target_cit */
1177
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001178static ssize_t lio_target_wwn_lio_version_show(struct config_item *item,
1179 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001180{
Nicholas Bellinger4c762512013-09-05 15:29:12 -07001181 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001182}
1183
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001184CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001185
1186static struct configfs_attribute *lio_target_wwn_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001187 &lio_target_wwn_attr_lio_version,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001188 NULL,
1189};
1190
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001191static struct se_wwn *lio_target_call_coreaddtiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001192 struct target_fabric_configfs *tf,
1193 struct config_group *group,
1194 const char *name)
1195{
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001196 struct iscsi_tiqn *tiqn;
1197
1198 tiqn = iscsit_add_tiqn((unsigned char *)name);
1199 if (IS_ERR(tiqn))
Thomas Meyere1750ba2011-08-01 23:58:18 +02001200 return ERR_CAST(tiqn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001201
Christoph Hellwig839559e2016-03-29 13:03:35 +02001202 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1203 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1204 " %s\n", name);
1205 return &tiqn->tiqn_wwn;
1206}
1207
1208static void lio_target_add_wwn_groups(struct se_wwn *wwn)
1209{
1210 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1211
Andy Groverb7eec2c2013-10-09 11:05:57 -07001212 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001213 "iscsi_instance", &iscsi_stat_instance_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001214 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
1215 &tiqn->tiqn_wwn.fabric_stat_group);
1216
Andy Groverb7eec2c2013-10-09 11:05:57 -07001217 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001218 "iscsi_sess_err", &iscsi_stat_sess_err_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001219 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
1220 &tiqn->tiqn_wwn.fabric_stat_group);
1221
Andy Groverb7eec2c2013-10-09 11:05:57 -07001222 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001223 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001224 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
1225 &tiqn->tiqn_wwn.fabric_stat_group);
1226
Andy Groverb7eec2c2013-10-09 11:05:57 -07001227 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001228 "iscsi_login_stats", &iscsi_stat_login_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001229 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
1230 &tiqn->tiqn_wwn.fabric_stat_group);
1231
Andy Groverb7eec2c2013-10-09 11:05:57 -07001232 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001233 "iscsi_logout_stats", &iscsi_stat_logout_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001234 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
1235 &tiqn->tiqn_wwn.fabric_stat_group);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001236}
1237
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001238static void lio_target_call_coredeltiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001239 struct se_wwn *wwn)
1240{
1241 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001242
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001243 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1244 tiqn->tiqn);
1245 iscsit_del_tiqn(tiqn);
1246}
1247
1248/* End LIO-Target TIQN struct contig_lio_target_cit */
1249
1250/* Start lio_target_discovery_auth_cit */
1251
1252#define DEF_DISC_AUTH_STR(name, flags) \
1253 __DEF_NACL_AUTH_STR(disc, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001254static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001255{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001256 return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001257 page); \
1258} \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001259static ssize_t iscsi_disc_##name##_store(struct config_item *item, \
1260 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001261{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001262 return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001263 page, count); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001264 \
1265} \
1266CONFIGFS_ATTR(iscsi_disc_, name)
1267
1268DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
1269DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
1270DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1271DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001272
1273#define DEF_DISC_AUTH_INT(name) \
1274 __DEF_NACL_AUTH_INT(disc, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001275static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001276{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001277 return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001278 page); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001279} \
1280CONFIGFS_ATTR_RO(iscsi_disc_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001281
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001282DEF_DISC_AUTH_INT(authenticate_target);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001283
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001284
1285static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item,
1286 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001287{
1288 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
1289
1290 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
1291}
1292
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001293static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1294 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001295{
1296 struct iscsi_param *param;
1297 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001298 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001299 int err;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001300
Jörn Engelad7babd2013-07-03 11:35:11 -04001301 err = kstrtou32(page, 0, &op);
1302 if (err)
1303 return -EINVAL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001304 if ((op != 1) && (op != 0)) {
1305 pr_err("Illegal value for enforce_discovery_auth:"
1306 " %u\n", op);
1307 return -EINVAL;
1308 }
1309
1310 if (!discovery_tpg) {
1311 pr_err("iscsit_global->discovery_tpg is NULL\n");
1312 return -EINVAL;
1313 }
1314
1315 param = iscsi_find_param_from_key(AUTHMETHOD,
1316 discovery_tpg->param_list);
1317 if (!param)
1318 return -EINVAL;
1319
1320 if (op) {
1321 /*
1322 * Reset the AuthMethod key to CHAP.
1323 */
1324 if (iscsi_update_param_value(param, CHAP) < 0)
1325 return -EINVAL;
1326
1327 discovery_tpg->tpg_attrib.authentication = 1;
1328 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
1329 pr_debug("LIO-CORE[0] Successfully enabled"
1330 " authentication enforcement for iSCSI"
1331 " Discovery TPG\n");
1332 } else {
1333 /*
1334 * Reset the AuthMethod key to CHAP,None
1335 */
1336 if (iscsi_update_param_value(param, "CHAP,None") < 0)
1337 return -EINVAL;
1338
1339 discovery_tpg->tpg_attrib.authentication = 0;
1340 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
1341 pr_debug("LIO-CORE[0] Successfully disabled"
1342 " authentication enforcement for iSCSI"
1343 " Discovery TPG\n");
1344 }
1345
1346 return count;
1347}
1348
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001349CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001350
1351static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001352 &iscsi_disc_attr_userid,
1353 &iscsi_disc_attr_password,
1354 &iscsi_disc_attr_authenticate_target,
1355 &iscsi_disc_attr_userid_mutual,
1356 &iscsi_disc_attr_password_mutual,
1357 &iscsi_disc_attr_enforce_discovery_auth,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001358 NULL,
1359};
1360
1361/* End lio_target_discovery_auth_cit */
1362
1363/* Start functions for target_core_fabric_ops */
1364
1365static char *iscsi_get_fabric_name(void)
1366{
1367 return "iSCSI";
1368}
1369
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001370static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1371{
1372 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1373
1374 return cmd->i_state;
1375}
1376
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001377static u32 lio_sess_get_index(struct se_session *se_sess)
1378{
1379 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1380
1381 return sess->session_index;
1382}
1383
1384static u32 lio_sess_get_initiator_sid(
1385 struct se_session *se_sess,
1386 unsigned char *buf,
1387 u32 size)
1388{
1389 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1390 /*
1391 * iSCSI Initiator Session Identifier from RFC-3720.
1392 */
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +02001393 return snprintf(buf, size, "%6phN", sess->isid);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001394}
1395
1396static int lio_queue_data_in(struct se_cmd *se_cmd)
1397{
1398 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1399
1400 cmd->i_state = ISTATE_SEND_DATAIN;
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001401 cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd);
1402
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001403 return 0;
1404}
1405
1406static int lio_write_pending(struct se_cmd *se_cmd)
1407{
1408 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001409 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001410
1411 if (!cmd->immediate_data && !cmd->unsolicited_data)
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001412 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001413
1414 return 0;
1415}
1416
1417static int lio_write_pending_status(struct se_cmd *se_cmd)
1418{
1419 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1420 int ret;
1421
1422 spin_lock_bh(&cmd->istate_lock);
1423 ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
1424 spin_unlock_bh(&cmd->istate_lock);
1425
1426 return ret;
1427}
1428
1429static int lio_queue_status(struct se_cmd *se_cmd)
1430{
1431 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1432
1433 cmd->i_state = ISTATE_SEND_STATUS;
Nicholas Bellinger5e8e6b42013-11-12 17:54:56 -08001434
1435 if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
1436 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
1437 return 0;
1438 }
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001439 cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd);
1440
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001441 return 0;
1442}
1443
Joern Engelb79fafa2013-07-03 11:22:17 -04001444static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001445{
1446 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1447
1448 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
1449 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001450}
1451
Nicholas Bellinger131e6ab2014-03-22 14:55:56 -07001452static void lio_aborted_task(struct se_cmd *se_cmd)
1453{
1454 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1455
1456 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
1457}
1458
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001459static inline struct iscsi_portal_group *iscsi_tpg(struct se_portal_group *se_tpg)
1460{
1461 return container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1462}
1463
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001464static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
1465{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001466 return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001467}
1468
1469static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
1470{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001471 return iscsi_tpg(se_tpg)->tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001472}
1473
1474static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
1475{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001476 return iscsi_tpg(se_tpg)->tpg_attrib.default_cmdsn_depth;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001477}
1478
1479static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
1480{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001481 return iscsi_tpg(se_tpg)->tpg_attrib.generate_node_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001482}
1483
1484static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
1485{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001486 return iscsi_tpg(se_tpg)->tpg_attrib.cache_dynamic_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001487}
1488
1489static int lio_tpg_check_demo_mode_write_protect(
1490 struct se_portal_group *se_tpg)
1491{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001492 return iscsi_tpg(se_tpg)->tpg_attrib.demo_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001493}
1494
1495static int lio_tpg_check_prod_mode_write_protect(
1496 struct se_portal_group *se_tpg)
1497{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001498 return iscsi_tpg(se_tpg)->tpg_attrib.prod_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001499}
1500
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001501static int lio_tpg_check_prot_fabric_only(
1502 struct se_portal_group *se_tpg)
1503{
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001504 /*
1505 * Only report fabric_prot_type if t10_pi has also been enabled
1506 * for incoming ib_isert sessions.
1507 */
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001508 if (!iscsi_tpg(se_tpg)->tpg_attrib.t10_pi)
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001509 return 0;
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001510 return iscsi_tpg(se_tpg)->tpg_attrib.fabric_prot_type;
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001511}
1512
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001513/*
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001514 * This function calls iscsit_inc_session_usage_count() on the
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001515 * struct iscsi_session in question.
1516 */
Christoph Hellwig44f33d02016-05-02 15:45:24 +02001517static void lio_tpg_close_session(struct se_session *se_sess)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001518{
1519 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001520 struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
Nicholas Bellinger26a99c12016-01-19 16:15:27 -08001521
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001522 spin_lock_bh(&se_tpg->session_lock);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001523 spin_lock(&sess->conn_lock);
1524 if (atomic_read(&sess->session_fall_back_to_erl0) ||
1525 atomic_read(&sess->session_logout) ||
1526 (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
1527 spin_unlock(&sess->conn_lock);
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001528 spin_unlock_bh(&se_tpg->session_lock);
Christoph Hellwig44f33d02016-05-02 15:45:24 +02001529 return;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001530 }
1531 atomic_set(&sess->session_reinstatement, 1);
1532 spin_unlock(&sess->conn_lock);
1533
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001534 iscsit_stop_time2retain_timer(sess);
Nicholas Bellingerd36ad772016-01-07 22:15:06 -08001535 spin_unlock_bh(&se_tpg->session_lock);
Nicholas Bellinger26a99c12016-01-19 16:15:27 -08001536
Nicholas Bellinger99367f02012-02-27 01:43:32 -08001537 iscsit_stop_session(sess, 1, 1);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001538 iscsit_close_session(sess);
1539}
1540
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001541static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
1542{
Christoph Hellwig2b6eb602015-05-01 17:47:53 +02001543 return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn_index;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001544}
1545
1546static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
1547{
1548 struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
1549 se_node_acl);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001550 struct se_portal_group *se_tpg = se_acl->se_tpg;
1551 struct iscsi_portal_group *tpg = container_of(se_tpg,
1552 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001553
Andy Groverb7eec2c2013-10-09 11:05:57 -07001554 acl->node_attrib.nacl = acl;
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001555 iscsit_set_default_node_attribues(acl, tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001556}
1557
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001558static int lio_check_stop_free(struct se_cmd *se_cmd)
1559{
Bart Van Asscheafc16602015-04-27 13:52:36 +02001560 return target_put_sess_cmd(se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001561}
1562
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001563static void lio_release_cmd(struct se_cmd *se_cmd)
1564{
1565 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1566
Nicholas Bellingercdb72662013-03-06 22:09:17 -08001567 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
Nicholas Bellingerd703ce22013-08-17 14:27:56 -07001568 iscsit_release_cmd(cmd);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001569}
1570
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001571const struct target_core_fabric_ops iscsi_ops = {
1572 .module = THIS_MODULE,
1573 .name = "iscsi",
Christoph Hellwig144bc4c2015-04-13 19:51:16 +02001574 .node_acl_size = sizeof(struct iscsi_node_acl),
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001575 .get_fabric_name = iscsi_get_fabric_name,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001576 .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
1577 .tpg_get_tag = lio_tpg_get_tag,
1578 .tpg_get_default_depth = lio_tpg_get_default_depth,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001579 .tpg_check_demo_mode = lio_tpg_check_demo_mode,
1580 .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache,
1581 .tpg_check_demo_mode_write_protect =
1582 lio_tpg_check_demo_mode_write_protect,
1583 .tpg_check_prod_mode_write_protect =
1584 lio_tpg_check_prod_mode_write_protect,
1585 .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001586 .tpg_get_inst_index = lio_tpg_get_inst_index,
1587 .check_stop_free = lio_check_stop_free,
1588 .release_cmd = lio_release_cmd,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001589 .close_session = lio_tpg_close_session,
1590 .sess_get_index = lio_sess_get_index,
1591 .sess_get_initiator_sid = lio_sess_get_initiator_sid,
1592 .write_pending = lio_write_pending,
1593 .write_pending_status = lio_write_pending_status,
1594 .set_default_node_attributes = lio_set_default_node_attributes,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001595 .get_cmd_state = iscsi_get_cmd_state,
1596 .queue_data_in = lio_queue_data_in,
1597 .queue_status = lio_queue_status,
1598 .queue_tm_rsp = lio_queue_tm_rsp,
1599 .aborted_task = lio_aborted_task,
1600 .fabric_make_wwn = lio_target_call_coreaddtiqn,
1601 .fabric_drop_wwn = lio_target_call_coredeltiqn,
Christoph Hellwig839559e2016-03-29 13:03:35 +02001602 .add_wwn_groups = lio_target_add_wwn_groups,
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001603 .fabric_make_tpg = lio_target_tiqn_addtpg,
1604 .fabric_drop_tpg = lio_target_tiqn_deltpg,
1605 .fabric_make_np = lio_target_call_addnptotpg,
1606 .fabric_drop_np = lio_target_call_delnpfromtpg,
Christoph Hellwigc7d6a802015-04-13 19:51:14 +02001607 .fabric_init_nodeacl = lio_target_init_nodeacl,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001608
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001609 .tfc_discovery_attrs = lio_target_discovery_auth_attrs,
1610 .tfc_wwn_attrs = lio_target_wwn_attrs,
1611 .tfc_tpg_base_attrs = lio_target_tpg_attrs,
1612 .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs,
1613 .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs,
1614 .tfc_tpg_param_attrs = lio_target_tpg_param_attrs,
1615 .tfc_tpg_np_base_attrs = lio_target_portal_attrs,
1616 .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs,
1617 .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
1618 .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
1619 .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
1620};