Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / target / target_core_stat.c
blobc42cbde8a31b3a338da412f7ec89751c0228af48
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*******************************************************************************
3 * Filename: target_core_stat.c
5 * Modern ConfigFS group context specific statistics based on original
6 * target_core_mib.c code
8 * (c) Copyright 2006-2013 Datera, Inc.
10 * Nicholas A. Bellinger <nab@linux-iscsi.org>
12 ******************************************************************************/
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/delay.h>
17 #include <linux/timer.h>
18 #include <linux/string.h>
19 #include <linux/utsname.h>
20 #include <linux/proc_fs.h>
21 #include <linux/seq_file.h>
22 #include <linux/configfs.h>
24 #include <target/target_core_base.h>
25 #include <target/target_core_backend.h>
26 #include <target/target_core_fabric.h>
28 #include "target_core_internal.h"
30 #ifndef INITIAL_JIFFIES
31 #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
32 #endif
34 #define SCSI_LU_INDEX 1
35 #define LU_COUNT 1
38 * SCSI Device Table
41 static struct se_device *to_stat_dev(struct config_item *item)
43 struct se_dev_stat_grps *sgrps = container_of(to_config_group(item),
44 struct se_dev_stat_grps, scsi_dev_group);
45 return container_of(sgrps, struct se_device, dev_stat_grps);
48 static ssize_t target_stat_inst_show(struct config_item *item, char *page)
50 struct se_hba *hba = to_stat_dev(item)->se_hba;
52 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
55 static ssize_t target_stat_indx_show(struct config_item *item, char *page)
57 return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->dev_index);
60 static ssize_t target_stat_role_show(struct config_item *item, char *page)
62 return snprintf(page, PAGE_SIZE, "Target\n");
65 static ssize_t target_stat_ports_show(struct config_item *item, char *page)
67 return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->export_count);
70 CONFIGFS_ATTR_RO(target_stat_, inst);
71 CONFIGFS_ATTR_RO(target_stat_, indx);
72 CONFIGFS_ATTR_RO(target_stat_, role);
73 CONFIGFS_ATTR_RO(target_stat_, ports);
75 static struct configfs_attribute *target_stat_scsi_dev_attrs[] = {
76 &target_stat_attr_inst,
77 &target_stat_attr_indx,
78 &target_stat_attr_role,
79 &target_stat_attr_ports,
80 NULL,
83 static const struct config_item_type target_stat_scsi_dev_cit = {
84 .ct_attrs = target_stat_scsi_dev_attrs,
85 .ct_owner = THIS_MODULE,
89 * SCSI Target Device Table
91 static struct se_device *to_stat_tgt_dev(struct config_item *item)
93 struct se_dev_stat_grps *sgrps = container_of(to_config_group(item),
94 struct se_dev_stat_grps, scsi_tgt_dev_group);
95 return container_of(sgrps, struct se_device, dev_stat_grps);
98 static ssize_t target_stat_tgt_inst_show(struct config_item *item, char *page)
100 struct se_hba *hba = to_stat_tgt_dev(item)->se_hba;
102 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
105 static ssize_t target_stat_tgt_indx_show(struct config_item *item, char *page)
107 return snprintf(page, PAGE_SIZE, "%u\n", to_stat_tgt_dev(item)->dev_index);
110 static ssize_t target_stat_tgt_num_lus_show(struct config_item *item,
111 char *page)
113 return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT);
116 static ssize_t target_stat_tgt_status_show(struct config_item *item,
117 char *page)
119 if (to_stat_tgt_dev(item)->export_count)
120 return snprintf(page, PAGE_SIZE, "activated");
121 else
122 return snprintf(page, PAGE_SIZE, "deactivated");
125 static ssize_t target_stat_tgt_non_access_lus_show(struct config_item *item,
126 char *page)
128 int non_accessible_lus;
130 if (to_stat_tgt_dev(item)->export_count)
131 non_accessible_lus = 0;
132 else
133 non_accessible_lus = 1;
135 return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus);
138 static ssize_t target_stat_tgt_resets_show(struct config_item *item,
139 char *page)
141 return snprintf(page, PAGE_SIZE, "%lu\n",
142 atomic_long_read(&to_stat_tgt_dev(item)->num_resets));
145 static ssize_t target_stat_tgt_aborts_complete_show(struct config_item *item,
146 char *page)
148 return snprintf(page, PAGE_SIZE, "%lu\n",
149 atomic_long_read(&to_stat_tgt_dev(item)->aborts_complete));
152 static ssize_t target_stat_tgt_aborts_no_task_show(struct config_item *item,
153 char *page)
155 return snprintf(page, PAGE_SIZE, "%lu\n",
156 atomic_long_read(&to_stat_tgt_dev(item)->aborts_no_task));
159 CONFIGFS_ATTR_RO(target_stat_tgt_, inst);
160 CONFIGFS_ATTR_RO(target_stat_tgt_, indx);
161 CONFIGFS_ATTR_RO(target_stat_tgt_, num_lus);
162 CONFIGFS_ATTR_RO(target_stat_tgt_, status);
163 CONFIGFS_ATTR_RO(target_stat_tgt_, non_access_lus);
164 CONFIGFS_ATTR_RO(target_stat_tgt_, resets);
165 CONFIGFS_ATTR_RO(target_stat_tgt_, aborts_complete);
166 CONFIGFS_ATTR_RO(target_stat_tgt_, aborts_no_task);
168 static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = {
169 &target_stat_tgt_attr_inst,
170 &target_stat_tgt_attr_indx,
171 &target_stat_tgt_attr_num_lus,
172 &target_stat_tgt_attr_status,
173 &target_stat_tgt_attr_non_access_lus,
174 &target_stat_tgt_attr_resets,
175 &target_stat_tgt_attr_aborts_complete,
176 &target_stat_tgt_attr_aborts_no_task,
177 NULL,
180 static const struct config_item_type target_stat_scsi_tgt_dev_cit = {
181 .ct_attrs = target_stat_scsi_tgt_dev_attrs,
182 .ct_owner = THIS_MODULE,
186 * SCSI Logical Unit Table
189 static struct se_device *to_stat_lu_dev(struct config_item *item)
191 struct se_dev_stat_grps *sgrps = container_of(to_config_group(item),
192 struct se_dev_stat_grps, scsi_lu_group);
193 return container_of(sgrps, struct se_device, dev_stat_grps);
196 static ssize_t target_stat_lu_inst_show(struct config_item *item, char *page)
198 struct se_hba *hba = to_stat_lu_dev(item)->se_hba;
200 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
203 static ssize_t target_stat_lu_dev_show(struct config_item *item, char *page)
205 return snprintf(page, PAGE_SIZE, "%u\n",
206 to_stat_lu_dev(item)->dev_index);
209 static ssize_t target_stat_lu_indx_show(struct config_item *item, char *page)
211 return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX);
214 static ssize_t target_stat_lu_lun_show(struct config_item *item, char *page)
216 /* FIXME: scsiLuDefaultLun */
217 return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0);
220 static ssize_t target_stat_lu_lu_name_show(struct config_item *item, char *page)
222 struct se_device *dev = to_stat_lu_dev(item);
224 /* scsiLuWwnName */
225 return snprintf(page, PAGE_SIZE, "%s\n",
226 (strlen(dev->t10_wwn.unit_serial)) ?
227 dev->t10_wwn.unit_serial : "None");
230 static ssize_t target_stat_lu_vend_show(struct config_item *item, char *page)
232 struct se_device *dev = to_stat_lu_dev(item);
234 return snprintf(page, PAGE_SIZE, "%-" __stringify(INQUIRY_VENDOR_LEN)
235 "s\n", dev->t10_wwn.vendor);
238 static ssize_t target_stat_lu_prod_show(struct config_item *item, char *page)
240 struct se_device *dev = to_stat_lu_dev(item);
242 return snprintf(page, PAGE_SIZE, "%-" __stringify(INQUIRY_MODEL_LEN)
243 "s\n", dev->t10_wwn.model);
246 static ssize_t target_stat_lu_rev_show(struct config_item *item, char *page)
248 struct se_device *dev = to_stat_lu_dev(item);
250 return snprintf(page, PAGE_SIZE, "%-" __stringify(INQUIRY_REVISION_LEN)
251 "s\n", dev->t10_wwn.revision);
254 static ssize_t target_stat_lu_dev_type_show(struct config_item *item, char *page)
256 struct se_device *dev = to_stat_lu_dev(item);
258 /* scsiLuPeripheralType */
259 return snprintf(page, PAGE_SIZE, "%u\n",
260 dev->transport->get_device_type(dev));
263 static ssize_t target_stat_lu_status_show(struct config_item *item, char *page)
265 struct se_device *dev = to_stat_lu_dev(item);
267 /* scsiLuStatus */
268 return snprintf(page, PAGE_SIZE, "%s\n",
269 (dev->export_count) ? "available" : "notavailable");
272 static ssize_t target_stat_lu_state_bit_show(struct config_item *item,
273 char *page)
275 /* scsiLuState */
276 return snprintf(page, PAGE_SIZE, "exposed\n");
279 static ssize_t target_stat_lu_num_cmds_show(struct config_item *item,
280 char *page)
282 struct se_device *dev = to_stat_lu_dev(item);
284 /* scsiLuNumCommands */
285 return snprintf(page, PAGE_SIZE, "%lu\n",
286 atomic_long_read(&dev->num_cmds));
289 static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item,
290 char *page)
292 struct se_device *dev = to_stat_lu_dev(item);
294 /* scsiLuReadMegaBytes */
295 return snprintf(page, PAGE_SIZE, "%lu\n",
296 atomic_long_read(&dev->read_bytes) >> 20);
299 static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item,
300 char *page)
302 struct se_device *dev = to_stat_lu_dev(item);
304 /* scsiLuWrittenMegaBytes */
305 return snprintf(page, PAGE_SIZE, "%lu\n",
306 atomic_long_read(&dev->write_bytes) >> 20);
309 static ssize_t target_stat_lu_resets_show(struct config_item *item, char *page)
311 struct se_device *dev = to_stat_lu_dev(item);
313 /* scsiLuInResets */
314 return snprintf(page, PAGE_SIZE, "%lu\n",
315 atomic_long_read(&dev->num_resets));
318 static ssize_t target_stat_lu_full_stat_show(struct config_item *item,
319 char *page)
321 /* FIXME: scsiLuOutTaskSetFullStatus */
322 return snprintf(page, PAGE_SIZE, "%u\n", 0);
325 static ssize_t target_stat_lu_hs_num_cmds_show(struct config_item *item,
326 char *page)
328 /* FIXME: scsiLuHSInCommands */
329 return snprintf(page, PAGE_SIZE, "%u\n", 0);
332 static ssize_t target_stat_lu_creation_time_show(struct config_item *item,
333 char *page)
335 struct se_device *dev = to_stat_lu_dev(item);
337 /* scsiLuCreationTime */
338 return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time -
339 INITIAL_JIFFIES) * 100 / HZ));
342 CONFIGFS_ATTR_RO(target_stat_lu_, inst);
343 CONFIGFS_ATTR_RO(target_stat_lu_, dev);
344 CONFIGFS_ATTR_RO(target_stat_lu_, indx);
345 CONFIGFS_ATTR_RO(target_stat_lu_, lun);
346 CONFIGFS_ATTR_RO(target_stat_lu_, lu_name);
347 CONFIGFS_ATTR_RO(target_stat_lu_, vend);
348 CONFIGFS_ATTR_RO(target_stat_lu_, prod);
349 CONFIGFS_ATTR_RO(target_stat_lu_, rev);
350 CONFIGFS_ATTR_RO(target_stat_lu_, dev_type);
351 CONFIGFS_ATTR_RO(target_stat_lu_, status);
352 CONFIGFS_ATTR_RO(target_stat_lu_, state_bit);
353 CONFIGFS_ATTR_RO(target_stat_lu_, num_cmds);
354 CONFIGFS_ATTR_RO(target_stat_lu_, read_mbytes);
355 CONFIGFS_ATTR_RO(target_stat_lu_, write_mbytes);
356 CONFIGFS_ATTR_RO(target_stat_lu_, resets);
357 CONFIGFS_ATTR_RO(target_stat_lu_, full_stat);
358 CONFIGFS_ATTR_RO(target_stat_lu_, hs_num_cmds);
359 CONFIGFS_ATTR_RO(target_stat_lu_, creation_time);
361 static struct configfs_attribute *target_stat_scsi_lu_attrs[] = {
362 &target_stat_lu_attr_inst,
363 &target_stat_lu_attr_dev,
364 &target_stat_lu_attr_indx,
365 &target_stat_lu_attr_lun,
366 &target_stat_lu_attr_lu_name,
367 &target_stat_lu_attr_vend,
368 &target_stat_lu_attr_prod,
369 &target_stat_lu_attr_rev,
370 &target_stat_lu_attr_dev_type,
371 &target_stat_lu_attr_status,
372 &target_stat_lu_attr_state_bit,
373 &target_stat_lu_attr_num_cmds,
374 &target_stat_lu_attr_read_mbytes,
375 &target_stat_lu_attr_write_mbytes,
376 &target_stat_lu_attr_resets,
377 &target_stat_lu_attr_full_stat,
378 &target_stat_lu_attr_hs_num_cmds,
379 &target_stat_lu_attr_creation_time,
380 NULL,
383 static const struct config_item_type target_stat_scsi_lu_cit = {
384 .ct_attrs = target_stat_scsi_lu_attrs,
385 .ct_owner = THIS_MODULE,
389 * Called from target_core_configfs.c:target_core_make_subdev() to setup
390 * the target statistics groups + configfs CITs located in target_core_stat.c
392 void target_stat_setup_dev_default_groups(struct se_device *dev)
394 config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group,
395 "scsi_dev", &target_stat_scsi_dev_cit);
396 configfs_add_default_group(&dev->dev_stat_grps.scsi_dev_group,
397 &dev->dev_stat_grps.stat_group);
399 config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group,
400 "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit);
401 configfs_add_default_group(&dev->dev_stat_grps.scsi_tgt_dev_group,
402 &dev->dev_stat_grps.stat_group);
404 config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group,
405 "scsi_lu", &target_stat_scsi_lu_cit);
406 configfs_add_default_group(&dev->dev_stat_grps.scsi_lu_group,
407 &dev->dev_stat_grps.stat_group);
411 * SCSI Port Table
414 static struct se_lun *to_stat_port(struct config_item *item)
416 struct se_port_stat_grps *pgrps = container_of(to_config_group(item),
417 struct se_port_stat_grps, scsi_port_group);
418 return container_of(pgrps, struct se_lun, port_stat_grps);
421 static ssize_t target_stat_port_inst_show(struct config_item *item, char *page)
423 struct se_lun *lun = to_stat_port(item);
424 struct se_device *dev;
425 ssize_t ret = -ENODEV;
427 rcu_read_lock();
428 dev = rcu_dereference(lun->lun_se_dev);
429 if (dev)
430 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
431 rcu_read_unlock();
432 return ret;
435 static ssize_t target_stat_port_dev_show(struct config_item *item, char *page)
437 struct se_lun *lun = to_stat_port(item);
438 struct se_device *dev;
439 ssize_t ret = -ENODEV;
441 rcu_read_lock();
442 dev = rcu_dereference(lun->lun_se_dev);
443 if (dev)
444 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
445 rcu_read_unlock();
446 return ret;
449 static ssize_t target_stat_port_indx_show(struct config_item *item, char *page)
451 struct se_lun *lun = to_stat_port(item);
452 struct se_device *dev;
453 ssize_t ret = -ENODEV;
455 rcu_read_lock();
456 dev = rcu_dereference(lun->lun_se_dev);
457 if (dev)
458 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_tpg->tpg_rtpi);
459 rcu_read_unlock();
460 return ret;
463 static ssize_t target_stat_port_role_show(struct config_item *item, char *page)
465 struct se_lun *lun = to_stat_port(item);
466 struct se_device *dev;
467 ssize_t ret = -ENODEV;
469 rcu_read_lock();
470 dev = rcu_dereference(lun->lun_se_dev);
471 if (dev)
472 ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index);
473 rcu_read_unlock();
474 return ret;
477 static ssize_t target_stat_port_busy_count_show(struct config_item *item,
478 char *page)
480 struct se_lun *lun = to_stat_port(item);
481 struct se_device *dev;
482 ssize_t ret = -ENODEV;
484 rcu_read_lock();
485 dev = rcu_dereference(lun->lun_se_dev);
486 if (dev) {
487 /* FIXME: scsiPortBusyStatuses */
488 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
490 rcu_read_unlock();
491 return ret;
494 CONFIGFS_ATTR_RO(target_stat_port_, inst);
495 CONFIGFS_ATTR_RO(target_stat_port_, dev);
496 CONFIGFS_ATTR_RO(target_stat_port_, indx);
497 CONFIGFS_ATTR_RO(target_stat_port_, role);
498 CONFIGFS_ATTR_RO(target_stat_port_, busy_count);
500 static struct configfs_attribute *target_stat_scsi_port_attrs[] = {
501 &target_stat_port_attr_inst,
502 &target_stat_port_attr_dev,
503 &target_stat_port_attr_indx,
504 &target_stat_port_attr_role,
505 &target_stat_port_attr_busy_count,
506 NULL,
509 static const struct config_item_type target_stat_scsi_port_cit = {
510 .ct_attrs = target_stat_scsi_port_attrs,
511 .ct_owner = THIS_MODULE,
515 * SCSI Target Port Table
517 static struct se_lun *to_stat_tgt_port(struct config_item *item)
519 struct se_port_stat_grps *pgrps = container_of(to_config_group(item),
520 struct se_port_stat_grps, scsi_tgt_port_group);
521 return container_of(pgrps, struct se_lun, port_stat_grps);
524 static ssize_t target_stat_tgt_port_inst_show(struct config_item *item,
525 char *page)
527 struct se_lun *lun = to_stat_tgt_port(item);
528 struct se_device *dev;
529 ssize_t ret = -ENODEV;
531 rcu_read_lock();
532 dev = rcu_dereference(lun->lun_se_dev);
533 if (dev)
534 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
535 rcu_read_unlock();
536 return ret;
539 static ssize_t target_stat_tgt_port_dev_show(struct config_item *item,
540 char *page)
542 struct se_lun *lun = to_stat_tgt_port(item);
543 struct se_device *dev;
544 ssize_t ret = -ENODEV;
546 rcu_read_lock();
547 dev = rcu_dereference(lun->lun_se_dev);
548 if (dev)
549 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
550 rcu_read_unlock();
551 return ret;
554 static ssize_t target_stat_tgt_port_indx_show(struct config_item *item,
555 char *page)
557 struct se_lun *lun = to_stat_tgt_port(item);
558 struct se_device *dev;
559 ssize_t ret = -ENODEV;
561 rcu_read_lock();
562 dev = rcu_dereference(lun->lun_se_dev);
563 if (dev)
564 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_tpg->tpg_rtpi);
565 rcu_read_unlock();
566 return ret;
569 static ssize_t target_stat_tgt_port_name_show(struct config_item *item,
570 char *page)
572 struct se_lun *lun = to_stat_tgt_port(item);
573 struct se_portal_group *tpg = lun->lun_tpg;
574 struct se_device *dev;
575 ssize_t ret = -ENODEV;
577 rcu_read_lock();
578 dev = rcu_dereference(lun->lun_se_dev);
579 if (dev)
580 ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n",
581 tpg->se_tpg_tfo->fabric_name,
582 lun->lun_tpg->tpg_rtpi);
583 rcu_read_unlock();
584 return ret;
587 static ssize_t target_stat_tgt_port_port_index_show(struct config_item *item,
588 char *page)
590 struct se_lun *lun = to_stat_tgt_port(item);
591 struct se_portal_group *tpg = lun->lun_tpg;
592 struct se_device *dev;
593 ssize_t ret = -ENODEV;
595 rcu_read_lock();
596 dev = rcu_dereference(lun->lun_se_dev);
597 if (dev)
598 ret = snprintf(page, PAGE_SIZE, "%s%s%d\n",
599 tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+",
600 tpg->se_tpg_tfo->tpg_get_tag(tpg));
601 rcu_read_unlock();
602 return ret;
605 static ssize_t target_stat_tgt_port_in_cmds_show(struct config_item *item,
606 char *page)
608 struct se_lun *lun = to_stat_tgt_port(item);
609 struct se_device *dev;
610 ssize_t ret = -ENODEV;
612 rcu_read_lock();
613 dev = rcu_dereference(lun->lun_se_dev);
614 if (dev)
615 ret = snprintf(page, PAGE_SIZE, "%lu\n",
616 atomic_long_read(&lun->lun_stats.cmd_pdus));
617 rcu_read_unlock();
618 return ret;
621 static ssize_t target_stat_tgt_port_write_mbytes_show(struct config_item *item,
622 char *page)
624 struct se_lun *lun = to_stat_tgt_port(item);
625 struct se_device *dev;
626 ssize_t ret = -ENODEV;
628 rcu_read_lock();
629 dev = rcu_dereference(lun->lun_se_dev);
630 if (dev)
631 ret = snprintf(page, PAGE_SIZE, "%u\n",
632 (u32)(atomic_long_read(&lun->lun_stats.rx_data_octets) >> 20));
633 rcu_read_unlock();
634 return ret;
637 static ssize_t target_stat_tgt_port_read_mbytes_show(struct config_item *item,
638 char *page)
640 struct se_lun *lun = to_stat_tgt_port(item);
641 struct se_device *dev;
642 ssize_t ret = -ENODEV;
644 rcu_read_lock();
645 dev = rcu_dereference(lun->lun_se_dev);
646 if (dev)
647 ret = snprintf(page, PAGE_SIZE, "%u\n",
648 (u32)(atomic_long_read(&lun->lun_stats.tx_data_octets) >> 20));
649 rcu_read_unlock();
650 return ret;
653 static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item,
654 char *page)
656 struct se_lun *lun = to_stat_tgt_port(item);
657 struct se_device *dev;
658 ssize_t ret = -ENODEV;
660 rcu_read_lock();
661 dev = rcu_dereference(lun->lun_se_dev);
662 if (dev) {
663 /* FIXME: scsiTgtPortHsInCommands */
664 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
666 rcu_read_unlock();
667 return ret;
670 CONFIGFS_ATTR_RO(target_stat_tgt_port_, inst);
671 CONFIGFS_ATTR_RO(target_stat_tgt_port_, dev);
672 CONFIGFS_ATTR_RO(target_stat_tgt_port_, indx);
673 CONFIGFS_ATTR_RO(target_stat_tgt_port_, name);
674 CONFIGFS_ATTR_RO(target_stat_tgt_port_, port_index);
675 CONFIGFS_ATTR_RO(target_stat_tgt_port_, in_cmds);
676 CONFIGFS_ATTR_RO(target_stat_tgt_port_, write_mbytes);
677 CONFIGFS_ATTR_RO(target_stat_tgt_port_, read_mbytes);
678 CONFIGFS_ATTR_RO(target_stat_tgt_port_, hs_in_cmds);
680 static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = {
681 &target_stat_tgt_port_attr_inst,
682 &target_stat_tgt_port_attr_dev,
683 &target_stat_tgt_port_attr_indx,
684 &target_stat_tgt_port_attr_name,
685 &target_stat_tgt_port_attr_port_index,
686 &target_stat_tgt_port_attr_in_cmds,
687 &target_stat_tgt_port_attr_write_mbytes,
688 &target_stat_tgt_port_attr_read_mbytes,
689 &target_stat_tgt_port_attr_hs_in_cmds,
690 NULL,
693 static const struct config_item_type target_stat_scsi_tgt_port_cit = {
694 .ct_attrs = target_stat_scsi_tgt_port_attrs,
695 .ct_owner = THIS_MODULE,
699 * SCSI Transport Table
701 static struct se_lun *to_transport_stat(struct config_item *item)
703 struct se_port_stat_grps *pgrps = container_of(to_config_group(item),
704 struct se_port_stat_grps, scsi_transport_group);
705 return container_of(pgrps, struct se_lun, port_stat_grps);
708 static ssize_t target_stat_transport_inst_show(struct config_item *item,
709 char *page)
711 struct se_lun *lun = to_transport_stat(item);
712 struct se_device *dev;
713 ssize_t ret = -ENODEV;
715 rcu_read_lock();
716 dev = rcu_dereference(lun->lun_se_dev);
717 if (dev)
718 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
719 rcu_read_unlock();
720 return ret;
723 static ssize_t target_stat_transport_device_show(struct config_item *item,
724 char *page)
726 struct se_lun *lun = to_transport_stat(item);
727 struct se_device *dev;
728 struct se_portal_group *tpg = lun->lun_tpg;
729 ssize_t ret = -ENODEV;
731 rcu_read_lock();
732 dev = rcu_dereference(lun->lun_se_dev);
733 if (dev) {
734 /* scsiTransportType */
735 ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n",
736 tpg->se_tpg_tfo->fabric_name);
738 rcu_read_unlock();
739 return ret;
742 static ssize_t target_stat_transport_indx_show(struct config_item *item,
743 char *page)
745 struct se_lun *lun = to_transport_stat(item);
746 struct se_device *dev;
747 struct se_portal_group *tpg = lun->lun_tpg;
748 ssize_t ret = -ENODEV;
750 rcu_read_lock();
751 dev = rcu_dereference(lun->lun_se_dev);
752 if (dev)
753 ret = snprintf(page, PAGE_SIZE, "%u\n",
754 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
755 rcu_read_unlock();
756 return ret;
759 static ssize_t target_stat_transport_dev_name_show(struct config_item *item,
760 char *page)
762 struct se_lun *lun = to_transport_stat(item);
763 struct se_device *dev;
764 struct se_portal_group *tpg = lun->lun_tpg;
765 struct t10_wwn *wwn;
766 ssize_t ret = -ENODEV;
768 rcu_read_lock();
769 dev = rcu_dereference(lun->lun_se_dev);
770 if (dev) {
771 wwn = &dev->t10_wwn;
772 /* scsiTransportDevName */
773 ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
774 tpg->se_tpg_tfo->tpg_get_wwn(tpg),
775 (strlen(wwn->unit_serial)) ? wwn->unit_serial :
776 wwn->vendor);
778 rcu_read_unlock();
779 return ret;
782 static ssize_t target_stat_transport_proto_id_show(struct config_item *item,
783 char *page)
785 struct se_lun *lun = to_transport_stat(item);
786 struct se_device *dev;
787 struct se_portal_group *tpg = lun->lun_tpg;
788 ssize_t ret = -ENODEV;
790 rcu_read_lock();
791 dev = rcu_dereference(lun->lun_se_dev);
792 if (dev)
793 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->proto_id);
794 rcu_read_unlock();
795 return ret;
798 CONFIGFS_ATTR_RO(target_stat_transport_, inst);
799 CONFIGFS_ATTR_RO(target_stat_transport_, device);
800 CONFIGFS_ATTR_RO(target_stat_transport_, indx);
801 CONFIGFS_ATTR_RO(target_stat_transport_, dev_name);
802 CONFIGFS_ATTR_RO(target_stat_transport_, proto_id);
804 static struct configfs_attribute *target_stat_scsi_transport_attrs[] = {
805 &target_stat_transport_attr_inst,
806 &target_stat_transport_attr_device,
807 &target_stat_transport_attr_indx,
808 &target_stat_transport_attr_dev_name,
809 &target_stat_transport_attr_proto_id,
810 NULL,
813 static const struct config_item_type target_stat_scsi_transport_cit = {
814 .ct_attrs = target_stat_scsi_transport_attrs,
815 .ct_owner = THIS_MODULE,
819 * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup
820 * the target port statistics groups + configfs CITs located in target_core_stat.c
822 void target_stat_setup_port_default_groups(struct se_lun *lun)
824 config_group_init_type_name(&lun->port_stat_grps.scsi_port_group,
825 "scsi_port", &target_stat_scsi_port_cit);
826 configfs_add_default_group(&lun->port_stat_grps.scsi_port_group,
827 &lun->port_stat_grps.stat_group);
829 config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group,
830 "scsi_tgt_port", &target_stat_scsi_tgt_port_cit);
831 configfs_add_default_group(&lun->port_stat_grps.scsi_tgt_port_group,
832 &lun->port_stat_grps.stat_group);
834 config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group,
835 "scsi_transport", &target_stat_scsi_transport_cit);
836 configfs_add_default_group(&lun->port_stat_grps.scsi_transport_group,
837 &lun->port_stat_grps.stat_group);
841 * SCSI Authorized Initiator Table
844 static struct se_lun_acl *auth_to_lacl(struct config_item *item)
846 struct se_ml_stat_grps *lgrps = container_of(to_config_group(item),
847 struct se_ml_stat_grps, scsi_auth_intr_group);
848 return container_of(lgrps, struct se_lun_acl, ml_stat_grps);
851 static ssize_t target_stat_auth_inst_show(struct config_item *item,
852 char *page)
854 struct se_lun_acl *lacl = auth_to_lacl(item);
855 struct se_node_acl *nacl = lacl->se_lun_nacl;
856 struct se_dev_entry *deve;
857 struct se_portal_group *tpg;
858 ssize_t ret;
860 rcu_read_lock();
861 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
862 if (!deve) {
863 rcu_read_unlock();
864 return -ENODEV;
866 tpg = nacl->se_tpg;
867 /* scsiInstIndex */
868 ret = snprintf(page, PAGE_SIZE, "%u\n",
869 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
870 rcu_read_unlock();
871 return ret;
874 static ssize_t target_stat_auth_dev_show(struct config_item *item,
875 char *page)
877 struct se_lun_acl *lacl = auth_to_lacl(item);
878 struct se_node_acl *nacl = lacl->se_lun_nacl;
879 struct se_dev_entry *deve;
880 ssize_t ret;
882 rcu_read_lock();
883 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
884 if (!deve) {
885 rcu_read_unlock();
886 return -ENODEV;
889 /* scsiDeviceIndex */
890 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->se_lun->lun_index);
891 rcu_read_unlock();
892 return ret;
895 static ssize_t target_stat_auth_port_show(struct config_item *item,
896 char *page)
898 struct se_lun_acl *lacl = auth_to_lacl(item);
899 struct se_node_acl *nacl = lacl->se_lun_nacl;
900 struct se_dev_entry *deve;
901 struct se_portal_group *tpg;
902 ssize_t ret;
904 rcu_read_lock();
905 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
906 if (!deve) {
907 rcu_read_unlock();
908 return -ENODEV;
910 tpg = nacl->se_tpg;
911 /* scsiAuthIntrTgtPortIndex */
912 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
913 rcu_read_unlock();
914 return ret;
917 static ssize_t target_stat_auth_indx_show(struct config_item *item,
918 char *page)
920 struct se_lun_acl *lacl = auth_to_lacl(item);
921 struct se_node_acl *nacl = lacl->se_lun_nacl;
922 struct se_dev_entry *deve;
923 ssize_t ret;
925 rcu_read_lock();
926 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
927 if (!deve) {
928 rcu_read_unlock();
929 return -ENODEV;
931 /* scsiAuthIntrIndex */
932 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
933 rcu_read_unlock();
934 return ret;
937 static ssize_t target_stat_auth_dev_or_port_show(struct config_item *item,
938 char *page)
940 struct se_lun_acl *lacl = auth_to_lacl(item);
941 struct se_node_acl *nacl = lacl->se_lun_nacl;
942 struct se_dev_entry *deve;
943 ssize_t ret;
945 rcu_read_lock();
946 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
947 if (!deve) {
948 rcu_read_unlock();
949 return -ENODEV;
951 /* scsiAuthIntrDevOrPort */
952 ret = snprintf(page, PAGE_SIZE, "%u\n", 1);
953 rcu_read_unlock();
954 return ret;
957 static ssize_t target_stat_auth_intr_name_show(struct config_item *item,
958 char *page)
960 struct se_lun_acl *lacl = auth_to_lacl(item);
961 struct se_node_acl *nacl = lacl->se_lun_nacl;
962 struct se_dev_entry *deve;
963 ssize_t ret;
965 rcu_read_lock();
966 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
967 if (!deve) {
968 rcu_read_unlock();
969 return -ENODEV;
971 /* scsiAuthIntrName */
972 ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname);
973 rcu_read_unlock();
974 return ret;
977 static ssize_t target_stat_auth_map_indx_show(struct config_item *item,
978 char *page)
980 struct se_lun_acl *lacl = auth_to_lacl(item);
981 struct se_node_acl *nacl = lacl->se_lun_nacl;
982 struct se_dev_entry *deve;
983 ssize_t ret;
985 rcu_read_lock();
986 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
987 if (!deve) {
988 rcu_read_unlock();
989 return -ENODEV;
991 /* FIXME: scsiAuthIntrLunMapIndex */
992 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
993 rcu_read_unlock();
994 return ret;
997 static ssize_t target_stat_auth_att_count_show(struct config_item *item,
998 char *page)
1000 struct se_lun_acl *lacl = auth_to_lacl(item);
1001 struct se_node_acl *nacl = lacl->se_lun_nacl;
1002 struct se_dev_entry *deve;
1003 ssize_t ret;
1005 rcu_read_lock();
1006 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1007 if (!deve) {
1008 rcu_read_unlock();
1009 return -ENODEV;
1011 /* scsiAuthIntrAttachedTimes */
1012 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count);
1013 rcu_read_unlock();
1014 return ret;
1017 static ssize_t target_stat_auth_num_cmds_show(struct config_item *item,
1018 char *page)
1020 struct se_lun_acl *lacl = auth_to_lacl(item);
1021 struct se_node_acl *nacl = lacl->se_lun_nacl;
1022 struct se_dev_entry *deve;
1023 ssize_t ret;
1025 rcu_read_lock();
1026 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1027 if (!deve) {
1028 rcu_read_unlock();
1029 return -ENODEV;
1031 /* scsiAuthIntrOutCommands */
1032 ret = snprintf(page, PAGE_SIZE, "%lu\n",
1033 atomic_long_read(&deve->total_cmds));
1034 rcu_read_unlock();
1035 return ret;
1038 static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item,
1039 char *page)
1041 struct se_lun_acl *lacl = auth_to_lacl(item);
1042 struct se_node_acl *nacl = lacl->se_lun_nacl;
1043 struct se_dev_entry *deve;
1044 ssize_t ret;
1046 rcu_read_lock();
1047 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1048 if (!deve) {
1049 rcu_read_unlock();
1050 return -ENODEV;
1052 /* scsiAuthIntrReadMegaBytes */
1053 ret = snprintf(page, PAGE_SIZE, "%u\n",
1054 (u32)(atomic_long_read(&deve->read_bytes) >> 20));
1055 rcu_read_unlock();
1056 return ret;
1059 static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item,
1060 char *page)
1062 struct se_lun_acl *lacl = auth_to_lacl(item);
1063 struct se_node_acl *nacl = lacl->se_lun_nacl;
1064 struct se_dev_entry *deve;
1065 ssize_t ret;
1067 rcu_read_lock();
1068 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1069 if (!deve) {
1070 rcu_read_unlock();
1071 return -ENODEV;
1073 /* scsiAuthIntrWrittenMegaBytes */
1074 ret = snprintf(page, PAGE_SIZE, "%u\n",
1075 (u32)(atomic_long_read(&deve->write_bytes) >> 20));
1076 rcu_read_unlock();
1077 return ret;
1080 static ssize_t target_stat_auth_hs_num_cmds_show(struct config_item *item,
1081 char *page)
1083 struct se_lun_acl *lacl = auth_to_lacl(item);
1084 struct se_node_acl *nacl = lacl->se_lun_nacl;
1085 struct se_dev_entry *deve;
1086 ssize_t ret;
1088 rcu_read_lock();
1089 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1090 if (!deve) {
1091 rcu_read_unlock();
1092 return -ENODEV;
1094 /* FIXME: scsiAuthIntrHSOutCommands */
1095 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
1096 rcu_read_unlock();
1097 return ret;
1100 static ssize_t target_stat_auth_creation_time_show(struct config_item *item,
1101 char *page)
1103 struct se_lun_acl *lacl = auth_to_lacl(item);
1104 struct se_node_acl *nacl = lacl->se_lun_nacl;
1105 struct se_dev_entry *deve;
1106 ssize_t ret;
1108 rcu_read_lock();
1109 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1110 if (!deve) {
1111 rcu_read_unlock();
1112 return -ENODEV;
1114 /* scsiAuthIntrLastCreation */
1115 ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time -
1116 INITIAL_JIFFIES) * 100 / HZ));
1117 rcu_read_unlock();
1118 return ret;
1121 static ssize_t target_stat_auth_row_status_show(struct config_item *item,
1122 char *page)
1124 struct se_lun_acl *lacl = auth_to_lacl(item);
1125 struct se_node_acl *nacl = lacl->se_lun_nacl;
1126 struct se_dev_entry *deve;
1127 ssize_t ret;
1129 rcu_read_lock();
1130 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1131 if (!deve) {
1132 rcu_read_unlock();
1133 return -ENODEV;
1135 /* FIXME: scsiAuthIntrRowStatus */
1136 ret = snprintf(page, PAGE_SIZE, "Ready\n");
1137 rcu_read_unlock();
1138 return ret;
1141 CONFIGFS_ATTR_RO(target_stat_auth_, inst);
1142 CONFIGFS_ATTR_RO(target_stat_auth_, dev);
1143 CONFIGFS_ATTR_RO(target_stat_auth_, port);
1144 CONFIGFS_ATTR_RO(target_stat_auth_, indx);
1145 CONFIGFS_ATTR_RO(target_stat_auth_, dev_or_port);
1146 CONFIGFS_ATTR_RO(target_stat_auth_, intr_name);
1147 CONFIGFS_ATTR_RO(target_stat_auth_, map_indx);
1148 CONFIGFS_ATTR_RO(target_stat_auth_, att_count);
1149 CONFIGFS_ATTR_RO(target_stat_auth_, num_cmds);
1150 CONFIGFS_ATTR_RO(target_stat_auth_, read_mbytes);
1151 CONFIGFS_ATTR_RO(target_stat_auth_, write_mbytes);
1152 CONFIGFS_ATTR_RO(target_stat_auth_, hs_num_cmds);
1153 CONFIGFS_ATTR_RO(target_stat_auth_, creation_time);
1154 CONFIGFS_ATTR_RO(target_stat_auth_, row_status);
1156 static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = {
1157 &target_stat_auth_attr_inst,
1158 &target_stat_auth_attr_dev,
1159 &target_stat_auth_attr_port,
1160 &target_stat_auth_attr_indx,
1161 &target_stat_auth_attr_dev_or_port,
1162 &target_stat_auth_attr_intr_name,
1163 &target_stat_auth_attr_map_indx,
1164 &target_stat_auth_attr_att_count,
1165 &target_stat_auth_attr_num_cmds,
1166 &target_stat_auth_attr_read_mbytes,
1167 &target_stat_auth_attr_write_mbytes,
1168 &target_stat_auth_attr_hs_num_cmds,
1169 &target_stat_auth_attr_creation_time,
1170 &target_stat_auth_attr_row_status,
1171 NULL,
1174 static const struct config_item_type target_stat_scsi_auth_intr_cit = {
1175 .ct_attrs = target_stat_scsi_auth_intr_attrs,
1176 .ct_owner = THIS_MODULE,
1180 * SCSI Attached Initiator Port Table
1183 static struct se_lun_acl *iport_to_lacl(struct config_item *item)
1185 struct se_ml_stat_grps *lgrps = container_of(to_config_group(item),
1186 struct se_ml_stat_grps, scsi_att_intr_port_group);
1187 return container_of(lgrps, struct se_lun_acl, ml_stat_grps);
1190 static ssize_t target_stat_iport_inst_show(struct config_item *item,
1191 char *page)
1193 struct se_lun_acl *lacl = iport_to_lacl(item);
1194 struct se_node_acl *nacl = lacl->se_lun_nacl;
1195 struct se_dev_entry *deve;
1196 struct se_portal_group *tpg;
1197 ssize_t ret;
1199 rcu_read_lock();
1200 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1201 if (!deve) {
1202 rcu_read_unlock();
1203 return -ENODEV;
1205 tpg = nacl->se_tpg;
1206 /* scsiInstIndex */
1207 ret = snprintf(page, PAGE_SIZE, "%u\n",
1208 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
1209 rcu_read_unlock();
1210 return ret;
1213 static ssize_t target_stat_iport_dev_show(struct config_item *item,
1214 char *page)
1216 struct se_lun_acl *lacl = iport_to_lacl(item);
1217 struct se_node_acl *nacl = lacl->se_lun_nacl;
1218 struct se_dev_entry *deve;
1219 ssize_t ret;
1221 rcu_read_lock();
1222 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1223 if (!deve) {
1224 rcu_read_unlock();
1225 return -ENODEV;
1228 /* scsiDeviceIndex */
1229 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->se_lun->lun_index);
1230 rcu_read_unlock();
1231 return ret;
1234 static ssize_t target_stat_iport_port_show(struct config_item *item,
1235 char *page)
1237 struct se_lun_acl *lacl = iport_to_lacl(item);
1238 struct se_node_acl *nacl = lacl->se_lun_nacl;
1239 struct se_dev_entry *deve;
1240 struct se_portal_group *tpg;
1241 ssize_t ret;
1243 rcu_read_lock();
1244 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1245 if (!deve) {
1246 rcu_read_unlock();
1247 return -ENODEV;
1249 tpg = nacl->se_tpg;
1250 /* scsiPortIndex */
1251 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
1252 rcu_read_unlock();
1253 return ret;
1256 static ssize_t target_stat_iport_indx_show(struct config_item *item,
1257 char *page)
1259 struct se_lun_acl *lacl = iport_to_lacl(item);
1260 struct se_node_acl *nacl = lacl->se_lun_nacl;
1261 struct se_session *se_sess;
1262 struct se_portal_group *tpg;
1263 ssize_t ret;
1265 spin_lock_irq(&nacl->nacl_sess_lock);
1266 se_sess = nacl->nacl_sess;
1267 if (!se_sess) {
1268 spin_unlock_irq(&nacl->nacl_sess_lock);
1269 return -ENODEV;
1272 tpg = nacl->se_tpg;
1273 /* scsiAttIntrPortIndex */
1274 ret = snprintf(page, PAGE_SIZE, "%u\n",
1275 tpg->se_tpg_tfo->sess_get_index(se_sess));
1276 spin_unlock_irq(&nacl->nacl_sess_lock);
1277 return ret;
1280 static ssize_t target_stat_iport_port_auth_indx_show(struct config_item *item,
1281 char *page)
1283 struct se_lun_acl *lacl = iport_to_lacl(item);
1284 struct se_node_acl *nacl = lacl->se_lun_nacl;
1285 struct se_dev_entry *deve;
1286 ssize_t ret;
1288 rcu_read_lock();
1289 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1290 if (!deve) {
1291 rcu_read_unlock();
1292 return -ENODEV;
1294 /* scsiAttIntrPortAuthIntrIdx */
1295 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
1296 rcu_read_unlock();
1297 return ret;
1300 static ssize_t target_stat_iport_port_ident_show(struct config_item *item,
1301 char *page)
1303 struct se_lun_acl *lacl = iport_to_lacl(item);
1304 struct se_node_acl *nacl = lacl->se_lun_nacl;
1305 struct se_session *se_sess;
1306 struct se_portal_group *tpg;
1307 ssize_t ret;
1308 unsigned char buf[64];
1310 spin_lock_irq(&nacl->nacl_sess_lock);
1311 se_sess = nacl->nacl_sess;
1312 if (!se_sess) {
1313 spin_unlock_irq(&nacl->nacl_sess_lock);
1314 return -ENODEV;
1317 tpg = nacl->se_tpg;
1318 /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
1319 memset(buf, 0, 64);
1320 if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL)
1321 tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64);
1323 ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf);
1324 spin_unlock_irq(&nacl->nacl_sess_lock);
1325 return ret;
1328 CONFIGFS_ATTR_RO(target_stat_iport_, inst);
1329 CONFIGFS_ATTR_RO(target_stat_iport_, dev);
1330 CONFIGFS_ATTR_RO(target_stat_iport_, port);
1331 CONFIGFS_ATTR_RO(target_stat_iport_, indx);
1332 CONFIGFS_ATTR_RO(target_stat_iport_, port_auth_indx);
1333 CONFIGFS_ATTR_RO(target_stat_iport_, port_ident);
1335 static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = {
1336 &target_stat_iport_attr_inst,
1337 &target_stat_iport_attr_dev,
1338 &target_stat_iport_attr_port,
1339 &target_stat_iport_attr_indx,
1340 &target_stat_iport_attr_port_auth_indx,
1341 &target_stat_iport_attr_port_ident,
1342 NULL,
1345 static const struct config_item_type target_stat_scsi_att_intr_port_cit = {
1346 .ct_attrs = target_stat_scsi_ath_intr_port_attrs,
1347 .ct_owner = THIS_MODULE,
1351 * Called from target_core_fabric_configfs.c:target_fabric_make_mappedlun() to setup
1352 * the target MappedLUN statistics groups + configfs CITs located in target_core_stat.c
1354 void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl)
1356 config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group,
1357 "scsi_auth_intr", &target_stat_scsi_auth_intr_cit);
1358 configfs_add_default_group(&lacl->ml_stat_grps.scsi_auth_intr_group,
1359 &lacl->ml_stat_grps.stat_group);
1361 config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group,
1362 "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit);
1363 configfs_add_default_group(&lacl->ml_stat_grps.scsi_att_intr_port_group,
1364 &lacl->ml_stat_grps.stat_group);