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