blob: 923c032f0b95f1efe2d1e12e90cb9086f3fd9346 [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>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000024#include <target/target_core_base.h>
Christoph Hellwigc4795fb2011-11-16 09:46:48 -050025#include <target/target_core_fabric.h>
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -070026#include <target/iscsi/iscsi_transport.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000027
Sagi Grimberg67f091f2015-01-07 14:57:31 +020028#include <target/iscsi/iscsi_target_core.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000029#include "iscsi_target_parameters.h"
30#include "iscsi_target_device.h"
31#include "iscsi_target_erl0.h"
32#include "iscsi_target_nodeattrib.h"
33#include "iscsi_target_tpg.h"
34#include "iscsi_target_util.h"
35#include "iscsi_target.h"
Sagi Grimberg67f091f2015-01-07 14:57:31 +020036#include <target/iscsi/iscsi_target_stat.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000037
Nicholas Bellingere48354c2011-07-23 06:43:04 +000038
Nicholas Bellingere48354c2011-07-23 06:43:04 +000039/* Start items for lio_target_portal_cit */
40
Christoph Hellwig2eafd722015-10-03 15:32:55 +020041static inline struct iscsi_tpg_np *to_iscsi_tpg_np(struct config_item *item)
Nicholas Bellingere48354c2011-07-23 06:43:04 +000042{
Christoph Hellwig2eafd722015-10-03 15:32:55 +020043 return container_of(to_tpg_np(item), struct iscsi_tpg_np, se_tpg_np);
44}
45
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070046static ssize_t lio_target_np_driver_show(struct config_item *item, char *page,
47 enum iscsit_transport_type type)
Christoph Hellwig2eafd722015-10-03 15:32:55 +020048{
49 struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070050 struct iscsi_tpg_np *tpg_np_new;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000051 ssize_t rb;
52
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070053 tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
54 if (tpg_np_new)
Nicholas Bellingere48354c2011-07-23 06:43:04 +000055 rb = sprintf(page, "1\n");
56 else
57 rb = sprintf(page, "0\n");
58
59 return rb;
60}
61
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070062static ssize_t lio_target_np_driver_store(struct config_item *item,
63 const char *page, size_t count, enum iscsit_transport_type type,
64 const char *mod_name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +000065{
Christoph Hellwig2eafd722015-10-03 15:32:55 +020066 struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +000067 struct iscsi_np *np;
68 struct iscsi_portal_group *tpg;
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070069 struct iscsi_tpg_np *tpg_np_new = NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000070 u32 op;
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070071 int rc;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000072
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070073 rc = kstrtou32(page, 0, &op);
74 if (rc)
75 return rc;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000076 if ((op != 1) && (op != 0)) {
77 pr_err("Illegal value for tpg_enable: %u\n", op);
78 return -EINVAL;
79 }
80 np = tpg_np->tpg_np;
81 if (!np) {
82 pr_err("Unable to locate struct iscsi_np from"
83 " struct iscsi_tpg_np\n");
84 return -EINVAL;
85 }
86
87 tpg = tpg_np->tpg;
88 if (iscsit_get_tpg(tpg) < 0)
89 return -EINVAL;
90
91 if (op) {
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -070092 if (strlen(mod_name)) {
93 rc = request_module(mod_name);
94 if (rc != 0) {
95 pr_warn("Unable to request_module for %s\n",
96 mod_name);
97 rc = 0;
98 }
Andy Grover58bd0c62013-05-29 12:05:59 -070099 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800100
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700101 tpg_np_new = iscsit_tpg_add_network_portal(tpg,
102 &np->np_sockaddr, tpg_np, type);
103 if (IS_ERR(tpg_np_new))
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800104 goto out;
105 } else {
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700106 tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
107 if (tpg_np_new) {
108 rc = iscsit_tpg_del_network_portal(tpg, tpg_np_new);
Andy Grover58bd0c62013-05-29 12:05:59 -0700109 if (rc < 0)
110 goto out;
111 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800112 }
113
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800114 iscsit_put_tpg(tpg);
115 return count;
116out:
117 iscsit_put_tpg(tpg);
Andy Grover58bd0c62013-05-29 12:05:59 -0700118 return rc;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800119}
120
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700121static ssize_t lio_target_np_iser_show(struct config_item *item, char *page)
Varun Prakash1c469602016-04-20 00:00:16 +0530122{
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700123 return lio_target_np_driver_show(item, page, ISCSI_INFINIBAND);
124}
Varun Prakash1c469602016-04-20 00:00:16 +0530125
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700126static ssize_t lio_target_np_iser_store(struct config_item *item,
127 const char *page, size_t count)
128{
129 return lio_target_np_driver_store(item, page, count,
130 ISCSI_INFINIBAND, "ib_isert");
131}
132CONFIGFS_ATTR(lio_target_np_, iser);
Varun Prakash1c469602016-04-20 00:00:16 +0530133
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700134static ssize_t lio_target_np_cxgbit_show(struct config_item *item, char *page)
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700135{
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700136 return lio_target_np_driver_show(item, page, ISCSI_CXGBIT);
Varun Prakash1c469602016-04-20 00:00:16 +0530137}
138
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700139static ssize_t lio_target_np_cxgbit_store(struct config_item *item,
140 const char *page, size_t count)
Varun Prakash1c469602016-04-20 00:00:16 +0530141{
Nicholas Bellingerd4b3fa42016-05-14 21:44:01 -0700142 return lio_target_np_driver_store(item, page, count,
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700143 ISCSI_CXGBIT, "cxgbit");
Varun Prakash1c469602016-04-20 00:00:16 +0530144}
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700145CONFIGFS_ATTR(lio_target_np_, cxgbit);
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800146
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000147static struct configfs_attribute *lio_target_portal_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200148 &lio_target_np_attr_iser,
Nicholas Bellingerff7199b2016-05-14 22:28:51 -0700149 &lio_target_np_attr_cxgbit,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000150 NULL,
151};
152
153/* Stop items for lio_target_portal_cit */
154
155/* Start items for lio_target_np_cit */
156
157#define MAX_PORTAL_LEN 256
158
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -0400159static struct se_tpg_np *lio_target_call_addnptotpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000160 struct se_portal_group *se_tpg,
161 struct config_group *group,
162 const char *name)
163{
164 struct iscsi_portal_group *tpg;
165 struct iscsi_tpg_np *tpg_np;
166 char *str, *str2, *ip_str, *port_str;
Andy Grover13a3cf02015-08-24 10:26:06 -0700167 struct sockaddr_storage sockaddr;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000168 struct sockaddr_in *sock_in;
169 struct sockaddr_in6 *sock_in6;
170 unsigned long port;
171 int ret;
172 char buf[MAX_PORTAL_LEN + 1];
173
174 if (strlen(name) > MAX_PORTAL_LEN) {
175 pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
176 (int)strlen(name), MAX_PORTAL_LEN);
177 return ERR_PTR(-EOVERFLOW);
178 }
179 memset(buf, 0, MAX_PORTAL_LEN + 1);
Nicholas Bellinger7bbb6542011-07-27 12:37:03 -0700180 snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000181
Andy Grover13a3cf02015-08-24 10:26:06 -0700182 memset(&sockaddr, 0, sizeof(struct sockaddr_storage));
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000183
184 str = strstr(buf, "[");
185 if (str) {
186 const char *end;
187
188 str2 = strstr(str, "]");
189 if (!str2) {
190 pr_err("Unable to locate trailing \"]\""
191 " in IPv6 iSCSI network portal address\n");
192 return ERR_PTR(-EINVAL);
193 }
194 str++; /* Skip over leading "[" */
Andy Grover76c28f12015-08-24 10:26:03 -0700195 *str2 = '\0'; /* Terminate the unbracketed IPv6 address */
196 str2++; /* Skip over the \0 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000197 port_str = strstr(str2, ":");
198 if (!port_str) {
199 pr_err("Unable to locate \":port\""
200 " in IPv6 iSCSI network portal address\n");
201 return ERR_PTR(-EINVAL);
202 }
203 *port_str = '\0'; /* Terminate string for IP */
204 port_str++; /* Skip over ":" */
205
Jingoo Han57103d72013-07-19 16:22:19 +0900206 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000207 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900208 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000209 return ERR_PTR(ret);
210 }
211 sock_in6 = (struct sockaddr_in6 *)&sockaddr;
212 sock_in6->sin6_family = AF_INET6;
213 sock_in6->sin6_port = htons((unsigned short)port);
Andy Groverdc58f762015-08-24 10:26:05 -0700214 ret = in6_pton(str, -1,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000215 (void *)&sock_in6->sin6_addr.in6_u, -1, &end);
216 if (ret <= 0) {
217 pr_err("in6_pton returned: %d\n", ret);
218 return ERR_PTR(-EINVAL);
219 }
220 } else {
221 str = ip_str = &buf[0];
222 port_str = strstr(ip_str, ":");
223 if (!port_str) {
224 pr_err("Unable to locate \":port\""
225 " in IPv4 iSCSI network portal address\n");
226 return ERR_PTR(-EINVAL);
227 }
228 *port_str = '\0'; /* Terminate string for IP */
229 port_str++; /* Skip over ":" */
230
Jingoo Han57103d72013-07-19 16:22:19 +0900231 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000232 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900233 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000234 return ERR_PTR(ret);
235 }
236 sock_in = (struct sockaddr_in *)&sockaddr;
237 sock_in->sin_family = AF_INET;
238 sock_in->sin_port = htons((unsigned short)port);
239 sock_in->sin_addr.s_addr = in_aton(ip_str);
240 }
241 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
242 ret = iscsit_get_tpg(tpg);
243 if (ret < 0)
244 return ERR_PTR(-EINVAL);
245
246 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
247 " PORTAL: %s\n",
248 config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
249 tpg->tpgt, name);
250 /*
251 * Assume ISCSI_TCP by default. Other network portals for other
252 * iSCSI fabrics:
253 *
254 * Traditional iSCSI over SCTP (initial support)
255 * iSER/TCP (TODO, hardware available)
256 * iSER/SCTP (TODO, software emulation with osc-iwarp)
257 * iSER/IB (TODO, hardware available)
258 *
Masanari Iida20879692012-08-27 22:46:00 +0900259 * can be enabled with attributes under
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000260 * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
261 *
262 */
Andy Grover76c28f12015-08-24 10:26:03 -0700263 tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, NULL,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000264 ISCSI_TCP);
265 if (IS_ERR(tpg_np)) {
266 iscsit_put_tpg(tpg);
Thomas Meyere1750ba2011-08-01 23:58:18 +0200267 return ERR_CAST(tpg_np);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000268 }
269 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
270
271 iscsit_put_tpg(tpg);
272 return &tpg_np->se_tpg_np;
273}
274
275static void lio_target_call_delnpfromtpg(
276 struct se_tpg_np *se_tpg_np)
277{
278 struct iscsi_portal_group *tpg;
279 struct iscsi_tpg_np *tpg_np;
280 struct se_portal_group *se_tpg;
281 int ret;
282
283 tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
284 tpg = tpg_np->tpg;
285 ret = iscsit_get_tpg(tpg);
286 if (ret < 0)
287 return;
288
289 se_tpg = &tpg->tpg_se_tpg;
290 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
Andy Grover69d75572015-08-24 10:26:04 -0700291 " PORTAL: %pISpc\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
292 tpg->tpgt, &tpg_np->tpg_np->np_sockaddr);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000293
294 ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
295 if (ret < 0)
296 goto out;
297
298 pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
299out:
300 iscsit_put_tpg(tpg);
301}
302
303/* End items for lio_target_np_cit */
304
305/* Start items for lio_target_nacl_attrib_cit */
306
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200307#define ISCSI_NACL_ATTR(name) \
308static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\
309 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000310{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200311 struct se_node_acl *se_nacl = attrib_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000312 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
313 se_node_acl); \
314 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700315 return sprintf(page, "%u\n", nacl->node_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000316} \
317 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200318static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\
319 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000320{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200321 struct se_node_acl *se_nacl = attrib_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000322 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
323 se_node_acl); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000324 u32 val; \
325 int ret; \
326 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400327 ret = kstrtou32(page, 0, &val); \
328 if (ret) \
329 return ret; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000330 ret = iscsit_na_##name(nacl, val); \
331 if (ret < 0) \
332 return ret; \
333 \
334 return count; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200335} \
336 \
337CONFIGFS_ATTR(iscsi_nacl_attrib_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000338
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200339ISCSI_NACL_ATTR(dataout_timeout);
340ISCSI_NACL_ATTR(dataout_timeout_retries);
341ISCSI_NACL_ATTR(default_erl);
342ISCSI_NACL_ATTR(nopin_timeout);
343ISCSI_NACL_ATTR(nopin_response_timeout);
344ISCSI_NACL_ATTR(random_datain_pdu_offsets);
345ISCSI_NACL_ATTR(random_datain_seq_offsets);
346ISCSI_NACL_ATTR(random_r2t_offsets);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000347
348static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200349 &iscsi_nacl_attrib_attr_dataout_timeout,
350 &iscsi_nacl_attrib_attr_dataout_timeout_retries,
351 &iscsi_nacl_attrib_attr_default_erl,
352 &iscsi_nacl_attrib_attr_nopin_timeout,
353 &iscsi_nacl_attrib_attr_nopin_response_timeout,
354 &iscsi_nacl_attrib_attr_random_datain_pdu_offsets,
355 &iscsi_nacl_attrib_attr_random_datain_seq_offsets,
356 &iscsi_nacl_attrib_attr_random_r2t_offsets,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000357 NULL,
358};
359
360/* End items for lio_target_nacl_attrib_cit */
361
362/* Start items for lio_target_nacl_auth_cit */
363
364#define __DEF_NACL_AUTH_STR(prefix, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200365static ssize_t __iscsi_##prefix##_##name##_show( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000366 struct iscsi_node_acl *nacl, \
367 char *page) \
368{ \
369 struct iscsi_node_auth *auth = &nacl->node_auth; \
370 \
371 if (!capable(CAP_SYS_ADMIN)) \
372 return -EPERM; \
373 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
374} \
375 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200376static ssize_t __iscsi_##prefix##_##name##_store( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000377 struct iscsi_node_acl *nacl, \
378 const char *page, \
379 size_t count) \
380{ \
381 struct iscsi_node_auth *auth = &nacl->node_auth; \
382 \
383 if (!capable(CAP_SYS_ADMIN)) \
384 return -EPERM; \
Eric Seppanen2306bfb2013-11-21 14:49:56 -0800385 if (count >= sizeof(auth->name)) \
386 return -EINVAL; \
Jörn Engel0fbfc462013-07-03 11:35:11 -0400387 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000388 if (!strncmp("NULL", auth->name, 4)) \
389 auth->naf_flags &= ~flags; \
390 else \
391 auth->naf_flags |= flags; \
392 \
393 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
394 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
395 auth->authenticate_target = 1; \
396 else \
397 auth->authenticate_target = 0; \
398 \
399 return count; \
400}
401
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200402#define DEF_NACL_AUTH_STR(name, flags) \
403 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
404static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
405 char *page) \
406{ \
407 struct se_node_acl *nacl = auth_to_nacl(item); \
408 return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
409 struct iscsi_node_acl, se_node_acl), page); \
410} \
411static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \
412 const char *page, size_t count) \
413{ \
414 struct se_node_acl *nacl = auth_to_nacl(item); \
415 return __iscsi_nacl_auth_##name##_store(container_of(nacl, \
416 struct iscsi_node_acl, se_node_acl), page, count); \
417} \
418 \
419CONFIGFS_ATTR(iscsi_nacl_auth_, name)
420
421/*
422 * One-way authentication userid
423 */
424DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
425DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
426DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
427DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
428
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000429#define __DEF_NACL_AUTH_INT(prefix, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200430static ssize_t __iscsi_##prefix##_##name##_show( \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000431 struct iscsi_node_acl *nacl, \
432 char *page) \
433{ \
434 struct iscsi_node_auth *auth = &nacl->node_auth; \
435 \
436 if (!capable(CAP_SYS_ADMIN)) \
437 return -EPERM; \
438 \
439 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
440}
441
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000442#define DEF_NACL_AUTH_INT(name) \
443 __DEF_NACL_AUTH_INT(nacl_auth, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200444static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
445 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000446{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200447 struct se_node_acl *nacl = auth_to_nacl(item); \
448 return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
449 struct iscsi_node_acl, se_node_acl), page); \
450} \
451 \
452CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000453
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000454DEF_NACL_AUTH_INT(authenticate_target);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000455
456static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200457 &iscsi_nacl_auth_attr_userid,
458 &iscsi_nacl_auth_attr_password,
459 &iscsi_nacl_auth_attr_authenticate_target,
460 &iscsi_nacl_auth_attr_userid_mutual,
461 &iscsi_nacl_auth_attr_password_mutual,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000462 NULL,
463};
464
465/* End items for lio_target_nacl_auth_cit */
466
467/* Start items for lio_target_nacl_param_cit */
468
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200469#define ISCSI_NACL_PARAM(name) \
470static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \
471 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000472{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200473 struct se_node_acl *se_nacl = param_to_nacl(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000474 struct iscsi_session *sess; \
475 struct se_session *se_sess; \
476 ssize_t rb; \
477 \
478 spin_lock_bh(&se_nacl->nacl_sess_lock); \
479 se_sess = se_nacl->nacl_sess; \
480 if (!se_sess) { \
481 rb = snprintf(page, PAGE_SIZE, \
482 "No Active iSCSI Session\n"); \
483 } else { \
484 sess = se_sess->fabric_sess_ptr; \
485 rb = snprintf(page, PAGE_SIZE, "%u\n", \
486 (u32)sess->sess_ops->name); \
487 } \
488 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
489 \
490 return rb; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200491} \
492 \
493CONFIGFS_ATTR_RO(iscsi_nacl_param_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000494
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200495ISCSI_NACL_PARAM(MaxConnections);
496ISCSI_NACL_PARAM(InitialR2T);
497ISCSI_NACL_PARAM(ImmediateData);
498ISCSI_NACL_PARAM(MaxBurstLength);
499ISCSI_NACL_PARAM(FirstBurstLength);
500ISCSI_NACL_PARAM(DefaultTime2Wait);
501ISCSI_NACL_PARAM(DefaultTime2Retain);
502ISCSI_NACL_PARAM(MaxOutstandingR2T);
503ISCSI_NACL_PARAM(DataPDUInOrder);
504ISCSI_NACL_PARAM(DataSequenceInOrder);
505ISCSI_NACL_PARAM(ErrorRecoveryLevel);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000506
507static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200508 &iscsi_nacl_param_attr_MaxConnections,
509 &iscsi_nacl_param_attr_InitialR2T,
510 &iscsi_nacl_param_attr_ImmediateData,
511 &iscsi_nacl_param_attr_MaxBurstLength,
512 &iscsi_nacl_param_attr_FirstBurstLength,
513 &iscsi_nacl_param_attr_DefaultTime2Wait,
514 &iscsi_nacl_param_attr_DefaultTime2Retain,
515 &iscsi_nacl_param_attr_MaxOutstandingR2T,
516 &iscsi_nacl_param_attr_DataPDUInOrder,
517 &iscsi_nacl_param_attr_DataSequenceInOrder,
518 &iscsi_nacl_param_attr_ErrorRecoveryLevel,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000519 NULL,
520};
521
522/* End items for lio_target_nacl_param_cit */
523
524/* Start items for lio_target_acl_cit */
525
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200526static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000527{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200528 struct se_node_acl *se_nacl = acl_to_nacl(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000529 struct iscsi_session *sess;
530 struct iscsi_conn *conn;
531 struct se_session *se_sess;
532 ssize_t rb = 0;
Roland Dreier109e2382015-07-23 14:53:32 -0700533 u32 max_cmd_sn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000534
535 spin_lock_bh(&se_nacl->nacl_sess_lock);
536 se_sess = se_nacl->nacl_sess;
537 if (!se_sess) {
538 rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
539 " Endpoint: %s\n", se_nacl->initiatorname);
540 } else {
541 sess = se_sess->fabric_sess_ptr;
542
Joern Engelcb354842014-09-02 17:49:50 -0400543 rb += sprintf(page+rb, "InitiatorName: %s\n",
544 sess->sess_ops->InitiatorName);
545 rb += sprintf(page+rb, "InitiatorAlias: %s\n",
546 sess->sess_ops->InitiatorAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000547
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +0200548 rb += sprintf(page+rb,
549 "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
550 sess->sid, sess->isid, sess->tsih);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000551 rb += sprintf(page+rb, "SessionType: %s\n",
552 (sess->sess_ops->SessionType) ?
553 "Discovery" : "Normal");
554 rb += sprintf(page+rb, "Session State: ");
555 switch (sess->session_state) {
556 case TARG_SESS_STATE_FREE:
557 rb += sprintf(page+rb, "TARG_SESS_FREE\n");
558 break;
559 case TARG_SESS_STATE_ACTIVE:
560 rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
561 break;
562 case TARG_SESS_STATE_LOGGED_IN:
563 rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
564 break;
565 case TARG_SESS_STATE_FAILED:
566 rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
567 break;
568 case TARG_SESS_STATE_IN_CONTINUE:
569 rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
570 break;
571 default:
572 rb += sprintf(page+rb, "ERROR: Unknown Session"
573 " State!\n");
574 break;
575 }
576
577 rb += sprintf(page+rb, "---------------------[iSCSI Session"
578 " Values]-----------------------\n");
579 rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
580 " : MaxCmdSN : ITT : TTT\n");
Roland Dreier109e2382015-07-23 14:53:32 -0700581 max_cmd_sn = (u32) atomic_read(&sess->max_cmd_sn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000582 rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
583 " 0x%08x 0x%08x\n",
584 sess->cmdsn_window,
Roland Dreier109e2382015-07-23 14:53:32 -0700585 (max_cmd_sn - sess->exp_cmd_sn) + 1,
586 sess->exp_cmd_sn, max_cmd_sn,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000587 sess->init_task_tag, sess->targ_xfer_tag);
588 rb += sprintf(page+rb, "----------------------[iSCSI"
589 " Connections]-------------------------\n");
590
591 spin_lock(&sess->conn_lock);
592 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
593 rb += sprintf(page+rb, "CID: %hu Connection"
594 " State: ", conn->cid);
595 switch (conn->conn_state) {
596 case TARG_CONN_STATE_FREE:
597 rb += sprintf(page+rb,
598 "TARG_CONN_STATE_FREE\n");
599 break;
600 case TARG_CONN_STATE_XPT_UP:
601 rb += sprintf(page+rb,
602 "TARG_CONN_STATE_XPT_UP\n");
603 break;
604 case TARG_CONN_STATE_IN_LOGIN:
605 rb += sprintf(page+rb,
606 "TARG_CONN_STATE_IN_LOGIN\n");
607 break;
608 case TARG_CONN_STATE_LOGGED_IN:
609 rb += sprintf(page+rb,
610 "TARG_CONN_STATE_LOGGED_IN\n");
611 break;
612 case TARG_CONN_STATE_IN_LOGOUT:
613 rb += sprintf(page+rb,
614 "TARG_CONN_STATE_IN_LOGOUT\n");
615 break;
616 case TARG_CONN_STATE_LOGOUT_REQUESTED:
617 rb += sprintf(page+rb,
618 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
619 break;
620 case TARG_CONN_STATE_CLEANUP_WAIT:
621 rb += sprintf(page+rb,
622 "TARG_CONN_STATE_CLEANUP_WAIT\n");
623 break;
624 default:
625 rb += sprintf(page+rb,
626 "ERROR: Unknown Connection State!\n");
627 break;
628 }
629
Andy Groverdc58f762015-08-24 10:26:05 -0700630 rb += sprintf(page+rb, " Address %pISc %s", &conn->login_sockaddr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000631 (conn->network_transport == ISCSI_TCP) ?
632 "TCP" : "SCTP");
633 rb += sprintf(page+rb, " StatSN: 0x%08x\n",
634 conn->stat_sn);
635 }
636 spin_unlock(&sess->conn_lock);
637 }
638 spin_unlock_bh(&se_nacl->nacl_sess_lock);
639
640 return rb;
641}
642
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200643static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item,
644 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000645{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200646 return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000647}
648
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200649static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item,
650 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000651{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200652 struct se_node_acl *se_nacl = acl_to_nacl(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000653 struct se_portal_group *se_tpg = se_nacl->se_tpg;
654 struct iscsi_portal_group *tpg = container_of(se_tpg,
655 struct iscsi_portal_group, tpg_se_tpg);
656 struct config_item *acl_ci, *tpg_ci, *wwn_ci;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000657 u32 cmdsn_depth = 0;
658 int ret;
659
Jörn Engelad7babd2013-07-03 11:35:11 -0400660 ret = kstrtou32(page, 0, &cmdsn_depth);
661 if (ret)
662 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000663 if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
664 pr_err("Passed cmdsn_depth: %u exceeds"
665 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
666 TA_DEFAULT_CMDSN_DEPTH_MAX);
667 return -EINVAL;
668 }
669 acl_ci = &se_nacl->acl_group.cg_item;
670 if (!acl_ci) {
671 pr_err("Unable to locatel acl_ci\n");
672 return -EINVAL;
673 }
674 tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
675 if (!tpg_ci) {
676 pr_err("Unable to locate tpg_ci\n");
677 return -EINVAL;
678 }
679 wwn_ci = &tpg_ci->ci_group->cg_item;
680 if (!wwn_ci) {
681 pr_err("Unable to locate config_item wwn_ci\n");
682 return -EINVAL;
683 }
684
685 if (iscsit_get_tpg(tpg) < 0)
686 return -EINVAL;
Nicholas Bellingerd36ad772016-01-07 22:15:06 -0800687
688 ret = core_tpg_set_initiator_node_queue_depth(se_nacl, cmdsn_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000689
690 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
691 "InitiatorName: %s\n", config_item_name(wwn_ci),
692 config_item_name(tpg_ci), cmdsn_depth,
693 config_item_name(acl_ci));
694
695 iscsit_put_tpg(tpg);
696 return (!ret) ? count : (ssize_t)ret;
697}
698
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200699static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page)
Andy Grover79e62fc2012-12-11 16:30:53 -0800700{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200701 return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag);
Andy Grover79e62fc2012-12-11 16:30:53 -0800702}
703
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200704static ssize_t lio_target_nacl_tag_store(struct config_item *item,
705 const char *page, size_t count)
Andy Grover79e62fc2012-12-11 16:30:53 -0800706{
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200707 struct se_node_acl *se_nacl = acl_to_nacl(item);
Andy Grover79e62fc2012-12-11 16:30:53 -0800708 int ret;
709
710 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
711
712 if (ret < 0)
713 return ret;
714 return count;
715}
716
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200717CONFIGFS_ATTR_RO(lio_target_nacl_, info);
718CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth);
719CONFIGFS_ATTR(lio_target_nacl_, tag);
Andy Grover79e62fc2012-12-11 16:30:53 -0800720
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000721static struct configfs_attribute *lio_target_initiator_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200722 &lio_target_nacl_attr_info,
723 &lio_target_nacl_attr_cmdsn_depth,
724 &lio_target_nacl_attr_tag,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000725 NULL,
726};
727
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200728static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
729 const char *name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000730{
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200731 struct iscsi_node_acl *acl =
732 container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000733
Andy Groverb7eec2c2013-10-09 11:05:57 -0700734 config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000735 "iscsi_sess_stats", &iscsi_stat_sess_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +0100736 configfs_add_default_group(&acl->node_stat_grps.iscsi_sess_stats_group,
737 &se_nacl->acl_fabric_stat_group);
Christoph Hellwigc7d6a802015-04-13 19:51:14 +0200738 return 0;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000739}
740
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000741/* End items for lio_target_acl_cit */
742
743/* Start items for lio_target_tpg_attrib_cit */
744
745#define DEF_TPG_ATTRIB(name) \
746 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200747static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \
748 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000749{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200750 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000751 struct iscsi_portal_group *tpg = container_of(se_tpg, \
752 struct iscsi_portal_group, tpg_se_tpg); \
753 ssize_t rb; \
754 \
755 if (iscsit_get_tpg(tpg) < 0) \
756 return -EINVAL; \
757 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700758 rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000759 iscsit_put_tpg(tpg); \
760 return rb; \
761} \
762 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200763static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\
764 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000765{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200766 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000767 struct iscsi_portal_group *tpg = container_of(se_tpg, \
768 struct iscsi_portal_group, tpg_se_tpg); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000769 u32 val; \
770 int ret; \
771 \
772 if (iscsit_get_tpg(tpg) < 0) \
773 return -EINVAL; \
774 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400775 ret = kstrtou32(page, 0, &val); \
776 if (ret) \
777 goto out; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000778 ret = iscsit_ta_##name(tpg, val); \
779 if (ret < 0) \
780 goto out; \
781 \
782 iscsit_put_tpg(tpg); \
783 return count; \
784out: \
785 iscsit_put_tpg(tpg); \
786 return ret; \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200787} \
788CONFIGFS_ATTR(iscsi_tpg_attrib_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000789
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000790DEF_TPG_ATTRIB(authentication);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000791DEF_TPG_ATTRIB(login_timeout);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000792DEF_TPG_ATTRIB(netif_timeout);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000793DEF_TPG_ATTRIB(generate_node_acls);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000794DEF_TPG_ATTRIB(default_cmdsn_depth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000795DEF_TPG_ATTRIB(cache_dynamic_acls);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000796DEF_TPG_ATTRIB(demo_mode_write_protect);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000797DEF_TPG_ATTRIB(prod_mode_write_protect);
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +0200798DEF_TPG_ATTRIB(demo_mode_discovery);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -0800799DEF_TPG_ATTRIB(default_erl);
Sagi Grimberg80851762014-02-19 17:50:20 +0200800DEF_TPG_ATTRIB(t10_pi);
Nicholas Bellinger901c04a2015-03-29 19:36:16 -0700801DEF_TPG_ATTRIB(fabric_prot_type);
David Disseldorpa6415cd2015-08-01 00:10:12 -0700802DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000803
804static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200805 &iscsi_tpg_attrib_attr_authentication,
806 &iscsi_tpg_attrib_attr_login_timeout,
807 &iscsi_tpg_attrib_attr_netif_timeout,
808 &iscsi_tpg_attrib_attr_generate_node_acls,
809 &iscsi_tpg_attrib_attr_default_cmdsn_depth,
810 &iscsi_tpg_attrib_attr_cache_dynamic_acls,
811 &iscsi_tpg_attrib_attr_demo_mode_write_protect,
812 &iscsi_tpg_attrib_attr_prod_mode_write_protect,
813 &iscsi_tpg_attrib_attr_demo_mode_discovery,
814 &iscsi_tpg_attrib_attr_default_erl,
815 &iscsi_tpg_attrib_attr_t10_pi,
816 &iscsi_tpg_attrib_attr_fabric_prot_type,
817 &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000818 NULL,
819};
820
821/* End items for lio_target_tpg_attrib_cit */
822
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700823/* Start items for lio_target_tpg_auth_cit */
824
825#define __DEF_TPG_AUTH_STR(prefix, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200826static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
827 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700828{ \
829 struct iscsi_portal_group *tpg = container_of(se_tpg, \
830 struct iscsi_portal_group, tpg_se_tpg); \
831 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
832 \
833 if (!capable(CAP_SYS_ADMIN)) \
834 return -EPERM; \
835 \
836 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
837} \
838 \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200839static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\
840 const char *page, size_t count) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700841{ \
842 struct iscsi_portal_group *tpg = container_of(se_tpg, \
843 struct iscsi_portal_group, tpg_se_tpg); \
844 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
845 \
846 if (!capable(CAP_SYS_ADMIN)) \
847 return -EPERM; \
848 \
Nicholas Bellinger37b32c62013-07-06 16:48:55 -0700849 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700850 if (!(strncmp("NULL", auth->name, 4))) \
851 auth->naf_flags &= ~flags; \
852 else \
853 auth->naf_flags |= flags; \
854 \
855 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
856 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
857 auth->authenticate_target = 1; \
858 else \
859 auth->authenticate_target = 0; \
860 \
861 return count; \
862}
863
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200864#define DEF_TPG_AUTH_STR(name, flags) \
865 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
866static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
867 char *page) \
868{ \
869 return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
870} \
871 \
872static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \
873 const char *page, size_t count) \
874{ \
875 return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \
876} \
877 \
878CONFIGFS_ATTR(iscsi_tpg_auth_, name);
879
880
881DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
882DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
883DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
884DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
885
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700886#define __DEF_TPG_AUTH_INT(prefix, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200887static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
888 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700889{ \
890 struct iscsi_portal_group *tpg = container_of(se_tpg, \
891 struct iscsi_portal_group, tpg_se_tpg); \
892 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
893 \
894 if (!capable(CAP_SYS_ADMIN)) \
895 return -EPERM; \
896 \
897 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
898}
899
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700900#define DEF_TPG_AUTH_INT(name) \
901 __DEF_TPG_AUTH_INT(tpg_auth, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200902static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
903 char *page) \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700904{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200905 return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
906} \
907CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name);
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700908
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700909DEF_TPG_AUTH_INT(authenticate_target);
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700910
911static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200912 &iscsi_tpg_auth_attr_userid,
913 &iscsi_tpg_auth_attr_password,
914 &iscsi_tpg_auth_attr_authenticate_target,
915 &iscsi_tpg_auth_attr_userid_mutual,
916 &iscsi_tpg_auth_attr_password_mutual,
Nicholas Bellingerc3e51442013-06-19 18:48:51 -0700917 NULL,
918};
919
920/* End items for lio_target_tpg_auth_cit */
921
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000922/* Start items for lio_target_tpg_param_cit */
923
924#define DEF_TPG_PARAM(name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200925static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \
926 char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000927{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200928 struct se_portal_group *se_tpg = param_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000929 struct iscsi_portal_group *tpg = container_of(se_tpg, \
930 struct iscsi_portal_group, tpg_se_tpg); \
931 struct iscsi_param *param; \
932 ssize_t rb; \
933 \
934 if (iscsit_get_tpg(tpg) < 0) \
935 return -EINVAL; \
936 \
937 param = iscsi_find_param_from_key(__stringify(name), \
938 tpg->param_list); \
939 if (!param) { \
940 iscsit_put_tpg(tpg); \
941 return -EINVAL; \
942 } \
943 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
944 \
945 iscsit_put_tpg(tpg); \
946 return rb; \
947} \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200948static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \
949 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000950{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200951 struct se_portal_group *se_tpg = param_to_tpg(item); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000952 struct iscsi_portal_group *tpg = container_of(se_tpg, \
953 struct iscsi_portal_group, tpg_se_tpg); \
954 char *buf; \
Jörn Engelad7babd2013-07-03 11:35:11 -0400955 int ret, len; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000956 \
957 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
958 if (!buf) \
959 return -ENOMEM; \
Jörn Engelad7babd2013-07-03 11:35:11 -0400960 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
961 if (isspace(buf[len-1])) \
962 buf[len-1] = '\0'; /* Kill newline */ \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000963 \
964 if (iscsit_get_tpg(tpg) < 0) { \
965 kfree(buf); \
966 return -EINVAL; \
967 } \
968 \
969 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
970 if (ret < 0) \
971 goto out; \
972 \
973 kfree(buf); \
974 iscsit_put_tpg(tpg); \
975 return count; \
976out: \
977 kfree(buf); \
978 iscsit_put_tpg(tpg); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +0200979 return -EINVAL; \
980} \
981CONFIGFS_ATTR(iscsi_tpg_param_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000982
983DEF_TPG_PARAM(AuthMethod);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000984DEF_TPG_PARAM(HeaderDigest);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000985DEF_TPG_PARAM(DataDigest);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000986DEF_TPG_PARAM(MaxConnections);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000987DEF_TPG_PARAM(TargetAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000988DEF_TPG_PARAM(InitialR2T);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000989DEF_TPG_PARAM(ImmediateData);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000990DEF_TPG_PARAM(MaxRecvDataSegmentLength);
Nicholas Bellingere004cb22012-09-29 21:47:16 -0700991DEF_TPG_PARAM(MaxXmitDataSegmentLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000992DEF_TPG_PARAM(MaxBurstLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000993DEF_TPG_PARAM(FirstBurstLength);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000994DEF_TPG_PARAM(DefaultTime2Wait);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000995DEF_TPG_PARAM(DefaultTime2Retain);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000996DEF_TPG_PARAM(MaxOutstandingR2T);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000997DEF_TPG_PARAM(DataPDUInOrder);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000998DEF_TPG_PARAM(DataSequenceInOrder);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000999DEF_TPG_PARAM(ErrorRecoveryLevel);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001000DEF_TPG_PARAM(IFMarker);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001001DEF_TPG_PARAM(OFMarker);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001002DEF_TPG_PARAM(IFMarkInt);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001003DEF_TPG_PARAM(OFMarkInt);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001004
1005static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001006 &iscsi_tpg_param_attr_AuthMethod,
1007 &iscsi_tpg_param_attr_HeaderDigest,
1008 &iscsi_tpg_param_attr_DataDigest,
1009 &iscsi_tpg_param_attr_MaxConnections,
1010 &iscsi_tpg_param_attr_TargetAlias,
1011 &iscsi_tpg_param_attr_InitialR2T,
1012 &iscsi_tpg_param_attr_ImmediateData,
1013 &iscsi_tpg_param_attr_MaxRecvDataSegmentLength,
1014 &iscsi_tpg_param_attr_MaxXmitDataSegmentLength,
1015 &iscsi_tpg_param_attr_MaxBurstLength,
1016 &iscsi_tpg_param_attr_FirstBurstLength,
1017 &iscsi_tpg_param_attr_DefaultTime2Wait,
1018 &iscsi_tpg_param_attr_DefaultTime2Retain,
1019 &iscsi_tpg_param_attr_MaxOutstandingR2T,
1020 &iscsi_tpg_param_attr_DataPDUInOrder,
1021 &iscsi_tpg_param_attr_DataSequenceInOrder,
1022 &iscsi_tpg_param_attr_ErrorRecoveryLevel,
1023 &iscsi_tpg_param_attr_IFMarker,
1024 &iscsi_tpg_param_attr_OFMarker,
1025 &iscsi_tpg_param_attr_IFMarkInt,
1026 &iscsi_tpg_param_attr_OFMarkInt,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001027 NULL,
1028};
1029
1030/* End items for lio_target_tpg_param_cit */
1031
1032/* Start items for lio_target_tpg_cit */
1033
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001034static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001035{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001036 struct se_portal_group *se_tpg = to_tpg(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001037 struct iscsi_portal_group *tpg = container_of(se_tpg,
1038 struct iscsi_portal_group, tpg_se_tpg);
1039 ssize_t len;
1040
1041 spin_lock(&tpg->tpg_state_lock);
1042 len = sprintf(page, "%d\n",
1043 (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
1044 spin_unlock(&tpg->tpg_state_lock);
1045
1046 return len;
1047}
1048
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001049static ssize_t lio_target_tpg_enable_store(struct config_item *item,
1050 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001051{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001052 struct se_portal_group *se_tpg = to_tpg(item);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001053 struct iscsi_portal_group *tpg = container_of(se_tpg,
1054 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001055 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001056 int ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001057
Jörn Engelad7babd2013-07-03 11:35:11 -04001058 ret = kstrtou32(page, 0, &op);
1059 if (ret)
1060 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001061 if ((op != 1) && (op != 0)) {
1062 pr_err("Illegal value for tpg_enable: %u\n", op);
1063 return -EINVAL;
1064 }
1065
1066 ret = iscsit_get_tpg(tpg);
1067 if (ret < 0)
1068 return -EINVAL;
1069
1070 if (op) {
1071 ret = iscsit_tpg_enable_portal_group(tpg);
1072 if (ret < 0)
1073 goto out;
1074 } else {
1075 /*
1076 * iscsit_tpg_disable_portal_group() assumes force=1
1077 */
1078 ret = iscsit_tpg_disable_portal_group(tpg, 1);
1079 if (ret < 0)
1080 goto out;
1081 }
1082
1083 iscsit_put_tpg(tpg);
1084 return count;
1085out:
1086 iscsit_put_tpg(tpg);
1087 return -EINVAL;
1088}
1089
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001090
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001091static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item,
1092 char *page)
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001093{
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001094 return target_show_dynamic_sessions(to_tpg(item), page);
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001095}
1096
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001097CONFIGFS_ATTR(lio_target_tpg_, enable);
1098CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions);
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001099
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001100static struct configfs_attribute *lio_target_tpg_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001101 &lio_target_tpg_attr_enable,
1102 &lio_target_tpg_attr_dynamic_sessions,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001103 NULL,
1104};
1105
1106/* End items for lio_target_tpg_cit */
1107
1108/* Start items for lio_target_tiqn_cit */
1109
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001110static struct se_portal_group *lio_target_tiqn_addtpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001111 struct se_wwn *wwn,
1112 struct config_group *group,
1113 const char *name)
1114{
1115 struct iscsi_portal_group *tpg;
1116 struct iscsi_tiqn *tiqn;
Jörn Engelad7babd2013-07-03 11:35:11 -04001117 char *tpgt_str;
1118 int ret;
1119 u16 tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001120
1121 tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1122 /*
1123 * Only tpgt_# directory groups can be created below
1124 * target/iscsi/iqn.superturodiskarry/
Jörn Engelad7babd2013-07-03 11:35:11 -04001125 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001126 tpgt_str = strstr(name, "tpgt_");
1127 if (!tpgt_str) {
1128 pr_err("Unable to locate \"tpgt_#\" directory"
1129 " group\n");
1130 return NULL;
1131 }
1132 tpgt_str += 5; /* Skip ahead of "tpgt_" */
Jörn Engelad7babd2013-07-03 11:35:11 -04001133 ret = kstrtou16(tpgt_str, 0, &tpgt);
1134 if (ret)
1135 return NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001136
1137 tpg = iscsit_alloc_portal_group(tiqn, tpgt);
1138 if (!tpg)
1139 return NULL;
1140
Nicholas Bellingerbc0c94b2015-05-20 21:48:03 -07001141 ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001142 if (ret < 0)
1143 return NULL;
1144
1145 ret = iscsit_tpg_add_portal_group(tiqn, tpg);
1146 if (ret != 0)
1147 goto out;
1148
1149 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1150 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1151 name);
1152 return &tpg->tpg_se_tpg;
1153out:
1154 core_tpg_deregister(&tpg->tpg_se_tpg);
1155 kfree(tpg);
1156 return NULL;
1157}
1158
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001159static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001160{
1161 struct iscsi_portal_group *tpg;
1162 struct iscsi_tiqn *tiqn;
1163
1164 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1165 tiqn = tpg->tpg_tiqn;
1166 /*
1167 * iscsit_tpg_del_portal_group() assumes force=1
1168 */
1169 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1170 iscsit_tpg_del_portal_group(tiqn, tpg, 1);
1171}
1172
1173/* End items for lio_target_tiqn_cit */
1174
1175/* Start LIO-Target TIQN struct contig_item lio_target_cit */
1176
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001177static ssize_t lio_target_wwn_lio_version_show(struct config_item *item,
1178 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001179{
Nicholas Bellinger4c762512013-09-05 15:29:12 -07001180 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001181}
1182
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001183CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001184
1185static struct configfs_attribute *lio_target_wwn_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001186 &lio_target_wwn_attr_lio_version,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001187 NULL,
1188};
1189
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001190static struct se_wwn *lio_target_call_coreaddtiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001191 struct target_fabric_configfs *tf,
1192 struct config_group *group,
1193 const char *name)
1194{
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001195 struct iscsi_tiqn *tiqn;
1196
1197 tiqn = iscsit_add_tiqn((unsigned char *)name);
1198 if (IS_ERR(tiqn))
Thomas Meyere1750ba2011-08-01 23:58:18 +02001199 return ERR_CAST(tiqn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001200
Christoph Hellwig839559e2016-03-29 13:03:35 +02001201 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1202 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1203 " %s\n", name);
1204 return &tiqn->tiqn_wwn;
1205}
1206
1207static void lio_target_add_wwn_groups(struct se_wwn *wwn)
1208{
1209 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1210
Andy Groverb7eec2c2013-10-09 11:05:57 -07001211 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001212 "iscsi_instance", &iscsi_stat_instance_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001213 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
1214 &tiqn->tiqn_wwn.fabric_stat_group);
1215
Andy Groverb7eec2c2013-10-09 11:05:57 -07001216 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001217 "iscsi_sess_err", &iscsi_stat_sess_err_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001218 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
1219 &tiqn->tiqn_wwn.fabric_stat_group);
1220
Andy Groverb7eec2c2013-10-09 11:05:57 -07001221 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001222 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001223 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
1224 &tiqn->tiqn_wwn.fabric_stat_group);
1225
Andy Groverb7eec2c2013-10-09 11:05:57 -07001226 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001227 "iscsi_login_stats", &iscsi_stat_login_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001228 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
1229 &tiqn->tiqn_wwn.fabric_stat_group);
1230
Andy Groverb7eec2c2013-10-09 11:05:57 -07001231 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001232 "iscsi_logout_stats", &iscsi_stat_logout_cit);
Christoph Hellwig1ae16022016-02-26 11:02:14 +01001233 configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
1234 &tiqn->tiqn_wwn.fabric_stat_group);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001235}
1236
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001237static void lio_target_call_coredeltiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001238 struct se_wwn *wwn)
1239{
1240 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001241
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001242 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1243 tiqn->tiqn);
1244 iscsit_del_tiqn(tiqn);
1245}
1246
1247/* End LIO-Target TIQN struct contig_lio_target_cit */
1248
1249/* Start lio_target_discovery_auth_cit */
1250
1251#define DEF_DISC_AUTH_STR(name, flags) \
1252 __DEF_NACL_AUTH_STR(disc, name, flags) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001253static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001254{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001255 return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001256 page); \
1257} \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001258static ssize_t iscsi_disc_##name##_store(struct config_item *item, \
1259 const char *page, size_t count) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001260{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001261 return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001262 page, count); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001263 \
1264} \
1265CONFIGFS_ATTR(iscsi_disc_, name)
1266
1267DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
1268DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
1269DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1270DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001271
1272#define DEF_DISC_AUTH_INT(name) \
1273 __DEF_NACL_AUTH_INT(disc, name) \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001274static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001275{ \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001276 return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001277 page); \
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001278} \
1279CONFIGFS_ATTR_RO(iscsi_disc_, name)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001280
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001281DEF_DISC_AUTH_INT(authenticate_target);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001282
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001283
1284static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item,
1285 char *page)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001286{
1287 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
1288
1289 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
1290}
1291
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001292static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1293 const char *page, size_t count)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001294{
1295 struct iscsi_param *param;
1296 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001297 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001298 int err;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001299
Jörn Engelad7babd2013-07-03 11:35:11 -04001300 err = kstrtou32(page, 0, &op);
1301 if (err)
1302 return -EINVAL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001303 if ((op != 1) && (op != 0)) {
1304 pr_err("Illegal value for enforce_discovery_auth:"
1305 " %u\n", op);
1306 return -EINVAL;
1307 }
1308
1309 if (!discovery_tpg) {
1310 pr_err("iscsit_global->discovery_tpg is NULL\n");
1311 return -EINVAL;
1312 }
1313
1314 param = iscsi_find_param_from_key(AUTHMETHOD,
1315 discovery_tpg->param_list);
1316 if (!param)
1317 return -EINVAL;
1318
1319 if (op) {
1320 /*
1321 * Reset the AuthMethod key to CHAP.
1322 */
1323 if (iscsi_update_param_value(param, CHAP) < 0)
1324 return -EINVAL;
1325
1326 discovery_tpg->tpg_attrib.authentication = 1;
1327 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
1328 pr_debug("LIO-CORE[0] Successfully enabled"
1329 " authentication enforcement for iSCSI"
1330 " Discovery TPG\n");
1331 } else {
1332 /*
1333 * Reset the AuthMethod key to CHAP,None
1334 */
1335 if (iscsi_update_param_value(param, "CHAP,None") < 0)
1336 return -EINVAL;
1337
1338 discovery_tpg->tpg_attrib.authentication = 0;
1339 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
1340 pr_debug("LIO-CORE[0] Successfully disabled"
1341 " authentication enforcement for iSCSI"
1342 " Discovery TPG\n");
1343 }
1344
1345 return count;
1346}
1347
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001348CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001349
1350static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
Christoph Hellwig2eafd722015-10-03 15:32:55 +02001351 &iscsi_disc_attr_userid,
1352 &iscsi_disc_attr_password,
1353 &iscsi_disc_attr_authenticate_target,
1354 &iscsi_disc_attr_userid_mutual,
1355 &iscsi_disc_attr_password_mutual,
1356 &iscsi_disc_attr_enforce_discovery_auth,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001357 NULL,
1358};
1359
1360/* End lio_target_discovery_auth_cit */
1361
1362/* Start functions for target_core_fabric_ops */
1363
1364static char *iscsi_get_fabric_name(void)
1365{
1366 return "iSCSI";
1367}
1368
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001369static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1370{
1371 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1372
1373 return cmd->i_state;
1374}
1375
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001376static u32 lio_sess_get_index(struct se_session *se_sess)
1377{
1378 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1379
1380 return sess->session_index;
1381}
1382
1383static u32 lio_sess_get_initiator_sid(
1384 struct se_session *se_sess,
1385 unsigned char *buf,
1386 u32 size)
1387{
1388 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1389 /*
1390 * iSCSI Initiator Session Identifier from RFC-3720.
1391 */
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +02001392 return snprintf(buf, size, "%6phN", sess->isid);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001393}
1394
1395static int lio_queue_data_in(struct se_cmd *se_cmd)
1396{
1397 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1398
1399 cmd->i_state = ISTATE_SEND_DATAIN;
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001400 cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd);
1401
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001402 return 0;
1403}
1404
1405static int lio_write_pending(struct se_cmd *se_cmd)
1406{
1407 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001408 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001409
1410 if (!cmd->immediate_data && !cmd->unsolicited_data)
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001411 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001412
1413 return 0;
1414}
1415
1416static int lio_write_pending_status(struct se_cmd *se_cmd)
1417{
1418 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1419 int ret;
1420
1421 spin_lock_bh(&cmd->istate_lock);
1422 ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
1423 spin_unlock_bh(&cmd->istate_lock);
1424
1425 return ret;
1426}
1427
1428static int lio_queue_status(struct se_cmd *se_cmd)
1429{
1430 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1431
1432 cmd->i_state = ISTATE_SEND_STATUS;
Nicholas Bellinger5e8e6b42013-11-12 17:54:56 -08001433
1434 if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
1435 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
1436 return 0;
1437 }
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001438 cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd);
1439
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001440 return 0;
1441}
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};