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