1 /******************************************************************************* 2 * Filename: target_core_fabric_configfs.c 3 * 4 * This file contains generic fabric module configfs infrastructure for 5 * TCM v4.x code 6 * 7 * (c) Copyright 2010-2013 Datera, Inc. 8 * 9 * Nicholas A. Bellinger <nab@linux-iscsi.org> 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 ****************************************************************************/ 21 22 #include <linux/module.h> 23 #include <linux/moduleparam.h> 24 #include <linux/utsname.h> 25 #include <linux/init.h> 26 #include <linux/fs.h> 27 #include <linux/namei.h> 28 #include <linux/slab.h> 29 #include <linux/types.h> 30 #include <linux/delay.h> 31 #include <linux/unistd.h> 32 #include <linux/string.h> 33 #include <linux/syscalls.h> 34 #include <linux/configfs.h> 35 36 #include <target/target_core_base.h> 37 #include <target/target_core_fabric.h> 38 #include <target/target_core_fabric_configfs.h> 39 #include <target/target_core_configfs.h> 40 #include <target/configfs_macros.h> 41 42 #include "target_core_internal.h" 43 #include "target_core_alua.h" 44 #include "target_core_pr.h" 45 46 #define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \ 47 static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \ 48 { \ 49 struct target_fabric_configfs_template *tfc = &tf->tf_cit_tmpl; \ 50 struct config_item_type *cit = &tfc->tfc_##_name##_cit; \ 51 \ 52 cit->ct_item_ops = _item_ops; \ 53 cit->ct_group_ops = _group_ops; \ 54 cit->ct_attrs = _attrs; \ 55 cit->ct_owner = tf->tf_module; \ 56 pr_debug("Setup generic %s\n", __stringify(_name)); \ 57 } 58 59 /* Start of tfc_tpg_mappedlun_cit */ 60 61 static int target_fabric_mappedlun_link( 62 struct config_item *lun_acl_ci, 63 struct config_item *lun_ci) 64 { 65 struct se_dev_entry *deve; 66 struct se_lun *lun = container_of(to_config_group(lun_ci), 67 struct se_lun, lun_group); 68 struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), 69 struct se_lun_acl, se_lun_group); 70 struct se_portal_group *se_tpg; 71 struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s; 72 int ret = 0, lun_access; 73 74 if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) { 75 pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:" 76 " %p to struct lun: %p\n", lun_ci, lun); 77 return -EFAULT; 78 } 79 /* 80 * Ensure that the source port exists 81 */ 82 if (!lun->lun_sep || !lun->lun_sep->sep_tpg) { 83 pr_err("Source se_lun->lun_sep or lun->lun_sep->sep" 84 "_tpg does not exist\n"); 85 return -EINVAL; 86 } 87 se_tpg = lun->lun_sep->sep_tpg; 88 89 nacl_ci = &lun_acl_ci->ci_parent->ci_group->cg_item; 90 tpg_ci = &nacl_ci->ci_group->cg_item; 91 wwn_ci = &tpg_ci->ci_group->cg_item; 92 tpg_ci_s = &lun_ci->ci_parent->ci_group->cg_item; 93 wwn_ci_s = &tpg_ci_s->ci_group->cg_item; 94 /* 95 * Make sure the SymLink is going to the same $FABRIC/$WWN/tpgt_$TPGT 96 */ 97 if (strcmp(config_item_name(wwn_ci), config_item_name(wwn_ci_s))) { 98 pr_err("Illegal Initiator ACL SymLink outside of %s\n", 99 config_item_name(wwn_ci)); 100 return -EINVAL; 101 } 102 if (strcmp(config_item_name(tpg_ci), config_item_name(tpg_ci_s))) { 103 pr_err("Illegal Initiator ACL Symlink outside of %s" 104 " TPGT: %s\n", config_item_name(wwn_ci), 105 config_item_name(tpg_ci)); 106 return -EINVAL; 107 } 108 /* 109 * If this struct se_node_acl was dynamically generated with 110 * tpg_1/attrib/generate_node_acls=1, use the existing deve->lun_flags, 111 * which be will write protected (READ-ONLY) when 112 * tpg_1/attrib/demo_mode_write_protect=1 113 */ 114 spin_lock_irq(&lacl->se_lun_nacl->device_list_lock); 115 deve = lacl->se_lun_nacl->device_list[lacl->mapped_lun]; 116 if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) 117 lun_access = deve->lun_flags; 118 else 119 lun_access = 120 (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect( 121 se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY : 122 TRANSPORT_LUNFLAGS_READ_WRITE; 123 spin_unlock_irq(&lacl->se_lun_nacl->device_list_lock); 124 /* 125 * Determine the actual mapped LUN value user wants.. 126 * 127 * This value is what the SCSI Initiator actually sees the 128 * iscsi/$IQN/$TPGT/lun/lun_* as on their SCSI Initiator Ports. 129 */ 130 ret = core_dev_add_initiator_node_lun_acl(se_tpg, lacl, 131 lun->unpacked_lun, lun_access); 132 133 return (ret < 0) ? -EINVAL : 0; 134 } 135 136 static int target_fabric_mappedlun_unlink( 137 struct config_item *lun_acl_ci, 138 struct config_item *lun_ci) 139 { 140 struct se_lun *lun; 141 struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), 142 struct se_lun_acl, se_lun_group); 143 struct se_node_acl *nacl = lacl->se_lun_nacl; 144 struct se_dev_entry *deve = nacl->device_list[lacl->mapped_lun]; 145 struct se_portal_group *se_tpg; 146 /* 147 * Determine if the underlying MappedLUN has already been released.. 148 */ 149 if (!deve->se_lun) 150 return 0; 151 152 lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group); 153 se_tpg = lun->lun_sep->sep_tpg; 154 155 core_dev_del_initiator_node_lun_acl(se_tpg, lun, lacl); 156 return 0; 157 } 158 159 CONFIGFS_EATTR_STRUCT(target_fabric_mappedlun, se_lun_acl); 160 #define TCM_MAPPEDLUN_ATTR(_name, _mode) \ 161 static struct target_fabric_mappedlun_attribute target_fabric_mappedlun_##_name = \ 162 __CONFIGFS_EATTR(_name, _mode, \ 163 target_fabric_mappedlun_show_##_name, \ 164 target_fabric_mappedlun_store_##_name); 165 166 static ssize_t target_fabric_mappedlun_show_write_protect( 167 struct se_lun_acl *lacl, 168 char *page) 169 { 170 struct se_node_acl *se_nacl = lacl->se_lun_nacl; 171 struct se_dev_entry *deve; 172 ssize_t len; 173 174 spin_lock_irq(&se_nacl->device_list_lock); 175 deve = se_nacl->device_list[lacl->mapped_lun]; 176 len = sprintf(page, "%d\n", 177 (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? 178 1 : 0); 179 spin_unlock_irq(&se_nacl->device_list_lock); 180 181 return len; 182 } 183 184 static ssize_t target_fabric_mappedlun_store_write_protect( 185 struct se_lun_acl *lacl, 186 const char *page, 187 size_t count) 188 { 189 struct se_node_acl *se_nacl = lacl->se_lun_nacl; 190 struct se_portal_group *se_tpg = se_nacl->se_tpg; 191 unsigned long op; 192 int ret; 193 194 ret = kstrtoul(page, 0, &op); 195 if (ret) 196 return ret; 197 198 if ((op != 1) && (op != 0)) 199 return -EINVAL; 200 201 core_update_device_list_access(lacl->mapped_lun, (op) ? 202 TRANSPORT_LUNFLAGS_READ_ONLY : 203 TRANSPORT_LUNFLAGS_READ_WRITE, 204 lacl->se_lun_nacl); 205 206 pr_debug("%s_ConfigFS: Changed Initiator ACL: %s" 207 " Mapped LUN: %u Write Protect bit to %s\n", 208 se_tpg->se_tpg_tfo->get_fabric_name(), 209 lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF"); 210 211 return count; 212 213 } 214 215 TCM_MAPPEDLUN_ATTR(write_protect, S_IRUGO | S_IWUSR); 216 217 CONFIGFS_EATTR_OPS(target_fabric_mappedlun, se_lun_acl, se_lun_group); 218 219 static void target_fabric_mappedlun_release(struct config_item *item) 220 { 221 struct se_lun_acl *lacl = container_of(to_config_group(item), 222 struct se_lun_acl, se_lun_group); 223 struct se_portal_group *se_tpg = lacl->se_lun_nacl->se_tpg; 224 225 core_dev_free_initiator_node_lun_acl(se_tpg, lacl); 226 } 227 228 static struct configfs_attribute *target_fabric_mappedlun_attrs[] = { 229 &target_fabric_mappedlun_write_protect.attr, 230 NULL, 231 }; 232 233 static struct configfs_item_operations target_fabric_mappedlun_item_ops = { 234 .release = target_fabric_mappedlun_release, 235 .show_attribute = target_fabric_mappedlun_attr_show, 236 .store_attribute = target_fabric_mappedlun_attr_store, 237 .allow_link = target_fabric_mappedlun_link, 238 .drop_link = target_fabric_mappedlun_unlink, 239 }; 240 241 TF_CIT_SETUP(tpg_mappedlun, &target_fabric_mappedlun_item_ops, NULL, 242 target_fabric_mappedlun_attrs); 243 244 /* End of tfc_tpg_mappedlun_cit */ 245 246 /* Start of tfc_tpg_mappedlun_port_cit */ 247 248 static struct config_group *target_core_mappedlun_stat_mkdir( 249 struct config_group *group, 250 const char *name) 251 { 252 return ERR_PTR(-ENOSYS); 253 } 254 255 static void target_core_mappedlun_stat_rmdir( 256 struct config_group *group, 257 struct config_item *item) 258 { 259 return; 260 } 261 262 static struct configfs_group_operations target_fabric_mappedlun_stat_group_ops = { 263 .make_group = target_core_mappedlun_stat_mkdir, 264 .drop_item = target_core_mappedlun_stat_rmdir, 265 }; 266 267 TF_CIT_SETUP(tpg_mappedlun_stat, NULL, &target_fabric_mappedlun_stat_group_ops, 268 NULL); 269 270 /* End of tfc_tpg_mappedlun_port_cit */ 271 272 /* Start of tfc_tpg_nacl_attrib_cit */ 273 274 CONFIGFS_EATTR_OPS(target_fabric_nacl_attrib, se_node_acl, acl_attrib_group); 275 276 static struct configfs_item_operations target_fabric_nacl_attrib_item_ops = { 277 .show_attribute = target_fabric_nacl_attrib_attr_show, 278 .store_attribute = target_fabric_nacl_attrib_attr_store, 279 }; 280 281 TF_CIT_SETUP(tpg_nacl_attrib, &target_fabric_nacl_attrib_item_ops, NULL, NULL); 282 283 /* End of tfc_tpg_nacl_attrib_cit */ 284 285 /* Start of tfc_tpg_nacl_auth_cit */ 286 287 CONFIGFS_EATTR_OPS(target_fabric_nacl_auth, se_node_acl, acl_auth_group); 288 289 static struct configfs_item_operations target_fabric_nacl_auth_item_ops = { 290 .show_attribute = target_fabric_nacl_auth_attr_show, 291 .store_attribute = target_fabric_nacl_auth_attr_store, 292 }; 293 294 TF_CIT_SETUP(tpg_nacl_auth, &target_fabric_nacl_auth_item_ops, NULL, NULL); 295 296 /* End of tfc_tpg_nacl_auth_cit */ 297 298 /* Start of tfc_tpg_nacl_param_cit */ 299 300 CONFIGFS_EATTR_OPS(target_fabric_nacl_param, se_node_acl, acl_param_group); 301 302 static struct configfs_item_operations target_fabric_nacl_param_item_ops = { 303 .show_attribute = target_fabric_nacl_param_attr_show, 304 .store_attribute = target_fabric_nacl_param_attr_store, 305 }; 306 307 TF_CIT_SETUP(tpg_nacl_param, &target_fabric_nacl_param_item_ops, NULL, NULL); 308 309 /* End of tfc_tpg_nacl_param_cit */ 310 311 /* Start of tfc_tpg_nacl_base_cit */ 312 313 CONFIGFS_EATTR_OPS(target_fabric_nacl_base, se_node_acl, acl_group); 314 315 static struct config_group *target_fabric_make_mappedlun( 316 struct config_group *group, 317 const char *name) 318 { 319 struct se_node_acl *se_nacl = container_of(group, 320 struct se_node_acl, acl_group); 321 struct se_portal_group *se_tpg = se_nacl->se_tpg; 322 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 323 struct se_lun_acl *lacl = NULL; 324 struct config_item *acl_ci; 325 struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL; 326 char *buf; 327 unsigned long mapped_lun; 328 int ret = 0; 329 330 acl_ci = &group->cg_item; 331 if (!acl_ci) { 332 pr_err("Unable to locatel acl_ci\n"); 333 return NULL; 334 } 335 336 buf = kzalloc(strlen(name) + 1, GFP_KERNEL); 337 if (!buf) { 338 pr_err("Unable to allocate memory for name buf\n"); 339 return ERR_PTR(-ENOMEM); 340 } 341 snprintf(buf, strlen(name) + 1, "%s", name); 342 /* 343 * Make sure user is creating iscsi/$IQN/$TPGT/acls/$INITIATOR/lun_$ID. 344 */ 345 if (strstr(buf, "lun_") != buf) { 346 pr_err("Unable to locate \"lun_\" from buf: %s" 347 " name: %s\n", buf, name); 348 ret = -EINVAL; 349 goto out; 350 } 351 /* 352 * Determine the Mapped LUN value. This is what the SCSI Initiator 353 * Port will actually see. 354 */ 355 ret = kstrtoul(buf + 4, 0, &mapped_lun); 356 if (ret) 357 goto out; 358 if (mapped_lun > UINT_MAX) { 359 ret = -EINVAL; 360 goto out; 361 } 362 if (mapped_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) { 363 pr_err("Mapped LUN: %lu exceeds TRANSPORT_MAX_LUNS_PER_TPG" 364 "-1: %u for Target Portal Group: %u\n", mapped_lun, 365 TRANSPORT_MAX_LUNS_PER_TPG-1, 366 se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg)); 367 ret = -EINVAL; 368 goto out; 369 } 370 371 lacl = core_dev_init_initiator_node_lun_acl(se_tpg, se_nacl, 372 mapped_lun, &ret); 373 if (!lacl) { 374 ret = -EINVAL; 375 goto out; 376 } 377 378 lacl_cg = &lacl->se_lun_group; 379 lacl_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, 380 GFP_KERNEL); 381 if (!lacl_cg->default_groups) { 382 pr_err("Unable to allocate lacl_cg->default_groups\n"); 383 ret = -ENOMEM; 384 goto out; 385 } 386 387 config_group_init_type_name(&lacl->se_lun_group, name, 388 &tf->tf_cit_tmpl.tfc_tpg_mappedlun_cit); 389 config_group_init_type_name(&lacl->ml_stat_grps.stat_group, 390 "statistics", &tf->tf_cit_tmpl.tfc_tpg_mappedlun_stat_cit); 391 lacl_cg->default_groups[0] = &lacl->ml_stat_grps.stat_group; 392 lacl_cg->default_groups[1] = NULL; 393 394 ml_stat_grp = &lacl->ml_stat_grps.stat_group; 395 ml_stat_grp->default_groups = kmalloc(sizeof(struct config_group *) * 3, 396 GFP_KERNEL); 397 if (!ml_stat_grp->default_groups) { 398 pr_err("Unable to allocate ml_stat_grp->default_groups\n"); 399 ret = -ENOMEM; 400 goto out; 401 } 402 target_stat_setup_mappedlun_default_groups(lacl); 403 404 kfree(buf); 405 return &lacl->se_lun_group; 406 out: 407 if (lacl_cg) 408 kfree(lacl_cg->default_groups); 409 kfree(lacl); 410 kfree(buf); 411 return ERR_PTR(ret); 412 } 413 414 static void target_fabric_drop_mappedlun( 415 struct config_group *group, 416 struct config_item *item) 417 { 418 struct se_lun_acl *lacl = container_of(to_config_group(item), 419 struct se_lun_acl, se_lun_group); 420 struct config_item *df_item; 421 struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL; 422 int i; 423 424 ml_stat_grp = &lacl->ml_stat_grps.stat_group; 425 for (i = 0; ml_stat_grp->default_groups[i]; i++) { 426 df_item = &ml_stat_grp->default_groups[i]->cg_item; 427 ml_stat_grp->default_groups[i] = NULL; 428 config_item_put(df_item); 429 } 430 kfree(ml_stat_grp->default_groups); 431 432 lacl_cg = &lacl->se_lun_group; 433 for (i = 0; lacl_cg->default_groups[i]; i++) { 434 df_item = &lacl_cg->default_groups[i]->cg_item; 435 lacl_cg->default_groups[i] = NULL; 436 config_item_put(df_item); 437 } 438 kfree(lacl_cg->default_groups); 439 440 config_item_put(item); 441 } 442 443 static void target_fabric_nacl_base_release(struct config_item *item) 444 { 445 struct se_node_acl *se_nacl = container_of(to_config_group(item), 446 struct se_node_acl, acl_group); 447 struct se_portal_group *se_tpg = se_nacl->se_tpg; 448 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 449 450 tf->tf_ops.fabric_drop_nodeacl(se_nacl); 451 } 452 453 static struct configfs_item_operations target_fabric_nacl_base_item_ops = { 454 .release = target_fabric_nacl_base_release, 455 .show_attribute = target_fabric_nacl_base_attr_show, 456 .store_attribute = target_fabric_nacl_base_attr_store, 457 }; 458 459 static struct configfs_group_operations target_fabric_nacl_base_group_ops = { 460 .make_group = target_fabric_make_mappedlun, 461 .drop_item = target_fabric_drop_mappedlun, 462 }; 463 464 TF_CIT_SETUP(tpg_nacl_base, &target_fabric_nacl_base_item_ops, 465 &target_fabric_nacl_base_group_ops, NULL); 466 467 /* End of tfc_tpg_nacl_base_cit */ 468 469 /* Start of tfc_node_fabric_stats_cit */ 470 /* 471 * This is used as a placeholder for struct se_node_acl->acl_fabric_stat_group 472 * to allow fabrics access to ->acl_fabric_stat_group->default_groups[] 473 */ 474 TF_CIT_SETUP(tpg_nacl_stat, NULL, NULL, NULL); 475 476 /* End of tfc_wwn_fabric_stats_cit */ 477 478 /* Start of tfc_tpg_nacl_cit */ 479 480 static struct config_group *target_fabric_make_nodeacl( 481 struct config_group *group, 482 const char *name) 483 { 484 struct se_portal_group *se_tpg = container_of(group, 485 struct se_portal_group, tpg_acl_group); 486 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 487 struct se_node_acl *se_nacl; 488 struct config_group *nacl_cg; 489 490 if (!tf->tf_ops.fabric_make_nodeacl) { 491 pr_err("tf->tf_ops.fabric_make_nodeacl is NULL\n"); 492 return ERR_PTR(-ENOSYS); 493 } 494 495 se_nacl = tf->tf_ops.fabric_make_nodeacl(se_tpg, group, name); 496 if (IS_ERR(se_nacl)) 497 return ERR_CAST(se_nacl); 498 499 nacl_cg = &se_nacl->acl_group; 500 nacl_cg->default_groups = se_nacl->acl_default_groups; 501 nacl_cg->default_groups[0] = &se_nacl->acl_attrib_group; 502 nacl_cg->default_groups[1] = &se_nacl->acl_auth_group; 503 nacl_cg->default_groups[2] = &se_nacl->acl_param_group; 504 nacl_cg->default_groups[3] = &se_nacl->acl_fabric_stat_group; 505 nacl_cg->default_groups[4] = NULL; 506 507 config_group_init_type_name(&se_nacl->acl_group, name, 508 &tf->tf_cit_tmpl.tfc_tpg_nacl_base_cit); 509 config_group_init_type_name(&se_nacl->acl_attrib_group, "attrib", 510 &tf->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit); 511 config_group_init_type_name(&se_nacl->acl_auth_group, "auth", 512 &tf->tf_cit_tmpl.tfc_tpg_nacl_auth_cit); 513 config_group_init_type_name(&se_nacl->acl_param_group, "param", 514 &tf->tf_cit_tmpl.tfc_tpg_nacl_param_cit); 515 config_group_init_type_name(&se_nacl->acl_fabric_stat_group, 516 "fabric_statistics", 517 &tf->tf_cit_tmpl.tfc_tpg_nacl_stat_cit); 518 519 return &se_nacl->acl_group; 520 } 521 522 static void target_fabric_drop_nodeacl( 523 struct config_group *group, 524 struct config_item *item) 525 { 526 struct se_node_acl *se_nacl = container_of(to_config_group(item), 527 struct se_node_acl, acl_group); 528 struct config_item *df_item; 529 struct config_group *nacl_cg; 530 int i; 531 532 nacl_cg = &se_nacl->acl_group; 533 for (i = 0; nacl_cg->default_groups[i]; i++) { 534 df_item = &nacl_cg->default_groups[i]->cg_item; 535 nacl_cg->default_groups[i] = NULL; 536 config_item_put(df_item); 537 } 538 /* 539 * struct se_node_acl free is done in target_fabric_nacl_base_release() 540 */ 541 config_item_put(item); 542 } 543 544 static struct configfs_group_operations target_fabric_nacl_group_ops = { 545 .make_group = target_fabric_make_nodeacl, 546 .drop_item = target_fabric_drop_nodeacl, 547 }; 548 549 TF_CIT_SETUP(tpg_nacl, NULL, &target_fabric_nacl_group_ops, NULL); 550 551 /* End of tfc_tpg_nacl_cit */ 552 553 /* Start of tfc_tpg_np_base_cit */ 554 555 CONFIGFS_EATTR_OPS(target_fabric_np_base, se_tpg_np, tpg_np_group); 556 557 static void target_fabric_np_base_release(struct config_item *item) 558 { 559 struct se_tpg_np *se_tpg_np = container_of(to_config_group(item), 560 struct se_tpg_np, tpg_np_group); 561 struct se_portal_group *se_tpg = se_tpg_np->tpg_np_parent; 562 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 563 564 tf->tf_ops.fabric_drop_np(se_tpg_np); 565 } 566 567 static struct configfs_item_operations target_fabric_np_base_item_ops = { 568 .release = target_fabric_np_base_release, 569 .show_attribute = target_fabric_np_base_attr_show, 570 .store_attribute = target_fabric_np_base_attr_store, 571 }; 572 573 TF_CIT_SETUP(tpg_np_base, &target_fabric_np_base_item_ops, NULL, NULL); 574 575 /* End of tfc_tpg_np_base_cit */ 576 577 /* Start of tfc_tpg_np_cit */ 578 579 static struct config_group *target_fabric_make_np( 580 struct config_group *group, 581 const char *name) 582 { 583 struct se_portal_group *se_tpg = container_of(group, 584 struct se_portal_group, tpg_np_group); 585 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 586 struct se_tpg_np *se_tpg_np; 587 588 if (!tf->tf_ops.fabric_make_np) { 589 pr_err("tf->tf_ops.fabric_make_np is NULL\n"); 590 return ERR_PTR(-ENOSYS); 591 } 592 593 se_tpg_np = tf->tf_ops.fabric_make_np(se_tpg, group, name); 594 if (!se_tpg_np || IS_ERR(se_tpg_np)) 595 return ERR_PTR(-EINVAL); 596 597 se_tpg_np->tpg_np_parent = se_tpg; 598 config_group_init_type_name(&se_tpg_np->tpg_np_group, name, 599 &tf->tf_cit_tmpl.tfc_tpg_np_base_cit); 600 601 return &se_tpg_np->tpg_np_group; 602 } 603 604 static void target_fabric_drop_np( 605 struct config_group *group, 606 struct config_item *item) 607 { 608 /* 609 * struct se_tpg_np is released via target_fabric_np_base_release() 610 */ 611 config_item_put(item); 612 } 613 614 static struct configfs_group_operations target_fabric_np_group_ops = { 615 .make_group = &target_fabric_make_np, 616 .drop_item = &target_fabric_drop_np, 617 }; 618 619 TF_CIT_SETUP(tpg_np, NULL, &target_fabric_np_group_ops, NULL); 620 621 /* End of tfc_tpg_np_cit */ 622 623 /* Start of tfc_tpg_port_cit */ 624 625 CONFIGFS_EATTR_STRUCT(target_fabric_port, se_lun); 626 #define TCM_PORT_ATTR(_name, _mode) \ 627 static struct target_fabric_port_attribute target_fabric_port_##_name = \ 628 __CONFIGFS_EATTR(_name, _mode, \ 629 target_fabric_port_show_attr_##_name, \ 630 target_fabric_port_store_attr_##_name); 631 632 #define TCM_PORT_ATTOR_RO(_name) \ 633 __CONFIGFS_EATTR_RO(_name, \ 634 target_fabric_port_show_attr_##_name); 635 636 /* 637 * alua_tg_pt_gp 638 */ 639 static ssize_t target_fabric_port_show_attr_alua_tg_pt_gp( 640 struct se_lun *lun, 641 char *page) 642 { 643 if (!lun || !lun->lun_sep) 644 return -ENODEV; 645 646 return core_alua_show_tg_pt_gp_info(lun->lun_sep, page); 647 } 648 649 static ssize_t target_fabric_port_store_attr_alua_tg_pt_gp( 650 struct se_lun *lun, 651 const char *page, 652 size_t count) 653 { 654 if (!lun || !lun->lun_sep) 655 return -ENODEV; 656 657 return core_alua_store_tg_pt_gp_info(lun->lun_sep, page, count); 658 } 659 660 TCM_PORT_ATTR(alua_tg_pt_gp, S_IRUGO | S_IWUSR); 661 662 /* 663 * alua_tg_pt_offline 664 */ 665 static ssize_t target_fabric_port_show_attr_alua_tg_pt_offline( 666 struct se_lun *lun, 667 char *page) 668 { 669 if (!lun || !lun->lun_sep) 670 return -ENODEV; 671 672 return core_alua_show_offline_bit(lun, page); 673 } 674 675 static ssize_t target_fabric_port_store_attr_alua_tg_pt_offline( 676 struct se_lun *lun, 677 const char *page, 678 size_t count) 679 { 680 if (!lun || !lun->lun_sep) 681 return -ENODEV; 682 683 return core_alua_store_offline_bit(lun, page, count); 684 } 685 686 TCM_PORT_ATTR(alua_tg_pt_offline, S_IRUGO | S_IWUSR); 687 688 /* 689 * alua_tg_pt_status 690 */ 691 static ssize_t target_fabric_port_show_attr_alua_tg_pt_status( 692 struct se_lun *lun, 693 char *page) 694 { 695 if (!lun || !lun->lun_sep) 696 return -ENODEV; 697 698 return core_alua_show_secondary_status(lun, page); 699 } 700 701 static ssize_t target_fabric_port_store_attr_alua_tg_pt_status( 702 struct se_lun *lun, 703 const char *page, 704 size_t count) 705 { 706 if (!lun || !lun->lun_sep) 707 return -ENODEV; 708 709 return core_alua_store_secondary_status(lun, page, count); 710 } 711 712 TCM_PORT_ATTR(alua_tg_pt_status, S_IRUGO | S_IWUSR); 713 714 /* 715 * alua_tg_pt_write_md 716 */ 717 static ssize_t target_fabric_port_show_attr_alua_tg_pt_write_md( 718 struct se_lun *lun, 719 char *page) 720 { 721 if (!lun || !lun->lun_sep) 722 return -ENODEV; 723 724 return core_alua_show_secondary_write_metadata(lun, page); 725 } 726 727 static ssize_t target_fabric_port_store_attr_alua_tg_pt_write_md( 728 struct se_lun *lun, 729 const char *page, 730 size_t count) 731 { 732 if (!lun || !lun->lun_sep) 733 return -ENODEV; 734 735 return core_alua_store_secondary_write_metadata(lun, page, count); 736 } 737 738 TCM_PORT_ATTR(alua_tg_pt_write_md, S_IRUGO | S_IWUSR); 739 740 741 static struct configfs_attribute *target_fabric_port_attrs[] = { 742 &target_fabric_port_alua_tg_pt_gp.attr, 743 &target_fabric_port_alua_tg_pt_offline.attr, 744 &target_fabric_port_alua_tg_pt_status.attr, 745 &target_fabric_port_alua_tg_pt_write_md.attr, 746 NULL, 747 }; 748 749 CONFIGFS_EATTR_OPS(target_fabric_port, se_lun, lun_group); 750 751 static int target_fabric_port_link( 752 struct config_item *lun_ci, 753 struct config_item *se_dev_ci) 754 { 755 struct config_item *tpg_ci; 756 struct se_lun *lun = container_of(to_config_group(lun_ci), 757 struct se_lun, lun_group); 758 struct se_lun *lun_p; 759 struct se_portal_group *se_tpg; 760 struct se_device *dev = 761 container_of(to_config_group(se_dev_ci), struct se_device, dev_group); 762 struct target_fabric_configfs *tf; 763 int ret; 764 765 if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) { 766 pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:" 767 " %p to struct se_device: %p\n", se_dev_ci, dev); 768 return -EFAULT; 769 } 770 771 if (!(dev->dev_flags & DF_CONFIGURED)) { 772 pr_err("se_device not configured yet, cannot port link\n"); 773 return -ENODEV; 774 } 775 776 tpg_ci = &lun_ci->ci_parent->ci_group->cg_item; 777 se_tpg = container_of(to_config_group(tpg_ci), 778 struct se_portal_group, tpg_group); 779 tf = se_tpg->se_tpg_wwn->wwn_tf; 780 781 if (lun->lun_se_dev != NULL) { 782 pr_err("Port Symlink already exists\n"); 783 return -EEXIST; 784 } 785 786 lun_p = core_dev_add_lun(se_tpg, dev, lun->unpacked_lun); 787 if (IS_ERR(lun_p)) { 788 pr_err("core_dev_add_lun() failed\n"); 789 ret = PTR_ERR(lun_p); 790 goto out; 791 } 792 793 if (tf->tf_ops.fabric_post_link) { 794 /* 795 * Call the optional fabric_post_link() to allow a 796 * fabric module to setup any additional state once 797 * core_dev_add_lun() has been called.. 798 */ 799 tf->tf_ops.fabric_post_link(se_tpg, lun); 800 } 801 802 return 0; 803 out: 804 return ret; 805 } 806 807 static int target_fabric_port_unlink( 808 struct config_item *lun_ci, 809 struct config_item *se_dev_ci) 810 { 811 struct se_lun *lun = container_of(to_config_group(lun_ci), 812 struct se_lun, lun_group); 813 struct se_portal_group *se_tpg = lun->lun_sep->sep_tpg; 814 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 815 816 if (tf->tf_ops.fabric_pre_unlink) { 817 /* 818 * Call the optional fabric_pre_unlink() to allow a 819 * fabric module to release any additional stat before 820 * core_dev_del_lun() is called. 821 */ 822 tf->tf_ops.fabric_pre_unlink(se_tpg, lun); 823 } 824 825 core_dev_del_lun(se_tpg, lun); 826 return 0; 827 } 828 829 static struct configfs_item_operations target_fabric_port_item_ops = { 830 .show_attribute = target_fabric_port_attr_show, 831 .store_attribute = target_fabric_port_attr_store, 832 .allow_link = target_fabric_port_link, 833 .drop_link = target_fabric_port_unlink, 834 }; 835 836 TF_CIT_SETUP(tpg_port, &target_fabric_port_item_ops, NULL, target_fabric_port_attrs); 837 838 /* End of tfc_tpg_port_cit */ 839 840 /* Start of tfc_tpg_port_stat_cit */ 841 842 static struct config_group *target_core_port_stat_mkdir( 843 struct config_group *group, 844 const char *name) 845 { 846 return ERR_PTR(-ENOSYS); 847 } 848 849 static void target_core_port_stat_rmdir( 850 struct config_group *group, 851 struct config_item *item) 852 { 853 return; 854 } 855 856 static struct configfs_group_operations target_fabric_port_stat_group_ops = { 857 .make_group = target_core_port_stat_mkdir, 858 .drop_item = target_core_port_stat_rmdir, 859 }; 860 861 TF_CIT_SETUP(tpg_port_stat, NULL, &target_fabric_port_stat_group_ops, NULL); 862 863 /* End of tfc_tpg_port_stat_cit */ 864 865 /* Start of tfc_tpg_lun_cit */ 866 867 static struct config_group *target_fabric_make_lun( 868 struct config_group *group, 869 const char *name) 870 { 871 struct se_lun *lun; 872 struct se_portal_group *se_tpg = container_of(group, 873 struct se_portal_group, tpg_lun_group); 874 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; 875 struct config_group *lun_cg = NULL, *port_stat_grp = NULL; 876 unsigned long unpacked_lun; 877 int errno; 878 879 if (strstr(name, "lun_") != name) { 880 pr_err("Unable to locate \'_\" in" 881 " \"lun_$LUN_NUMBER\"\n"); 882 return ERR_PTR(-EINVAL); 883 } 884 errno = kstrtoul(name + 4, 0, &unpacked_lun); 885 if (errno) 886 return ERR_PTR(errno); 887 if (unpacked_lun > UINT_MAX) 888 return ERR_PTR(-EINVAL); 889 890 lun = core_get_lun_from_tpg(se_tpg, unpacked_lun); 891 if (!lun) 892 return ERR_PTR(-EINVAL); 893 894 lun_cg = &lun->lun_group; 895 lun_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, 896 GFP_KERNEL); 897 if (!lun_cg->default_groups) { 898 pr_err("Unable to allocate lun_cg->default_groups\n"); 899 return ERR_PTR(-ENOMEM); 900 } 901 902 config_group_init_type_name(&lun->lun_group, name, 903 &tf->tf_cit_tmpl.tfc_tpg_port_cit); 904 config_group_init_type_name(&lun->port_stat_grps.stat_group, 905 "statistics", &tf->tf_cit_tmpl.tfc_tpg_port_stat_cit); 906 lun_cg->default_groups[0] = &lun->port_stat_grps.stat_group; 907 lun_cg->default_groups[1] = NULL; 908 909 port_stat_grp = &lun->port_stat_grps.stat_group; 910 port_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) * 4, 911 GFP_KERNEL); 912 if (!port_stat_grp->default_groups) { 913 pr_err("Unable to allocate port_stat_grp->default_groups\n"); 914 kfree(lun_cg->default_groups); 915 return ERR_PTR(-ENOMEM); 916 } 917 target_stat_setup_port_default_groups(lun); 918 919 return &lun->lun_group; 920 } 921 922 static void target_fabric_drop_lun( 923 struct config_group *group, 924 struct config_item *item) 925 { 926 struct se_lun *lun = container_of(to_config_group(item), 927 struct se_lun, lun_group); 928 struct config_item *df_item; 929 struct config_group *lun_cg, *port_stat_grp; 930 int i; 931 932 port_stat_grp = &lun->port_stat_grps.stat_group; 933 for (i = 0; port_stat_grp->default_groups[i]; i++) { 934 df_item = &port_stat_grp->default_groups[i]->cg_item; 935 port_stat_grp->default_groups[i] = NULL; 936 config_item_put(df_item); 937 } 938 kfree(port_stat_grp->default_groups); 939 940 lun_cg = &lun->lun_group; 941 for (i = 0; lun_cg->default_groups[i]; i++) { 942 df_item = &lun_cg->default_groups[i]->cg_item; 943 lun_cg->default_groups[i] = NULL; 944 config_item_put(df_item); 945 } 946 kfree(lun_cg->default_groups); 947 948 config_item_put(item); 949 } 950 951 static struct configfs_group_operations target_fabric_lun_group_ops = { 952 .make_group = &target_fabric_make_lun, 953 .drop_item = &target_fabric_drop_lun, 954 }; 955 956 TF_CIT_SETUP(tpg_lun, NULL, &target_fabric_lun_group_ops, NULL); 957 958 /* End of tfc_tpg_lun_cit */ 959 960 /* Start of tfc_tpg_attrib_cit */ 961 962 CONFIGFS_EATTR_OPS(target_fabric_tpg_attrib, se_portal_group, tpg_attrib_group); 963 964 static struct configfs_item_operations target_fabric_tpg_attrib_item_ops = { 965 .show_attribute = target_fabric_tpg_attrib_attr_show, 966 .store_attribute = target_fabric_tpg_attrib_attr_store, 967 }; 968 969 TF_CIT_SETUP(tpg_attrib, &target_fabric_tpg_attrib_item_ops, NULL, NULL); 970 971 /* End of tfc_tpg_attrib_cit */ 972 973 /* Start of tfc_tpg_auth_cit */ 974 975 CONFIGFS_EATTR_OPS(target_fabric_tpg_auth, se_portal_group, tpg_auth_group); 976 977 static struct configfs_item_operations target_fabric_tpg_auth_item_ops = { 978 .show_attribute = target_fabric_tpg_auth_attr_show, 979 .store_attribute = target_fabric_tpg_auth_attr_store, 980 }; 981 982 TF_CIT_SETUP(tpg_auth, &target_fabric_tpg_auth_item_ops, NULL, NULL); 983 984 /* End of tfc_tpg_attrib_cit */ 985 986 /* Start of tfc_tpg_param_cit */ 987 988 CONFIGFS_EATTR_OPS(target_fabric_tpg_param, se_portal_group, tpg_param_group); 989 990 static struct configfs_item_operations target_fabric_tpg_param_item_ops = { 991 .show_attribute = target_fabric_tpg_param_attr_show, 992 .store_attribute = target_fabric_tpg_param_attr_store, 993 }; 994 995 TF_CIT_SETUP(tpg_param, &target_fabric_tpg_param_item_ops, NULL, NULL); 996 997 /* End of tfc_tpg_param_cit */ 998 999 /* Start of tfc_tpg_base_cit */ 1000 /* 1001 * For use with TF_TPG_ATTR() and TF_TPG_ATTR_RO() 1002 */ 1003 CONFIGFS_EATTR_OPS(target_fabric_tpg, se_portal_group, tpg_group); 1004 1005 static void target_fabric_tpg_release(struct config_item *item) 1006 { 1007 struct se_portal_group *se_tpg = container_of(to_config_group(item), 1008 struct se_portal_group, tpg_group); 1009 struct se_wwn *wwn = se_tpg->se_tpg_wwn; 1010 struct target_fabric_configfs *tf = wwn->wwn_tf; 1011 1012 tf->tf_ops.fabric_drop_tpg(se_tpg); 1013 } 1014 1015 static struct configfs_item_operations target_fabric_tpg_base_item_ops = { 1016 .release = target_fabric_tpg_release, 1017 .show_attribute = target_fabric_tpg_attr_show, 1018 .store_attribute = target_fabric_tpg_attr_store, 1019 }; 1020 1021 TF_CIT_SETUP(tpg_base, &target_fabric_tpg_base_item_ops, NULL, NULL); 1022 1023 /* End of tfc_tpg_base_cit */ 1024 1025 /* Start of tfc_tpg_cit */ 1026 1027 static struct config_group *target_fabric_make_tpg( 1028 struct config_group *group, 1029 const char *name) 1030 { 1031 struct se_wwn *wwn = container_of(group, struct se_wwn, wwn_group); 1032 struct target_fabric_configfs *tf = wwn->wwn_tf; 1033 struct se_portal_group *se_tpg; 1034 1035 if (!tf->tf_ops.fabric_make_tpg) { 1036 pr_err("tf->tf_ops.fabric_make_tpg is NULL\n"); 1037 return ERR_PTR(-ENOSYS); 1038 } 1039 1040 se_tpg = tf->tf_ops.fabric_make_tpg(wwn, group, name); 1041 if (!se_tpg || IS_ERR(se_tpg)) 1042 return ERR_PTR(-EINVAL); 1043 /* 1044 * Setup default groups from pre-allocated se_tpg->tpg_default_groups 1045 */ 1046 se_tpg->tpg_group.default_groups = se_tpg->tpg_default_groups; 1047 se_tpg->tpg_group.default_groups[0] = &se_tpg->tpg_lun_group; 1048 se_tpg->tpg_group.default_groups[1] = &se_tpg->tpg_np_group; 1049 se_tpg->tpg_group.default_groups[2] = &se_tpg->tpg_acl_group; 1050 se_tpg->tpg_group.default_groups[3] = &se_tpg->tpg_attrib_group; 1051 se_tpg->tpg_group.default_groups[4] = &se_tpg->tpg_auth_group; 1052 se_tpg->tpg_group.default_groups[5] = &se_tpg->tpg_param_group; 1053 se_tpg->tpg_group.default_groups[6] = NULL; 1054 1055 config_group_init_type_name(&se_tpg->tpg_group, name, 1056 &tf->tf_cit_tmpl.tfc_tpg_base_cit); 1057 config_group_init_type_name(&se_tpg->tpg_lun_group, "lun", 1058 &tf->tf_cit_tmpl.tfc_tpg_lun_cit); 1059 config_group_init_type_name(&se_tpg->tpg_np_group, "np", 1060 &tf->tf_cit_tmpl.tfc_tpg_np_cit); 1061 config_group_init_type_name(&se_tpg->tpg_acl_group, "acls", 1062 &tf->tf_cit_tmpl.tfc_tpg_nacl_cit); 1063 config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib", 1064 &tf->tf_cit_tmpl.tfc_tpg_attrib_cit); 1065 config_group_init_type_name(&se_tpg->tpg_auth_group, "auth", 1066 &tf->tf_cit_tmpl.tfc_tpg_auth_cit); 1067 config_group_init_type_name(&se_tpg->tpg_param_group, "param", 1068 &tf->tf_cit_tmpl.tfc_tpg_param_cit); 1069 1070 return &se_tpg->tpg_group; 1071 } 1072 1073 static void target_fabric_drop_tpg( 1074 struct config_group *group, 1075 struct config_item *item) 1076 { 1077 struct se_portal_group *se_tpg = container_of(to_config_group(item), 1078 struct se_portal_group, tpg_group); 1079 struct config_group *tpg_cg = &se_tpg->tpg_group; 1080 struct config_item *df_item; 1081 int i; 1082 /* 1083 * Release default groups, but do not release tpg_cg->default_groups 1084 * memory as it is statically allocated at se_tpg->tpg_default_groups. 1085 */ 1086 for (i = 0; tpg_cg->default_groups[i]; i++) { 1087 df_item = &tpg_cg->default_groups[i]->cg_item; 1088 tpg_cg->default_groups[i] = NULL; 1089 config_item_put(df_item); 1090 } 1091 1092 config_item_put(item); 1093 } 1094 1095 static void target_fabric_release_wwn(struct config_item *item) 1096 { 1097 struct se_wwn *wwn = container_of(to_config_group(item), 1098 struct se_wwn, wwn_group); 1099 struct target_fabric_configfs *tf = wwn->wwn_tf; 1100 1101 tf->tf_ops.fabric_drop_wwn(wwn); 1102 } 1103 1104 static struct configfs_item_operations target_fabric_tpg_item_ops = { 1105 .release = target_fabric_release_wwn, 1106 }; 1107 1108 static struct configfs_group_operations target_fabric_tpg_group_ops = { 1109 .make_group = target_fabric_make_tpg, 1110 .drop_item = target_fabric_drop_tpg, 1111 }; 1112 1113 TF_CIT_SETUP(tpg, &target_fabric_tpg_item_ops, &target_fabric_tpg_group_ops, 1114 NULL); 1115 1116 /* End of tfc_tpg_cit */ 1117 1118 /* Start of tfc_wwn_fabric_stats_cit */ 1119 /* 1120 * This is used as a placeholder for struct se_wwn->fabric_stat_group 1121 * to allow fabrics access to ->fabric_stat_group->default_groups[] 1122 */ 1123 TF_CIT_SETUP(wwn_fabric_stats, NULL, NULL, NULL); 1124 1125 /* End of tfc_wwn_fabric_stats_cit */ 1126 1127 /* Start of tfc_wwn_cit */ 1128 1129 static struct config_group *target_fabric_make_wwn( 1130 struct config_group *group, 1131 const char *name) 1132 { 1133 struct target_fabric_configfs *tf = container_of(group, 1134 struct target_fabric_configfs, tf_group); 1135 struct se_wwn *wwn; 1136 1137 if (!tf->tf_ops.fabric_make_wwn) { 1138 pr_err("tf->tf_ops.fabric_make_wwn is NULL\n"); 1139 return ERR_PTR(-ENOSYS); 1140 } 1141 1142 wwn = tf->tf_ops.fabric_make_wwn(tf, group, name); 1143 if (!wwn || IS_ERR(wwn)) 1144 return ERR_PTR(-EINVAL); 1145 1146 wwn->wwn_tf = tf; 1147 /* 1148 * Setup default groups from pre-allocated wwn->wwn_default_groups 1149 */ 1150 wwn->wwn_group.default_groups = wwn->wwn_default_groups; 1151 wwn->wwn_group.default_groups[0] = &wwn->fabric_stat_group; 1152 wwn->wwn_group.default_groups[1] = NULL; 1153 1154 config_group_init_type_name(&wwn->wwn_group, name, 1155 &tf->tf_cit_tmpl.tfc_tpg_cit); 1156 config_group_init_type_name(&wwn->fabric_stat_group, "fabric_statistics", 1157 &tf->tf_cit_tmpl.tfc_wwn_fabric_stats_cit); 1158 1159 return &wwn->wwn_group; 1160 } 1161 1162 static void target_fabric_drop_wwn( 1163 struct config_group *group, 1164 struct config_item *item) 1165 { 1166 struct se_wwn *wwn = container_of(to_config_group(item), 1167 struct se_wwn, wwn_group); 1168 struct config_item *df_item; 1169 struct config_group *cg = &wwn->wwn_group; 1170 int i; 1171 1172 for (i = 0; cg->default_groups[i]; i++) { 1173 df_item = &cg->default_groups[i]->cg_item; 1174 cg->default_groups[i] = NULL; 1175 config_item_put(df_item); 1176 } 1177 1178 config_item_put(item); 1179 } 1180 1181 static struct configfs_group_operations target_fabric_wwn_group_ops = { 1182 .make_group = target_fabric_make_wwn, 1183 .drop_item = target_fabric_drop_wwn, 1184 }; 1185 /* 1186 * For use with TF_WWN_ATTR() and TF_WWN_ATTR_RO() 1187 */ 1188 CONFIGFS_EATTR_OPS(target_fabric_wwn, target_fabric_configfs, tf_group); 1189 1190 static struct configfs_item_operations target_fabric_wwn_item_ops = { 1191 .show_attribute = target_fabric_wwn_attr_show, 1192 .store_attribute = target_fabric_wwn_attr_store, 1193 }; 1194 1195 TF_CIT_SETUP(wwn, &target_fabric_wwn_item_ops, &target_fabric_wwn_group_ops, NULL); 1196 1197 /* End of tfc_wwn_cit */ 1198 1199 /* Start of tfc_discovery_cit */ 1200 1201 CONFIGFS_EATTR_OPS(target_fabric_discovery, target_fabric_configfs, 1202 tf_disc_group); 1203 1204 static struct configfs_item_operations target_fabric_discovery_item_ops = { 1205 .show_attribute = target_fabric_discovery_attr_show, 1206 .store_attribute = target_fabric_discovery_attr_store, 1207 }; 1208 1209 TF_CIT_SETUP(discovery, &target_fabric_discovery_item_ops, NULL, NULL); 1210 1211 /* End of tfc_discovery_cit */ 1212 1213 int target_fabric_setup_cits(struct target_fabric_configfs *tf) 1214 { 1215 target_fabric_setup_discovery_cit(tf); 1216 target_fabric_setup_wwn_cit(tf); 1217 target_fabric_setup_wwn_fabric_stats_cit(tf); 1218 target_fabric_setup_tpg_cit(tf); 1219 target_fabric_setup_tpg_base_cit(tf); 1220 target_fabric_setup_tpg_port_cit(tf); 1221 target_fabric_setup_tpg_port_stat_cit(tf); 1222 target_fabric_setup_tpg_lun_cit(tf); 1223 target_fabric_setup_tpg_np_cit(tf); 1224 target_fabric_setup_tpg_np_base_cit(tf); 1225 target_fabric_setup_tpg_attrib_cit(tf); 1226 target_fabric_setup_tpg_auth_cit(tf); 1227 target_fabric_setup_tpg_param_cit(tf); 1228 target_fabric_setup_tpg_nacl_cit(tf); 1229 target_fabric_setup_tpg_nacl_base_cit(tf); 1230 target_fabric_setup_tpg_nacl_attrib_cit(tf); 1231 target_fabric_setup_tpg_nacl_auth_cit(tf); 1232 target_fabric_setup_tpg_nacl_param_cit(tf); 1233 target_fabric_setup_tpg_nacl_stat_cit(tf); 1234 target_fabric_setup_tpg_mappedlun_cit(tf); 1235 target_fabric_setup_tpg_mappedlun_stat_cit(tf); 1236 1237 return 0; 1238 } 1239