]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
12d23384 NB |
2 | /******************************************************************************* |
3 | * Filename: target_core_stat.c | |
4 | * | |
12d23384 NB |
5 | * Modern ConfigFS group context specific statistics based on original |
6 | * target_core_mib.c code | |
7 | * | |
4c76251e | 8 | * (c) Copyright 2006-2013 Datera, Inc. |
12d23384 NB |
9 | * |
10 | * Nicholas A. Bellinger <[email protected]> | |
11 | * | |
12d23384 NB |
12 | ******************************************************************************/ |
13 | ||
14 | #include <linux/kernel.h> | |
15 | #include <linux/module.h> | |
16 | #include <linux/delay.h> | |
17 | #include <linux/timer.h> | |
18 | #include <linux/string.h> | |
12d23384 NB |
19 | #include <linux/utsname.h> |
20 | #include <linux/proc_fs.h> | |
21 | #include <linux/seq_file.h> | |
12d23384 | 22 | #include <linux/configfs.h> |
12d23384 NB |
23 | |
24 | #include <target/target_core_base.h> | |
c4795fb2 CH |
25 | #include <target/target_core_backend.h> |
26 | #include <target/target_core_fabric.h> | |
12d23384 | 27 | |
e26d99ae | 28 | #include "target_core_internal.h" |
12d23384 NB |
29 | |
30 | #ifndef INITIAL_JIFFIES | |
31 | #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ)) | |
32 | #endif | |
33 | ||
12d23384 NB |
34 | #define SCSI_LU_INDEX 1 |
35 | #define LU_COUNT 1 | |
36 | ||
37 | /* | |
38 | * SCSI Device Table | |
39 | */ | |
40 | ||
2eafd729 CH |
41 | static struct se_device *to_stat_dev(struct config_item *item) |
42 | { | |
43 | struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), | |
44 | struct se_dev_stat_grps, scsi_dev_group); | |
45 | return container_of(sgrps, struct se_device, dev_stat_grps); | |
46 | } | |
12d23384 | 47 | |
2eafd729 | 48 | static ssize_t target_stat_inst_show(struct config_item *item, char *page) |
12d23384 | 49 | { |
2eafd729 | 50 | struct se_hba *hba = to_stat_dev(item)->se_hba; |
12d23384 NB |
51 | |
52 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | |
53 | } | |
12d23384 | 54 | |
2eafd729 | 55 | static ssize_t target_stat_indx_show(struct config_item *item, char *page) |
12d23384 | 56 | { |
2eafd729 | 57 | return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->dev_index); |
12d23384 | 58 | } |
12d23384 | 59 | |
2eafd729 | 60 | static ssize_t target_stat_role_show(struct config_item *item, char *page) |
12d23384 | 61 | { |
12d23384 NB |
62 | return snprintf(page, PAGE_SIZE, "Target\n"); |
63 | } | |
12d23384 | 64 | |
2eafd729 | 65 | static ssize_t target_stat_ports_show(struct config_item *item, char *page) |
12d23384 | 66 | { |
2eafd729 | 67 | return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->export_count); |
12d23384 | 68 | } |
12d23384 | 69 | |
2eafd729 CH |
70 | CONFIGFS_ATTR_RO(target_stat_, inst); |
71 | CONFIGFS_ATTR_RO(target_stat_, indx); | |
72 | CONFIGFS_ATTR_RO(target_stat_, role); | |
73 | CONFIGFS_ATTR_RO(target_stat_, ports); | |
12d23384 NB |
74 | |
75 | static struct configfs_attribute *target_stat_scsi_dev_attrs[] = { | |
2eafd729 CH |
76 | &target_stat_attr_inst, |
77 | &target_stat_attr_indx, | |
78 | &target_stat_attr_role, | |
79 | &target_stat_attr_ports, | |
12d23384 NB |
80 | NULL, |
81 | }; | |
82 | ||
ece550b5 | 83 | static const struct config_item_type target_stat_scsi_dev_cit = { |
12d23384 NB |
84 | .ct_attrs = target_stat_scsi_dev_attrs, |
85 | .ct_owner = THIS_MODULE, | |
86 | }; | |
87 | ||
88 | /* | |
89 | * SCSI Target Device Table | |
90 | */ | |
2eafd729 CH |
91 | static struct se_device *to_stat_tgt_dev(struct config_item *item) |
92 | { | |
93 | struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), | |
94 | struct se_dev_stat_grps, scsi_tgt_dev_group); | |
95 | return container_of(sgrps, struct se_device, dev_stat_grps); | |
96 | } | |
12d23384 | 97 | |
2eafd729 | 98 | static ssize_t target_stat_tgt_inst_show(struct config_item *item, char *page) |
12d23384 | 99 | { |
2eafd729 | 100 | struct se_hba *hba = to_stat_tgt_dev(item)->se_hba; |
12d23384 NB |
101 | |
102 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | |
103 | } | |
12d23384 | 104 | |
2eafd729 | 105 | static ssize_t target_stat_tgt_indx_show(struct config_item *item, char *page) |
12d23384 | 106 | { |
2eafd729 | 107 | return snprintf(page, PAGE_SIZE, "%u\n", to_stat_tgt_dev(item)->dev_index); |
12d23384 | 108 | } |
12d23384 | 109 | |
2eafd729 CH |
110 | static ssize_t target_stat_tgt_num_lus_show(struct config_item *item, |
111 | char *page) | |
12d23384 | 112 | { |
12d23384 NB |
113 | return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT); |
114 | } | |
12d23384 | 115 | |
2eafd729 CH |
116 | static ssize_t target_stat_tgt_status_show(struct config_item *item, |
117 | char *page) | |
12d23384 | 118 | { |
2eafd729 | 119 | if (to_stat_tgt_dev(item)->export_count) |
c9d27829 | 120 | return snprintf(page, PAGE_SIZE, "activated\n"); |
0fd97ccf | 121 | else |
c9d27829 | 122 | return snprintf(page, PAGE_SIZE, "deactivated\n"); |
12d23384 | 123 | } |
12d23384 | 124 | |
2eafd729 CH |
125 | static ssize_t target_stat_tgt_non_access_lus_show(struct config_item *item, |
126 | char *page) | |
12d23384 | 127 | { |
12d23384 NB |
128 | int non_accessible_lus; |
129 | ||
2eafd729 | 130 | if (to_stat_tgt_dev(item)->export_count) |
12d23384 | 131 | non_accessible_lus = 0; |
0fd97ccf | 132 | else |
12d23384 | 133 | non_accessible_lus = 1; |
12d23384 NB |
134 | |
135 | return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus); | |
136 | } | |
12d23384 | 137 | |
2eafd729 CH |
138 | static ssize_t target_stat_tgt_resets_show(struct config_item *item, |
139 | char *page) | |
12d23384 | 140 | { |
ee480683 | 141 | return snprintf(page, PAGE_SIZE, "%lu\n", |
2eafd729 | 142 | atomic_long_read(&to_stat_tgt_dev(item)->num_resets)); |
12d23384 | 143 | } |
12d23384 | 144 | |
c87ba9c4 NB |
145 | static ssize_t target_stat_tgt_aborts_complete_show(struct config_item *item, |
146 | char *page) | |
147 | { | |
148 | return snprintf(page, PAGE_SIZE, "%lu\n", | |
149 | atomic_long_read(&to_stat_tgt_dev(item)->aborts_complete)); | |
150 | } | |
151 | ||
152 | static ssize_t target_stat_tgt_aborts_no_task_show(struct config_item *item, | |
153 | char *page) | |
154 | { | |
155 | return snprintf(page, PAGE_SIZE, "%lu\n", | |
156 | atomic_long_read(&to_stat_tgt_dev(item)->aborts_no_task)); | |
157 | } | |
158 | ||
2eafd729 CH |
159 | CONFIGFS_ATTR_RO(target_stat_tgt_, inst); |
160 | CONFIGFS_ATTR_RO(target_stat_tgt_, indx); | |
161 | CONFIGFS_ATTR_RO(target_stat_tgt_, num_lus); | |
162 | CONFIGFS_ATTR_RO(target_stat_tgt_, status); | |
163 | CONFIGFS_ATTR_RO(target_stat_tgt_, non_access_lus); | |
164 | CONFIGFS_ATTR_RO(target_stat_tgt_, resets); | |
c87ba9c4 NB |
165 | CONFIGFS_ATTR_RO(target_stat_tgt_, aborts_complete); |
166 | CONFIGFS_ATTR_RO(target_stat_tgt_, aborts_no_task); | |
12d23384 NB |
167 | |
168 | static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = { | |
2eafd729 CH |
169 | &target_stat_tgt_attr_inst, |
170 | &target_stat_tgt_attr_indx, | |
171 | &target_stat_tgt_attr_num_lus, | |
172 | &target_stat_tgt_attr_status, | |
173 | &target_stat_tgt_attr_non_access_lus, | |
174 | &target_stat_tgt_attr_resets, | |
c87ba9c4 NB |
175 | &target_stat_tgt_attr_aborts_complete, |
176 | &target_stat_tgt_attr_aborts_no_task, | |
12d23384 NB |
177 | NULL, |
178 | }; | |
179 | ||
ece550b5 | 180 | static const struct config_item_type target_stat_scsi_tgt_dev_cit = { |
12d23384 NB |
181 | .ct_attrs = target_stat_scsi_tgt_dev_attrs, |
182 | .ct_owner = THIS_MODULE, | |
183 | }; | |
184 | ||
185 | /* | |
186 | * SCSI Logical Unit Table | |
187 | */ | |
188 | ||
2eafd729 CH |
189 | static struct se_device *to_stat_lu_dev(struct config_item *item) |
190 | { | |
191 | struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), | |
192 | struct se_dev_stat_grps, scsi_lu_group); | |
193 | return container_of(sgrps, struct se_device, dev_stat_grps); | |
194 | } | |
12d23384 | 195 | |
2eafd729 | 196 | static ssize_t target_stat_lu_inst_show(struct config_item *item, char *page) |
12d23384 | 197 | { |
2eafd729 | 198 | struct se_hba *hba = to_stat_lu_dev(item)->se_hba; |
12d23384 NB |
199 | |
200 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | |
201 | } | |
12d23384 | 202 | |
2eafd729 | 203 | static ssize_t target_stat_lu_dev_show(struct config_item *item, char *page) |
12d23384 | 204 | { |
2eafd729 CH |
205 | return snprintf(page, PAGE_SIZE, "%u\n", |
206 | to_stat_lu_dev(item)->dev_index); | |
12d23384 | 207 | } |
12d23384 | 208 | |
2eafd729 | 209 | static ssize_t target_stat_lu_indx_show(struct config_item *item, char *page) |
12d23384 | 210 | { |
12d23384 NB |
211 | return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX); |
212 | } | |
12d23384 | 213 | |
2eafd729 | 214 | static ssize_t target_stat_lu_lun_show(struct config_item *item, char *page) |
12d23384 | 215 | { |
12d23384 NB |
216 | /* FIXME: scsiLuDefaultLun */ |
217 | return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0); | |
218 | } | |
12d23384 | 219 | |
2eafd729 | 220 | static ssize_t target_stat_lu_lu_name_show(struct config_item *item, char *page) |
12d23384 | 221 | { |
2eafd729 | 222 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 | 223 | |
12d23384 NB |
224 | /* scsiLuWwnName */ |
225 | return snprintf(page, PAGE_SIZE, "%s\n", | |
0fd97ccf CH |
226 | (strlen(dev->t10_wwn.unit_serial)) ? |
227 | dev->t10_wwn.unit_serial : "None"); | |
12d23384 | 228 | } |
12d23384 | 229 | |
2eafd729 | 230 | static ssize_t target_stat_lu_vend_show(struct config_item *item, char *page) |
12d23384 | 231 | { |
2eafd729 | 232 | struct se_device *dev = to_stat_lu_dev(item); |
b2da4abf DD |
233 | |
234 | return snprintf(page, PAGE_SIZE, "%-" __stringify(INQUIRY_VENDOR_LEN) | |
235 | "s\n", dev->t10_wwn.vendor); | |
12d23384 | 236 | } |
12d23384 | 237 | |
2eafd729 | 238 | static ssize_t target_stat_lu_prod_show(struct config_item *item, char *page) |
12d23384 | 239 | { |
2eafd729 | 240 | struct se_device *dev = to_stat_lu_dev(item); |
b2da4abf DD |
241 | |
242 | return snprintf(page, PAGE_SIZE, "%-" __stringify(INQUIRY_MODEL_LEN) | |
243 | "s\n", dev->t10_wwn.model); | |
12d23384 | 244 | } |
12d23384 | 245 | |
2eafd729 | 246 | static ssize_t target_stat_lu_rev_show(struct config_item *item, char *page) |
12d23384 | 247 | { |
2eafd729 | 248 | struct se_device *dev = to_stat_lu_dev(item); |
b2da4abf DD |
249 | |
250 | return snprintf(page, PAGE_SIZE, "%-" __stringify(INQUIRY_REVISION_LEN) | |
251 | "s\n", dev->t10_wwn.revision); | |
12d23384 | 252 | } |
12d23384 | 253 | |
2eafd729 | 254 | static ssize_t target_stat_lu_dev_type_show(struct config_item *item, char *page) |
12d23384 | 255 | { |
2eafd729 | 256 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
257 | |
258 | /* scsiLuPeripheralType */ | |
259 | return snprintf(page, PAGE_SIZE, "%u\n", | |
e3d6f909 | 260 | dev->transport->get_device_type(dev)); |
12d23384 | 261 | } |
12d23384 | 262 | |
2eafd729 | 263 | static ssize_t target_stat_lu_status_show(struct config_item *item, char *page) |
12d23384 | 264 | { |
2eafd729 | 265 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
266 | |
267 | /* scsiLuStatus */ | |
268 | return snprintf(page, PAGE_SIZE, "%s\n", | |
0fd97ccf | 269 | (dev->export_count) ? "available" : "notavailable"); |
12d23384 | 270 | } |
12d23384 | 271 | |
2eafd729 CH |
272 | static ssize_t target_stat_lu_state_bit_show(struct config_item *item, |
273 | char *page) | |
12d23384 | 274 | { |
12d23384 NB |
275 | /* scsiLuState */ |
276 | return snprintf(page, PAGE_SIZE, "exposed\n"); | |
277 | } | |
12d23384 | 278 | |
2eafd729 CH |
279 | static ssize_t target_stat_lu_num_cmds_show(struct config_item *item, |
280 | char *page) | |
12d23384 | 281 | { |
2eafd729 | 282 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
283 | |
284 | /* scsiLuNumCommands */ | |
ee480683 NB |
285 | return snprintf(page, PAGE_SIZE, "%lu\n", |
286 | atomic_long_read(&dev->num_cmds)); | |
12d23384 | 287 | } |
12d23384 | 288 | |
2eafd729 CH |
289 | static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item, |
290 | char *page) | |
12d23384 | 291 | { |
2eafd729 | 292 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
293 | |
294 | /* scsiLuReadMegaBytes */ | |
ee480683 NB |
295 | return snprintf(page, PAGE_SIZE, "%lu\n", |
296 | atomic_long_read(&dev->read_bytes) >> 20); | |
12d23384 | 297 | } |
12d23384 | 298 | |
2eafd729 CH |
299 | static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item, |
300 | char *page) | |
12d23384 | 301 | { |
2eafd729 | 302 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
303 | |
304 | /* scsiLuWrittenMegaBytes */ | |
ee480683 NB |
305 | return snprintf(page, PAGE_SIZE, "%lu\n", |
306 | atomic_long_read(&dev->write_bytes) >> 20); | |
12d23384 | 307 | } |
12d23384 | 308 | |
2eafd729 | 309 | static ssize_t target_stat_lu_resets_show(struct config_item *item, char *page) |
12d23384 | 310 | { |
2eafd729 | 311 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
312 | |
313 | /* scsiLuInResets */ | |
2eafd729 CH |
314 | return snprintf(page, PAGE_SIZE, "%lu\n", |
315 | atomic_long_read(&dev->num_resets)); | |
12d23384 | 316 | } |
12d23384 | 317 | |
2eafd729 CH |
318 | static ssize_t target_stat_lu_full_stat_show(struct config_item *item, |
319 | char *page) | |
12d23384 | 320 | { |
12d23384 NB |
321 | /* FIXME: scsiLuOutTaskSetFullStatus */ |
322 | return snprintf(page, PAGE_SIZE, "%u\n", 0); | |
323 | } | |
12d23384 | 324 | |
2eafd729 CH |
325 | static ssize_t target_stat_lu_hs_num_cmds_show(struct config_item *item, |
326 | char *page) | |
12d23384 | 327 | { |
12d23384 NB |
328 | /* FIXME: scsiLuHSInCommands */ |
329 | return snprintf(page, PAGE_SIZE, "%u\n", 0); | |
330 | } | |
12d23384 | 331 | |
2eafd729 CH |
332 | static ssize_t target_stat_lu_creation_time_show(struct config_item *item, |
333 | char *page) | |
12d23384 | 334 | { |
2eafd729 | 335 | struct se_device *dev = to_stat_lu_dev(item); |
12d23384 NB |
336 | |
337 | /* scsiLuCreationTime */ | |
338 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time - | |
339 | INITIAL_JIFFIES) * 100 / HZ)); | |
340 | } | |
12d23384 | 341 | |
2eafd729 CH |
342 | CONFIGFS_ATTR_RO(target_stat_lu_, inst); |
343 | CONFIGFS_ATTR_RO(target_stat_lu_, dev); | |
344 | CONFIGFS_ATTR_RO(target_stat_lu_, indx); | |
345 | CONFIGFS_ATTR_RO(target_stat_lu_, lun); | |
346 | CONFIGFS_ATTR_RO(target_stat_lu_, lu_name); | |
347 | CONFIGFS_ATTR_RO(target_stat_lu_, vend); | |
348 | CONFIGFS_ATTR_RO(target_stat_lu_, prod); | |
349 | CONFIGFS_ATTR_RO(target_stat_lu_, rev); | |
350 | CONFIGFS_ATTR_RO(target_stat_lu_, dev_type); | |
351 | CONFIGFS_ATTR_RO(target_stat_lu_, status); | |
352 | CONFIGFS_ATTR_RO(target_stat_lu_, state_bit); | |
353 | CONFIGFS_ATTR_RO(target_stat_lu_, num_cmds); | |
354 | CONFIGFS_ATTR_RO(target_stat_lu_, read_mbytes); | |
355 | CONFIGFS_ATTR_RO(target_stat_lu_, write_mbytes); | |
356 | CONFIGFS_ATTR_RO(target_stat_lu_, resets); | |
357 | CONFIGFS_ATTR_RO(target_stat_lu_, full_stat); | |
358 | CONFIGFS_ATTR_RO(target_stat_lu_, hs_num_cmds); | |
359 | CONFIGFS_ATTR_RO(target_stat_lu_, creation_time); | |
12d23384 NB |
360 | |
361 | static struct configfs_attribute *target_stat_scsi_lu_attrs[] = { | |
2eafd729 CH |
362 | &target_stat_lu_attr_inst, |
363 | &target_stat_lu_attr_dev, | |
364 | &target_stat_lu_attr_indx, | |
365 | &target_stat_lu_attr_lun, | |
366 | &target_stat_lu_attr_lu_name, | |
367 | &target_stat_lu_attr_vend, | |
368 | &target_stat_lu_attr_prod, | |
369 | &target_stat_lu_attr_rev, | |
370 | &target_stat_lu_attr_dev_type, | |
371 | &target_stat_lu_attr_status, | |
372 | &target_stat_lu_attr_state_bit, | |
373 | &target_stat_lu_attr_num_cmds, | |
374 | &target_stat_lu_attr_read_mbytes, | |
375 | &target_stat_lu_attr_write_mbytes, | |
376 | &target_stat_lu_attr_resets, | |
377 | &target_stat_lu_attr_full_stat, | |
378 | &target_stat_lu_attr_hs_num_cmds, | |
379 | &target_stat_lu_attr_creation_time, | |
12d23384 NB |
380 | NULL, |
381 | }; | |
382 | ||
ece550b5 | 383 | static const struct config_item_type target_stat_scsi_lu_cit = { |
12d23384 NB |
384 | .ct_attrs = target_stat_scsi_lu_attrs, |
385 | .ct_owner = THIS_MODULE, | |
386 | }; | |
387 | ||
388 | /* | |
389 | * Called from target_core_configfs.c:target_core_make_subdev() to setup | |
390 | * the target statistics groups + configfs CITs located in target_core_stat.c | |
391 | */ | |
0fd97ccf | 392 | void target_stat_setup_dev_default_groups(struct se_device *dev) |
12d23384 | 393 | { |
0fd97ccf | 394 | config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group, |
12d23384 | 395 | "scsi_dev", &target_stat_scsi_dev_cit); |
1ae1602d CH |
396 | configfs_add_default_group(&dev->dev_stat_grps.scsi_dev_group, |
397 | &dev->dev_stat_grps.stat_group); | |
398 | ||
0fd97ccf | 399 | config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group, |
12d23384 | 400 | "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); |
1ae1602d CH |
401 | configfs_add_default_group(&dev->dev_stat_grps.scsi_tgt_dev_group, |
402 | &dev->dev_stat_grps.stat_group); | |
403 | ||
0fd97ccf | 404 | config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group, |
12d23384 | 405 | "scsi_lu", &target_stat_scsi_lu_cit); |
1ae1602d CH |
406 | configfs_add_default_group(&dev->dev_stat_grps.scsi_lu_group, |
407 | &dev->dev_stat_grps.stat_group); | |
12d23384 NB |
408 | } |
409 | ||
410 | /* | |
411 | * SCSI Port Table | |
412 | */ | |
413 | ||
2eafd729 CH |
414 | static struct se_lun *to_stat_port(struct config_item *item) |
415 | { | |
416 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), | |
417 | struct se_port_stat_grps, scsi_port_group); | |
418 | return container_of(pgrps, struct se_lun, port_stat_grps); | |
419 | } | |
12d23384 | 420 | |
2eafd729 | 421 | static ssize_t target_stat_port_inst_show(struct config_item *item, char *page) |
12d23384 | 422 | { |
2eafd729 | 423 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
424 | struct se_device *dev; |
425 | ssize_t ret = -ENODEV; | |
12d23384 | 426 | |
4cc987ea NB |
427 | rcu_read_lock(); |
428 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 429 | if (dev) |
4cc987ea NB |
430 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index); |
431 | rcu_read_unlock(); | |
12d23384 NB |
432 | return ret; |
433 | } | |
12d23384 | 434 | |
2eafd729 | 435 | static ssize_t target_stat_port_dev_show(struct config_item *item, char *page) |
12d23384 | 436 | { |
2eafd729 | 437 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
438 | struct se_device *dev; |
439 | ssize_t ret = -ENODEV; | |
12d23384 | 440 | |
4cc987ea NB |
441 | rcu_read_lock(); |
442 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
443 | if (dev) |
444 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | |
4cc987ea | 445 | rcu_read_unlock(); |
12d23384 NB |
446 | return ret; |
447 | } | |
12d23384 | 448 | |
2eafd729 | 449 | static ssize_t target_stat_port_indx_show(struct config_item *item, char *page) |
12d23384 | 450 | { |
2eafd729 | 451 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
452 | struct se_device *dev; |
453 | ssize_t ret = -ENODEV; | |
12d23384 | 454 | |
4cc987ea NB |
455 | rcu_read_lock(); |
456 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 457 | if (dev) |
b9e063ad | 458 | ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_tpg->tpg_rtpi); |
4cc987ea | 459 | rcu_read_unlock(); |
12d23384 NB |
460 | return ret; |
461 | } | |
12d23384 | 462 | |
2eafd729 | 463 | static ssize_t target_stat_port_role_show(struct config_item *item, char *page) |
12d23384 | 464 | { |
2eafd729 | 465 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
466 | struct se_device *dev; |
467 | ssize_t ret = -ENODEV; | |
12d23384 | 468 | |
4cc987ea NB |
469 | rcu_read_lock(); |
470 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
471 | if (dev) |
472 | ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index); | |
4cc987ea | 473 | rcu_read_unlock(); |
12d23384 NB |
474 | return ret; |
475 | } | |
12d23384 | 476 | |
2eafd729 CH |
477 | static ssize_t target_stat_port_busy_count_show(struct config_item *item, |
478 | char *page) | |
12d23384 | 479 | { |
2eafd729 | 480 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
481 | struct se_device *dev; |
482 | ssize_t ret = -ENODEV; | |
12d23384 | 483 | |
4cc987ea NB |
484 | rcu_read_lock(); |
485 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
486 | if (dev) { |
487 | /* FIXME: scsiPortBusyStatuses */ | |
488 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
12d23384 | 489 | } |
4cc987ea | 490 | rcu_read_unlock(); |
12d23384 NB |
491 | return ret; |
492 | } | |
12d23384 | 493 | |
2eafd729 CH |
494 | CONFIGFS_ATTR_RO(target_stat_port_, inst); |
495 | CONFIGFS_ATTR_RO(target_stat_port_, dev); | |
496 | CONFIGFS_ATTR_RO(target_stat_port_, indx); | |
497 | CONFIGFS_ATTR_RO(target_stat_port_, role); | |
498 | CONFIGFS_ATTR_RO(target_stat_port_, busy_count); | |
12d23384 NB |
499 | |
500 | static struct configfs_attribute *target_stat_scsi_port_attrs[] = { | |
2eafd729 CH |
501 | &target_stat_port_attr_inst, |
502 | &target_stat_port_attr_dev, | |
503 | &target_stat_port_attr_indx, | |
504 | &target_stat_port_attr_role, | |
505 | &target_stat_port_attr_busy_count, | |
12d23384 NB |
506 | NULL, |
507 | }; | |
508 | ||
ece550b5 | 509 | static const struct config_item_type target_stat_scsi_port_cit = { |
12d23384 NB |
510 | .ct_attrs = target_stat_scsi_port_attrs, |
511 | .ct_owner = THIS_MODULE, | |
512 | }; | |
513 | ||
514 | /* | |
515 | * SCSI Target Port Table | |
516 | */ | |
2eafd729 CH |
517 | static struct se_lun *to_stat_tgt_port(struct config_item *item) |
518 | { | |
519 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), | |
520 | struct se_port_stat_grps, scsi_tgt_port_group); | |
521 | return container_of(pgrps, struct se_lun, port_stat_grps); | |
522 | } | |
523 | ||
524 | static ssize_t target_stat_tgt_port_inst_show(struct config_item *item, | |
525 | char *page) | |
526 | { | |
527 | struct se_lun *lun = to_stat_tgt_port(item); | |
adf653f9 CH |
528 | struct se_device *dev; |
529 | ssize_t ret = -ENODEV; | |
12d23384 | 530 | |
4cc987ea NB |
531 | rcu_read_lock(); |
532 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 533 | if (dev) |
4cc987ea NB |
534 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index); |
535 | rcu_read_unlock(); | |
12d23384 NB |
536 | return ret; |
537 | } | |
12d23384 | 538 | |
2eafd729 CH |
539 | static ssize_t target_stat_tgt_port_dev_show(struct config_item *item, |
540 | char *page) | |
12d23384 | 541 | { |
2eafd729 | 542 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
543 | struct se_device *dev; |
544 | ssize_t ret = -ENODEV; | |
12d23384 | 545 | |
4cc987ea NB |
546 | rcu_read_lock(); |
547 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
548 | if (dev) |
549 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | |
4cc987ea | 550 | rcu_read_unlock(); |
12d23384 NB |
551 | return ret; |
552 | } | |
12d23384 | 553 | |
2eafd729 CH |
554 | static ssize_t target_stat_tgt_port_indx_show(struct config_item *item, |
555 | char *page) | |
12d23384 | 556 | { |
2eafd729 | 557 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
558 | struct se_device *dev; |
559 | ssize_t ret = -ENODEV; | |
12d23384 | 560 | |
4cc987ea NB |
561 | rcu_read_lock(); |
562 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 563 | if (dev) |
b9e063ad | 564 | ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_tpg->tpg_rtpi); |
4cc987ea | 565 | rcu_read_unlock(); |
12d23384 NB |
566 | return ret; |
567 | } | |
12d23384 | 568 | |
2eafd729 CH |
569 | static ssize_t target_stat_tgt_port_name_show(struct config_item *item, |
570 | char *page) | |
12d23384 | 571 | { |
2eafd729 | 572 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
573 | struct se_portal_group *tpg = lun->lun_tpg; |
574 | struct se_device *dev; | |
575 | ssize_t ret = -ENODEV; | |
12d23384 | 576 | |
4cc987ea NB |
577 | rcu_read_lock(); |
578 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
579 | if (dev) |
580 | ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n", | |
30c7ca93 | 581 | tpg->se_tpg_tfo->fabric_name, |
b9e063ad | 582 | lun->lun_tpg->tpg_rtpi); |
4cc987ea | 583 | rcu_read_unlock(); |
12d23384 NB |
584 | return ret; |
585 | } | |
12d23384 | 586 | |
2eafd729 CH |
587 | static ssize_t target_stat_tgt_port_port_index_show(struct config_item *item, |
588 | char *page) | |
12d23384 | 589 | { |
2eafd729 | 590 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
591 | struct se_portal_group *tpg = lun->lun_tpg; |
592 | struct se_device *dev; | |
593 | ssize_t ret = -ENODEV; | |
12d23384 | 594 | |
4cc987ea NB |
595 | rcu_read_lock(); |
596 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
597 | if (dev) |
598 | ret = snprintf(page, PAGE_SIZE, "%s%s%d\n", | |
599 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+", | |
600 | tpg->se_tpg_tfo->tpg_get_tag(tpg)); | |
4cc987ea | 601 | rcu_read_unlock(); |
12d23384 NB |
602 | return ret; |
603 | } | |
12d23384 | 604 | |
2eafd729 CH |
605 | static ssize_t target_stat_tgt_port_in_cmds_show(struct config_item *item, |
606 | char *page) | |
12d23384 | 607 | { |
2eafd729 | 608 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
609 | struct se_device *dev; |
610 | ssize_t ret = -ENODEV; | |
12d23384 | 611 | |
4cc987ea NB |
612 | rcu_read_lock(); |
613 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 614 | if (dev) |
4cc987ea NB |
615 | ret = snprintf(page, PAGE_SIZE, "%lu\n", |
616 | atomic_long_read(&lun->lun_stats.cmd_pdus)); | |
617 | rcu_read_unlock(); | |
12d23384 NB |
618 | return ret; |
619 | } | |
12d23384 | 620 | |
2eafd729 CH |
621 | static ssize_t target_stat_tgt_port_write_mbytes_show(struct config_item *item, |
622 | char *page) | |
12d23384 | 623 | { |
2eafd729 | 624 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
625 | struct se_device *dev; |
626 | ssize_t ret = -ENODEV; | |
12d23384 | 627 | |
4cc987ea NB |
628 | rcu_read_lock(); |
629 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
630 | if (dev) |
631 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
4cc987ea NB |
632 | (u32)(atomic_long_read(&lun->lun_stats.rx_data_octets) >> 20)); |
633 | rcu_read_unlock(); | |
12d23384 NB |
634 | return ret; |
635 | } | |
12d23384 | 636 | |
2eafd729 CH |
637 | static ssize_t target_stat_tgt_port_read_mbytes_show(struct config_item *item, |
638 | char *page) | |
12d23384 | 639 | { |
2eafd729 | 640 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
641 | struct se_device *dev; |
642 | ssize_t ret = -ENODEV; | |
12d23384 | 643 | |
4cc987ea NB |
644 | rcu_read_lock(); |
645 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
646 | if (dev) |
647 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
4cc987ea NB |
648 | (u32)(atomic_long_read(&lun->lun_stats.tx_data_octets) >> 20)); |
649 | rcu_read_unlock(); | |
12d23384 NB |
650 | return ret; |
651 | } | |
12d23384 | 652 | |
2eafd729 CH |
653 | static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item, |
654 | char *page) | |
12d23384 | 655 | { |
2eafd729 | 656 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
657 | struct se_device *dev; |
658 | ssize_t ret = -ENODEV; | |
12d23384 | 659 | |
4cc987ea NB |
660 | rcu_read_lock(); |
661 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
662 | if (dev) { |
663 | /* FIXME: scsiTgtPortHsInCommands */ | |
664 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
12d23384 | 665 | } |
4cc987ea | 666 | rcu_read_unlock(); |
12d23384 NB |
667 | return ret; |
668 | } | |
12d23384 | 669 | |
2eafd729 CH |
670 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, inst); |
671 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, dev); | |
672 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, indx); | |
673 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, name); | |
674 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, port_index); | |
675 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, in_cmds); | |
676 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, write_mbytes); | |
677 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, read_mbytes); | |
678 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, hs_in_cmds); | |
12d23384 NB |
679 | |
680 | static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = { | |
2eafd729 CH |
681 | &target_stat_tgt_port_attr_inst, |
682 | &target_stat_tgt_port_attr_dev, | |
683 | &target_stat_tgt_port_attr_indx, | |
684 | &target_stat_tgt_port_attr_name, | |
685 | &target_stat_tgt_port_attr_port_index, | |
686 | &target_stat_tgt_port_attr_in_cmds, | |
687 | &target_stat_tgt_port_attr_write_mbytes, | |
688 | &target_stat_tgt_port_attr_read_mbytes, | |
689 | &target_stat_tgt_port_attr_hs_in_cmds, | |
12d23384 NB |
690 | NULL, |
691 | }; | |
692 | ||
ece550b5 | 693 | static const struct config_item_type target_stat_scsi_tgt_port_cit = { |
12d23384 NB |
694 | .ct_attrs = target_stat_scsi_tgt_port_attrs, |
695 | .ct_owner = THIS_MODULE, | |
696 | }; | |
697 | ||
698 | /* | |
699 | * SCSI Transport Table | |
2eafd729 CH |
700 | */ |
701 | static struct se_lun *to_transport_stat(struct config_item *item) | |
702 | { | |
703 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), | |
704 | struct se_port_stat_grps, scsi_transport_group); | |
705 | return container_of(pgrps, struct se_lun, port_stat_grps); | |
706 | } | |
707 | ||
708 | static ssize_t target_stat_transport_inst_show(struct config_item *item, | |
709 | char *page) | |
710 | { | |
711 | struct se_lun *lun = to_transport_stat(item); | |
adf653f9 CH |
712 | struct se_device *dev; |
713 | ssize_t ret = -ENODEV; | |
12d23384 | 714 | |
4cc987ea NB |
715 | rcu_read_lock(); |
716 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 717 | if (dev) |
4cc987ea NB |
718 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index); |
719 | rcu_read_unlock(); | |
12d23384 NB |
720 | return ret; |
721 | } | |
12d23384 | 722 | |
2eafd729 CH |
723 | static ssize_t target_stat_transport_device_show(struct config_item *item, |
724 | char *page) | |
12d23384 | 725 | { |
2eafd729 | 726 | struct se_lun *lun = to_transport_stat(item); |
adf653f9 CH |
727 | struct se_device *dev; |
728 | struct se_portal_group *tpg = lun->lun_tpg; | |
729 | ssize_t ret = -ENODEV; | |
12d23384 | 730 | |
4cc987ea NB |
731 | rcu_read_lock(); |
732 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
733 | if (dev) { |
734 | /* scsiTransportType */ | |
735 | ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n", | |
30c7ca93 | 736 | tpg->se_tpg_tfo->fabric_name); |
12d23384 | 737 | } |
4cc987ea | 738 | rcu_read_unlock(); |
12d23384 NB |
739 | return ret; |
740 | } | |
12d23384 | 741 | |
2eafd729 CH |
742 | static ssize_t target_stat_transport_indx_show(struct config_item *item, |
743 | char *page) | |
12d23384 | 744 | { |
2eafd729 | 745 | struct se_lun *lun = to_transport_stat(item); |
adf653f9 CH |
746 | struct se_device *dev; |
747 | struct se_portal_group *tpg = lun->lun_tpg; | |
748 | ssize_t ret = -ENODEV; | |
12d23384 | 749 | |
4cc987ea NB |
750 | rcu_read_lock(); |
751 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
752 | if (dev) |
753 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
754 | tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); | |
4cc987ea | 755 | rcu_read_unlock(); |
12d23384 NB |
756 | return ret; |
757 | } | |
12d23384 | 758 | |
2eafd729 CH |
759 | static ssize_t target_stat_transport_dev_name_show(struct config_item *item, |
760 | char *page) | |
12d23384 | 761 | { |
2eafd729 | 762 | struct se_lun *lun = to_transport_stat(item); |
4cc987ea | 763 | struct se_device *dev; |
adf653f9 | 764 | struct se_portal_group *tpg = lun->lun_tpg; |
12d23384 | 765 | struct t10_wwn *wwn; |
adf653f9 | 766 | ssize_t ret = -ENODEV; |
12d23384 | 767 | |
4cc987ea NB |
768 | rcu_read_lock(); |
769 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
770 | if (dev) { |
771 | wwn = &dev->t10_wwn; | |
772 | /* scsiTransportDevName */ | |
773 | ret = snprintf(page, PAGE_SIZE, "%s+%s\n", | |
774 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), | |
775 | (strlen(wwn->unit_serial)) ? wwn->unit_serial : | |
776 | wwn->vendor); | |
12d23384 | 777 | } |
4cc987ea | 778 | rcu_read_unlock(); |
12d23384 NB |
779 | return ret; |
780 | } | |
12d23384 | 781 | |
0ab8ac6f MC |
782 | static ssize_t target_stat_transport_proto_id_show(struct config_item *item, |
783 | char *page) | |
784 | { | |
785 | struct se_lun *lun = to_transport_stat(item); | |
786 | struct se_device *dev; | |
787 | struct se_portal_group *tpg = lun->lun_tpg; | |
788 | ssize_t ret = -ENODEV; | |
789 | ||
790 | rcu_read_lock(); | |
791 | dev = rcu_dereference(lun->lun_se_dev); | |
792 | if (dev) | |
793 | ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->proto_id); | |
794 | rcu_read_unlock(); | |
795 | return ret; | |
796 | } | |
797 | ||
2eafd729 CH |
798 | CONFIGFS_ATTR_RO(target_stat_transport_, inst); |
799 | CONFIGFS_ATTR_RO(target_stat_transport_, device); | |
800 | CONFIGFS_ATTR_RO(target_stat_transport_, indx); | |
801 | CONFIGFS_ATTR_RO(target_stat_transport_, dev_name); | |
0ab8ac6f | 802 | CONFIGFS_ATTR_RO(target_stat_transport_, proto_id); |
12d23384 NB |
803 | |
804 | static struct configfs_attribute *target_stat_scsi_transport_attrs[] = { | |
2eafd729 CH |
805 | &target_stat_transport_attr_inst, |
806 | &target_stat_transport_attr_device, | |
807 | &target_stat_transport_attr_indx, | |
808 | &target_stat_transport_attr_dev_name, | |
0ab8ac6f | 809 | &target_stat_transport_attr_proto_id, |
12d23384 NB |
810 | NULL, |
811 | }; | |
812 | ||
ece550b5 | 813 | static const struct config_item_type target_stat_scsi_transport_cit = { |
12d23384 NB |
814 | .ct_attrs = target_stat_scsi_transport_attrs, |
815 | .ct_owner = THIS_MODULE, | |
816 | }; | |
817 | ||
818 | /* | |
819 | * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup | |
820 | * the target port statistics groups + configfs CITs located in target_core_stat.c | |
821 | */ | |
822 | void target_stat_setup_port_default_groups(struct se_lun *lun) | |
823 | { | |
e3d6f909 | 824 | config_group_init_type_name(&lun->port_stat_grps.scsi_port_group, |
12d23384 | 825 | "scsi_port", &target_stat_scsi_port_cit); |
1ae1602d CH |
826 | configfs_add_default_group(&lun->port_stat_grps.scsi_port_group, |
827 | &lun->port_stat_grps.stat_group); | |
828 | ||
e3d6f909 | 829 | config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group, |
12d23384 | 830 | "scsi_tgt_port", &target_stat_scsi_tgt_port_cit); |
1ae1602d CH |
831 | configfs_add_default_group(&lun->port_stat_grps.scsi_tgt_port_group, |
832 | &lun->port_stat_grps.stat_group); | |
833 | ||
e3d6f909 | 834 | config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group, |
12d23384 | 835 | "scsi_transport", &target_stat_scsi_transport_cit); |
1ae1602d CH |
836 | configfs_add_default_group(&lun->port_stat_grps.scsi_transport_group, |
837 | &lun->port_stat_grps.stat_group); | |
12d23384 NB |
838 | } |
839 | ||
840 | /* | |
841 | * SCSI Authorized Initiator Table | |
842 | */ | |
843 | ||
2eafd729 CH |
844 | static struct se_lun_acl *auth_to_lacl(struct config_item *item) |
845 | { | |
846 | struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), | |
847 | struct se_ml_stat_grps, scsi_auth_intr_group); | |
848 | return container_of(lgrps, struct se_lun_acl, ml_stat_grps); | |
849 | } | |
850 | ||
851 | static ssize_t target_stat_auth_inst_show(struct config_item *item, | |
852 | char *page) | |
853 | { | |
854 | struct se_lun_acl *lacl = auth_to_lacl(item); | |
12d23384 NB |
855 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
856 | struct se_dev_entry *deve; | |
857 | struct se_portal_group *tpg; | |
858 | ssize_t ret; | |
859 | ||
29a05dee NB |
860 | rcu_read_lock(); |
861 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
862 | if (!deve) { | |
863 | rcu_read_unlock(); | |
12d23384 NB |
864 | return -ENODEV; |
865 | } | |
866 | tpg = nacl->se_tpg; | |
867 | /* scsiInstIndex */ | |
868 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
e3d6f909 | 869 | tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); |
29a05dee | 870 | rcu_read_unlock(); |
12d23384 NB |
871 | return ret; |
872 | } | |
12d23384 | 873 | |
2eafd729 CH |
874 | static ssize_t target_stat_auth_dev_show(struct config_item *item, |
875 | char *page) | |
12d23384 | 876 | { |
2eafd729 | 877 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
878 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
879 | struct se_dev_entry *deve; | |
12d23384 NB |
880 | ssize_t ret; |
881 | ||
29a05dee NB |
882 | rcu_read_lock(); |
883 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
884 | if (!deve) { | |
885 | rcu_read_unlock(); | |
12d23384 NB |
886 | return -ENODEV; |
887 | } | |
ef4f7e4b | 888 | |
12d23384 | 889 | /* scsiDeviceIndex */ |
ef4f7e4b | 890 | ret = snprintf(page, PAGE_SIZE, "%u\n", deve->se_lun->lun_index); |
29a05dee | 891 | rcu_read_unlock(); |
12d23384 NB |
892 | return ret; |
893 | } | |
12d23384 | 894 | |
2eafd729 CH |
895 | static ssize_t target_stat_auth_port_show(struct config_item *item, |
896 | char *page) | |
12d23384 | 897 | { |
2eafd729 | 898 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
899 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
900 | struct se_dev_entry *deve; | |
901 | struct se_portal_group *tpg; | |
902 | ssize_t ret; | |
903 | ||
29a05dee NB |
904 | rcu_read_lock(); |
905 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
906 | if (!deve) { | |
907 | rcu_read_unlock(); | |
12d23384 NB |
908 | return -ENODEV; |
909 | } | |
910 | tpg = nacl->se_tpg; | |
911 | /* scsiAuthIntrTgtPortIndex */ | |
e3d6f909 | 912 | ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg)); |
29a05dee | 913 | rcu_read_unlock(); |
12d23384 NB |
914 | return ret; |
915 | } | |
12d23384 | 916 | |
2eafd729 CH |
917 | static ssize_t target_stat_auth_indx_show(struct config_item *item, |
918 | char *page) | |
12d23384 | 919 | { |
2eafd729 | 920 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
921 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
922 | struct se_dev_entry *deve; | |
923 | ssize_t ret; | |
924 | ||
29a05dee NB |
925 | rcu_read_lock(); |
926 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
927 | if (!deve) { | |
928 | rcu_read_unlock(); | |
12d23384 NB |
929 | return -ENODEV; |
930 | } | |
931 | /* scsiAuthIntrIndex */ | |
932 | ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index); | |
29a05dee | 933 | rcu_read_unlock(); |
12d23384 NB |
934 | return ret; |
935 | } | |
12d23384 | 936 | |
2eafd729 CH |
937 | static ssize_t target_stat_auth_dev_or_port_show(struct config_item *item, |
938 | char *page) | |
12d23384 | 939 | { |
2eafd729 | 940 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
941 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
942 | struct se_dev_entry *deve; | |
943 | ssize_t ret; | |
944 | ||
29a05dee NB |
945 | rcu_read_lock(); |
946 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
947 | if (!deve) { | |
948 | rcu_read_unlock(); | |
12d23384 NB |
949 | return -ENODEV; |
950 | } | |
951 | /* scsiAuthIntrDevOrPort */ | |
952 | ret = snprintf(page, PAGE_SIZE, "%u\n", 1); | |
29a05dee | 953 | rcu_read_unlock(); |
12d23384 NB |
954 | return ret; |
955 | } | |
12d23384 | 956 | |
2eafd729 CH |
957 | static ssize_t target_stat_auth_intr_name_show(struct config_item *item, |
958 | char *page) | |
12d23384 | 959 | { |
2eafd729 | 960 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
961 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
962 | struct se_dev_entry *deve; | |
963 | ssize_t ret; | |
964 | ||
29a05dee NB |
965 | rcu_read_lock(); |
966 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
967 | if (!deve) { | |
968 | rcu_read_unlock(); | |
12d23384 NB |
969 | return -ENODEV; |
970 | } | |
971 | /* scsiAuthIntrName */ | |
972 | ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname); | |
29a05dee | 973 | rcu_read_unlock(); |
12d23384 NB |
974 | return ret; |
975 | } | |
12d23384 | 976 | |
2eafd729 CH |
977 | static ssize_t target_stat_auth_map_indx_show(struct config_item *item, |
978 | char *page) | |
12d23384 | 979 | { |
2eafd729 | 980 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
981 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
982 | struct se_dev_entry *deve; | |
983 | ssize_t ret; | |
984 | ||
29a05dee NB |
985 | rcu_read_lock(); |
986 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
987 | if (!deve) { | |
988 | rcu_read_unlock(); | |
12d23384 NB |
989 | return -ENODEV; |
990 | } | |
991 | /* FIXME: scsiAuthIntrLunMapIndex */ | |
992 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
29a05dee | 993 | rcu_read_unlock(); |
12d23384 NB |
994 | return ret; |
995 | } | |
12d23384 | 996 | |
2eafd729 CH |
997 | static ssize_t target_stat_auth_att_count_show(struct config_item *item, |
998 | char *page) | |
12d23384 | 999 | { |
2eafd729 | 1000 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1001 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1002 | struct se_dev_entry *deve; | |
1003 | ssize_t ret; | |
1004 | ||
29a05dee NB |
1005 | rcu_read_lock(); |
1006 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1007 | if (!deve) { | |
1008 | rcu_read_unlock(); | |
12d23384 NB |
1009 | return -ENODEV; |
1010 | } | |
1011 | /* scsiAuthIntrAttachedTimes */ | |
1012 | ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count); | |
29a05dee | 1013 | rcu_read_unlock(); |
12d23384 NB |
1014 | return ret; |
1015 | } | |
12d23384 | 1016 | |
2eafd729 CH |
1017 | static ssize_t target_stat_auth_num_cmds_show(struct config_item *item, |
1018 | char *page) | |
12d23384 | 1019 | { |
2eafd729 | 1020 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1021 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1022 | struct se_dev_entry *deve; | |
1023 | ssize_t ret; | |
1024 | ||
29a05dee NB |
1025 | rcu_read_lock(); |
1026 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1027 | if (!deve) { | |
1028 | rcu_read_unlock(); | |
12d23384 NB |
1029 | return -ENODEV; |
1030 | } | |
1031 | /* scsiAuthIntrOutCommands */ | |
29a05dee NB |
1032 | ret = snprintf(page, PAGE_SIZE, "%lu\n", |
1033 | atomic_long_read(&deve->total_cmds)); | |
1034 | rcu_read_unlock(); | |
12d23384 NB |
1035 | return ret; |
1036 | } | |
12d23384 | 1037 | |
2eafd729 CH |
1038 | static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item, |
1039 | char *page) | |
12d23384 | 1040 | { |
2eafd729 | 1041 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1042 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1043 | struct se_dev_entry *deve; | |
1044 | ssize_t ret; | |
1045 | ||
29a05dee NB |
1046 | rcu_read_lock(); |
1047 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1048 | if (!deve) { | |
1049 | rcu_read_unlock(); | |
12d23384 NB |
1050 | return -ENODEV; |
1051 | } | |
1052 | /* scsiAuthIntrReadMegaBytes */ | |
29a05dee NB |
1053 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
1054 | (u32)(atomic_long_read(&deve->read_bytes) >> 20)); | |
1055 | rcu_read_unlock(); | |
12d23384 NB |
1056 | return ret; |
1057 | } | |
12d23384 | 1058 | |
2eafd729 CH |
1059 | static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item, |
1060 | char *page) | |
12d23384 | 1061 | { |
2eafd729 | 1062 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1063 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1064 | struct se_dev_entry *deve; | |
1065 | ssize_t ret; | |
1066 | ||
29a05dee NB |
1067 | rcu_read_lock(); |
1068 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1069 | if (!deve) { | |
1070 | rcu_read_unlock(); | |
12d23384 NB |
1071 | return -ENODEV; |
1072 | } | |
1073 | /* scsiAuthIntrWrittenMegaBytes */ | |
29a05dee NB |
1074 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
1075 | (u32)(atomic_long_read(&deve->write_bytes) >> 20)); | |
1076 | rcu_read_unlock(); | |
12d23384 NB |
1077 | return ret; |
1078 | } | |
12d23384 | 1079 | |
2eafd729 CH |
1080 | static ssize_t target_stat_auth_hs_num_cmds_show(struct config_item *item, |
1081 | char *page) | |
12d23384 | 1082 | { |
2eafd729 | 1083 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1084 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1085 | struct se_dev_entry *deve; | |
1086 | ssize_t ret; | |
1087 | ||
29a05dee NB |
1088 | rcu_read_lock(); |
1089 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1090 | if (!deve) { | |
1091 | rcu_read_unlock(); | |
12d23384 NB |
1092 | return -ENODEV; |
1093 | } | |
1094 | /* FIXME: scsiAuthIntrHSOutCommands */ | |
1095 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
29a05dee | 1096 | rcu_read_unlock(); |
12d23384 NB |
1097 | return ret; |
1098 | } | |
12d23384 | 1099 | |
2eafd729 CH |
1100 | static ssize_t target_stat_auth_creation_time_show(struct config_item *item, |
1101 | char *page) | |
12d23384 | 1102 | { |
2eafd729 | 1103 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1104 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1105 | struct se_dev_entry *deve; | |
1106 | ssize_t ret; | |
1107 | ||
29a05dee NB |
1108 | rcu_read_lock(); |
1109 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1110 | if (!deve) { | |
1111 | rcu_read_unlock(); | |
12d23384 NB |
1112 | return -ENODEV; |
1113 | } | |
1114 | /* scsiAuthIntrLastCreation */ | |
1115 | ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time - | |
1116 | INITIAL_JIFFIES) * 100 / HZ)); | |
29a05dee | 1117 | rcu_read_unlock(); |
12d23384 NB |
1118 | return ret; |
1119 | } | |
12d23384 | 1120 | |
2eafd729 CH |
1121 | static ssize_t target_stat_auth_row_status_show(struct config_item *item, |
1122 | char *page) | |
12d23384 | 1123 | { |
2eafd729 | 1124 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1125 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1126 | struct se_dev_entry *deve; | |
1127 | ssize_t ret; | |
1128 | ||
29a05dee NB |
1129 | rcu_read_lock(); |
1130 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1131 | if (!deve) { | |
1132 | rcu_read_unlock(); | |
12d23384 NB |
1133 | return -ENODEV; |
1134 | } | |
1135 | /* FIXME: scsiAuthIntrRowStatus */ | |
1136 | ret = snprintf(page, PAGE_SIZE, "Ready\n"); | |
29a05dee | 1137 | rcu_read_unlock(); |
12d23384 NB |
1138 | return ret; |
1139 | } | |
12d23384 | 1140 | |
2eafd729 CH |
1141 | CONFIGFS_ATTR_RO(target_stat_auth_, inst); |
1142 | CONFIGFS_ATTR_RO(target_stat_auth_, dev); | |
1143 | CONFIGFS_ATTR_RO(target_stat_auth_, port); | |
1144 | CONFIGFS_ATTR_RO(target_stat_auth_, indx); | |
1145 | CONFIGFS_ATTR_RO(target_stat_auth_, dev_or_port); | |
1146 | CONFIGFS_ATTR_RO(target_stat_auth_, intr_name); | |
1147 | CONFIGFS_ATTR_RO(target_stat_auth_, map_indx); | |
1148 | CONFIGFS_ATTR_RO(target_stat_auth_, att_count); | |
1149 | CONFIGFS_ATTR_RO(target_stat_auth_, num_cmds); | |
1150 | CONFIGFS_ATTR_RO(target_stat_auth_, read_mbytes); | |
1151 | CONFIGFS_ATTR_RO(target_stat_auth_, write_mbytes); | |
1152 | CONFIGFS_ATTR_RO(target_stat_auth_, hs_num_cmds); | |
1153 | CONFIGFS_ATTR_RO(target_stat_auth_, creation_time); | |
1154 | CONFIGFS_ATTR_RO(target_stat_auth_, row_status); | |
12d23384 NB |
1155 | |
1156 | static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = { | |
2eafd729 CH |
1157 | &target_stat_auth_attr_inst, |
1158 | &target_stat_auth_attr_dev, | |
1159 | &target_stat_auth_attr_port, | |
1160 | &target_stat_auth_attr_indx, | |
1161 | &target_stat_auth_attr_dev_or_port, | |
1162 | &target_stat_auth_attr_intr_name, | |
1163 | &target_stat_auth_attr_map_indx, | |
1164 | &target_stat_auth_attr_att_count, | |
1165 | &target_stat_auth_attr_num_cmds, | |
1166 | &target_stat_auth_attr_read_mbytes, | |
1167 | &target_stat_auth_attr_write_mbytes, | |
1168 | &target_stat_auth_attr_hs_num_cmds, | |
1169 | &target_stat_auth_attr_creation_time, | |
1170 | &target_stat_auth_attr_row_status, | |
12d23384 NB |
1171 | NULL, |
1172 | }; | |
1173 | ||
ece550b5 | 1174 | static const struct config_item_type target_stat_scsi_auth_intr_cit = { |
12d23384 NB |
1175 | .ct_attrs = target_stat_scsi_auth_intr_attrs, |
1176 | .ct_owner = THIS_MODULE, | |
1177 | }; | |
1178 | ||
1179 | /* | |
1180 | * SCSI Attached Initiator Port Table | |
1181 | */ | |
1182 | ||
2eafd729 CH |
1183 | static struct se_lun_acl *iport_to_lacl(struct config_item *item) |
1184 | { | |
1185 | struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), | |
1186 | struct se_ml_stat_grps, scsi_att_intr_port_group); | |
1187 | return container_of(lgrps, struct se_lun_acl, ml_stat_grps); | |
1188 | } | |
1189 | ||
1190 | static ssize_t target_stat_iport_inst_show(struct config_item *item, | |
1191 | char *page) | |
1192 | { | |
1193 | struct se_lun_acl *lacl = iport_to_lacl(item); | |
12d23384 NB |
1194 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1195 | struct se_dev_entry *deve; | |
1196 | struct se_portal_group *tpg; | |
1197 | ssize_t ret; | |
1198 | ||
29a05dee NB |
1199 | rcu_read_lock(); |
1200 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1201 | if (!deve) { | |
1202 | rcu_read_unlock(); | |
12d23384 NB |
1203 | return -ENODEV; |
1204 | } | |
1205 | tpg = nacl->se_tpg; | |
1206 | /* scsiInstIndex */ | |
1207 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
e3d6f909 | 1208 | tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); |
29a05dee | 1209 | rcu_read_unlock(); |
12d23384 NB |
1210 | return ret; |
1211 | } | |
12d23384 | 1212 | |
2eafd729 CH |
1213 | static ssize_t target_stat_iport_dev_show(struct config_item *item, |
1214 | char *page) | |
12d23384 | 1215 | { |
2eafd729 | 1216 | struct se_lun_acl *lacl = iport_to_lacl(item); |
12d23384 NB |
1217 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1218 | struct se_dev_entry *deve; | |
12d23384 NB |
1219 | ssize_t ret; |
1220 | ||
29a05dee NB |
1221 | rcu_read_lock(); |
1222 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1223 | if (!deve) { | |
1224 | rcu_read_unlock(); | |
12d23384 NB |
1225 | return -ENODEV; |
1226 | } | |
ef4f7e4b | 1227 | |
12d23384 | 1228 | /* scsiDeviceIndex */ |
ef4f7e4b | 1229 | ret = snprintf(page, PAGE_SIZE, "%u\n", deve->se_lun->lun_index); |
29a05dee | 1230 | rcu_read_unlock(); |
12d23384 NB |
1231 | return ret; |
1232 | } | |
12d23384 | 1233 | |
2eafd729 CH |
1234 | static ssize_t target_stat_iport_port_show(struct config_item *item, |
1235 | char *page) | |
12d23384 | 1236 | { |
2eafd729 | 1237 | struct se_lun_acl *lacl = iport_to_lacl(item); |
12d23384 NB |
1238 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1239 | struct se_dev_entry *deve; | |
1240 | struct se_portal_group *tpg; | |
1241 | ssize_t ret; | |
1242 | ||
29a05dee NB |
1243 | rcu_read_lock(); |
1244 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1245 | if (!deve) { | |
1246 | rcu_read_unlock(); | |
12d23384 NB |
1247 | return -ENODEV; |
1248 | } | |
1249 | tpg = nacl->se_tpg; | |
1250 | /* scsiPortIndex */ | |
e3d6f909 | 1251 | ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg)); |
29a05dee | 1252 | rcu_read_unlock(); |
12d23384 NB |
1253 | return ret; |
1254 | } | |
12d23384 | 1255 | |
2eafd729 CH |
1256 | static ssize_t target_stat_iport_indx_show(struct config_item *item, |
1257 | char *page) | |
12d23384 | 1258 | { |
2eafd729 | 1259 | struct se_lun_acl *lacl = iport_to_lacl(item); |
12d23384 NB |
1260 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1261 | struct se_session *se_sess; | |
1262 | struct se_portal_group *tpg; | |
1263 | ssize_t ret; | |
1264 | ||
1265 | spin_lock_irq(&nacl->nacl_sess_lock); | |
1266 | se_sess = nacl->nacl_sess; | |
1267 | if (!se_sess) { | |
1268 | spin_unlock_irq(&nacl->nacl_sess_lock); | |
1269 | return -ENODEV; | |
1270 | } | |
1271 | ||
1272 | tpg = nacl->se_tpg; | |
1273 | /* scsiAttIntrPortIndex */ | |
1274 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
e3d6f909 | 1275 | tpg->se_tpg_tfo->sess_get_index(se_sess)); |
12d23384 NB |
1276 | spin_unlock_irq(&nacl->nacl_sess_lock); |
1277 | return ret; | |
1278 | } | |
12d23384 | 1279 | |
2eafd729 CH |
1280 | static ssize_t target_stat_iport_port_auth_indx_show(struct config_item *item, |
1281 | char *page) | |
12d23384 | 1282 | { |
2eafd729 | 1283 | struct se_lun_acl *lacl = iport_to_lacl(item); |
12d23384 NB |
1284 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1285 | struct se_dev_entry *deve; | |
1286 | ssize_t ret; | |
1287 | ||
29a05dee NB |
1288 | rcu_read_lock(); |
1289 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1290 | if (!deve) { | |
1291 | rcu_read_unlock(); | |
12d23384 NB |
1292 | return -ENODEV; |
1293 | } | |
1294 | /* scsiAttIntrPortAuthIntrIdx */ | |
1295 | ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index); | |
29a05dee | 1296 | rcu_read_unlock(); |
12d23384 NB |
1297 | return ret; |
1298 | } | |
12d23384 | 1299 | |
2eafd729 CH |
1300 | static ssize_t target_stat_iport_port_ident_show(struct config_item *item, |
1301 | char *page) | |
12d23384 | 1302 | { |
2eafd729 | 1303 | struct se_lun_acl *lacl = iport_to_lacl(item); |
12d23384 NB |
1304 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1305 | struct se_session *se_sess; | |
1306 | struct se_portal_group *tpg; | |
1307 | ssize_t ret; | |
1308 | unsigned char buf[64]; | |
1309 | ||
1310 | spin_lock_irq(&nacl->nacl_sess_lock); | |
1311 | se_sess = nacl->nacl_sess; | |
1312 | if (!se_sess) { | |
1313 | spin_unlock_irq(&nacl->nacl_sess_lock); | |
1314 | return -ENODEV; | |
1315 | } | |
1316 | ||
1317 | tpg = nacl->se_tpg; | |
1318 | /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */ | |
1319 | memset(buf, 0, 64); | |
e3d6f909 | 1320 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) |
8359cf43 | 1321 | tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64); |
12d23384 NB |
1322 | |
1323 | ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf); | |
1324 | spin_unlock_irq(&nacl->nacl_sess_lock); | |
1325 | return ret; | |
1326 | } | |
12d23384 | 1327 | |
2eafd729 CH |
1328 | CONFIGFS_ATTR_RO(target_stat_iport_, inst); |
1329 | CONFIGFS_ATTR_RO(target_stat_iport_, dev); | |
1330 | CONFIGFS_ATTR_RO(target_stat_iport_, port); | |
1331 | CONFIGFS_ATTR_RO(target_stat_iport_, indx); | |
1332 | CONFIGFS_ATTR_RO(target_stat_iport_, port_auth_indx); | |
1333 | CONFIGFS_ATTR_RO(target_stat_iport_, port_ident); | |
12d23384 NB |
1334 | |
1335 | static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = { | |
2eafd729 CH |
1336 | &target_stat_iport_attr_inst, |
1337 | &target_stat_iport_attr_dev, | |
1338 | &target_stat_iport_attr_port, | |
1339 | &target_stat_iport_attr_indx, | |
1340 | &target_stat_iport_attr_port_auth_indx, | |
1341 | &target_stat_iport_attr_port_ident, | |
12d23384 NB |
1342 | NULL, |
1343 | }; | |
1344 | ||
ece550b5 | 1345 | static const struct config_item_type target_stat_scsi_att_intr_port_cit = { |
12d23384 NB |
1346 | .ct_attrs = target_stat_scsi_ath_intr_port_attrs, |
1347 | .ct_owner = THIS_MODULE, | |
1348 | }; | |
1349 | ||
1350 | /* | |
1351 | * Called from target_core_fabric_configfs.c:target_fabric_make_mappedlun() to setup | |
1352 | * the target MappedLUN statistics groups + configfs CITs located in target_core_stat.c | |
1353 | */ | |
1354 | void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl) | |
1355 | { | |
e3d6f909 | 1356 | config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group, |
12d23384 | 1357 | "scsi_auth_intr", &target_stat_scsi_auth_intr_cit); |
1ae1602d CH |
1358 | configfs_add_default_group(&lacl->ml_stat_grps.scsi_auth_intr_group, |
1359 | &lacl->ml_stat_grps.stat_group); | |
1360 | ||
e3d6f909 | 1361 | config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group, |
12d23384 | 1362 | "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit); |
1ae1602d CH |
1363 | configfs_add_default_group(&lacl->ml_stat_grps.scsi_att_intr_port_group, |
1364 | &lacl->ml_stat_grps.stat_group); | |
12d23384 | 1365 | } |