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
);
957 struct se_portal_group
*tpg
;
960 spin_lock(&lun
->lun_sep_lock
);
963 spin_unlock(&lun
->lun_sep_lock
);
968 ret
= snprintf(page
, PAGE_SIZE
, "%llu\n", sep
->sep_stats
.cmd_pdus
);
969 spin_unlock(&lun
->lun_sep_lock
);
972 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds
);
974 static ssize_t
target_stat_scsi_tgt_port_show_attr_write_mbytes(
975 struct se_port_stat_grps
*pgrps
, char *page
)
977 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
979 struct se_portal_group
*tpg
;
982 spin_lock(&lun
->lun_sep_lock
);
985 spin_unlock(&lun
->lun_sep_lock
);
990 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
991 (u32
)(sep
->sep_stats
.rx_data_octets
>> 20));
992 spin_unlock(&lun
->lun_sep_lock
);
995 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes
);
997 static ssize_t
target_stat_scsi_tgt_port_show_attr_read_mbytes(
998 struct se_port_stat_grps
*pgrps
, char *page
)
1000 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1001 struct se_port
*sep
;
1002 struct se_portal_group
*tpg
;
1005 spin_lock(&lun
->lun_sep_lock
);
1008 spin_unlock(&lun
->lun_sep_lock
);
1013 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1014 (u32
)(sep
->sep_stats
.tx_data_octets
>> 20));
1015 spin_unlock(&lun
->lun_sep_lock
);
1018 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes
);
1020 static ssize_t
target_stat_scsi_tgt_port_show_attr_hs_in_cmds(
1021 struct se_port_stat_grps
*pgrps
, char *page
)
1023 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1024 struct se_port
*sep
;
1025 struct se_portal_group
*tpg
;
1028 spin_lock(&lun
->lun_sep_lock
);
1031 spin_unlock(&lun
->lun_sep_lock
);
1036 /* FIXME: scsiTgtPortHsInCommands */
1037 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
1038 spin_unlock(&lun
->lun_sep_lock
);
1041 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds
);
1043 CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_port
, se_port_stat_grps
,
1044 scsi_tgt_port_group
);
1046 static struct configfs_attribute
*target_stat_scsi_tgt_port_attrs
[] = {
1047 &target_stat_scsi_tgt_port_inst
.attr
,
1048 &target_stat_scsi_tgt_port_dev
.attr
,
1049 &target_stat_scsi_tgt_port_indx
.attr
,
1050 &target_stat_scsi_tgt_port_name
.attr
,
1051 &target_stat_scsi_tgt_port_port_index
.attr
,
1052 &target_stat_scsi_tgt_port_in_cmds
.attr
,
1053 &target_stat_scsi_tgt_port_write_mbytes
.attr
,
1054 &target_stat_scsi_tgt_port_read_mbytes
.attr
,
1055 &target_stat_scsi_tgt_port_hs_in_cmds
.attr
,
1059 static struct configfs_item_operations target_stat_scsi_tgt_port_attrib_ops
= {
1060 .show_attribute
= target_stat_scsi_tgt_port_attr_show
,
1061 .store_attribute
= target_stat_scsi_tgt_port_attr_store
,
1064 static struct config_item_type target_stat_scsi_tgt_port_cit
= {
1065 .ct_item_ops
= &target_stat_scsi_tgt_port_attrib_ops
,
1066 .ct_attrs
= target_stat_scsi_tgt_port_attrs
,
1067 .ct_owner
= THIS_MODULE
,
1071 * SCSI Transport Table
1074 CONFIGFS_EATTR_STRUCT(target_stat_scsi_transport
, se_port_stat_grps
);
1075 #define DEV_STAT_SCSI_TRANSPORT_ATTR(_name, _mode) \
1076 static struct target_stat_scsi_transport_attribute \
1077 target_stat_scsi_transport_##_name = \
1078 __CONFIGFS_EATTR(_name, _mode, \
1079 target_stat_scsi_transport_show_attr_##_name, \
1080 target_stat_scsi_transport_store_attr_##_name);
1082 #define DEV_STAT_SCSI_TRANSPORT_ATTR_RO(_name) \
1083 static struct target_stat_scsi_transport_attribute \
1084 target_stat_scsi_transport_##_name = \
1085 __CONFIGFS_EATTR_RO(_name, \
1086 target_stat_scsi_transport_show_attr_##_name);
1088 static ssize_t
target_stat_scsi_transport_show_attr_inst(
1089 struct se_port_stat_grps
*pgrps
, char *page
)
1091 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1092 struct se_device
*dev
= lun
->lun_se_dev
;
1093 struct se_port
*sep
;
1097 spin_lock(&lun
->lun_sep_lock
);
1100 spin_unlock(&lun
->lun_sep_lock
);
1105 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", hba
->hba_index
);
1106 spin_unlock(&lun
->lun_sep_lock
);
1109 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst
);
1111 static ssize_t
target_stat_scsi_transport_show_attr_device(
1112 struct se_port_stat_grps
*pgrps
, char *page
)
1114 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1115 struct se_port
*sep
;
1116 struct se_portal_group
*tpg
;
1119 spin_lock(&lun
->lun_sep_lock
);
1122 spin_unlock(&lun
->lun_sep_lock
);
1126 /* scsiTransportType */
1127 ret
= snprintf(page
, PAGE_SIZE
, "scsiTransport%s\n",
1128 tpg
->se_tpg_tfo
->get_fabric_name());
1129 spin_unlock(&lun
->lun_sep_lock
);
1132 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device
);
1134 static ssize_t
target_stat_scsi_transport_show_attr_indx(
1135 struct se_port_stat_grps
*pgrps
, char *page
)
1137 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1138 struct se_port
*sep
;
1139 struct se_portal_group
*tpg
;
1142 spin_lock(&lun
->lun_sep_lock
);
1145 spin_unlock(&lun
->lun_sep_lock
);
1149 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1150 tpg
->se_tpg_tfo
->tpg_get_inst_index(tpg
));
1151 spin_unlock(&lun
->lun_sep_lock
);
1154 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx
);
1156 static ssize_t
target_stat_scsi_transport_show_attr_dev_name(
1157 struct se_port_stat_grps
*pgrps
, char *page
)
1159 struct se_lun
*lun
= container_of(pgrps
, struct se_lun
, port_stat_grps
);
1160 struct se_device
*dev
= lun
->lun_se_dev
;
1161 struct se_port
*sep
;
1162 struct se_portal_group
*tpg
;
1163 struct t10_wwn
*wwn
;
1166 spin_lock(&lun
->lun_sep_lock
);
1169 spin_unlock(&lun
->lun_sep_lock
);
1173 wwn
= &dev
->se_sub_dev
->t10_wwn
;
1174 /* scsiTransportDevName */
1175 ret
= snprintf(page
, PAGE_SIZE
, "%s+%s\n",
1176 tpg
->se_tpg_tfo
->tpg_get_wwn(tpg
),
1177 (strlen(wwn
->unit_serial
)) ? wwn
->unit_serial
:
1179 spin_unlock(&lun
->lun_sep_lock
);
1182 DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name
);
1184 CONFIGFS_EATTR_OPS(target_stat_scsi_transport
, se_port_stat_grps
,
1185 scsi_transport_group
);
1187 static struct configfs_attribute
*target_stat_scsi_transport_attrs
[] = {
1188 &target_stat_scsi_transport_inst
.attr
,
1189 &target_stat_scsi_transport_device
.attr
,
1190 &target_stat_scsi_transport_indx
.attr
,
1191 &target_stat_scsi_transport_dev_name
.attr
,
1195 static struct configfs_item_operations target_stat_scsi_transport_attrib_ops
= {
1196 .show_attribute
= target_stat_scsi_transport_attr_show
,
1197 .store_attribute
= target_stat_scsi_transport_attr_store
,
1200 static struct config_item_type target_stat_scsi_transport_cit
= {
1201 .ct_item_ops
= &target_stat_scsi_transport_attrib_ops
,
1202 .ct_attrs
= target_stat_scsi_transport_attrs
,
1203 .ct_owner
= THIS_MODULE
,
1207 * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup
1208 * the target port statistics groups + configfs CITs located in target_core_stat.c
1210 void target_stat_setup_port_default_groups(struct se_lun
*lun
)
1212 struct config_group
*port_stat_grp
= &lun
->port_stat_grps
.stat_group
;
1214 config_group_init_type_name(&lun
->port_stat_grps
.scsi_port_group
,
1215 "scsi_port", &target_stat_scsi_port_cit
);
1216 config_group_init_type_name(&lun
->port_stat_grps
.scsi_tgt_port_group
,
1217 "scsi_tgt_port", &target_stat_scsi_tgt_port_cit
);
1218 config_group_init_type_name(&lun
->port_stat_grps
.scsi_transport_group
,
1219 "scsi_transport", &target_stat_scsi_transport_cit
);
1221 port_stat_grp
->default_groups
[0] = &lun
->port_stat_grps
.scsi_port_group
;
1222 port_stat_grp
->default_groups
[1] = &lun
->port_stat_grps
.scsi_tgt_port_group
;
1223 port_stat_grp
->default_groups
[2] = &lun
->port_stat_grps
.scsi_transport_group
;
1224 port_stat_grp
->default_groups
[3] = NULL
;
1228 * SCSI Authorized Initiator Table
1231 CONFIGFS_EATTR_STRUCT(target_stat_scsi_auth_intr
, se_ml_stat_grps
);
1232 #define DEV_STAT_SCSI_AUTH_INTR_ATTR(_name, _mode) \
1233 static struct target_stat_scsi_auth_intr_attribute \
1234 target_stat_scsi_auth_intr_##_name = \
1235 __CONFIGFS_EATTR(_name, _mode, \
1236 target_stat_scsi_auth_intr_show_attr_##_name, \
1237 target_stat_scsi_auth_intr_store_attr_##_name);
1239 #define DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(_name) \
1240 static struct target_stat_scsi_auth_intr_attribute \
1241 target_stat_scsi_auth_intr_##_name = \
1242 __CONFIGFS_EATTR_RO(_name, \
1243 target_stat_scsi_auth_intr_show_attr_##_name);
1245 static ssize_t
target_stat_scsi_auth_intr_show_attr_inst(
1246 struct se_ml_stat_grps
*lgrps
, char *page
)
1248 struct se_lun_acl
*lacl
= container_of(lgrps
,
1249 struct se_lun_acl
, ml_stat_grps
);
1250 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1251 struct se_dev_entry
*deve
;
1252 struct se_portal_group
*tpg
;
1255 spin_lock_irq(&nacl
->device_list_lock
);
1256 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1257 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1258 spin_unlock_irq(&nacl
->device_list_lock
);
1263 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1264 tpg
->se_tpg_tfo
->tpg_get_inst_index(tpg
));
1265 spin_unlock_irq(&nacl
->device_list_lock
);
1268 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst
);
1270 static ssize_t
target_stat_scsi_auth_intr_show_attr_dev(
1271 struct se_ml_stat_grps
*lgrps
, char *page
)
1273 struct se_lun_acl
*lacl
= container_of(lgrps
,
1274 struct se_lun_acl
, ml_stat_grps
);
1275 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1276 struct se_dev_entry
*deve
;
1278 struct se_portal_group
*tpg
;
1281 spin_lock_irq(&nacl
->device_list_lock
);
1282 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1283 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1284 spin_unlock_irq(&nacl
->device_list_lock
);
1289 /* scsiDeviceIndex */
1290 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lun
->lun_se_dev
->dev_index
);
1291 spin_unlock_irq(&nacl
->device_list_lock
);
1294 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev
);
1296 static ssize_t
target_stat_scsi_auth_intr_show_attr_port(
1297 struct se_ml_stat_grps
*lgrps
, char *page
)
1299 struct se_lun_acl
*lacl
= container_of(lgrps
,
1300 struct se_lun_acl
, ml_stat_grps
);
1301 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1302 struct se_dev_entry
*deve
;
1303 struct se_portal_group
*tpg
;
1306 spin_lock_irq(&nacl
->device_list_lock
);
1307 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1308 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1309 spin_unlock_irq(&nacl
->device_list_lock
);
1313 /* scsiAuthIntrTgtPortIndex */
1314 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", tpg
->se_tpg_tfo
->tpg_get_tag(tpg
));
1315 spin_unlock_irq(&nacl
->device_list_lock
);
1318 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port
);
1320 static ssize_t
target_stat_scsi_auth_intr_show_attr_indx(
1321 struct se_ml_stat_grps
*lgrps
, char *page
)
1323 struct se_lun_acl
*lacl
= container_of(lgrps
,
1324 struct se_lun_acl
, ml_stat_grps
);
1325 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1326 struct se_dev_entry
*deve
;
1329 spin_lock_irq(&nacl
->device_list_lock
);
1330 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1331 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1332 spin_unlock_irq(&nacl
->device_list_lock
);
1335 /* scsiAuthIntrIndex */
1336 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", nacl
->acl_index
);
1337 spin_unlock_irq(&nacl
->device_list_lock
);
1340 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx
);
1342 static ssize_t
target_stat_scsi_auth_intr_show_attr_dev_or_port(
1343 struct se_ml_stat_grps
*lgrps
, char *page
)
1345 struct se_lun_acl
*lacl
= container_of(lgrps
,
1346 struct se_lun_acl
, ml_stat_grps
);
1347 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1348 struct se_dev_entry
*deve
;
1351 spin_lock_irq(&nacl
->device_list_lock
);
1352 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1353 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1354 spin_unlock_irq(&nacl
->device_list_lock
);
1357 /* scsiAuthIntrDevOrPort */
1358 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 1);
1359 spin_unlock_irq(&nacl
->device_list_lock
);
1362 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port
);
1364 static ssize_t
target_stat_scsi_auth_intr_show_attr_intr_name(
1365 struct se_ml_stat_grps
*lgrps
, char *page
)
1367 struct se_lun_acl
*lacl
= container_of(lgrps
,
1368 struct se_lun_acl
, ml_stat_grps
);
1369 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1370 struct se_dev_entry
*deve
;
1373 spin_lock_irq(&nacl
->device_list_lock
);
1374 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1375 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1376 spin_unlock_irq(&nacl
->device_list_lock
);
1379 /* scsiAuthIntrName */
1380 ret
= snprintf(page
, PAGE_SIZE
, "%s\n", nacl
->initiatorname
);
1381 spin_unlock_irq(&nacl
->device_list_lock
);
1384 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name
);
1386 static ssize_t
target_stat_scsi_auth_intr_show_attr_map_indx(
1387 struct se_ml_stat_grps
*lgrps
, char *page
)
1389 struct se_lun_acl
*lacl
= container_of(lgrps
,
1390 struct se_lun_acl
, ml_stat_grps
);
1391 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1392 struct se_dev_entry
*deve
;
1395 spin_lock_irq(&nacl
->device_list_lock
);
1396 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1397 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1398 spin_unlock_irq(&nacl
->device_list_lock
);
1401 /* FIXME: scsiAuthIntrLunMapIndex */
1402 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
1403 spin_unlock_irq(&nacl
->device_list_lock
);
1406 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx
);
1408 static ssize_t
target_stat_scsi_auth_intr_show_attr_att_count(
1409 struct se_ml_stat_grps
*lgrps
, char *page
)
1411 struct se_lun_acl
*lacl
= container_of(lgrps
,
1412 struct se_lun_acl
, ml_stat_grps
);
1413 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1414 struct se_dev_entry
*deve
;
1417 spin_lock_irq(&nacl
->device_list_lock
);
1418 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1419 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1420 spin_unlock_irq(&nacl
->device_list_lock
);
1423 /* scsiAuthIntrAttachedTimes */
1424 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", deve
->attach_count
);
1425 spin_unlock_irq(&nacl
->device_list_lock
);
1428 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count
);
1430 static ssize_t
target_stat_scsi_auth_intr_show_attr_num_cmds(
1431 struct se_ml_stat_grps
*lgrps
, char *page
)
1433 struct se_lun_acl
*lacl
= container_of(lgrps
,
1434 struct se_lun_acl
, ml_stat_grps
);
1435 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1436 struct se_dev_entry
*deve
;
1439 spin_lock_irq(&nacl
->device_list_lock
);
1440 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1441 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1442 spin_unlock_irq(&nacl
->device_list_lock
);
1445 /* scsiAuthIntrOutCommands */
1446 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", deve
->total_cmds
);
1447 spin_unlock_irq(&nacl
->device_list_lock
);
1450 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds
);
1452 static ssize_t
target_stat_scsi_auth_intr_show_attr_read_mbytes(
1453 struct se_ml_stat_grps
*lgrps
, char *page
)
1455 struct se_lun_acl
*lacl
= container_of(lgrps
,
1456 struct se_lun_acl
, ml_stat_grps
);
1457 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1458 struct se_dev_entry
*deve
;
1461 spin_lock_irq(&nacl
->device_list_lock
);
1462 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1463 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1464 spin_unlock_irq(&nacl
->device_list_lock
);
1467 /* scsiAuthIntrReadMegaBytes */
1468 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(deve
->read_bytes
>> 20));
1469 spin_unlock_irq(&nacl
->device_list_lock
);
1472 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes
);
1474 static ssize_t
target_stat_scsi_auth_intr_show_attr_write_mbytes(
1475 struct se_ml_stat_grps
*lgrps
, char *page
)
1477 struct se_lun_acl
*lacl
= container_of(lgrps
,
1478 struct se_lun_acl
, ml_stat_grps
);
1479 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1480 struct se_dev_entry
*deve
;
1483 spin_lock_irq(&nacl
->device_list_lock
);
1484 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1485 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1486 spin_unlock_irq(&nacl
->device_list_lock
);
1489 /* scsiAuthIntrWrittenMegaBytes */
1490 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(deve
->write_bytes
>> 20));
1491 spin_unlock_irq(&nacl
->device_list_lock
);
1494 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes
);
1496 static ssize_t
target_stat_scsi_auth_intr_show_attr_hs_num_cmds(
1497 struct se_ml_stat_grps
*lgrps
, char *page
)
1499 struct se_lun_acl
*lacl
= container_of(lgrps
,
1500 struct se_lun_acl
, ml_stat_grps
);
1501 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1502 struct se_dev_entry
*deve
;
1505 spin_lock_irq(&nacl
->device_list_lock
);
1506 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1507 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1508 spin_unlock_irq(&nacl
->device_list_lock
);
1511 /* FIXME: scsiAuthIntrHSOutCommands */
1512 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", 0);
1513 spin_unlock_irq(&nacl
->device_list_lock
);
1516 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds
);
1518 static ssize_t
target_stat_scsi_auth_intr_show_attr_creation_time(
1519 struct se_ml_stat_grps
*lgrps
, char *page
)
1521 struct se_lun_acl
*lacl
= container_of(lgrps
,
1522 struct se_lun_acl
, ml_stat_grps
);
1523 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1524 struct se_dev_entry
*deve
;
1527 spin_lock_irq(&nacl
->device_list_lock
);
1528 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1529 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1530 spin_unlock_irq(&nacl
->device_list_lock
);
1533 /* scsiAuthIntrLastCreation */
1534 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", (u32
)(((u32
)deve
->creation_time
-
1535 INITIAL_JIFFIES
) * 100 / HZ
));
1536 spin_unlock_irq(&nacl
->device_list_lock
);
1539 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time
);
1541 static ssize_t
target_stat_scsi_auth_intr_show_attr_row_status(
1542 struct se_ml_stat_grps
*lgrps
, char *page
)
1544 struct se_lun_acl
*lacl
= container_of(lgrps
,
1545 struct se_lun_acl
, ml_stat_grps
);
1546 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1547 struct se_dev_entry
*deve
;
1550 spin_lock_irq(&nacl
->device_list_lock
);
1551 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1552 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1553 spin_unlock_irq(&nacl
->device_list_lock
);
1556 /* FIXME: scsiAuthIntrRowStatus */
1557 ret
= snprintf(page
, PAGE_SIZE
, "Ready\n");
1558 spin_unlock_irq(&nacl
->device_list_lock
);
1561 DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status
);
1563 CONFIGFS_EATTR_OPS(target_stat_scsi_auth_intr
, se_ml_stat_grps
,
1564 scsi_auth_intr_group
);
1566 static struct configfs_attribute
*target_stat_scsi_auth_intr_attrs
[] = {
1567 &target_stat_scsi_auth_intr_inst
.attr
,
1568 &target_stat_scsi_auth_intr_dev
.attr
,
1569 &target_stat_scsi_auth_intr_port
.attr
,
1570 &target_stat_scsi_auth_intr_indx
.attr
,
1571 &target_stat_scsi_auth_intr_dev_or_port
.attr
,
1572 &target_stat_scsi_auth_intr_intr_name
.attr
,
1573 &target_stat_scsi_auth_intr_map_indx
.attr
,
1574 &target_stat_scsi_auth_intr_att_count
.attr
,
1575 &target_stat_scsi_auth_intr_num_cmds
.attr
,
1576 &target_stat_scsi_auth_intr_read_mbytes
.attr
,
1577 &target_stat_scsi_auth_intr_write_mbytes
.attr
,
1578 &target_stat_scsi_auth_intr_hs_num_cmds
.attr
,
1579 &target_stat_scsi_auth_intr_creation_time
.attr
,
1580 &target_stat_scsi_auth_intr_row_status
.attr
,
1584 static struct configfs_item_operations target_stat_scsi_auth_intr_attrib_ops
= {
1585 .show_attribute
= target_stat_scsi_auth_intr_attr_show
,
1586 .store_attribute
= target_stat_scsi_auth_intr_attr_store
,
1589 static struct config_item_type target_stat_scsi_auth_intr_cit
= {
1590 .ct_item_ops
= &target_stat_scsi_auth_intr_attrib_ops
,
1591 .ct_attrs
= target_stat_scsi_auth_intr_attrs
,
1592 .ct_owner
= THIS_MODULE
,
1596 * SCSI Attached Initiator Port Table
1599 CONFIGFS_EATTR_STRUCT(target_stat_scsi_att_intr_port
, se_ml_stat_grps
);
1600 #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR(_name, _mode) \
1601 static struct target_stat_scsi_att_intr_port_attribute \
1602 target_stat_scsi_att_intr_port_##_name = \
1603 __CONFIGFS_EATTR(_name, _mode, \
1604 target_stat_scsi_att_intr_port_show_attr_##_name, \
1605 target_stat_scsi_att_intr_port_store_attr_##_name);
1607 #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(_name) \
1608 static struct target_stat_scsi_att_intr_port_attribute \
1609 target_stat_scsi_att_intr_port_##_name = \
1610 __CONFIGFS_EATTR_RO(_name, \
1611 target_stat_scsi_att_intr_port_show_attr_##_name);
1613 static ssize_t
target_stat_scsi_att_intr_port_show_attr_inst(
1614 struct se_ml_stat_grps
*lgrps
, char *page
)
1616 struct se_lun_acl
*lacl
= container_of(lgrps
,
1617 struct se_lun_acl
, ml_stat_grps
);
1618 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1619 struct se_dev_entry
*deve
;
1620 struct se_portal_group
*tpg
;
1623 spin_lock_irq(&nacl
->device_list_lock
);
1624 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1625 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1626 spin_unlock_irq(&nacl
->device_list_lock
);
1631 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1632 tpg
->se_tpg_tfo
->tpg_get_inst_index(tpg
));
1633 spin_unlock_irq(&nacl
->device_list_lock
);
1636 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst
);
1638 static ssize_t
target_stat_scsi_att_intr_port_show_attr_dev(
1639 struct se_ml_stat_grps
*lgrps
, char *page
)
1641 struct se_lun_acl
*lacl
= container_of(lgrps
,
1642 struct se_lun_acl
, ml_stat_grps
);
1643 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1644 struct se_dev_entry
*deve
;
1646 struct se_portal_group
*tpg
;
1649 spin_lock_irq(&nacl
->device_list_lock
);
1650 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1651 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1652 spin_unlock_irq(&nacl
->device_list_lock
);
1657 /* scsiDeviceIndex */
1658 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lun
->lun_se_dev
->dev_index
);
1659 spin_unlock_irq(&nacl
->device_list_lock
);
1662 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev
);
1664 static ssize_t
target_stat_scsi_att_intr_port_show_attr_port(
1665 struct se_ml_stat_grps
*lgrps
, char *page
)
1667 struct se_lun_acl
*lacl
= container_of(lgrps
,
1668 struct se_lun_acl
, ml_stat_grps
);
1669 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1670 struct se_dev_entry
*deve
;
1671 struct se_portal_group
*tpg
;
1674 spin_lock_irq(&nacl
->device_list_lock
);
1675 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1676 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1677 spin_unlock_irq(&nacl
->device_list_lock
);
1682 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", tpg
->se_tpg_tfo
->tpg_get_tag(tpg
));
1683 spin_unlock_irq(&nacl
->device_list_lock
);
1686 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port
);
1688 static ssize_t
target_stat_scsi_att_intr_port_show_attr_indx(
1689 struct se_ml_stat_grps
*lgrps
, char *page
)
1691 struct se_lun_acl
*lacl
= container_of(lgrps
,
1692 struct se_lun_acl
, ml_stat_grps
);
1693 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1694 struct se_session
*se_sess
;
1695 struct se_portal_group
*tpg
;
1698 spin_lock_irq(&nacl
->nacl_sess_lock
);
1699 se_sess
= nacl
->nacl_sess
;
1701 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1706 /* scsiAttIntrPortIndex */
1707 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
1708 tpg
->se_tpg_tfo
->sess_get_index(se_sess
));
1709 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1712 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(indx
);
1714 static ssize_t
target_stat_scsi_att_intr_port_show_attr_port_auth_indx(
1715 struct se_ml_stat_grps
*lgrps
, char *page
)
1717 struct se_lun_acl
*lacl
= container_of(lgrps
,
1718 struct se_lun_acl
, ml_stat_grps
);
1719 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1720 struct se_dev_entry
*deve
;
1723 spin_lock_irq(&nacl
->device_list_lock
);
1724 deve
= &nacl
->device_list
[lacl
->mapped_lun
];
1725 if (!deve
->se_lun
|| !deve
->se_lun_acl
) {
1726 spin_unlock_irq(&nacl
->device_list_lock
);
1729 /* scsiAttIntrPortAuthIntrIdx */
1730 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", nacl
->acl_index
);
1731 spin_unlock_irq(&nacl
->device_list_lock
);
1734 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx
);
1736 static ssize_t
target_stat_scsi_att_intr_port_show_attr_port_ident(
1737 struct se_ml_stat_grps
*lgrps
, char *page
)
1739 struct se_lun_acl
*lacl
= container_of(lgrps
,
1740 struct se_lun_acl
, ml_stat_grps
);
1741 struct se_node_acl
*nacl
= lacl
->se_lun_nacl
;
1742 struct se_session
*se_sess
;
1743 struct se_portal_group
*tpg
;
1745 unsigned char buf
[64];
1747 spin_lock_irq(&nacl
->nacl_sess_lock
);
1748 se_sess
= nacl
->nacl_sess
;
1750 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1755 /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
1757 if (tpg
->se_tpg_tfo
->sess_get_initiator_sid
!= NULL
)
1758 tpg
->se_tpg_tfo
->sess_get_initiator_sid(se_sess
, buf
, 64);
1760 ret
= snprintf(page
, PAGE_SIZE
, "%s+i+%s\n", nacl
->initiatorname
, buf
);
1761 spin_unlock_irq(&nacl
->nacl_sess_lock
);
1764 DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_ident
);
1766 CONFIGFS_EATTR_OPS(target_stat_scsi_att_intr_port
, se_ml_stat_grps
,
1767 scsi_att_intr_port_group
);
1769 static struct configfs_attribute
*target_stat_scsi_ath_intr_port_attrs
[] = {
1770 &target_stat_scsi_att_intr_port_inst
.attr
,
1771 &target_stat_scsi_att_intr_port_dev
.attr
,
1772 &target_stat_scsi_att_intr_port_port
.attr
,
1773 &target_stat_scsi_att_intr_port_indx
.attr
,
1774 &target_stat_scsi_att_intr_port_port_auth_indx
.attr
,
1775 &target_stat_scsi_att_intr_port_port_ident
.attr
,
1779 static struct configfs_item_operations target_stat_scsi_att_intr_port_attrib_ops
= {
1780 .show_attribute
= target_stat_scsi_att_intr_port_attr_show
,
1781 .store_attribute
= target_stat_scsi_att_intr_port_attr_store
,
1784 static struct config_item_type target_stat_scsi_att_intr_port_cit
= {
1785 .ct_item_ops
= &target_stat_scsi_att_intr_port_attrib_ops
,
1786 .ct_attrs
= target_stat_scsi_ath_intr_port_attrs
,
1787 .ct_owner
= THIS_MODULE
,
1791 * Called from target_core_fabric_configfs.c:target_fabric_make_mappedlun() to setup
1792 * the target MappedLUN statistics groups + configfs CITs located in target_core_stat.c
1794 void target_stat_setup_mappedlun_default_groups(struct se_lun_acl
*lacl
)
1796 struct config_group
*ml_stat_grp
= &lacl
->ml_stat_grps
.stat_group
;
1798 config_group_init_type_name(&lacl
->ml_stat_grps
.scsi_auth_intr_group
,
1799 "scsi_auth_intr", &target_stat_scsi_auth_intr_cit
);
1800 config_group_init_type_name(&lacl
->ml_stat_grps
.scsi_att_intr_port_group
,
1801 "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit
);
1803 ml_stat_grp
->default_groups
[0] = &lacl
->ml_stat_grps
.scsi_auth_intr_group
;
1804 ml_stat_grp
->default_groups
[1] = &lacl
->ml_stat_grps
.scsi_att_intr_port_group
;
1805 ml_stat_grp
->default_groups
[2] = NULL
;