blob: 568e478615a5d537a6fba2d989c50cfb565e4053 [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 Bellingere48354c2011-07-23 06:43:04 +000026#include <target/target_core_fabric_configfs.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000027#include <target/target_core_configfs.h>
28#include <target/configfs_macros.h>
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -070029#include <target/iscsi/iscsi_transport.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000030
Sagi Grimberg67f091f2015-01-07 14:57:31 +020031#include <target/iscsi/iscsi_target_core.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000032#include "iscsi_target_parameters.h"
33#include "iscsi_target_device.h"
34#include "iscsi_target_erl0.h"
35#include "iscsi_target_nodeattrib.h"
36#include "iscsi_target_tpg.h"
37#include "iscsi_target_util.h"
38#include "iscsi_target.h"
Sagi Grimberg67f091f2015-01-07 14:57:31 +020039#include <target/iscsi/iscsi_target_stat.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000040
41struct lio_target_configfs_attribute {
42 struct configfs_attribute attr;
43 ssize_t (*show)(void *, char *);
44 ssize_t (*store)(void *, const char *, size_t);
45};
46
Nicholas Bellingere48354c2011-07-23 06:43:04 +000047/* Start items for lio_target_portal_cit */
48
49static ssize_t lio_target_np_show_sctp(
50 struct se_tpg_np *se_tpg_np,
51 char *page)
52{
53 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
54 struct iscsi_tpg_np, se_tpg_np);
55 struct iscsi_tpg_np *tpg_np_sctp;
56 ssize_t rb;
57
58 tpg_np_sctp = iscsit_tpg_locate_child_np(tpg_np, ISCSI_SCTP_TCP);
59 if (tpg_np_sctp)
60 rb = sprintf(page, "1\n");
61 else
62 rb = sprintf(page, "0\n");
63
64 return rb;
65}
66
67static ssize_t lio_target_np_store_sctp(
68 struct se_tpg_np *se_tpg_np,
69 const char *page,
70 size_t count)
71{
72 struct iscsi_np *np;
73 struct iscsi_portal_group *tpg;
74 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
75 struct iscsi_tpg_np, se_tpg_np);
76 struct iscsi_tpg_np *tpg_np_sctp = NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000077 u32 op;
78 int ret;
79
Jörn Engelad7babd2013-07-03 11:35:11 -040080 ret = kstrtou32(page, 0, &op);
81 if (ret)
82 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000083 if ((op != 1) && (op != 0)) {
84 pr_err("Illegal value for tpg_enable: %u\n", op);
85 return -EINVAL;
86 }
87 np = tpg_np->tpg_np;
88 if (!np) {
89 pr_err("Unable to locate struct iscsi_np from"
90 " struct iscsi_tpg_np\n");
91 return -EINVAL;
92 }
93
94 tpg = tpg_np->tpg;
95 if (iscsit_get_tpg(tpg) < 0)
96 return -EINVAL;
97
98 if (op) {
99 /*
100 * Use existing np->np_sockaddr for SCTP network portal reference
101 */
102 tpg_np_sctp = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr,
103 np->np_ip, tpg_np, ISCSI_SCTP_TCP);
104 if (!tpg_np_sctp || IS_ERR(tpg_np_sctp))
105 goto out;
106 } else {
107 tpg_np_sctp = iscsit_tpg_locate_child_np(tpg_np, ISCSI_SCTP_TCP);
108 if (!tpg_np_sctp)
109 goto out;
110
111 ret = iscsit_tpg_del_network_portal(tpg, tpg_np_sctp);
112 if (ret < 0)
113 goto out;
114 }
115
116 iscsit_put_tpg(tpg);
117 return count;
118out:
119 iscsit_put_tpg(tpg);
120 return -EINVAL;
121}
122
123TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR);
124
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800125static ssize_t lio_target_np_show_iser(
126 struct se_tpg_np *se_tpg_np,
127 char *page)
128{
129 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
130 struct iscsi_tpg_np, se_tpg_np);
131 struct iscsi_tpg_np *tpg_np_iser;
132 ssize_t rb;
133
134 tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND);
135 if (tpg_np_iser)
136 rb = sprintf(page, "1\n");
137 else
138 rb = sprintf(page, "0\n");
139
140 return rb;
141}
142
143static ssize_t lio_target_np_store_iser(
144 struct se_tpg_np *se_tpg_np,
145 const char *page,
146 size_t count)
147{
148 struct iscsi_np *np;
149 struct iscsi_portal_group *tpg;
150 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
151 struct iscsi_tpg_np, se_tpg_np);
152 struct iscsi_tpg_np *tpg_np_iser = NULL;
153 char *endptr;
154 u32 op;
Andy Grover58bd0c62013-05-29 12:05:59 -0700155 int rc = 0;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800156
157 op = simple_strtoul(page, &endptr, 0);
158 if ((op != 1) && (op != 0)) {
159 pr_err("Illegal value for tpg_enable: %u\n", op);
160 return -EINVAL;
161 }
162 np = tpg_np->tpg_np;
163 if (!np) {
164 pr_err("Unable to locate struct iscsi_np from"
165 " struct iscsi_tpg_np\n");
166 return -EINVAL;
167 }
168
169 tpg = tpg_np->tpg;
170 if (iscsit_get_tpg(tpg) < 0)
171 return -EINVAL;
172
173 if (op) {
Andy Grover58bd0c62013-05-29 12:05:59 -0700174 rc = request_module("ib_isert");
175 if (rc != 0) {
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800176 pr_warn("Unable to request_module for ib_isert\n");
Andy Grover58bd0c62013-05-29 12:05:59 -0700177 rc = 0;
178 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800179
180 tpg_np_iser = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr,
181 np->np_ip, tpg_np, ISCSI_INFINIBAND);
Andy Grover58bd0c62013-05-29 12:05:59 -0700182 if (IS_ERR(tpg_np_iser)) {
183 rc = PTR_ERR(tpg_np_iser);
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800184 goto out;
Andy Grover58bd0c62013-05-29 12:05:59 -0700185 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800186 } else {
187 tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND);
Andy Grover58bd0c62013-05-29 12:05:59 -0700188 if (tpg_np_iser) {
189 rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser);
190 if (rc < 0)
191 goto out;
192 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800193 }
194
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800195 iscsit_put_tpg(tpg);
196 return count;
197out:
198 iscsit_put_tpg(tpg);
Andy Grover58bd0c62013-05-29 12:05:59 -0700199 return rc;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800200}
201
202TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR);
203
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000204static struct configfs_attribute *lio_target_portal_attrs[] = {
205 &lio_target_np_sctp.attr,
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800206 &lio_target_np_iser.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000207 NULL,
208};
209
210/* Stop items for lio_target_portal_cit */
211
212/* Start items for lio_target_np_cit */
213
214#define MAX_PORTAL_LEN 256
215
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -0400216static struct se_tpg_np *lio_target_call_addnptotpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000217 struct se_portal_group *se_tpg,
218 struct config_group *group,
219 const char *name)
220{
221 struct iscsi_portal_group *tpg;
222 struct iscsi_tpg_np *tpg_np;
223 char *str, *str2, *ip_str, *port_str;
224 struct __kernel_sockaddr_storage sockaddr;
225 struct sockaddr_in *sock_in;
226 struct sockaddr_in6 *sock_in6;
227 unsigned long port;
228 int ret;
229 char buf[MAX_PORTAL_LEN + 1];
230
231 if (strlen(name) > MAX_PORTAL_LEN) {
232 pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
233 (int)strlen(name), MAX_PORTAL_LEN);
234 return ERR_PTR(-EOVERFLOW);
235 }
236 memset(buf, 0, MAX_PORTAL_LEN + 1);
Nicholas Bellinger7bbb6542011-07-27 12:37:03 -0700237 snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000238
239 memset(&sockaddr, 0, sizeof(struct __kernel_sockaddr_storage));
240
241 str = strstr(buf, "[");
242 if (str) {
243 const char *end;
244
245 str2 = strstr(str, "]");
246 if (!str2) {
247 pr_err("Unable to locate trailing \"]\""
248 " in IPv6 iSCSI network portal address\n");
249 return ERR_PTR(-EINVAL);
250 }
251 str++; /* Skip over leading "[" */
252 *str2 = '\0'; /* Terminate the IPv6 address */
253 str2++; /* Skip over the "]" */
254 port_str = strstr(str2, ":");
255 if (!port_str) {
256 pr_err("Unable to locate \":port\""
257 " in IPv6 iSCSI network portal address\n");
258 return ERR_PTR(-EINVAL);
259 }
260 *port_str = '\0'; /* Terminate string for IP */
261 port_str++; /* Skip over ":" */
262
Jingoo Han57103d72013-07-19 16:22:19 +0900263 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000264 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900265 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000266 return ERR_PTR(ret);
267 }
268 sock_in6 = (struct sockaddr_in6 *)&sockaddr;
269 sock_in6->sin6_family = AF_INET6;
270 sock_in6->sin6_port = htons((unsigned short)port);
271 ret = in6_pton(str, IPV6_ADDRESS_SPACE,
272 (void *)&sock_in6->sin6_addr.in6_u, -1, &end);
273 if (ret <= 0) {
274 pr_err("in6_pton returned: %d\n", ret);
275 return ERR_PTR(-EINVAL);
276 }
277 } else {
278 str = ip_str = &buf[0];
279 port_str = strstr(ip_str, ":");
280 if (!port_str) {
281 pr_err("Unable to locate \":port\""
282 " in IPv4 iSCSI network portal address\n");
283 return ERR_PTR(-EINVAL);
284 }
285 *port_str = '\0'; /* Terminate string for IP */
286 port_str++; /* Skip over ":" */
287
Jingoo Han57103d72013-07-19 16:22:19 +0900288 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000289 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900290 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000291 return ERR_PTR(ret);
292 }
293 sock_in = (struct sockaddr_in *)&sockaddr;
294 sock_in->sin_family = AF_INET;
295 sock_in->sin_port = htons((unsigned short)port);
296 sock_in->sin_addr.s_addr = in_aton(ip_str);
297 }
298 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
299 ret = iscsit_get_tpg(tpg);
300 if (ret < 0)
301 return ERR_PTR(-EINVAL);
302
303 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
304 " PORTAL: %s\n",
305 config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
306 tpg->tpgt, name);
307 /*
308 * Assume ISCSI_TCP by default. Other network portals for other
309 * iSCSI fabrics:
310 *
311 * Traditional iSCSI over SCTP (initial support)
312 * iSER/TCP (TODO, hardware available)
313 * iSER/SCTP (TODO, software emulation with osc-iwarp)
314 * iSER/IB (TODO, hardware available)
315 *
Masanari Iida20879692012-08-27 22:46:00 +0900316 * can be enabled with attributes under
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000317 * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
318 *
319 */
320 tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, str, NULL,
321 ISCSI_TCP);
322 if (IS_ERR(tpg_np)) {
323 iscsit_put_tpg(tpg);
Thomas Meyere1750ba2011-08-01 23:58:18 +0200324 return ERR_CAST(tpg_np);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000325 }
326 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
327
328 iscsit_put_tpg(tpg);
329 return &tpg_np->se_tpg_np;
330}
331
332static void lio_target_call_delnpfromtpg(
333 struct se_tpg_np *se_tpg_np)
334{
335 struct iscsi_portal_group *tpg;
336 struct iscsi_tpg_np *tpg_np;
337 struct se_portal_group *se_tpg;
338 int ret;
339
340 tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
341 tpg = tpg_np->tpg;
342 ret = iscsit_get_tpg(tpg);
343 if (ret < 0)
344 return;
345
346 se_tpg = &tpg->tpg_se_tpg;
347 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
348 " PORTAL: %s:%hu\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
349 tpg->tpgt, tpg_np->tpg_np->np_ip, tpg_np->tpg_np->np_port);
350
351 ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
352 if (ret < 0)
353 goto out;
354
355 pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
356out:
357 iscsit_put_tpg(tpg);
358}
359
360/* End items for lio_target_np_cit */
361
362/* Start items for lio_target_nacl_attrib_cit */
363
364#define DEF_NACL_ATTRIB(name) \
365static ssize_t iscsi_nacl_attrib_show_##name( \
366 struct se_node_acl *se_nacl, \
367 char *page) \
368{ \
369 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
370 se_node_acl); \
371 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700372 return sprintf(page, "%u\n", nacl->node_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000373} \
374 \
375static ssize_t iscsi_nacl_attrib_store_##name( \
376 struct se_node_acl *se_nacl, \
377 const char *page, \
378 size_t count) \
379{ \
380 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
381 se_node_acl); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000382 u32 val; \
383 int ret; \
384 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400385 ret = kstrtou32(page, 0, &val); \
386 if (ret) \
387 return ret; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000388 ret = iscsit_na_##name(nacl, val); \
389 if (ret < 0) \
390 return ret; \
391 \
392 return count; \
393}
394
395#define NACL_ATTR(_name, _mode) TF_NACL_ATTRIB_ATTR(iscsi, _name, _mode);
396/*
397 * Define iscsi_node_attrib_s_dataout_timeout
398 */
399DEF_NACL_ATTRIB(dataout_timeout);
400NACL_ATTR(dataout_timeout, S_IRUGO | S_IWUSR);
401/*
402 * Define iscsi_node_attrib_s_dataout_timeout_retries
403 */
404DEF_NACL_ATTRIB(dataout_timeout_retries);
405NACL_ATTR(dataout_timeout_retries, S_IRUGO | S_IWUSR);
406/*
407 * Define iscsi_node_attrib_s_default_erl
408 */
409DEF_NACL_ATTRIB(default_erl);
410NACL_ATTR(default_erl, S_IRUGO | S_IWUSR);
411/*
412 * Define iscsi_node_attrib_s_nopin_timeout
413 */
414DEF_NACL_ATTRIB(nopin_timeout);
415NACL_ATTR(nopin_timeout, S_IRUGO | S_IWUSR);
416/*
417 * Define iscsi_node_attrib_s_nopin_response_timeout
418 */
419DEF_NACL_ATTRIB(nopin_response_timeout);
420NACL_ATTR(nopin_response_timeout, S_IRUGO | S_IWUSR);
421/*
422 * Define iscsi_node_attrib_s_random_datain_pdu_offsets
423 */
424DEF_NACL_ATTRIB(random_datain_pdu_offsets);
425NACL_ATTR(random_datain_pdu_offsets, S_IRUGO | S_IWUSR);
426/*
427 * Define iscsi_node_attrib_s_random_datain_seq_offsets
428 */
429DEF_NACL_ATTRIB(random_datain_seq_offsets);
430NACL_ATTR(random_datain_seq_offsets, S_IRUGO | S_IWUSR);
431/*
432 * Define iscsi_node_attrib_s_random_r2t_offsets
433 */
434DEF_NACL_ATTRIB(random_r2t_offsets);
435NACL_ATTR(random_r2t_offsets, S_IRUGO | S_IWUSR);
436
437static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
438 &iscsi_nacl_attrib_dataout_timeout.attr,
439 &iscsi_nacl_attrib_dataout_timeout_retries.attr,
440 &iscsi_nacl_attrib_default_erl.attr,
441 &iscsi_nacl_attrib_nopin_timeout.attr,
442 &iscsi_nacl_attrib_nopin_response_timeout.attr,
443 &iscsi_nacl_attrib_random_datain_pdu_offsets.attr,
444 &iscsi_nacl_attrib_random_datain_seq_offsets.attr,
445 &iscsi_nacl_attrib_random_r2t_offsets.attr,
446 NULL,
447};
448
449/* End items for lio_target_nacl_attrib_cit */
450
451/* Start items for lio_target_nacl_auth_cit */
452
453#define __DEF_NACL_AUTH_STR(prefix, name, flags) \
454static ssize_t __iscsi_##prefix##_show_##name( \
455 struct iscsi_node_acl *nacl, \
456 char *page) \
457{ \
458 struct iscsi_node_auth *auth = &nacl->node_auth; \
459 \
460 if (!capable(CAP_SYS_ADMIN)) \
461 return -EPERM; \
462 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
463} \
464 \
465static ssize_t __iscsi_##prefix##_store_##name( \
466 struct iscsi_node_acl *nacl, \
467 const char *page, \
468 size_t count) \
469{ \
470 struct iscsi_node_auth *auth = &nacl->node_auth; \
471 \
472 if (!capable(CAP_SYS_ADMIN)) \
473 return -EPERM; \
Eric Seppanen2306bfb2013-11-21 14:49:56 -0800474 if (count >= sizeof(auth->name)) \
475 return -EINVAL; \
Jörn Engel0fbfc462013-07-03 11:35:11 -0400476 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000477 if (!strncmp("NULL", auth->name, 4)) \
478 auth->naf_flags &= ~flags; \
479 else \
480 auth->naf_flags |= flags; \
481 \
482 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
483 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
484 auth->authenticate_target = 1; \
485 else \
486 auth->authenticate_target = 0; \
487 \
488 return count; \
489}
490
491#define __DEF_NACL_AUTH_INT(prefix, name) \
492static ssize_t __iscsi_##prefix##_show_##name( \
493 struct iscsi_node_acl *nacl, \
494 char *page) \
495{ \
496 struct iscsi_node_auth *auth = &nacl->node_auth; \
497 \
498 if (!capable(CAP_SYS_ADMIN)) \
499 return -EPERM; \
500 \
501 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
502}
503
504#define DEF_NACL_AUTH_STR(name, flags) \
505 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
506static ssize_t iscsi_nacl_auth_show_##name( \
507 struct se_node_acl *nacl, \
508 char *page) \
509{ \
510 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
511 struct iscsi_node_acl, se_node_acl), page); \
512} \
513static ssize_t iscsi_nacl_auth_store_##name( \
514 struct se_node_acl *nacl, \
515 const char *page, \
516 size_t count) \
517{ \
518 return __iscsi_nacl_auth_store_##name(container_of(nacl, \
519 struct iscsi_node_acl, se_node_acl), page, count); \
520}
521
522#define DEF_NACL_AUTH_INT(name) \
523 __DEF_NACL_AUTH_INT(nacl_auth, name) \
524static ssize_t iscsi_nacl_auth_show_##name( \
525 struct se_node_acl *nacl, \
526 char *page) \
527{ \
528 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
529 struct iscsi_node_acl, se_node_acl), page); \
530}
531
532#define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode);
533#define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name);
534
535/*
536 * One-way authentication userid
537 */
538DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
539AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
540/*
541 * One-way authentication password
542 */
543DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
544AUTH_ATTR(password, S_IRUGO | S_IWUSR);
545/*
546 * Enforce mutual authentication
547 */
548DEF_NACL_AUTH_INT(authenticate_target);
549AUTH_ATTR_RO(authenticate_target);
550/*
551 * Mutual authentication userid
552 */
553DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
554AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
555/*
556 * Mutual authentication password
557 */
558DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
559AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
560
561static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
562 &iscsi_nacl_auth_userid.attr,
563 &iscsi_nacl_auth_password.attr,
564 &iscsi_nacl_auth_authenticate_target.attr,
565 &iscsi_nacl_auth_userid_mutual.attr,
566 &iscsi_nacl_auth_password_mutual.attr,
567 NULL,
568};
569
570/* End items for lio_target_nacl_auth_cit */
571
572/* Start items for lio_target_nacl_param_cit */
573
574#define DEF_NACL_PARAM(name) \
575static ssize_t iscsi_nacl_param_show_##name( \
576 struct se_node_acl *se_nacl, \
577 char *page) \
578{ \
579 struct iscsi_session *sess; \
580 struct se_session *se_sess; \
581 ssize_t rb; \
582 \
583 spin_lock_bh(&se_nacl->nacl_sess_lock); \
584 se_sess = se_nacl->nacl_sess; \
585 if (!se_sess) { \
586 rb = snprintf(page, PAGE_SIZE, \
587 "No Active iSCSI Session\n"); \
588 } else { \
589 sess = se_sess->fabric_sess_ptr; \
590 rb = snprintf(page, PAGE_SIZE, "%u\n", \
591 (u32)sess->sess_ops->name); \
592 } \
593 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
594 \
595 return rb; \
596}
597
598#define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name);
599
600DEF_NACL_PARAM(MaxConnections);
601NACL_PARAM_ATTR(MaxConnections);
602
603DEF_NACL_PARAM(InitialR2T);
604NACL_PARAM_ATTR(InitialR2T);
605
606DEF_NACL_PARAM(ImmediateData);
607NACL_PARAM_ATTR(ImmediateData);
608
609DEF_NACL_PARAM(MaxBurstLength);
610NACL_PARAM_ATTR(MaxBurstLength);
611
612DEF_NACL_PARAM(FirstBurstLength);
613NACL_PARAM_ATTR(FirstBurstLength);
614
615DEF_NACL_PARAM(DefaultTime2Wait);
616NACL_PARAM_ATTR(DefaultTime2Wait);
617
618DEF_NACL_PARAM(DefaultTime2Retain);
619NACL_PARAM_ATTR(DefaultTime2Retain);
620
621DEF_NACL_PARAM(MaxOutstandingR2T);
622NACL_PARAM_ATTR(MaxOutstandingR2T);
623
624DEF_NACL_PARAM(DataPDUInOrder);
625NACL_PARAM_ATTR(DataPDUInOrder);
626
627DEF_NACL_PARAM(DataSequenceInOrder);
628NACL_PARAM_ATTR(DataSequenceInOrder);
629
630DEF_NACL_PARAM(ErrorRecoveryLevel);
631NACL_PARAM_ATTR(ErrorRecoveryLevel);
632
633static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
634 &iscsi_nacl_param_MaxConnections.attr,
635 &iscsi_nacl_param_InitialR2T.attr,
636 &iscsi_nacl_param_ImmediateData.attr,
637 &iscsi_nacl_param_MaxBurstLength.attr,
638 &iscsi_nacl_param_FirstBurstLength.attr,
639 &iscsi_nacl_param_DefaultTime2Wait.attr,
640 &iscsi_nacl_param_DefaultTime2Retain.attr,
641 &iscsi_nacl_param_MaxOutstandingR2T.attr,
642 &iscsi_nacl_param_DataPDUInOrder.attr,
643 &iscsi_nacl_param_DataSequenceInOrder.attr,
644 &iscsi_nacl_param_ErrorRecoveryLevel.attr,
645 NULL,
646};
647
648/* End items for lio_target_nacl_param_cit */
649
650/* Start items for lio_target_acl_cit */
651
652static ssize_t lio_target_nacl_show_info(
653 struct se_node_acl *se_nacl,
654 char *page)
655{
656 struct iscsi_session *sess;
657 struct iscsi_conn *conn;
658 struct se_session *se_sess;
659 ssize_t rb = 0;
660
661 spin_lock_bh(&se_nacl->nacl_sess_lock);
662 se_sess = se_nacl->nacl_sess;
663 if (!se_sess) {
664 rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
665 " Endpoint: %s\n", se_nacl->initiatorname);
666 } else {
667 sess = se_sess->fabric_sess_ptr;
668
Joern Engelcb354842014-09-02 17:49:50 -0400669 rb += sprintf(page+rb, "InitiatorName: %s\n",
670 sess->sess_ops->InitiatorName);
671 rb += sprintf(page+rb, "InitiatorAlias: %s\n",
672 sess->sess_ops->InitiatorAlias);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000673
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +0200674 rb += sprintf(page+rb,
675 "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
676 sess->sid, sess->isid, sess->tsih);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000677 rb += sprintf(page+rb, "SessionType: %s\n",
678 (sess->sess_ops->SessionType) ?
679 "Discovery" : "Normal");
680 rb += sprintf(page+rb, "Session State: ");
681 switch (sess->session_state) {
682 case TARG_SESS_STATE_FREE:
683 rb += sprintf(page+rb, "TARG_SESS_FREE\n");
684 break;
685 case TARG_SESS_STATE_ACTIVE:
686 rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
687 break;
688 case TARG_SESS_STATE_LOGGED_IN:
689 rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
690 break;
691 case TARG_SESS_STATE_FAILED:
692 rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
693 break;
694 case TARG_SESS_STATE_IN_CONTINUE:
695 rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
696 break;
697 default:
698 rb += sprintf(page+rb, "ERROR: Unknown Session"
699 " State!\n");
700 break;
701 }
702
703 rb += sprintf(page+rb, "---------------------[iSCSI Session"
704 " Values]-----------------------\n");
705 rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
706 " : MaxCmdSN : ITT : TTT\n");
707 rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
708 " 0x%08x 0x%08x\n",
709 sess->cmdsn_window,
710 (sess->max_cmd_sn - sess->exp_cmd_sn) + 1,
711 sess->exp_cmd_sn, sess->max_cmd_sn,
712 sess->init_task_tag, sess->targ_xfer_tag);
713 rb += sprintf(page+rb, "----------------------[iSCSI"
714 " Connections]-------------------------\n");
715
716 spin_lock(&sess->conn_lock);
717 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
718 rb += sprintf(page+rb, "CID: %hu Connection"
719 " State: ", conn->cid);
720 switch (conn->conn_state) {
721 case TARG_CONN_STATE_FREE:
722 rb += sprintf(page+rb,
723 "TARG_CONN_STATE_FREE\n");
724 break;
725 case TARG_CONN_STATE_XPT_UP:
726 rb += sprintf(page+rb,
727 "TARG_CONN_STATE_XPT_UP\n");
728 break;
729 case TARG_CONN_STATE_IN_LOGIN:
730 rb += sprintf(page+rb,
731 "TARG_CONN_STATE_IN_LOGIN\n");
732 break;
733 case TARG_CONN_STATE_LOGGED_IN:
734 rb += sprintf(page+rb,
735 "TARG_CONN_STATE_LOGGED_IN\n");
736 break;
737 case TARG_CONN_STATE_IN_LOGOUT:
738 rb += sprintf(page+rb,
739 "TARG_CONN_STATE_IN_LOGOUT\n");
740 break;
741 case TARG_CONN_STATE_LOGOUT_REQUESTED:
742 rb += sprintf(page+rb,
743 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
744 break;
745 case TARG_CONN_STATE_CLEANUP_WAIT:
746 rb += sprintf(page+rb,
747 "TARG_CONN_STATE_CLEANUP_WAIT\n");
748 break;
749 default:
750 rb += sprintf(page+rb,
751 "ERROR: Unknown Connection State!\n");
752 break;
753 }
754
755 rb += sprintf(page+rb, " Address %s %s", conn->login_ip,
756 (conn->network_transport == ISCSI_TCP) ?
757 "TCP" : "SCTP");
758 rb += sprintf(page+rb, " StatSN: 0x%08x\n",
759 conn->stat_sn);
760 }
761 spin_unlock(&sess->conn_lock);
762 }
763 spin_unlock_bh(&se_nacl->nacl_sess_lock);
764
765 return rb;
766}
767
768TF_NACL_BASE_ATTR_RO(lio_target, info);
769
770static ssize_t lio_target_nacl_show_cmdsn_depth(
771 struct se_node_acl *se_nacl,
772 char *page)
773{
774 return sprintf(page, "%u\n", se_nacl->queue_depth);
775}
776
777static ssize_t lio_target_nacl_store_cmdsn_depth(
778 struct se_node_acl *se_nacl,
779 const char *page,
780 size_t count)
781{
782 struct se_portal_group *se_tpg = se_nacl->se_tpg;
783 struct iscsi_portal_group *tpg = container_of(se_tpg,
784 struct iscsi_portal_group, tpg_se_tpg);
785 struct config_item *acl_ci, *tpg_ci, *wwn_ci;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000786 u32 cmdsn_depth = 0;
787 int ret;
788
Jörn Engelad7babd2013-07-03 11:35:11 -0400789 ret = kstrtou32(page, 0, &cmdsn_depth);
790 if (ret)
791 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000792 if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
793 pr_err("Passed cmdsn_depth: %u exceeds"
794 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
795 TA_DEFAULT_CMDSN_DEPTH_MAX);
796 return -EINVAL;
797 }
798 acl_ci = &se_nacl->acl_group.cg_item;
799 if (!acl_ci) {
800 pr_err("Unable to locatel acl_ci\n");
801 return -EINVAL;
802 }
803 tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
804 if (!tpg_ci) {
805 pr_err("Unable to locate tpg_ci\n");
806 return -EINVAL;
807 }
808 wwn_ci = &tpg_ci->ci_group->cg_item;
809 if (!wwn_ci) {
810 pr_err("Unable to locate config_item wwn_ci\n");
811 return -EINVAL;
812 }
813
814 if (iscsit_get_tpg(tpg) < 0)
815 return -EINVAL;
816 /*
817 * iscsit_tpg_set_initiator_node_queue_depth() assumes force=1
818 */
819 ret = iscsit_tpg_set_initiator_node_queue_depth(tpg,
820 config_item_name(acl_ci), cmdsn_depth, 1);
821
822 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
823 "InitiatorName: %s\n", config_item_name(wwn_ci),
824 config_item_name(tpg_ci), cmdsn_depth,
825 config_item_name(acl_ci));
826
827 iscsit_put_tpg(tpg);
828 return (!ret) ? count : (ssize_t)ret;
829}
830
831TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR);
832
Andy Grover79e62fc2012-12-11 16:30:53 -0800833static ssize_t lio_target_nacl_show_tag(
834 struct se_node_acl *se_nacl,
835 char *page)
836{
837 return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag);
838}
839
840static ssize_t lio_target_nacl_store_tag(
841 struct se_node_acl *se_nacl,
842 const char *page,
843 size_t count)
844{
845 int ret;
846
847 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
848
849 if (ret < 0)
850 return ret;
851 return count;
852}
853
854TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR);
855
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000856static struct configfs_attribute *lio_target_initiator_attrs[] = {
857 &lio_target_nacl_info.attr,
858 &lio_target_nacl_cmdsn_depth.attr,
Andy Grover79e62fc2012-12-11 16:30:53 -0800859 &lio_target_nacl_tag.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000860 NULL,
861};
862
863static struct se_node_acl *lio_tpg_alloc_fabric_acl(
864 struct se_portal_group *se_tpg)
865{
866 struct iscsi_node_acl *acl;
867
868 acl = kzalloc(sizeof(struct iscsi_node_acl), GFP_KERNEL);
869 if (!acl) {
870 pr_err("Unable to allocate memory for struct iscsi_node_acl\n");
871 return NULL;
872 }
873
874 return &acl->se_node_acl;
875}
876
877static struct se_node_acl *lio_target_make_nodeacl(
878 struct se_portal_group *se_tpg,
879 struct config_group *group,
880 const char *name)
881{
882 struct config_group *stats_cg;
883 struct iscsi_node_acl *acl;
884 struct se_node_acl *se_nacl_new, *se_nacl;
885 struct iscsi_portal_group *tpg = container_of(se_tpg,
886 struct iscsi_portal_group, tpg_se_tpg);
887 u32 cmdsn_depth;
888
889 se_nacl_new = lio_tpg_alloc_fabric_acl(se_tpg);
890 if (!se_nacl_new)
891 return ERR_PTR(-ENOMEM);
892
Andy Groverb7eec2c2013-10-09 11:05:57 -0700893 cmdsn_depth = tpg->tpg_attrib.default_cmdsn_depth;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000894 /*
895 * se_nacl_new may be released by core_tpg_add_initiator_node_acl()
896 * when converting a NdoeACL from demo mode -> explict
897 */
898 se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
899 name, cmdsn_depth);
900 if (IS_ERR(se_nacl))
901 return se_nacl;
902
Nicholas Bellingerd0628332012-02-26 22:16:07 -0800903 acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
904 stats_cg = &se_nacl->acl_fabric_stat_group;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000905
Sebastian Andrzej Siewior13f6a912012-11-27 18:54:21 +0100906 stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000907 GFP_KERNEL);
908 if (!stats_cg->default_groups) {
909 pr_err("Unable to allocate memory for"
910 " stats_cg->default_groups\n");
911 core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
912 kfree(acl);
913 return ERR_PTR(-ENOMEM);
914 }
915
Andy Groverb7eec2c2013-10-09 11:05:57 -0700916 stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000917 stats_cg->default_groups[1] = NULL;
Andy Groverb7eec2c2013-10-09 11:05:57 -0700918 config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000919 "iscsi_sess_stats", &iscsi_stat_sess_cit);
920
921 return se_nacl;
922}
923
924static void lio_target_drop_nodeacl(
925 struct se_node_acl *se_nacl)
926{
927 struct se_portal_group *se_tpg = se_nacl->se_tpg;
928 struct iscsi_node_acl *acl = container_of(se_nacl,
929 struct iscsi_node_acl, se_node_acl);
930 struct config_item *df_item;
931 struct config_group *stats_cg;
932 int i;
933
934 stats_cg = &acl->se_node_acl.acl_fabric_stat_group;
935 for (i = 0; stats_cg->default_groups[i]; i++) {
936 df_item = &stats_cg->default_groups[i]->cg_item;
937 stats_cg->default_groups[i] = NULL;
938 config_item_put(df_item);
939 }
940 kfree(stats_cg->default_groups);
941
942 core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
943 kfree(acl);
944}
945
946/* End items for lio_target_acl_cit */
947
948/* Start items for lio_target_tpg_attrib_cit */
949
950#define DEF_TPG_ATTRIB(name) \
951 \
952static ssize_t iscsi_tpg_attrib_show_##name( \
953 struct se_portal_group *se_tpg, \
954 char *page) \
955{ \
956 struct iscsi_portal_group *tpg = container_of(se_tpg, \
957 struct iscsi_portal_group, tpg_se_tpg); \
958 ssize_t rb; \
959 \
960 if (iscsit_get_tpg(tpg) < 0) \
961 return -EINVAL; \
962 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700963 rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000964 iscsit_put_tpg(tpg); \
965 return rb; \
966} \
967 \
968static ssize_t iscsi_tpg_attrib_store_##name( \
969 struct se_portal_group *se_tpg, \
970 const char *page, \
971 size_t count) \
972{ \
973 struct iscsi_portal_group *tpg = container_of(se_tpg, \
974 struct iscsi_portal_group, tpg_se_tpg); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000975 u32 val; \
976 int ret; \
977 \
978 if (iscsit_get_tpg(tpg) < 0) \
979 return -EINVAL; \
980 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400981 ret = kstrtou32(page, 0, &val); \
982 if (ret) \
983 goto out; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000984 ret = iscsit_ta_##name(tpg, val); \
985 if (ret < 0) \
986 goto out; \
987 \
988 iscsit_put_tpg(tpg); \
989 return count; \
990out: \
991 iscsit_put_tpg(tpg); \
992 return ret; \
993}
994
995#define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode);
996
997/*
998 * Define iscsi_tpg_attrib_s_authentication
999 */
1000DEF_TPG_ATTRIB(authentication);
1001TPG_ATTR(authentication, S_IRUGO | S_IWUSR);
1002/*
1003 * Define iscsi_tpg_attrib_s_login_timeout
1004 */
1005DEF_TPG_ATTRIB(login_timeout);
1006TPG_ATTR(login_timeout, S_IRUGO | S_IWUSR);
1007/*
1008 * Define iscsi_tpg_attrib_s_netif_timeout
1009 */
1010DEF_TPG_ATTRIB(netif_timeout);
1011TPG_ATTR(netif_timeout, S_IRUGO | S_IWUSR);
1012/*
1013 * Define iscsi_tpg_attrib_s_generate_node_acls
1014 */
1015DEF_TPG_ATTRIB(generate_node_acls);
1016TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR);
1017/*
1018 * Define iscsi_tpg_attrib_s_default_cmdsn_depth
1019 */
1020DEF_TPG_ATTRIB(default_cmdsn_depth);
1021TPG_ATTR(default_cmdsn_depth, S_IRUGO | S_IWUSR);
1022/*
1023 Define iscsi_tpg_attrib_s_cache_dynamic_acls
1024 */
1025DEF_TPG_ATTRIB(cache_dynamic_acls);
1026TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR);
1027/*
1028 * Define iscsi_tpg_attrib_s_demo_mode_write_protect
1029 */
1030DEF_TPG_ATTRIB(demo_mode_write_protect);
1031TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR);
1032/*
1033 * Define iscsi_tpg_attrib_s_prod_mode_write_protect
1034 */
1035DEF_TPG_ATTRIB(prod_mode_write_protect);
1036TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR);
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +02001037/*
1038 * Define iscsi_tpg_attrib_s_demo_mode_discovery,
1039 */
1040DEF_TPG_ATTRIB(demo_mode_discovery);
1041TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001042/*
1043 * Define iscsi_tpg_attrib_s_default_erl
1044 */
1045DEF_TPG_ATTRIB(default_erl);
1046TPG_ATTR(default_erl, S_IRUGO | S_IWUSR);
Sagi Grimberg80851762014-02-19 17:50:20 +02001047/*
1048 * Define iscsi_tpg_attrib_s_t10_pi
1049 */
1050DEF_TPG_ATTRIB(t10_pi);
1051TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR);
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001052/*
1053 * Define iscsi_tpg_attrib_s_fabric_prot_type
1054 */
1055DEF_TPG_ATTRIB(fabric_prot_type);
1056TPG_ATTR(fabric_prot_type, S_IRUGO | S_IWUSR);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001057
1058static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
1059 &iscsi_tpg_attrib_authentication.attr,
1060 &iscsi_tpg_attrib_login_timeout.attr,
1061 &iscsi_tpg_attrib_netif_timeout.attr,
1062 &iscsi_tpg_attrib_generate_node_acls.attr,
1063 &iscsi_tpg_attrib_default_cmdsn_depth.attr,
1064 &iscsi_tpg_attrib_cache_dynamic_acls.attr,
1065 &iscsi_tpg_attrib_demo_mode_write_protect.attr,
1066 &iscsi_tpg_attrib_prod_mode_write_protect.attr,
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +02001067 &iscsi_tpg_attrib_demo_mode_discovery.attr,
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001068 &iscsi_tpg_attrib_default_erl.attr,
Sagi Grimberg80851762014-02-19 17:50:20 +02001069 &iscsi_tpg_attrib_t10_pi.attr,
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001070 &iscsi_tpg_attrib_fabric_prot_type.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001071 NULL,
1072};
1073
1074/* End items for lio_target_tpg_attrib_cit */
1075
Nicholas Bellingerc3e51442013-06-19 18:48:51 -07001076/* Start items for lio_target_tpg_auth_cit */
1077
1078#define __DEF_TPG_AUTH_STR(prefix, name, flags) \
1079static ssize_t __iscsi_##prefix##_show_##name( \
1080 struct se_portal_group *se_tpg, \
1081 char *page) \
1082{ \
1083 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1084 struct iscsi_portal_group, tpg_se_tpg); \
1085 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1086 \
1087 if (!capable(CAP_SYS_ADMIN)) \
1088 return -EPERM; \
1089 \
1090 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
1091} \
1092 \
1093static ssize_t __iscsi_##prefix##_store_##name( \
1094 struct se_portal_group *se_tpg, \
1095 const char *page, \
1096 size_t count) \
1097{ \
1098 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1099 struct iscsi_portal_group, tpg_se_tpg); \
1100 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1101 \
1102 if (!capable(CAP_SYS_ADMIN)) \
1103 return -EPERM; \
1104 \
Nicholas Bellinger37b32c62013-07-06 16:48:55 -07001105 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -07001106 if (!(strncmp("NULL", auth->name, 4))) \
1107 auth->naf_flags &= ~flags; \
1108 else \
1109 auth->naf_flags |= flags; \
1110 \
1111 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
1112 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
1113 auth->authenticate_target = 1; \
1114 else \
1115 auth->authenticate_target = 0; \
1116 \
1117 return count; \
1118}
1119
1120#define __DEF_TPG_AUTH_INT(prefix, name) \
1121static ssize_t __iscsi_##prefix##_show_##name( \
1122 struct se_portal_group *se_tpg, \
1123 char *page) \
1124{ \
1125 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1126 struct iscsi_portal_group, tpg_se_tpg); \
1127 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1128 \
1129 if (!capable(CAP_SYS_ADMIN)) \
1130 return -EPERM; \
1131 \
1132 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
1133}
1134
1135#define DEF_TPG_AUTH_STR(name, flags) \
1136 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
1137static ssize_t iscsi_tpg_auth_show_##name( \
1138 struct se_portal_group *se_tpg, \
1139 char *page) \
1140{ \
1141 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1142} \
1143 \
1144static ssize_t iscsi_tpg_auth_store_##name( \
1145 struct se_portal_group *se_tpg, \
1146 const char *page, \
1147 size_t count) \
1148{ \
1149 return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \
1150}
1151
1152#define DEF_TPG_AUTH_INT(name) \
1153 __DEF_TPG_AUTH_INT(tpg_auth, name) \
1154static ssize_t iscsi_tpg_auth_show_##name( \
1155 struct se_portal_group *se_tpg, \
1156 char *page) \
1157{ \
1158 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1159}
1160
1161#define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode);
1162#define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name);
1163
1164/*
1165 * * One-way authentication userid
1166 * */
1167DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
1168TPG_AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
1169/*
1170 * * One-way authentication password
1171 * */
1172DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
1173TPG_AUTH_ATTR(password, S_IRUGO | S_IWUSR);
1174/*
1175 * * Enforce mutual authentication
1176 * */
1177DEF_TPG_AUTH_INT(authenticate_target);
1178TPG_AUTH_ATTR_RO(authenticate_target);
1179/*
1180 * * Mutual authentication userid
1181 * */
1182DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1183TPG_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
1184/*
1185 * * Mutual authentication password
1186 * */
1187DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
1188TPG_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
1189
1190static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
1191 &iscsi_tpg_auth_userid.attr,
1192 &iscsi_tpg_auth_password.attr,
1193 &iscsi_tpg_auth_authenticate_target.attr,
1194 &iscsi_tpg_auth_userid_mutual.attr,
1195 &iscsi_tpg_auth_password_mutual.attr,
1196 NULL,
1197};
1198
1199/* End items for lio_target_tpg_auth_cit */
1200
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001201/* Start items for lio_target_tpg_param_cit */
1202
1203#define DEF_TPG_PARAM(name) \
1204static ssize_t iscsi_tpg_param_show_##name( \
1205 struct se_portal_group *se_tpg, \
1206 char *page) \
1207{ \
1208 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1209 struct iscsi_portal_group, tpg_se_tpg); \
1210 struct iscsi_param *param; \
1211 ssize_t rb; \
1212 \
1213 if (iscsit_get_tpg(tpg) < 0) \
1214 return -EINVAL; \
1215 \
1216 param = iscsi_find_param_from_key(__stringify(name), \
1217 tpg->param_list); \
1218 if (!param) { \
1219 iscsit_put_tpg(tpg); \
1220 return -EINVAL; \
1221 } \
1222 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
1223 \
1224 iscsit_put_tpg(tpg); \
1225 return rb; \
1226} \
1227static ssize_t iscsi_tpg_param_store_##name( \
1228 struct se_portal_group *se_tpg, \
1229 const char *page, \
1230 size_t count) \
1231{ \
1232 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1233 struct iscsi_portal_group, tpg_se_tpg); \
1234 char *buf; \
Jörn Engelad7babd2013-07-03 11:35:11 -04001235 int ret, len; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001236 \
1237 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
1238 if (!buf) \
1239 return -ENOMEM; \
Jörn Engelad7babd2013-07-03 11:35:11 -04001240 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
1241 if (isspace(buf[len-1])) \
1242 buf[len-1] = '\0'; /* Kill newline */ \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001243 \
1244 if (iscsit_get_tpg(tpg) < 0) { \
1245 kfree(buf); \
1246 return -EINVAL; \
1247 } \
1248 \
1249 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
1250 if (ret < 0) \
1251 goto out; \
1252 \
1253 kfree(buf); \
1254 iscsit_put_tpg(tpg); \
1255 return count; \
1256out: \
1257 kfree(buf); \
1258 iscsit_put_tpg(tpg); \
1259 return -EINVAL; \
1260}
1261
1262#define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode);
1263
1264DEF_TPG_PARAM(AuthMethod);
1265TPG_PARAM_ATTR(AuthMethod, S_IRUGO | S_IWUSR);
1266
1267DEF_TPG_PARAM(HeaderDigest);
1268TPG_PARAM_ATTR(HeaderDigest, S_IRUGO | S_IWUSR);
1269
1270DEF_TPG_PARAM(DataDigest);
1271TPG_PARAM_ATTR(DataDigest, S_IRUGO | S_IWUSR);
1272
1273DEF_TPG_PARAM(MaxConnections);
1274TPG_PARAM_ATTR(MaxConnections, S_IRUGO | S_IWUSR);
1275
1276DEF_TPG_PARAM(TargetAlias);
1277TPG_PARAM_ATTR(TargetAlias, S_IRUGO | S_IWUSR);
1278
1279DEF_TPG_PARAM(InitialR2T);
1280TPG_PARAM_ATTR(InitialR2T, S_IRUGO | S_IWUSR);
1281
1282DEF_TPG_PARAM(ImmediateData);
1283TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR);
1284
1285DEF_TPG_PARAM(MaxRecvDataSegmentLength);
1286TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR);
1287
Nicholas Bellingere004cb22012-09-29 21:47:16 -07001288DEF_TPG_PARAM(MaxXmitDataSegmentLength);
1289TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR);
1290
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001291DEF_TPG_PARAM(MaxBurstLength);
1292TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR);
1293
1294DEF_TPG_PARAM(FirstBurstLength);
1295TPG_PARAM_ATTR(FirstBurstLength, S_IRUGO | S_IWUSR);
1296
1297DEF_TPG_PARAM(DefaultTime2Wait);
1298TPG_PARAM_ATTR(DefaultTime2Wait, S_IRUGO | S_IWUSR);
1299
1300DEF_TPG_PARAM(DefaultTime2Retain);
1301TPG_PARAM_ATTR(DefaultTime2Retain, S_IRUGO | S_IWUSR);
1302
1303DEF_TPG_PARAM(MaxOutstandingR2T);
1304TPG_PARAM_ATTR(MaxOutstandingR2T, S_IRUGO | S_IWUSR);
1305
1306DEF_TPG_PARAM(DataPDUInOrder);
1307TPG_PARAM_ATTR(DataPDUInOrder, S_IRUGO | S_IWUSR);
1308
1309DEF_TPG_PARAM(DataSequenceInOrder);
1310TPG_PARAM_ATTR(DataSequenceInOrder, S_IRUGO | S_IWUSR);
1311
1312DEF_TPG_PARAM(ErrorRecoveryLevel);
1313TPG_PARAM_ATTR(ErrorRecoveryLevel, S_IRUGO | S_IWUSR);
1314
1315DEF_TPG_PARAM(IFMarker);
1316TPG_PARAM_ATTR(IFMarker, S_IRUGO | S_IWUSR);
1317
1318DEF_TPG_PARAM(OFMarker);
1319TPG_PARAM_ATTR(OFMarker, S_IRUGO | S_IWUSR);
1320
1321DEF_TPG_PARAM(IFMarkInt);
1322TPG_PARAM_ATTR(IFMarkInt, S_IRUGO | S_IWUSR);
1323
1324DEF_TPG_PARAM(OFMarkInt);
1325TPG_PARAM_ATTR(OFMarkInt, S_IRUGO | S_IWUSR);
1326
1327static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
1328 &iscsi_tpg_param_AuthMethod.attr,
1329 &iscsi_tpg_param_HeaderDigest.attr,
1330 &iscsi_tpg_param_DataDigest.attr,
1331 &iscsi_tpg_param_MaxConnections.attr,
1332 &iscsi_tpg_param_TargetAlias.attr,
1333 &iscsi_tpg_param_InitialR2T.attr,
1334 &iscsi_tpg_param_ImmediateData.attr,
1335 &iscsi_tpg_param_MaxRecvDataSegmentLength.attr,
Nicholas Bellingere004cb22012-09-29 21:47:16 -07001336 &iscsi_tpg_param_MaxXmitDataSegmentLength.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001337 &iscsi_tpg_param_MaxBurstLength.attr,
1338 &iscsi_tpg_param_FirstBurstLength.attr,
1339 &iscsi_tpg_param_DefaultTime2Wait.attr,
1340 &iscsi_tpg_param_DefaultTime2Retain.attr,
1341 &iscsi_tpg_param_MaxOutstandingR2T.attr,
1342 &iscsi_tpg_param_DataPDUInOrder.attr,
1343 &iscsi_tpg_param_DataSequenceInOrder.attr,
1344 &iscsi_tpg_param_ErrorRecoveryLevel.attr,
1345 &iscsi_tpg_param_IFMarker.attr,
1346 &iscsi_tpg_param_OFMarker.attr,
1347 &iscsi_tpg_param_IFMarkInt.attr,
1348 &iscsi_tpg_param_OFMarkInt.attr,
1349 NULL,
1350};
1351
1352/* End items for lio_target_tpg_param_cit */
1353
1354/* Start items for lio_target_tpg_cit */
1355
1356static ssize_t lio_target_tpg_show_enable(
1357 struct se_portal_group *se_tpg,
1358 char *page)
1359{
1360 struct iscsi_portal_group *tpg = container_of(se_tpg,
1361 struct iscsi_portal_group, tpg_se_tpg);
1362 ssize_t len;
1363
1364 spin_lock(&tpg->tpg_state_lock);
1365 len = sprintf(page, "%d\n",
1366 (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
1367 spin_unlock(&tpg->tpg_state_lock);
1368
1369 return len;
1370}
1371
1372static ssize_t lio_target_tpg_store_enable(
1373 struct se_portal_group *se_tpg,
1374 const char *page,
1375 size_t count)
1376{
1377 struct iscsi_portal_group *tpg = container_of(se_tpg,
1378 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001379 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001380 int ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001381
Jörn Engelad7babd2013-07-03 11:35:11 -04001382 ret = kstrtou32(page, 0, &op);
1383 if (ret)
1384 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001385 if ((op != 1) && (op != 0)) {
1386 pr_err("Illegal value for tpg_enable: %u\n", op);
1387 return -EINVAL;
1388 }
1389
1390 ret = iscsit_get_tpg(tpg);
1391 if (ret < 0)
1392 return -EINVAL;
1393
1394 if (op) {
1395 ret = iscsit_tpg_enable_portal_group(tpg);
1396 if (ret < 0)
1397 goto out;
1398 } else {
1399 /*
1400 * iscsit_tpg_disable_portal_group() assumes force=1
1401 */
1402 ret = iscsit_tpg_disable_portal_group(tpg, 1);
1403 if (ret < 0)
1404 goto out;
1405 }
1406
1407 iscsit_put_tpg(tpg);
1408 return count;
1409out:
1410 iscsit_put_tpg(tpg);
1411 return -EINVAL;
1412}
1413
1414TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR);
1415
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001416static ssize_t lio_target_tpg_show_dynamic_sessions(
1417 struct se_portal_group *se_tpg,
1418 char *page)
1419{
1420 return target_show_dynamic_sessions(se_tpg, page);
1421}
1422
1423TF_TPG_BASE_ATTR_RO(lio_target, dynamic_sessions);
1424
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001425static struct configfs_attribute *lio_target_tpg_attrs[] = {
1426 &lio_target_tpg_enable.attr,
Nicholas Bellingerd4ee46f2015-03-06 20:40:57 -08001427 &lio_target_tpg_dynamic_sessions.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001428 NULL,
1429};
1430
1431/* End items for lio_target_tpg_cit */
1432
1433/* Start items for lio_target_tiqn_cit */
1434
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001435static struct se_portal_group *lio_target_tiqn_addtpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001436 struct se_wwn *wwn,
1437 struct config_group *group,
1438 const char *name)
1439{
1440 struct iscsi_portal_group *tpg;
1441 struct iscsi_tiqn *tiqn;
Jörn Engelad7babd2013-07-03 11:35:11 -04001442 char *tpgt_str;
1443 int ret;
1444 u16 tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001445
1446 tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1447 /*
1448 * Only tpgt_# directory groups can be created below
1449 * target/iscsi/iqn.superturodiskarry/
Jörn Engelad7babd2013-07-03 11:35:11 -04001450 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001451 tpgt_str = strstr(name, "tpgt_");
1452 if (!tpgt_str) {
1453 pr_err("Unable to locate \"tpgt_#\" directory"
1454 " group\n");
1455 return NULL;
1456 }
1457 tpgt_str += 5; /* Skip ahead of "tpgt_" */
Jörn Engelad7babd2013-07-03 11:35:11 -04001458 ret = kstrtou16(tpgt_str, 0, &tpgt);
1459 if (ret)
1460 return NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001461
1462 tpg = iscsit_alloc_portal_group(tiqn, tpgt);
1463 if (!tpg)
1464 return NULL;
1465
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001466 ret = core_tpg_register(&iscsi_ops, wwn, &tpg->tpg_se_tpg,
1467 tpg, TRANSPORT_TPG_TYPE_NORMAL);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001468 if (ret < 0)
1469 return NULL;
1470
1471 ret = iscsit_tpg_add_portal_group(tiqn, tpg);
1472 if (ret != 0)
1473 goto out;
1474
1475 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1476 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1477 name);
1478 return &tpg->tpg_se_tpg;
1479out:
1480 core_tpg_deregister(&tpg->tpg_se_tpg);
1481 kfree(tpg);
1482 return NULL;
1483}
1484
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001485static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001486{
1487 struct iscsi_portal_group *tpg;
1488 struct iscsi_tiqn *tiqn;
1489
1490 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1491 tiqn = tpg->tpg_tiqn;
1492 /*
1493 * iscsit_tpg_del_portal_group() assumes force=1
1494 */
1495 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1496 iscsit_tpg_del_portal_group(tiqn, tpg, 1);
1497}
1498
1499/* End items for lio_target_tiqn_cit */
1500
1501/* Start LIO-Target TIQN struct contig_item lio_target_cit */
1502
1503static ssize_t lio_target_wwn_show_attr_lio_version(
1504 struct target_fabric_configfs *tf,
1505 char *page)
1506{
Nicholas Bellinger4c762512013-09-05 15:29:12 -07001507 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001508}
1509
1510TF_WWN_ATTR_RO(lio_target, lio_version);
1511
1512static struct configfs_attribute *lio_target_wwn_attrs[] = {
1513 &lio_target_wwn_lio_version.attr,
1514 NULL,
1515};
1516
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001517static struct se_wwn *lio_target_call_coreaddtiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001518 struct target_fabric_configfs *tf,
1519 struct config_group *group,
1520 const char *name)
1521{
1522 struct config_group *stats_cg;
1523 struct iscsi_tiqn *tiqn;
1524
1525 tiqn = iscsit_add_tiqn((unsigned char *)name);
1526 if (IS_ERR(tiqn))
Thomas Meyere1750ba2011-08-01 23:58:18 +02001527 return ERR_CAST(tiqn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001528 /*
1529 * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group.
1530 */
1531 stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
1532
Sebastian Andrzej Siewior13f6a912012-11-27 18:54:21 +01001533 stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001534 GFP_KERNEL);
1535 if (!stats_cg->default_groups) {
1536 pr_err("Unable to allocate memory for"
1537 " stats_cg->default_groups\n");
1538 iscsit_del_tiqn(tiqn);
1539 return ERR_PTR(-ENOMEM);
1540 }
1541
Andy Groverb7eec2c2013-10-09 11:05:57 -07001542 stats_cg->default_groups[0] = &tiqn->tiqn_stat_grps.iscsi_instance_group;
1543 stats_cg->default_groups[1] = &tiqn->tiqn_stat_grps.iscsi_sess_err_group;
1544 stats_cg->default_groups[2] = &tiqn->tiqn_stat_grps.iscsi_tgt_attr_group;
1545 stats_cg->default_groups[3] = &tiqn->tiqn_stat_grps.iscsi_login_stats_group;
1546 stats_cg->default_groups[4] = &tiqn->tiqn_stat_grps.iscsi_logout_stats_group;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001547 stats_cg->default_groups[5] = NULL;
Andy Groverb7eec2c2013-10-09 11:05:57 -07001548 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001549 "iscsi_instance", &iscsi_stat_instance_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001550 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001551 "iscsi_sess_err", &iscsi_stat_sess_err_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001552 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001553 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001554 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001555 "iscsi_login_stats", &iscsi_stat_login_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001556 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001557 "iscsi_logout_stats", &iscsi_stat_logout_cit);
1558
1559 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1560 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1561 " %s\n", name);
1562 return &tiqn->tiqn_wwn;
1563}
1564
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001565static void lio_target_call_coredeltiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001566 struct se_wwn *wwn)
1567{
1568 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1569 struct config_item *df_item;
1570 struct config_group *stats_cg;
1571 int i;
1572
1573 stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
1574 for (i = 0; stats_cg->default_groups[i]; i++) {
1575 df_item = &stats_cg->default_groups[i]->cg_item;
1576 stats_cg->default_groups[i] = NULL;
1577 config_item_put(df_item);
1578 }
1579 kfree(stats_cg->default_groups);
1580
1581 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1582 tiqn->tiqn);
1583 iscsit_del_tiqn(tiqn);
1584}
1585
1586/* End LIO-Target TIQN struct contig_lio_target_cit */
1587
1588/* Start lio_target_discovery_auth_cit */
1589
1590#define DEF_DISC_AUTH_STR(name, flags) \
1591 __DEF_NACL_AUTH_STR(disc, name, flags) \
1592static ssize_t iscsi_disc_show_##name( \
1593 struct target_fabric_configfs *tf, \
1594 char *page) \
1595{ \
1596 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1597 page); \
1598} \
1599static ssize_t iscsi_disc_store_##name( \
1600 struct target_fabric_configfs *tf, \
1601 const char *page, \
1602 size_t count) \
1603{ \
1604 return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \
1605 page, count); \
1606}
1607
1608#define DEF_DISC_AUTH_INT(name) \
1609 __DEF_NACL_AUTH_INT(disc, name) \
1610static ssize_t iscsi_disc_show_##name( \
1611 struct target_fabric_configfs *tf, \
1612 char *page) \
1613{ \
1614 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1615 page); \
1616}
1617
1618#define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode)
1619#define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name)
1620
1621/*
1622 * One-way authentication userid
1623 */
1624DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
1625DISC_AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
1626/*
1627 * One-way authentication password
1628 */
1629DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
1630DISC_AUTH_ATTR(password, S_IRUGO | S_IWUSR);
1631/*
1632 * Enforce mutual authentication
1633 */
1634DEF_DISC_AUTH_INT(authenticate_target);
1635DISC_AUTH_ATTR_RO(authenticate_target);
1636/*
1637 * Mutual authentication userid
1638 */
1639DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1640DISC_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
1641/*
1642 * Mutual authentication password
1643 */
1644DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
1645DISC_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
1646
1647/*
1648 * enforce_discovery_auth
1649 */
1650static ssize_t iscsi_disc_show_enforce_discovery_auth(
1651 struct target_fabric_configfs *tf,
1652 char *page)
1653{
1654 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
1655
1656 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
1657}
1658
1659static ssize_t iscsi_disc_store_enforce_discovery_auth(
1660 struct target_fabric_configfs *tf,
1661 const char *page,
1662 size_t count)
1663{
1664 struct iscsi_param *param;
1665 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001666 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001667 int err;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001668
Jörn Engelad7babd2013-07-03 11:35:11 -04001669 err = kstrtou32(page, 0, &op);
1670 if (err)
1671 return -EINVAL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001672 if ((op != 1) && (op != 0)) {
1673 pr_err("Illegal value for enforce_discovery_auth:"
1674 " %u\n", op);
1675 return -EINVAL;
1676 }
1677
1678 if (!discovery_tpg) {
1679 pr_err("iscsit_global->discovery_tpg is NULL\n");
1680 return -EINVAL;
1681 }
1682
1683 param = iscsi_find_param_from_key(AUTHMETHOD,
1684 discovery_tpg->param_list);
1685 if (!param)
1686 return -EINVAL;
1687
1688 if (op) {
1689 /*
1690 * Reset the AuthMethod key to CHAP.
1691 */
1692 if (iscsi_update_param_value(param, CHAP) < 0)
1693 return -EINVAL;
1694
1695 discovery_tpg->tpg_attrib.authentication = 1;
1696 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
1697 pr_debug("LIO-CORE[0] Successfully enabled"
1698 " authentication enforcement for iSCSI"
1699 " Discovery TPG\n");
1700 } else {
1701 /*
1702 * Reset the AuthMethod key to CHAP,None
1703 */
1704 if (iscsi_update_param_value(param, "CHAP,None") < 0)
1705 return -EINVAL;
1706
1707 discovery_tpg->tpg_attrib.authentication = 0;
1708 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
1709 pr_debug("LIO-CORE[0] Successfully disabled"
1710 " authentication enforcement for iSCSI"
1711 " Discovery TPG\n");
1712 }
1713
1714 return count;
1715}
1716
1717DISC_AUTH_ATTR(enforce_discovery_auth, S_IRUGO | S_IWUSR);
1718
1719static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
1720 &iscsi_disc_userid.attr,
1721 &iscsi_disc_password.attr,
1722 &iscsi_disc_authenticate_target.attr,
1723 &iscsi_disc_userid_mutual.attr,
1724 &iscsi_disc_password_mutual.attr,
1725 &iscsi_disc_enforce_discovery_auth.attr,
1726 NULL,
1727};
1728
1729/* End lio_target_discovery_auth_cit */
1730
1731/* Start functions for target_core_fabric_ops */
1732
1733static char *iscsi_get_fabric_name(void)
1734{
1735 return "iSCSI";
1736}
1737
1738static u32 iscsi_get_task_tag(struct se_cmd *se_cmd)
1739{
1740 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1741
Christoph Hellwig66c7db62012-09-26 08:00:39 -04001742 /* only used for printks or comparism with ->ref_task_tag */
1743 return (__force u32)cmd->init_task_tag;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001744}
1745
1746static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1747{
1748 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1749
1750 return cmd->i_state;
1751}
1752
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001753static u32 lio_sess_get_index(struct se_session *se_sess)
1754{
1755 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1756
1757 return sess->session_index;
1758}
1759
1760static u32 lio_sess_get_initiator_sid(
1761 struct se_session *se_sess,
1762 unsigned char *buf,
1763 u32 size)
1764{
1765 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1766 /*
1767 * iSCSI Initiator Session Identifier from RFC-3720.
1768 */
Andy Shevchenko5cdf5a82015-01-15 13:40:56 +02001769 return snprintf(buf, size, "%6phN", sess->isid);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001770}
1771
1772static int lio_queue_data_in(struct se_cmd *se_cmd)
1773{
1774 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1775
1776 cmd->i_state = ISTATE_SEND_DATAIN;
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001777 cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd);
1778
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001779 return 0;
1780}
1781
1782static int lio_write_pending(struct se_cmd *se_cmd)
1783{
1784 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001785 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001786
1787 if (!cmd->immediate_data && !cmd->unsolicited_data)
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001788 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001789
1790 return 0;
1791}
1792
1793static int lio_write_pending_status(struct se_cmd *se_cmd)
1794{
1795 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1796 int ret;
1797
1798 spin_lock_bh(&cmd->istate_lock);
1799 ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
1800 spin_unlock_bh(&cmd->istate_lock);
1801
1802 return ret;
1803}
1804
1805static int lio_queue_status(struct se_cmd *se_cmd)
1806{
1807 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1808
1809 cmd->i_state = ISTATE_SEND_STATUS;
Nicholas Bellinger5e8e6b42013-11-12 17:54:56 -08001810
1811 if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
1812 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
1813 return 0;
1814 }
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001815 cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd);
1816
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001817 return 0;
1818}
1819
Joern Engelb79fafa2013-07-03 11:22:17 -04001820static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001821{
1822 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1823
1824 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
1825 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001826}
1827
Nicholas Bellinger131e6ab2014-03-22 14:55:56 -07001828static void lio_aborted_task(struct se_cmd *se_cmd)
1829{
1830 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1831
1832 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
1833}
1834
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001835static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
1836{
1837 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1838
1839 return &tpg->tpg_tiqn->tiqn[0];
1840}
1841
1842static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
1843{
1844 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1845
1846 return tpg->tpgt;
1847}
1848
1849static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
1850{
1851 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1852
Andy Groverb7eec2c2013-10-09 11:05:57 -07001853 return tpg->tpg_attrib.default_cmdsn_depth;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001854}
1855
1856static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
1857{
1858 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1859
Andy Groverb7eec2c2013-10-09 11:05:57 -07001860 return tpg->tpg_attrib.generate_node_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001861}
1862
1863static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
1864{
1865 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1866
Andy Groverb7eec2c2013-10-09 11:05:57 -07001867 return tpg->tpg_attrib.cache_dynamic_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001868}
1869
1870static int lio_tpg_check_demo_mode_write_protect(
1871 struct se_portal_group *se_tpg)
1872{
1873 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1874
Andy Groverb7eec2c2013-10-09 11:05:57 -07001875 return tpg->tpg_attrib.demo_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001876}
1877
1878static int lio_tpg_check_prod_mode_write_protect(
1879 struct se_portal_group *se_tpg)
1880{
1881 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1882
Andy Groverb7eec2c2013-10-09 11:05:57 -07001883 return tpg->tpg_attrib.prod_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001884}
1885
Nicholas Bellinger901c04a2015-03-29 19:36:16 -07001886static int lio_tpg_check_prot_fabric_only(
1887 struct se_portal_group *se_tpg)
1888{
1889 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1890 /*
1891 * Only report fabric_prot_type if t10_pi has also been enabled
1892 * for incoming ib_isert sessions.
1893 */
1894 if (!tpg->tpg_attrib.t10_pi)
1895 return 0;
1896
1897 return tpg->tpg_attrib.fabric_prot_type;
1898}
1899
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001900static void lio_tpg_release_fabric_acl(
1901 struct se_portal_group *se_tpg,
1902 struct se_node_acl *se_acl)
1903{
1904 struct iscsi_node_acl *acl = container_of(se_acl,
1905 struct iscsi_node_acl, se_node_acl);
1906 kfree(acl);
1907}
1908
1909/*
1910 * Called with spin_lock_bh(struct se_portal_group->session_lock) held..
1911 *
1912 * Also, this function calls iscsit_inc_session_usage_count() on the
1913 * struct iscsi_session in question.
1914 */
1915static int lio_tpg_shutdown_session(struct se_session *se_sess)
1916{
1917 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1918
1919 spin_lock(&sess->conn_lock);
1920 if (atomic_read(&sess->session_fall_back_to_erl0) ||
1921 atomic_read(&sess->session_logout) ||
1922 (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
1923 spin_unlock(&sess->conn_lock);
1924 return 0;
1925 }
1926 atomic_set(&sess->session_reinstatement, 1);
1927 spin_unlock(&sess->conn_lock);
1928
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001929 iscsit_stop_time2retain_timer(sess);
Nicholas Bellinger99367f02012-02-27 01:43:32 -08001930 iscsit_stop_session(sess, 1, 1);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001931
1932 return 1;
1933}
1934
1935/*
1936 * Calls iscsit_dec_session_usage_count() as inverse of
1937 * lio_tpg_shutdown_session()
1938 */
1939static void lio_tpg_close_session(struct se_session *se_sess)
1940{
1941 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1942 /*
1943 * If the iSCSI Session for the iSCSI Initiator Node exists,
1944 * forcefully shutdown the iSCSI NEXUS.
1945 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001946 iscsit_close_session(sess);
1947}
1948
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001949static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
1950{
1951 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1952
1953 return tpg->tpg_tiqn->tiqn_index;
1954}
1955
1956static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
1957{
1958 struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
1959 se_node_acl);
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001960 struct se_portal_group *se_tpg = se_acl->se_tpg;
1961 struct iscsi_portal_group *tpg = container_of(se_tpg,
1962 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001963
Andy Groverb7eec2c2013-10-09 11:05:57 -07001964 acl->node_attrib.nacl = acl;
Nicholas Bellingerd1fa7a12013-11-20 11:57:18 -08001965 iscsit_set_default_node_attribues(acl, tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001966}
1967
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001968static int lio_check_stop_free(struct se_cmd *se_cmd)
1969{
Bart Van Asscheafc16602015-04-27 13:52:36 +02001970 return target_put_sess_cmd(se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001971}
1972
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001973static void lio_release_cmd(struct se_cmd *se_cmd)
1974{
1975 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1976
Nicholas Bellingercdb72662013-03-06 22:09:17 -08001977 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
Nicholas Bellingerd703ce22013-08-17 14:27:56 -07001978 iscsit_release_cmd(cmd);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001979}
1980
Christoph Hellwig9ac89282015-04-08 20:01:35 +02001981const struct target_core_fabric_ops iscsi_ops = {
1982 .module = THIS_MODULE,
1983 .name = "iscsi",
1984 .get_fabric_name = iscsi_get_fabric_name,
1985 .get_fabric_proto_ident = iscsi_get_fabric_proto_ident,
1986 .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
1987 .tpg_get_tag = lio_tpg_get_tag,
1988 .tpg_get_default_depth = lio_tpg_get_default_depth,
1989 .tpg_get_pr_transport_id = iscsi_get_pr_transport_id,
1990 .tpg_get_pr_transport_id_len = iscsi_get_pr_transport_id_len,
1991 .tpg_parse_pr_out_transport_id = iscsi_parse_pr_out_transport_id,
1992 .tpg_check_demo_mode = lio_tpg_check_demo_mode,
1993 .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache,
1994 .tpg_check_demo_mode_write_protect =
1995 lio_tpg_check_demo_mode_write_protect,
1996 .tpg_check_prod_mode_write_protect =
1997 lio_tpg_check_prod_mode_write_protect,
1998 .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
1999 .tpg_alloc_fabric_acl = lio_tpg_alloc_fabric_acl,
2000 .tpg_release_fabric_acl = lio_tpg_release_fabric_acl,
2001 .tpg_get_inst_index = lio_tpg_get_inst_index,
2002 .check_stop_free = lio_check_stop_free,
2003 .release_cmd = lio_release_cmd,
2004 .shutdown_session = lio_tpg_shutdown_session,
2005 .close_session = lio_tpg_close_session,
2006 .sess_get_index = lio_sess_get_index,
2007 .sess_get_initiator_sid = lio_sess_get_initiator_sid,
2008 .write_pending = lio_write_pending,
2009 .write_pending_status = lio_write_pending_status,
2010 .set_default_node_attributes = lio_set_default_node_attributes,
2011 .get_task_tag = iscsi_get_task_tag,
2012 .get_cmd_state = iscsi_get_cmd_state,
2013 .queue_data_in = lio_queue_data_in,
2014 .queue_status = lio_queue_status,
2015 .queue_tm_rsp = lio_queue_tm_rsp,
2016 .aborted_task = lio_aborted_task,
2017 .fabric_make_wwn = lio_target_call_coreaddtiqn,
2018 .fabric_drop_wwn = lio_target_call_coredeltiqn,
2019 .fabric_make_tpg = lio_target_tiqn_addtpg,
2020 .fabric_drop_tpg = lio_target_tiqn_deltpg,
2021 .fabric_make_np = lio_target_call_addnptotpg,
2022 .fabric_drop_np = lio_target_call_delnpfromtpg,
2023 .fabric_make_nodeacl = lio_target_make_nodeacl,
2024 .fabric_drop_nodeacl = lio_target_drop_nodeacl,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00002025
Christoph Hellwig9ac89282015-04-08 20:01:35 +02002026 .tfc_discovery_attrs = lio_target_discovery_auth_attrs,
2027 .tfc_wwn_attrs = lio_target_wwn_attrs,
2028 .tfc_tpg_base_attrs = lio_target_tpg_attrs,
2029 .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs,
2030 .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs,
2031 .tfc_tpg_param_attrs = lio_target_tpg_param_attrs,
2032 .tfc_tpg_np_base_attrs = lio_target_portal_attrs,
2033 .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs,
2034 .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
2035 .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
2036 .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
2037};