]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/target/target_core_fabric_configfs.c
Merge tag 'cris-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper...
[mirror_ubuntu-zesty-kernel.git] / drivers / target / target_core_fabric_configfs.c
CommitLineData
c66ac9db
NB
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 *
4c76251e 7 * (c) Copyright 2010-2013 Datera, Inc.
c66ac9db 8 *
fd9a11d7 9 * Nicholas A. Bellinger <nab@linux-iscsi.org>
c66ac9db
NB
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>
c66ac9db
NB
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>
c4795fb2 37#include <target/target_core_fabric.h>
c66ac9db 38
e26d99ae 39#include "target_core_internal.h"
c66ac9db 40#include "target_core_alua.h"
c66ac9db
NB
41#include "target_core_pr.h"
42
43#define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \
44static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \
45{ \
968ebe75 46 struct config_item_type *cit = &tf->tf_##_name##_cit; \
c66ac9db
NB
47 \
48 cit->ct_item_ops = _item_ops; \
49 cit->ct_group_ops = _group_ops; \
50 cit->ct_attrs = _attrs; \
0dc2e8d1 51 cit->ct_owner = tf->tf_ops->module; \
6708bb27 52 pr_debug("Setup generic %s\n", __stringify(_name)); \
c66ac9db
NB
53}
54
9ac8928e
CH
55#define TF_CIT_SETUP_DRV(_name, _item_ops, _group_ops) \
56static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \
57{ \
968ebe75 58 struct config_item_type *cit = &tf->tf_##_name##_cit; \
ef0caf8d 59 struct configfs_attribute **attrs = tf->tf_ops->tfc_##_name##_attrs; \
9ac8928e
CH
60 \
61 cit->ct_item_ops = _item_ops; \
62 cit->ct_group_ops = _group_ops; \
63 cit->ct_attrs = attrs; \
0dc2e8d1 64 cit->ct_owner = tf->tf_ops->module; \
9ac8928e
CH
65 pr_debug("Setup generic %s\n", __stringify(_name)); \
66}
67
c66ac9db
NB
68/* Start of tfc_tpg_mappedlun_cit */
69
70static int target_fabric_mappedlun_link(
71 struct config_item *lun_acl_ci,
72 struct config_item *lun_ci)
73{
74 struct se_dev_entry *deve;
75 struct se_lun *lun = container_of(to_config_group(lun_ci),
76 struct se_lun, lun_group);
77 struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci),
78 struct se_lun_acl, se_lun_group);
79 struct se_portal_group *se_tpg;
80 struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s;
6bb82612 81 int lun_access;
0ff87549
NB
82
83 if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) {
84 pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:"
85 " %p to struct lun: %p\n", lun_ci, lun);
86 return -EFAULT;
87 }
c66ac9db
NB
88 /*
89 * Ensure that the source port exists
90 */
adf653f9
CH
91 if (!lun->lun_se_dev) {
92 pr_err("Source se_lun->lun_se_dev does not exist\n");
c66ac9db
NB
93 return -EINVAL;
94 }
adf653f9 95 se_tpg = lun->lun_tpg;
c66ac9db
NB
96
97 nacl_ci = &lun_acl_ci->ci_parent->ci_group->cg_item;
98 tpg_ci = &nacl_ci->ci_group->cg_item;
99 wwn_ci = &tpg_ci->ci_group->cg_item;
100 tpg_ci_s = &lun_ci->ci_parent->ci_group->cg_item;
101 wwn_ci_s = &tpg_ci_s->ci_group->cg_item;
102 /*
103 * Make sure the SymLink is going to the same $FABRIC/$WWN/tpgt_$TPGT
104 */
105 if (strcmp(config_item_name(wwn_ci), config_item_name(wwn_ci_s))) {
6708bb27 106 pr_err("Illegal Initiator ACL SymLink outside of %s\n",
c66ac9db
NB
107 config_item_name(wwn_ci));
108 return -EINVAL;
109 }
110 if (strcmp(config_item_name(tpg_ci), config_item_name(tpg_ci_s))) {
6708bb27 111 pr_err("Illegal Initiator ACL Symlink outside of %s"
c66ac9db
NB
112 " TPGT: %s\n", config_item_name(wwn_ci),
113 config_item_name(tpg_ci));
114 return -EINVAL;
115 }
116 /*
117 * If this struct se_node_acl was dynamically generated with
118 * tpg_1/attrib/generate_node_acls=1, use the existing deve->lun_flags,
119 * which be will write protected (READ-ONLY) when
120 * tpg_1/attrib/demo_mode_write_protect=1
121 */
29a05dee
NB
122 rcu_read_lock();
123 deve = target_nacl_find_deve(lacl->se_lun_nacl, lacl->mapped_lun);
124 if (deve)
c66ac9db
NB
125 lun_access = deve->lun_flags;
126 else
127 lun_access =
e3d6f909 128 (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect(
c66ac9db
NB
129 se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY :
130 TRANSPORT_LUNFLAGS_READ_WRITE;
29a05dee 131 rcu_read_unlock();
c66ac9db
NB
132 /*
133 * Determine the actual mapped LUN value user wants..
134 *
135 * This value is what the SCSI Initiator actually sees the
6bb82612 136 * $FABRIC/$WWPN/$TPGT/lun/lun_* as on their SCSI Initiator Ports.
c66ac9db 137 */
6bb82612 138 return core_dev_add_initiator_node_lun_acl(se_tpg, lacl, lun, lun_access);
c66ac9db
NB
139}
140
141static int target_fabric_mappedlun_unlink(
142 struct config_item *lun_acl_ci,
143 struct config_item *lun_ci)
144{
c66ac9db
NB
145 struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci),
146 struct se_lun_acl, se_lun_group);
29a05dee
NB
147 struct se_lun *lun = container_of(to_config_group(lun_ci),
148 struct se_lun, lun_group);
c66ac9db 149
adf653f9 150 return core_dev_del_initiator_node_lun_acl(lun, lacl);
c66ac9db
NB
151}
152
2eafd729
CH
153static struct se_lun_acl *item_to_lun_acl(struct config_item *item)
154{
155 return container_of(to_config_group(item), struct se_lun_acl,
156 se_lun_group);
157}
c66ac9db 158
2eafd729
CH
159static ssize_t target_fabric_mappedlun_write_protect_show(
160 struct config_item *item, char *page)
c66ac9db 161{
2eafd729 162 struct se_lun_acl *lacl = item_to_lun_acl(item);
c66ac9db
NB
163 struct se_node_acl *se_nacl = lacl->se_lun_nacl;
164 struct se_dev_entry *deve;
29a05dee
NB
165 ssize_t len = 0;
166
167 rcu_read_lock();
168 deve = target_nacl_find_deve(se_nacl, lacl->mapped_lun);
169 if (deve) {
170 len = sprintf(page, "%d\n",
171 (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? 1 : 0);
172 }
173 rcu_read_unlock();
c66ac9db
NB
174
175 return len;
176}
177
2eafd729
CH
178static ssize_t target_fabric_mappedlun_write_protect_store(
179 struct config_item *item, const char *page, size_t count)
c66ac9db 180{
2eafd729 181 struct se_lun_acl *lacl = item_to_lun_acl(item);
c66ac9db
NB
182 struct se_node_acl *se_nacl = lacl->se_lun_nacl;
183 struct se_portal_group *se_tpg = se_nacl->se_tpg;
184 unsigned long op;
57103d7f 185 int ret;
c66ac9db 186
57103d7f
JH
187 ret = kstrtoul(page, 0, &op);
188 if (ret)
189 return ret;
c66ac9db
NB
190
191 if ((op != 1) && (op != 0))
192 return -EINVAL;
193
194 core_update_device_list_access(lacl->mapped_lun, (op) ?
195 TRANSPORT_LUNFLAGS_READ_ONLY :
196 TRANSPORT_LUNFLAGS_READ_WRITE,
197 lacl->se_lun_nacl);
198
6708bb27 199 pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
f2d30680 200 " Mapped LUN: %llu Write Protect bit to %s\n",
e3d6f909 201 se_tpg->se_tpg_tfo->get_fabric_name(),
b6a54b8d 202 se_nacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
c66ac9db
NB
203
204 return count;
205
206}
207
2eafd729 208CONFIGFS_ATTR(target_fabric_mappedlun_, write_protect);
c66ac9db 209
2eafd729
CH
210static struct configfs_attribute *target_fabric_mappedlun_attrs[] = {
211 &target_fabric_mappedlun_attr_write_protect,
212 NULL,
213};
c66ac9db 214
1f6fe7cb
NB
215static void target_fabric_mappedlun_release(struct config_item *item)
216{
217 struct se_lun_acl *lacl = container_of(to_config_group(item),
218 struct se_lun_acl, se_lun_group);
219 struct se_portal_group *se_tpg = lacl->se_lun_nacl->se_tpg;
220
221 core_dev_free_initiator_node_lun_acl(se_tpg, lacl);
222}
223
c66ac9db 224static struct configfs_item_operations target_fabric_mappedlun_item_ops = {
1f6fe7cb 225 .release = target_fabric_mappedlun_release,
c66ac9db
NB
226 .allow_link = target_fabric_mappedlun_link,
227 .drop_link = target_fabric_mappedlun_unlink,
228};
229
230TF_CIT_SETUP(tpg_mappedlun, &target_fabric_mappedlun_item_ops, NULL,
231 target_fabric_mappedlun_attrs);
232
233/* End of tfc_tpg_mappedlun_cit */
234
12d23384
NB
235/* Start of tfc_tpg_mappedlun_port_cit */
236
237static struct config_group *target_core_mappedlun_stat_mkdir(
238 struct config_group *group,
239 const char *name)
240{
241 return ERR_PTR(-ENOSYS);
242}
243
244static void target_core_mappedlun_stat_rmdir(
245 struct config_group *group,
246 struct config_item *item)
247{
248 return;
249}
250
251static struct configfs_group_operations target_fabric_mappedlun_stat_group_ops = {
252 .make_group = target_core_mappedlun_stat_mkdir,
253 .drop_item = target_core_mappedlun_stat_rmdir,
254};
255
256TF_CIT_SETUP(tpg_mappedlun_stat, NULL, &target_fabric_mappedlun_stat_group_ops,
257 NULL);
258
259/* End of tfc_tpg_mappedlun_port_cit */
260
2eafd729
CH
261TF_CIT_SETUP_DRV(tpg_nacl_attrib, NULL, NULL);
262TF_CIT_SETUP_DRV(tpg_nacl_auth, NULL, NULL);
263TF_CIT_SETUP_DRV(tpg_nacl_param, NULL, NULL);
c66ac9db
NB
264
265/* Start of tfc_tpg_nacl_base_cit */
266
c66ac9db
NB
267static struct config_group *target_fabric_make_mappedlun(
268 struct config_group *group,
269 const char *name)
270{
271 struct se_node_acl *se_nacl = container_of(group,
272 struct se_node_acl, acl_group);
273 struct se_portal_group *se_tpg = se_nacl->se_tpg;
274 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
da0abaee 275 struct se_lun_acl *lacl = NULL;
c66ac9db 276 struct config_item *acl_ci;
12d23384 277 struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL;
c66ac9db 278 char *buf;
f2d30680 279 unsigned long long mapped_lun;
c66ac9db
NB
280 int ret = 0;
281
282 acl_ci = &group->cg_item;
6708bb27
AG
283 if (!acl_ci) {
284 pr_err("Unable to locatel acl_ci\n");
c66ac9db
NB
285 return NULL;
286 }
287
288 buf = kzalloc(strlen(name) + 1, GFP_KERNEL);
6708bb27
AG
289 if (!buf) {
290 pr_err("Unable to allocate memory for name buf\n");
c66ac9db
NB
291 return ERR_PTR(-ENOMEM);
292 }
293 snprintf(buf, strlen(name) + 1, "%s", name);
294 /*
295 * Make sure user is creating iscsi/$IQN/$TPGT/acls/$INITIATOR/lun_$ID.
296 */
297 if (strstr(buf, "lun_") != buf) {
6708bb27 298 pr_err("Unable to locate \"lun_\" from buf: %s"
c66ac9db
NB
299 " name: %s\n", buf, name);
300 ret = -EINVAL;
301 goto out;
302 }
303 /*
304 * Determine the Mapped LUN value. This is what the SCSI Initiator
305 * Port will actually see.
306 */
f2d30680 307 ret = kstrtoull(buf + 4, 0, &mapped_lun);
57103d7f
JH
308 if (ret)
309 goto out;
c66ac9db 310
fcf29481
NB
311 lacl = core_dev_init_initiator_node_lun_acl(se_tpg, se_nacl,
312 mapped_lun, &ret);
6708bb27 313 if (!lacl) {
12d23384 314 ret = -EINVAL;
c66ac9db 315 goto out;
12d23384
NB
316 }
317
318 lacl_cg = &lacl->se_lun_group;
13f6a914 319 lacl_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
12d23384
NB
320 GFP_KERNEL);
321 if (!lacl_cg->default_groups) {
6708bb27 322 pr_err("Unable to allocate lacl_cg->default_groups\n");
12d23384
NB
323 ret = -ENOMEM;
324 goto out;
325 }
c66ac9db
NB
326
327 config_group_init_type_name(&lacl->se_lun_group, name,
968ebe75 328 &tf->tf_tpg_mappedlun_cit);
12d23384 329 config_group_init_type_name(&lacl->ml_stat_grps.stat_group,
968ebe75 330 "statistics", &tf->tf_tpg_mappedlun_stat_cit);
12d23384
NB
331 lacl_cg->default_groups[0] = &lacl->ml_stat_grps.stat_group;
332 lacl_cg->default_groups[1] = NULL;
333
e3d6f909 334 ml_stat_grp = &lacl->ml_stat_grps.stat_group;
13f6a914 335 ml_stat_grp->default_groups = kmalloc(sizeof(struct config_group *) * 3,
12d23384
NB
336 GFP_KERNEL);
337 if (!ml_stat_grp->default_groups) {
6708bb27 338 pr_err("Unable to allocate ml_stat_grp->default_groups\n");
12d23384
NB
339 ret = -ENOMEM;
340 goto out;
341 }
342 target_stat_setup_mappedlun_default_groups(lacl);
c66ac9db
NB
343
344 kfree(buf);
345 return &lacl->se_lun_group;
346out:
12d23384
NB
347 if (lacl_cg)
348 kfree(lacl_cg->default_groups);
da0abaee 349 kfree(lacl);
c66ac9db
NB
350 kfree(buf);
351 return ERR_PTR(ret);
352}
353
354static void target_fabric_drop_mappedlun(
355 struct config_group *group,
356 struct config_item *item)
357{
12d23384
NB
358 struct se_lun_acl *lacl = container_of(to_config_group(item),
359 struct se_lun_acl, se_lun_group);
360 struct config_item *df_item;
361 struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL;
362 int i;
363
e3d6f909 364 ml_stat_grp = &lacl->ml_stat_grps.stat_group;
12d23384
NB
365 for (i = 0; ml_stat_grp->default_groups[i]; i++) {
366 df_item = &ml_stat_grp->default_groups[i]->cg_item;
367 ml_stat_grp->default_groups[i] = NULL;
368 config_item_put(df_item);
369 }
370 kfree(ml_stat_grp->default_groups);
371
372 lacl_cg = &lacl->se_lun_group;
373 for (i = 0; lacl_cg->default_groups[i]; i++) {
374 df_item = &lacl_cg->default_groups[i]->cg_item;
375 lacl_cg->default_groups[i] = NULL;
376 config_item_put(df_item);
377 }
378 kfree(lacl_cg->default_groups);
379
c66ac9db 380 config_item_put(item);
1f6fe7cb
NB
381}
382
383static void target_fabric_nacl_base_release(struct config_item *item)
384{
385 struct se_node_acl *se_nacl = container_of(to_config_group(item),
386 struct se_node_acl, acl_group);
c7d6a803 387 struct target_fabric_configfs *tf = se_nacl->se_tpg->se_tpg_wwn->wwn_tf;
1f6fe7cb 388
ef0caf8d
CH
389 if (tf->tf_ops->fabric_cleanup_nodeacl)
390 tf->tf_ops->fabric_cleanup_nodeacl(se_nacl);
c7d6a803 391 core_tpg_del_initiator_node_acl(se_nacl);
c66ac9db
NB
392}
393
394static struct configfs_item_operations target_fabric_nacl_base_item_ops = {
1f6fe7cb 395 .release = target_fabric_nacl_base_release,
c66ac9db
NB
396};
397
398static struct configfs_group_operations target_fabric_nacl_base_group_ops = {
399 .make_group = target_fabric_make_mappedlun,
400 .drop_item = target_fabric_drop_mappedlun,
401};
402
9ac8928e
CH
403TF_CIT_SETUP_DRV(tpg_nacl_base, &target_fabric_nacl_base_item_ops,
404 &target_fabric_nacl_base_group_ops);
c66ac9db
NB
405
406/* End of tfc_tpg_nacl_base_cit */
407
12d23384
NB
408/* Start of tfc_node_fabric_stats_cit */
409/*
410 * This is used as a placeholder for struct se_node_acl->acl_fabric_stat_group
411 * to allow fabrics access to ->acl_fabric_stat_group->default_groups[]
412 */
413TF_CIT_SETUP(tpg_nacl_stat, NULL, NULL, NULL);
414
415/* End of tfc_wwn_fabric_stats_cit */
416
c66ac9db
NB
417/* Start of tfc_tpg_nacl_cit */
418
419static struct config_group *target_fabric_make_nodeacl(
420 struct config_group *group,
421 const char *name)
422{
423 struct se_portal_group *se_tpg = container_of(group,
424 struct se_portal_group, tpg_acl_group);
425 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
426 struct se_node_acl *se_nacl;
427 struct config_group *nacl_cg;
428
c7d6a803 429 se_nacl = core_tpg_add_initiator_node_acl(se_tpg, name);
c66ac9db 430 if (IS_ERR(se_nacl))
e1750ba2 431 return ERR_CAST(se_nacl);
c66ac9db 432
ef0caf8d
CH
433 if (tf->tf_ops->fabric_init_nodeacl) {
434 int ret = tf->tf_ops->fabric_init_nodeacl(se_nacl, name);
c7d6a803
CH
435 if (ret) {
436 core_tpg_del_initiator_node_acl(se_nacl);
437 return ERR_PTR(ret);
438 }
439 }
440
c66ac9db
NB
441 nacl_cg = &se_nacl->acl_group;
442 nacl_cg->default_groups = se_nacl->acl_default_groups;
443 nacl_cg->default_groups[0] = &se_nacl->acl_attrib_group;
444 nacl_cg->default_groups[1] = &se_nacl->acl_auth_group;
445 nacl_cg->default_groups[2] = &se_nacl->acl_param_group;
12d23384
NB
446 nacl_cg->default_groups[3] = &se_nacl->acl_fabric_stat_group;
447 nacl_cg->default_groups[4] = NULL;
c66ac9db
NB
448
449 config_group_init_type_name(&se_nacl->acl_group, name,
968ebe75 450 &tf->tf_tpg_nacl_base_cit);
c66ac9db 451 config_group_init_type_name(&se_nacl->acl_attrib_group, "attrib",
968ebe75 452 &tf->tf_tpg_nacl_attrib_cit);
c66ac9db 453 config_group_init_type_name(&se_nacl->acl_auth_group, "auth",
968ebe75 454 &tf->tf_tpg_nacl_auth_cit);
c66ac9db 455 config_group_init_type_name(&se_nacl->acl_param_group, "param",
968ebe75 456 &tf->tf_tpg_nacl_param_cit);
12d23384 457 config_group_init_type_name(&se_nacl->acl_fabric_stat_group,
968ebe75 458 "fabric_statistics", &tf->tf_tpg_nacl_stat_cit);
c66ac9db
NB
459
460 return &se_nacl->acl_group;
461}
462
463static void target_fabric_drop_nodeacl(
464 struct config_group *group,
465 struct config_item *item)
466{
c66ac9db
NB
467 struct se_node_acl *se_nacl = container_of(to_config_group(item),
468 struct se_node_acl, acl_group);
469 struct config_item *df_item;
470 struct config_group *nacl_cg;
471 int i;
472
473 nacl_cg = &se_nacl->acl_group;
474 for (i = 0; nacl_cg->default_groups[i]; i++) {
475 df_item = &nacl_cg->default_groups[i]->cg_item;
476 nacl_cg->default_groups[i] = NULL;
477 config_item_put(df_item);
478 }
1f6fe7cb
NB
479 /*
480 * struct se_node_acl free is done in target_fabric_nacl_base_release()
481 */
c66ac9db 482 config_item_put(item);
c66ac9db
NB
483}
484
485static struct configfs_group_operations target_fabric_nacl_group_ops = {
486 .make_group = target_fabric_make_nodeacl,
487 .drop_item = target_fabric_drop_nodeacl,
488};
489
490TF_CIT_SETUP(tpg_nacl, NULL, &target_fabric_nacl_group_ops, NULL);
491
492/* End of tfc_tpg_nacl_cit */
493
494/* Start of tfc_tpg_np_base_cit */
495
1f6fe7cb
NB
496static void target_fabric_np_base_release(struct config_item *item)
497{
498 struct se_tpg_np *se_tpg_np = container_of(to_config_group(item),
499 struct se_tpg_np, tpg_np_group);
500 struct se_portal_group *se_tpg = se_tpg_np->tpg_np_parent;
501 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
502
ef0caf8d 503 tf->tf_ops->fabric_drop_np(se_tpg_np);
1f6fe7cb
NB
504}
505
c66ac9db 506static struct configfs_item_operations target_fabric_np_base_item_ops = {
1f6fe7cb 507 .release = target_fabric_np_base_release,
c66ac9db
NB
508};
509
9ac8928e 510TF_CIT_SETUP_DRV(tpg_np_base, &target_fabric_np_base_item_ops, NULL);
c66ac9db
NB
511
512/* End of tfc_tpg_np_base_cit */
513
514/* Start of tfc_tpg_np_cit */
515
516static struct config_group *target_fabric_make_np(
517 struct config_group *group,
518 const char *name)
519{
520 struct se_portal_group *se_tpg = container_of(group,
521 struct se_portal_group, tpg_np_group);
522 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
523 struct se_tpg_np *se_tpg_np;
524
ef0caf8d 525 if (!tf->tf_ops->fabric_make_np) {
6708bb27 526 pr_err("tf->tf_ops.fabric_make_np is NULL\n");
c66ac9db
NB
527 return ERR_PTR(-ENOSYS);
528 }
529
ef0caf8d 530 se_tpg_np = tf->tf_ops->fabric_make_np(se_tpg, group, name);
6708bb27 531 if (!se_tpg_np || IS_ERR(se_tpg_np))
c66ac9db
NB
532 return ERR_PTR(-EINVAL);
533
1f6fe7cb 534 se_tpg_np->tpg_np_parent = se_tpg;
c66ac9db 535 config_group_init_type_name(&se_tpg_np->tpg_np_group, name,
968ebe75 536 &tf->tf_tpg_np_base_cit);
c66ac9db
NB
537
538 return &se_tpg_np->tpg_np_group;
539}
540
541static void target_fabric_drop_np(
542 struct config_group *group,
543 struct config_item *item)
544{
1f6fe7cb
NB
545 /*
546 * struct se_tpg_np is released via target_fabric_np_base_release()
547 */
c66ac9db 548 config_item_put(item);
c66ac9db
NB
549}
550
551static struct configfs_group_operations target_fabric_np_group_ops = {
552 .make_group = &target_fabric_make_np,
553 .drop_item = &target_fabric_drop_np,
554};
555
556TF_CIT_SETUP(tpg_np, NULL, &target_fabric_np_group_ops, NULL);
557
558/* End of tfc_tpg_np_cit */
559
560/* Start of tfc_tpg_port_cit */
561
2eafd729
CH
562static struct se_lun *item_to_lun(struct config_item *item)
563{
564 return container_of(to_config_group(item), struct se_lun,
565 lun_group);
566}
c66ac9db 567
2eafd729
CH
568static ssize_t target_fabric_port_alua_tg_pt_gp_show(struct config_item *item,
569 char *page)
c66ac9db 570{
2eafd729
CH
571 struct se_lun *lun = item_to_lun(item);
572
adf653f9 573 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
574 return -ENODEV;
575
adf653f9 576 return core_alua_show_tg_pt_gp_info(lun, page);
c66ac9db
NB
577}
578
2eafd729
CH
579static ssize_t target_fabric_port_alua_tg_pt_gp_store(struct config_item *item,
580 const char *page, size_t count)
c66ac9db 581{
2eafd729
CH
582 struct se_lun *lun = item_to_lun(item);
583
adf653f9 584 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
585 return -ENODEV;
586
adf653f9 587 return core_alua_store_tg_pt_gp_info(lun, page, count);
c66ac9db
NB
588}
589
2eafd729
CH
590static ssize_t target_fabric_port_alua_tg_pt_offline_show(
591 struct config_item *item, char *page)
c66ac9db 592{
2eafd729
CH
593 struct se_lun *lun = item_to_lun(item);
594
adf653f9 595 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
596 return -ENODEV;
597
598 return core_alua_show_offline_bit(lun, page);
599}
600
2eafd729
CH
601static ssize_t target_fabric_port_alua_tg_pt_offline_store(
602 struct config_item *item, const char *page, size_t count)
c66ac9db 603{
2eafd729
CH
604 struct se_lun *lun = item_to_lun(item);
605
adf653f9 606 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
607 return -ENODEV;
608
609 return core_alua_store_offline_bit(lun, page, count);
610}
611
2eafd729
CH
612static ssize_t target_fabric_port_alua_tg_pt_status_show(
613 struct config_item *item, char *page)
c66ac9db 614{
2eafd729
CH
615 struct se_lun *lun = item_to_lun(item);
616
adf653f9 617 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
618 return -ENODEV;
619
620 return core_alua_show_secondary_status(lun, page);
621}
622
2eafd729
CH
623static ssize_t target_fabric_port_alua_tg_pt_status_store(
624 struct config_item *item, const char *page, size_t count)
c66ac9db 625{
2eafd729
CH
626 struct se_lun *lun = item_to_lun(item);
627
adf653f9 628 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
629 return -ENODEV;
630
631 return core_alua_store_secondary_status(lun, page, count);
632}
633
2eafd729
CH
634static ssize_t target_fabric_port_alua_tg_pt_write_md_show(
635 struct config_item *item, char *page)
c66ac9db 636{
2eafd729
CH
637 struct se_lun *lun = item_to_lun(item);
638
adf653f9 639 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
640 return -ENODEV;
641
642 return core_alua_show_secondary_write_metadata(lun, page);
643}
644
2eafd729
CH
645static ssize_t target_fabric_port_alua_tg_pt_write_md_store(
646 struct config_item *item, const char *page, size_t count)
c66ac9db 647{
2eafd729
CH
648 struct se_lun *lun = item_to_lun(item);
649
adf653f9 650 if (!lun || !lun->lun_se_dev)
c66ac9db
NB
651 return -ENODEV;
652
653 return core_alua_store_secondary_write_metadata(lun, page, count);
654}
655
2eafd729
CH
656CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_gp);
657CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_offline);
658CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_status);
659CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_write_md);
c66ac9db
NB
660
661static struct configfs_attribute *target_fabric_port_attrs[] = {
2eafd729
CH
662 &target_fabric_port_attr_alua_tg_pt_gp,
663 &target_fabric_port_attr_alua_tg_pt_offline,
664 &target_fabric_port_attr_alua_tg_pt_status,
665 &target_fabric_port_attr_alua_tg_pt_write_md,
c66ac9db
NB
666 NULL,
667};
668
c66ac9db
NB
669static int target_fabric_port_link(
670 struct config_item *lun_ci,
671 struct config_item *se_dev_ci)
672{
673 struct config_item *tpg_ci;
c66ac9db
NB
674 struct se_lun *lun = container_of(to_config_group(lun_ci),
675 struct se_lun, lun_group);
c66ac9db 676 struct se_portal_group *se_tpg;
0fd97ccf
CH
677 struct se_device *dev =
678 container_of(to_config_group(se_dev_ci), struct se_device, dev_group);
c66ac9db
NB
679 struct target_fabric_configfs *tf;
680 int ret;
681
0ff87549
NB
682 if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) {
683 pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:"
684 " %p to struct se_device: %p\n", se_dev_ci, dev);
685 return -EFAULT;
686 }
687
faa06ab9
NB
688 if (!(dev->dev_flags & DF_CONFIGURED)) {
689 pr_err("se_device not configured yet, cannot port link\n");
690 return -ENODEV;
691 }
692
c66ac9db
NB
693 tpg_ci = &lun_ci->ci_parent->ci_group->cg_item;
694 se_tpg = container_of(to_config_group(tpg_ci),
695 struct se_portal_group, tpg_group);
696 tf = se_tpg->se_tpg_wwn->wwn_tf;
697
698 if (lun->lun_se_dev != NULL) {
6708bb27 699 pr_err("Port Symlink already exists\n");
c66ac9db
NB
700 return -EEXIST;
701 }
702
6bb82612
NB
703 ret = core_dev_add_lun(se_tpg, dev, lun);
704 if (ret) {
705 pr_err("core_dev_add_lun() failed: %d\n", ret);
c66ac9db
NB
706 goto out;
707 }
708
ef0caf8d 709 if (tf->tf_ops->fabric_post_link) {
c66ac9db
NB
710 /*
711 * Call the optional fabric_post_link() to allow a
712 * fabric module to setup any additional state once
713 * core_dev_add_lun() has been called..
714 */
ef0caf8d 715 tf->tf_ops->fabric_post_link(se_tpg, lun);
c66ac9db
NB
716 }
717
718 return 0;
719out:
720 return ret;
721}
722
723static int target_fabric_port_unlink(
724 struct config_item *lun_ci,
725 struct config_item *se_dev_ci)
726{
727 struct se_lun *lun = container_of(to_config_group(lun_ci),
728 struct se_lun, lun_group);
adf653f9 729 struct se_portal_group *se_tpg = lun->lun_tpg;
c66ac9db
NB
730 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
731
ef0caf8d 732 if (tf->tf_ops->fabric_pre_unlink) {
c66ac9db
NB
733 /*
734 * Call the optional fabric_pre_unlink() to allow a
735 * fabric module to release any additional stat before
736 * core_dev_del_lun() is called.
737 */
ef0caf8d 738 tf->tf_ops->fabric_pre_unlink(se_tpg, lun);
c66ac9db
NB
739 }
740
cd9d7cba 741 core_dev_del_lun(se_tpg, lun);
c66ac9db
NB
742 return 0;
743}
744
6bb82612
NB
745static void target_fabric_port_release(struct config_item *item)
746{
747 struct se_lun *lun = container_of(to_config_group(item),
748 struct se_lun, lun_group);
749
750 kfree_rcu(lun, rcu_head);
751}
752
c66ac9db 753static struct configfs_item_operations target_fabric_port_item_ops = {
6bb82612 754 .release = target_fabric_port_release,
c66ac9db
NB
755 .allow_link = target_fabric_port_link,
756 .drop_link = target_fabric_port_unlink,
757};
758
759TF_CIT_SETUP(tpg_port, &target_fabric_port_item_ops, NULL, target_fabric_port_attrs);
760
761/* End of tfc_tpg_port_cit */
762
12d23384
NB
763/* Start of tfc_tpg_port_stat_cit */
764
765static struct config_group *target_core_port_stat_mkdir(
766 struct config_group *group,
767 const char *name)
768{
769 return ERR_PTR(-ENOSYS);
770}
771
772static void target_core_port_stat_rmdir(
773 struct config_group *group,
774 struct config_item *item)
775{
776 return;
777}
778
779static struct configfs_group_operations target_fabric_port_stat_group_ops = {
780 .make_group = target_core_port_stat_mkdir,
781 .drop_item = target_core_port_stat_rmdir,
782};
783
784TF_CIT_SETUP(tpg_port_stat, NULL, &target_fabric_port_stat_group_ops, NULL);
785
786/* End of tfc_tpg_port_stat_cit */
787
c66ac9db
NB
788/* Start of tfc_tpg_lun_cit */
789
790static struct config_group *target_fabric_make_lun(
791 struct config_group *group,
792 const char *name)
793{
794 struct se_lun *lun;
795 struct se_portal_group *se_tpg = container_of(group,
796 struct se_portal_group, tpg_lun_group);
797 struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
12d23384 798 struct config_group *lun_cg = NULL, *port_stat_grp = NULL;
f2d30680 799 unsigned long long unpacked_lun;
12d23384 800 int errno;
c66ac9db
NB
801
802 if (strstr(name, "lun_") != name) {
6708bb27 803 pr_err("Unable to locate \'_\" in"
c66ac9db
NB
804 " \"lun_$LUN_NUMBER\"\n");
805 return ERR_PTR(-EINVAL);
806 }
f2d30680 807 errno = kstrtoull(name + 4, 0, &unpacked_lun);
57103d7f
JH
808 if (errno)
809 return ERR_PTR(errno);
c66ac9db 810
6bb82612
NB
811 lun = core_tpg_alloc_lun(se_tpg, unpacked_lun);
812 if (IS_ERR(lun))
813 return ERR_CAST(lun);
c66ac9db 814
12d23384 815 lun_cg = &lun->lun_group;
13f6a914 816 lun_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
12d23384
NB
817 GFP_KERNEL);
818 if (!lun_cg->default_groups) {
6708bb27 819 pr_err("Unable to allocate lun_cg->default_groups\n");
6bb82612 820 kfree(lun);
12d23384
NB
821 return ERR_PTR(-ENOMEM);
822 }
823
c66ac9db 824 config_group_init_type_name(&lun->lun_group, name,
968ebe75 825 &tf->tf_tpg_port_cit);
12d23384 826 config_group_init_type_name(&lun->port_stat_grps.stat_group,
968ebe75 827 "statistics", &tf->tf_tpg_port_stat_cit);
12d23384
NB
828 lun_cg->default_groups[0] = &lun->port_stat_grps.stat_group;
829 lun_cg->default_groups[1] = NULL;
830
e3d6f909 831 port_stat_grp = &lun->port_stat_grps.stat_group;
ab6dae82 832 port_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) * 4,
12d23384
NB
833 GFP_KERNEL);
834 if (!port_stat_grp->default_groups) {
6708bb27 835 pr_err("Unable to allocate port_stat_grp->default_groups\n");
1481473b 836 kfree(lun_cg->default_groups);
6bb82612 837 kfree(lun);
1481473b 838 return ERR_PTR(-ENOMEM);
12d23384
NB
839 }
840 target_stat_setup_port_default_groups(lun);
c66ac9db
NB
841
842 return &lun->lun_group;
843}
844
845static void target_fabric_drop_lun(
846 struct config_group *group,
847 struct config_item *item)
848{
12d23384
NB
849 struct se_lun *lun = container_of(to_config_group(item),
850 struct se_lun, lun_group);
851 struct config_item *df_item;
852 struct config_group *lun_cg, *port_stat_grp;
853 int i;
854
e3d6f909 855 port_stat_grp = &lun->port_stat_grps.stat_group;
12d23384
NB
856 for (i = 0; port_stat_grp->default_groups[i]; i++) {
857 df_item = &port_stat_grp->default_groups[i]->cg_item;
858 port_stat_grp->default_groups[i] = NULL;
859 config_item_put(df_item);
860 }
861 kfree(port_stat_grp->default_groups);
862
863 lun_cg = &lun->lun_group;
864 for (i = 0; lun_cg->default_groups[i]; i++) {
865 df_item = &lun_cg->default_groups[i]->cg_item;
866 lun_cg->default_groups[i] = NULL;
867 config_item_put(df_item);
868 }
869 kfree(lun_cg->default_groups);
870
c66ac9db
NB
871 config_item_put(item);
872}
873
874static struct configfs_group_operations target_fabric_lun_group_ops = {
875 .make_group = &target_fabric_make_lun,
876 .drop_item = &target_fabric_drop_lun,
877};
878
879TF_CIT_SETUP(tpg_lun, NULL, &target_fabric_lun_group_ops, NULL);
880
881/* End of tfc_tpg_lun_cit */
882
2eafd729
CH
883TF_CIT_SETUP_DRV(tpg_attrib, NULL, NULL);
884TF_CIT_SETUP_DRV(tpg_auth, NULL, NULL);
885TF_CIT_SETUP_DRV(tpg_param, NULL, NULL);
c66ac9db
NB
886
887/* Start of tfc_tpg_base_cit */
c66ac9db 888
1f6fe7cb
NB
889static void target_fabric_tpg_release(struct config_item *item)
890{
891 struct se_portal_group *se_tpg = container_of(to_config_group(item),
892 struct se_portal_group, tpg_group);
893 struct se_wwn *wwn = se_tpg->se_tpg_wwn;
894 struct target_fabric_configfs *tf = wwn->wwn_tf;
895
ef0caf8d 896 tf->tf_ops->fabric_drop_tpg(se_tpg);
1f6fe7cb
NB
897}
898
c66ac9db 899static struct configfs_item_operations target_fabric_tpg_base_item_ops = {
1f6fe7cb 900 .release = target_fabric_tpg_release,
c66ac9db
NB
901};
902
9ac8928e 903TF_CIT_SETUP_DRV(tpg_base, &target_fabric_tpg_base_item_ops, NULL);
c66ac9db
NB
904
905/* End of tfc_tpg_base_cit */
906
907/* Start of tfc_tpg_cit */
908
909static struct config_group *target_fabric_make_tpg(
910 struct config_group *group,
911 const char *name)
912{
913 struct se_wwn *wwn = container_of(group, struct se_wwn, wwn_group);
914 struct target_fabric_configfs *tf = wwn->wwn_tf;
915 struct se_portal_group *se_tpg;
916
ef0caf8d
CH
917 if (!tf->tf_ops->fabric_make_tpg) {
918 pr_err("tf->tf_ops->fabric_make_tpg is NULL\n");
c66ac9db
NB
919 return ERR_PTR(-ENOSYS);
920 }
921
ef0caf8d 922 se_tpg = tf->tf_ops->fabric_make_tpg(wwn, group, name);
6708bb27 923 if (!se_tpg || IS_ERR(se_tpg))
c66ac9db
NB
924 return ERR_PTR(-EINVAL);
925 /*
926 * Setup default groups from pre-allocated se_tpg->tpg_default_groups
927 */
928 se_tpg->tpg_group.default_groups = se_tpg->tpg_default_groups;
929 se_tpg->tpg_group.default_groups[0] = &se_tpg->tpg_lun_group;
930 se_tpg->tpg_group.default_groups[1] = &se_tpg->tpg_np_group;
931 se_tpg->tpg_group.default_groups[2] = &se_tpg->tpg_acl_group;
932 se_tpg->tpg_group.default_groups[3] = &se_tpg->tpg_attrib_group;
e4b512e7
NB
933 se_tpg->tpg_group.default_groups[4] = &se_tpg->tpg_auth_group;
934 se_tpg->tpg_group.default_groups[5] = &se_tpg->tpg_param_group;
935 se_tpg->tpg_group.default_groups[6] = NULL;
c66ac9db
NB
936
937 config_group_init_type_name(&se_tpg->tpg_group, name,
968ebe75 938 &tf->tf_tpg_base_cit);
c66ac9db 939 config_group_init_type_name(&se_tpg->tpg_lun_group, "lun",
968ebe75 940 &tf->tf_tpg_lun_cit);
c66ac9db 941 config_group_init_type_name(&se_tpg->tpg_np_group, "np",
968ebe75 942 &tf->tf_tpg_np_cit);
c66ac9db 943 config_group_init_type_name(&se_tpg->tpg_acl_group, "acls",
968ebe75 944 &tf->tf_tpg_nacl_cit);
c66ac9db 945 config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib",
968ebe75 946 &tf->tf_tpg_attrib_cit);
e4b512e7 947 config_group_init_type_name(&se_tpg->tpg_auth_group, "auth",
968ebe75 948 &tf->tf_tpg_auth_cit);
c66ac9db 949 config_group_init_type_name(&se_tpg->tpg_param_group, "param",
968ebe75 950 &tf->tf_tpg_param_cit);
c66ac9db
NB
951
952 return &se_tpg->tpg_group;
953}
954
955static void target_fabric_drop_tpg(
956 struct config_group *group,
957 struct config_item *item)
958{
c66ac9db
NB
959 struct se_portal_group *se_tpg = container_of(to_config_group(item),
960 struct se_portal_group, tpg_group);
961 struct config_group *tpg_cg = &se_tpg->tpg_group;
962 struct config_item *df_item;
963 int i;
964 /*
965 * Release default groups, but do not release tpg_cg->default_groups
966 * memory as it is statically allocated at se_tpg->tpg_default_groups.
967 */
968 for (i = 0; tpg_cg->default_groups[i]; i++) {
969 df_item = &tpg_cg->default_groups[i]->cg_item;
970 tpg_cg->default_groups[i] = NULL;
971 config_item_put(df_item);
972 }
973
974 config_item_put(item);
c66ac9db
NB
975}
976
1f6fe7cb
NB
977static void target_fabric_release_wwn(struct config_item *item)
978{
979 struct se_wwn *wwn = container_of(to_config_group(item),
980 struct se_wwn, wwn_group);
981 struct target_fabric_configfs *tf = wwn->wwn_tf;
982
ef0caf8d 983 tf->tf_ops->fabric_drop_wwn(wwn);
1f6fe7cb
NB
984}
985
986static struct configfs_item_operations target_fabric_tpg_item_ops = {
987 .release = target_fabric_release_wwn,
988};
989
c66ac9db
NB
990static struct configfs_group_operations target_fabric_tpg_group_ops = {
991 .make_group = target_fabric_make_tpg,
992 .drop_item = target_fabric_drop_tpg,
993};
994
1f6fe7cb
NB
995TF_CIT_SETUP(tpg, &target_fabric_tpg_item_ops, &target_fabric_tpg_group_ops,
996 NULL);
c66ac9db
NB
997
998/* End of tfc_tpg_cit */
999
12d23384
NB
1000/* Start of tfc_wwn_fabric_stats_cit */
1001/*
1002 * This is used as a placeholder for struct se_wwn->fabric_stat_group
1003 * to allow fabrics access to ->fabric_stat_group->default_groups[]
1004 */
1005TF_CIT_SETUP(wwn_fabric_stats, NULL, NULL, NULL);
1006
1007/* End of tfc_wwn_fabric_stats_cit */
1008
c66ac9db
NB
1009/* Start of tfc_wwn_cit */
1010
1011static struct config_group *target_fabric_make_wwn(
1012 struct config_group *group,
1013 const char *name)
1014{
1015 struct target_fabric_configfs *tf = container_of(group,
1016 struct target_fabric_configfs, tf_group);
1017 struct se_wwn *wwn;
1018
ef0caf8d 1019 if (!tf->tf_ops->fabric_make_wwn) {
6708bb27 1020 pr_err("tf->tf_ops.fabric_make_wwn is NULL\n");
c66ac9db
NB
1021 return ERR_PTR(-ENOSYS);
1022 }
1023
ef0caf8d 1024 wwn = tf->tf_ops->fabric_make_wwn(tf, group, name);
6708bb27 1025 if (!wwn || IS_ERR(wwn))
c66ac9db
NB
1026 return ERR_PTR(-EINVAL);
1027
1028 wwn->wwn_tf = tf;
12d23384
NB
1029 /*
1030 * Setup default groups from pre-allocated wwn->wwn_default_groups
1031 */
1032 wwn->wwn_group.default_groups = wwn->wwn_default_groups;
1033 wwn->wwn_group.default_groups[0] = &wwn->fabric_stat_group;
1034 wwn->wwn_group.default_groups[1] = NULL;
1035
968ebe75 1036 config_group_init_type_name(&wwn->wwn_group, name, &tf->tf_tpg_cit);
12d23384 1037 config_group_init_type_name(&wwn->fabric_stat_group, "fabric_statistics",
968ebe75 1038 &tf->tf_wwn_fabric_stats_cit);
c66ac9db
NB
1039
1040 return &wwn->wwn_group;
1041}
1042
1043static void target_fabric_drop_wwn(
1044 struct config_group *group,
1045 struct config_item *item)
1046{
12d23384
NB
1047 struct se_wwn *wwn = container_of(to_config_group(item),
1048 struct se_wwn, wwn_group);
1049 struct config_item *df_item;
1050 struct config_group *cg = &wwn->wwn_group;
1051 int i;
1052
1053 for (i = 0; cg->default_groups[i]; i++) {
1054 df_item = &cg->default_groups[i]->cg_item;
1055 cg->default_groups[i] = NULL;
1056 config_item_put(df_item);
1057 }
1058
c66ac9db 1059 config_item_put(item);
c66ac9db
NB
1060}
1061
1062static struct configfs_group_operations target_fabric_wwn_group_ops = {
1063 .make_group = target_fabric_make_wwn,
1064 .drop_item = target_fabric_drop_wwn,
1065};
c66ac9db 1066
2eafd729
CH
1067TF_CIT_SETUP_DRV(wwn, NULL, &target_fabric_wwn_group_ops);
1068TF_CIT_SETUP_DRV(discovery, NULL, NULL);
c66ac9db
NB
1069
1070int target_fabric_setup_cits(struct target_fabric_configfs *tf)
1071{
1072 target_fabric_setup_discovery_cit(tf);
1073 target_fabric_setup_wwn_cit(tf);
12d23384 1074 target_fabric_setup_wwn_fabric_stats_cit(tf);
c66ac9db
NB
1075 target_fabric_setup_tpg_cit(tf);
1076 target_fabric_setup_tpg_base_cit(tf);
1077 target_fabric_setup_tpg_port_cit(tf);
12d23384 1078 target_fabric_setup_tpg_port_stat_cit(tf);
c66ac9db
NB
1079 target_fabric_setup_tpg_lun_cit(tf);
1080 target_fabric_setup_tpg_np_cit(tf);
1081 target_fabric_setup_tpg_np_base_cit(tf);
1082 target_fabric_setup_tpg_attrib_cit(tf);
e4b512e7 1083 target_fabric_setup_tpg_auth_cit(tf);
c66ac9db
NB
1084 target_fabric_setup_tpg_param_cit(tf);
1085 target_fabric_setup_tpg_nacl_cit(tf);
1086 target_fabric_setup_tpg_nacl_base_cit(tf);
1087 target_fabric_setup_tpg_nacl_attrib_cit(tf);
1088 target_fabric_setup_tpg_nacl_auth_cit(tf);
1089 target_fabric_setup_tpg_nacl_param_cit(tf);
12d23384 1090 target_fabric_setup_tpg_nacl_stat_cit(tf);
c66ac9db 1091 target_fabric_setup_tpg_mappedlun_cit(tf);
12d23384 1092 target_fabric_setup_tpg_mappedlun_stat_cit(tf);
c66ac9db
NB
1093
1094 return 0;
1095}