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