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