target: Subsume se_port + t10_alua_tg_pt_gp_member into se_lun
[deliverable/linux.git] / drivers / target / target_core_stat.c
CommitLineData
12d23384
NB
1/*******************************************************************************
2 * Filename: target_core_stat.c
3 *
12d23384
NB
4 * Modern ConfigFS group context specific statistics based on original
5 * target_core_mib.c code
6 *
4c76251e 7 * (c) Copyright 2006-2013 Datera, Inc.
12d23384
NB
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 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 *
25 ******************************************************************************/
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/delay.h>
30#include <linux/timer.h>
31#include <linux/string.h>
12d23384
NB
32#include <linux/utsname.h>
33#include <linux/proc_fs.h>
34#include <linux/seq_file.h>
12d23384
NB
35#include <linux/configfs.h>
36#include <scsi/scsi.h>
37#include <scsi/scsi_device.h>
38#include <scsi/scsi_host.h>
39
40#include <target/target_core_base.h>
c4795fb2
CH
41#include <target/target_core_backend.h>
42#include <target/target_core_fabric.h>
12d23384
NB
43#include <target/configfs_macros.h>
44
e26d99ae 45#include "target_core_internal.h"
12d23384
NB
46
47#ifndef INITIAL_JIFFIES
48#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
49#endif
50
51#define NONE "None"
52#define ISPRINT(a) ((a >= ' ') && (a <= '~'))
53
54#define SCSI_LU_INDEX 1
55#define LU_COUNT 1
56
57/*
58 * SCSI Device Table
59 */
60
61CONFIGFS_EATTR_STRUCT(target_stat_scsi_dev, se_dev_stat_grps);
62#define DEV_STAT_SCSI_DEV_ATTR(_name, _mode) \
63static struct target_stat_scsi_dev_attribute \
64 target_stat_scsi_dev_##_name = \
65 __CONFIGFS_EATTR(_name, _mode, \
66 target_stat_scsi_dev_show_attr_##_name, \
67 target_stat_scsi_dev_store_attr_##_name);
68
69#define DEV_STAT_SCSI_DEV_ATTR_RO(_name) \
70static struct target_stat_scsi_dev_attribute \
71 target_stat_scsi_dev_##_name = \
72 __CONFIGFS_EATTR_RO(_name, \
73 target_stat_scsi_dev_show_attr_##_name);
74
75static ssize_t target_stat_scsi_dev_show_attr_inst(
76 struct se_dev_stat_grps *sgrps, char *page)
77{
0fd97ccf
CH
78 struct se_device *dev =
79 container_of(sgrps, struct se_device, dev_stat_grps);
80 struct se_hba *hba = dev->se_hba;
12d23384
NB
81
82 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
83}
84DEV_STAT_SCSI_DEV_ATTR_RO(inst);
85
86static ssize_t target_stat_scsi_dev_show_attr_indx(
87 struct se_dev_stat_grps *sgrps, char *page)
88{
0fd97ccf
CH
89 struct se_device *dev =
90 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
91
92 return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
93}
94DEV_STAT_SCSI_DEV_ATTR_RO(indx);
95
96static ssize_t target_stat_scsi_dev_show_attr_role(
97 struct se_dev_stat_grps *sgrps, char *page)
98{
12d23384
NB
99 return snprintf(page, PAGE_SIZE, "Target\n");
100}
101DEV_STAT_SCSI_DEV_ATTR_RO(role);
102
103static ssize_t target_stat_scsi_dev_show_attr_ports(
104 struct se_dev_stat_grps *sgrps, char *page)
105{
0fd97ccf
CH
106 struct se_device *dev =
107 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384 108
adf653f9 109 return snprintf(page, PAGE_SIZE, "%u\n", dev->export_count);
12d23384
NB
110}
111DEV_STAT_SCSI_DEV_ATTR_RO(ports);
112
113CONFIGFS_EATTR_OPS(target_stat_scsi_dev, se_dev_stat_grps, scsi_dev_group);
114
115static struct configfs_attribute *target_stat_scsi_dev_attrs[] = {
116 &target_stat_scsi_dev_inst.attr,
117 &target_stat_scsi_dev_indx.attr,
118 &target_stat_scsi_dev_role.attr,
119 &target_stat_scsi_dev_ports.attr,
120 NULL,
121};
122
123static struct configfs_item_operations target_stat_scsi_dev_attrib_ops = {
124 .show_attribute = target_stat_scsi_dev_attr_show,
125 .store_attribute = target_stat_scsi_dev_attr_store,
126};
127
128static struct config_item_type target_stat_scsi_dev_cit = {
129 .ct_item_ops = &target_stat_scsi_dev_attrib_ops,
130 .ct_attrs = target_stat_scsi_dev_attrs,
131 .ct_owner = THIS_MODULE,
132};
133
134/*
135 * SCSI Target Device Table
136 */
137
138CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_dev, se_dev_stat_grps);
139#define DEV_STAT_SCSI_TGT_DEV_ATTR(_name, _mode) \
140static struct target_stat_scsi_tgt_dev_attribute \
141 target_stat_scsi_tgt_dev_##_name = \
142 __CONFIGFS_EATTR(_name, _mode, \
143 target_stat_scsi_tgt_dev_show_attr_##_name, \
144 target_stat_scsi_tgt_dev_store_attr_##_name);
145
146#define DEV_STAT_SCSI_TGT_DEV_ATTR_RO(_name) \
147static struct target_stat_scsi_tgt_dev_attribute \
148 target_stat_scsi_tgt_dev_##_name = \
149 __CONFIGFS_EATTR_RO(_name, \
150 target_stat_scsi_tgt_dev_show_attr_##_name);
151
152static ssize_t target_stat_scsi_tgt_dev_show_attr_inst(
153 struct se_dev_stat_grps *sgrps, char *page)
154{
0fd97ccf
CH
155 struct se_device *dev =
156 container_of(sgrps, struct se_device, dev_stat_grps);
157 struct se_hba *hba = dev->se_hba;
12d23384
NB
158
159 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
160}
161DEV_STAT_SCSI_TGT_DEV_ATTR_RO(inst);
162
163static ssize_t target_stat_scsi_tgt_dev_show_attr_indx(
164 struct se_dev_stat_grps *sgrps, char *page)
165{
0fd97ccf
CH
166 struct se_device *dev =
167 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
168
169 return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
170}
171DEV_STAT_SCSI_TGT_DEV_ATTR_RO(indx);
172
173static ssize_t target_stat_scsi_tgt_dev_show_attr_num_lus(
174 struct se_dev_stat_grps *sgrps, char *page)
175{
12d23384
NB
176 return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT);
177}
178DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus);
179
180static ssize_t target_stat_scsi_tgt_dev_show_attr_status(
181 struct se_dev_stat_grps *sgrps, char *page)
182{
0fd97ccf
CH
183 struct se_device *dev =
184 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384 185
0fd97ccf
CH
186 if (dev->export_count)
187 return snprintf(page, PAGE_SIZE, "activated");
188 else
189 return snprintf(page, PAGE_SIZE, "deactivated");
12d23384
NB
190}
191DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status);
192
193static ssize_t target_stat_scsi_tgt_dev_show_attr_non_access_lus(
194 struct se_dev_stat_grps *sgrps, char *page)
195{
0fd97ccf
CH
196 struct se_device *dev =
197 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
198 int non_accessible_lus;
199
0fd97ccf 200 if (dev->export_count)
12d23384 201 non_accessible_lus = 0;
0fd97ccf 202 else
12d23384 203 non_accessible_lus = 1;
12d23384
NB
204
205 return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus);
206}
207DEV_STAT_SCSI_TGT_DEV_ATTR_RO(non_access_lus);
208
209static ssize_t target_stat_scsi_tgt_dev_show_attr_resets(
210 struct se_dev_stat_grps *sgrps, char *page)
211{
0fd97ccf
CH
212 struct se_device *dev =
213 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384 214
ee480683
NB
215 return snprintf(page, PAGE_SIZE, "%lu\n",
216 atomic_long_read(&dev->num_resets));
12d23384
NB
217}
218DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets);
219
220
221CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_dev, se_dev_stat_grps, scsi_tgt_dev_group);
222
223static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = {
224 &target_stat_scsi_tgt_dev_inst.attr,
225 &target_stat_scsi_tgt_dev_indx.attr,
226 &target_stat_scsi_tgt_dev_num_lus.attr,
227 &target_stat_scsi_tgt_dev_status.attr,
228 &target_stat_scsi_tgt_dev_non_access_lus.attr,
229 &target_stat_scsi_tgt_dev_resets.attr,
230 NULL,
231};
232
233static struct configfs_item_operations target_stat_scsi_tgt_dev_attrib_ops = {
234 .show_attribute = target_stat_scsi_tgt_dev_attr_show,
235 .store_attribute = target_stat_scsi_tgt_dev_attr_store,
236};
237
238static struct config_item_type target_stat_scsi_tgt_dev_cit = {
239 .ct_item_ops = &target_stat_scsi_tgt_dev_attrib_ops,
240 .ct_attrs = target_stat_scsi_tgt_dev_attrs,
241 .ct_owner = THIS_MODULE,
242};
243
244/*
245 * SCSI Logical Unit Table
246 */
247
248CONFIGFS_EATTR_STRUCT(target_stat_scsi_lu, se_dev_stat_grps);
249#define DEV_STAT_SCSI_LU_ATTR(_name, _mode) \
250static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \
251 __CONFIGFS_EATTR(_name, _mode, \
252 target_stat_scsi_lu_show_attr_##_name, \
253 target_stat_scsi_lu_store_attr_##_name);
254
255#define DEV_STAT_SCSI_LU_ATTR_RO(_name) \
256static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \
257 __CONFIGFS_EATTR_RO(_name, \
258 target_stat_scsi_lu_show_attr_##_name);
259
260static ssize_t target_stat_scsi_lu_show_attr_inst(
261 struct se_dev_stat_grps *sgrps, char *page)
262{
0fd97ccf
CH
263 struct se_device *dev =
264 container_of(sgrps, struct se_device, dev_stat_grps);
265 struct se_hba *hba = dev->se_hba;
12d23384
NB
266
267 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
268}
269DEV_STAT_SCSI_LU_ATTR_RO(inst);
270
271static ssize_t target_stat_scsi_lu_show_attr_dev(
272 struct se_dev_stat_grps *sgrps, char *page)
273{
0fd97ccf
CH
274 struct se_device *dev =
275 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
276
277 return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
278}
279DEV_STAT_SCSI_LU_ATTR_RO(dev);
280
281static ssize_t target_stat_scsi_lu_show_attr_indx(
282 struct se_dev_stat_grps *sgrps, char *page)
283{
12d23384
NB
284 return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX);
285}
286DEV_STAT_SCSI_LU_ATTR_RO(indx);
287
288static ssize_t target_stat_scsi_lu_show_attr_lun(
289 struct se_dev_stat_grps *sgrps, char *page)
290{
12d23384
NB
291 /* FIXME: scsiLuDefaultLun */
292 return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0);
293}
294DEV_STAT_SCSI_LU_ATTR_RO(lun);
295
296static ssize_t target_stat_scsi_lu_show_attr_lu_name(
297 struct se_dev_stat_grps *sgrps, char *page)
298{
0fd97ccf
CH
299 struct se_device *dev =
300 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384 301
12d23384
NB
302 /* scsiLuWwnName */
303 return snprintf(page, PAGE_SIZE, "%s\n",
0fd97ccf
CH
304 (strlen(dev->t10_wwn.unit_serial)) ?
305 dev->t10_wwn.unit_serial : "None");
12d23384
NB
306}
307DEV_STAT_SCSI_LU_ATTR_RO(lu_name);
308
309static ssize_t target_stat_scsi_lu_show_attr_vend(
310 struct se_dev_stat_grps *sgrps, char *page)
311{
0fd97ccf
CH
312 struct se_device *dev =
313 container_of(sgrps, struct se_device, dev_stat_grps);
e3d6f909 314 int i;
0fd97ccf 315 char str[sizeof(dev->t10_wwn.vendor)+1];
e3d6f909 316
12d23384 317 /* scsiLuVendorId */
0fd97ccf
CH
318 for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++)
319 str[i] = ISPRINT(dev->t10_wwn.vendor[i]) ?
320 dev->t10_wwn.vendor[i] : ' ';
e3d6f909 321 str[i] = '\0';
12d23384
NB
322 return snprintf(page, PAGE_SIZE, "%s\n", str);
323}
324DEV_STAT_SCSI_LU_ATTR_RO(vend);
325
326static ssize_t target_stat_scsi_lu_show_attr_prod(
327 struct se_dev_stat_grps *sgrps, char *page)
328{
0fd97ccf
CH
329 struct se_device *dev =
330 container_of(sgrps, struct se_device, dev_stat_grps);
e3d6f909 331 int i;
0fd97ccf 332 char str[sizeof(dev->t10_wwn.model)+1];
12d23384
NB
333
334 /* scsiLuProductId */
0fd97ccf
CH
335 for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++)
336 str[i] = ISPRINT(dev->t10_wwn.model[i]) ?
337 dev->t10_wwn.model[i] : ' ';
e3d6f909 338 str[i] = '\0';
12d23384
NB
339 return snprintf(page, PAGE_SIZE, "%s\n", str);
340}
341DEV_STAT_SCSI_LU_ATTR_RO(prod);
342
343static ssize_t target_stat_scsi_lu_show_attr_rev(
344 struct se_dev_stat_grps *sgrps, char *page)
345{
0fd97ccf
CH
346 struct se_device *dev =
347 container_of(sgrps, struct se_device, dev_stat_grps);
e3d6f909 348 int i;
0fd97ccf 349 char str[sizeof(dev->t10_wwn.revision)+1];
12d23384
NB
350
351 /* scsiLuRevisionId */
0fd97ccf
CH
352 for (i = 0; i < sizeof(dev->t10_wwn.revision); i++)
353 str[i] = ISPRINT(dev->t10_wwn.revision[i]) ?
354 dev->t10_wwn.revision[i] : ' ';
e3d6f909 355 str[i] = '\0';
12d23384
NB
356 return snprintf(page, PAGE_SIZE, "%s\n", str);
357}
358DEV_STAT_SCSI_LU_ATTR_RO(rev);
359
360static ssize_t target_stat_scsi_lu_show_attr_dev_type(
361 struct se_dev_stat_grps *sgrps, char *page)
362{
0fd97ccf
CH
363 struct se_device *dev =
364 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
365
366 /* scsiLuPeripheralType */
367 return snprintf(page, PAGE_SIZE, "%u\n",
e3d6f909 368 dev->transport->get_device_type(dev));
12d23384
NB
369}
370DEV_STAT_SCSI_LU_ATTR_RO(dev_type);
371
372static ssize_t target_stat_scsi_lu_show_attr_status(
373 struct se_dev_stat_grps *sgrps, char *page)
374{
0fd97ccf
CH
375 struct se_device *dev =
376 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
377
378 /* scsiLuStatus */
379 return snprintf(page, PAGE_SIZE, "%s\n",
0fd97ccf 380 (dev->export_count) ? "available" : "notavailable");
12d23384
NB
381}
382DEV_STAT_SCSI_LU_ATTR_RO(status);
383
384static ssize_t target_stat_scsi_lu_show_attr_state_bit(
385 struct se_dev_stat_grps *sgrps, char *page)
386{
12d23384
NB
387 /* scsiLuState */
388 return snprintf(page, PAGE_SIZE, "exposed\n");
389}
390DEV_STAT_SCSI_LU_ATTR_RO(state_bit);
391
392static ssize_t target_stat_scsi_lu_show_attr_num_cmds(
393 struct se_dev_stat_grps *sgrps, char *page)
394{
0fd97ccf
CH
395 struct se_device *dev =
396 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
397
398 /* scsiLuNumCommands */
ee480683
NB
399 return snprintf(page, PAGE_SIZE, "%lu\n",
400 atomic_long_read(&dev->num_cmds));
12d23384
NB
401}
402DEV_STAT_SCSI_LU_ATTR_RO(num_cmds);
403
404static ssize_t target_stat_scsi_lu_show_attr_read_mbytes(
405 struct se_dev_stat_grps *sgrps, char *page)
406{
0fd97ccf
CH
407 struct se_device *dev =
408 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
409
410 /* scsiLuReadMegaBytes */
ee480683
NB
411 return snprintf(page, PAGE_SIZE, "%lu\n",
412 atomic_long_read(&dev->read_bytes) >> 20);
12d23384
NB
413}
414DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes);
415
416static ssize_t target_stat_scsi_lu_show_attr_write_mbytes(
417 struct se_dev_stat_grps *sgrps, char *page)
418{
0fd97ccf
CH
419 struct se_device *dev =
420 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
421
422 /* scsiLuWrittenMegaBytes */
ee480683
NB
423 return snprintf(page, PAGE_SIZE, "%lu\n",
424 atomic_long_read(&dev->write_bytes) >> 20);
12d23384
NB
425}
426DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes);
427
428static ssize_t target_stat_scsi_lu_show_attr_resets(
429 struct se_dev_stat_grps *sgrps, char *page)
430{
0fd97ccf
CH
431 struct se_device *dev =
432 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
433
434 /* scsiLuInResets */
ee480683 435 return snprintf(page, PAGE_SIZE, "%lu\n", atomic_long_read(&dev->num_resets));
12d23384
NB
436}
437DEV_STAT_SCSI_LU_ATTR_RO(resets);
438
439static ssize_t target_stat_scsi_lu_show_attr_full_stat(
440 struct se_dev_stat_grps *sgrps, char *page)
441{
12d23384
NB
442 /* FIXME: scsiLuOutTaskSetFullStatus */
443 return snprintf(page, PAGE_SIZE, "%u\n", 0);
444}
445DEV_STAT_SCSI_LU_ATTR_RO(full_stat);
446
447static ssize_t target_stat_scsi_lu_show_attr_hs_num_cmds(
448 struct se_dev_stat_grps *sgrps, char *page)
449{
12d23384
NB
450 /* FIXME: scsiLuHSInCommands */
451 return snprintf(page, PAGE_SIZE, "%u\n", 0);
452}
453DEV_STAT_SCSI_LU_ATTR_RO(hs_num_cmds);
454
455static ssize_t target_stat_scsi_lu_show_attr_creation_time(
456 struct se_dev_stat_grps *sgrps, char *page)
457{
0fd97ccf
CH
458 struct se_device *dev =
459 container_of(sgrps, struct se_device, dev_stat_grps);
12d23384
NB
460
461 /* scsiLuCreationTime */
462 return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time -
463 INITIAL_JIFFIES) * 100 / HZ));
464}
465DEV_STAT_SCSI_LU_ATTR_RO(creation_time);
466
467CONFIGFS_EATTR_OPS(target_stat_scsi_lu, se_dev_stat_grps, scsi_lu_group);
468
469static struct configfs_attribute *target_stat_scsi_lu_attrs[] = {
470 &target_stat_scsi_lu_inst.attr,
471 &target_stat_scsi_lu_dev.attr,
472 &target_stat_scsi_lu_indx.attr,
473 &target_stat_scsi_lu_lun.attr,
474 &target_stat_scsi_lu_lu_name.attr,
475 &target_stat_scsi_lu_vend.attr,
476 &target_stat_scsi_lu_prod.attr,
477 &target_stat_scsi_lu_rev.attr,
478 &target_stat_scsi_lu_dev_type.attr,
479 &target_stat_scsi_lu_status.attr,
480 &target_stat_scsi_lu_state_bit.attr,
481 &target_stat_scsi_lu_num_cmds.attr,
482 &target_stat_scsi_lu_read_mbytes.attr,
483 &target_stat_scsi_lu_write_mbytes.attr,
484 &target_stat_scsi_lu_resets.attr,
485 &target_stat_scsi_lu_full_stat.attr,
486 &target_stat_scsi_lu_hs_num_cmds.attr,
487 &target_stat_scsi_lu_creation_time.attr,
488 NULL,
489};
490
491static struct configfs_item_operations target_stat_scsi_lu_attrib_ops = {
492 .show_attribute = target_stat_scsi_lu_attr_show,
493 .store_attribute = target_stat_scsi_lu_attr_store,
494};
495
496static struct config_item_type target_stat_scsi_lu_cit = {
497 .ct_item_ops = &target_stat_scsi_lu_attrib_ops,
498 .ct_attrs = target_stat_scsi_lu_attrs,
499 .ct_owner = THIS_MODULE,
500};
501
502/*
503 * Called from target_core_configfs.c:target_core_make_subdev() to setup
504 * the target statistics groups + configfs CITs located in target_core_stat.c
505 */
0fd97ccf 506void target_stat_setup_dev_default_groups(struct se_device *dev)
12d23384 507{
0fd97ccf 508 struct config_group *dev_stat_grp = &dev->dev_stat_grps.stat_group;
12d23384 509
0fd97ccf 510 config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group,
12d23384 511 "scsi_dev", &target_stat_scsi_dev_cit);
0fd97ccf 512 config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group,
12d23384 513 "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit);
0fd97ccf 514 config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group,
12d23384
NB
515 "scsi_lu", &target_stat_scsi_lu_cit);
516
0fd97ccf
CH
517 dev_stat_grp->default_groups[0] = &dev->dev_stat_grps.scsi_dev_group;
518 dev_stat_grp->default_groups[1] = &dev->dev_stat_grps.scsi_tgt_dev_group;
519 dev_stat_grp->default_groups[2] = &dev->dev_stat_grps.scsi_lu_group;
12d23384
NB
520 dev_stat_grp->default_groups[3] = NULL;
521}
522
523/*
524 * SCSI Port Table
525 */
526
527CONFIGFS_EATTR_STRUCT(target_stat_scsi_port, se_port_stat_grps);
528#define DEV_STAT_SCSI_PORT_ATTR(_name, _mode) \
529static struct target_stat_scsi_port_attribute \
530 target_stat_scsi_port_##_name = \
531 __CONFIGFS_EATTR(_name, _mode, \
532 target_stat_scsi_port_show_attr_##_name, \
533 target_stat_scsi_port_store_attr_##_name);
534
535#define DEV_STAT_SCSI_PORT_ATTR_RO(_name) \
536static struct target_stat_scsi_port_attribute \
537 target_stat_scsi_port_##_name = \
538 __CONFIGFS_EATTR_RO(_name, \
539 target_stat_scsi_port_show_attr_##_name);
540
541static ssize_t target_stat_scsi_port_show_attr_inst(
542 struct se_port_stat_grps *pgrps, char *page)
543{
544 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
545 struct se_device *dev;
546 ssize_t ret = -ENODEV;
12d23384
NB
547
548 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
549 dev = lun->lun_se_dev;
550 if (dev)
551 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->se_hba->hba_index);
12d23384
NB
552 spin_unlock(&lun->lun_sep_lock);
553 return ret;
554}
555DEV_STAT_SCSI_PORT_ATTR_RO(inst);
556
557static ssize_t target_stat_scsi_port_show_attr_dev(
558 struct se_port_stat_grps *pgrps, char *page)
559{
560 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
561 struct se_device *dev;
562 ssize_t ret = -ENODEV;
12d23384
NB
563
564 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
565 dev = lun->lun_se_dev;
566 if (dev)
567 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
12d23384
NB
568 spin_unlock(&lun->lun_sep_lock);
569 return ret;
570}
571DEV_STAT_SCSI_PORT_ATTR_RO(dev);
572
573static ssize_t target_stat_scsi_port_show_attr_indx(
574 struct se_port_stat_grps *pgrps, char *page)
575{
576 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
577 struct se_device *dev;
578 ssize_t ret = -ENODEV;
12d23384
NB
579
580 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
581 dev = lun->lun_se_dev;
582 if (dev)
583 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi);
12d23384
NB
584 spin_unlock(&lun->lun_sep_lock);
585 return ret;
586}
587DEV_STAT_SCSI_PORT_ATTR_RO(indx);
588
589static ssize_t target_stat_scsi_port_show_attr_role(
590 struct se_port_stat_grps *pgrps, char *page)
591{
592 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
593 struct se_device *dev;
594 ssize_t ret = -ENODEV;
12d23384
NB
595
596 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
597 dev = lun->lun_se_dev;
598 if (dev)
599 ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index);
12d23384
NB
600 spin_unlock(&lun->lun_sep_lock);
601 return ret;
602}
603DEV_STAT_SCSI_PORT_ATTR_RO(role);
604
605static ssize_t target_stat_scsi_port_show_attr_busy_count(
606 struct se_port_stat_grps *pgrps, char *page)
607{
608 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
609 struct se_device *dev;
610 ssize_t ret = -ENODEV;
12d23384
NB
611
612 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
613 dev = lun->lun_se_dev;
614 if (dev) {
615 /* FIXME: scsiPortBusyStatuses */
616 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
12d23384 617 }
12d23384
NB
618 spin_unlock(&lun->lun_sep_lock);
619 return ret;
620}
621DEV_STAT_SCSI_PORT_ATTR_RO(busy_count);
622
623CONFIGFS_EATTR_OPS(target_stat_scsi_port, se_port_stat_grps, scsi_port_group);
624
625static struct configfs_attribute *target_stat_scsi_port_attrs[] = {
626 &target_stat_scsi_port_inst.attr,
627 &target_stat_scsi_port_dev.attr,
628 &target_stat_scsi_port_indx.attr,
629 &target_stat_scsi_port_role.attr,
630 &target_stat_scsi_port_busy_count.attr,
631 NULL,
632};
633
634static struct configfs_item_operations target_stat_scsi_port_attrib_ops = {
635 .show_attribute = target_stat_scsi_port_attr_show,
636 .store_attribute = target_stat_scsi_port_attr_store,
637};
638
639static struct config_item_type target_stat_scsi_port_cit = {
640 .ct_item_ops = &target_stat_scsi_port_attrib_ops,
641 .ct_attrs = target_stat_scsi_port_attrs,
642 .ct_owner = THIS_MODULE,
643};
644
645/*
646 * SCSI Target Port Table
647 */
648CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_port, se_port_stat_grps);
649#define DEV_STAT_SCSI_TGT_PORT_ATTR(_name, _mode) \
650static struct target_stat_scsi_tgt_port_attribute \
651 target_stat_scsi_tgt_port_##_name = \
652 __CONFIGFS_EATTR(_name, _mode, \
653 target_stat_scsi_tgt_port_show_attr_##_name, \
654 target_stat_scsi_tgt_port_store_attr_##_name);
655
656#define DEV_STAT_SCSI_TGT_PORT_ATTR_RO(_name) \
657static struct target_stat_scsi_tgt_port_attribute \
658 target_stat_scsi_tgt_port_##_name = \
659 __CONFIGFS_EATTR_RO(_name, \
660 target_stat_scsi_tgt_port_show_attr_##_name);
661
662static ssize_t target_stat_scsi_tgt_port_show_attr_inst(
663 struct se_port_stat_grps *pgrps, char *page)
664{
665 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
666 struct se_device *dev;
667 ssize_t ret = -ENODEV;
12d23384
NB
668
669 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
670 dev = lun->lun_se_dev;
671 if (dev)
672 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->se_hba->hba_index);
12d23384
NB
673 spin_unlock(&lun->lun_sep_lock);
674 return ret;
675}
676DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst);
677
678static ssize_t target_stat_scsi_tgt_port_show_attr_dev(
679 struct se_port_stat_grps *pgrps, char *page)
680{
681 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
682 struct se_device *dev;
683 ssize_t ret = -ENODEV;
12d23384
NB
684
685 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
686 dev = lun->lun_se_dev;
687 if (dev)
688 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
12d23384
NB
689 spin_unlock(&lun->lun_sep_lock);
690 return ret;
691}
692DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev);
693
694static ssize_t target_stat_scsi_tgt_port_show_attr_indx(
695 struct se_port_stat_grps *pgrps, char *page)
696{
697 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
698 struct se_device *dev;
699 ssize_t ret = -ENODEV;
12d23384
NB
700
701 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
702 dev = lun->lun_se_dev;
703 if (dev)
704 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi);
12d23384
NB
705 spin_unlock(&lun->lun_sep_lock);
706 return ret;
707}
708DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx);
709
710static ssize_t target_stat_scsi_tgt_port_show_attr_name(
711 struct se_port_stat_grps *pgrps, char *page)
712{
713 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
714 struct se_portal_group *tpg = lun->lun_tpg;
715 struct se_device *dev;
716 ssize_t ret = -ENODEV;
12d23384
NB
717
718 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
719 dev = lun->lun_se_dev;
720 if (dev)
721 ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n",
722 tpg->se_tpg_tfo->get_fabric_name(),
723 lun->lun_rtpi);
12d23384
NB
724 spin_unlock(&lun->lun_sep_lock);
725 return ret;
726}
727DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name);
728
729static ssize_t target_stat_scsi_tgt_port_show_attr_port_index(
730 struct se_port_stat_grps *pgrps, char *page)
731{
732 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
733 struct se_portal_group *tpg = lun->lun_tpg;
734 struct se_device *dev;
735 ssize_t ret = -ENODEV;
12d23384
NB
736
737 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
738 dev = lun->lun_se_dev;
739 if (dev)
740 ret = snprintf(page, PAGE_SIZE, "%s%s%d\n",
741 tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+",
742 tpg->se_tpg_tfo->tpg_get_tag(tpg));
12d23384
NB
743 spin_unlock(&lun->lun_sep_lock);
744 return ret;
745}
746DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index);
747
748static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds(
749 struct se_port_stat_grps *pgrps, char *page)
750{
751 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
752 struct se_device *dev;
753 ssize_t ret = -ENODEV;
12d23384
NB
754
755 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
756 dev = lun->lun_se_dev;
757 if (dev)
758 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_stats.cmd_pdus);
12d23384
NB
759 spin_unlock(&lun->lun_sep_lock);
760 return ret;
761}
762DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds);
763
764static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes(
765 struct se_port_stat_grps *pgrps, char *page)
766{
767 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
768 struct se_device *dev;
769 ssize_t ret = -ENODEV;
12d23384
NB
770
771 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
772 dev = lun->lun_se_dev;
773 if (dev)
774 ret = snprintf(page, PAGE_SIZE, "%u\n",
775 (u32)(lun->lun_stats.rx_data_octets >> 20));
12d23384
NB
776 spin_unlock(&lun->lun_sep_lock);
777 return ret;
778}
779DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes);
780
781static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes(
782 struct se_port_stat_grps *pgrps, char *page)
783{
784 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
785 struct se_device *dev;
786 ssize_t ret = -ENODEV;
12d23384
NB
787
788 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
789 dev = lun->lun_se_dev;
790 if (dev)
791 ret = snprintf(page, PAGE_SIZE, "%u\n",
792 (u32)(lun->lun_stats.tx_data_octets >> 20));
12d23384
NB
793 spin_unlock(&lun->lun_sep_lock);
794 return ret;
795}
796DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes);
797
798static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds(
799 struct se_port_stat_grps *pgrps, char *page)
800{
801 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
802 struct se_device *dev;
803 ssize_t ret = -ENODEV;
12d23384
NB
804
805 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
806 dev = lun->lun_se_dev;
807 if (dev) {
808 /* FIXME: scsiTgtPortHsInCommands */
809 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
12d23384 810 }
12d23384
NB
811 spin_unlock(&lun->lun_sep_lock);
812 return ret;
813}
814DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds);
815
816CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_port, se_port_stat_grps,
817 scsi_tgt_port_group);
818
819static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = {
820 &target_stat_scsi_tgt_port_inst.attr,
821 &target_stat_scsi_tgt_port_dev.attr,
822 &target_stat_scsi_tgt_port_indx.attr,
823 &target_stat_scsi_tgt_port_name.attr,
824 &target_stat_scsi_tgt_port_port_index.attr,
825 &target_stat_scsi_tgt_port_in_cmds.attr,
826 &target_stat_scsi_tgt_port_write_mbytes.attr,
827 &target_stat_scsi_tgt_port_read_mbytes.attr,
828 &target_stat_scsi_tgt_port_hs_in_cmds.attr,
829 NULL,
830};
831
832static struct configfs_item_operations target_stat_scsi_tgt_port_attrib_ops = {
833 .show_attribute = target_stat_scsi_tgt_port_attr_show,
834 .store_attribute = target_stat_scsi_tgt_port_attr_store,
835};
836
837static struct config_item_type target_stat_scsi_tgt_port_cit = {
838 .ct_item_ops = &target_stat_scsi_tgt_port_attrib_ops,
839 .ct_attrs = target_stat_scsi_tgt_port_attrs,
840 .ct_owner = THIS_MODULE,
841};
842
843/*
844 * SCSI Transport Table
845o */
846
847CONFIGFS_EATTR_STRUCT(target_stat_scsi_transport, se_port_stat_grps);
848#define DEV_STAT_SCSI_TRANSPORT_ATTR(_name, _mode) \
849static struct target_stat_scsi_transport_attribute \
850 target_stat_scsi_transport_##_name = \
851 __CONFIGFS_EATTR(_name, _mode, \
852 target_stat_scsi_transport_show_attr_##_name, \
853 target_stat_scsi_transport_store_attr_##_name);
854
855#define DEV_STAT_SCSI_TRANSPORT_ATTR_RO(_name) \
856static struct target_stat_scsi_transport_attribute \
857 target_stat_scsi_transport_##_name = \
858 __CONFIGFS_EATTR_RO(_name, \
859 target_stat_scsi_transport_show_attr_##_name);
860
861static ssize_t target_stat_scsi_transport_show_attr_inst(
862 struct se_port_stat_grps *pgrps, char *page)
863{
864 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
865 struct se_device *dev;
866 ssize_t ret = -ENODEV;
12d23384
NB
867
868 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
869 dev = lun->lun_se_dev;
870 if (dev)
871 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->se_hba->hba_index);
12d23384
NB
872 spin_unlock(&lun->lun_sep_lock);
873 return ret;
874}
875DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst);
876
877static ssize_t target_stat_scsi_transport_show_attr_device(
878 struct se_port_stat_grps *pgrps, char *page)
879{
880 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
881 struct se_device *dev;
882 struct se_portal_group *tpg = lun->lun_tpg;
883 ssize_t ret = -ENODEV;
12d23384
NB
884
885 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
886 dev = lun->lun_se_dev;
887 if (dev) {
888 /* scsiTransportType */
889 ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n",
890 tpg->se_tpg_tfo->get_fabric_name());
12d23384 891 }
12d23384
NB
892 spin_unlock(&lun->lun_sep_lock);
893 return ret;
894}
895DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device);
896
897static ssize_t target_stat_scsi_transport_show_attr_indx(
898 struct se_port_stat_grps *pgrps, char *page)
899{
900 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
adf653f9
CH
901 struct se_device *dev;
902 struct se_portal_group *tpg = lun->lun_tpg;
903 ssize_t ret = -ENODEV;
12d23384
NB
904
905 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
906 dev = lun->lun_se_dev;
907 if (dev)
908 ret = snprintf(page, PAGE_SIZE, "%u\n",
909 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
12d23384
NB
910 spin_unlock(&lun->lun_sep_lock);
911 return ret;
912}
913DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx);
914
915static ssize_t target_stat_scsi_transport_show_attr_dev_name(
916 struct se_port_stat_grps *pgrps, char *page)
917{
918 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
919 struct se_device *dev = lun->lun_se_dev;
adf653f9 920 struct se_portal_group *tpg = lun->lun_tpg;
12d23384 921 struct t10_wwn *wwn;
adf653f9 922 ssize_t ret = -ENODEV;
12d23384
NB
923
924 spin_lock(&lun->lun_sep_lock);
adf653f9
CH
925 dev = lun->lun_se_dev;
926 if (dev) {
927 wwn = &dev->t10_wwn;
928 /* scsiTransportDevName */
929 ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
930 tpg->se_tpg_tfo->tpg_get_wwn(tpg),
931 (strlen(wwn->unit_serial)) ? wwn->unit_serial :
932 wwn->vendor);
12d23384 933 }
12d23384
NB
934 spin_unlock(&lun->lun_sep_lock);
935 return ret;
936}
937DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name);
938
939CONFIGFS_EATTR_OPS(target_stat_scsi_transport, se_port_stat_grps,
940 scsi_transport_group);
941
942static struct configfs_attribute *target_stat_scsi_transport_attrs[] = {
943 &target_stat_scsi_transport_inst.attr,
944 &target_stat_scsi_transport_device.attr,
945 &target_stat_scsi_transport_indx.attr,
946 &target_stat_scsi_transport_dev_name.attr,
947 NULL,
948};
949
950static struct configfs_item_operations target_stat_scsi_transport_attrib_ops = {
951 .show_attribute = target_stat_scsi_transport_attr_show,
952 .store_attribute = target_stat_scsi_transport_attr_store,
953};
954
955static struct config_item_type target_stat_scsi_transport_cit = {
956 .ct_item_ops = &target_stat_scsi_transport_attrib_ops,
957 .ct_attrs = target_stat_scsi_transport_attrs,
958 .ct_owner = THIS_MODULE,
959};
960
961/*
962 * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup
963 * the target port statistics groups + configfs CITs located in target_core_stat.c
964 */
965void target_stat_setup_port_default_groups(struct se_lun *lun)
966{
e3d6f909 967 struct config_group *port_stat_grp = &lun->port_stat_grps.stat_group;
12d23384 968
e3d6f909 969 config_group_init_type_name(&lun->port_stat_grps.scsi_port_group,
12d23384 970 "scsi_port", &target_stat_scsi_port_cit);
e3d6f909 971 config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group,
12d23384 972 "scsi_tgt_port", &target_stat_scsi_tgt_port_cit);
e3d6f909 973 config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group,
12d23384
NB
974 "scsi_transport", &target_stat_scsi_transport_cit);
975
e3d6f909
AG
976 port_stat_grp->default_groups[0] = &lun->port_stat_grps.scsi_port_group;
977 port_stat_grp->default_groups[1] = &lun->port_stat_grps.scsi_tgt_port_group;
978 port_stat_grp->default_groups[2] = &lun->port_stat_grps.scsi_transport_group;
12d23384
NB
979 port_stat_grp->default_groups[3] = NULL;
980}
981
982/*
983 * SCSI Authorized Initiator Table
984 */
985
986CONFIGFS_EATTR_STRUCT(target_stat_scsi_auth_intr, se_ml_stat_grps);
987#define DEV_STAT_SCSI_AUTH_INTR_ATTR(_name, _mode) \
988static struct target_stat_scsi_auth_intr_attribute \
989 target_stat_scsi_auth_intr_##_name = \
990 __CONFIGFS_EATTR(_name, _mode, \
991 target_stat_scsi_auth_intr_show_attr_##_name, \
992 target_stat_scsi_auth_intr_store_attr_##_name);
993
994#define DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(_name) \
995static struct target_stat_scsi_auth_intr_attribute \
996 target_stat_scsi_auth_intr_##_name = \
997 __CONFIGFS_EATTR_RO(_name, \
998 target_stat_scsi_auth_intr_show_attr_##_name);
999
1000static ssize_t target_stat_scsi_auth_intr_show_attr_inst(
1001 struct se_ml_stat_grps *lgrps, char *page)
1002{
1003 struct se_lun_acl *lacl = container_of(lgrps,
1004 struct se_lun_acl, ml_stat_grps);
1005 struct se_node_acl *nacl = lacl->se_lun_nacl;
1006 struct se_dev_entry *deve;
1007 struct se_portal_group *tpg;
1008 ssize_t ret;
1009
29a05dee
NB
1010 rcu_read_lock();
1011 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1012 if (!deve) {
1013 rcu_read_unlock();
12d23384
NB
1014 return -ENODEV;
1015 }
1016 tpg = nacl->se_tpg;
1017 /* scsiInstIndex */
1018 ret = snprintf(page, PAGE_SIZE, "%u\n",
e3d6f909 1019 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
29a05dee 1020 rcu_read_unlock();
12d23384
NB
1021 return ret;
1022}
1023DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst);
1024
1025static ssize_t target_stat_scsi_auth_intr_show_attr_dev(
1026 struct se_ml_stat_grps *lgrps, char *page)
1027{
1028 struct se_lun_acl *lacl = container_of(lgrps,
1029 struct se_lun_acl, ml_stat_grps);
1030 struct se_node_acl *nacl = lacl->se_lun_nacl;
1031 struct se_dev_entry *deve;
1032 struct se_lun *lun;
12d23384
NB
1033 ssize_t ret;
1034
29a05dee
NB
1035 rcu_read_lock();
1036 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1037 if (!deve) {
1038 rcu_read_unlock();
12d23384
NB
1039 return -ENODEV;
1040 }
29a05dee 1041 lun = rcu_dereference(deve->se_lun);
12d23384 1042 /* scsiDeviceIndex */
29a05dee
NB
1043 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index);
1044 rcu_read_unlock();
12d23384
NB
1045 return ret;
1046}
1047DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev);
1048
1049static ssize_t target_stat_scsi_auth_intr_show_attr_port(
1050 struct se_ml_stat_grps *lgrps, char *page)
1051{
1052 struct se_lun_acl *lacl = container_of(lgrps,
1053 struct se_lun_acl, ml_stat_grps);
1054 struct se_node_acl *nacl = lacl->se_lun_nacl;
1055 struct se_dev_entry *deve;
1056 struct se_portal_group *tpg;
1057 ssize_t ret;
1058
29a05dee
NB
1059 rcu_read_lock();
1060 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1061 if (!deve) {
1062 rcu_read_unlock();
12d23384
NB
1063 return -ENODEV;
1064 }
1065 tpg = nacl->se_tpg;
1066 /* scsiAuthIntrTgtPortIndex */
e3d6f909 1067 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
29a05dee 1068 rcu_read_unlock();
12d23384
NB
1069 return ret;
1070}
1071DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port);
1072
1073static ssize_t target_stat_scsi_auth_intr_show_attr_indx(
1074 struct se_ml_stat_grps *lgrps, char *page)
1075{
1076 struct se_lun_acl *lacl = container_of(lgrps,
1077 struct se_lun_acl, ml_stat_grps);
1078 struct se_node_acl *nacl = lacl->se_lun_nacl;
1079 struct se_dev_entry *deve;
1080 ssize_t ret;
1081
29a05dee
NB
1082 rcu_read_lock();
1083 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1084 if (!deve) {
1085 rcu_read_unlock();
12d23384
NB
1086 return -ENODEV;
1087 }
1088 /* scsiAuthIntrIndex */
1089 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
29a05dee 1090 rcu_read_unlock();
12d23384
NB
1091 return ret;
1092}
1093DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx);
1094
1095static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port(
1096 struct se_ml_stat_grps *lgrps, char *page)
1097{
1098 struct se_lun_acl *lacl = container_of(lgrps,
1099 struct se_lun_acl, ml_stat_grps);
1100 struct se_node_acl *nacl = lacl->se_lun_nacl;
1101 struct se_dev_entry *deve;
1102 ssize_t ret;
1103
29a05dee
NB
1104 rcu_read_lock();
1105 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1106 if (!deve) {
1107 rcu_read_unlock();
12d23384
NB
1108 return -ENODEV;
1109 }
1110 /* scsiAuthIntrDevOrPort */
1111 ret = snprintf(page, PAGE_SIZE, "%u\n", 1);
29a05dee 1112 rcu_read_unlock();
12d23384
NB
1113 return ret;
1114}
1115DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port);
1116
1117static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name(
1118 struct se_ml_stat_grps *lgrps, char *page)
1119{
1120 struct se_lun_acl *lacl = container_of(lgrps,
1121 struct se_lun_acl, ml_stat_grps);
1122 struct se_node_acl *nacl = lacl->se_lun_nacl;
1123 struct se_dev_entry *deve;
1124 ssize_t ret;
1125
29a05dee
NB
1126 rcu_read_lock();
1127 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1128 if (!deve) {
1129 rcu_read_unlock();
12d23384
NB
1130 return -ENODEV;
1131 }
1132 /* scsiAuthIntrName */
1133 ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname);
29a05dee 1134 rcu_read_unlock();
12d23384
NB
1135 return ret;
1136}
1137DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name);
1138
1139static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx(
1140 struct se_ml_stat_grps *lgrps, char *page)
1141{
1142 struct se_lun_acl *lacl = container_of(lgrps,
1143 struct se_lun_acl, ml_stat_grps);
1144 struct se_node_acl *nacl = lacl->se_lun_nacl;
1145 struct se_dev_entry *deve;
1146 ssize_t ret;
1147
29a05dee
NB
1148 rcu_read_lock();
1149 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1150 if (!deve) {
1151 rcu_read_unlock();
12d23384
NB
1152 return -ENODEV;
1153 }
1154 /* FIXME: scsiAuthIntrLunMapIndex */
1155 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
29a05dee 1156 rcu_read_unlock();
12d23384
NB
1157 return ret;
1158}
1159DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx);
1160
1161static ssize_t target_stat_scsi_auth_intr_show_attr_att_count(
1162 struct se_ml_stat_grps *lgrps, char *page)
1163{
1164 struct se_lun_acl *lacl = container_of(lgrps,
1165 struct se_lun_acl, ml_stat_grps);
1166 struct se_node_acl *nacl = lacl->se_lun_nacl;
1167 struct se_dev_entry *deve;
1168 ssize_t ret;
1169
29a05dee
NB
1170 rcu_read_lock();
1171 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1172 if (!deve) {
1173 rcu_read_unlock();
12d23384
NB
1174 return -ENODEV;
1175 }
1176 /* scsiAuthIntrAttachedTimes */
1177 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count);
29a05dee 1178 rcu_read_unlock();
12d23384
NB
1179 return ret;
1180}
1181DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count);
1182
1183static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds(
1184 struct se_ml_stat_grps *lgrps, char *page)
1185{
1186 struct se_lun_acl *lacl = container_of(lgrps,
1187 struct se_lun_acl, ml_stat_grps);
1188 struct se_node_acl *nacl = lacl->se_lun_nacl;
1189 struct se_dev_entry *deve;
1190 ssize_t ret;
1191
29a05dee
NB
1192 rcu_read_lock();
1193 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1194 if (!deve) {
1195 rcu_read_unlock();
12d23384
NB
1196 return -ENODEV;
1197 }
1198 /* scsiAuthIntrOutCommands */
29a05dee
NB
1199 ret = snprintf(page, PAGE_SIZE, "%lu\n",
1200 atomic_long_read(&deve->total_cmds));
1201 rcu_read_unlock();
12d23384
NB
1202 return ret;
1203}
1204DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds);
1205
1206static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes(
1207 struct se_ml_stat_grps *lgrps, char *page)
1208{
1209 struct se_lun_acl *lacl = container_of(lgrps,
1210 struct se_lun_acl, ml_stat_grps);
1211 struct se_node_acl *nacl = lacl->se_lun_nacl;
1212 struct se_dev_entry *deve;
1213 ssize_t ret;
1214
29a05dee
NB
1215 rcu_read_lock();
1216 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1217 if (!deve) {
1218 rcu_read_unlock();
12d23384
NB
1219 return -ENODEV;
1220 }
1221 /* scsiAuthIntrReadMegaBytes */
29a05dee
NB
1222 ret = snprintf(page, PAGE_SIZE, "%u\n",
1223 (u32)(atomic_long_read(&deve->read_bytes) >> 20));
1224 rcu_read_unlock();
12d23384
NB
1225 return ret;
1226}
1227DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes);
1228
1229static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes(
1230 struct se_ml_stat_grps *lgrps, char *page)
1231{
1232 struct se_lun_acl *lacl = container_of(lgrps,
1233 struct se_lun_acl, ml_stat_grps);
1234 struct se_node_acl *nacl = lacl->se_lun_nacl;
1235 struct se_dev_entry *deve;
1236 ssize_t ret;
1237
29a05dee
NB
1238 rcu_read_lock();
1239 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1240 if (!deve) {
1241 rcu_read_unlock();
12d23384
NB
1242 return -ENODEV;
1243 }
1244 /* scsiAuthIntrWrittenMegaBytes */
29a05dee
NB
1245 ret = snprintf(page, PAGE_SIZE, "%u\n",
1246 (u32)(atomic_long_read(&deve->write_bytes) >> 20));
1247 rcu_read_unlock();
12d23384
NB
1248 return ret;
1249}
1250DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes);
1251
1252static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds(
1253 struct se_ml_stat_grps *lgrps, char *page)
1254{
1255 struct se_lun_acl *lacl = container_of(lgrps,
1256 struct se_lun_acl, ml_stat_grps);
1257 struct se_node_acl *nacl = lacl->se_lun_nacl;
1258 struct se_dev_entry *deve;
1259 ssize_t ret;
1260
29a05dee
NB
1261 rcu_read_lock();
1262 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1263 if (!deve) {
1264 rcu_read_unlock();
12d23384
NB
1265 return -ENODEV;
1266 }
1267 /* FIXME: scsiAuthIntrHSOutCommands */
1268 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
29a05dee 1269 rcu_read_unlock();
12d23384
NB
1270 return ret;
1271}
1272DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds);
1273
1274static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time(
1275 struct se_ml_stat_grps *lgrps, char *page)
1276{
1277 struct se_lun_acl *lacl = container_of(lgrps,
1278 struct se_lun_acl, ml_stat_grps);
1279 struct se_node_acl *nacl = lacl->se_lun_nacl;
1280 struct se_dev_entry *deve;
1281 ssize_t ret;
1282
29a05dee
NB
1283 rcu_read_lock();
1284 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1285 if (!deve) {
1286 rcu_read_unlock();
12d23384
NB
1287 return -ENODEV;
1288 }
1289 /* scsiAuthIntrLastCreation */
1290 ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time -
1291 INITIAL_JIFFIES) * 100 / HZ));
29a05dee 1292 rcu_read_unlock();
12d23384
NB
1293 return ret;
1294}
1295DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time);
1296
1297static ssize_t target_stat_scsi_auth_intr_show_attr_row_status(
1298 struct se_ml_stat_grps *lgrps, char *page)
1299{
1300 struct se_lun_acl *lacl = container_of(lgrps,
1301 struct se_lun_acl, ml_stat_grps);
1302 struct se_node_acl *nacl = lacl->se_lun_nacl;
1303 struct se_dev_entry *deve;
1304 ssize_t ret;
1305
29a05dee
NB
1306 rcu_read_lock();
1307 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1308 if (!deve) {
1309 rcu_read_unlock();
12d23384
NB
1310 return -ENODEV;
1311 }
1312 /* FIXME: scsiAuthIntrRowStatus */
1313 ret = snprintf(page, PAGE_SIZE, "Ready\n");
29a05dee 1314 rcu_read_unlock();
12d23384
NB
1315 return ret;
1316}
1317DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status);
1318
1319CONFIGFS_EATTR_OPS(target_stat_scsi_auth_intr, se_ml_stat_grps,
1320 scsi_auth_intr_group);
1321
1322static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = {
1323 &target_stat_scsi_auth_intr_inst.attr,
1324 &target_stat_scsi_auth_intr_dev.attr,
1325 &target_stat_scsi_auth_intr_port.attr,
1326 &target_stat_scsi_auth_intr_indx.attr,
1327 &target_stat_scsi_auth_intr_dev_or_port.attr,
1328 &target_stat_scsi_auth_intr_intr_name.attr,
1329 &target_stat_scsi_auth_intr_map_indx.attr,
1330 &target_stat_scsi_auth_intr_att_count.attr,
1331 &target_stat_scsi_auth_intr_num_cmds.attr,
1332 &target_stat_scsi_auth_intr_read_mbytes.attr,
1333 &target_stat_scsi_auth_intr_write_mbytes.attr,
1334 &target_stat_scsi_auth_intr_hs_num_cmds.attr,
1335 &target_stat_scsi_auth_intr_creation_time.attr,
1336 &target_stat_scsi_auth_intr_row_status.attr,
1337 NULL,
1338};
1339
1340static struct configfs_item_operations target_stat_scsi_auth_intr_attrib_ops = {
1341 .show_attribute = target_stat_scsi_auth_intr_attr_show,
1342 .store_attribute = target_stat_scsi_auth_intr_attr_store,
1343};
1344
1345static struct config_item_type target_stat_scsi_auth_intr_cit = {
1346 .ct_item_ops = &target_stat_scsi_auth_intr_attrib_ops,
1347 .ct_attrs = target_stat_scsi_auth_intr_attrs,
1348 .ct_owner = THIS_MODULE,
1349};
1350
1351/*
1352 * SCSI Attached Initiator Port Table
1353 */
1354
1355CONFIGFS_EATTR_STRUCT(target_stat_scsi_att_intr_port, se_ml_stat_grps);
1356#define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR(_name, _mode) \
1357static struct target_stat_scsi_att_intr_port_attribute \
1358 target_stat_scsi_att_intr_port_##_name = \
1359 __CONFIGFS_EATTR(_name, _mode, \
1360 target_stat_scsi_att_intr_port_show_attr_##_name, \
1361 target_stat_scsi_att_intr_port_store_attr_##_name);
1362
1363#define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(_name) \
1364static struct target_stat_scsi_att_intr_port_attribute \
1365 target_stat_scsi_att_intr_port_##_name = \
1366 __CONFIGFS_EATTR_RO(_name, \
1367 target_stat_scsi_att_intr_port_show_attr_##_name);
1368
1369static ssize_t target_stat_scsi_att_intr_port_show_attr_inst(
1370 struct se_ml_stat_grps *lgrps, char *page)
1371{
1372 struct se_lun_acl *lacl = container_of(lgrps,
1373 struct se_lun_acl, ml_stat_grps);
1374 struct se_node_acl *nacl = lacl->se_lun_nacl;
1375 struct se_dev_entry *deve;
1376 struct se_portal_group *tpg;
1377 ssize_t ret;
1378
29a05dee
NB
1379 rcu_read_lock();
1380 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1381 if (!deve) {
1382 rcu_read_unlock();
12d23384
NB
1383 return -ENODEV;
1384 }
1385 tpg = nacl->se_tpg;
1386 /* scsiInstIndex */
1387 ret = snprintf(page, PAGE_SIZE, "%u\n",
e3d6f909 1388 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
29a05dee 1389 rcu_read_unlock();
12d23384
NB
1390 return ret;
1391}
1392DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst);
1393
1394static ssize_t target_stat_scsi_att_intr_port_show_attr_dev(
1395 struct se_ml_stat_grps *lgrps, char *page)
1396{
1397 struct se_lun_acl *lacl = container_of(lgrps,
1398 struct se_lun_acl, ml_stat_grps);
1399 struct se_node_acl *nacl = lacl->se_lun_nacl;
1400 struct se_dev_entry *deve;
1401 struct se_lun *lun;
12d23384
NB
1402 ssize_t ret;
1403
29a05dee
NB
1404 rcu_read_lock();
1405 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1406 if (!deve) {
1407 rcu_read_unlock();
12d23384
NB
1408 return -ENODEV;
1409 }
29a05dee 1410 lun = rcu_dereference(deve->se_lun);
12d23384 1411 /* scsiDeviceIndex */
29a05dee
NB
1412 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index);
1413 rcu_read_unlock();
12d23384
NB
1414 return ret;
1415}
1416DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev);
1417
1418static ssize_t target_stat_scsi_att_intr_port_show_attr_port(
1419 struct se_ml_stat_grps *lgrps, char *page)
1420{
1421 struct se_lun_acl *lacl = container_of(lgrps,
1422 struct se_lun_acl, ml_stat_grps);
1423 struct se_node_acl *nacl = lacl->se_lun_nacl;
1424 struct se_dev_entry *deve;
1425 struct se_portal_group *tpg;
1426 ssize_t ret;
1427
29a05dee
NB
1428 rcu_read_lock();
1429 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1430 if (!deve) {
1431 rcu_read_unlock();
12d23384
NB
1432 return -ENODEV;
1433 }
1434 tpg = nacl->se_tpg;
1435 /* scsiPortIndex */
e3d6f909 1436 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
29a05dee 1437 rcu_read_unlock();
12d23384
NB
1438 return ret;
1439}
1440DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port);
1441
1442static ssize_t target_stat_scsi_att_intr_port_show_attr_indx(
1443 struct se_ml_stat_grps *lgrps, char *page)
1444{
1445 struct se_lun_acl *lacl = container_of(lgrps,
1446 struct se_lun_acl, ml_stat_grps);
1447 struct se_node_acl *nacl = lacl->se_lun_nacl;
1448 struct se_session *se_sess;
1449 struct se_portal_group *tpg;
1450 ssize_t ret;
1451
1452 spin_lock_irq(&nacl->nacl_sess_lock);
1453 se_sess = nacl->nacl_sess;
1454 if (!se_sess) {
1455 spin_unlock_irq(&nacl->nacl_sess_lock);
1456 return -ENODEV;
1457 }
1458
1459 tpg = nacl->se_tpg;
1460 /* scsiAttIntrPortIndex */
1461 ret = snprintf(page, PAGE_SIZE, "%u\n",
e3d6f909 1462 tpg->se_tpg_tfo->sess_get_index(se_sess));
12d23384
NB
1463 spin_unlock_irq(&nacl->nacl_sess_lock);
1464 return ret;
1465}
1466DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(indx);
1467
1468static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx(
1469 struct se_ml_stat_grps *lgrps, char *page)
1470{
1471 struct se_lun_acl *lacl = container_of(lgrps,
1472 struct se_lun_acl, ml_stat_grps);
1473 struct se_node_acl *nacl = lacl->se_lun_nacl;
1474 struct se_dev_entry *deve;
1475 ssize_t ret;
1476
29a05dee
NB
1477 rcu_read_lock();
1478 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1479 if (!deve) {
1480 rcu_read_unlock();
12d23384
NB
1481 return -ENODEV;
1482 }
1483 /* scsiAttIntrPortAuthIntrIdx */
1484 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
29a05dee 1485 rcu_read_unlock();
12d23384
NB
1486 return ret;
1487}
1488DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx);
1489
1490static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident(
1491 struct se_ml_stat_grps *lgrps, char *page)
1492{
1493 struct se_lun_acl *lacl = container_of(lgrps,
1494 struct se_lun_acl, ml_stat_grps);
1495 struct se_node_acl *nacl = lacl->se_lun_nacl;
1496 struct se_session *se_sess;
1497 struct se_portal_group *tpg;
1498 ssize_t ret;
1499 unsigned char buf[64];
1500
1501 spin_lock_irq(&nacl->nacl_sess_lock);
1502 se_sess = nacl->nacl_sess;
1503 if (!se_sess) {
1504 spin_unlock_irq(&nacl->nacl_sess_lock);
1505 return -ENODEV;
1506 }
1507
1508 tpg = nacl->se_tpg;
1509 /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
1510 memset(buf, 0, 64);
e3d6f909 1511 if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL)
8359cf43 1512 tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64);
12d23384
NB
1513
1514 ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf);
1515 spin_unlock_irq(&nacl->nacl_sess_lock);
1516 return ret;
1517}
1518DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_ident);
1519
1520CONFIGFS_EATTR_OPS(target_stat_scsi_att_intr_port, se_ml_stat_grps,
1521 scsi_att_intr_port_group);
1522
1523static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = {
1524 &target_stat_scsi_att_intr_port_inst.attr,
1525 &target_stat_scsi_att_intr_port_dev.attr,
1526 &target_stat_scsi_att_intr_port_port.attr,
1527 &target_stat_scsi_att_intr_port_indx.attr,
1528 &target_stat_scsi_att_intr_port_port_auth_indx.attr,
1529 &target_stat_scsi_att_intr_port_port_ident.attr,
1530 NULL,
1531};
1532
1533static struct configfs_item_operations target_stat_scsi_att_intr_port_attrib_ops = {
1534 .show_attribute = target_stat_scsi_att_intr_port_attr_show,
1535 .store_attribute = target_stat_scsi_att_intr_port_attr_store,
1536};
1537
1538static struct config_item_type target_stat_scsi_att_intr_port_cit = {
1539 .ct_item_ops = &target_stat_scsi_att_intr_port_attrib_ops,
1540 .ct_attrs = target_stat_scsi_ath_intr_port_attrs,
1541 .ct_owner = THIS_MODULE,
1542};
1543
1544/*
1545 * Called from target_core_fabric_configfs.c:target_fabric_make_mappedlun() to setup
1546 * the target MappedLUN statistics groups + configfs CITs located in target_core_stat.c
1547 */
1548void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl)
1549{
e3d6f909 1550 struct config_group *ml_stat_grp = &lacl->ml_stat_grps.stat_group;
12d23384 1551
e3d6f909 1552 config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group,
12d23384 1553 "scsi_auth_intr", &target_stat_scsi_auth_intr_cit);
e3d6f909 1554 config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group,
12d23384
NB
1555 "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit);
1556
e3d6f909
AG
1557 ml_stat_grp->default_groups[0] = &lacl->ml_stat_grps.scsi_auth_intr_group;
1558 ml_stat_grp->default_groups[1] = &lacl->ml_stat_grps.scsi_att_intr_port_group;
12d23384
NB
1559 ml_stat_grp->default_groups[2] = NULL;
1560}
This page took 0.307739 seconds and 5 git commands to generate.