1 /*******************************************************************************
2 * Filename: target_core_stat.c
4 * Copyright (c) 2011 Rising Tide Systems
5 * Copyright (c) 2011 Linux-iSCSI.org
7 * Modern ConfigFS group context specific statistics based on original
8 * target_core_mib.c code
10 * Copyright (c) 2006-2007 SBE, Inc. All Rights Reserved.
12 * Nicholas A. Bellinger <nab@linux-iscsi.org>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 ******************************************************************************/
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/delay.h>
33 #include <linux/timer.h>
34 #include <linux/string.h>
35 #include <generated/utsrelease.h>
36 #include <linux/utsname.h>
37 #include <linux/proc_fs.h>
38 #include <linux/seq_file.h>
39 #include <linux/blkdev.h>
40 #include <linux/configfs.h>
41 #include <scsi/scsi.h>
42 #include <scsi/scsi_device.h>
43 #include <scsi/scsi_host.h>
45 #include <target/target_core_base.h>
46 #include <target/target_core_backend.h>
47 #include <target/target_core_fabric.h>
48 #include <target/target_core_configfs.h>
49 #include <target/configfs_macros.h>
51 #include "target_core_internal.h"
53 #ifndef INITIAL_JIFFIES
54 #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
58 #define ISPRINT(a) ((a >= ' ') && (a <= '~'))
60 #define SCSI_LU_INDEX 1
67 CONFIGFS_EATTR_STRUCT(target_stat_scsi_dev
, se_dev_stat_grps
);
68 #define DEV_STAT_SCSI_DEV_ATTR(_name, _mode) \
69 static struct target_stat_scsi_dev_attribute \
70 target_stat_scsi_dev_##_name = \
71 __CONFIGFS_EATTR(_name, _mode, \
72 target_stat_scsi_dev_show_attr_##_name, \
73 target_stat_scsi_dev_store_attr_##_name);
75 #define DEV_STAT_SCSI_DEV_ATTR_RO(_name) \
76 static struct target_stat_scsi_dev_attribute \
77 target_stat_scsi_dev_##_name = \
78 __CONFIGFS_EATTR_RO(_name, \
79 target_stat_scsi_dev_show_attr_##_name);
81 static ssize_t
target_stat_scsi_dev_show_attr_inst(
82 struct se_dev_stat_grps
*sgrps
, char *page
)
84 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
85 struct se_subsystem_dev
, dev_stat_grps
);
86 struct se_hba
*hba
= se_subdev
->se_dev_hba
;
87 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
92 return snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
94 DEV_STAT_SCSI_DEV_ATTR_RO(inst
);
96 static ssize_t
target_stat_scsi_dev_show_attr_indx(
97 struct se_dev_stat_grps
*sgrps
, char *page
)
99 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
100 struct se_subsystem_dev
, dev_stat_grps
);
101 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
106 return snprintf(page
, PAGE_SIZE
, "%u\n", dev
->dev_index
);
108 DEV_STAT_SCSI_DEV_ATTR_RO(indx
);
110 static ssize_t
target_stat_scsi_dev_show_attr_role(
111 struct se_dev_stat_grps
*sgrps
, char *page
)
113 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
114 struct se_subsystem_dev
, dev_stat_grps
);
115 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
120 return snprintf(page
, PAGE_SIZE
, "Target\n");
122 DEV_STAT_SCSI_DEV_ATTR_RO(role
);
124 static ssize_t
target_stat_scsi_dev_show_attr_ports(
125 struct se_dev_stat_grps
*sgrps
, char *page
)
127 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
128 struct se_subsystem_dev
, dev_stat_grps
);
129 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
134 return snprintf(page
, PAGE_SIZE
, "%u\n", dev
->dev_port_count
);
136 DEV_STAT_SCSI_DEV_ATTR_RO(ports
);
138 CONFIGFS_EATTR_OPS(target_stat_scsi_dev
, se_dev_stat_grps
, scsi_dev_group
);
140 static struct configfs_attribute
*target_stat_scsi_dev_attrs
[] = {
141 &target_stat_scsi_dev_inst
.attr
,
142 &target_stat_scsi_dev_indx
.attr
,
143 &target_stat_scsi_dev_role
.attr
,
144 &target_stat_scsi_dev_ports
.attr
,
148 static struct configfs_item_operations target_stat_scsi_dev_attrib_ops
= {
149 .show_attribute
= target_stat_scsi_dev_attr_show
,
150 .store_attribute
= target_stat_scsi_dev_attr_store
,
153 static struct config_item_type target_stat_scsi_dev_cit
= {
154 .ct_item_ops
= &target_stat_scsi_dev_attrib_ops
,
155 .ct_attrs
= target_stat_scsi_dev_attrs
,
156 .ct_owner
= THIS_MODULE
,
160 * SCSI Target Device Table
163 CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_dev
, se_dev_stat_grps
);
164 #define DEV_STAT_SCSI_TGT_DEV_ATTR(_name, _mode) \
165 static struct target_stat_scsi_tgt_dev_attribute \
166 target_stat_scsi_tgt_dev_##_name = \
167 __CONFIGFS_EATTR(_name, _mode, \
168 target_stat_scsi_tgt_dev_show_attr_##_name, \
169 target_stat_scsi_tgt_dev_store_attr_##_name);
171 #define DEV_STAT_SCSI_TGT_DEV_ATTR_RO(_name) \
172 static struct target_stat_scsi_tgt_dev_attribute \
173 target_stat_scsi_tgt_dev_##_name = \
174 __CONFIGFS_EATTR_RO(_name, \
175 target_stat_scsi_tgt_dev_show_attr_##_name);
177 static ssize_t
target_stat_scsi_tgt_dev_show_attr_inst(
178 struct se_dev_stat_grps
*sgrps
, char *page
)
180 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
181 struct se_subsystem_dev
, dev_stat_grps
);
182 struct se_hba
*hba
= se_subdev
->se_dev_hba
;
183 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
188 return snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
190 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(inst
);
192 static ssize_t
target_stat_scsi_tgt_dev_show_attr_indx(
193 struct se_dev_stat_grps
*sgrps
, char *page
)
195 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
196 struct se_subsystem_dev
, dev_stat_grps
);
197 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
202 return snprintf(page
, PAGE_SIZE
, "%u\n", dev
->dev_index
);
204 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(indx
);
206 static ssize_t
target_stat_scsi_tgt_dev_show_attr_num_lus(
207 struct se_dev_stat_grps
*sgrps
, char *page
)
209 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
210 struct se_subsystem_dev
, dev_stat_grps
);
211 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
216 return snprintf(page
, PAGE_SIZE
, "%u\n", LU_COUNT
);
218 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus
);
220 static ssize_t
target_stat_scsi_tgt_dev_show_attr_status(
221 struct se_dev_stat_grps
*sgrps
, char *page
)
223 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
224 struct se_subsystem_dev
, dev_stat_grps
);
225 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
231 switch (dev
->dev_status
) {
232 case TRANSPORT_DEVICE_ACTIVATED
:
233 strcpy(status
, "activated");
235 case TRANSPORT_DEVICE_DEACTIVATED
:
236 strcpy(status
, "deactivated");
238 case TRANSPORT_DEVICE_SHUTDOWN
:
239 strcpy(status
, "shutdown");
241 case TRANSPORT_DEVICE_OFFLINE_ACTIVATED
:
242 case TRANSPORT_DEVICE_OFFLINE_DEACTIVATED
:
243 strcpy(status
, "offline");
246 sprintf(status
, "unknown(%d)", dev
->dev_status
);
250 return snprintf(page
, PAGE_SIZE
, "%s\n", status
);
252 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status
);
254 static ssize_t
target_stat_scsi_tgt_dev_show_attr_non_access_lus(
255 struct se_dev_stat_grps
*sgrps
, char *page
)
257 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
258 struct se_subsystem_dev
, dev_stat_grps
);
259 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
260 int non_accessible_lus
;
265 switch (dev
->dev_status
) {
266 case TRANSPORT_DEVICE_ACTIVATED
:
267 non_accessible_lus
= 0;
269 case TRANSPORT_DEVICE_DEACTIVATED
:
270 case TRANSPORT_DEVICE_SHUTDOWN
:
271 case TRANSPORT_DEVICE_OFFLINE_ACTIVATED
:
272 case TRANSPORT_DEVICE_OFFLINE_DEACTIVATED
:
274 non_accessible_lus
= 1;
278 return snprintf(page
, PAGE_SIZE
, "%u\n", non_accessible_lus
);
280 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(non_access_lus
);
282 static ssize_t
target_stat_scsi_tgt_dev_show_attr_resets(
283 struct se_dev_stat_grps
*sgrps
, char *page
)
285 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
286 struct se_subsystem_dev
, dev_stat_grps
);
287 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
292 return snprintf(page
, PAGE_SIZE
, "%u\n", dev
->num_resets
);
294 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets
);
297 CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_dev
, se_dev_stat_grps
, scsi_tgt_dev_group
);
299 static struct configfs_attribute
*target_stat_scsi_tgt_dev_attrs
[] = {
300 &target_stat_scsi_tgt_dev_inst
.attr
,
301 &target_stat_scsi_tgt_dev_indx
.attr
,
302 &target_stat_scsi_tgt_dev_num_lus
.attr
,
303 &target_stat_scsi_tgt_dev_status
.attr
,
304 &target_stat_scsi_tgt_dev_non_access_lus
.attr
,
305 &target_stat_scsi_tgt_dev_resets
.attr
,
309 static struct configfs_item_operations target_stat_scsi_tgt_dev_attrib_ops
= {
310 .show_attribute
= target_stat_scsi_tgt_dev_attr_show
,
311 .store_attribute
= target_stat_scsi_tgt_dev_attr_store
,
314 static struct config_item_type target_stat_scsi_tgt_dev_cit
= {
315 .ct_item_ops
= &target_stat_scsi_tgt_dev_attrib_ops
,
316 .ct_attrs
= target_stat_scsi_tgt_dev_attrs
,
317 .ct_owner
= THIS_MODULE
,
321 * SCSI Logical Unit Table
324 CONFIGFS_EATTR_STRUCT(target_stat_scsi_lu
, se_dev_stat_grps
);
325 #define DEV_STAT_SCSI_LU_ATTR(_name, _mode) \
326 static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \
327 __CONFIGFS_EATTR(_name, _mode, \
328 target_stat_scsi_lu_show_attr_##_name, \
329 target_stat_scsi_lu_store_attr_##_name);
331 #define DEV_STAT_SCSI_LU_ATTR_RO(_name) \
332 static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \
333 __CONFIGFS_EATTR_RO(_name, \
334 target_stat_scsi_lu_show_attr_##_name);
336 static ssize_t
target_stat_scsi_lu_show_attr_inst(
337 struct se_dev_stat_grps
*sgrps
, char *page
)
339 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
340 struct se_subsystem_dev
, dev_stat_grps
);
341 struct se_hba
*hba
= se_subdev
->se_dev_hba
;
342 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
347 return snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
349 DEV_STAT_SCSI_LU_ATTR_RO(inst
);
351 static ssize_t
target_stat_scsi_lu_show_attr_dev(
352 struct se_dev_stat_grps
*sgrps
, char *page
)
354 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
355 struct se_subsystem_dev
, dev_stat_grps
);
356 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
361 return snprintf(page
, PAGE_SIZE
, "%u\n", dev
->dev_index
);
363 DEV_STAT_SCSI_LU_ATTR_RO(dev
);
365 static ssize_t
target_stat_scsi_lu_show_attr_indx(
366 struct se_dev_stat_grps
*sgrps
, char *page
)
368 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
369 struct se_subsystem_dev
, dev_stat_grps
);
370 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
375 return snprintf(page
, PAGE_SIZE
, "%u\n", SCSI_LU_INDEX
);
377 DEV_STAT_SCSI_LU_ATTR_RO(indx
);
379 static ssize_t
target_stat_scsi_lu_show_attr_lun(
380 struct se_dev_stat_grps
*sgrps
, char *page
)
382 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
383 struct se_subsystem_dev
, dev_stat_grps
);
384 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
388 /* FIXME: scsiLuDefaultLun */
389 return snprintf(page
, PAGE_SIZE
, "%llu\n", (unsigned long long)0);
391 DEV_STAT_SCSI_LU_ATTR_RO(lun
);
393 static ssize_t
target_stat_scsi_lu_show_attr_lu_name(
394 struct se_dev_stat_grps
*sgrps
, char *page
)
396 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
397 struct se_subsystem_dev
, dev_stat_grps
);
398 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
403 return snprintf(page
, PAGE_SIZE
, "%s\n",
404 (strlen(dev
->se_sub_dev
->t10_wwn
.unit_serial
)) ?
405 dev
->se_sub_dev
->t10_wwn
.unit_serial
: "None");
407 DEV_STAT_SCSI_LU_ATTR_RO(lu_name
);
409 static ssize_t
target_stat_scsi_lu_show_attr_vend(
410 struct se_dev_stat_grps
*sgrps
, char *page
)
412 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
413 struct se_subsystem_dev
, dev_stat_grps
);
414 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
416 char str
[sizeof(dev
->se_sub_dev
->t10_wwn
.vendor
)+1];
422 for (i
= 0; i
< sizeof(dev
->se_sub_dev
->t10_wwn
.vendor
); i
++)
423 str
[i
] = ISPRINT(dev
->se_sub_dev
->t10_wwn
.vendor
[i
]) ?
424 dev
->se_sub_dev
->t10_wwn
.vendor
[i
] : ' ';
426 return snprintf(page
, PAGE_SIZE
, "%s\n", str
);
428 DEV_STAT_SCSI_LU_ATTR_RO(vend
);
430 static ssize_t
target_stat_scsi_lu_show_attr_prod(
431 struct se_dev_stat_grps
*sgrps
, char *page
)
433 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
434 struct se_subsystem_dev
, dev_stat_grps
);
435 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
437 char str
[sizeof(dev
->se_sub_dev
->t10_wwn
.model
)+1];
442 /* scsiLuProductId */
443 for (i
= 0; i
< sizeof(dev
->se_sub_dev
->t10_wwn
.vendor
); i
++)
444 str
[i
] = ISPRINT(dev
->se_sub_dev
->t10_wwn
.model
[i
]) ?
445 dev
->se_sub_dev
->t10_wwn
.model
[i
] : ' ';
447 return snprintf(page
, PAGE_SIZE
, "%s\n", str
);
449 DEV_STAT_SCSI_LU_ATTR_RO(prod
);
451 static ssize_t
target_stat_scsi_lu_show_attr_rev(
452 struct se_dev_stat_grps
*sgrps
, char *page
)
454 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
455 struct se_subsystem_dev
, dev_stat_grps
);
456 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
458 char str
[sizeof(dev
->se_sub_dev
->t10_wwn
.revision
)+1];
463 /* scsiLuRevisionId */
464 for (i
= 0; i
< sizeof(dev
->se_sub_dev
->t10_wwn
.revision
); i
++)
465 str
[i
] = ISPRINT(dev
->se_sub_dev
->t10_wwn
.revision
[i
]) ?
466 dev
->se_sub_dev
->t10_wwn
.revision
[i
] : ' ';
468 return snprintf(page
, PAGE_SIZE
, "%s\n", str
);
470 DEV_STAT_SCSI_LU_ATTR_RO(rev
);
472 static ssize_t
target_stat_scsi_lu_show_attr_dev_type(
473 struct se_dev_stat_grps
*sgrps
, char *page
)
475 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
476 struct se_subsystem_dev
, dev_stat_grps
);
477 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
482 /* scsiLuPeripheralType */
483 return snprintf(page
, PAGE_SIZE
, "%u\n",
484 dev
->transport
->get_device_type(dev
));
486 DEV_STAT_SCSI_LU_ATTR_RO(dev_type
);
488 static ssize_t
target_stat_scsi_lu_show_attr_status(
489 struct se_dev_stat_grps
*sgrps
, char *page
)
491 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
492 struct se_subsystem_dev
, dev_stat_grps
);
493 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
499 return snprintf(page
, PAGE_SIZE
, "%s\n",
500 (dev
->dev_status
== TRANSPORT_DEVICE_ACTIVATED
) ?
501 "available" : "notavailable");
503 DEV_STAT_SCSI_LU_ATTR_RO(status
);
505 static ssize_t
target_stat_scsi_lu_show_attr_state_bit(
506 struct se_dev_stat_grps
*sgrps
, char *page
)
508 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
509 struct se_subsystem_dev
, dev_stat_grps
);
510 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
516 return snprintf(page
, PAGE_SIZE
, "exposed\n");
518 DEV_STAT_SCSI_LU_ATTR_RO(state_bit
);
520 static ssize_t
target_stat_scsi_lu_show_attr_num_cmds(
521 struct se_dev_stat_grps
*sgrps
, char *page
)
523 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
524 struct se_subsystem_dev
, dev_stat_grps
);
525 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
530 /* scsiLuNumCommands */
531 return snprintf(page
, PAGE_SIZE
, "%llu\n",
532 (unsigned long long)dev
->num_cmds
);
534 DEV_STAT_SCSI_LU_ATTR_RO(num_cmds
);
536 static ssize_t
target_stat_scsi_lu_show_attr_read_mbytes(
537 struct se_dev_stat_grps
*sgrps
, char *page
)
539 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
540 struct se_subsystem_dev
, dev_stat_grps
);
541 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
546 /* scsiLuReadMegaBytes */
547 return snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(dev
->read_bytes
>> 20));
549 DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes
);
551 static ssize_t
target_stat_scsi_lu_show_attr_write_mbytes(
552 struct se_dev_stat_grps
*sgrps
, char *page
)
554 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
555 struct se_subsystem_dev
, dev_stat_grps
);
556 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
561 /* scsiLuWrittenMegaBytes */
562 return snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(dev
->write_bytes
>> 20));
564 DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes
);
566 static ssize_t
target_stat_scsi_lu_show_attr_resets(
567 struct se_dev_stat_grps
*sgrps
, char *page
)
569 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
570 struct se_subsystem_dev
, dev_stat_grps
);
571 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
577 return snprintf(page
, PAGE_SIZE
, "%u\n", dev
->num_resets
);
579 DEV_STAT_SCSI_LU_ATTR_RO(resets
);
581 static ssize_t
target_stat_scsi_lu_show_attr_full_stat(
582 struct se_dev_stat_grps
*sgrps
, char *page
)
584 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
585 struct se_subsystem_dev
, dev_stat_grps
);
586 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
591 /* FIXME: scsiLuOutTaskSetFullStatus */
592 return snprintf(page
, PAGE_SIZE
, "%u\n", 0);
594 DEV_STAT_SCSI_LU_ATTR_RO(full_stat
);
596 static ssize_t
target_stat_scsi_lu_show_attr_hs_num_cmds(
597 struct se_dev_stat_grps
*sgrps
, char *page
)
599 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
600 struct se_subsystem_dev
, dev_stat_grps
);
601 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
606 /* FIXME: scsiLuHSInCommands */
607 return snprintf(page
, PAGE_SIZE
, "%u\n", 0);
609 DEV_STAT_SCSI_LU_ATTR_RO(hs_num_cmds
);
611 static ssize_t
target_stat_scsi_lu_show_attr_creation_time(
612 struct se_dev_stat_grps
*sgrps
, char *page
)
614 struct se_subsystem_dev
*se_subdev
= container_of(sgrps
,
615 struct se_subsystem_dev
, dev_stat_grps
);
616 struct se_device
*dev
= se_subdev
->se_dev_ptr
;
621 /* scsiLuCreationTime */
622 return snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(((u32
)dev
->creation_time
-
623 INITIAL_JIFFIES
) * 100 / HZ
));
625 DEV_STAT_SCSI_LU_ATTR_RO(creation_time
);
627 CONFIGFS_EATTR_OPS(target_stat_scsi_lu
, se_dev_stat_grps
, scsi_lu_group
);
629 static struct configfs_attribute
*target_stat_scsi_lu_attrs
[] = {
630 &target_stat_scsi_lu_inst
.attr
,
631 &target_stat_scsi_lu_dev
.attr
,
632 &target_stat_scsi_lu_indx
.attr
,
633 &target_stat_scsi_lu_lun
.attr
,
634 &target_stat_scsi_lu_lu_name
.attr
,
635 &target_stat_scsi_lu_vend
.attr
,
636 &target_stat_scsi_lu_prod
.attr
,
637 &target_stat_scsi_lu_rev
.attr
,
638 &target_stat_scsi_lu_dev_type
.attr
,
639 &target_stat_scsi_lu_status
.attr
,
640 &target_stat_scsi_lu_state_bit
.attr
,
641 &target_stat_scsi_lu_num_cmds
.attr
,
642 &target_stat_scsi_lu_read_mbytes
.attr
,
643 &target_stat_scsi_lu_write_mbytes
.attr
,
644 &target_stat_scsi_lu_resets
.attr
,
645 &target_stat_scsi_lu_full_stat
.attr
,
646 &target_stat_scsi_lu_hs_num_cmds
.attr
,
647 &target_stat_scsi_lu_creation_time
.attr
,
651 static struct configfs_item_operations target_stat_scsi_lu_attrib_ops
= {
652 .show_attribute
= target_stat_scsi_lu_attr_show
,
653 .store_attribute
= target_stat_scsi_lu_attr_store
,
656 static struct config_item_type target_stat_scsi_lu_cit
= {
657 .ct_item_ops
= &target_stat_scsi_lu_attrib_ops
,
658 .ct_attrs
= target_stat_scsi_lu_attrs
,
659 .ct_owner
= THIS_MODULE
,
663 * Called from target_core_configfs.c:target_core_make_subdev() to setup
664 * the target statistics groups + configfs CITs located in target_core_stat.c
666 void target_stat_setup_dev_default_groups(struct se_subsystem_dev
*se_subdev
)
668 struct config_group
*dev_stat_grp
= &se_subdev
->dev_stat_grps
.stat_group
;
670 config_group_init_type_name(&se_subdev
->dev_stat_grps
.scsi_dev_group
,
671 "scsi_dev", &target_stat_scsi_dev_cit
);
672 config_group_init_type_name(&se_subdev
->dev_stat_grps
.scsi_tgt_dev_group
,
673 "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit
);
674 config_group_init_type_name(&se_subdev
->dev_stat_grps
.scsi_lu_group
,
675 "scsi_lu", &target_stat_scsi_lu_cit
);
677 dev_stat_grp
->default_groups
[0] = &se_subdev
->dev_stat_grps
.scsi_dev_group
;
678 dev_stat_grp
->default_groups
[1] = &se_subdev
->dev_stat_grps
.scsi_tgt_dev_group
;
679 dev_stat_grp
->default_groups
[2] = &se_subdev
->dev_stat_grps
.scsi_lu_group
;
680 dev_stat_grp
->default_groups
[3] = NULL
;
687 CONFIGFS_EATTR_STRUCT(target_stat_scsi_port
, se_port_stat_grps
);
688 #define DEV_STAT_SCSI_PORT_ATTR(_name, _mode) \
689 static struct target_stat_scsi_port_attribute \
690 target_stat_scsi_port_##_name = \
691 __CONFIGFS_EATTR(_name, _mode, \
692 target_stat_scsi_port_show_attr_##_name, \
693 target_stat_scsi_port_store_attr_##_name);
695 #define DEV_STAT_SCSI_PORT_ATTR_RO(_name) \
696 static struct target_stat_scsi_port_attribute \
697 target_stat_scsi_port_##_name = \
698 __CONFIGFS_EATTR_RO(_name, \
699 target_stat_scsi_port_show_attr_##_name);
701 static ssize_t
target_stat_scsi_port_show_attr_inst(
702 struct se_port_stat_grps
*pgrps
, char *page
)
704 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
706 struct se_device
*dev
= lun
->lun_se_dev
;
710 spin_lock(&lun
->lun_sep_lock
);
713 spin_unlock(&lun
->lun_sep_lock
);
717 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
718 spin_unlock(&lun
->lun_sep_lock
);
721 DEV_STAT_SCSI_PORT_ATTR_RO(inst
);
723 static ssize_t
target_stat_scsi_port_show_attr_dev(
724 struct se_port_stat_grps
*pgrps
, char *page
)
726 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
728 struct se_device
*dev
= lun
->lun_se_dev
;
731 spin_lock(&lun
->lun_sep_lock
);
734 spin_unlock(&lun
->lun_sep_lock
);
737 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", dev
->dev_index
);
738 spin_unlock(&lun
->lun_sep_lock
);
741 DEV_STAT_SCSI_PORT_ATTR_RO(dev
);
743 static ssize_t
target_stat_scsi_port_show_attr_indx(
744 struct se_port_stat_grps
*pgrps
, char *page
)
746 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
750 spin_lock(&lun
->lun_sep_lock
);
753 spin_unlock(&lun
->lun_sep_lock
);
756 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", sep
->sep_index
);
757 spin_unlock(&lun
->lun_sep_lock
);
760 DEV_STAT_SCSI_PORT_ATTR_RO(indx
);
762 static ssize_t
target_stat_scsi_port_show_attr_role(
763 struct se_port_stat_grps
*pgrps
, char *page
)
765 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
766 struct se_device
*dev
= lun
->lun_se_dev
;
773 spin_lock(&lun
->lun_sep_lock
);
776 spin_unlock(&lun
->lun_sep_lock
);
779 ret
= snprintf(page
, PAGE_SIZE
, "%s%u\n", "Device", dev
->dev_index
);
780 spin_unlock(&lun
->lun_sep_lock
);
783 DEV_STAT_SCSI_PORT_ATTR_RO(role
);
785 static ssize_t
target_stat_scsi_port_show_attr_busy_count(
786 struct se_port_stat_grps
*pgrps
, char *page
)
788 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
792 spin_lock(&lun
->lun_sep_lock
);
795 spin_unlock(&lun
->lun_sep_lock
);
798 /* FIXME: scsiPortBusyStatuses */
799 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
800 spin_unlock(&lun
->lun_sep_lock
);
803 DEV_STAT_SCSI_PORT_ATTR_RO(busy_count
);
805 CONFIGFS_EATTR_OPS(target_stat_scsi_port
, se_port_stat_grps
, scsi_port_group
);
807 static struct configfs_attribute
*target_stat_scsi_port_attrs
[] = {
808 &target_stat_scsi_port_inst
.attr
,
809 &target_stat_scsi_port_dev
.attr
,
810 &target_stat_scsi_port_indx
.attr
,
811 &target_stat_scsi_port_role
.attr
,
812 &target_stat_scsi_port_busy_count
.attr
,
816 static struct configfs_item_operations target_stat_scsi_port_attrib_ops
= {
817 .show_attribute
= target_stat_scsi_port_attr_show
,
818 .store_attribute
= target_stat_scsi_port_attr_store
,
821 static struct config_item_type target_stat_scsi_port_cit
= {
822 .ct_item_ops
= &target_stat_scsi_port_attrib_ops
,
823 .ct_attrs
= target_stat_scsi_port_attrs
,
824 .ct_owner
= THIS_MODULE
,
828 * SCSI Target Port Table
830 CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_port
, se_port_stat_grps
);
831 #define DEV_STAT_SCSI_TGT_PORT_ATTR(_name, _mode) \
832 static struct target_stat_scsi_tgt_port_attribute \
833 target_stat_scsi_tgt_port_##_name = \
834 __CONFIGFS_EATTR(_name, _mode, \
835 target_stat_scsi_tgt_port_show_attr_##_name, \
836 target_stat_scsi_tgt_port_store_attr_##_name);
838 #define DEV_STAT_SCSI_TGT_PORT_ATTR_RO(_name) \
839 static struct target_stat_scsi_tgt_port_attribute \
840 target_stat_scsi_tgt_port_##_name = \
841 __CONFIGFS_EATTR_RO(_name, \
842 target_stat_scsi_tgt_port_show_attr_##_name);
844 static ssize_t
target_stat_scsi_tgt_port_show_attr_inst(
845 struct se_port_stat_grps
*pgrps
, char *page
)
847 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
848 struct se_device
*dev
= lun
->lun_se_dev
;
853 spin_lock(&lun
->lun_sep_lock
);
856 spin_unlock(&lun
->lun_sep_lock
);
860 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
861 spin_unlock(&lun
->lun_sep_lock
);
864 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst
);
866 static ssize_t
target_stat_scsi_tgt_port_show_attr_dev(
867 struct se_port_stat_grps
*pgrps
, char *page
)
869 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
870 struct se_device
*dev
= lun
->lun_se_dev
;
874 spin_lock(&lun
->lun_sep_lock
);
877 spin_unlock(&lun
->lun_sep_lock
);
880 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", dev
->dev_index
);
881 spin_unlock(&lun
->lun_sep_lock
);
884 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev
);
886 static ssize_t
target_stat_scsi_tgt_port_show_attr_indx(
887 struct se_port_stat_grps
*pgrps
, char *page
)
889 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
893 spin_lock(&lun
->lun_sep_lock
);
896 spin_unlock(&lun
->lun_sep_lock
);
899 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", sep
->sep_index
);
900 spin_unlock(&lun
->lun_sep_lock
);
903 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx
);
905 static ssize_t
target_stat_scsi_tgt_port_show_attr_name(
906 struct se_port_stat_grps
*pgrps
, char *page
)
908 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
910 struct se_portal_group
*tpg
;
913 spin_lock(&lun
->lun_sep_lock
);
916 spin_unlock(&lun
->lun_sep_lock
);
921 ret
= snprintf(page
, PAGE_SIZE
, "%sPort#%u\n",
922 tpg
->se_tpg_tfo
->get_fabric_name(), sep
->sep_index
);
923 spin_unlock(&lun
->lun_sep_lock
);
926 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name
);
928 static ssize_t
target_stat_scsi_tgt_port_show_attr_port_index(
929 struct se_port_stat_grps
*pgrps
, char *page
)
931 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
933 struct se_portal_group
*tpg
;
936 spin_lock(&lun
->lun_sep_lock
);
939 spin_unlock(&lun
->lun_sep_lock
);
944 ret
= snprintf(page
, PAGE_SIZE
, "%s%s%d\n",
945 tpg
->se_tpg_tfo
->tpg_get_wwn(tpg
), "+t+",
946 tpg
->se_tpg_tfo
->tpg_get_tag(tpg
));
947 spin_unlock(&lun
->lun_sep_lock
);
950 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index
);
952 static ssize_t
target_stat_scsi_tgt_port_show_attr_in_cmds(
953 struct se_port_stat_grps
*pgrps
, char *page
)
955 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
959 spin_lock(&lun
->lun_sep_lock
);
962 spin_unlock(&lun
->lun_sep_lock
);
966 ret
= snprintf(page
, PAGE_SIZE
, "%llu\n", sep
->sep_stats
.cmd_pdus
);
967 spin_unlock(&lun
->lun_sep_lock
);
970 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds
);
972 static ssize_t
target_stat_scsi_tgt_port_show_attr_write_mbytes(
973 struct se_port_stat_grps
*pgrps
, char *page
)
975 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
979 spin_lock(&lun
->lun_sep_lock
);
982 spin_unlock(&lun
->lun_sep_lock
);
986 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
987 (u32
)(sep
->sep_stats
.rx_data_octets
>> 20));
988 spin_unlock(&lun
->lun_sep_lock
);
991 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes
);
993 static ssize_t
target_stat_scsi_tgt_port_show_attr_read_mbytes(
994 struct se_port_stat_grps
*pgrps
, char *page
)
996 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1000 spin_lock(&lun
->lun_sep_lock
);
1003 spin_unlock(&lun
->lun_sep_lock
);
1007 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1008 (u32
)(sep
->sep_stats
.tx_data_octets
>> 20));
1009 spin_unlock(&lun
->lun_sep_lock
);
1012 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes
);
1014 static ssize_t
target_stat_scsi_tgt_port_show_attr_hs_in_cmds(
1015 struct se_port_stat_grps
*pgrps
, char *page
)
1017 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1018 struct se_port
*sep
;
1021 spin_lock(&lun
->lun_sep_lock
);
1024 spin_unlock(&lun
->lun_sep_lock
);
1028 /* FIXME: scsiTgtPortHsInCommands */
1029 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
1030 spin_unlock(&lun
->lun_sep_lock
);
1033 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds
);
1035 CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_port
, se_port_stat_grps
,
1036 scsi_tgt_port_group
);
1038 static struct configfs_attribute
*target_stat_scsi_tgt_port_attrs
[] = {
1039 &target_stat_scsi_tgt_port_inst
.attr
,
1040 &target_stat_scsi_tgt_port_dev
.attr
,
1041 &target_stat_scsi_tgt_port_indx
.attr
,
1042 &target_stat_scsi_tgt_port_name
.attr
,
1043 &target_stat_scsi_tgt_port_port_index
.attr
,
1044 &target_stat_scsi_tgt_port_in_cmds
.attr
,
1045 &target_stat_scsi_tgt_port_write_mbytes
.attr
,
1046 &target_stat_scsi_tgt_port_read_mbytes
.attr
,
1047 &target_stat_scsi_tgt_port_hs_in_cmds
.attr
,
1051 static struct configfs_item_operations target_stat_scsi_tgt_port_attrib_ops
= {
1052 .show_attribute
= target_stat_scsi_tgt_port_attr_show
,
1053 .store_attribute
= target_stat_scsi_tgt_port_attr_store
,
1056 static struct config_item_type target_stat_scsi_tgt_port_cit
= {
1057 .ct_item_ops
= &target_stat_scsi_tgt_port_attrib_ops
,
1058 .ct_attrs
= target_stat_scsi_tgt_port_attrs
,
1059 .ct_owner
= THIS_MODULE
,
1063 * SCSI Transport Table
1066 CONFIGFS_EATTR_STRUCT(target_stat_scsi_transport
, se_port_stat_grps
);
1067 #define DEV_STAT_SCSI_TRANSPORT_ATTR(_name, _mode) \
1068 static struct target_stat_scsi_transport_attribute \
1069 target_stat_scsi_transport_##_name = \
1070 __CONFIGFS_EATTR(_name, _mode, \
1071 target_stat_scsi_transport_show_attr_##_name, \
1072 target_stat_scsi_transport_store_attr_##_name);
1074 #define DEV_STAT_SCSI_TRANSPORT_ATTR_RO(_name) \
1075 static struct target_stat_scsi_transport_attribute \
1076 target_stat_scsi_transport_##_name = \
1077 __CONFIGFS_EATTR_RO(_name, \
1078 target_stat_scsi_transport_show_attr_##_name);
1080 static ssize_t
target_stat_scsi_transport_show_attr_inst(
1081 struct se_port_stat_grps
*pgrps
, char *page
)
1083 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1084 struct se_device
*dev
= lun
->lun_se_dev
;
1085 struct se_port
*sep
;
1089 spin_lock(&lun
->lun_sep_lock
);
1092 spin_unlock(&lun
->lun_sep_lock
);
1097 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
1098 spin_unlock(&lun
->lun_sep_lock
);
1101 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst
);
1103 static ssize_t
target_stat_scsi_transport_show_attr_device(
1104 struct se_port_stat_grps
*pgrps
, char *page
)
1106 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1107 struct se_port
*sep
;
1108 struct se_portal_group
*tpg
;
1111 spin_lock(&lun
->lun_sep_lock
);
1114 spin_unlock(&lun
->lun_sep_lock
);
1118 /* scsiTransportType */
1119 ret
= snprintf(page
, PAGE_SIZE
, "scsiTransport%s\n",
1120 tpg
->se_tpg_tfo
->get_fabric_name());
1121 spin_unlock(&lun
->lun_sep_lock
);
1124 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device
);
1126 static ssize_t
target_stat_scsi_transport_show_attr_indx(
1127 struct se_port_stat_grps
*pgrps
, char *page
)
1129 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1130 struct se_port
*sep
;
1131 struct se_portal_group
*tpg
;
1134 spin_lock(&lun
->lun_sep_lock
);
1137 spin_unlock(&lun
->lun_sep_lock
);
1141 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1142 tpg
->se_tpg_tfo
->tpg_get_inst_index(tpg
));
1143 spin_unlock(&lun
->lun_sep_lock
);
1146 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx
);
1148 static ssize_t
target_stat_scsi_transport_show_attr_dev_name(
1149 struct se_port_stat_grps
*pgrps
, char *page
)
1151 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1152 struct se_device
*dev
= lun
->lun_se_dev
;
1153 struct se_port
*sep
;
1154 struct se_portal_group
*tpg
;
1155 struct t10_wwn
*wwn
;
1158 spin_lock(&lun
->lun_sep_lock
);
1161 spin_unlock(&lun
->lun_sep_lock
);
1165 wwn
= &dev
->se_sub_dev
->t10_wwn
;
1166 /* scsiTransportDevName */
1167 ret
= snprintf(page
, PAGE_SIZE
, "%s+%s\n",
1168 tpg
->se_tpg_tfo
->tpg_get_wwn(tpg
),
1169 (strlen(wwn
->unit_serial
)) ? wwn
->unit_serial
:
1171 spin_unlock(&lun
->lun_sep_lock
);
1174 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name
);
1176 CONFIGFS_EATTR_OPS(target_stat_scsi_transport
, se_port_stat_grps
,
1177 scsi_transport_group
);
1179 static struct configfs_attribute
*target_stat_scsi_transport_attrs
[] = {
1180 &target_stat_scsi_transport_inst
.attr
,
1181 &target_stat_scsi_transport_device
.attr
,
1182 &target_stat_scsi_transport_indx
.attr
,
1183 &target_stat_scsi_transport_dev_name
.attr
,
1187 static struct configfs_item_operations target_stat_scsi_transport_attrib_ops
= {
1188 .show_attribute
= target_stat_scsi_transport_attr_show
,
1189 .store_attribute
= target_stat_scsi_transport_attr_store
,
1192 static struct config_item_type target_stat_scsi_transport_cit
= {
1193 .ct_item_ops
= &target_stat_scsi_transport_attrib_ops
,
1194 .ct_attrs
= target_stat_scsi_transport_attrs
,
1195 .ct_owner
= THIS_MODULE
,
1199 * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup
1200 * the target port statistics groups + configfs CITs located in target_core_stat.c
1202 void target_stat_setup_port_default_groups(struct se_lun
*lun
)
1204 struct config_group
*port_stat_grp
= &lun
->port_stat_grps
.stat_group
;
1206 config_group_init_type_name(&lun
->port_stat_grps
.scsi_port_group
,
1207 "scsi_port", &target_stat_scsi_port_cit
);
1208 config_group_init_type_name(&lun
->port_stat_grps
.scsi_tgt_port_group
,
1209 "scsi_tgt_port", &target_stat_scsi_tgt_port_cit
);
1210 config_group_init_type_name(&lun
->port_stat_grps
.scsi_transport_group
,
1211 "scsi_transport", &target_stat_scsi_transport_cit
);
1213 port_stat_grp
->default_groups
[0] = &lun
->port_stat_grps
.scsi_port_group
;
1214 port_stat_grp
->default_groups
[1] = &lun
->port_stat_grps
.scsi_tgt_port_group
;
1215 port_stat_grp
->default_groups
[2] = &lun
->port_stat_grps
.scsi_transport_group
;
1216 port_stat_grp
->default_groups
[3] = NULL
;
1220 * SCSI Authorized Initiator Table
1223 CONFIGFS_EATTR_STRUCT(target_stat_scsi_auth_intr
, se_ml_stat_grps
);
1224 #define DEV_STAT_SCSI_AUTH_INTR_ATTR(_name, _mode) \
1225 static struct target_stat_scsi_auth_intr_attribute \
1226 target_stat_scsi_auth_intr_##_name = \
1227 __CONFIGFS_EATTR(_name, _mode, \
1228 target_stat_scsi_auth_intr_show_attr_##_name, \
1229 target_stat_scsi_auth_intr_store_attr_##_name);
1231 #define DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(_name) \
1232 static struct target_stat_scsi_auth_intr_attribute \
1233 target_stat_scsi_auth_intr_##_name = \
1234 __CONFIGFS_EATTR_RO(_name, \
1235 target_stat_scsi_auth_intr_show_attr_##_name);
1237 static ssize_t
target_stat_scsi_auth_intr_show_attr_inst(
1238 struct se_ml_stat_grps
*lgrps
, char *page
)
1240 struct se_lun_acl
*lacl
= container_of(lgrps
,
1241 struct se_lun_acl
, ml_stat_grps
);
1242 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1243 struct se_dev_entry
*deve
;
1244 struct se_portal_group
*tpg
;
1247 spin_lock_irq(&nacl
->device_list_lock
);
1248 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1249 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1250 spin_unlock_irq(&nacl
->device_list_lock
);
1255 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1256 tpg
->se_tpg_tfo
->tpg_get_inst_index(tpg
));
1257 spin_unlock_irq(&nacl
->device_list_lock
);
1260 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst
);
1262 static ssize_t
target_stat_scsi_auth_intr_show_attr_dev(
1263 struct se_ml_stat_grps
*lgrps
, char *page
)
1265 struct se_lun_acl
*lacl
= container_of(lgrps
,
1266 struct se_lun_acl
, ml_stat_grps
);
1267 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1268 struct se_dev_entry
*deve
;
1272 spin_lock_irq(&nacl
->device_list_lock
);
1273 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1274 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1275 spin_unlock_irq(&nacl
->device_list_lock
);
1279 /* scsiDeviceIndex */
1280 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lun
->lun_se_dev
->dev_index
);
1281 spin_unlock_irq(&nacl
->device_list_lock
);
1284 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev
);
1286 static ssize_t
target_stat_scsi_auth_intr_show_attr_port(
1287 struct se_ml_stat_grps
*lgrps
, char *page
)
1289 struct se_lun_acl
*lacl
= container_of(lgrps
,
1290 struct se_lun_acl
, ml_stat_grps
);
1291 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1292 struct se_dev_entry
*deve
;
1293 struct se_portal_group
*tpg
;
1296 spin_lock_irq(&nacl
->device_list_lock
);
1297 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1298 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1299 spin_unlock_irq(&nacl
->device_list_lock
);
1303 /* scsiAuthIntrTgtPortIndex */
1304 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", tpg
->se_tpg_tfo
->tpg_get_tag(tpg
));
1305 spin_unlock_irq(&nacl
->device_list_lock
);
1308 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port
);
1310 static ssize_t
target_stat_scsi_auth_intr_show_attr_indx(
1311 struct se_ml_stat_grps
*lgrps
, char *page
)
1313 struct se_lun_acl
*lacl
= container_of(lgrps
,
1314 struct se_lun_acl
, ml_stat_grps
);
1315 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1316 struct se_dev_entry
*deve
;
1319 spin_lock_irq(&nacl
->device_list_lock
);
1320 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1321 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1322 spin_unlock_irq(&nacl
->device_list_lock
);
1325 /* scsiAuthIntrIndex */
1326 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", nacl
->acl_index
);
1327 spin_unlock_irq(&nacl
->device_list_lock
);
1330 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx
);
1332 static ssize_t
target_stat_scsi_auth_intr_show_attr_dev_or_port(
1333 struct se_ml_stat_grps
*lgrps
, char *page
)
1335 struct se_lun_acl
*lacl
= container_of(lgrps
,
1336 struct se_lun_acl
, ml_stat_grps
);
1337 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1338 struct se_dev_entry
*deve
;
1341 spin_lock_irq(&nacl
->device_list_lock
);
1342 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1343 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1344 spin_unlock_irq(&nacl
->device_list_lock
);
1347 /* scsiAuthIntrDevOrPort */
1348 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 1);
1349 spin_unlock_irq(&nacl
->device_list_lock
);
1352 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port
);
1354 static ssize_t
target_stat_scsi_auth_intr_show_attr_intr_name(
1355 struct se_ml_stat_grps
*lgrps
, char *page
)
1357 struct se_lun_acl
*lacl
= container_of(lgrps
,
1358 struct se_lun_acl
, ml_stat_grps
);
1359 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1360 struct se_dev_entry
*deve
;
1363 spin_lock_irq(&nacl
->device_list_lock
);
1364 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1365 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1366 spin_unlock_irq(&nacl
->device_list_lock
);
1369 /* scsiAuthIntrName */
1370 ret
= snprintf(page
, PAGE_SIZE
, "%s\n", nacl
->initiatorname
);
1371 spin_unlock_irq(&nacl
->device_list_lock
);
1374 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name
);
1376 static ssize_t
target_stat_scsi_auth_intr_show_attr_map_indx(
1377 struct se_ml_stat_grps
*lgrps
, char *page
)
1379 struct se_lun_acl
*lacl
= container_of(lgrps
,
1380 struct se_lun_acl
, ml_stat_grps
);
1381 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1382 struct se_dev_entry
*deve
;
1385 spin_lock_irq(&nacl
->device_list_lock
);
1386 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1387 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1388 spin_unlock_irq(&nacl
->device_list_lock
);
1391 /* FIXME: scsiAuthIntrLunMapIndex */
1392 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
1393 spin_unlock_irq(&nacl
->device_list_lock
);
1396 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx
);
1398 static ssize_t
target_stat_scsi_auth_intr_show_attr_att_count(
1399 struct se_ml_stat_grps
*lgrps
, char *page
)
1401 struct se_lun_acl
*lacl
= container_of(lgrps
,
1402 struct se_lun_acl
, ml_stat_grps
);
1403 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1404 struct se_dev_entry
*deve
;
1407 spin_lock_irq(&nacl
->device_list_lock
);
1408 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1409 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1410 spin_unlock_irq(&nacl
->device_list_lock
);
1413 /* scsiAuthIntrAttachedTimes */
1414 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", deve
->attach_count
);
1415 spin_unlock_irq(&nacl
->device_list_lock
);
1418 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count
);
1420 static ssize_t
target_stat_scsi_auth_intr_show_attr_num_cmds(
1421 struct se_ml_stat_grps
*lgrps
, char *page
)
1423 struct se_lun_acl
*lacl
= container_of(lgrps
,
1424 struct se_lun_acl
, ml_stat_grps
);
1425 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1426 struct se_dev_entry
*deve
;
1429 spin_lock_irq(&nacl
->device_list_lock
);
1430 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1431 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1432 spin_unlock_irq(&nacl
->device_list_lock
);
1435 /* scsiAuthIntrOutCommands */
1436 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", deve
->total_cmds
);
1437 spin_unlock_irq(&nacl
->device_list_lock
);
1440 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds
);
1442 static ssize_t
target_stat_scsi_auth_intr_show_attr_read_mbytes(
1443 struct se_ml_stat_grps
*lgrps
, char *page
)
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_dev_entry
*deve
;
1451 spin_lock_irq(&nacl
->device_list_lock
);
1452 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1453 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1454 spin_unlock_irq(&nacl
->device_list_lock
);
1457 /* scsiAuthIntrReadMegaBytes */
1458 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(deve
->read_bytes
>> 20));
1459 spin_unlock_irq(&nacl
->device_list_lock
);
1462 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes
);
1464 static ssize_t
target_stat_scsi_auth_intr_show_attr_write_mbytes(
1465 struct se_ml_stat_grps
*lgrps
, char *page
)
1467 struct se_lun_acl
*lacl
= container_of(lgrps
,
1468 struct se_lun_acl
, ml_stat_grps
);
1469 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1470 struct se_dev_entry
*deve
;
1473 spin_lock_irq(&nacl
->device_list_lock
);
1474 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1475 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1476 spin_unlock_irq(&nacl
->device_list_lock
);
1479 /* scsiAuthIntrWrittenMegaBytes */
1480 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(deve
->write_bytes
>> 20));
1481 spin_unlock_irq(&nacl
->device_list_lock
);
1484 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes
);
1486 static ssize_t
target_stat_scsi_auth_intr_show_attr_hs_num_cmds(
1487 struct se_ml_stat_grps
*lgrps
, char *page
)
1489 struct se_lun_acl
*lacl
= container_of(lgrps
,
1490 struct se_lun_acl
, ml_stat_grps
);
1491 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1492 struct se_dev_entry
*deve
;
1495 spin_lock_irq(&nacl
->device_list_lock
);
1496 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1497 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1498 spin_unlock_irq(&nacl
->device_list_lock
);
1501 /* FIXME: scsiAuthIntrHSOutCommands */
1502 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
1503 spin_unlock_irq(&nacl
->device_list_lock
);
1506 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds
);
1508 static ssize_t
target_stat_scsi_auth_intr_show_attr_creation_time(
1509 struct se_ml_stat_grps
*lgrps
, char *page
)
1511 struct se_lun_acl
*lacl
= container_of(lgrps
,
1512 struct se_lun_acl
, ml_stat_grps
);
1513 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1514 struct se_dev_entry
*deve
;
1517 spin_lock_irq(&nacl
->device_list_lock
);
1518 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1519 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1520 spin_unlock_irq(&nacl
->device_list_lock
);
1523 /* scsiAuthIntrLastCreation */
1524 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(((u32
)deve
->creation_time
-
1525 INITIAL_JIFFIES
) * 100 / HZ
));
1526 spin_unlock_irq(&nacl
->device_list_lock
);
1529 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time
);
1531 static ssize_t
target_stat_scsi_auth_intr_show_attr_row_status(
1532 struct se_ml_stat_grps
*lgrps
, char *page
)
1534 struct se_lun_acl
*lacl
= container_of(lgrps
,
1535 struct se_lun_acl
, ml_stat_grps
);
1536 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1537 struct se_dev_entry
*deve
;
1540 spin_lock_irq(&nacl
->device_list_lock
);
1541 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1542 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1543 spin_unlock_irq(&nacl
->device_list_lock
);
1546 /* FIXME: scsiAuthIntrRowStatus */
1547 ret
= snprintf(page
, PAGE_SIZE
, "Ready\n");
1548 spin_unlock_irq(&nacl
->device_list_lock
);
1551 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status
);
1553 CONFIGFS_EATTR_OPS(target_stat_scsi_auth_intr
, se_ml_stat_grps
,
1554 scsi_auth_intr_group
);
1556 static struct configfs_attribute
*target_stat_scsi_auth_intr_attrs
[] = {
1557 &target_stat_scsi_auth_intr_inst
.attr
,
1558 &target_stat_scsi_auth_intr_dev
.attr
,
1559 &target_stat_scsi_auth_intr_port
.attr
,
1560 &target_stat_scsi_auth_intr_indx
.attr
,
1561 &target_stat_scsi_auth_intr_dev_or_port
.attr
,
1562 &target_stat_scsi_auth_intr_intr_name
.attr
,
1563 &target_stat_scsi_auth_intr_map_indx
.attr
,
1564 &target_stat_scsi_auth_intr_att_count
.attr
,
1565 &target_stat_scsi_auth_intr_num_cmds
.attr
,
1566 &target_stat_scsi_auth_intr_read_mbytes
.attr
,
1567 &target_stat_scsi_auth_intr_write_mbytes
.attr
,
1568 &target_stat_scsi_auth_intr_hs_num_cmds
.attr
,
1569 &target_stat_scsi_auth_intr_creation_time
.attr
,
1570 &target_stat_scsi_auth_intr_row_status
.attr
,
1574 static struct configfs_item_operations target_stat_scsi_auth_intr_attrib_ops
= {
1575 .show_attribute
= target_stat_scsi_auth_intr_attr_show
,
1576 .store_attribute
= target_stat_scsi_auth_intr_attr_store
,
1579 static struct config_item_type target_stat_scsi_auth_intr_cit
= {
1580 .ct_item_ops
= &target_stat_scsi_auth_intr_attrib_ops
,
1581 .ct_attrs
= target_stat_scsi_auth_intr_attrs
,
1582 .ct_owner
= THIS_MODULE
,
1586 * SCSI Attached Initiator Port Table
1589 CONFIGFS_EATTR_STRUCT(target_stat_scsi_att_intr_port
, se_ml_stat_grps
);
1590 #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR(_name, _mode) \
1591 static struct target_stat_scsi_att_intr_port_attribute \
1592 target_stat_scsi_att_intr_port_##_name = \
1593 __CONFIGFS_EATTR(_name, _mode, \
1594 target_stat_scsi_att_intr_port_show_attr_##_name, \
1595 target_stat_scsi_att_intr_port_store_attr_##_name);
1597 #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(_name) \
1598 static struct target_stat_scsi_att_intr_port_attribute \
1599 target_stat_scsi_att_intr_port_##_name = \
1600 __CONFIGFS_EATTR_RO(_name, \
1601 target_stat_scsi_att_intr_port_show_attr_##_name);
1603 static ssize_t
target_stat_scsi_att_intr_port_show_attr_inst(
1604 struct se_ml_stat_grps
*lgrps
, char *page
)
1606 struct se_lun_acl
*lacl
= container_of(lgrps
,
1607 struct se_lun_acl
, ml_stat_grps
);
1608 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1609 struct se_dev_entry
*deve
;
1610 struct se_portal_group
*tpg
;
1613 spin_lock_irq(&nacl
->device_list_lock
);
1614 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1615 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1616 spin_unlock_irq(&nacl
->device_list_lock
);
1621 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1622 tpg
->se_tpg_tfo
->tpg_get_inst_index(tpg
));
1623 spin_unlock_irq(&nacl
->device_list_lock
);
1626 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst
);
1628 static ssize_t
target_stat_scsi_att_intr_port_show_attr_dev(
1629 struct se_ml_stat_grps
*lgrps
, char *page
)
1631 struct se_lun_acl
*lacl
= container_of(lgrps
,
1632 struct se_lun_acl
, ml_stat_grps
);
1633 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1634 struct se_dev_entry
*deve
;
1638 spin_lock_irq(&nacl
->device_list_lock
);
1639 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1640 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1641 spin_unlock_irq(&nacl
->device_list_lock
);
1645 /* scsiDeviceIndex */
1646 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lun
->lun_se_dev
->dev_index
);
1647 spin_unlock_irq(&nacl
->device_list_lock
);
1650 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev
);
1652 static ssize_t
target_stat_scsi_att_intr_port_show_attr_port(
1653 struct se_ml_stat_grps
*lgrps
, char *page
)
1655 struct se_lun_acl
*lacl
= container_of(lgrps
,
1656 struct se_lun_acl
, ml_stat_grps
);
1657 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1658 struct se_dev_entry
*deve
;
1659 struct se_portal_group
*tpg
;
1662 spin_lock_irq(&nacl
->device_list_lock
);
1663 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1664 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1665 spin_unlock_irq(&nacl
->device_list_lock
);
1670 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", tpg
->se_tpg_tfo
->tpg_get_tag(tpg
));
1671 spin_unlock_irq(&nacl
->device_list_lock
);
1674 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port
);
1676 static ssize_t
target_stat_scsi_att_intr_port_show_attr_indx(
1677 struct se_ml_stat_grps
*lgrps
, char *page
)
1679 struct se_lun_acl
*lacl
= container_of(lgrps
,
1680 struct se_lun_acl
, ml_stat_grps
);
1681 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1682 struct se_session
*se_sess
;
1683 struct se_portal_group
*tpg
;
1686 spin_lock_irq(&nacl
->nacl_sess_lock
);
1687 se_sess
= nacl
->nacl_sess
;
1689 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1694 /* scsiAttIntrPortIndex */
1695 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1696 tpg
->se_tpg_tfo
->sess_get_index(se_sess
));
1697 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1700 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(indx
);
1702 static ssize_t
target_stat_scsi_att_intr_port_show_attr_port_auth_indx(
1703 struct se_ml_stat_grps
*lgrps
, char *page
)
1705 struct se_lun_acl
*lacl
= container_of(lgrps
,
1706 struct se_lun_acl
, ml_stat_grps
);
1707 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1708 struct se_dev_entry
*deve
;
1711 spin_lock_irq(&nacl
->device_list_lock
);
1712 deve
= nacl
->device_list
[lacl
->mapped_lun
];
1713 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1714 spin_unlock_irq(&nacl
->device_list_lock
);
1717 /* scsiAttIntrPortAuthIntrIdx */
1718 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", nacl
->acl_index
);
1719 spin_unlock_irq(&nacl
->device_list_lock
);
1722 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx
);
1724 static ssize_t
target_stat_scsi_att_intr_port_show_attr_port_ident(
1725 struct se_ml_stat_grps
*lgrps
, char *page
)
1727 struct se_lun_acl
*lacl
= container_of(lgrps
,
1728 struct se_lun_acl
, ml_stat_grps
);
1729 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1730 struct se_session
*se_sess
;
1731 struct se_portal_group
*tpg
;
1733 unsigned char buf
[64];
1735 spin_lock_irq(&nacl
->nacl_sess_lock
);
1736 se_sess
= nacl
->nacl_sess
;
1738 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1743 /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
1745 if (tpg
->se_tpg_tfo
->sess_get_initiator_sid
!= NULL
)
1746 tpg
->se_tpg_tfo
->sess_get_initiator_sid(se_sess
, buf
, 64);
1748 ret
= snprintf(page
, PAGE_SIZE
, "%s+i+%s\n", nacl
->initiatorname
, buf
);
1749 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1752 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_ident
);
1754 CONFIGFS_EATTR_OPS(target_stat_scsi_att_intr_port
, se_ml_stat_grps
,
1755 scsi_att_intr_port_group
);
1757 static struct configfs_attribute
*target_stat_scsi_ath_intr_port_attrs
[] = {
1758 &target_stat_scsi_att_intr_port_inst
.attr
,
1759 &target_stat_scsi_att_intr_port_dev
.attr
,
1760 &target_stat_scsi_att_intr_port_port
.attr
,
1761 &target_stat_scsi_att_intr_port_indx
.attr
,
1762 &target_stat_scsi_att_intr_port_port_auth_indx
.attr
,
1763 &target_stat_scsi_att_intr_port_port_ident
.attr
,
1767 static struct configfs_item_operations target_stat_scsi_att_intr_port_attrib_ops
= {
1768 .show_attribute
= target_stat_scsi_att_intr_port_attr_show
,
1769 .store_attribute
= target_stat_scsi_att_intr_port_attr_store
,
1772 static struct config_item_type target_stat_scsi_att_intr_port_cit
= {
1773 .ct_item_ops
= &target_stat_scsi_att_intr_port_attrib_ops
,
1774 .ct_attrs
= target_stat_scsi_ath_intr_port_attrs
,
1775 .ct_owner
= THIS_MODULE
,
1779 * Called from target_core_fabric_configfs.c:target_fabric_make_mappedlun() to setup
1780 * the target MappedLUN statistics groups + configfs CITs located in target_core_stat.c
1782 void target_stat_setup_mappedlun_default_groups(struct se_lun_acl
*lacl
)
1784 struct config_group
*ml_stat_grp
= &lacl
->ml_stat_grps
.stat_group
;
1786 config_group_init_type_name(&lacl
->ml_stat_grps
.scsi_auth_intr_group
,
1787 "scsi_auth_intr", &target_stat_scsi_auth_intr_cit
);
1788 config_group_init_type_name(&lacl
->ml_stat_grps
.scsi_att_intr_port_group
,
1789 "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit
);
1791 ml_stat_grp
->default_groups
[0] = &lacl
->ml_stat_grps
.scsi_auth_intr_group
;
1792 ml_stat_grp
->default_groups
[1] = &lacl
->ml_stat_grps
.scsi_att_intr_port_group
;
1793 ml_stat_grp
->default_groups
[2] = NULL
;