Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 2 | /******************************************************************************* |
| 3 | * Filename: target_core_fabric_configfs.c |
| 4 | * |
| 5 | * This file contains generic fabric module configfs infrastructure for |
| 6 | * TCM v4.x code |
| 7 | * |
Nicholas Bellinger | 4c76251 | 2013-09-05 15:29:12 -0700 | [diff] [blame] | 8 | * (c) Copyright 2010-2013 Datera, Inc. |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 9 | * |
Nicholas Bellinger | fd9a11d | 2012-11-09 14:51:48 -0800 | [diff] [blame] | 10 | * Nicholas A. Bellinger <nab@linux-iscsi.org> |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 11 | * |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 12 | ****************************************************************************/ |
| 13 | |
Christophe JAILLET | e56ca6b | 2022-11-01 22:13:52 +0100 | [diff] [blame] | 14 | #include <linux/kstrtox.h> |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 15 | #include <linux/module.h> |
| 16 | #include <linux/moduleparam.h> |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 17 | #include <linux/utsname.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/fs.h> |
| 20 | #include <linux/namei.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/types.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/unistd.h> |
| 25 | #include <linux/string.h> |
| 26 | #include <linux/syscalls.h> |
| 27 | #include <linux/configfs.h> |
| 28 | |
| 29 | #include <target/target_core_base.h> |
Mike Christie | cb0f32e | 2018-07-23 14:07:45 -0500 | [diff] [blame] | 30 | #include <target/target_core_backend.h> |
Christoph Hellwig | c4795fb | 2011-11-16 09:46:48 -0500 | [diff] [blame] | 31 | #include <target/target_core_fabric.h> |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 32 | |
Christoph Hellwig | e26d99a | 2011-11-14 12:30:30 -0500 | [diff] [blame] | 33 | #include "target_core_internal.h" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 34 | #include "target_core_alua.h" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 35 | #include "target_core_pr.h" |
| 36 | |
| 37 | #define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \ |
| 38 | static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \ |
| 39 | { \ |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 40 | struct config_item_type *cit = &tf->tf_##_name##_cit; \ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 41 | \ |
| 42 | cit->ct_item_ops = _item_ops; \ |
| 43 | cit->ct_group_ops = _group_ops; \ |
| 44 | cit->ct_attrs = _attrs; \ |
Christoph Hellwig | 0dc2e8d | 2015-05-03 08:50:54 +0200 | [diff] [blame] | 45 | cit->ct_owner = tf->tf_ops->module; \ |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 46 | pr_debug("Setup generic %s\n", __stringify(_name)); \ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 47 | } |
| 48 | |
Christoph Hellwig | 9ac8928 | 2015-04-08 20:01:35 +0200 | [diff] [blame] | 49 | #define TF_CIT_SETUP_DRV(_name, _item_ops, _group_ops) \ |
| 50 | static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \ |
| 51 | { \ |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 52 | struct config_item_type *cit = &tf->tf_##_name##_cit; \ |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 53 | struct configfs_attribute **attrs = tf->tf_ops->tfc_##_name##_attrs; \ |
Christoph Hellwig | 9ac8928 | 2015-04-08 20:01:35 +0200 | [diff] [blame] | 54 | \ |
| 55 | cit->ct_item_ops = _item_ops; \ |
| 56 | cit->ct_group_ops = _group_ops; \ |
| 57 | cit->ct_attrs = attrs; \ |
Christoph Hellwig | 0dc2e8d | 2015-05-03 08:50:54 +0200 | [diff] [blame] | 58 | cit->ct_owner = tf->tf_ops->module; \ |
Christoph Hellwig | 9ac8928 | 2015-04-08 20:01:35 +0200 | [diff] [blame] | 59 | pr_debug("Setup generic %s\n", __stringify(_name)); \ |
| 60 | } |
| 61 | |
Nicholas Bellinger | 9ae0e9ad | 2017-06-01 03:11:18 -0700 | [diff] [blame] | 62 | static struct configfs_item_operations target_fabric_port_item_ops; |
| 63 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 64 | /* Start of tfc_tpg_mappedlun_cit */ |
| 65 | |
| 66 | static int target_fabric_mappedlun_link( |
| 67 | struct config_item *lun_acl_ci, |
| 68 | struct config_item *lun_ci) |
| 69 | { |
| 70 | struct se_dev_entry *deve; |
Nicholas Bellinger | 9ae0e9ad | 2017-06-01 03:11:18 -0700 | [diff] [blame] | 71 | struct se_lun *lun; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 72 | struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), |
| 73 | struct se_lun_acl, se_lun_group); |
| 74 | struct se_portal_group *se_tpg; |
| 75 | struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s; |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 76 | bool lun_access_ro; |
Nicholas Bellinger | 0ff8754 | 2012-12-04 23:43:57 -0800 | [diff] [blame] | 77 | |
Nicholas Bellinger | 9ae0e9ad | 2017-06-01 03:11:18 -0700 | [diff] [blame] | 78 | if (!lun_ci->ci_type || |
| 79 | lun_ci->ci_type->ct_item_ops != &target_fabric_port_item_ops) { |
| 80 | pr_err("Bad lun_ci, not a valid lun_ci pointer: %p\n", lun_ci); |
Nicholas Bellinger | 0ff8754 | 2012-12-04 23:43:57 -0800 | [diff] [blame] | 81 | return -EFAULT; |
| 82 | } |
Nicholas Bellinger | 9ae0e9ad | 2017-06-01 03:11:18 -0700 | [diff] [blame] | 83 | lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group); |
| 84 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 85 | /* |
| 86 | * Ensure that the source port exists |
| 87 | */ |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 88 | if (!lun->lun_se_dev) { |
| 89 | pr_err("Source se_lun->lun_se_dev does not exist\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 90 | return -EINVAL; |
| 91 | } |
Nicholas Bellinger | 49cb77e | 2017-03-27 16:12:43 -0700 | [diff] [blame] | 92 | if (lun->lun_shutdown) { |
| 93 | pr_err("Unable to create mappedlun symlink because" |
| 94 | " lun->lun_shutdown=true\n"); |
| 95 | return -EINVAL; |
| 96 | } |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 97 | se_tpg = lun->lun_tpg; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 98 | |
| 99 | nacl_ci = &lun_acl_ci->ci_parent->ci_group->cg_item; |
| 100 | tpg_ci = &nacl_ci->ci_group->cg_item; |
| 101 | wwn_ci = &tpg_ci->ci_group->cg_item; |
| 102 | tpg_ci_s = &lun_ci->ci_parent->ci_group->cg_item; |
| 103 | wwn_ci_s = &tpg_ci_s->ci_group->cg_item; |
| 104 | /* |
| 105 | * Make sure the SymLink is going to the same $FABRIC/$WWN/tpgt_$TPGT |
| 106 | */ |
| 107 | if (strcmp(config_item_name(wwn_ci), config_item_name(wwn_ci_s))) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 108 | pr_err("Illegal Initiator ACL SymLink outside of %s\n", |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 109 | config_item_name(wwn_ci)); |
| 110 | return -EINVAL; |
| 111 | } |
| 112 | if (strcmp(config_item_name(tpg_ci), config_item_name(tpg_ci_s))) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 113 | pr_err("Illegal Initiator ACL Symlink outside of %s" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 114 | " TPGT: %s\n", config_item_name(wwn_ci), |
| 115 | config_item_name(tpg_ci)); |
| 116 | return -EINVAL; |
| 117 | } |
| 118 | /* |
| 119 | * If this struct se_node_acl was dynamically generated with |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 120 | * tpg_1/attrib/generate_node_acls=1, use the existing |
| 121 | * deve->lun_access_ro value, which will be true when |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 122 | * tpg_1/attrib/demo_mode_write_protect=1 |
| 123 | */ |
Nicholas Bellinger | 29a05de | 2015-03-22 20:42:19 -0700 | [diff] [blame] | 124 | rcu_read_lock(); |
| 125 | deve = target_nacl_find_deve(lacl->se_lun_nacl, lacl->mapped_lun); |
| 126 | if (deve) |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 127 | lun_access_ro = deve->lun_access_ro; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 128 | else |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 129 | lun_access_ro = |
Andy Grover | e3d6f90 | 2011-07-19 08:55:10 +0000 | [diff] [blame] | 130 | (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect( |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 131 | se_tpg)) ? true : false; |
Nicholas Bellinger | 29a05de | 2015-03-22 20:42:19 -0700 | [diff] [blame] | 132 | rcu_read_unlock(); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 133 | /* |
| 134 | * Determine the actual mapped LUN value user wants.. |
| 135 | * |
| 136 | * This value is what the SCSI Initiator actually sees the |
Nicholas Bellinger | 6bb8261 | 2015-05-10 19:31:10 -0700 | [diff] [blame] | 137 | * $FABRIC/$WWPN/$TPGT/lun/lun_* as on their SCSI Initiator Ports. |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 138 | */ |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 139 | return core_dev_add_initiator_node_lun_acl(se_tpg, lacl, lun, lun_access_ro); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Andrzej Pietrasiewicz | e16769d | 2016-11-28 13:22:42 +0100 | [diff] [blame] | 142 | static void target_fabric_mappedlun_unlink( |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 143 | struct config_item *lun_acl_ci, |
| 144 | struct config_item *lun_ci) |
| 145 | { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 146 | struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), |
| 147 | struct se_lun_acl, se_lun_group); |
Nicholas Bellinger | 29a05de | 2015-03-22 20:42:19 -0700 | [diff] [blame] | 148 | struct se_lun *lun = container_of(to_config_group(lun_ci), |
| 149 | struct se_lun, lun_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 150 | |
Andrzej Pietrasiewicz | e16769d | 2016-11-28 13:22:42 +0100 | [diff] [blame] | 151 | core_dev_del_initiator_node_lun_acl(lun, lacl); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 152 | } |
| 153 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 154 | static struct se_lun_acl *item_to_lun_acl(struct config_item *item) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 155 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 156 | return container_of(to_config_group(item), struct se_lun_acl, |
| 157 | se_lun_group); |
| 158 | } |
| 159 | |
| 160 | static ssize_t target_fabric_mappedlun_write_protect_show( |
| 161 | struct config_item *item, char *page) |
| 162 | { |
| 163 | struct se_lun_acl *lacl = item_to_lun_acl(item); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 164 | struct se_node_acl *se_nacl = lacl->se_lun_nacl; |
| 165 | struct se_dev_entry *deve; |
Nicholas Bellinger | 29a05de | 2015-03-22 20:42:19 -0700 | [diff] [blame] | 166 | ssize_t len = 0; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 167 | |
Nicholas Bellinger | 29a05de | 2015-03-22 20:42:19 -0700 | [diff] [blame] | 168 | rcu_read_lock(); |
| 169 | deve = target_nacl_find_deve(se_nacl, lacl->mapped_lun); |
| 170 | if (deve) { |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 171 | len = sprintf(page, "%d\n", deve->lun_access_ro); |
Nicholas Bellinger | 29a05de | 2015-03-22 20:42:19 -0700 | [diff] [blame] | 172 | } |
| 173 | rcu_read_unlock(); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 174 | |
| 175 | return len; |
| 176 | } |
| 177 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 178 | static ssize_t target_fabric_mappedlun_write_protect_store( |
| 179 | struct config_item *item, const char *page, size_t count) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 180 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 181 | struct se_lun_acl *lacl = item_to_lun_acl(item); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 182 | struct se_node_acl *se_nacl = lacl->se_lun_nacl; |
| 183 | struct se_portal_group *se_tpg = se_nacl->se_tpg; |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 184 | unsigned long wp; |
Jingoo Han | 57103d7 | 2013-07-19 16:22:19 +0900 | [diff] [blame] | 185 | int ret; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 186 | |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 187 | ret = kstrtoul(page, 0, &wp); |
Jingoo Han | 57103d7 | 2013-07-19 16:22:19 +0900 | [diff] [blame] | 188 | if (ret) |
| 189 | return ret; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 190 | |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 191 | if ((wp != 1) && (wp != 0)) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 192 | return -EINVAL; |
| 193 | |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 194 | /* wp=1 means lun_access_ro=true */ |
| 195 | core_update_device_list_access(lacl->mapped_lun, wp, lacl->se_lun_nacl); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 196 | |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 197 | pr_debug("%s_ConfigFS: Changed Initiator ACL: %s" |
Hannes Reinecke | f2d3068 | 2015-06-10 08:41:22 +0200 | [diff] [blame] | 198 | " Mapped LUN: %llu Write Protect bit to %s\n", |
David Disseldorp | 30c7ca9 | 2018-11-23 18:36:12 +0100 | [diff] [blame] | 199 | se_tpg->se_tpg_tfo->fabric_name, |
Andy Grover | 03a68b4 | 2016-02-25 15:14:32 -0800 | [diff] [blame] | 200 | se_nacl->initiatorname, lacl->mapped_lun, (wp) ? "ON" : "OFF"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 201 | |
| 202 | return count; |
| 203 | |
| 204 | } |
| 205 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 206 | CONFIGFS_ATTR(target_fabric_mappedlun_, write_protect); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 207 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 208 | static struct configfs_attribute *target_fabric_mappedlun_attrs[] = { |
| 209 | &target_fabric_mappedlun_attr_write_protect, |
| 210 | NULL, |
| 211 | }; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 212 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 213 | static void target_fabric_mappedlun_release(struct config_item *item) |
| 214 | { |
| 215 | struct se_lun_acl *lacl = container_of(to_config_group(item), |
| 216 | struct se_lun_acl, se_lun_group); |
| 217 | struct se_portal_group *se_tpg = lacl->se_lun_nacl->se_tpg; |
| 218 | |
| 219 | core_dev_free_initiator_node_lun_acl(se_tpg, lacl); |
| 220 | } |
| 221 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 222 | static struct configfs_item_operations target_fabric_mappedlun_item_ops = { |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 223 | .release = target_fabric_mappedlun_release, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 224 | .allow_link = target_fabric_mappedlun_link, |
| 225 | .drop_link = target_fabric_mappedlun_unlink, |
| 226 | }; |
| 227 | |
| 228 | TF_CIT_SETUP(tpg_mappedlun, &target_fabric_mappedlun_item_ops, NULL, |
| 229 | target_fabric_mappedlun_attrs); |
| 230 | |
| 231 | /* End of tfc_tpg_mappedlun_cit */ |
| 232 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 233 | /* Start of tfc_tpg_mappedlun_port_cit */ |
| 234 | |
| 235 | static struct config_group *target_core_mappedlun_stat_mkdir( |
| 236 | struct config_group *group, |
| 237 | const char *name) |
| 238 | { |
| 239 | return ERR_PTR(-ENOSYS); |
| 240 | } |
| 241 | |
| 242 | static void target_core_mappedlun_stat_rmdir( |
| 243 | struct config_group *group, |
| 244 | struct config_item *item) |
| 245 | { |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | static struct configfs_group_operations target_fabric_mappedlun_stat_group_ops = { |
| 250 | .make_group = target_core_mappedlun_stat_mkdir, |
| 251 | .drop_item = target_core_mappedlun_stat_rmdir, |
| 252 | }; |
| 253 | |
| 254 | TF_CIT_SETUP(tpg_mappedlun_stat, NULL, &target_fabric_mappedlun_stat_group_ops, |
| 255 | NULL); |
| 256 | |
| 257 | /* End of tfc_tpg_mappedlun_port_cit */ |
| 258 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 259 | TF_CIT_SETUP_DRV(tpg_nacl_attrib, NULL, NULL); |
| 260 | TF_CIT_SETUP_DRV(tpg_nacl_auth, NULL, NULL); |
| 261 | TF_CIT_SETUP_DRV(tpg_nacl_param, NULL, NULL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 262 | |
| 263 | /* Start of tfc_tpg_nacl_base_cit */ |
| 264 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 265 | static struct config_group *target_fabric_make_mappedlun( |
| 266 | struct config_group *group, |
| 267 | const char *name) |
| 268 | { |
| 269 | struct se_node_acl *se_nacl = container_of(group, |
| 270 | struct se_node_acl, acl_group); |
| 271 | struct se_portal_group *se_tpg = se_nacl->se_tpg; |
| 272 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
Joern Engel | da0abae | 2014-09-02 17:49:57 -0400 | [diff] [blame] | 273 | struct se_lun_acl *lacl = NULL; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 274 | char *buf; |
Hannes Reinecke | f2d3068 | 2015-06-10 08:41:22 +0200 | [diff] [blame] | 275 | unsigned long long mapped_lun; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 276 | int ret = 0; |
| 277 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 278 | buf = kzalloc(strlen(name) + 1, GFP_KERNEL); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 279 | if (!buf) { |
| 280 | pr_err("Unable to allocate memory for name buf\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 281 | return ERR_PTR(-ENOMEM); |
| 282 | } |
| 283 | snprintf(buf, strlen(name) + 1, "%s", name); |
| 284 | /* |
| 285 | * Make sure user is creating iscsi/$IQN/$TPGT/acls/$INITIATOR/lun_$ID. |
| 286 | */ |
| 287 | if (strstr(buf, "lun_") != buf) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 288 | pr_err("Unable to locate \"lun_\" from buf: %s" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 289 | " name: %s\n", buf, name); |
| 290 | ret = -EINVAL; |
| 291 | goto out; |
| 292 | } |
| 293 | /* |
| 294 | * Determine the Mapped LUN value. This is what the SCSI Initiator |
| 295 | * Port will actually see. |
| 296 | */ |
Hannes Reinecke | f2d3068 | 2015-06-10 08:41:22 +0200 | [diff] [blame] | 297 | ret = kstrtoull(buf + 4, 0, &mapped_lun); |
Jingoo Han | 57103d7 | 2013-07-19 16:22:19 +0900 | [diff] [blame] | 298 | if (ret) |
| 299 | goto out; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 300 | |
Nicholas Bellinger | fcf2948 | 2013-02-18 18:00:33 -0800 | [diff] [blame] | 301 | lacl = core_dev_init_initiator_node_lun_acl(se_tpg, se_nacl, |
| 302 | mapped_lun, &ret); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 303 | if (!lacl) { |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 304 | ret = -EINVAL; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 305 | goto out; |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 308 | config_group_init_type_name(&lacl->se_lun_group, name, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 309 | &tf->tf_tpg_mappedlun_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 310 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 311 | config_group_init_type_name(&lacl->ml_stat_grps.stat_group, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 312 | "statistics", &tf->tf_tpg_mappedlun_stat_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 313 | configfs_add_default_group(&lacl->ml_stat_grps.stat_group, |
| 314 | &lacl->se_lun_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 315 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 316 | target_stat_setup_mappedlun_default_groups(lacl); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 317 | |
| 318 | kfree(buf); |
| 319 | return &lacl->se_lun_group; |
| 320 | out: |
Joern Engel | da0abae | 2014-09-02 17:49:57 -0400 | [diff] [blame] | 321 | kfree(lacl); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 322 | kfree(buf); |
| 323 | return ERR_PTR(ret); |
| 324 | } |
| 325 | |
| 326 | static void target_fabric_drop_mappedlun( |
| 327 | struct config_group *group, |
| 328 | struct config_item *item) |
| 329 | { |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 330 | struct se_lun_acl *lacl = container_of(to_config_group(item), |
| 331 | struct se_lun_acl, se_lun_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 332 | |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 333 | configfs_remove_default_groups(&lacl->ml_stat_grps.stat_group); |
| 334 | configfs_remove_default_groups(&lacl->se_lun_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 335 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 336 | config_item_put(item); |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | static void target_fabric_nacl_base_release(struct config_item *item) |
| 340 | { |
| 341 | struct se_node_acl *se_nacl = container_of(to_config_group(item), |
| 342 | struct se_node_acl, acl_group); |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 343 | |
Christoph Hellwig | ce7043f | 2016-03-29 13:03:33 +0200 | [diff] [blame] | 344 | configfs_remove_default_groups(&se_nacl->acl_fabric_stat_group); |
Christoph Hellwig | c7d6a80 | 2015-04-13 19:51:14 +0200 | [diff] [blame] | 345 | core_tpg_del_initiator_node_acl(se_nacl); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | static struct configfs_item_operations target_fabric_nacl_base_item_ops = { |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 349 | .release = target_fabric_nacl_base_release, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 350 | }; |
| 351 | |
| 352 | static struct configfs_group_operations target_fabric_nacl_base_group_ops = { |
| 353 | .make_group = target_fabric_make_mappedlun, |
| 354 | .drop_item = target_fabric_drop_mappedlun, |
| 355 | }; |
| 356 | |
Christoph Hellwig | 9ac8928 | 2015-04-08 20:01:35 +0200 | [diff] [blame] | 357 | TF_CIT_SETUP_DRV(tpg_nacl_base, &target_fabric_nacl_base_item_ops, |
| 358 | &target_fabric_nacl_base_group_ops); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 359 | |
| 360 | /* End of tfc_tpg_nacl_base_cit */ |
| 361 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 362 | /* Start of tfc_node_fabric_stats_cit */ |
| 363 | /* |
| 364 | * This is used as a placeholder for struct se_node_acl->acl_fabric_stat_group |
| 365 | * to allow fabrics access to ->acl_fabric_stat_group->default_groups[] |
| 366 | */ |
| 367 | TF_CIT_SETUP(tpg_nacl_stat, NULL, NULL, NULL); |
| 368 | |
| 369 | /* End of tfc_wwn_fabric_stats_cit */ |
| 370 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 371 | /* Start of tfc_tpg_nacl_cit */ |
| 372 | |
| 373 | static struct config_group *target_fabric_make_nodeacl( |
| 374 | struct config_group *group, |
| 375 | const char *name) |
| 376 | { |
| 377 | struct se_portal_group *se_tpg = container_of(group, |
| 378 | struct se_portal_group, tpg_acl_group); |
| 379 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
| 380 | struct se_node_acl *se_nacl; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 381 | |
Christoph Hellwig | c7d6a80 | 2015-04-13 19:51:14 +0200 | [diff] [blame] | 382 | se_nacl = core_tpg_add_initiator_node_acl(se_tpg, name); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 383 | if (IS_ERR(se_nacl)) |
Thomas Meyer | e1750ba | 2011-08-01 23:58:18 +0200 | [diff] [blame] | 384 | return ERR_CAST(se_nacl); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 385 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 386 | config_group_init_type_name(&se_nacl->acl_group, name, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 387 | &tf->tf_tpg_nacl_base_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 388 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 389 | config_group_init_type_name(&se_nacl->acl_attrib_group, "attrib", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 390 | &tf->tf_tpg_nacl_attrib_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 391 | configfs_add_default_group(&se_nacl->acl_attrib_group, |
| 392 | &se_nacl->acl_group); |
| 393 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 394 | config_group_init_type_name(&se_nacl->acl_auth_group, "auth", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 395 | &tf->tf_tpg_nacl_auth_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 396 | configfs_add_default_group(&se_nacl->acl_auth_group, |
| 397 | &se_nacl->acl_group); |
| 398 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 399 | config_group_init_type_name(&se_nacl->acl_param_group, "param", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 400 | &tf->tf_tpg_nacl_param_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 401 | configfs_add_default_group(&se_nacl->acl_param_group, |
| 402 | &se_nacl->acl_group); |
| 403 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 404 | config_group_init_type_name(&se_nacl->acl_fabric_stat_group, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 405 | "fabric_statistics", &tf->tf_tpg_nacl_stat_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 406 | configfs_add_default_group(&se_nacl->acl_fabric_stat_group, |
| 407 | &se_nacl->acl_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 408 | |
Christoph Hellwig | e6e202e | 2016-03-29 13:03:34 +0200 | [diff] [blame] | 409 | if (tf->tf_ops->fabric_init_nodeacl) { |
| 410 | int ret = tf->tf_ops->fabric_init_nodeacl(se_nacl, name); |
| 411 | if (ret) { |
| 412 | configfs_remove_default_groups(&se_nacl->acl_fabric_stat_group); |
| 413 | core_tpg_del_initiator_node_acl(se_nacl); |
| 414 | return ERR_PTR(ret); |
| 415 | } |
| 416 | } |
| 417 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 418 | return &se_nacl->acl_group; |
| 419 | } |
| 420 | |
| 421 | static void target_fabric_drop_nodeacl( |
| 422 | struct config_group *group, |
| 423 | struct config_item *item) |
| 424 | { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 425 | struct se_node_acl *se_nacl = container_of(to_config_group(item), |
| 426 | struct se_node_acl, acl_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 427 | |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 428 | configfs_remove_default_groups(&se_nacl->acl_group); |
| 429 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 430 | /* |
| 431 | * struct se_node_acl free is done in target_fabric_nacl_base_release() |
| 432 | */ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 433 | config_item_put(item); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | static struct configfs_group_operations target_fabric_nacl_group_ops = { |
| 437 | .make_group = target_fabric_make_nodeacl, |
| 438 | .drop_item = target_fabric_drop_nodeacl, |
| 439 | }; |
| 440 | |
| 441 | TF_CIT_SETUP(tpg_nacl, NULL, &target_fabric_nacl_group_ops, NULL); |
| 442 | |
| 443 | /* End of tfc_tpg_nacl_cit */ |
| 444 | |
| 445 | /* Start of tfc_tpg_np_base_cit */ |
| 446 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 447 | static void target_fabric_np_base_release(struct config_item *item) |
| 448 | { |
| 449 | struct se_tpg_np *se_tpg_np = container_of(to_config_group(item), |
| 450 | struct se_tpg_np, tpg_np_group); |
| 451 | struct se_portal_group *se_tpg = se_tpg_np->tpg_np_parent; |
| 452 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
| 453 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 454 | tf->tf_ops->fabric_drop_np(se_tpg_np); |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 455 | } |
| 456 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 457 | static struct configfs_item_operations target_fabric_np_base_item_ops = { |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 458 | .release = target_fabric_np_base_release, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 459 | }; |
| 460 | |
Christoph Hellwig | 9ac8928 | 2015-04-08 20:01:35 +0200 | [diff] [blame] | 461 | TF_CIT_SETUP_DRV(tpg_np_base, &target_fabric_np_base_item_ops, NULL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 462 | |
| 463 | /* End of tfc_tpg_np_base_cit */ |
| 464 | |
| 465 | /* Start of tfc_tpg_np_cit */ |
| 466 | |
| 467 | static struct config_group *target_fabric_make_np( |
| 468 | struct config_group *group, |
| 469 | const char *name) |
| 470 | { |
| 471 | struct se_portal_group *se_tpg = container_of(group, |
| 472 | struct se_portal_group, tpg_np_group); |
| 473 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
| 474 | struct se_tpg_np *se_tpg_np; |
| 475 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 476 | if (!tf->tf_ops->fabric_make_np) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 477 | pr_err("tf->tf_ops.fabric_make_np is NULL\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 478 | return ERR_PTR(-ENOSYS); |
| 479 | } |
| 480 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 481 | se_tpg_np = tf->tf_ops->fabric_make_np(se_tpg, group, name); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 482 | if (!se_tpg_np || IS_ERR(se_tpg_np)) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 483 | return ERR_PTR(-EINVAL); |
| 484 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 485 | se_tpg_np->tpg_np_parent = se_tpg; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 486 | config_group_init_type_name(&se_tpg_np->tpg_np_group, name, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 487 | &tf->tf_tpg_np_base_cit); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 488 | |
| 489 | return &se_tpg_np->tpg_np_group; |
| 490 | } |
| 491 | |
| 492 | static void target_fabric_drop_np( |
| 493 | struct config_group *group, |
| 494 | struct config_item *item) |
| 495 | { |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 496 | /* |
| 497 | * struct se_tpg_np is released via target_fabric_np_base_release() |
| 498 | */ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 499 | config_item_put(item); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | static struct configfs_group_operations target_fabric_np_group_ops = { |
| 503 | .make_group = &target_fabric_make_np, |
| 504 | .drop_item = &target_fabric_drop_np, |
| 505 | }; |
| 506 | |
| 507 | TF_CIT_SETUP(tpg_np, NULL, &target_fabric_np_group_ops, NULL); |
| 508 | |
| 509 | /* End of tfc_tpg_np_cit */ |
| 510 | |
| 511 | /* Start of tfc_tpg_port_cit */ |
| 512 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 513 | static struct se_lun *item_to_lun(struct config_item *item) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 514 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 515 | return container_of(to_config_group(item), struct se_lun, |
| 516 | lun_group); |
| 517 | } |
| 518 | |
| 519 | static ssize_t target_fabric_port_alua_tg_pt_gp_show(struct config_item *item, |
| 520 | char *page) |
| 521 | { |
| 522 | struct se_lun *lun = item_to_lun(item); |
| 523 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 524 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 525 | return -ENODEV; |
| 526 | |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 527 | return core_alua_show_tg_pt_gp_info(lun, page); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 528 | } |
| 529 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 530 | static ssize_t target_fabric_port_alua_tg_pt_gp_store(struct config_item *item, |
| 531 | const char *page, size_t count) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 532 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 533 | struct se_lun *lun = item_to_lun(item); |
| 534 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 535 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 536 | return -ENODEV; |
| 537 | |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 538 | return core_alua_store_tg_pt_gp_info(lun, page, count); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 539 | } |
| 540 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 541 | static ssize_t target_fabric_port_alua_tg_pt_offline_show( |
| 542 | struct config_item *item, char *page) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 543 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 544 | struct se_lun *lun = item_to_lun(item); |
| 545 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 546 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 547 | return -ENODEV; |
| 548 | |
| 549 | return core_alua_show_offline_bit(lun, page); |
| 550 | } |
| 551 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 552 | static ssize_t target_fabric_port_alua_tg_pt_offline_store( |
| 553 | struct config_item *item, const char *page, size_t count) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 554 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 555 | struct se_lun *lun = item_to_lun(item); |
| 556 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 557 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 558 | return -ENODEV; |
| 559 | |
| 560 | return core_alua_store_offline_bit(lun, page, count); |
| 561 | } |
| 562 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 563 | static ssize_t target_fabric_port_alua_tg_pt_status_show( |
| 564 | struct config_item *item, char *page) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 565 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 566 | struct se_lun *lun = item_to_lun(item); |
| 567 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 568 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 569 | return -ENODEV; |
| 570 | |
| 571 | return core_alua_show_secondary_status(lun, page); |
| 572 | } |
| 573 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 574 | static ssize_t target_fabric_port_alua_tg_pt_status_store( |
| 575 | struct config_item *item, const char *page, size_t count) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 576 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 577 | struct se_lun *lun = item_to_lun(item); |
| 578 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 579 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 580 | return -ENODEV; |
| 581 | |
| 582 | return core_alua_store_secondary_status(lun, page, count); |
| 583 | } |
| 584 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 585 | static ssize_t target_fabric_port_alua_tg_pt_write_md_show( |
| 586 | struct config_item *item, char *page) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 587 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 588 | struct se_lun *lun = item_to_lun(item); |
| 589 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 590 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 591 | return -ENODEV; |
| 592 | |
| 593 | return core_alua_show_secondary_write_metadata(lun, page); |
| 594 | } |
| 595 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 596 | static ssize_t target_fabric_port_alua_tg_pt_write_md_store( |
| 597 | struct config_item *item, const char *page, size_t count) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 598 | { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 599 | struct se_lun *lun = item_to_lun(item); |
| 600 | |
Dan Carpenter | 9c6603e1 | 2021-11-18 11:49:00 +0300 | [diff] [blame] | 601 | if (!lun->lun_se_dev) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 602 | return -ENODEV; |
| 603 | |
| 604 | return core_alua_store_secondary_write_metadata(lun, page, count); |
| 605 | } |
| 606 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 607 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_gp); |
| 608 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_offline); |
| 609 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_status); |
| 610 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_write_md); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 611 | |
| 612 | static struct configfs_attribute *target_fabric_port_attrs[] = { |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 613 | &target_fabric_port_attr_alua_tg_pt_gp, |
| 614 | &target_fabric_port_attr_alua_tg_pt_offline, |
| 615 | &target_fabric_port_attr_alua_tg_pt_status, |
| 616 | &target_fabric_port_attr_alua_tg_pt_write_md, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 617 | NULL, |
| 618 | }; |
| 619 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 620 | static int target_fabric_port_link( |
| 621 | struct config_item *lun_ci, |
| 622 | struct config_item *se_dev_ci) |
| 623 | { |
| 624 | struct config_item *tpg_ci; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 625 | struct se_lun *lun = container_of(to_config_group(lun_ci), |
| 626 | struct se_lun, lun_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 627 | struct se_portal_group *se_tpg; |
Nicholas Bellinger | c17cd24 | 2017-06-01 03:10:53 -0700 | [diff] [blame] | 628 | struct se_device *dev; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 629 | struct target_fabric_configfs *tf; |
| 630 | int ret; |
| 631 | |
Nicholas Bellinger | c17cd24 | 2017-06-01 03:10:53 -0700 | [diff] [blame] | 632 | if (!se_dev_ci->ci_type || |
| 633 | se_dev_ci->ci_type->ct_item_ops != &target_core_dev_item_ops) { |
| 634 | pr_err("Bad se_dev_ci, not a valid se_dev_ci pointer: %p\n", se_dev_ci); |
Nicholas Bellinger | 0ff8754 | 2012-12-04 23:43:57 -0800 | [diff] [blame] | 635 | return -EFAULT; |
| 636 | } |
Nicholas Bellinger | c17cd24 | 2017-06-01 03:10:53 -0700 | [diff] [blame] | 637 | dev = container_of(to_config_group(se_dev_ci), struct se_device, dev_group); |
Nicholas Bellinger | 0ff8754 | 2012-12-04 23:43:57 -0800 | [diff] [blame] | 638 | |
Mike Christie | cb0f32e | 2018-07-23 14:07:45 -0500 | [diff] [blame] | 639 | if (!target_dev_configured(dev)) { |
Nicholas Bellinger | faa06ab | 2013-01-31 14:56:12 -0800 | [diff] [blame] | 640 | pr_err("se_device not configured yet, cannot port link\n"); |
| 641 | return -ENODEV; |
| 642 | } |
| 643 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 644 | tpg_ci = &lun_ci->ci_parent->ci_group->cg_item; |
| 645 | se_tpg = container_of(to_config_group(tpg_ci), |
| 646 | struct se_portal_group, tpg_group); |
| 647 | tf = se_tpg->se_tpg_wwn->wwn_tf; |
| 648 | |
| 649 | if (lun->lun_se_dev != NULL) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 650 | pr_err("Port Symlink already exists\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 651 | return -EEXIST; |
| 652 | } |
| 653 | |
Nicholas Bellinger | 6bb8261 | 2015-05-10 19:31:10 -0700 | [diff] [blame] | 654 | ret = core_dev_add_lun(se_tpg, dev, lun); |
| 655 | if (ret) { |
| 656 | pr_err("core_dev_add_lun() failed: %d\n", ret); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 657 | goto out; |
| 658 | } |
| 659 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 660 | if (tf->tf_ops->fabric_post_link) { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 661 | /* |
| 662 | * Call the optional fabric_post_link() to allow a |
| 663 | * fabric module to setup any additional state once |
| 664 | * core_dev_add_lun() has been called.. |
| 665 | */ |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 666 | tf->tf_ops->fabric_post_link(se_tpg, lun); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | return 0; |
| 670 | out: |
| 671 | return ret; |
| 672 | } |
| 673 | |
Andrzej Pietrasiewicz | e16769d | 2016-11-28 13:22:42 +0100 | [diff] [blame] | 674 | static void target_fabric_port_unlink( |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 675 | struct config_item *lun_ci, |
| 676 | struct config_item *se_dev_ci) |
| 677 | { |
| 678 | struct se_lun *lun = container_of(to_config_group(lun_ci), |
| 679 | struct se_lun, lun_group); |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 680 | struct se_portal_group *se_tpg = lun->lun_tpg; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 681 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
| 682 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 683 | if (tf->tf_ops->fabric_pre_unlink) { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 684 | /* |
| 685 | * Call the optional fabric_pre_unlink() to allow a |
| 686 | * fabric module to release any additional stat before |
| 687 | * core_dev_del_lun() is called. |
| 688 | */ |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 689 | tf->tf_ops->fabric_pre_unlink(se_tpg, lun); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 690 | } |
| 691 | |
Andy Grover | cd9d7cb | 2014-06-30 16:39:44 -0700 | [diff] [blame] | 692 | core_dev_del_lun(se_tpg, lun); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 693 | } |
| 694 | |
Nicholas Bellinger | 6bb8261 | 2015-05-10 19:31:10 -0700 | [diff] [blame] | 695 | static void target_fabric_port_release(struct config_item *item) |
| 696 | { |
| 697 | struct se_lun *lun = container_of(to_config_group(item), |
| 698 | struct se_lun, lun_group); |
| 699 | |
| 700 | kfree_rcu(lun, rcu_head); |
| 701 | } |
| 702 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 703 | static struct configfs_item_operations target_fabric_port_item_ops = { |
Nicholas Bellinger | 6bb8261 | 2015-05-10 19:31:10 -0700 | [diff] [blame] | 704 | .release = target_fabric_port_release, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 705 | .allow_link = target_fabric_port_link, |
| 706 | .drop_link = target_fabric_port_unlink, |
| 707 | }; |
| 708 | |
| 709 | TF_CIT_SETUP(tpg_port, &target_fabric_port_item_ops, NULL, target_fabric_port_attrs); |
| 710 | |
| 711 | /* End of tfc_tpg_port_cit */ |
| 712 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 713 | /* Start of tfc_tpg_port_stat_cit */ |
| 714 | |
| 715 | static struct config_group *target_core_port_stat_mkdir( |
| 716 | struct config_group *group, |
| 717 | const char *name) |
| 718 | { |
| 719 | return ERR_PTR(-ENOSYS); |
| 720 | } |
| 721 | |
| 722 | static void target_core_port_stat_rmdir( |
| 723 | struct config_group *group, |
| 724 | struct config_item *item) |
| 725 | { |
| 726 | return; |
| 727 | } |
| 728 | |
| 729 | static struct configfs_group_operations target_fabric_port_stat_group_ops = { |
| 730 | .make_group = target_core_port_stat_mkdir, |
| 731 | .drop_item = target_core_port_stat_rmdir, |
| 732 | }; |
| 733 | |
| 734 | TF_CIT_SETUP(tpg_port_stat, NULL, &target_fabric_port_stat_group_ops, NULL); |
| 735 | |
| 736 | /* End of tfc_tpg_port_stat_cit */ |
| 737 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 738 | /* Start of tfc_tpg_lun_cit */ |
| 739 | |
| 740 | static struct config_group *target_fabric_make_lun( |
| 741 | struct config_group *group, |
| 742 | const char *name) |
| 743 | { |
| 744 | struct se_lun *lun; |
| 745 | struct se_portal_group *se_tpg = container_of(group, |
| 746 | struct se_portal_group, tpg_lun_group); |
| 747 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
Hannes Reinecke | f2d3068 | 2015-06-10 08:41:22 +0200 | [diff] [blame] | 748 | unsigned long long unpacked_lun; |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 749 | int errno; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 750 | |
| 751 | if (strstr(name, "lun_") != name) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 752 | pr_err("Unable to locate \'_\" in" |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 753 | " \"lun_$LUN_NUMBER\"\n"); |
| 754 | return ERR_PTR(-EINVAL); |
| 755 | } |
Hannes Reinecke | f2d3068 | 2015-06-10 08:41:22 +0200 | [diff] [blame] | 756 | errno = kstrtoull(name + 4, 0, &unpacked_lun); |
Jingoo Han | 57103d7 | 2013-07-19 16:22:19 +0900 | [diff] [blame] | 757 | if (errno) |
| 758 | return ERR_PTR(errno); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 759 | |
Nicholas Bellinger | 6bb8261 | 2015-05-10 19:31:10 -0700 | [diff] [blame] | 760 | lun = core_tpg_alloc_lun(se_tpg, unpacked_lun); |
| 761 | if (IS_ERR(lun)) |
| 762 | return ERR_CAST(lun); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 763 | |
| 764 | config_group_init_type_name(&lun->lun_group, name, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 765 | &tf->tf_tpg_port_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 766 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 767 | config_group_init_type_name(&lun->port_stat_grps.stat_group, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 768 | "statistics", &tf->tf_tpg_port_stat_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 769 | configfs_add_default_group(&lun->port_stat_grps.stat_group, |
| 770 | &lun->lun_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 771 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 772 | target_stat_setup_port_default_groups(lun); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 773 | |
| 774 | return &lun->lun_group; |
| 775 | } |
| 776 | |
| 777 | static void target_fabric_drop_lun( |
| 778 | struct config_group *group, |
| 779 | struct config_item *item) |
| 780 | { |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 781 | struct se_lun *lun = container_of(to_config_group(item), |
| 782 | struct se_lun, lun_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 783 | |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 784 | configfs_remove_default_groups(&lun->port_stat_grps.stat_group); |
| 785 | configfs_remove_default_groups(&lun->lun_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 786 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 787 | config_item_put(item); |
| 788 | } |
| 789 | |
| 790 | static struct configfs_group_operations target_fabric_lun_group_ops = { |
| 791 | .make_group = &target_fabric_make_lun, |
| 792 | .drop_item = &target_fabric_drop_lun, |
| 793 | }; |
| 794 | |
| 795 | TF_CIT_SETUP(tpg_lun, NULL, &target_fabric_lun_group_ops, NULL); |
| 796 | |
| 797 | /* End of tfc_tpg_lun_cit */ |
| 798 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 799 | TF_CIT_SETUP_DRV(tpg_attrib, NULL, NULL); |
| 800 | TF_CIT_SETUP_DRV(tpg_auth, NULL, NULL); |
| 801 | TF_CIT_SETUP_DRV(tpg_param, NULL, NULL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 802 | |
| 803 | /* Start of tfc_tpg_base_cit */ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 804 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 805 | static void target_fabric_tpg_release(struct config_item *item) |
| 806 | { |
| 807 | struct se_portal_group *se_tpg = container_of(to_config_group(item), |
| 808 | struct se_portal_group, tpg_group); |
| 809 | struct se_wwn *wwn = se_tpg->se_tpg_wwn; |
| 810 | struct target_fabric_configfs *tf = wwn->wwn_tf; |
| 811 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 812 | tf->tf_ops->fabric_drop_tpg(se_tpg); |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 813 | } |
| 814 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 815 | static struct configfs_item_operations target_fabric_tpg_base_item_ops = { |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 816 | .release = target_fabric_tpg_release, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 817 | }; |
| 818 | |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 819 | static ssize_t target_fabric_tpg_base_enable_show(struct config_item *item, |
| 820 | char *page) |
| 821 | { |
| 822 | return sysfs_emit(page, "%d\n", to_tpg(item)->enabled); |
| 823 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 824 | |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 825 | static ssize_t target_fabric_tpg_base_enable_store(struct config_item *item, |
| 826 | const char *page, |
| 827 | size_t count) |
| 828 | { |
| 829 | struct se_portal_group *se_tpg = to_tpg(item); |
| 830 | int ret; |
| 831 | bool op; |
| 832 | |
Christophe JAILLET | e56ca6b | 2022-11-01 22:13:52 +0100 | [diff] [blame] | 833 | ret = kstrtobool(page, &op); |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 834 | if (ret) |
| 835 | return ret; |
| 836 | |
| 837 | if (se_tpg->enabled == op) |
| 838 | return count; |
Dmitry Bogdanov | 3f4b9cb | 2023-03-01 11:45:09 +0300 | [diff] [blame] | 839 | if (op) |
| 840 | ret = target_tpg_enable(se_tpg); |
| 841 | else |
| 842 | ret = target_tpg_disable(se_tpg); |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 843 | if (ret) |
| 844 | return ret; |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 845 | return count; |
| 846 | } |
Dmitry Bogdanov | 31177b7 | 2023-03-01 11:45:12 +0300 | [diff] [blame] | 847 | static ssize_t target_fabric_tpg_base_rtpi_show(struct config_item *item, char *page) |
| 848 | { |
| 849 | struct se_portal_group *se_tpg = to_tpg(item); |
| 850 | |
| 851 | return sysfs_emit(page, "%#x\n", se_tpg->tpg_rtpi); |
| 852 | } |
| 853 | |
| 854 | static ssize_t target_fabric_tpg_base_rtpi_store(struct config_item *item, |
| 855 | const char *page, size_t count) |
| 856 | { |
| 857 | struct se_portal_group *se_tpg = to_tpg(item); |
| 858 | u16 val; |
| 859 | int ret; |
| 860 | |
| 861 | ret = kstrtou16(page, 0, &val); |
| 862 | if (ret < 0) |
| 863 | return ret; |
| 864 | if (val == 0) |
| 865 | return -EINVAL; |
| 866 | |
| 867 | if (se_tpg->enabled) { |
| 868 | pr_info("%s_TPG[%hu] - Can not change RTPI on enabled TPG", |
| 869 | se_tpg->se_tpg_tfo->fabric_name, |
| 870 | se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg)); |
| 871 | return -EINVAL; |
| 872 | } |
| 873 | |
| 874 | se_tpg->tpg_rtpi = val; |
| 875 | se_tpg->rtpi_manual = true; |
| 876 | |
| 877 | return count; |
| 878 | } |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 879 | |
| 880 | CONFIGFS_ATTR(target_fabric_tpg_base_, enable); |
Dmitry Bogdanov | 31177b7 | 2023-03-01 11:45:12 +0300 | [diff] [blame] | 881 | CONFIGFS_ATTR(target_fabric_tpg_base_, rtpi); |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 882 | |
| 883 | static int |
| 884 | target_fabric_setup_tpg_base_cit(struct target_fabric_configfs *tf) |
| 885 | { |
| 886 | struct config_item_type *cit = &tf->tf_tpg_base_cit; |
| 887 | struct configfs_attribute **attrs = NULL; |
Maurizio Lombardi | a0fde51 | 2023-04-07 15:00:33 +0200 | [diff] [blame] | 888 | size_t nr_attrs = 0; |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 889 | int i = 0; |
| 890 | |
| 891 | if (tf->tf_ops->tfc_tpg_base_attrs) |
| 892 | while (tf->tf_ops->tfc_tpg_base_attrs[nr_attrs] != NULL) |
| 893 | nr_attrs++; |
| 894 | |
| 895 | if (tf->tf_ops->fabric_enable_tpg) |
| 896 | nr_attrs++; |
| 897 | |
Maurizio Lombardi | a0fde51 | 2023-04-07 15:00:33 +0200 | [diff] [blame] | 898 | /* + 1 for target_fabric_tpg_base_attr_rtpi */ |
| 899 | nr_attrs++; |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 900 | |
| 901 | /* + 1 for final NULL in the array */ |
| 902 | attrs = kcalloc(nr_attrs + 1, sizeof(*attrs), GFP_KERNEL); |
| 903 | if (!attrs) |
| 904 | return -ENOMEM; |
| 905 | |
| 906 | if (tf->tf_ops->tfc_tpg_base_attrs) |
| 907 | for (; tf->tf_ops->tfc_tpg_base_attrs[i] != NULL; i++) |
| 908 | attrs[i] = tf->tf_ops->tfc_tpg_base_attrs[i]; |
| 909 | |
| 910 | if (tf->tf_ops->fabric_enable_tpg) |
Dmitry Bogdanov | 31177b7 | 2023-03-01 11:45:12 +0300 | [diff] [blame] | 911 | attrs[i++] = &target_fabric_tpg_base_attr_enable; |
| 912 | |
| 913 | attrs[i++] = &target_fabric_tpg_base_attr_rtpi; |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 914 | |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 915 | cit->ct_item_ops = &target_fabric_tpg_base_item_ops; |
| 916 | cit->ct_attrs = attrs; |
| 917 | cit->ct_owner = tf->tf_ops->module; |
| 918 | pr_debug("Setup generic tpg_base\n"); |
| 919 | |
| 920 | return 0; |
| 921 | } |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 922 | /* End of tfc_tpg_base_cit */ |
| 923 | |
| 924 | /* Start of tfc_tpg_cit */ |
| 925 | |
| 926 | static struct config_group *target_fabric_make_tpg( |
| 927 | struct config_group *group, |
| 928 | const char *name) |
| 929 | { |
| 930 | struct se_wwn *wwn = container_of(group, struct se_wwn, wwn_group); |
| 931 | struct target_fabric_configfs *tf = wwn->wwn_tf; |
| 932 | struct se_portal_group *se_tpg; |
| 933 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 934 | if (!tf->tf_ops->fabric_make_tpg) { |
| 935 | pr_err("tf->tf_ops->fabric_make_tpg is NULL\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 936 | return ERR_PTR(-ENOSYS); |
| 937 | } |
| 938 | |
Bart Van Assche | aa090ea | 2018-06-22 14:53:02 -0700 | [diff] [blame] | 939 | se_tpg = tf->tf_ops->fabric_make_tpg(wwn, name); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 940 | if (!se_tpg || IS_ERR(se_tpg)) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 941 | return ERR_PTR(-EINVAL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 942 | |
| 943 | config_group_init_type_name(&se_tpg->tpg_group, name, |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 944 | &tf->tf_tpg_base_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 945 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 946 | config_group_init_type_name(&se_tpg->tpg_lun_group, "lun", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 947 | &tf->tf_tpg_lun_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 948 | configfs_add_default_group(&se_tpg->tpg_lun_group, |
| 949 | &se_tpg->tpg_group); |
| 950 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 951 | config_group_init_type_name(&se_tpg->tpg_np_group, "np", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 952 | &tf->tf_tpg_np_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 953 | configfs_add_default_group(&se_tpg->tpg_np_group, |
| 954 | &se_tpg->tpg_group); |
| 955 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 956 | config_group_init_type_name(&se_tpg->tpg_acl_group, "acls", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 957 | &tf->tf_tpg_nacl_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 958 | configfs_add_default_group(&se_tpg->tpg_acl_group, |
| 959 | &se_tpg->tpg_group); |
| 960 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 961 | config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 962 | &tf->tf_tpg_attrib_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 963 | configfs_add_default_group(&se_tpg->tpg_attrib_group, |
| 964 | &se_tpg->tpg_group); |
| 965 | |
Nicholas Bellinger | e4b512e | 2013-06-19 18:37:00 -0700 | [diff] [blame] | 966 | config_group_init_type_name(&se_tpg->tpg_auth_group, "auth", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 967 | &tf->tf_tpg_auth_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 968 | configfs_add_default_group(&se_tpg->tpg_auth_group, |
| 969 | &se_tpg->tpg_group); |
| 970 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 971 | config_group_init_type_name(&se_tpg->tpg_param_group, "param", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 972 | &tf->tf_tpg_param_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 973 | configfs_add_default_group(&se_tpg->tpg_param_group, |
| 974 | &se_tpg->tpg_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 975 | |
| 976 | return &se_tpg->tpg_group; |
| 977 | } |
| 978 | |
| 979 | static void target_fabric_drop_tpg( |
| 980 | struct config_group *group, |
| 981 | struct config_item *item) |
| 982 | { |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 983 | struct se_portal_group *se_tpg = container_of(to_config_group(item), |
| 984 | struct se_portal_group, tpg_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 985 | |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 986 | configfs_remove_default_groups(&se_tpg->tpg_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 987 | config_item_put(item); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 988 | } |
| 989 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 990 | static void target_fabric_release_wwn(struct config_item *item) |
| 991 | { |
| 992 | struct se_wwn *wwn = container_of(to_config_group(item), |
| 993 | struct se_wwn, wwn_group); |
| 994 | struct target_fabric_configfs *tf = wwn->wwn_tf; |
| 995 | |
Christoph Hellwig | 839559e | 2016-03-29 13:03:35 +0200 | [diff] [blame] | 996 | configfs_remove_default_groups(&wwn->fabric_stat_group); |
Mike Christie | 39ae3ed | 2021-02-27 11:00:06 -0600 | [diff] [blame] | 997 | configfs_remove_default_groups(&wwn->param_group); |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 998 | tf->tf_ops->fabric_drop_wwn(wwn); |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | static struct configfs_item_operations target_fabric_tpg_item_ops = { |
| 1002 | .release = target_fabric_release_wwn, |
| 1003 | }; |
| 1004 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1005 | static struct configfs_group_operations target_fabric_tpg_group_ops = { |
| 1006 | .make_group = target_fabric_make_tpg, |
| 1007 | .drop_item = target_fabric_drop_tpg, |
| 1008 | }; |
| 1009 | |
Nicholas Bellinger | 1f6fe7c | 2011-02-09 15:34:54 -0800 | [diff] [blame] | 1010 | TF_CIT_SETUP(tpg, &target_fabric_tpg_item_ops, &target_fabric_tpg_group_ops, |
| 1011 | NULL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1012 | |
| 1013 | /* End of tfc_tpg_cit */ |
| 1014 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1015 | /* Start of tfc_wwn_fabric_stats_cit */ |
| 1016 | /* |
| 1017 | * This is used as a placeholder for struct se_wwn->fabric_stat_group |
| 1018 | * to allow fabrics access to ->fabric_stat_group->default_groups[] |
| 1019 | */ |
| 1020 | TF_CIT_SETUP(wwn_fabric_stats, NULL, NULL, NULL); |
| 1021 | |
| 1022 | /* End of tfc_wwn_fabric_stats_cit */ |
| 1023 | |
Mike Christie | 39ae3ed | 2021-02-27 11:00:06 -0600 | [diff] [blame] | 1024 | static ssize_t |
| 1025 | target_fabric_wwn_cmd_completion_affinity_show(struct config_item *item, |
| 1026 | char *page) |
| 1027 | { |
| 1028 | struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn, |
| 1029 | param_group); |
| 1030 | return sprintf(page, "%d\n", |
| 1031 | wwn->cmd_compl_affinity == WORK_CPU_UNBOUND ? |
| 1032 | SE_COMPL_AFFINITY_CURR_CPU : wwn->cmd_compl_affinity); |
| 1033 | } |
| 1034 | |
| 1035 | static ssize_t |
| 1036 | target_fabric_wwn_cmd_completion_affinity_store(struct config_item *item, |
| 1037 | const char *page, size_t count) |
| 1038 | { |
| 1039 | struct se_wwn *wwn = container_of(to_config_group(item), struct se_wwn, |
| 1040 | param_group); |
| 1041 | int compl_val; |
| 1042 | |
| 1043 | if (kstrtoint(page, 0, &compl_val)) |
| 1044 | return -EINVAL; |
| 1045 | |
| 1046 | switch (compl_val) { |
| 1047 | case SE_COMPL_AFFINITY_CPUID: |
| 1048 | wwn->cmd_compl_affinity = compl_val; |
| 1049 | break; |
| 1050 | case SE_COMPL_AFFINITY_CURR_CPU: |
| 1051 | wwn->cmd_compl_affinity = WORK_CPU_UNBOUND; |
| 1052 | break; |
| 1053 | default: |
| 1054 | if (compl_val < 0 || compl_val >= nr_cpu_ids || |
| 1055 | !cpu_online(compl_val)) { |
| 1056 | pr_err("Command completion value must be between %d and %d or an online CPU.\n", |
| 1057 | SE_COMPL_AFFINITY_CPUID, |
| 1058 | SE_COMPL_AFFINITY_CURR_CPU); |
| 1059 | return -EINVAL; |
| 1060 | } |
| 1061 | wwn->cmd_compl_affinity = compl_val; |
| 1062 | } |
| 1063 | |
| 1064 | return count; |
| 1065 | } |
| 1066 | CONFIGFS_ATTR(target_fabric_wwn_, cmd_completion_affinity); |
| 1067 | |
| 1068 | static struct configfs_attribute *target_fabric_wwn_param_attrs[] = { |
| 1069 | &target_fabric_wwn_attr_cmd_completion_affinity, |
| 1070 | NULL, |
| 1071 | }; |
| 1072 | |
| 1073 | TF_CIT_SETUP(wwn_param, NULL, NULL, target_fabric_wwn_param_attrs); |
| 1074 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1075 | /* Start of tfc_wwn_cit */ |
| 1076 | |
| 1077 | static struct config_group *target_fabric_make_wwn( |
| 1078 | struct config_group *group, |
| 1079 | const char *name) |
| 1080 | { |
| 1081 | struct target_fabric_configfs *tf = container_of(group, |
| 1082 | struct target_fabric_configfs, tf_group); |
| 1083 | struct se_wwn *wwn; |
| 1084 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 1085 | if (!tf->tf_ops->fabric_make_wwn) { |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1086 | pr_err("tf->tf_ops.fabric_make_wwn is NULL\n"); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1087 | return ERR_PTR(-ENOSYS); |
| 1088 | } |
| 1089 | |
Christoph Hellwig | ef0caf8 | 2015-05-03 08:50:53 +0200 | [diff] [blame] | 1090 | wwn = tf->tf_ops->fabric_make_wwn(tf, group, name); |
Andy Grover | 6708bb2 | 2011-06-08 10:36:43 -0700 | [diff] [blame] | 1091 | if (!wwn || IS_ERR(wwn)) |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1092 | return ERR_PTR(-EINVAL); |
| 1093 | |
Mike Christie | 39ae3ed | 2021-02-27 11:00:06 -0600 | [diff] [blame] | 1094 | wwn->cmd_compl_affinity = SE_COMPL_AFFINITY_CPUID; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1095 | wwn->wwn_tf = tf; |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1096 | |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 1097 | config_group_init_type_name(&wwn->wwn_group, name, &tf->tf_tpg_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 1098 | |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1099 | config_group_init_type_name(&wwn->fabric_stat_group, "fabric_statistics", |
Christoph Hellwig | 968ebe7 | 2015-05-03 08:50:55 +0200 | [diff] [blame] | 1100 | &tf->tf_wwn_fabric_stats_cit); |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 1101 | configfs_add_default_group(&wwn->fabric_stat_group, &wwn->wwn_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1102 | |
Mike Christie | 39ae3ed | 2021-02-27 11:00:06 -0600 | [diff] [blame] | 1103 | config_group_init_type_name(&wwn->param_group, "param", |
| 1104 | &tf->tf_wwn_param_cit); |
| 1105 | configfs_add_default_group(&wwn->param_group, &wwn->wwn_group); |
| 1106 | |
Christoph Hellwig | 839559e | 2016-03-29 13:03:35 +0200 | [diff] [blame] | 1107 | if (tf->tf_ops->add_wwn_groups) |
| 1108 | tf->tf_ops->add_wwn_groups(wwn); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1109 | return &wwn->wwn_group; |
| 1110 | } |
| 1111 | |
| 1112 | static void target_fabric_drop_wwn( |
| 1113 | struct config_group *group, |
| 1114 | struct config_item *item) |
| 1115 | { |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1116 | struct se_wwn *wwn = container_of(to_config_group(item), |
| 1117 | struct se_wwn, wwn_group); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1118 | |
Christoph Hellwig | 1ae1602 | 2016-02-26 11:02:14 +0100 | [diff] [blame] | 1119 | configfs_remove_default_groups(&wwn->wwn_group); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1120 | config_item_put(item); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | static struct configfs_group_operations target_fabric_wwn_group_ops = { |
| 1124 | .make_group = target_fabric_make_wwn, |
| 1125 | .drop_item = target_fabric_drop_wwn, |
| 1126 | }; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1127 | |
Christoph Hellwig | 2eafd72 | 2015-10-03 15:32:55 +0200 | [diff] [blame] | 1128 | TF_CIT_SETUP_DRV(wwn, NULL, &target_fabric_wwn_group_ops); |
| 1129 | TF_CIT_SETUP_DRV(discovery, NULL, NULL); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1130 | |
| 1131 | int target_fabric_setup_cits(struct target_fabric_configfs *tf) |
| 1132 | { |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 1133 | int ret; |
| 1134 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1135 | target_fabric_setup_discovery_cit(tf); |
| 1136 | target_fabric_setup_wwn_cit(tf); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1137 | target_fabric_setup_wwn_fabric_stats_cit(tf); |
Mike Christie | 39ae3ed | 2021-02-27 11:00:06 -0600 | [diff] [blame] | 1138 | target_fabric_setup_wwn_param_cit(tf); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1139 | target_fabric_setup_tpg_cit(tf); |
Dmitry Bogdanov | 80ed33c | 2021-09-10 11:41:27 +0300 | [diff] [blame] | 1140 | |
| 1141 | ret = target_fabric_setup_tpg_base_cit(tf); |
| 1142 | if (ret) |
| 1143 | return ret; |
| 1144 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1145 | target_fabric_setup_tpg_port_cit(tf); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1146 | target_fabric_setup_tpg_port_stat_cit(tf); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1147 | target_fabric_setup_tpg_lun_cit(tf); |
| 1148 | target_fabric_setup_tpg_np_cit(tf); |
| 1149 | target_fabric_setup_tpg_np_base_cit(tf); |
| 1150 | target_fabric_setup_tpg_attrib_cit(tf); |
Nicholas Bellinger | e4b512e | 2013-06-19 18:37:00 -0700 | [diff] [blame] | 1151 | target_fabric_setup_tpg_auth_cit(tf); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1152 | target_fabric_setup_tpg_param_cit(tf); |
| 1153 | target_fabric_setup_tpg_nacl_cit(tf); |
| 1154 | target_fabric_setup_tpg_nacl_base_cit(tf); |
| 1155 | target_fabric_setup_tpg_nacl_attrib_cit(tf); |
| 1156 | target_fabric_setup_tpg_nacl_auth_cit(tf); |
| 1157 | target_fabric_setup_tpg_nacl_param_cit(tf); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1158 | target_fabric_setup_tpg_nacl_stat_cit(tf); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1159 | target_fabric_setup_tpg_mappedlun_cit(tf); |
Nicholas Bellinger | 12d233842 | 2011-03-14 04:06:11 -0700 | [diff] [blame] | 1160 | target_fabric_setup_tpg_mappedlun_stat_cit(tf); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 1161 | |
| 1162 | return 0; |
| 1163 | } |