1e48354ceSNicholas Bellinger /******************************************************************************* 2e48354ceSNicholas Bellinger * This file contains the configfs implementation for iSCSI Target mode 3e48354ceSNicholas Bellinger * from the LIO-Target Project. 4e48354ceSNicholas Bellinger * 54c76251eSNicholas Bellinger * (c) Copyright 2007-2013 Datera, Inc. 6e48354ceSNicholas Bellinger * 7e48354ceSNicholas Bellinger * Author: Nicholas A. Bellinger <nab@linux-iscsi.org> 8e48354ceSNicholas Bellinger * 9e48354ceSNicholas Bellinger * This program is free software; you can redistribute it and/or modify 10e48354ceSNicholas Bellinger * it under the terms of the GNU General Public License as published by 11e48354ceSNicholas Bellinger * the Free Software Foundation; either version 2 of the License, or 12e48354ceSNicholas Bellinger * (at your option) any later version. 13e48354ceSNicholas Bellinger * 14e48354ceSNicholas Bellinger * This program is distributed in the hope that it will be useful, 15e48354ceSNicholas Bellinger * but WITHOUT ANY WARRANTY; without even the implied warranty of 16e48354ceSNicholas Bellinger * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17e48354ceSNicholas Bellinger * GNU General Public License for more details. 18e48354ceSNicholas Bellinger ****************************************************************************/ 19e48354ceSNicholas Bellinger 20e48354ceSNicholas Bellinger #include <linux/configfs.h> 21ad7babd2SJörn Engel #include <linux/ctype.h> 22c53181afSPaul Gortmaker #include <linux/export.h> 23c3bc93daSStephen Rothwell #include <linux/inet.h> 24e48354ceSNicholas Bellinger #include <target/target_core_base.h> 25c4795fb2SChristoph Hellwig #include <target/target_core_fabric.h> 26e48354ceSNicholas Bellinger #include <target/target_core_fabric_configfs.h> 27e48354ceSNicholas Bellinger #include <target/configfs_macros.h> 282ec5a8c1SNicholas Bellinger #include <target/iscsi/iscsi_transport.h> 29e48354ceSNicholas Bellinger 3067f091f2SSagi Grimberg #include <target/iscsi/iscsi_target_core.h> 31e48354ceSNicholas Bellinger #include "iscsi_target_parameters.h" 32e48354ceSNicholas Bellinger #include "iscsi_target_device.h" 33e48354ceSNicholas Bellinger #include "iscsi_target_erl0.h" 34e48354ceSNicholas Bellinger #include "iscsi_target_nodeattrib.h" 35e48354ceSNicholas Bellinger #include "iscsi_target_tpg.h" 36e48354ceSNicholas Bellinger #include "iscsi_target_util.h" 37e48354ceSNicholas Bellinger #include "iscsi_target.h" 3867f091f2SSagi Grimberg #include <target/iscsi/iscsi_target_stat.h> 39e48354ceSNicholas Bellinger 40e48354ceSNicholas Bellinger struct lio_target_configfs_attribute { 41e48354ceSNicholas Bellinger struct configfs_attribute attr; 42e48354ceSNicholas Bellinger ssize_t (*show)(void *, char *); 43e48354ceSNicholas Bellinger ssize_t (*store)(void *, const char *, size_t); 44e48354ceSNicholas Bellinger }; 45e48354ceSNicholas Bellinger 46e48354ceSNicholas Bellinger /* Start items for lio_target_portal_cit */ 47e48354ceSNicholas Bellinger 48e48354ceSNicholas Bellinger static ssize_t lio_target_np_show_sctp( 49e48354ceSNicholas Bellinger struct se_tpg_np *se_tpg_np, 50e48354ceSNicholas Bellinger char *page) 51e48354ceSNicholas Bellinger { 52e48354ceSNicholas Bellinger struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 53e48354ceSNicholas Bellinger struct iscsi_tpg_np, se_tpg_np); 54e48354ceSNicholas Bellinger struct iscsi_tpg_np *tpg_np_sctp; 55e48354ceSNicholas Bellinger ssize_t rb; 56e48354ceSNicholas Bellinger 57e48354ceSNicholas Bellinger tpg_np_sctp = iscsit_tpg_locate_child_np(tpg_np, ISCSI_SCTP_TCP); 58e48354ceSNicholas Bellinger if (tpg_np_sctp) 59e48354ceSNicholas Bellinger rb = sprintf(page, "1\n"); 60e48354ceSNicholas Bellinger else 61e48354ceSNicholas Bellinger rb = sprintf(page, "0\n"); 62e48354ceSNicholas Bellinger 63e48354ceSNicholas Bellinger return rb; 64e48354ceSNicholas Bellinger } 65e48354ceSNicholas Bellinger 66e48354ceSNicholas Bellinger static ssize_t lio_target_np_store_sctp( 67e48354ceSNicholas Bellinger struct se_tpg_np *se_tpg_np, 68e48354ceSNicholas Bellinger const char *page, 69e48354ceSNicholas Bellinger size_t count) 70e48354ceSNicholas Bellinger { 71e48354ceSNicholas Bellinger struct iscsi_np *np; 72e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg; 73e48354ceSNicholas Bellinger struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 74e48354ceSNicholas Bellinger struct iscsi_tpg_np, se_tpg_np); 75e48354ceSNicholas Bellinger struct iscsi_tpg_np *tpg_np_sctp = NULL; 76e48354ceSNicholas Bellinger u32 op; 77e48354ceSNicholas Bellinger int ret; 78e48354ceSNicholas Bellinger 79ad7babd2SJörn Engel ret = kstrtou32(page, 0, &op); 80ad7babd2SJörn Engel if (ret) 81ad7babd2SJörn Engel return ret; 82e48354ceSNicholas Bellinger if ((op != 1) && (op != 0)) { 83e48354ceSNicholas Bellinger pr_err("Illegal value for tpg_enable: %u\n", op); 84e48354ceSNicholas Bellinger return -EINVAL; 85e48354ceSNicholas Bellinger } 86e48354ceSNicholas Bellinger np = tpg_np->tpg_np; 87e48354ceSNicholas Bellinger if (!np) { 88e48354ceSNicholas Bellinger pr_err("Unable to locate struct iscsi_np from" 89e48354ceSNicholas Bellinger " struct iscsi_tpg_np\n"); 90e48354ceSNicholas Bellinger return -EINVAL; 91e48354ceSNicholas Bellinger } 92e48354ceSNicholas Bellinger 93e48354ceSNicholas Bellinger tpg = tpg_np->tpg; 94e48354ceSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) 95e48354ceSNicholas Bellinger return -EINVAL; 96e48354ceSNicholas Bellinger 97e48354ceSNicholas Bellinger if (op) { 98e48354ceSNicholas Bellinger /* 99e48354ceSNicholas Bellinger * Use existing np->np_sockaddr for SCTP network portal reference 100e48354ceSNicholas Bellinger */ 101e48354ceSNicholas Bellinger tpg_np_sctp = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr, 102e48354ceSNicholas Bellinger np->np_ip, tpg_np, ISCSI_SCTP_TCP); 103e48354ceSNicholas Bellinger if (!tpg_np_sctp || IS_ERR(tpg_np_sctp)) 104e48354ceSNicholas Bellinger goto out; 105e48354ceSNicholas Bellinger } else { 106e48354ceSNicholas Bellinger tpg_np_sctp = iscsit_tpg_locate_child_np(tpg_np, ISCSI_SCTP_TCP); 107e48354ceSNicholas Bellinger if (!tpg_np_sctp) 108e48354ceSNicholas Bellinger goto out; 109e48354ceSNicholas Bellinger 110e48354ceSNicholas Bellinger ret = iscsit_tpg_del_network_portal(tpg, tpg_np_sctp); 111e48354ceSNicholas Bellinger if (ret < 0) 112e48354ceSNicholas Bellinger goto out; 113e48354ceSNicholas Bellinger } 114e48354ceSNicholas Bellinger 115e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 116e48354ceSNicholas Bellinger return count; 117e48354ceSNicholas Bellinger out: 118e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 119e48354ceSNicholas Bellinger return -EINVAL; 120e48354ceSNicholas Bellinger } 121e48354ceSNicholas Bellinger 122e48354ceSNicholas Bellinger TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR); 123e48354ceSNicholas Bellinger 12472438cddSNicholas Bellinger static ssize_t lio_target_np_show_iser( 12572438cddSNicholas Bellinger struct se_tpg_np *se_tpg_np, 12672438cddSNicholas Bellinger char *page) 12772438cddSNicholas Bellinger { 12872438cddSNicholas Bellinger struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 12972438cddSNicholas Bellinger struct iscsi_tpg_np, se_tpg_np); 13072438cddSNicholas Bellinger struct iscsi_tpg_np *tpg_np_iser; 13172438cddSNicholas Bellinger ssize_t rb; 13272438cddSNicholas Bellinger 13372438cddSNicholas Bellinger tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND); 13472438cddSNicholas Bellinger if (tpg_np_iser) 13572438cddSNicholas Bellinger rb = sprintf(page, "1\n"); 13672438cddSNicholas Bellinger else 13772438cddSNicholas Bellinger rb = sprintf(page, "0\n"); 13872438cddSNicholas Bellinger 13972438cddSNicholas Bellinger return rb; 14072438cddSNicholas Bellinger } 14172438cddSNicholas Bellinger 14272438cddSNicholas Bellinger static ssize_t lio_target_np_store_iser( 14372438cddSNicholas Bellinger struct se_tpg_np *se_tpg_np, 14472438cddSNicholas Bellinger const char *page, 14572438cddSNicholas Bellinger size_t count) 14672438cddSNicholas Bellinger { 14772438cddSNicholas Bellinger struct iscsi_np *np; 14872438cddSNicholas Bellinger struct iscsi_portal_group *tpg; 14972438cddSNicholas Bellinger struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 15072438cddSNicholas Bellinger struct iscsi_tpg_np, se_tpg_np); 15172438cddSNicholas Bellinger struct iscsi_tpg_np *tpg_np_iser = NULL; 15272438cddSNicholas Bellinger char *endptr; 15372438cddSNicholas Bellinger u32 op; 15458bd0c69SAndy Grover int rc = 0; 15572438cddSNicholas Bellinger 15672438cddSNicholas Bellinger op = simple_strtoul(page, &endptr, 0); 15772438cddSNicholas Bellinger if ((op != 1) && (op != 0)) { 15872438cddSNicholas Bellinger pr_err("Illegal value for tpg_enable: %u\n", op); 15972438cddSNicholas Bellinger return -EINVAL; 16072438cddSNicholas Bellinger } 16172438cddSNicholas Bellinger np = tpg_np->tpg_np; 16272438cddSNicholas Bellinger if (!np) { 16372438cddSNicholas Bellinger pr_err("Unable to locate struct iscsi_np from" 16472438cddSNicholas Bellinger " struct iscsi_tpg_np\n"); 16572438cddSNicholas Bellinger return -EINVAL; 16672438cddSNicholas Bellinger } 16772438cddSNicholas Bellinger 16872438cddSNicholas Bellinger tpg = tpg_np->tpg; 16972438cddSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) 17072438cddSNicholas Bellinger return -EINVAL; 17172438cddSNicholas Bellinger 17272438cddSNicholas Bellinger if (op) { 17358bd0c69SAndy Grover rc = request_module("ib_isert"); 17458bd0c69SAndy Grover if (rc != 0) { 17572438cddSNicholas Bellinger pr_warn("Unable to request_module for ib_isert\n"); 17658bd0c69SAndy Grover rc = 0; 17758bd0c69SAndy Grover } 17872438cddSNicholas Bellinger 17972438cddSNicholas Bellinger tpg_np_iser = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr, 18072438cddSNicholas Bellinger np->np_ip, tpg_np, ISCSI_INFINIBAND); 18158bd0c69SAndy Grover if (IS_ERR(tpg_np_iser)) { 18258bd0c69SAndy Grover rc = PTR_ERR(tpg_np_iser); 18372438cddSNicholas Bellinger goto out; 18458bd0c69SAndy Grover } 18572438cddSNicholas Bellinger } else { 18672438cddSNicholas Bellinger tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND); 18758bd0c69SAndy Grover if (tpg_np_iser) { 18872438cddSNicholas Bellinger rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser); 18972438cddSNicholas Bellinger if (rc < 0) 19072438cddSNicholas Bellinger goto out; 19172438cddSNicholas Bellinger } 19258bd0c69SAndy Grover } 19372438cddSNicholas Bellinger 19472438cddSNicholas Bellinger iscsit_put_tpg(tpg); 19572438cddSNicholas Bellinger return count; 19672438cddSNicholas Bellinger out: 19772438cddSNicholas Bellinger iscsit_put_tpg(tpg); 19858bd0c69SAndy Grover return rc; 19972438cddSNicholas Bellinger } 20072438cddSNicholas Bellinger 20172438cddSNicholas Bellinger TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR); 20272438cddSNicholas Bellinger 203e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_portal_attrs[] = { 204e48354ceSNicholas Bellinger &lio_target_np_sctp.attr, 20572438cddSNicholas Bellinger &lio_target_np_iser.attr, 206e48354ceSNicholas Bellinger NULL, 207e48354ceSNicholas Bellinger }; 208e48354ceSNicholas Bellinger 209e48354ceSNicholas Bellinger /* Stop items for lio_target_portal_cit */ 210e48354ceSNicholas Bellinger 211e48354ceSNicholas Bellinger /* Start items for lio_target_np_cit */ 212e48354ceSNicholas Bellinger 213e48354ceSNicholas Bellinger #define MAX_PORTAL_LEN 256 214e48354ceSNicholas Bellinger 215fceb5bc7SChristoph Hellwig static struct se_tpg_np *lio_target_call_addnptotpg( 216e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, 217e48354ceSNicholas Bellinger struct config_group *group, 218e48354ceSNicholas Bellinger const char *name) 219e48354ceSNicholas Bellinger { 220e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg; 221e48354ceSNicholas Bellinger struct iscsi_tpg_np *tpg_np; 222e48354ceSNicholas Bellinger char *str, *str2, *ip_str, *port_str; 223e48354ceSNicholas Bellinger struct __kernel_sockaddr_storage sockaddr; 224e48354ceSNicholas Bellinger struct sockaddr_in *sock_in; 225e48354ceSNicholas Bellinger struct sockaddr_in6 *sock_in6; 226e48354ceSNicholas Bellinger unsigned long port; 227e48354ceSNicholas Bellinger int ret; 228e48354ceSNicholas Bellinger char buf[MAX_PORTAL_LEN + 1]; 229e48354ceSNicholas Bellinger 230e48354ceSNicholas Bellinger if (strlen(name) > MAX_PORTAL_LEN) { 231e48354ceSNicholas Bellinger pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n", 232e48354ceSNicholas Bellinger (int)strlen(name), MAX_PORTAL_LEN); 233e48354ceSNicholas Bellinger return ERR_PTR(-EOVERFLOW); 234e48354ceSNicholas Bellinger } 235e48354ceSNicholas Bellinger memset(buf, 0, MAX_PORTAL_LEN + 1); 2367bbb654eSNicholas Bellinger snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name); 237e48354ceSNicholas Bellinger 238e48354ceSNicholas Bellinger memset(&sockaddr, 0, sizeof(struct __kernel_sockaddr_storage)); 239e48354ceSNicholas Bellinger 240e48354ceSNicholas Bellinger str = strstr(buf, "["); 241e48354ceSNicholas Bellinger if (str) { 242e48354ceSNicholas Bellinger const char *end; 243e48354ceSNicholas Bellinger 244e48354ceSNicholas Bellinger str2 = strstr(str, "]"); 245e48354ceSNicholas Bellinger if (!str2) { 246e48354ceSNicholas Bellinger pr_err("Unable to locate trailing \"]\"" 247e48354ceSNicholas Bellinger " in IPv6 iSCSI network portal address\n"); 248e48354ceSNicholas Bellinger return ERR_PTR(-EINVAL); 249e48354ceSNicholas Bellinger } 250e48354ceSNicholas Bellinger str++; /* Skip over leading "[" */ 251e48354ceSNicholas Bellinger *str2 = '\0'; /* Terminate the IPv6 address */ 252e48354ceSNicholas Bellinger str2++; /* Skip over the "]" */ 253e48354ceSNicholas Bellinger port_str = strstr(str2, ":"); 254e48354ceSNicholas Bellinger if (!port_str) { 255e48354ceSNicholas Bellinger pr_err("Unable to locate \":port\"" 256e48354ceSNicholas Bellinger " in IPv6 iSCSI network portal address\n"); 257e48354ceSNicholas Bellinger return ERR_PTR(-EINVAL); 258e48354ceSNicholas Bellinger } 259e48354ceSNicholas Bellinger *port_str = '\0'; /* Terminate string for IP */ 260e48354ceSNicholas Bellinger port_str++; /* Skip over ":" */ 261e48354ceSNicholas Bellinger 26257103d7fSJingoo Han ret = kstrtoul(port_str, 0, &port); 263e48354ceSNicholas Bellinger if (ret < 0) { 26457103d7fSJingoo Han pr_err("kstrtoul() failed for port_str: %d\n", ret); 265e48354ceSNicholas Bellinger return ERR_PTR(ret); 266e48354ceSNicholas Bellinger } 267e48354ceSNicholas Bellinger sock_in6 = (struct sockaddr_in6 *)&sockaddr; 268e48354ceSNicholas Bellinger sock_in6->sin6_family = AF_INET6; 269e48354ceSNicholas Bellinger sock_in6->sin6_port = htons((unsigned short)port); 270e48354ceSNicholas Bellinger ret = in6_pton(str, IPV6_ADDRESS_SPACE, 271e48354ceSNicholas Bellinger (void *)&sock_in6->sin6_addr.in6_u, -1, &end); 272e48354ceSNicholas Bellinger if (ret <= 0) { 273e48354ceSNicholas Bellinger pr_err("in6_pton returned: %d\n", ret); 274e48354ceSNicholas Bellinger return ERR_PTR(-EINVAL); 275e48354ceSNicholas Bellinger } 276e48354ceSNicholas Bellinger } else { 277e48354ceSNicholas Bellinger str = ip_str = &buf[0]; 278e48354ceSNicholas Bellinger port_str = strstr(ip_str, ":"); 279e48354ceSNicholas Bellinger if (!port_str) { 280e48354ceSNicholas Bellinger pr_err("Unable to locate \":port\"" 281e48354ceSNicholas Bellinger " in IPv4 iSCSI network portal address\n"); 282e48354ceSNicholas Bellinger return ERR_PTR(-EINVAL); 283e48354ceSNicholas Bellinger } 284e48354ceSNicholas Bellinger *port_str = '\0'; /* Terminate string for IP */ 285e48354ceSNicholas Bellinger port_str++; /* Skip over ":" */ 286e48354ceSNicholas Bellinger 28757103d7fSJingoo Han ret = kstrtoul(port_str, 0, &port); 288e48354ceSNicholas Bellinger if (ret < 0) { 28957103d7fSJingoo Han pr_err("kstrtoul() failed for port_str: %d\n", ret); 290e48354ceSNicholas Bellinger return ERR_PTR(ret); 291e48354ceSNicholas Bellinger } 292e48354ceSNicholas Bellinger sock_in = (struct sockaddr_in *)&sockaddr; 293e48354ceSNicholas Bellinger sock_in->sin_family = AF_INET; 294e48354ceSNicholas Bellinger sock_in->sin_port = htons((unsigned short)port); 295e48354ceSNicholas Bellinger sock_in->sin_addr.s_addr = in_aton(ip_str); 296e48354ceSNicholas Bellinger } 297e48354ceSNicholas Bellinger tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg); 298e48354ceSNicholas Bellinger ret = iscsit_get_tpg(tpg); 299e48354ceSNicholas Bellinger if (ret < 0) 300e48354ceSNicholas Bellinger return ERR_PTR(-EINVAL); 301e48354ceSNicholas Bellinger 302e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu" 303e48354ceSNicholas Bellinger " PORTAL: %s\n", 304e48354ceSNicholas Bellinger config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item), 305e48354ceSNicholas Bellinger tpg->tpgt, name); 306e48354ceSNicholas Bellinger /* 307e48354ceSNicholas Bellinger * Assume ISCSI_TCP by default. Other network portals for other 308e48354ceSNicholas Bellinger * iSCSI fabrics: 309e48354ceSNicholas Bellinger * 310e48354ceSNicholas Bellinger * Traditional iSCSI over SCTP (initial support) 311e48354ceSNicholas Bellinger * iSER/TCP (TODO, hardware available) 312e48354ceSNicholas Bellinger * iSER/SCTP (TODO, software emulation with osc-iwarp) 313e48354ceSNicholas Bellinger * iSER/IB (TODO, hardware available) 314e48354ceSNicholas Bellinger * 31520879696SMasanari Iida * can be enabled with attributes under 316e48354ceSNicholas Bellinger * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/ 317e48354ceSNicholas Bellinger * 318e48354ceSNicholas Bellinger */ 319e48354ceSNicholas Bellinger tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, str, NULL, 320e48354ceSNicholas Bellinger ISCSI_TCP); 321e48354ceSNicholas Bellinger if (IS_ERR(tpg_np)) { 322e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 323e1750ba2SThomas Meyer return ERR_CAST(tpg_np); 324e48354ceSNicholas Bellinger } 325e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n"); 326e48354ceSNicholas Bellinger 327e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 328e48354ceSNicholas Bellinger return &tpg_np->se_tpg_np; 329e48354ceSNicholas Bellinger } 330e48354ceSNicholas Bellinger 331e48354ceSNicholas Bellinger static void lio_target_call_delnpfromtpg( 332e48354ceSNicholas Bellinger struct se_tpg_np *se_tpg_np) 333e48354ceSNicholas Bellinger { 334e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg; 335e48354ceSNicholas Bellinger struct iscsi_tpg_np *tpg_np; 336e48354ceSNicholas Bellinger struct se_portal_group *se_tpg; 337e48354ceSNicholas Bellinger int ret; 338e48354ceSNicholas Bellinger 339e48354ceSNicholas Bellinger tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np); 340e48354ceSNicholas Bellinger tpg = tpg_np->tpg; 341e48354ceSNicholas Bellinger ret = iscsit_get_tpg(tpg); 342e48354ceSNicholas Bellinger if (ret < 0) 343e48354ceSNicholas Bellinger return; 344e48354ceSNicholas Bellinger 345e48354ceSNicholas Bellinger se_tpg = &tpg->tpg_se_tpg; 346e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu" 347e48354ceSNicholas Bellinger " PORTAL: %s:%hu\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item), 348e48354ceSNicholas Bellinger tpg->tpgt, tpg_np->tpg_np->np_ip, tpg_np->tpg_np->np_port); 349e48354ceSNicholas Bellinger 350e48354ceSNicholas Bellinger ret = iscsit_tpg_del_network_portal(tpg, tpg_np); 351e48354ceSNicholas Bellinger if (ret < 0) 352e48354ceSNicholas Bellinger goto out; 353e48354ceSNicholas Bellinger 354e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n"); 355e48354ceSNicholas Bellinger out: 356e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 357e48354ceSNicholas Bellinger } 358e48354ceSNicholas Bellinger 359e48354ceSNicholas Bellinger /* End items for lio_target_np_cit */ 360e48354ceSNicholas Bellinger 361e48354ceSNicholas Bellinger /* Start items for lio_target_nacl_attrib_cit */ 362e48354ceSNicholas Bellinger 363e48354ceSNicholas Bellinger #define DEF_NACL_ATTRIB(name) \ 364e48354ceSNicholas Bellinger static ssize_t iscsi_nacl_attrib_show_##name( \ 365e48354ceSNicholas Bellinger struct se_node_acl *se_nacl, \ 366e48354ceSNicholas Bellinger char *page) \ 367e48354ceSNicholas Bellinger { \ 368e48354ceSNicholas Bellinger struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ 369e48354ceSNicholas Bellinger se_node_acl); \ 370e48354ceSNicholas Bellinger \ 371b7eec2cdSAndy Grover return sprintf(page, "%u\n", nacl->node_attrib.name); \ 372e48354ceSNicholas Bellinger } \ 373e48354ceSNicholas Bellinger \ 374e48354ceSNicholas Bellinger static ssize_t iscsi_nacl_attrib_store_##name( \ 375e48354ceSNicholas Bellinger struct se_node_acl *se_nacl, \ 376e48354ceSNicholas Bellinger const char *page, \ 377e48354ceSNicholas Bellinger size_t count) \ 378e48354ceSNicholas Bellinger { \ 379e48354ceSNicholas Bellinger struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ 380e48354ceSNicholas Bellinger se_node_acl); \ 381e48354ceSNicholas Bellinger u32 val; \ 382e48354ceSNicholas Bellinger int ret; \ 383e48354ceSNicholas Bellinger \ 384ad7babd2SJörn Engel ret = kstrtou32(page, 0, &val); \ 385ad7babd2SJörn Engel if (ret) \ 386ad7babd2SJörn Engel return ret; \ 387e48354ceSNicholas Bellinger ret = iscsit_na_##name(nacl, val); \ 388e48354ceSNicholas Bellinger if (ret < 0) \ 389e48354ceSNicholas Bellinger return ret; \ 390e48354ceSNicholas Bellinger \ 391e48354ceSNicholas Bellinger return count; \ 392e48354ceSNicholas Bellinger } 393e48354ceSNicholas Bellinger 394e48354ceSNicholas Bellinger #define NACL_ATTR(_name, _mode) TF_NACL_ATTRIB_ATTR(iscsi, _name, _mode); 395e48354ceSNicholas Bellinger /* 396e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_dataout_timeout 397e48354ceSNicholas Bellinger */ 398e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(dataout_timeout); 399e48354ceSNicholas Bellinger NACL_ATTR(dataout_timeout, S_IRUGO | S_IWUSR); 400e48354ceSNicholas Bellinger /* 401e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_dataout_timeout_retries 402e48354ceSNicholas Bellinger */ 403e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(dataout_timeout_retries); 404e48354ceSNicholas Bellinger NACL_ATTR(dataout_timeout_retries, S_IRUGO | S_IWUSR); 405e48354ceSNicholas Bellinger /* 406e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_default_erl 407e48354ceSNicholas Bellinger */ 408e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(default_erl); 409e48354ceSNicholas Bellinger NACL_ATTR(default_erl, S_IRUGO | S_IWUSR); 410e48354ceSNicholas Bellinger /* 411e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_nopin_timeout 412e48354ceSNicholas Bellinger */ 413e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(nopin_timeout); 414e48354ceSNicholas Bellinger NACL_ATTR(nopin_timeout, S_IRUGO | S_IWUSR); 415e48354ceSNicholas Bellinger /* 416e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_nopin_response_timeout 417e48354ceSNicholas Bellinger */ 418e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(nopin_response_timeout); 419e48354ceSNicholas Bellinger NACL_ATTR(nopin_response_timeout, S_IRUGO | S_IWUSR); 420e48354ceSNicholas Bellinger /* 421e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_random_datain_pdu_offsets 422e48354ceSNicholas Bellinger */ 423e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(random_datain_pdu_offsets); 424e48354ceSNicholas Bellinger NACL_ATTR(random_datain_pdu_offsets, S_IRUGO | S_IWUSR); 425e48354ceSNicholas Bellinger /* 426e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_random_datain_seq_offsets 427e48354ceSNicholas Bellinger */ 428e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(random_datain_seq_offsets); 429e48354ceSNicholas Bellinger NACL_ATTR(random_datain_seq_offsets, S_IRUGO | S_IWUSR); 430e48354ceSNicholas Bellinger /* 431e48354ceSNicholas Bellinger * Define iscsi_node_attrib_s_random_r2t_offsets 432e48354ceSNicholas Bellinger */ 433e48354ceSNicholas Bellinger DEF_NACL_ATTRIB(random_r2t_offsets); 434e48354ceSNicholas Bellinger NACL_ATTR(random_r2t_offsets, S_IRUGO | S_IWUSR); 435e48354ceSNicholas Bellinger 436e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = { 437e48354ceSNicholas Bellinger &iscsi_nacl_attrib_dataout_timeout.attr, 438e48354ceSNicholas Bellinger &iscsi_nacl_attrib_dataout_timeout_retries.attr, 439e48354ceSNicholas Bellinger &iscsi_nacl_attrib_default_erl.attr, 440e48354ceSNicholas Bellinger &iscsi_nacl_attrib_nopin_timeout.attr, 441e48354ceSNicholas Bellinger &iscsi_nacl_attrib_nopin_response_timeout.attr, 442e48354ceSNicholas Bellinger &iscsi_nacl_attrib_random_datain_pdu_offsets.attr, 443e48354ceSNicholas Bellinger &iscsi_nacl_attrib_random_datain_seq_offsets.attr, 444e48354ceSNicholas Bellinger &iscsi_nacl_attrib_random_r2t_offsets.attr, 445e48354ceSNicholas Bellinger NULL, 446e48354ceSNicholas Bellinger }; 447e48354ceSNicholas Bellinger 448e48354ceSNicholas Bellinger /* End items for lio_target_nacl_attrib_cit */ 449e48354ceSNicholas Bellinger 450e48354ceSNicholas Bellinger /* Start items for lio_target_nacl_auth_cit */ 451e48354ceSNicholas Bellinger 452e48354ceSNicholas Bellinger #define __DEF_NACL_AUTH_STR(prefix, name, flags) \ 453e48354ceSNicholas Bellinger static ssize_t __iscsi_##prefix##_show_##name( \ 454e48354ceSNicholas Bellinger struct iscsi_node_acl *nacl, \ 455e48354ceSNicholas Bellinger char *page) \ 456e48354ceSNicholas Bellinger { \ 457e48354ceSNicholas Bellinger struct iscsi_node_auth *auth = &nacl->node_auth; \ 458e48354ceSNicholas Bellinger \ 459e48354ceSNicholas Bellinger if (!capable(CAP_SYS_ADMIN)) \ 460e48354ceSNicholas Bellinger return -EPERM; \ 461e48354ceSNicholas Bellinger return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ 462e48354ceSNicholas Bellinger } \ 463e48354ceSNicholas Bellinger \ 464e48354ceSNicholas Bellinger static ssize_t __iscsi_##prefix##_store_##name( \ 465e48354ceSNicholas Bellinger struct iscsi_node_acl *nacl, \ 466e48354ceSNicholas Bellinger const char *page, \ 467e48354ceSNicholas Bellinger size_t count) \ 468e48354ceSNicholas Bellinger { \ 469e48354ceSNicholas Bellinger struct iscsi_node_auth *auth = &nacl->node_auth; \ 470e48354ceSNicholas Bellinger \ 471e48354ceSNicholas Bellinger if (!capable(CAP_SYS_ADMIN)) \ 472e48354ceSNicholas Bellinger return -EPERM; \ 4732306bfb2SEric Seppanen if (count >= sizeof(auth->name)) \ 4742306bfb2SEric Seppanen return -EINVAL; \ 4750fbfc46fSJörn Engel snprintf(auth->name, sizeof(auth->name), "%s", page); \ 476e48354ceSNicholas Bellinger if (!strncmp("NULL", auth->name, 4)) \ 477e48354ceSNicholas Bellinger auth->naf_flags &= ~flags; \ 478e48354ceSNicholas Bellinger else \ 479e48354ceSNicholas Bellinger auth->naf_flags |= flags; \ 480e48354ceSNicholas Bellinger \ 481e48354ceSNicholas Bellinger if ((auth->naf_flags & NAF_USERID_IN_SET) && \ 482e48354ceSNicholas Bellinger (auth->naf_flags & NAF_PASSWORD_IN_SET)) \ 483e48354ceSNicholas Bellinger auth->authenticate_target = 1; \ 484e48354ceSNicholas Bellinger else \ 485e48354ceSNicholas Bellinger auth->authenticate_target = 0; \ 486e48354ceSNicholas Bellinger \ 487e48354ceSNicholas Bellinger return count; \ 488e48354ceSNicholas Bellinger } 489e48354ceSNicholas Bellinger 490e48354ceSNicholas Bellinger #define __DEF_NACL_AUTH_INT(prefix, name) \ 491e48354ceSNicholas Bellinger static ssize_t __iscsi_##prefix##_show_##name( \ 492e48354ceSNicholas Bellinger struct iscsi_node_acl *nacl, \ 493e48354ceSNicholas Bellinger char *page) \ 494e48354ceSNicholas Bellinger { \ 495e48354ceSNicholas Bellinger struct iscsi_node_auth *auth = &nacl->node_auth; \ 496e48354ceSNicholas Bellinger \ 497e48354ceSNicholas Bellinger if (!capable(CAP_SYS_ADMIN)) \ 498e48354ceSNicholas Bellinger return -EPERM; \ 499e48354ceSNicholas Bellinger \ 500e48354ceSNicholas Bellinger return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ 501e48354ceSNicholas Bellinger } 502e48354ceSNicholas Bellinger 503e48354ceSNicholas Bellinger #define DEF_NACL_AUTH_STR(name, flags) \ 504e48354ceSNicholas Bellinger __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \ 505e48354ceSNicholas Bellinger static ssize_t iscsi_nacl_auth_show_##name( \ 506e48354ceSNicholas Bellinger struct se_node_acl *nacl, \ 507e48354ceSNicholas Bellinger char *page) \ 508e48354ceSNicholas Bellinger { \ 509e48354ceSNicholas Bellinger return __iscsi_nacl_auth_show_##name(container_of(nacl, \ 510e48354ceSNicholas Bellinger struct iscsi_node_acl, se_node_acl), page); \ 511e48354ceSNicholas Bellinger } \ 512e48354ceSNicholas Bellinger static ssize_t iscsi_nacl_auth_store_##name( \ 513e48354ceSNicholas Bellinger struct se_node_acl *nacl, \ 514e48354ceSNicholas Bellinger const char *page, \ 515e48354ceSNicholas Bellinger size_t count) \ 516e48354ceSNicholas Bellinger { \ 517e48354ceSNicholas Bellinger return __iscsi_nacl_auth_store_##name(container_of(nacl, \ 518e48354ceSNicholas Bellinger struct iscsi_node_acl, se_node_acl), page, count); \ 519e48354ceSNicholas Bellinger } 520e48354ceSNicholas Bellinger 521e48354ceSNicholas Bellinger #define DEF_NACL_AUTH_INT(name) \ 522e48354ceSNicholas Bellinger __DEF_NACL_AUTH_INT(nacl_auth, name) \ 523e48354ceSNicholas Bellinger static ssize_t iscsi_nacl_auth_show_##name( \ 524e48354ceSNicholas Bellinger struct se_node_acl *nacl, \ 525e48354ceSNicholas Bellinger char *page) \ 526e48354ceSNicholas Bellinger { \ 527e48354ceSNicholas Bellinger return __iscsi_nacl_auth_show_##name(container_of(nacl, \ 528e48354ceSNicholas Bellinger struct iscsi_node_acl, se_node_acl), page); \ 529e48354ceSNicholas Bellinger } 530e48354ceSNicholas Bellinger 531e48354ceSNicholas Bellinger #define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode); 532e48354ceSNicholas Bellinger #define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name); 533e48354ceSNicholas Bellinger 534e48354ceSNicholas Bellinger /* 535e48354ceSNicholas Bellinger * One-way authentication userid 536e48354ceSNicholas Bellinger */ 537e48354ceSNicholas Bellinger DEF_NACL_AUTH_STR(userid, NAF_USERID_SET); 538e48354ceSNicholas Bellinger AUTH_ATTR(userid, S_IRUGO | S_IWUSR); 539e48354ceSNicholas Bellinger /* 540e48354ceSNicholas Bellinger * One-way authentication password 541e48354ceSNicholas Bellinger */ 542e48354ceSNicholas Bellinger DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET); 543e48354ceSNicholas Bellinger AUTH_ATTR(password, S_IRUGO | S_IWUSR); 544e48354ceSNicholas Bellinger /* 545e48354ceSNicholas Bellinger * Enforce mutual authentication 546e48354ceSNicholas Bellinger */ 547e48354ceSNicholas Bellinger DEF_NACL_AUTH_INT(authenticate_target); 548e48354ceSNicholas Bellinger AUTH_ATTR_RO(authenticate_target); 549e48354ceSNicholas Bellinger /* 550e48354ceSNicholas Bellinger * Mutual authentication userid 551e48354ceSNicholas Bellinger */ 552e48354ceSNicholas Bellinger DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 553e48354ceSNicholas Bellinger AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); 554e48354ceSNicholas Bellinger /* 555e48354ceSNicholas Bellinger * Mutual authentication password 556e48354ceSNicholas Bellinger */ 557e48354ceSNicholas Bellinger DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 558e48354ceSNicholas Bellinger AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); 559e48354ceSNicholas Bellinger 560e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_nacl_auth_attrs[] = { 561e48354ceSNicholas Bellinger &iscsi_nacl_auth_userid.attr, 562e48354ceSNicholas Bellinger &iscsi_nacl_auth_password.attr, 563e48354ceSNicholas Bellinger &iscsi_nacl_auth_authenticate_target.attr, 564e48354ceSNicholas Bellinger &iscsi_nacl_auth_userid_mutual.attr, 565e48354ceSNicholas Bellinger &iscsi_nacl_auth_password_mutual.attr, 566e48354ceSNicholas Bellinger NULL, 567e48354ceSNicholas Bellinger }; 568e48354ceSNicholas Bellinger 569e48354ceSNicholas Bellinger /* End items for lio_target_nacl_auth_cit */ 570e48354ceSNicholas Bellinger 571e48354ceSNicholas Bellinger /* Start items for lio_target_nacl_param_cit */ 572e48354ceSNicholas Bellinger 573e48354ceSNicholas Bellinger #define DEF_NACL_PARAM(name) \ 574e48354ceSNicholas Bellinger static ssize_t iscsi_nacl_param_show_##name( \ 575e48354ceSNicholas Bellinger struct se_node_acl *se_nacl, \ 576e48354ceSNicholas Bellinger char *page) \ 577e48354ceSNicholas Bellinger { \ 578e48354ceSNicholas Bellinger struct iscsi_session *sess; \ 579e48354ceSNicholas Bellinger struct se_session *se_sess; \ 580e48354ceSNicholas Bellinger ssize_t rb; \ 581e48354ceSNicholas Bellinger \ 582e48354ceSNicholas Bellinger spin_lock_bh(&se_nacl->nacl_sess_lock); \ 583e48354ceSNicholas Bellinger se_sess = se_nacl->nacl_sess; \ 584e48354ceSNicholas Bellinger if (!se_sess) { \ 585e48354ceSNicholas Bellinger rb = snprintf(page, PAGE_SIZE, \ 586e48354ceSNicholas Bellinger "No Active iSCSI Session\n"); \ 587e48354ceSNicholas Bellinger } else { \ 588e48354ceSNicholas Bellinger sess = se_sess->fabric_sess_ptr; \ 589e48354ceSNicholas Bellinger rb = snprintf(page, PAGE_SIZE, "%u\n", \ 590e48354ceSNicholas Bellinger (u32)sess->sess_ops->name); \ 591e48354ceSNicholas Bellinger } \ 592e48354ceSNicholas Bellinger spin_unlock_bh(&se_nacl->nacl_sess_lock); \ 593e48354ceSNicholas Bellinger \ 594e48354ceSNicholas Bellinger return rb; \ 595e48354ceSNicholas Bellinger } 596e48354ceSNicholas Bellinger 597e48354ceSNicholas Bellinger #define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name); 598e48354ceSNicholas Bellinger 599e48354ceSNicholas Bellinger DEF_NACL_PARAM(MaxConnections); 600e48354ceSNicholas Bellinger NACL_PARAM_ATTR(MaxConnections); 601e48354ceSNicholas Bellinger 602e48354ceSNicholas Bellinger DEF_NACL_PARAM(InitialR2T); 603e48354ceSNicholas Bellinger NACL_PARAM_ATTR(InitialR2T); 604e48354ceSNicholas Bellinger 605e48354ceSNicholas Bellinger DEF_NACL_PARAM(ImmediateData); 606e48354ceSNicholas Bellinger NACL_PARAM_ATTR(ImmediateData); 607e48354ceSNicholas Bellinger 608e48354ceSNicholas Bellinger DEF_NACL_PARAM(MaxBurstLength); 609e48354ceSNicholas Bellinger NACL_PARAM_ATTR(MaxBurstLength); 610e48354ceSNicholas Bellinger 611e48354ceSNicholas Bellinger DEF_NACL_PARAM(FirstBurstLength); 612e48354ceSNicholas Bellinger NACL_PARAM_ATTR(FirstBurstLength); 613e48354ceSNicholas Bellinger 614e48354ceSNicholas Bellinger DEF_NACL_PARAM(DefaultTime2Wait); 615e48354ceSNicholas Bellinger NACL_PARAM_ATTR(DefaultTime2Wait); 616e48354ceSNicholas Bellinger 617e48354ceSNicholas Bellinger DEF_NACL_PARAM(DefaultTime2Retain); 618e48354ceSNicholas Bellinger NACL_PARAM_ATTR(DefaultTime2Retain); 619e48354ceSNicholas Bellinger 620e48354ceSNicholas Bellinger DEF_NACL_PARAM(MaxOutstandingR2T); 621e48354ceSNicholas Bellinger NACL_PARAM_ATTR(MaxOutstandingR2T); 622e48354ceSNicholas Bellinger 623e48354ceSNicholas Bellinger DEF_NACL_PARAM(DataPDUInOrder); 624e48354ceSNicholas Bellinger NACL_PARAM_ATTR(DataPDUInOrder); 625e48354ceSNicholas Bellinger 626e48354ceSNicholas Bellinger DEF_NACL_PARAM(DataSequenceInOrder); 627e48354ceSNicholas Bellinger NACL_PARAM_ATTR(DataSequenceInOrder); 628e48354ceSNicholas Bellinger 629e48354ceSNicholas Bellinger DEF_NACL_PARAM(ErrorRecoveryLevel); 630e48354ceSNicholas Bellinger NACL_PARAM_ATTR(ErrorRecoveryLevel); 631e48354ceSNicholas Bellinger 632e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_nacl_param_attrs[] = { 633e48354ceSNicholas Bellinger &iscsi_nacl_param_MaxConnections.attr, 634e48354ceSNicholas Bellinger &iscsi_nacl_param_InitialR2T.attr, 635e48354ceSNicholas Bellinger &iscsi_nacl_param_ImmediateData.attr, 636e48354ceSNicholas Bellinger &iscsi_nacl_param_MaxBurstLength.attr, 637e48354ceSNicholas Bellinger &iscsi_nacl_param_FirstBurstLength.attr, 638e48354ceSNicholas Bellinger &iscsi_nacl_param_DefaultTime2Wait.attr, 639e48354ceSNicholas Bellinger &iscsi_nacl_param_DefaultTime2Retain.attr, 640e48354ceSNicholas Bellinger &iscsi_nacl_param_MaxOutstandingR2T.attr, 641e48354ceSNicholas Bellinger &iscsi_nacl_param_DataPDUInOrder.attr, 642e48354ceSNicholas Bellinger &iscsi_nacl_param_DataSequenceInOrder.attr, 643e48354ceSNicholas Bellinger &iscsi_nacl_param_ErrorRecoveryLevel.attr, 644e48354ceSNicholas Bellinger NULL, 645e48354ceSNicholas Bellinger }; 646e48354ceSNicholas Bellinger 647e48354ceSNicholas Bellinger /* End items for lio_target_nacl_param_cit */ 648e48354ceSNicholas Bellinger 649e48354ceSNicholas Bellinger /* Start items for lio_target_acl_cit */ 650e48354ceSNicholas Bellinger 651e48354ceSNicholas Bellinger static ssize_t lio_target_nacl_show_info( 652e48354ceSNicholas Bellinger struct se_node_acl *se_nacl, 653e48354ceSNicholas Bellinger char *page) 654e48354ceSNicholas Bellinger { 655e48354ceSNicholas Bellinger struct iscsi_session *sess; 656e48354ceSNicholas Bellinger struct iscsi_conn *conn; 657e48354ceSNicholas Bellinger struct se_session *se_sess; 658e48354ceSNicholas Bellinger ssize_t rb = 0; 659e48354ceSNicholas Bellinger 660e48354ceSNicholas Bellinger spin_lock_bh(&se_nacl->nacl_sess_lock); 661e48354ceSNicholas Bellinger se_sess = se_nacl->nacl_sess; 662e48354ceSNicholas Bellinger if (!se_sess) { 663e48354ceSNicholas Bellinger rb += sprintf(page+rb, "No active iSCSI Session for Initiator" 664e48354ceSNicholas Bellinger " Endpoint: %s\n", se_nacl->initiatorname); 665e48354ceSNicholas Bellinger } else { 666e48354ceSNicholas Bellinger sess = se_sess->fabric_sess_ptr; 667e48354ceSNicholas Bellinger 668e48354ceSNicholas Bellinger rb += sprintf(page+rb, "InitiatorName: %s\n", 669e48354ceSNicholas Bellinger sess->sess_ops->InitiatorName); 670e48354ceSNicholas Bellinger rb += sprintf(page+rb, "InitiatorAlias: %s\n", 671e48354ceSNicholas Bellinger sess->sess_ops->InitiatorAlias); 672e48354ceSNicholas Bellinger 6735cdf5a87SAndy Shevchenko rb += sprintf(page+rb, 6745cdf5a87SAndy Shevchenko "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ", 6755cdf5a87SAndy Shevchenko sess->sid, sess->isid, sess->tsih); 676e48354ceSNicholas Bellinger rb += sprintf(page+rb, "SessionType: %s\n", 677e48354ceSNicholas Bellinger (sess->sess_ops->SessionType) ? 678e48354ceSNicholas Bellinger "Discovery" : "Normal"); 679e48354ceSNicholas Bellinger rb += sprintf(page+rb, "Session State: "); 680e48354ceSNicholas Bellinger switch (sess->session_state) { 681e48354ceSNicholas Bellinger case TARG_SESS_STATE_FREE: 682e48354ceSNicholas Bellinger rb += sprintf(page+rb, "TARG_SESS_FREE\n"); 683e48354ceSNicholas Bellinger break; 684e48354ceSNicholas Bellinger case TARG_SESS_STATE_ACTIVE: 685e48354ceSNicholas Bellinger rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n"); 686e48354ceSNicholas Bellinger break; 687e48354ceSNicholas Bellinger case TARG_SESS_STATE_LOGGED_IN: 688e48354ceSNicholas Bellinger rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n"); 689e48354ceSNicholas Bellinger break; 690e48354ceSNicholas Bellinger case TARG_SESS_STATE_FAILED: 691e48354ceSNicholas Bellinger rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n"); 692e48354ceSNicholas Bellinger break; 693e48354ceSNicholas Bellinger case TARG_SESS_STATE_IN_CONTINUE: 694e48354ceSNicholas Bellinger rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n"); 695e48354ceSNicholas Bellinger break; 696e48354ceSNicholas Bellinger default: 697e48354ceSNicholas Bellinger rb += sprintf(page+rb, "ERROR: Unknown Session" 698e48354ceSNicholas Bellinger " State!\n"); 699e48354ceSNicholas Bellinger break; 700e48354ceSNicholas Bellinger } 701e48354ceSNicholas Bellinger 702e48354ceSNicholas Bellinger rb += sprintf(page+rb, "---------------------[iSCSI Session" 703e48354ceSNicholas Bellinger " Values]-----------------------\n"); 704e48354ceSNicholas Bellinger rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN" 705e48354ceSNicholas Bellinger " : MaxCmdSN : ITT : TTT\n"); 706e48354ceSNicholas Bellinger rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x" 707e48354ceSNicholas Bellinger " 0x%08x 0x%08x\n", 708e48354ceSNicholas Bellinger sess->cmdsn_window, 709e48354ceSNicholas Bellinger (sess->max_cmd_sn - sess->exp_cmd_sn) + 1, 710e48354ceSNicholas Bellinger sess->exp_cmd_sn, sess->max_cmd_sn, 711e48354ceSNicholas Bellinger sess->init_task_tag, sess->targ_xfer_tag); 712e48354ceSNicholas Bellinger rb += sprintf(page+rb, "----------------------[iSCSI" 713e48354ceSNicholas Bellinger " Connections]-------------------------\n"); 714e48354ceSNicholas Bellinger 715e48354ceSNicholas Bellinger spin_lock(&sess->conn_lock); 716e48354ceSNicholas Bellinger list_for_each_entry(conn, &sess->sess_conn_list, conn_list) { 717e48354ceSNicholas Bellinger rb += sprintf(page+rb, "CID: %hu Connection" 718e48354ceSNicholas Bellinger " State: ", conn->cid); 719e48354ceSNicholas Bellinger switch (conn->conn_state) { 720e48354ceSNicholas Bellinger case TARG_CONN_STATE_FREE: 721e48354ceSNicholas Bellinger rb += sprintf(page+rb, 722e48354ceSNicholas Bellinger "TARG_CONN_STATE_FREE\n"); 723e48354ceSNicholas Bellinger break; 724e48354ceSNicholas Bellinger case TARG_CONN_STATE_XPT_UP: 725e48354ceSNicholas Bellinger rb += sprintf(page+rb, 726e48354ceSNicholas Bellinger "TARG_CONN_STATE_XPT_UP\n"); 727e48354ceSNicholas Bellinger break; 728e48354ceSNicholas Bellinger case TARG_CONN_STATE_IN_LOGIN: 729e48354ceSNicholas Bellinger rb += sprintf(page+rb, 730e48354ceSNicholas Bellinger "TARG_CONN_STATE_IN_LOGIN\n"); 731e48354ceSNicholas Bellinger break; 732e48354ceSNicholas Bellinger case TARG_CONN_STATE_LOGGED_IN: 733e48354ceSNicholas Bellinger rb += sprintf(page+rb, 734e48354ceSNicholas Bellinger "TARG_CONN_STATE_LOGGED_IN\n"); 735e48354ceSNicholas Bellinger break; 736e48354ceSNicholas Bellinger case TARG_CONN_STATE_IN_LOGOUT: 737e48354ceSNicholas Bellinger rb += sprintf(page+rb, 738e48354ceSNicholas Bellinger "TARG_CONN_STATE_IN_LOGOUT\n"); 739e48354ceSNicholas Bellinger break; 740e48354ceSNicholas Bellinger case TARG_CONN_STATE_LOGOUT_REQUESTED: 741e48354ceSNicholas Bellinger rb += sprintf(page+rb, 742e48354ceSNicholas Bellinger "TARG_CONN_STATE_LOGOUT_REQUESTED\n"); 743e48354ceSNicholas Bellinger break; 744e48354ceSNicholas Bellinger case TARG_CONN_STATE_CLEANUP_WAIT: 745e48354ceSNicholas Bellinger rb += sprintf(page+rb, 746e48354ceSNicholas Bellinger "TARG_CONN_STATE_CLEANUP_WAIT\n"); 747e48354ceSNicholas Bellinger break; 748e48354ceSNicholas Bellinger default: 749e48354ceSNicholas Bellinger rb += sprintf(page+rb, 750e48354ceSNicholas Bellinger "ERROR: Unknown Connection State!\n"); 751e48354ceSNicholas Bellinger break; 752e48354ceSNicholas Bellinger } 753e48354ceSNicholas Bellinger 754e48354ceSNicholas Bellinger rb += sprintf(page+rb, " Address %s %s", conn->login_ip, 755e48354ceSNicholas Bellinger (conn->network_transport == ISCSI_TCP) ? 756e48354ceSNicholas Bellinger "TCP" : "SCTP"); 757e48354ceSNicholas Bellinger rb += sprintf(page+rb, " StatSN: 0x%08x\n", 758e48354ceSNicholas Bellinger conn->stat_sn); 759e48354ceSNicholas Bellinger } 760e48354ceSNicholas Bellinger spin_unlock(&sess->conn_lock); 761e48354ceSNicholas Bellinger } 762e48354ceSNicholas Bellinger spin_unlock_bh(&se_nacl->nacl_sess_lock); 763e48354ceSNicholas Bellinger 764e48354ceSNicholas Bellinger return rb; 765e48354ceSNicholas Bellinger } 766e48354ceSNicholas Bellinger 767e48354ceSNicholas Bellinger TF_NACL_BASE_ATTR_RO(lio_target, info); 768e48354ceSNicholas Bellinger 769e48354ceSNicholas Bellinger static ssize_t lio_target_nacl_show_cmdsn_depth( 770e48354ceSNicholas Bellinger struct se_node_acl *se_nacl, 771e48354ceSNicholas Bellinger char *page) 772e48354ceSNicholas Bellinger { 773e48354ceSNicholas Bellinger return sprintf(page, "%u\n", se_nacl->queue_depth); 774e48354ceSNicholas Bellinger } 775e48354ceSNicholas Bellinger 776e48354ceSNicholas Bellinger static ssize_t lio_target_nacl_store_cmdsn_depth( 777e48354ceSNicholas Bellinger struct se_node_acl *se_nacl, 778e48354ceSNicholas Bellinger const char *page, 779e48354ceSNicholas Bellinger size_t count) 780e48354ceSNicholas Bellinger { 781e48354ceSNicholas Bellinger struct se_portal_group *se_tpg = se_nacl->se_tpg; 782e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, 783e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); 784e48354ceSNicholas Bellinger struct config_item *acl_ci, *tpg_ci, *wwn_ci; 785e48354ceSNicholas Bellinger u32 cmdsn_depth = 0; 786e48354ceSNicholas Bellinger int ret; 787e48354ceSNicholas Bellinger 788ad7babd2SJörn Engel ret = kstrtou32(page, 0, &cmdsn_depth); 789ad7babd2SJörn Engel if (ret) 790ad7babd2SJörn Engel return ret; 791e48354ceSNicholas Bellinger if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) { 792e48354ceSNicholas Bellinger pr_err("Passed cmdsn_depth: %u exceeds" 793e48354ceSNicholas Bellinger " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth, 794e48354ceSNicholas Bellinger TA_DEFAULT_CMDSN_DEPTH_MAX); 795e48354ceSNicholas Bellinger return -EINVAL; 796e48354ceSNicholas Bellinger } 797e48354ceSNicholas Bellinger acl_ci = &se_nacl->acl_group.cg_item; 798e48354ceSNicholas Bellinger if (!acl_ci) { 799e48354ceSNicholas Bellinger pr_err("Unable to locatel acl_ci\n"); 800e48354ceSNicholas Bellinger return -EINVAL; 801e48354ceSNicholas Bellinger } 802e48354ceSNicholas Bellinger tpg_ci = &acl_ci->ci_parent->ci_group->cg_item; 803e48354ceSNicholas Bellinger if (!tpg_ci) { 804e48354ceSNicholas Bellinger pr_err("Unable to locate tpg_ci\n"); 805e48354ceSNicholas Bellinger return -EINVAL; 806e48354ceSNicholas Bellinger } 807e48354ceSNicholas Bellinger wwn_ci = &tpg_ci->ci_group->cg_item; 808e48354ceSNicholas Bellinger if (!wwn_ci) { 809e48354ceSNicholas Bellinger pr_err("Unable to locate config_item wwn_ci\n"); 810e48354ceSNicholas Bellinger return -EINVAL; 811e48354ceSNicholas Bellinger } 812e48354ceSNicholas Bellinger 813e48354ceSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) 814e48354ceSNicholas Bellinger return -EINVAL; 815e48354ceSNicholas Bellinger /* 816e48354ceSNicholas Bellinger * iscsit_tpg_set_initiator_node_queue_depth() assumes force=1 817e48354ceSNicholas Bellinger */ 818e48354ceSNicholas Bellinger ret = iscsit_tpg_set_initiator_node_queue_depth(tpg, 819e48354ceSNicholas Bellinger config_item_name(acl_ci), cmdsn_depth, 1); 820e48354ceSNicholas Bellinger 821e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for" 822e48354ceSNicholas Bellinger "InitiatorName: %s\n", config_item_name(wwn_ci), 823e48354ceSNicholas Bellinger config_item_name(tpg_ci), cmdsn_depth, 824e48354ceSNicholas Bellinger config_item_name(acl_ci)); 825e48354ceSNicholas Bellinger 826e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 827e48354ceSNicholas Bellinger return (!ret) ? count : (ssize_t)ret; 828e48354ceSNicholas Bellinger } 829e48354ceSNicholas Bellinger 830e48354ceSNicholas Bellinger TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR); 831e48354ceSNicholas Bellinger 83279e62fc3SAndy Grover static ssize_t lio_target_nacl_show_tag( 83379e62fc3SAndy Grover struct se_node_acl *se_nacl, 83479e62fc3SAndy Grover char *page) 83579e62fc3SAndy Grover { 83679e62fc3SAndy Grover return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag); 83779e62fc3SAndy Grover } 83879e62fc3SAndy Grover 83979e62fc3SAndy Grover static ssize_t lio_target_nacl_store_tag( 84079e62fc3SAndy Grover struct se_node_acl *se_nacl, 84179e62fc3SAndy Grover const char *page, 84279e62fc3SAndy Grover size_t count) 84379e62fc3SAndy Grover { 84479e62fc3SAndy Grover int ret; 84579e62fc3SAndy Grover 84679e62fc3SAndy Grover ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page); 84779e62fc3SAndy Grover 84879e62fc3SAndy Grover if (ret < 0) 84979e62fc3SAndy Grover return ret; 85079e62fc3SAndy Grover return count; 85179e62fc3SAndy Grover } 85279e62fc3SAndy Grover 85379e62fc3SAndy Grover TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR); 85479e62fc3SAndy Grover 855e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_initiator_attrs[] = { 856e48354ceSNicholas Bellinger &lio_target_nacl_info.attr, 857e48354ceSNicholas Bellinger &lio_target_nacl_cmdsn_depth.attr, 85879e62fc3SAndy Grover &lio_target_nacl_tag.attr, 859e48354ceSNicholas Bellinger NULL, 860e48354ceSNicholas Bellinger }; 861e48354ceSNicholas Bellinger 862c7d6a803SChristoph Hellwig static int lio_target_init_nodeacl(struct se_node_acl *se_nacl, 863e48354ceSNicholas Bellinger const char *name) 864e48354ceSNicholas Bellinger { 865c7d6a803SChristoph Hellwig struct iscsi_node_acl *acl = 866c7d6a803SChristoph Hellwig container_of(se_nacl, struct iscsi_node_acl, se_node_acl); 867c7d6a803SChristoph Hellwig struct config_group *stats_cg = &se_nacl->acl_fabric_stat_group; 868e48354ceSNicholas Bellinger 86913f6a914SSebastian Andrzej Siewior stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, 870e48354ceSNicholas Bellinger GFP_KERNEL); 871e48354ceSNicholas Bellinger if (!stats_cg->default_groups) { 872e48354ceSNicholas Bellinger pr_err("Unable to allocate memory for" 873e48354ceSNicholas Bellinger " stats_cg->default_groups\n"); 874c7d6a803SChristoph Hellwig return -ENOMEM; 875e48354ceSNicholas Bellinger } 876e48354ceSNicholas Bellinger 877b7eec2cdSAndy Grover stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group; 878e48354ceSNicholas Bellinger stats_cg->default_groups[1] = NULL; 879b7eec2cdSAndy Grover config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group, 880e48354ceSNicholas Bellinger "iscsi_sess_stats", &iscsi_stat_sess_cit); 881e48354ceSNicholas Bellinger 882c7d6a803SChristoph Hellwig return 0; 883e48354ceSNicholas Bellinger } 884e48354ceSNicholas Bellinger 885c7d6a803SChristoph Hellwig static void lio_target_cleanup_nodeacl( struct se_node_acl *se_nacl) 886e48354ceSNicholas Bellinger { 887e48354ceSNicholas Bellinger struct iscsi_node_acl *acl = container_of(se_nacl, 888e48354ceSNicholas Bellinger struct iscsi_node_acl, se_node_acl); 889e48354ceSNicholas Bellinger struct config_item *df_item; 890e48354ceSNicholas Bellinger struct config_group *stats_cg; 891e48354ceSNicholas Bellinger int i; 892e48354ceSNicholas Bellinger 893e48354ceSNicholas Bellinger stats_cg = &acl->se_node_acl.acl_fabric_stat_group; 894e48354ceSNicholas Bellinger for (i = 0; stats_cg->default_groups[i]; i++) { 895e48354ceSNicholas Bellinger df_item = &stats_cg->default_groups[i]->cg_item; 896e48354ceSNicholas Bellinger stats_cg->default_groups[i] = NULL; 897e48354ceSNicholas Bellinger config_item_put(df_item); 898e48354ceSNicholas Bellinger } 899e48354ceSNicholas Bellinger kfree(stats_cg->default_groups); 900e48354ceSNicholas Bellinger } 901e48354ceSNicholas Bellinger 902e48354ceSNicholas Bellinger /* End items for lio_target_acl_cit */ 903e48354ceSNicholas Bellinger 904e48354ceSNicholas Bellinger /* Start items for lio_target_tpg_attrib_cit */ 905e48354ceSNicholas Bellinger 906e48354ceSNicholas Bellinger #define DEF_TPG_ATTRIB(name) \ 907e48354ceSNicholas Bellinger \ 908e48354ceSNicholas Bellinger static ssize_t iscsi_tpg_attrib_show_##name( \ 909e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, \ 910e48354ceSNicholas Bellinger char *page) \ 911e48354ceSNicholas Bellinger { \ 912e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 913e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 914e48354ceSNicholas Bellinger ssize_t rb; \ 915e48354ceSNicholas Bellinger \ 916e48354ceSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) \ 917e48354ceSNicholas Bellinger return -EINVAL; \ 918e48354ceSNicholas Bellinger \ 919b7eec2cdSAndy Grover rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \ 920e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 921e48354ceSNicholas Bellinger return rb; \ 922e48354ceSNicholas Bellinger } \ 923e48354ceSNicholas Bellinger \ 924e48354ceSNicholas Bellinger static ssize_t iscsi_tpg_attrib_store_##name( \ 925e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, \ 926e48354ceSNicholas Bellinger const char *page, \ 927e48354ceSNicholas Bellinger size_t count) \ 928e48354ceSNicholas Bellinger { \ 929e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 930e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 931e48354ceSNicholas Bellinger u32 val; \ 932e48354ceSNicholas Bellinger int ret; \ 933e48354ceSNicholas Bellinger \ 934e48354ceSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) \ 935e48354ceSNicholas Bellinger return -EINVAL; \ 936e48354ceSNicholas Bellinger \ 937ad7babd2SJörn Engel ret = kstrtou32(page, 0, &val); \ 938ad7babd2SJörn Engel if (ret) \ 939ad7babd2SJörn Engel goto out; \ 940e48354ceSNicholas Bellinger ret = iscsit_ta_##name(tpg, val); \ 941e48354ceSNicholas Bellinger if (ret < 0) \ 942e48354ceSNicholas Bellinger goto out; \ 943e48354ceSNicholas Bellinger \ 944e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 945e48354ceSNicholas Bellinger return count; \ 946e48354ceSNicholas Bellinger out: \ 947e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 948e48354ceSNicholas Bellinger return ret; \ 949e48354ceSNicholas Bellinger } 950e48354ceSNicholas Bellinger 951e48354ceSNicholas Bellinger #define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode); 952e48354ceSNicholas Bellinger 953e48354ceSNicholas Bellinger /* 954e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_authentication 955e48354ceSNicholas Bellinger */ 956e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(authentication); 957e48354ceSNicholas Bellinger TPG_ATTR(authentication, S_IRUGO | S_IWUSR); 958e48354ceSNicholas Bellinger /* 959e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_login_timeout 960e48354ceSNicholas Bellinger */ 961e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(login_timeout); 962e48354ceSNicholas Bellinger TPG_ATTR(login_timeout, S_IRUGO | S_IWUSR); 963e48354ceSNicholas Bellinger /* 964e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_netif_timeout 965e48354ceSNicholas Bellinger */ 966e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(netif_timeout); 967e48354ceSNicholas Bellinger TPG_ATTR(netif_timeout, S_IRUGO | S_IWUSR); 968e48354ceSNicholas Bellinger /* 969e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_generate_node_acls 970e48354ceSNicholas Bellinger */ 971e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(generate_node_acls); 972e48354ceSNicholas Bellinger TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR); 973e48354ceSNicholas Bellinger /* 974e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_default_cmdsn_depth 975e48354ceSNicholas Bellinger */ 976e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(default_cmdsn_depth); 977e48354ceSNicholas Bellinger TPG_ATTR(default_cmdsn_depth, S_IRUGO | S_IWUSR); 978e48354ceSNicholas Bellinger /* 979e48354ceSNicholas Bellinger Define iscsi_tpg_attrib_s_cache_dynamic_acls 980e48354ceSNicholas Bellinger */ 981e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(cache_dynamic_acls); 982e48354ceSNicholas Bellinger TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR); 983e48354ceSNicholas Bellinger /* 984e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_demo_mode_write_protect 985e48354ceSNicholas Bellinger */ 986e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(demo_mode_write_protect); 987e48354ceSNicholas Bellinger TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR); 988e48354ceSNicholas Bellinger /* 989e48354ceSNicholas Bellinger * Define iscsi_tpg_attrib_s_prod_mode_write_protect 990e48354ceSNicholas Bellinger */ 991e48354ceSNicholas Bellinger DEF_TPG_ATTRIB(prod_mode_write_protect); 992e48354ceSNicholas Bellinger TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); 9934c54b6cfSThomas Glanzmann /* 9944c54b6cfSThomas Glanzmann * Define iscsi_tpg_attrib_s_demo_mode_discovery, 9954c54b6cfSThomas Glanzmann */ 9964c54b6cfSThomas Glanzmann DEF_TPG_ATTRIB(demo_mode_discovery); 9974c54b6cfSThomas Glanzmann TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR); 998d1fa7a1dSNicholas Bellinger /* 999d1fa7a1dSNicholas Bellinger * Define iscsi_tpg_attrib_s_default_erl 1000d1fa7a1dSNicholas Bellinger */ 1001d1fa7a1dSNicholas Bellinger DEF_TPG_ATTRIB(default_erl); 1002d1fa7a1dSNicholas Bellinger TPG_ATTR(default_erl, S_IRUGO | S_IWUSR); 10038085176fSSagi Grimberg /* 10048085176fSSagi Grimberg * Define iscsi_tpg_attrib_s_t10_pi 10058085176fSSagi Grimberg */ 10068085176fSSagi Grimberg DEF_TPG_ATTRIB(t10_pi); 10078085176fSSagi Grimberg TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR); 1008901c04a3SNicholas Bellinger /* 1009901c04a3SNicholas Bellinger * Define iscsi_tpg_attrib_s_fabric_prot_type 1010901c04a3SNicholas Bellinger */ 1011901c04a3SNicholas Bellinger DEF_TPG_ATTRIB(fabric_prot_type); 1012901c04a3SNicholas Bellinger TPG_ATTR(fabric_prot_type, S_IRUGO | S_IWUSR); 1013a6415cddSDavid Disseldorp /* 1014a6415cddSDavid Disseldorp * Define iscsi_tpg_attrib_s_tpg_enabled_sendtargets 1015a6415cddSDavid Disseldorp */ 1016a6415cddSDavid Disseldorp DEF_TPG_ATTRIB(tpg_enabled_sendtargets); 1017a6415cddSDavid Disseldorp TPG_ATTR(tpg_enabled_sendtargets, S_IRUGO | S_IWUSR); 1018e48354ceSNicholas Bellinger 1019e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { 1020e48354ceSNicholas Bellinger &iscsi_tpg_attrib_authentication.attr, 1021e48354ceSNicholas Bellinger &iscsi_tpg_attrib_login_timeout.attr, 1022e48354ceSNicholas Bellinger &iscsi_tpg_attrib_netif_timeout.attr, 1023e48354ceSNicholas Bellinger &iscsi_tpg_attrib_generate_node_acls.attr, 1024e48354ceSNicholas Bellinger &iscsi_tpg_attrib_default_cmdsn_depth.attr, 1025e48354ceSNicholas Bellinger &iscsi_tpg_attrib_cache_dynamic_acls.attr, 1026e48354ceSNicholas Bellinger &iscsi_tpg_attrib_demo_mode_write_protect.attr, 1027e48354ceSNicholas Bellinger &iscsi_tpg_attrib_prod_mode_write_protect.attr, 10284c54b6cfSThomas Glanzmann &iscsi_tpg_attrib_demo_mode_discovery.attr, 1029d1fa7a1dSNicholas Bellinger &iscsi_tpg_attrib_default_erl.attr, 10308085176fSSagi Grimberg &iscsi_tpg_attrib_t10_pi.attr, 1031901c04a3SNicholas Bellinger &iscsi_tpg_attrib_fabric_prot_type.attr, 1032a6415cddSDavid Disseldorp &iscsi_tpg_attrib_tpg_enabled_sendtargets.attr, 1033e48354ceSNicholas Bellinger NULL, 1034e48354ceSNicholas Bellinger }; 1035e48354ceSNicholas Bellinger 1036e48354ceSNicholas Bellinger /* End items for lio_target_tpg_attrib_cit */ 1037e48354ceSNicholas Bellinger 1038c3e51442SNicholas Bellinger /* Start items for lio_target_tpg_auth_cit */ 1039c3e51442SNicholas Bellinger 1040c3e51442SNicholas Bellinger #define __DEF_TPG_AUTH_STR(prefix, name, flags) \ 1041c3e51442SNicholas Bellinger static ssize_t __iscsi_##prefix##_show_##name( \ 1042c3e51442SNicholas Bellinger struct se_portal_group *se_tpg, \ 1043c3e51442SNicholas Bellinger char *page) \ 1044c3e51442SNicholas Bellinger { \ 1045c3e51442SNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1046c3e51442SNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 1047c3e51442SNicholas Bellinger struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \ 1048c3e51442SNicholas Bellinger \ 1049c3e51442SNicholas Bellinger if (!capable(CAP_SYS_ADMIN)) \ 1050c3e51442SNicholas Bellinger return -EPERM; \ 1051c3e51442SNicholas Bellinger \ 1052c3e51442SNicholas Bellinger return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ 1053c3e51442SNicholas Bellinger } \ 1054c3e51442SNicholas Bellinger \ 1055c3e51442SNicholas Bellinger static ssize_t __iscsi_##prefix##_store_##name( \ 1056c3e51442SNicholas Bellinger struct se_portal_group *se_tpg, \ 1057c3e51442SNicholas Bellinger const char *page, \ 1058c3e51442SNicholas Bellinger size_t count) \ 1059c3e51442SNicholas Bellinger { \ 1060c3e51442SNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1061c3e51442SNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 1062c3e51442SNicholas Bellinger struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \ 1063c3e51442SNicholas Bellinger \ 1064c3e51442SNicholas Bellinger if (!capable(CAP_SYS_ADMIN)) \ 1065c3e51442SNicholas Bellinger return -EPERM; \ 1066c3e51442SNicholas Bellinger \ 106737b32c6fSNicholas Bellinger snprintf(auth->name, sizeof(auth->name), "%s", page); \ 1068c3e51442SNicholas Bellinger if (!(strncmp("NULL", auth->name, 4))) \ 1069c3e51442SNicholas Bellinger auth->naf_flags &= ~flags; \ 1070c3e51442SNicholas Bellinger else \ 1071c3e51442SNicholas Bellinger auth->naf_flags |= flags; \ 1072c3e51442SNicholas Bellinger \ 1073c3e51442SNicholas Bellinger if ((auth->naf_flags & NAF_USERID_IN_SET) && \ 1074c3e51442SNicholas Bellinger (auth->naf_flags & NAF_PASSWORD_IN_SET)) \ 1075c3e51442SNicholas Bellinger auth->authenticate_target = 1; \ 1076c3e51442SNicholas Bellinger else \ 1077c3e51442SNicholas Bellinger auth->authenticate_target = 0; \ 1078c3e51442SNicholas Bellinger \ 1079c3e51442SNicholas Bellinger return count; \ 1080c3e51442SNicholas Bellinger } 1081c3e51442SNicholas Bellinger 1082c3e51442SNicholas Bellinger #define __DEF_TPG_AUTH_INT(prefix, name) \ 1083c3e51442SNicholas Bellinger static ssize_t __iscsi_##prefix##_show_##name( \ 1084c3e51442SNicholas Bellinger struct se_portal_group *se_tpg, \ 1085c3e51442SNicholas Bellinger char *page) \ 1086c3e51442SNicholas Bellinger { \ 1087c3e51442SNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1088c3e51442SNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 1089c3e51442SNicholas Bellinger struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \ 1090c3e51442SNicholas Bellinger \ 1091c3e51442SNicholas Bellinger if (!capable(CAP_SYS_ADMIN)) \ 1092c3e51442SNicholas Bellinger return -EPERM; \ 1093c3e51442SNicholas Bellinger \ 1094c3e51442SNicholas Bellinger return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ 1095c3e51442SNicholas Bellinger } 1096c3e51442SNicholas Bellinger 1097c3e51442SNicholas Bellinger #define DEF_TPG_AUTH_STR(name, flags) \ 1098c3e51442SNicholas Bellinger __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \ 1099c3e51442SNicholas Bellinger static ssize_t iscsi_tpg_auth_show_##name( \ 1100c3e51442SNicholas Bellinger struct se_portal_group *se_tpg, \ 1101c3e51442SNicholas Bellinger char *page) \ 1102c3e51442SNicholas Bellinger { \ 1103c3e51442SNicholas Bellinger return __iscsi_tpg_auth_show_##name(se_tpg, page); \ 1104c3e51442SNicholas Bellinger } \ 1105c3e51442SNicholas Bellinger \ 1106c3e51442SNicholas Bellinger static ssize_t iscsi_tpg_auth_store_##name( \ 1107c3e51442SNicholas Bellinger struct se_portal_group *se_tpg, \ 1108c3e51442SNicholas Bellinger const char *page, \ 1109c3e51442SNicholas Bellinger size_t count) \ 1110c3e51442SNicholas Bellinger { \ 1111c3e51442SNicholas Bellinger return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \ 1112c3e51442SNicholas Bellinger } 1113c3e51442SNicholas Bellinger 1114c3e51442SNicholas Bellinger #define DEF_TPG_AUTH_INT(name) \ 1115c3e51442SNicholas Bellinger __DEF_TPG_AUTH_INT(tpg_auth, name) \ 1116c3e51442SNicholas Bellinger static ssize_t iscsi_tpg_auth_show_##name( \ 1117c3e51442SNicholas Bellinger struct se_portal_group *se_tpg, \ 1118c3e51442SNicholas Bellinger char *page) \ 1119c3e51442SNicholas Bellinger { \ 1120c3e51442SNicholas Bellinger return __iscsi_tpg_auth_show_##name(se_tpg, page); \ 1121c3e51442SNicholas Bellinger } 1122c3e51442SNicholas Bellinger 1123c3e51442SNicholas Bellinger #define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode); 1124c3e51442SNicholas Bellinger #define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name); 1125c3e51442SNicholas Bellinger 1126c3e51442SNicholas Bellinger /* 1127c3e51442SNicholas Bellinger * * One-way authentication userid 1128c3e51442SNicholas Bellinger * */ 1129c3e51442SNicholas Bellinger DEF_TPG_AUTH_STR(userid, NAF_USERID_SET); 1130c3e51442SNicholas Bellinger TPG_AUTH_ATTR(userid, S_IRUGO | S_IWUSR); 1131c3e51442SNicholas Bellinger /* 1132c3e51442SNicholas Bellinger * * One-way authentication password 1133c3e51442SNicholas Bellinger * */ 1134c3e51442SNicholas Bellinger DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET); 1135c3e51442SNicholas Bellinger TPG_AUTH_ATTR(password, S_IRUGO | S_IWUSR); 1136c3e51442SNicholas Bellinger /* 1137c3e51442SNicholas Bellinger * * Enforce mutual authentication 1138c3e51442SNicholas Bellinger * */ 1139c3e51442SNicholas Bellinger DEF_TPG_AUTH_INT(authenticate_target); 1140c3e51442SNicholas Bellinger TPG_AUTH_ATTR_RO(authenticate_target); 1141c3e51442SNicholas Bellinger /* 1142c3e51442SNicholas Bellinger * * Mutual authentication userid 1143c3e51442SNicholas Bellinger * */ 1144c3e51442SNicholas Bellinger DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 1145c3e51442SNicholas Bellinger TPG_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); 1146c3e51442SNicholas Bellinger /* 1147c3e51442SNicholas Bellinger * * Mutual authentication password 1148c3e51442SNicholas Bellinger * */ 1149c3e51442SNicholas Bellinger DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 1150c3e51442SNicholas Bellinger TPG_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); 1151c3e51442SNicholas Bellinger 1152c3e51442SNicholas Bellinger static struct configfs_attribute *lio_target_tpg_auth_attrs[] = { 1153c3e51442SNicholas Bellinger &iscsi_tpg_auth_userid.attr, 1154c3e51442SNicholas Bellinger &iscsi_tpg_auth_password.attr, 1155c3e51442SNicholas Bellinger &iscsi_tpg_auth_authenticate_target.attr, 1156c3e51442SNicholas Bellinger &iscsi_tpg_auth_userid_mutual.attr, 1157c3e51442SNicholas Bellinger &iscsi_tpg_auth_password_mutual.attr, 1158c3e51442SNicholas Bellinger NULL, 1159c3e51442SNicholas Bellinger }; 1160c3e51442SNicholas Bellinger 1161c3e51442SNicholas Bellinger /* End items for lio_target_tpg_auth_cit */ 1162c3e51442SNicholas Bellinger 1163e48354ceSNicholas Bellinger /* Start items for lio_target_tpg_param_cit */ 1164e48354ceSNicholas Bellinger 1165e48354ceSNicholas Bellinger #define DEF_TPG_PARAM(name) \ 1166e48354ceSNicholas Bellinger static ssize_t iscsi_tpg_param_show_##name( \ 1167e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, \ 1168e48354ceSNicholas Bellinger char *page) \ 1169e48354ceSNicholas Bellinger { \ 1170e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1171e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 1172e48354ceSNicholas Bellinger struct iscsi_param *param; \ 1173e48354ceSNicholas Bellinger ssize_t rb; \ 1174e48354ceSNicholas Bellinger \ 1175e48354ceSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) \ 1176e48354ceSNicholas Bellinger return -EINVAL; \ 1177e48354ceSNicholas Bellinger \ 1178e48354ceSNicholas Bellinger param = iscsi_find_param_from_key(__stringify(name), \ 1179e48354ceSNicholas Bellinger tpg->param_list); \ 1180e48354ceSNicholas Bellinger if (!param) { \ 1181e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 1182e48354ceSNicholas Bellinger return -EINVAL; \ 1183e48354ceSNicholas Bellinger } \ 1184e48354ceSNicholas Bellinger rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \ 1185e48354ceSNicholas Bellinger \ 1186e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 1187e48354ceSNicholas Bellinger return rb; \ 1188e48354ceSNicholas Bellinger } \ 1189e48354ceSNicholas Bellinger static ssize_t iscsi_tpg_param_store_##name( \ 1190e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, \ 1191e48354ceSNicholas Bellinger const char *page, \ 1192e48354ceSNicholas Bellinger size_t count) \ 1193e48354ceSNicholas Bellinger { \ 1194e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1195e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); \ 1196e48354ceSNicholas Bellinger char *buf; \ 1197ad7babd2SJörn Engel int ret, len; \ 1198e48354ceSNicholas Bellinger \ 1199e48354ceSNicholas Bellinger buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \ 1200e48354ceSNicholas Bellinger if (!buf) \ 1201e48354ceSNicholas Bellinger return -ENOMEM; \ 1202ad7babd2SJörn Engel len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \ 1203ad7babd2SJörn Engel if (isspace(buf[len-1])) \ 1204ad7babd2SJörn Engel buf[len-1] = '\0'; /* Kill newline */ \ 1205e48354ceSNicholas Bellinger \ 1206e48354ceSNicholas Bellinger if (iscsit_get_tpg(tpg) < 0) { \ 1207e48354ceSNicholas Bellinger kfree(buf); \ 1208e48354ceSNicholas Bellinger return -EINVAL; \ 1209e48354ceSNicholas Bellinger } \ 1210e48354ceSNicholas Bellinger \ 1211e48354ceSNicholas Bellinger ret = iscsi_change_param_value(buf, tpg->param_list, 1); \ 1212e48354ceSNicholas Bellinger if (ret < 0) \ 1213e48354ceSNicholas Bellinger goto out; \ 1214e48354ceSNicholas Bellinger \ 1215e48354ceSNicholas Bellinger kfree(buf); \ 1216e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 1217e48354ceSNicholas Bellinger return count; \ 1218e48354ceSNicholas Bellinger out: \ 1219e48354ceSNicholas Bellinger kfree(buf); \ 1220e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); \ 1221e48354ceSNicholas Bellinger return -EINVAL; \ 1222e48354ceSNicholas Bellinger } 1223e48354ceSNicholas Bellinger 1224e48354ceSNicholas Bellinger #define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode); 1225e48354ceSNicholas Bellinger 1226e48354ceSNicholas Bellinger DEF_TPG_PARAM(AuthMethod); 1227e48354ceSNicholas Bellinger TPG_PARAM_ATTR(AuthMethod, S_IRUGO | S_IWUSR); 1228e48354ceSNicholas Bellinger 1229e48354ceSNicholas Bellinger DEF_TPG_PARAM(HeaderDigest); 1230e48354ceSNicholas Bellinger TPG_PARAM_ATTR(HeaderDigest, S_IRUGO | S_IWUSR); 1231e48354ceSNicholas Bellinger 1232e48354ceSNicholas Bellinger DEF_TPG_PARAM(DataDigest); 1233e48354ceSNicholas Bellinger TPG_PARAM_ATTR(DataDigest, S_IRUGO | S_IWUSR); 1234e48354ceSNicholas Bellinger 1235e48354ceSNicholas Bellinger DEF_TPG_PARAM(MaxConnections); 1236e48354ceSNicholas Bellinger TPG_PARAM_ATTR(MaxConnections, S_IRUGO | S_IWUSR); 1237e48354ceSNicholas Bellinger 1238e48354ceSNicholas Bellinger DEF_TPG_PARAM(TargetAlias); 1239e48354ceSNicholas Bellinger TPG_PARAM_ATTR(TargetAlias, S_IRUGO | S_IWUSR); 1240e48354ceSNicholas Bellinger 1241e48354ceSNicholas Bellinger DEF_TPG_PARAM(InitialR2T); 1242e48354ceSNicholas Bellinger TPG_PARAM_ATTR(InitialR2T, S_IRUGO | S_IWUSR); 1243e48354ceSNicholas Bellinger 1244e48354ceSNicholas Bellinger DEF_TPG_PARAM(ImmediateData); 1245e48354ceSNicholas Bellinger TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR); 1246e48354ceSNicholas Bellinger 1247e48354ceSNicholas Bellinger DEF_TPG_PARAM(MaxRecvDataSegmentLength); 1248e48354ceSNicholas Bellinger TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR); 1249e48354ceSNicholas Bellinger 1250e004cb25SNicholas Bellinger DEF_TPG_PARAM(MaxXmitDataSegmentLength); 1251e004cb25SNicholas Bellinger TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR); 1252e004cb25SNicholas Bellinger 1253e48354ceSNicholas Bellinger DEF_TPG_PARAM(MaxBurstLength); 1254e48354ceSNicholas Bellinger TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR); 1255e48354ceSNicholas Bellinger 1256e48354ceSNicholas Bellinger DEF_TPG_PARAM(FirstBurstLength); 1257e48354ceSNicholas Bellinger TPG_PARAM_ATTR(FirstBurstLength, S_IRUGO | S_IWUSR); 1258e48354ceSNicholas Bellinger 1259e48354ceSNicholas Bellinger DEF_TPG_PARAM(DefaultTime2Wait); 1260e48354ceSNicholas Bellinger TPG_PARAM_ATTR(DefaultTime2Wait, S_IRUGO | S_IWUSR); 1261e48354ceSNicholas Bellinger 1262e48354ceSNicholas Bellinger DEF_TPG_PARAM(DefaultTime2Retain); 1263e48354ceSNicholas Bellinger TPG_PARAM_ATTR(DefaultTime2Retain, S_IRUGO | S_IWUSR); 1264e48354ceSNicholas Bellinger 1265e48354ceSNicholas Bellinger DEF_TPG_PARAM(MaxOutstandingR2T); 1266e48354ceSNicholas Bellinger TPG_PARAM_ATTR(MaxOutstandingR2T, S_IRUGO | S_IWUSR); 1267e48354ceSNicholas Bellinger 1268e48354ceSNicholas Bellinger DEF_TPG_PARAM(DataPDUInOrder); 1269e48354ceSNicholas Bellinger TPG_PARAM_ATTR(DataPDUInOrder, S_IRUGO | S_IWUSR); 1270e48354ceSNicholas Bellinger 1271e48354ceSNicholas Bellinger DEF_TPG_PARAM(DataSequenceInOrder); 1272e48354ceSNicholas Bellinger TPG_PARAM_ATTR(DataSequenceInOrder, S_IRUGO | S_IWUSR); 1273e48354ceSNicholas Bellinger 1274e48354ceSNicholas Bellinger DEF_TPG_PARAM(ErrorRecoveryLevel); 1275e48354ceSNicholas Bellinger TPG_PARAM_ATTR(ErrorRecoveryLevel, S_IRUGO | S_IWUSR); 1276e48354ceSNicholas Bellinger 1277e48354ceSNicholas Bellinger DEF_TPG_PARAM(IFMarker); 1278e48354ceSNicholas Bellinger TPG_PARAM_ATTR(IFMarker, S_IRUGO | S_IWUSR); 1279e48354ceSNicholas Bellinger 1280e48354ceSNicholas Bellinger DEF_TPG_PARAM(OFMarker); 1281e48354ceSNicholas Bellinger TPG_PARAM_ATTR(OFMarker, S_IRUGO | S_IWUSR); 1282e48354ceSNicholas Bellinger 1283e48354ceSNicholas Bellinger DEF_TPG_PARAM(IFMarkInt); 1284e48354ceSNicholas Bellinger TPG_PARAM_ATTR(IFMarkInt, S_IRUGO | S_IWUSR); 1285e48354ceSNicholas Bellinger 1286e48354ceSNicholas Bellinger DEF_TPG_PARAM(OFMarkInt); 1287e48354ceSNicholas Bellinger TPG_PARAM_ATTR(OFMarkInt, S_IRUGO | S_IWUSR); 1288e48354ceSNicholas Bellinger 1289e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_tpg_param_attrs[] = { 1290e48354ceSNicholas Bellinger &iscsi_tpg_param_AuthMethod.attr, 1291e48354ceSNicholas Bellinger &iscsi_tpg_param_HeaderDigest.attr, 1292e48354ceSNicholas Bellinger &iscsi_tpg_param_DataDigest.attr, 1293e48354ceSNicholas Bellinger &iscsi_tpg_param_MaxConnections.attr, 1294e48354ceSNicholas Bellinger &iscsi_tpg_param_TargetAlias.attr, 1295e48354ceSNicholas Bellinger &iscsi_tpg_param_InitialR2T.attr, 1296e48354ceSNicholas Bellinger &iscsi_tpg_param_ImmediateData.attr, 1297e48354ceSNicholas Bellinger &iscsi_tpg_param_MaxRecvDataSegmentLength.attr, 1298e004cb25SNicholas Bellinger &iscsi_tpg_param_MaxXmitDataSegmentLength.attr, 1299e48354ceSNicholas Bellinger &iscsi_tpg_param_MaxBurstLength.attr, 1300e48354ceSNicholas Bellinger &iscsi_tpg_param_FirstBurstLength.attr, 1301e48354ceSNicholas Bellinger &iscsi_tpg_param_DefaultTime2Wait.attr, 1302e48354ceSNicholas Bellinger &iscsi_tpg_param_DefaultTime2Retain.attr, 1303e48354ceSNicholas Bellinger &iscsi_tpg_param_MaxOutstandingR2T.attr, 1304e48354ceSNicholas Bellinger &iscsi_tpg_param_DataPDUInOrder.attr, 1305e48354ceSNicholas Bellinger &iscsi_tpg_param_DataSequenceInOrder.attr, 1306e48354ceSNicholas Bellinger &iscsi_tpg_param_ErrorRecoveryLevel.attr, 1307e48354ceSNicholas Bellinger &iscsi_tpg_param_IFMarker.attr, 1308e48354ceSNicholas Bellinger &iscsi_tpg_param_OFMarker.attr, 1309e48354ceSNicholas Bellinger &iscsi_tpg_param_IFMarkInt.attr, 1310e48354ceSNicholas Bellinger &iscsi_tpg_param_OFMarkInt.attr, 1311e48354ceSNicholas Bellinger NULL, 1312e48354ceSNicholas Bellinger }; 1313e48354ceSNicholas Bellinger 1314e48354ceSNicholas Bellinger /* End items for lio_target_tpg_param_cit */ 1315e48354ceSNicholas Bellinger 1316e48354ceSNicholas Bellinger /* Start items for lio_target_tpg_cit */ 1317e48354ceSNicholas Bellinger 1318e48354ceSNicholas Bellinger static ssize_t lio_target_tpg_show_enable( 1319e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, 1320e48354ceSNicholas Bellinger char *page) 1321e48354ceSNicholas Bellinger { 1322e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, 1323e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); 1324e48354ceSNicholas Bellinger ssize_t len; 1325e48354ceSNicholas Bellinger 1326e48354ceSNicholas Bellinger spin_lock(&tpg->tpg_state_lock); 1327e48354ceSNicholas Bellinger len = sprintf(page, "%d\n", 1328e48354ceSNicholas Bellinger (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0); 1329e48354ceSNicholas Bellinger spin_unlock(&tpg->tpg_state_lock); 1330e48354ceSNicholas Bellinger 1331e48354ceSNicholas Bellinger return len; 1332e48354ceSNicholas Bellinger } 1333e48354ceSNicholas Bellinger 1334e48354ceSNicholas Bellinger static ssize_t lio_target_tpg_store_enable( 1335e48354ceSNicholas Bellinger struct se_portal_group *se_tpg, 1336e48354ceSNicholas Bellinger const char *page, 1337e48354ceSNicholas Bellinger size_t count) 1338e48354ceSNicholas Bellinger { 1339e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, 1340e48354ceSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); 1341e48354ceSNicholas Bellinger u32 op; 1342ad7babd2SJörn Engel int ret; 1343e48354ceSNicholas Bellinger 1344ad7babd2SJörn Engel ret = kstrtou32(page, 0, &op); 1345ad7babd2SJörn Engel if (ret) 1346ad7babd2SJörn Engel return ret; 1347e48354ceSNicholas Bellinger if ((op != 1) && (op != 0)) { 1348e48354ceSNicholas Bellinger pr_err("Illegal value for tpg_enable: %u\n", op); 1349e48354ceSNicholas Bellinger return -EINVAL; 1350e48354ceSNicholas Bellinger } 1351e48354ceSNicholas Bellinger 1352e48354ceSNicholas Bellinger ret = iscsit_get_tpg(tpg); 1353e48354ceSNicholas Bellinger if (ret < 0) 1354e48354ceSNicholas Bellinger return -EINVAL; 1355e48354ceSNicholas Bellinger 1356e48354ceSNicholas Bellinger if (op) { 1357e48354ceSNicholas Bellinger ret = iscsit_tpg_enable_portal_group(tpg); 1358e48354ceSNicholas Bellinger if (ret < 0) 1359e48354ceSNicholas Bellinger goto out; 1360e48354ceSNicholas Bellinger } else { 1361e48354ceSNicholas Bellinger /* 1362e48354ceSNicholas Bellinger * iscsit_tpg_disable_portal_group() assumes force=1 1363e48354ceSNicholas Bellinger */ 1364e48354ceSNicholas Bellinger ret = iscsit_tpg_disable_portal_group(tpg, 1); 1365e48354ceSNicholas Bellinger if (ret < 0) 1366e48354ceSNicholas Bellinger goto out; 1367e48354ceSNicholas Bellinger } 1368e48354ceSNicholas Bellinger 1369e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 1370e48354ceSNicholas Bellinger return count; 1371e48354ceSNicholas Bellinger out: 1372e48354ceSNicholas Bellinger iscsit_put_tpg(tpg); 1373e48354ceSNicholas Bellinger return -EINVAL; 1374e48354ceSNicholas Bellinger } 1375e48354ceSNicholas Bellinger 1376e48354ceSNicholas Bellinger TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR); 1377e48354ceSNicholas Bellinger 1378d4ee46ffSNicholas Bellinger static ssize_t lio_target_tpg_show_dynamic_sessions( 1379d4ee46ffSNicholas Bellinger struct se_portal_group *se_tpg, 1380d4ee46ffSNicholas Bellinger char *page) 1381d4ee46ffSNicholas Bellinger { 1382d4ee46ffSNicholas Bellinger return target_show_dynamic_sessions(se_tpg, page); 1383d4ee46ffSNicholas Bellinger } 1384d4ee46ffSNicholas Bellinger 1385d4ee46ffSNicholas Bellinger TF_TPG_BASE_ATTR_RO(lio_target, dynamic_sessions); 1386d4ee46ffSNicholas Bellinger 1387e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_tpg_attrs[] = { 1388e48354ceSNicholas Bellinger &lio_target_tpg_enable.attr, 1389d4ee46ffSNicholas Bellinger &lio_target_tpg_dynamic_sessions.attr, 1390e48354ceSNicholas Bellinger NULL, 1391e48354ceSNicholas Bellinger }; 1392e48354ceSNicholas Bellinger 1393e48354ceSNicholas Bellinger /* End items for lio_target_tpg_cit */ 1394e48354ceSNicholas Bellinger 1395e48354ceSNicholas Bellinger /* Start items for lio_target_tiqn_cit */ 1396e48354ceSNicholas Bellinger 1397fceb5bc7SChristoph Hellwig static struct se_portal_group *lio_target_tiqn_addtpg( 1398e48354ceSNicholas Bellinger struct se_wwn *wwn, 1399e48354ceSNicholas Bellinger struct config_group *group, 1400e48354ceSNicholas Bellinger const char *name) 1401e48354ceSNicholas Bellinger { 1402e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg; 1403e48354ceSNicholas Bellinger struct iscsi_tiqn *tiqn; 1404ad7babd2SJörn Engel char *tpgt_str; 1405ad7babd2SJörn Engel int ret; 1406ad7babd2SJörn Engel u16 tpgt; 1407e48354ceSNicholas Bellinger 1408e48354ceSNicholas Bellinger tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); 1409e48354ceSNicholas Bellinger /* 1410e48354ceSNicholas Bellinger * Only tpgt_# directory groups can be created below 1411e48354ceSNicholas Bellinger * target/iscsi/iqn.superturodiskarry/ 1412e48354ceSNicholas Bellinger */ 1413e48354ceSNicholas Bellinger tpgt_str = strstr(name, "tpgt_"); 1414e48354ceSNicholas Bellinger if (!tpgt_str) { 1415e48354ceSNicholas Bellinger pr_err("Unable to locate \"tpgt_#\" directory" 1416e48354ceSNicholas Bellinger " group\n"); 1417e48354ceSNicholas Bellinger return NULL; 1418e48354ceSNicholas Bellinger } 1419e48354ceSNicholas Bellinger tpgt_str += 5; /* Skip ahead of "tpgt_" */ 1420ad7babd2SJörn Engel ret = kstrtou16(tpgt_str, 0, &tpgt); 1421ad7babd2SJörn Engel if (ret) 1422ad7babd2SJörn Engel return NULL; 1423e48354ceSNicholas Bellinger 1424e48354ceSNicholas Bellinger tpg = iscsit_alloc_portal_group(tiqn, tpgt); 1425e48354ceSNicholas Bellinger if (!tpg) 1426e48354ceSNicholas Bellinger return NULL; 1427e48354ceSNicholas Bellinger 1428bc0c94b1SNicholas Bellinger ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI); 1429e48354ceSNicholas Bellinger if (ret < 0) 1430e48354ceSNicholas Bellinger return NULL; 1431e48354ceSNicholas Bellinger 1432e48354ceSNicholas Bellinger ret = iscsit_tpg_add_portal_group(tiqn, tpg); 1433e48354ceSNicholas Bellinger if (ret != 0) 1434e48354ceSNicholas Bellinger goto out; 1435e48354ceSNicholas Bellinger 1436e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn); 1437e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n", 1438e48354ceSNicholas Bellinger name); 1439e48354ceSNicholas Bellinger return &tpg->tpg_se_tpg; 1440e48354ceSNicholas Bellinger out: 1441e48354ceSNicholas Bellinger core_tpg_deregister(&tpg->tpg_se_tpg); 1442e48354ceSNicholas Bellinger kfree(tpg); 1443e48354ceSNicholas Bellinger return NULL; 1444e48354ceSNicholas Bellinger } 1445e48354ceSNicholas Bellinger 1446fceb5bc7SChristoph Hellwig static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg) 1447e48354ceSNicholas Bellinger { 1448e48354ceSNicholas Bellinger struct iscsi_portal_group *tpg; 1449e48354ceSNicholas Bellinger struct iscsi_tiqn *tiqn; 1450e48354ceSNicholas Bellinger 1451e48354ceSNicholas Bellinger tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg); 1452e48354ceSNicholas Bellinger tiqn = tpg->tpg_tiqn; 1453e48354ceSNicholas Bellinger /* 1454e48354ceSNicholas Bellinger * iscsit_tpg_del_portal_group() assumes force=1 1455e48354ceSNicholas Bellinger */ 1456e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n"); 1457e48354ceSNicholas Bellinger iscsit_tpg_del_portal_group(tiqn, tpg, 1); 1458e48354ceSNicholas Bellinger } 1459e48354ceSNicholas Bellinger 1460e48354ceSNicholas Bellinger /* End items for lio_target_tiqn_cit */ 1461e48354ceSNicholas Bellinger 1462e48354ceSNicholas Bellinger /* Start LIO-Target TIQN struct contig_item lio_target_cit */ 1463e48354ceSNicholas Bellinger 1464e48354ceSNicholas Bellinger static ssize_t lio_target_wwn_show_attr_lio_version( 1465e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, 1466e48354ceSNicholas Bellinger char *page) 1467e48354ceSNicholas Bellinger { 14684c76251eSNicholas Bellinger return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n"); 1469e48354ceSNicholas Bellinger } 1470e48354ceSNicholas Bellinger 1471e48354ceSNicholas Bellinger TF_WWN_ATTR_RO(lio_target, lio_version); 1472e48354ceSNicholas Bellinger 1473e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_wwn_attrs[] = { 1474e48354ceSNicholas Bellinger &lio_target_wwn_lio_version.attr, 1475e48354ceSNicholas Bellinger NULL, 1476e48354ceSNicholas Bellinger }; 1477e48354ceSNicholas Bellinger 1478fceb5bc7SChristoph Hellwig static struct se_wwn *lio_target_call_coreaddtiqn( 1479e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, 1480e48354ceSNicholas Bellinger struct config_group *group, 1481e48354ceSNicholas Bellinger const char *name) 1482e48354ceSNicholas Bellinger { 1483e48354ceSNicholas Bellinger struct config_group *stats_cg; 1484e48354ceSNicholas Bellinger struct iscsi_tiqn *tiqn; 1485e48354ceSNicholas Bellinger 1486e48354ceSNicholas Bellinger tiqn = iscsit_add_tiqn((unsigned char *)name); 1487e48354ceSNicholas Bellinger if (IS_ERR(tiqn)) 1488e1750ba2SThomas Meyer return ERR_CAST(tiqn); 1489e48354ceSNicholas Bellinger /* 1490e48354ceSNicholas Bellinger * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group. 1491e48354ceSNicholas Bellinger */ 1492e48354ceSNicholas Bellinger stats_cg = &tiqn->tiqn_wwn.fabric_stat_group; 1493e48354ceSNicholas Bellinger 149413f6a914SSebastian Andrzej Siewior stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6, 1495e48354ceSNicholas Bellinger GFP_KERNEL); 1496e48354ceSNicholas Bellinger if (!stats_cg->default_groups) { 1497e48354ceSNicholas Bellinger pr_err("Unable to allocate memory for" 1498e48354ceSNicholas Bellinger " stats_cg->default_groups\n"); 1499e48354ceSNicholas Bellinger iscsit_del_tiqn(tiqn); 1500e48354ceSNicholas Bellinger return ERR_PTR(-ENOMEM); 1501e48354ceSNicholas Bellinger } 1502e48354ceSNicholas Bellinger 1503b7eec2cdSAndy Grover stats_cg->default_groups[0] = &tiqn->tiqn_stat_grps.iscsi_instance_group; 1504b7eec2cdSAndy Grover stats_cg->default_groups[1] = &tiqn->tiqn_stat_grps.iscsi_sess_err_group; 1505b7eec2cdSAndy Grover stats_cg->default_groups[2] = &tiqn->tiqn_stat_grps.iscsi_tgt_attr_group; 1506b7eec2cdSAndy Grover stats_cg->default_groups[3] = &tiqn->tiqn_stat_grps.iscsi_login_stats_group; 1507b7eec2cdSAndy Grover stats_cg->default_groups[4] = &tiqn->tiqn_stat_grps.iscsi_logout_stats_group; 1508e48354ceSNicholas Bellinger stats_cg->default_groups[5] = NULL; 1509b7eec2cdSAndy Grover config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group, 1510e48354ceSNicholas Bellinger "iscsi_instance", &iscsi_stat_instance_cit); 1511b7eec2cdSAndy Grover config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group, 1512e48354ceSNicholas Bellinger "iscsi_sess_err", &iscsi_stat_sess_err_cit); 1513b7eec2cdSAndy Grover config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group, 1514e48354ceSNicholas Bellinger "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit); 1515b7eec2cdSAndy Grover config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group, 1516e48354ceSNicholas Bellinger "iscsi_login_stats", &iscsi_stat_login_cit); 1517b7eec2cdSAndy Grover config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group, 1518e48354ceSNicholas Bellinger "iscsi_logout_stats", &iscsi_stat_logout_cit); 1519e48354ceSNicholas Bellinger 1520e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn); 1521e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:" 1522e48354ceSNicholas Bellinger " %s\n", name); 1523e48354ceSNicholas Bellinger return &tiqn->tiqn_wwn; 1524e48354ceSNicholas Bellinger } 1525e48354ceSNicholas Bellinger 1526fceb5bc7SChristoph Hellwig static void lio_target_call_coredeltiqn( 1527e48354ceSNicholas Bellinger struct se_wwn *wwn) 1528e48354ceSNicholas Bellinger { 1529e48354ceSNicholas Bellinger struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); 1530e48354ceSNicholas Bellinger struct config_item *df_item; 1531e48354ceSNicholas Bellinger struct config_group *stats_cg; 1532e48354ceSNicholas Bellinger int i; 1533e48354ceSNicholas Bellinger 1534e48354ceSNicholas Bellinger stats_cg = &tiqn->tiqn_wwn.fabric_stat_group; 1535e48354ceSNicholas Bellinger for (i = 0; stats_cg->default_groups[i]; i++) { 1536e48354ceSNicholas Bellinger df_item = &stats_cg->default_groups[i]->cg_item; 1537e48354ceSNicholas Bellinger stats_cg->default_groups[i] = NULL; 1538e48354ceSNicholas Bellinger config_item_put(df_item); 1539e48354ceSNicholas Bellinger } 1540e48354ceSNicholas Bellinger kfree(stats_cg->default_groups); 1541e48354ceSNicholas Bellinger 1542e48354ceSNicholas Bellinger pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n", 1543e48354ceSNicholas Bellinger tiqn->tiqn); 1544e48354ceSNicholas Bellinger iscsit_del_tiqn(tiqn); 1545e48354ceSNicholas Bellinger } 1546e48354ceSNicholas Bellinger 1547e48354ceSNicholas Bellinger /* End LIO-Target TIQN struct contig_lio_target_cit */ 1548e48354ceSNicholas Bellinger 1549e48354ceSNicholas Bellinger /* Start lio_target_discovery_auth_cit */ 1550e48354ceSNicholas Bellinger 1551e48354ceSNicholas Bellinger #define DEF_DISC_AUTH_STR(name, flags) \ 1552e48354ceSNicholas Bellinger __DEF_NACL_AUTH_STR(disc, name, flags) \ 1553e48354ceSNicholas Bellinger static ssize_t iscsi_disc_show_##name( \ 1554e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, \ 1555e48354ceSNicholas Bellinger char *page) \ 1556e48354ceSNicholas Bellinger { \ 1557e48354ceSNicholas Bellinger return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \ 1558e48354ceSNicholas Bellinger page); \ 1559e48354ceSNicholas Bellinger } \ 1560e48354ceSNicholas Bellinger static ssize_t iscsi_disc_store_##name( \ 1561e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, \ 1562e48354ceSNicholas Bellinger const char *page, \ 1563e48354ceSNicholas Bellinger size_t count) \ 1564e48354ceSNicholas Bellinger { \ 1565e48354ceSNicholas Bellinger return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \ 1566e48354ceSNicholas Bellinger page, count); \ 1567e48354ceSNicholas Bellinger } 1568e48354ceSNicholas Bellinger 1569e48354ceSNicholas Bellinger #define DEF_DISC_AUTH_INT(name) \ 1570e48354ceSNicholas Bellinger __DEF_NACL_AUTH_INT(disc, name) \ 1571e48354ceSNicholas Bellinger static ssize_t iscsi_disc_show_##name( \ 1572e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, \ 1573e48354ceSNicholas Bellinger char *page) \ 1574e48354ceSNicholas Bellinger { \ 1575e48354ceSNicholas Bellinger return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \ 1576e48354ceSNicholas Bellinger page); \ 1577e48354ceSNicholas Bellinger } 1578e48354ceSNicholas Bellinger 1579e48354ceSNicholas Bellinger #define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode) 1580e48354ceSNicholas Bellinger #define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name) 1581e48354ceSNicholas Bellinger 1582e48354ceSNicholas Bellinger /* 1583e48354ceSNicholas Bellinger * One-way authentication userid 1584e48354ceSNicholas Bellinger */ 1585e48354ceSNicholas Bellinger DEF_DISC_AUTH_STR(userid, NAF_USERID_SET); 1586e48354ceSNicholas Bellinger DISC_AUTH_ATTR(userid, S_IRUGO | S_IWUSR); 1587e48354ceSNicholas Bellinger /* 1588e48354ceSNicholas Bellinger * One-way authentication password 1589e48354ceSNicholas Bellinger */ 1590e48354ceSNicholas Bellinger DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET); 1591e48354ceSNicholas Bellinger DISC_AUTH_ATTR(password, S_IRUGO | S_IWUSR); 1592e48354ceSNicholas Bellinger /* 1593e48354ceSNicholas Bellinger * Enforce mutual authentication 1594e48354ceSNicholas Bellinger */ 1595e48354ceSNicholas Bellinger DEF_DISC_AUTH_INT(authenticate_target); 1596e48354ceSNicholas Bellinger DISC_AUTH_ATTR_RO(authenticate_target); 1597e48354ceSNicholas Bellinger /* 1598e48354ceSNicholas Bellinger * Mutual authentication userid 1599e48354ceSNicholas Bellinger */ 1600e48354ceSNicholas Bellinger DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 1601e48354ceSNicholas Bellinger DISC_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); 1602e48354ceSNicholas Bellinger /* 1603e48354ceSNicholas Bellinger * Mutual authentication password 1604e48354ceSNicholas Bellinger */ 1605e48354ceSNicholas Bellinger DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 1606e48354ceSNicholas Bellinger DISC_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); 1607e48354ceSNicholas Bellinger 1608e48354ceSNicholas Bellinger /* 1609e48354ceSNicholas Bellinger * enforce_discovery_auth 1610e48354ceSNicholas Bellinger */ 1611e48354ceSNicholas Bellinger static ssize_t iscsi_disc_show_enforce_discovery_auth( 1612e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, 1613e48354ceSNicholas Bellinger char *page) 1614e48354ceSNicholas Bellinger { 1615e48354ceSNicholas Bellinger struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth; 1616e48354ceSNicholas Bellinger 1617e48354ceSNicholas Bellinger return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth); 1618e48354ceSNicholas Bellinger } 1619e48354ceSNicholas Bellinger 1620e48354ceSNicholas Bellinger static ssize_t iscsi_disc_store_enforce_discovery_auth( 1621e48354ceSNicholas Bellinger struct target_fabric_configfs *tf, 1622e48354ceSNicholas Bellinger const char *page, 1623e48354ceSNicholas Bellinger size_t count) 1624e48354ceSNicholas Bellinger { 1625e48354ceSNicholas Bellinger struct iscsi_param *param; 1626e48354ceSNicholas Bellinger struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg; 1627e48354ceSNicholas Bellinger u32 op; 1628ad7babd2SJörn Engel int err; 1629e48354ceSNicholas Bellinger 1630ad7babd2SJörn Engel err = kstrtou32(page, 0, &op); 1631ad7babd2SJörn Engel if (err) 1632ad7babd2SJörn Engel return -EINVAL; 1633e48354ceSNicholas Bellinger if ((op != 1) && (op != 0)) { 1634e48354ceSNicholas Bellinger pr_err("Illegal value for enforce_discovery_auth:" 1635e48354ceSNicholas Bellinger " %u\n", op); 1636e48354ceSNicholas Bellinger return -EINVAL; 1637e48354ceSNicholas Bellinger } 1638e48354ceSNicholas Bellinger 1639e48354ceSNicholas Bellinger if (!discovery_tpg) { 1640e48354ceSNicholas Bellinger pr_err("iscsit_global->discovery_tpg is NULL\n"); 1641e48354ceSNicholas Bellinger return -EINVAL; 1642e48354ceSNicholas Bellinger } 1643e48354ceSNicholas Bellinger 1644e48354ceSNicholas Bellinger param = iscsi_find_param_from_key(AUTHMETHOD, 1645e48354ceSNicholas Bellinger discovery_tpg->param_list); 1646e48354ceSNicholas Bellinger if (!param) 1647e48354ceSNicholas Bellinger return -EINVAL; 1648e48354ceSNicholas Bellinger 1649e48354ceSNicholas Bellinger if (op) { 1650e48354ceSNicholas Bellinger /* 1651e48354ceSNicholas Bellinger * Reset the AuthMethod key to CHAP. 1652e48354ceSNicholas Bellinger */ 1653e48354ceSNicholas Bellinger if (iscsi_update_param_value(param, CHAP) < 0) 1654e48354ceSNicholas Bellinger return -EINVAL; 1655e48354ceSNicholas Bellinger 1656e48354ceSNicholas Bellinger discovery_tpg->tpg_attrib.authentication = 1; 1657e48354ceSNicholas Bellinger iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1; 1658e48354ceSNicholas Bellinger pr_debug("LIO-CORE[0] Successfully enabled" 1659e48354ceSNicholas Bellinger " authentication enforcement for iSCSI" 1660e48354ceSNicholas Bellinger " Discovery TPG\n"); 1661e48354ceSNicholas Bellinger } else { 1662e48354ceSNicholas Bellinger /* 1663e48354ceSNicholas Bellinger * Reset the AuthMethod key to CHAP,None 1664e48354ceSNicholas Bellinger */ 1665e48354ceSNicholas Bellinger if (iscsi_update_param_value(param, "CHAP,None") < 0) 1666e48354ceSNicholas Bellinger return -EINVAL; 1667e48354ceSNicholas Bellinger 1668e48354ceSNicholas Bellinger discovery_tpg->tpg_attrib.authentication = 0; 1669e48354ceSNicholas Bellinger iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0; 1670e48354ceSNicholas Bellinger pr_debug("LIO-CORE[0] Successfully disabled" 1671e48354ceSNicholas Bellinger " authentication enforcement for iSCSI" 1672e48354ceSNicholas Bellinger " Discovery TPG\n"); 1673e48354ceSNicholas Bellinger } 1674e48354ceSNicholas Bellinger 1675e48354ceSNicholas Bellinger return count; 1676e48354ceSNicholas Bellinger } 1677e48354ceSNicholas Bellinger 1678e48354ceSNicholas Bellinger DISC_AUTH_ATTR(enforce_discovery_auth, S_IRUGO | S_IWUSR); 1679e48354ceSNicholas Bellinger 1680e48354ceSNicholas Bellinger static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { 1681e48354ceSNicholas Bellinger &iscsi_disc_userid.attr, 1682e48354ceSNicholas Bellinger &iscsi_disc_password.attr, 1683e48354ceSNicholas Bellinger &iscsi_disc_authenticate_target.attr, 1684e48354ceSNicholas Bellinger &iscsi_disc_userid_mutual.attr, 1685e48354ceSNicholas Bellinger &iscsi_disc_password_mutual.attr, 1686e48354ceSNicholas Bellinger &iscsi_disc_enforce_discovery_auth.attr, 1687e48354ceSNicholas Bellinger NULL, 1688e48354ceSNicholas Bellinger }; 1689e48354ceSNicholas Bellinger 1690e48354ceSNicholas Bellinger /* End lio_target_discovery_auth_cit */ 1691e48354ceSNicholas Bellinger 1692e48354ceSNicholas Bellinger /* Start functions for target_core_fabric_ops */ 1693e48354ceSNicholas Bellinger 1694e48354ceSNicholas Bellinger static char *iscsi_get_fabric_name(void) 1695e48354ceSNicholas Bellinger { 1696e48354ceSNicholas Bellinger return "iSCSI"; 1697e48354ceSNicholas Bellinger } 1698e48354ceSNicholas Bellinger 1699e48354ceSNicholas Bellinger static int iscsi_get_cmd_state(struct se_cmd *se_cmd) 1700e48354ceSNicholas Bellinger { 1701e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1702e48354ceSNicholas Bellinger 1703e48354ceSNicholas Bellinger return cmd->i_state; 1704e48354ceSNicholas Bellinger } 1705e48354ceSNicholas Bellinger 1706e48354ceSNicholas Bellinger static u32 lio_sess_get_index(struct se_session *se_sess) 1707e48354ceSNicholas Bellinger { 1708e48354ceSNicholas Bellinger struct iscsi_session *sess = se_sess->fabric_sess_ptr; 1709e48354ceSNicholas Bellinger 1710e48354ceSNicholas Bellinger return sess->session_index; 1711e48354ceSNicholas Bellinger } 1712e48354ceSNicholas Bellinger 1713e48354ceSNicholas Bellinger static u32 lio_sess_get_initiator_sid( 1714e48354ceSNicholas Bellinger struct se_session *se_sess, 1715e48354ceSNicholas Bellinger unsigned char *buf, 1716e48354ceSNicholas Bellinger u32 size) 1717e48354ceSNicholas Bellinger { 1718e48354ceSNicholas Bellinger struct iscsi_session *sess = se_sess->fabric_sess_ptr; 1719e48354ceSNicholas Bellinger /* 1720e48354ceSNicholas Bellinger * iSCSI Initiator Session Identifier from RFC-3720. 1721e48354ceSNicholas Bellinger */ 17225cdf5a87SAndy Shevchenko return snprintf(buf, size, "%6phN", sess->isid); 1723e48354ceSNicholas Bellinger } 1724e48354ceSNicholas Bellinger 1725e48354ceSNicholas Bellinger static int lio_queue_data_in(struct se_cmd *se_cmd) 1726e48354ceSNicholas Bellinger { 1727e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1728e48354ceSNicholas Bellinger 1729e48354ceSNicholas Bellinger cmd->i_state = ISTATE_SEND_DATAIN; 17302ec5a8c1SNicholas Bellinger cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd); 17312ec5a8c1SNicholas Bellinger 1732e48354ceSNicholas Bellinger return 0; 1733e48354ceSNicholas Bellinger } 1734e48354ceSNicholas Bellinger 1735e48354ceSNicholas Bellinger static int lio_write_pending(struct se_cmd *se_cmd) 1736e48354ceSNicholas Bellinger { 1737e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 17383e1c81a9SNicholas Bellinger struct iscsi_conn *conn = cmd->conn; 1739e48354ceSNicholas Bellinger 1740e48354ceSNicholas Bellinger if (!cmd->immediate_data && !cmd->unsolicited_data) 17413e1c81a9SNicholas Bellinger return conn->conn_transport->iscsit_get_dataout(conn, cmd, false); 1742e48354ceSNicholas Bellinger 1743e48354ceSNicholas Bellinger return 0; 1744e48354ceSNicholas Bellinger } 1745e48354ceSNicholas Bellinger 1746e48354ceSNicholas Bellinger static int lio_write_pending_status(struct se_cmd *se_cmd) 1747e48354ceSNicholas Bellinger { 1748e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1749e48354ceSNicholas Bellinger int ret; 1750e48354ceSNicholas Bellinger 1751e48354ceSNicholas Bellinger spin_lock_bh(&cmd->istate_lock); 1752e48354ceSNicholas Bellinger ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT); 1753e48354ceSNicholas Bellinger spin_unlock_bh(&cmd->istate_lock); 1754e48354ceSNicholas Bellinger 1755e48354ceSNicholas Bellinger return ret; 1756e48354ceSNicholas Bellinger } 1757e48354ceSNicholas Bellinger 1758e48354ceSNicholas Bellinger static int lio_queue_status(struct se_cmd *se_cmd) 1759e48354ceSNicholas Bellinger { 1760e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1761e48354ceSNicholas Bellinger 1762e48354ceSNicholas Bellinger cmd->i_state = ISTATE_SEND_STATUS; 17635e8e6b4bSNicholas Bellinger 17645e8e6b4bSNicholas Bellinger if (cmd->se_cmd.scsi_status || cmd->sense_reason) { 17655e8e6b4bSNicholas Bellinger iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); 17665e8e6b4bSNicholas Bellinger return 0; 17675e8e6b4bSNicholas Bellinger } 17682ec5a8c1SNicholas Bellinger cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd); 17692ec5a8c1SNicholas Bellinger 1770e48354ceSNicholas Bellinger return 0; 1771e48354ceSNicholas Bellinger } 1772e48354ceSNicholas Bellinger 1773b79fafacSJoern Engel static void lio_queue_tm_rsp(struct se_cmd *se_cmd) 1774e48354ceSNicholas Bellinger { 1775e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1776e48354ceSNicholas Bellinger 1777e48354ceSNicholas Bellinger cmd->i_state = ISTATE_SEND_TASKMGTRSP; 1778e48354ceSNicholas Bellinger iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); 1779e48354ceSNicholas Bellinger } 1780e48354ceSNicholas Bellinger 1781131e6abcSNicholas Bellinger static void lio_aborted_task(struct se_cmd *se_cmd) 1782131e6abcSNicholas Bellinger { 1783131e6abcSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1784131e6abcSNicholas Bellinger 1785131e6abcSNicholas Bellinger cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd); 1786131e6abcSNicholas Bellinger } 1787131e6abcSNicholas Bellinger 17882b6eb609SChristoph Hellwig static inline struct iscsi_portal_group *iscsi_tpg(struct se_portal_group *se_tpg) 17892b6eb609SChristoph Hellwig { 17902b6eb609SChristoph Hellwig return container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg); 17912b6eb609SChristoph Hellwig } 17922b6eb609SChristoph Hellwig 1793e48354ceSNicholas Bellinger static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg) 1794e48354ceSNicholas Bellinger { 17952b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn; 1796e48354ceSNicholas Bellinger } 1797e48354ceSNicholas Bellinger 1798e48354ceSNicholas Bellinger static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg) 1799e48354ceSNicholas Bellinger { 18002b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpgt; 1801e48354ceSNicholas Bellinger } 1802e48354ceSNicholas Bellinger 1803e48354ceSNicholas Bellinger static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg) 1804e48354ceSNicholas Bellinger { 18052b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_attrib.default_cmdsn_depth; 1806e48354ceSNicholas Bellinger } 1807e48354ceSNicholas Bellinger 1808e48354ceSNicholas Bellinger static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg) 1809e48354ceSNicholas Bellinger { 18102b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_attrib.generate_node_acls; 1811e48354ceSNicholas Bellinger } 1812e48354ceSNicholas Bellinger 1813e48354ceSNicholas Bellinger static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg) 1814e48354ceSNicholas Bellinger { 18152b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_attrib.cache_dynamic_acls; 1816e48354ceSNicholas Bellinger } 1817e48354ceSNicholas Bellinger 1818e48354ceSNicholas Bellinger static int lio_tpg_check_demo_mode_write_protect( 1819e48354ceSNicholas Bellinger struct se_portal_group *se_tpg) 1820e48354ceSNicholas Bellinger { 18212b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_attrib.demo_mode_write_protect; 1822e48354ceSNicholas Bellinger } 1823e48354ceSNicholas Bellinger 1824e48354ceSNicholas Bellinger static int lio_tpg_check_prod_mode_write_protect( 1825e48354ceSNicholas Bellinger struct se_portal_group *se_tpg) 1826e48354ceSNicholas Bellinger { 18272b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_attrib.prod_mode_write_protect; 1828e48354ceSNicholas Bellinger } 1829e48354ceSNicholas Bellinger 1830901c04a3SNicholas Bellinger static int lio_tpg_check_prot_fabric_only( 1831901c04a3SNicholas Bellinger struct se_portal_group *se_tpg) 1832901c04a3SNicholas Bellinger { 1833901c04a3SNicholas Bellinger /* 1834901c04a3SNicholas Bellinger * Only report fabric_prot_type if t10_pi has also been enabled 1835901c04a3SNicholas Bellinger * for incoming ib_isert sessions. 1836901c04a3SNicholas Bellinger */ 18372b6eb609SChristoph Hellwig if (!iscsi_tpg(se_tpg)->tpg_attrib.t10_pi) 1838901c04a3SNicholas Bellinger return 0; 18392b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_attrib.fabric_prot_type; 1840901c04a3SNicholas Bellinger } 1841901c04a3SNicholas Bellinger 1842e48354ceSNicholas Bellinger /* 1843e48354ceSNicholas Bellinger * Called with spin_lock_bh(struct se_portal_group->session_lock) held.. 1844e48354ceSNicholas Bellinger * 1845e48354ceSNicholas Bellinger * Also, this function calls iscsit_inc_session_usage_count() on the 1846e48354ceSNicholas Bellinger * struct iscsi_session in question. 1847e48354ceSNicholas Bellinger */ 1848e48354ceSNicholas Bellinger static int lio_tpg_shutdown_session(struct se_session *se_sess) 1849e48354ceSNicholas Bellinger { 1850e48354ceSNicholas Bellinger struct iscsi_session *sess = se_sess->fabric_sess_ptr; 1851e48354ceSNicholas Bellinger 1852e48354ceSNicholas Bellinger spin_lock(&sess->conn_lock); 1853e48354ceSNicholas Bellinger if (atomic_read(&sess->session_fall_back_to_erl0) || 1854e48354ceSNicholas Bellinger atomic_read(&sess->session_logout) || 1855e48354ceSNicholas Bellinger (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) { 1856e48354ceSNicholas Bellinger spin_unlock(&sess->conn_lock); 1857e48354ceSNicholas Bellinger return 0; 1858e48354ceSNicholas Bellinger } 1859e48354ceSNicholas Bellinger atomic_set(&sess->session_reinstatement, 1); 1860e48354ceSNicholas Bellinger spin_unlock(&sess->conn_lock); 1861e48354ceSNicholas Bellinger 1862e48354ceSNicholas Bellinger iscsit_stop_time2retain_timer(sess); 186399367f01SNicholas Bellinger iscsit_stop_session(sess, 1, 1); 1864e48354ceSNicholas Bellinger 1865e48354ceSNicholas Bellinger return 1; 1866e48354ceSNicholas Bellinger } 1867e48354ceSNicholas Bellinger 1868e48354ceSNicholas Bellinger /* 1869e48354ceSNicholas Bellinger * Calls iscsit_dec_session_usage_count() as inverse of 1870e48354ceSNicholas Bellinger * lio_tpg_shutdown_session() 1871e48354ceSNicholas Bellinger */ 1872e48354ceSNicholas Bellinger static void lio_tpg_close_session(struct se_session *se_sess) 1873e48354ceSNicholas Bellinger { 1874e48354ceSNicholas Bellinger struct iscsi_session *sess = se_sess->fabric_sess_ptr; 1875e48354ceSNicholas Bellinger /* 1876e48354ceSNicholas Bellinger * If the iSCSI Session for the iSCSI Initiator Node exists, 1877e48354ceSNicholas Bellinger * forcefully shutdown the iSCSI NEXUS. 1878e48354ceSNicholas Bellinger */ 1879e48354ceSNicholas Bellinger iscsit_close_session(sess); 1880e48354ceSNicholas Bellinger } 1881e48354ceSNicholas Bellinger 1882e48354ceSNicholas Bellinger static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg) 1883e48354ceSNicholas Bellinger { 18842b6eb609SChristoph Hellwig return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn_index; 1885e48354ceSNicholas Bellinger } 1886e48354ceSNicholas Bellinger 1887e48354ceSNicholas Bellinger static void lio_set_default_node_attributes(struct se_node_acl *se_acl) 1888e48354ceSNicholas Bellinger { 1889e48354ceSNicholas Bellinger struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl, 1890e48354ceSNicholas Bellinger se_node_acl); 1891d1fa7a1dSNicholas Bellinger struct se_portal_group *se_tpg = se_acl->se_tpg; 1892d1fa7a1dSNicholas Bellinger struct iscsi_portal_group *tpg = container_of(se_tpg, 1893d1fa7a1dSNicholas Bellinger struct iscsi_portal_group, tpg_se_tpg); 1894e48354ceSNicholas Bellinger 1895b7eec2cdSAndy Grover acl->node_attrib.nacl = acl; 1896d1fa7a1dSNicholas Bellinger iscsit_set_default_node_attribues(acl, tpg); 1897e48354ceSNicholas Bellinger } 1898e48354ceSNicholas Bellinger 18993e1c81a9SNicholas Bellinger static int lio_check_stop_free(struct se_cmd *se_cmd) 19003e1c81a9SNicholas Bellinger { 1901afc16604SBart Van Assche return target_put_sess_cmd(se_cmd); 19023e1c81a9SNicholas Bellinger } 19033e1c81a9SNicholas Bellinger 1904e48354ceSNicholas Bellinger static void lio_release_cmd(struct se_cmd *se_cmd) 1905e48354ceSNicholas Bellinger { 1906e48354ceSNicholas Bellinger struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1907e48354ceSNicholas Bellinger 1908cdb72665SNicholas Bellinger pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); 1909d703ce2fSNicholas Bellinger iscsit_release_cmd(cmd); 1910e48354ceSNicholas Bellinger } 1911e48354ceSNicholas Bellinger 19129ac8928eSChristoph Hellwig const struct target_core_fabric_ops iscsi_ops = { 19139ac8928eSChristoph Hellwig .module = THIS_MODULE, 19149ac8928eSChristoph Hellwig .name = "iscsi", 1915144bc4c2SChristoph Hellwig .node_acl_size = sizeof(struct iscsi_node_acl), 19169ac8928eSChristoph Hellwig .get_fabric_name = iscsi_get_fabric_name, 19179ac8928eSChristoph Hellwig .tpg_get_wwn = lio_tpg_get_endpoint_wwn, 19189ac8928eSChristoph Hellwig .tpg_get_tag = lio_tpg_get_tag, 19199ac8928eSChristoph Hellwig .tpg_get_default_depth = lio_tpg_get_default_depth, 19209ac8928eSChristoph Hellwig .tpg_check_demo_mode = lio_tpg_check_demo_mode, 19219ac8928eSChristoph Hellwig .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache, 19229ac8928eSChristoph Hellwig .tpg_check_demo_mode_write_protect = 19239ac8928eSChristoph Hellwig lio_tpg_check_demo_mode_write_protect, 19249ac8928eSChristoph Hellwig .tpg_check_prod_mode_write_protect = 19259ac8928eSChristoph Hellwig lio_tpg_check_prod_mode_write_protect, 19269ac8928eSChristoph Hellwig .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only, 19279ac8928eSChristoph Hellwig .tpg_get_inst_index = lio_tpg_get_inst_index, 19289ac8928eSChristoph Hellwig .check_stop_free = lio_check_stop_free, 19299ac8928eSChristoph Hellwig .release_cmd = lio_release_cmd, 19309ac8928eSChristoph Hellwig .shutdown_session = lio_tpg_shutdown_session, 19319ac8928eSChristoph Hellwig .close_session = lio_tpg_close_session, 19329ac8928eSChristoph Hellwig .sess_get_index = lio_sess_get_index, 19339ac8928eSChristoph Hellwig .sess_get_initiator_sid = lio_sess_get_initiator_sid, 19349ac8928eSChristoph Hellwig .write_pending = lio_write_pending, 19359ac8928eSChristoph Hellwig .write_pending_status = lio_write_pending_status, 19369ac8928eSChristoph Hellwig .set_default_node_attributes = lio_set_default_node_attributes, 19379ac8928eSChristoph Hellwig .get_cmd_state = iscsi_get_cmd_state, 19389ac8928eSChristoph Hellwig .queue_data_in = lio_queue_data_in, 19399ac8928eSChristoph Hellwig .queue_status = lio_queue_status, 19409ac8928eSChristoph Hellwig .queue_tm_rsp = lio_queue_tm_rsp, 19419ac8928eSChristoph Hellwig .aborted_task = lio_aborted_task, 19429ac8928eSChristoph Hellwig .fabric_make_wwn = lio_target_call_coreaddtiqn, 19439ac8928eSChristoph Hellwig .fabric_drop_wwn = lio_target_call_coredeltiqn, 19449ac8928eSChristoph Hellwig .fabric_make_tpg = lio_target_tiqn_addtpg, 19459ac8928eSChristoph Hellwig .fabric_drop_tpg = lio_target_tiqn_deltpg, 19469ac8928eSChristoph Hellwig .fabric_make_np = lio_target_call_addnptotpg, 19479ac8928eSChristoph Hellwig .fabric_drop_np = lio_target_call_delnpfromtpg, 1948c7d6a803SChristoph Hellwig .fabric_init_nodeacl = lio_target_init_nodeacl, 1949c7d6a803SChristoph Hellwig .fabric_cleanup_nodeacl = lio_target_cleanup_nodeacl, 1950e48354ceSNicholas Bellinger 19519ac8928eSChristoph Hellwig .tfc_discovery_attrs = lio_target_discovery_auth_attrs, 19529ac8928eSChristoph Hellwig .tfc_wwn_attrs = lio_target_wwn_attrs, 19539ac8928eSChristoph Hellwig .tfc_tpg_base_attrs = lio_target_tpg_attrs, 19549ac8928eSChristoph Hellwig .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs, 19559ac8928eSChristoph Hellwig .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs, 19569ac8928eSChristoph Hellwig .tfc_tpg_param_attrs = lio_target_tpg_param_attrs, 19579ac8928eSChristoph Hellwig .tfc_tpg_np_base_attrs = lio_target_portal_attrs, 19589ac8928eSChristoph Hellwig .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs, 19599ac8928eSChristoph Hellwig .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs, 19609ac8928eSChristoph Hellwig .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs, 19619ac8928eSChristoph Hellwig .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs, 19629ac8928eSChristoph Hellwig }; 1963