]>
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 | config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group, |
12d23384 | 411 | "scsi_dev", &target_stat_scsi_dev_cit); |
1ae1602d CH |
412 | configfs_add_default_group(&dev->dev_stat_grps.scsi_dev_group, |
413 | &dev->dev_stat_grps.stat_group); | |
414 | ||
0fd97ccf | 415 | config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group, |
12d23384 | 416 | "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); |
1ae1602d CH |
417 | configfs_add_default_group(&dev->dev_stat_grps.scsi_tgt_dev_group, |
418 | &dev->dev_stat_grps.stat_group); | |
419 | ||
0fd97ccf | 420 | config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group, |
12d23384 | 421 | "scsi_lu", &target_stat_scsi_lu_cit); |
1ae1602d CH |
422 | configfs_add_default_group(&dev->dev_stat_grps.scsi_lu_group, |
423 | &dev->dev_stat_grps.stat_group); | |
12d23384 NB |
424 | } |
425 | ||
426 | /* | |
427 | * SCSI Port Table | |
428 | */ | |
429 | ||
2eafd729 CH |
430 | static struct se_lun *to_stat_port(struct config_item *item) |
431 | { | |
432 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), | |
433 | struct se_port_stat_grps, scsi_port_group); | |
434 | return container_of(pgrps, struct se_lun, port_stat_grps); | |
435 | } | |
12d23384 | 436 | |
2eafd729 | 437 | static ssize_t target_stat_port_inst_show(struct config_item *item, char *page) |
12d23384 | 438 | { |
2eafd729 | 439 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
440 | struct se_device *dev; |
441 | ssize_t ret = -ENODEV; | |
12d23384 | 442 | |
4cc987ea NB |
443 | rcu_read_lock(); |
444 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 445 | if (dev) |
4cc987ea NB |
446 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index); |
447 | rcu_read_unlock(); | |
12d23384 NB |
448 | return ret; |
449 | } | |
12d23384 | 450 | |
2eafd729 | 451 | static ssize_t target_stat_port_dev_show(struct config_item *item, char *page) |
12d23384 | 452 | { |
2eafd729 | 453 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
454 | struct se_device *dev; |
455 | ssize_t ret = -ENODEV; | |
12d23384 | 456 | |
4cc987ea NB |
457 | rcu_read_lock(); |
458 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
459 | if (dev) |
460 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | |
4cc987ea | 461 | rcu_read_unlock(); |
12d23384 NB |
462 | return ret; |
463 | } | |
12d23384 | 464 | |
2eafd729 | 465 | static ssize_t target_stat_port_indx_show(struct config_item *item, char *page) |
12d23384 | 466 | { |
2eafd729 | 467 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
468 | struct se_device *dev; |
469 | ssize_t ret = -ENODEV; | |
12d23384 | 470 | |
4cc987ea NB |
471 | rcu_read_lock(); |
472 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
473 | if (dev) |
474 | ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi); | |
4cc987ea | 475 | rcu_read_unlock(); |
12d23384 NB |
476 | return ret; |
477 | } | |
12d23384 | 478 | |
2eafd729 | 479 | static ssize_t target_stat_port_role_show(struct config_item *item, char *page) |
12d23384 | 480 | { |
2eafd729 | 481 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
482 | struct se_device *dev; |
483 | ssize_t ret = -ENODEV; | |
12d23384 | 484 | |
4cc987ea NB |
485 | rcu_read_lock(); |
486 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
487 | if (dev) |
488 | ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index); | |
4cc987ea | 489 | rcu_read_unlock(); |
12d23384 NB |
490 | return ret; |
491 | } | |
12d23384 | 492 | |
2eafd729 CH |
493 | static ssize_t target_stat_port_busy_count_show(struct config_item *item, |
494 | char *page) | |
12d23384 | 495 | { |
2eafd729 | 496 | struct se_lun *lun = to_stat_port(item); |
adf653f9 CH |
497 | struct se_device *dev; |
498 | ssize_t ret = -ENODEV; | |
12d23384 | 499 | |
4cc987ea NB |
500 | rcu_read_lock(); |
501 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
502 | if (dev) { |
503 | /* FIXME: scsiPortBusyStatuses */ | |
504 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
12d23384 | 505 | } |
4cc987ea | 506 | rcu_read_unlock(); |
12d23384 NB |
507 | return ret; |
508 | } | |
12d23384 | 509 | |
2eafd729 CH |
510 | CONFIGFS_ATTR_RO(target_stat_port_, inst); |
511 | CONFIGFS_ATTR_RO(target_stat_port_, dev); | |
512 | CONFIGFS_ATTR_RO(target_stat_port_, indx); | |
513 | CONFIGFS_ATTR_RO(target_stat_port_, role); | |
514 | CONFIGFS_ATTR_RO(target_stat_port_, busy_count); | |
12d23384 NB |
515 | |
516 | static struct configfs_attribute *target_stat_scsi_port_attrs[] = { | |
2eafd729 CH |
517 | &target_stat_port_attr_inst, |
518 | &target_stat_port_attr_dev, | |
519 | &target_stat_port_attr_indx, | |
520 | &target_stat_port_attr_role, | |
521 | &target_stat_port_attr_busy_count, | |
12d23384 NB |
522 | NULL, |
523 | }; | |
524 | ||
12d23384 | 525 | static struct config_item_type target_stat_scsi_port_cit = { |
12d23384 NB |
526 | .ct_attrs = target_stat_scsi_port_attrs, |
527 | .ct_owner = THIS_MODULE, | |
528 | }; | |
529 | ||
530 | /* | |
531 | * SCSI Target Port Table | |
532 | */ | |
2eafd729 CH |
533 | static struct se_lun *to_stat_tgt_port(struct config_item *item) |
534 | { | |
535 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), | |
536 | struct se_port_stat_grps, scsi_tgt_port_group); | |
537 | return container_of(pgrps, struct se_lun, port_stat_grps); | |
538 | } | |
539 | ||
540 | static ssize_t target_stat_tgt_port_inst_show(struct config_item *item, | |
541 | char *page) | |
542 | { | |
543 | struct se_lun *lun = to_stat_tgt_port(item); | |
adf653f9 CH |
544 | struct se_device *dev; |
545 | ssize_t ret = -ENODEV; | |
12d23384 | 546 | |
4cc987ea NB |
547 | rcu_read_lock(); |
548 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 549 | if (dev) |
4cc987ea NB |
550 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index); |
551 | rcu_read_unlock(); | |
12d23384 NB |
552 | return ret; |
553 | } | |
12d23384 | 554 | |
2eafd729 CH |
555 | static ssize_t target_stat_tgt_port_dev_show(struct config_item *item, |
556 | char *page) | |
12d23384 | 557 | { |
2eafd729 | 558 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
559 | struct se_device *dev; |
560 | ssize_t ret = -ENODEV; | |
12d23384 | 561 | |
4cc987ea NB |
562 | rcu_read_lock(); |
563 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
564 | if (dev) |
565 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | |
4cc987ea | 566 | rcu_read_unlock(); |
12d23384 NB |
567 | return ret; |
568 | } | |
12d23384 | 569 | |
2eafd729 CH |
570 | static ssize_t target_stat_tgt_port_indx_show(struct config_item *item, |
571 | char *page) | |
12d23384 | 572 | { |
2eafd729 | 573 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
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, "%u\n", lun->lun_rtpi); | |
4cc987ea | 581 | rcu_read_unlock(); |
12d23384 NB |
582 | return ret; |
583 | } | |
12d23384 | 584 | |
2eafd729 CH |
585 | static ssize_t target_stat_tgt_port_name_show(struct config_item *item, |
586 | char *page) | |
12d23384 | 587 | { |
2eafd729 | 588 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
589 | struct se_portal_group *tpg = lun->lun_tpg; |
590 | struct se_device *dev; | |
591 | ssize_t ret = -ENODEV; | |
12d23384 | 592 | |
4cc987ea NB |
593 | rcu_read_lock(); |
594 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
595 | if (dev) |
596 | ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n", | |
597 | tpg->se_tpg_tfo->get_fabric_name(), | |
598 | lun->lun_rtpi); | |
4cc987ea | 599 | rcu_read_unlock(); |
12d23384 NB |
600 | return ret; |
601 | } | |
12d23384 | 602 | |
2eafd729 CH |
603 | static ssize_t target_stat_tgt_port_port_index_show(struct config_item *item, |
604 | char *page) | |
12d23384 | 605 | { |
2eafd729 | 606 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
607 | struct se_portal_group *tpg = lun->lun_tpg; |
608 | struct se_device *dev; | |
609 | ssize_t ret = -ENODEV; | |
12d23384 | 610 | |
4cc987ea NB |
611 | rcu_read_lock(); |
612 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
613 | if (dev) |
614 | ret = snprintf(page, PAGE_SIZE, "%s%s%d\n", | |
615 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+", | |
616 | tpg->se_tpg_tfo->tpg_get_tag(tpg)); | |
4cc987ea | 617 | rcu_read_unlock(); |
12d23384 NB |
618 | return ret; |
619 | } | |
12d23384 | 620 | |
2eafd729 CH |
621 | static ssize_t target_stat_tgt_port_in_cmds_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 | 630 | if (dev) |
4cc987ea NB |
631 | ret = snprintf(page, PAGE_SIZE, "%lu\n", |
632 | atomic_long_read(&lun->lun_stats.cmd_pdus)); | |
633 | rcu_read_unlock(); | |
12d23384 NB |
634 | return ret; |
635 | } | |
12d23384 | 636 | |
2eafd729 CH |
637 | static ssize_t target_stat_tgt_port_write_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.rx_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_read_mbytes_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 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
4cc987ea NB |
664 | (u32)(atomic_long_read(&lun->lun_stats.tx_data_octets) >> 20)); |
665 | rcu_read_unlock(); | |
12d23384 NB |
666 | return ret; |
667 | } | |
12d23384 | 668 | |
2eafd729 CH |
669 | static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item, |
670 | char *page) | |
12d23384 | 671 | { |
2eafd729 | 672 | struct se_lun *lun = to_stat_tgt_port(item); |
adf653f9 CH |
673 | struct se_device *dev; |
674 | ssize_t ret = -ENODEV; | |
12d23384 | 675 | |
4cc987ea NB |
676 | rcu_read_lock(); |
677 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
678 | if (dev) { |
679 | /* FIXME: scsiTgtPortHsInCommands */ | |
680 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
12d23384 | 681 | } |
4cc987ea | 682 | rcu_read_unlock(); |
12d23384 NB |
683 | return ret; |
684 | } | |
12d23384 | 685 | |
2eafd729 CH |
686 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, inst); |
687 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, dev); | |
688 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, indx); | |
689 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, name); | |
690 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, port_index); | |
691 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, in_cmds); | |
692 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, write_mbytes); | |
693 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, read_mbytes); | |
694 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, hs_in_cmds); | |
12d23384 NB |
695 | |
696 | static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = { | |
2eafd729 CH |
697 | &target_stat_tgt_port_attr_inst, |
698 | &target_stat_tgt_port_attr_dev, | |
699 | &target_stat_tgt_port_attr_indx, | |
700 | &target_stat_tgt_port_attr_name, | |
701 | &target_stat_tgt_port_attr_port_index, | |
702 | &target_stat_tgt_port_attr_in_cmds, | |
703 | &target_stat_tgt_port_attr_write_mbytes, | |
704 | &target_stat_tgt_port_attr_read_mbytes, | |
705 | &target_stat_tgt_port_attr_hs_in_cmds, | |
12d23384 NB |
706 | NULL, |
707 | }; | |
708 | ||
12d23384 | 709 | static struct config_item_type target_stat_scsi_tgt_port_cit = { |
12d23384 NB |
710 | .ct_attrs = target_stat_scsi_tgt_port_attrs, |
711 | .ct_owner = THIS_MODULE, | |
712 | }; | |
713 | ||
714 | /* | |
715 | * SCSI Transport Table | |
2eafd729 CH |
716 | */ |
717 | static struct se_lun *to_transport_stat(struct config_item *item) | |
718 | { | |
719 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), | |
720 | struct se_port_stat_grps, scsi_transport_group); | |
721 | return container_of(pgrps, struct se_lun, port_stat_grps); | |
722 | } | |
723 | ||
724 | static ssize_t target_stat_transport_inst_show(struct config_item *item, | |
725 | char *page) | |
726 | { | |
727 | struct se_lun *lun = to_transport_stat(item); | |
adf653f9 CH |
728 | struct se_device *dev; |
729 | ssize_t ret = -ENODEV; | |
12d23384 | 730 | |
4cc987ea NB |
731 | rcu_read_lock(); |
732 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 | 733 | if (dev) |
4cc987ea NB |
734 | ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index); |
735 | rcu_read_unlock(); | |
12d23384 NB |
736 | return ret; |
737 | } | |
12d23384 | 738 | |
2eafd729 CH |
739 | static ssize_t target_stat_transport_device_show(struct config_item *item, |
740 | char *page) | |
12d23384 | 741 | { |
2eafd729 | 742 | struct se_lun *lun = to_transport_stat(item); |
adf653f9 CH |
743 | struct se_device *dev; |
744 | struct se_portal_group *tpg = lun->lun_tpg; | |
745 | ssize_t ret = -ENODEV; | |
12d23384 | 746 | |
4cc987ea NB |
747 | rcu_read_lock(); |
748 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
749 | if (dev) { |
750 | /* scsiTransportType */ | |
751 | ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n", | |
752 | tpg->se_tpg_tfo->get_fabric_name()); | |
12d23384 | 753 | } |
4cc987ea | 754 | rcu_read_unlock(); |
12d23384 NB |
755 | return ret; |
756 | } | |
12d23384 | 757 | |
2eafd729 CH |
758 | static ssize_t target_stat_transport_indx_show(struct config_item *item, |
759 | char *page) | |
12d23384 | 760 | { |
2eafd729 | 761 | struct se_lun *lun = to_transport_stat(item); |
adf653f9 CH |
762 | struct se_device *dev; |
763 | struct se_portal_group *tpg = lun->lun_tpg; | |
764 | ssize_t ret = -ENODEV; | |
12d23384 | 765 | |
4cc987ea NB |
766 | rcu_read_lock(); |
767 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
768 | if (dev) |
769 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
770 | tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); | |
4cc987ea | 771 | rcu_read_unlock(); |
12d23384 NB |
772 | return ret; |
773 | } | |
12d23384 | 774 | |
2eafd729 CH |
775 | static ssize_t target_stat_transport_dev_name_show(struct config_item *item, |
776 | char *page) | |
12d23384 | 777 | { |
2eafd729 | 778 | struct se_lun *lun = to_transport_stat(item); |
4cc987ea | 779 | struct se_device *dev; |
adf653f9 | 780 | struct se_portal_group *tpg = lun->lun_tpg; |
12d23384 | 781 | struct t10_wwn *wwn; |
adf653f9 | 782 | ssize_t ret = -ENODEV; |
12d23384 | 783 | |
4cc987ea NB |
784 | rcu_read_lock(); |
785 | dev = rcu_dereference(lun->lun_se_dev); | |
adf653f9 CH |
786 | if (dev) { |
787 | wwn = &dev->t10_wwn; | |
788 | /* scsiTransportDevName */ | |
789 | ret = snprintf(page, PAGE_SIZE, "%s+%s\n", | |
790 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), | |
791 | (strlen(wwn->unit_serial)) ? wwn->unit_serial : | |
792 | wwn->vendor); | |
12d23384 | 793 | } |
4cc987ea | 794 | rcu_read_unlock(); |
12d23384 NB |
795 | return ret; |
796 | } | |
12d23384 | 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); | |
12d23384 NB |
802 | |
803 | static struct configfs_attribute *target_stat_scsi_transport_attrs[] = { | |
2eafd729 CH |
804 | &target_stat_transport_attr_inst, |
805 | &target_stat_transport_attr_device, | |
806 | &target_stat_transport_attr_indx, | |
807 | &target_stat_transport_attr_dev_name, | |
12d23384 NB |
808 | NULL, |
809 | }; | |
810 | ||
12d23384 | 811 | static struct config_item_type target_stat_scsi_transport_cit = { |
12d23384 NB |
812 | .ct_attrs = target_stat_scsi_transport_attrs, |
813 | .ct_owner = THIS_MODULE, | |
814 | }; | |
815 | ||
816 | /* | |
817 | * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup | |
818 | * the target port statistics groups + configfs CITs located in target_core_stat.c | |
819 | */ | |
820 | void target_stat_setup_port_default_groups(struct se_lun *lun) | |
821 | { | |
e3d6f909 | 822 | config_group_init_type_name(&lun->port_stat_grps.scsi_port_group, |
12d23384 | 823 | "scsi_port", &target_stat_scsi_port_cit); |
1ae1602d CH |
824 | configfs_add_default_group(&lun->port_stat_grps.scsi_port_group, |
825 | &lun->port_stat_grps.stat_group); | |
826 | ||
e3d6f909 | 827 | config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group, |
12d23384 | 828 | "scsi_tgt_port", &target_stat_scsi_tgt_port_cit); |
1ae1602d CH |
829 | configfs_add_default_group(&lun->port_stat_grps.scsi_tgt_port_group, |
830 | &lun->port_stat_grps.stat_group); | |
831 | ||
e3d6f909 | 832 | config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group, |
12d23384 | 833 | "scsi_transport", &target_stat_scsi_transport_cit); |
1ae1602d CH |
834 | configfs_add_default_group(&lun->port_stat_grps.scsi_transport_group, |
835 | &lun->port_stat_grps.stat_group); | |
12d23384 NB |
836 | } |
837 | ||
838 | /* | |
839 | * SCSI Authorized Initiator Table | |
840 | */ | |
841 | ||
2eafd729 CH |
842 | static struct se_lun_acl *auth_to_lacl(struct config_item *item) |
843 | { | |
844 | struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), | |
845 | struct se_ml_stat_grps, scsi_auth_intr_group); | |
846 | return container_of(lgrps, struct se_lun_acl, ml_stat_grps); | |
847 | } | |
848 | ||
849 | static ssize_t target_stat_auth_inst_show(struct config_item *item, | |
850 | char *page) | |
851 | { | |
852 | struct se_lun_acl *lacl = auth_to_lacl(item); | |
12d23384 NB |
853 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
854 | struct se_dev_entry *deve; | |
855 | struct se_portal_group *tpg; | |
856 | ssize_t ret; | |
857 | ||
29a05dee NB |
858 | rcu_read_lock(); |
859 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
860 | if (!deve) { | |
861 | rcu_read_unlock(); | |
12d23384 NB |
862 | return -ENODEV; |
863 | } | |
864 | tpg = nacl->se_tpg; | |
865 | /* scsiInstIndex */ | |
866 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
e3d6f909 | 867 | tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); |
29a05dee | 868 | rcu_read_unlock(); |
12d23384 NB |
869 | return ret; |
870 | } | |
12d23384 | 871 | |
2eafd729 CH |
872 | static ssize_t target_stat_auth_dev_show(struct config_item *item, |
873 | char *page) | |
12d23384 | 874 | { |
2eafd729 | 875 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
876 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
877 | struct se_dev_entry *deve; | |
878 | struct se_lun *lun; | |
12d23384 NB |
879 | ssize_t ret; |
880 | ||
29a05dee NB |
881 | rcu_read_lock(); |
882 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
883 | if (!deve) { | |
884 | rcu_read_unlock(); | |
12d23384 NB |
885 | return -ENODEV; |
886 | } | |
29a05dee | 887 | lun = rcu_dereference(deve->se_lun); |
12d23384 | 888 | /* scsiDeviceIndex */ |
29a05dee NB |
889 | ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index); |
890 | rcu_read_unlock(); | |
12d23384 NB |
891 | return ret; |
892 | } | |
12d23384 | 893 | |
2eafd729 CH |
894 | static ssize_t target_stat_auth_port_show(struct config_item *item, |
895 | char *page) | |
12d23384 | 896 | { |
2eafd729 | 897 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
898 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
899 | struct se_dev_entry *deve; | |
900 | struct se_portal_group *tpg; | |
901 | ssize_t ret; | |
902 | ||
29a05dee NB |
903 | rcu_read_lock(); |
904 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
905 | if (!deve) { | |
906 | rcu_read_unlock(); | |
12d23384 NB |
907 | return -ENODEV; |
908 | } | |
909 | tpg = nacl->se_tpg; | |
910 | /* scsiAuthIntrTgtPortIndex */ | |
e3d6f909 | 911 | ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg)); |
29a05dee | 912 | rcu_read_unlock(); |
12d23384 NB |
913 | return ret; |
914 | } | |
12d23384 | 915 | |
2eafd729 CH |
916 | static ssize_t target_stat_auth_indx_show(struct config_item *item, |
917 | char *page) | |
12d23384 | 918 | { |
2eafd729 | 919 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
920 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
921 | struct se_dev_entry *deve; | |
922 | ssize_t ret; | |
923 | ||
29a05dee NB |
924 | rcu_read_lock(); |
925 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
926 | if (!deve) { | |
927 | rcu_read_unlock(); | |
12d23384 NB |
928 | return -ENODEV; |
929 | } | |
930 | /* scsiAuthIntrIndex */ | |
931 | ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index); | |
29a05dee | 932 | rcu_read_unlock(); |
12d23384 NB |
933 | return ret; |
934 | } | |
12d23384 | 935 | |
2eafd729 CH |
936 | static ssize_t target_stat_auth_dev_or_port_show(struct config_item *item, |
937 | char *page) | |
12d23384 | 938 | { |
2eafd729 | 939 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
940 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
941 | struct se_dev_entry *deve; | |
942 | ssize_t ret; | |
943 | ||
29a05dee NB |
944 | rcu_read_lock(); |
945 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
946 | if (!deve) { | |
947 | rcu_read_unlock(); | |
12d23384 NB |
948 | return -ENODEV; |
949 | } | |
950 | /* scsiAuthIntrDevOrPort */ | |
951 | ret = snprintf(page, PAGE_SIZE, "%u\n", 1); | |
29a05dee | 952 | rcu_read_unlock(); |
12d23384 NB |
953 | return ret; |
954 | } | |
12d23384 | 955 | |
2eafd729 CH |
956 | static ssize_t target_stat_auth_intr_name_show(struct config_item *item, |
957 | char *page) | |
12d23384 | 958 | { |
2eafd729 | 959 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
960 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
961 | struct se_dev_entry *deve; | |
962 | ssize_t ret; | |
963 | ||
29a05dee NB |
964 | rcu_read_lock(); |
965 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
966 | if (!deve) { | |
967 | rcu_read_unlock(); | |
12d23384 NB |
968 | return -ENODEV; |
969 | } | |
970 | /* scsiAuthIntrName */ | |
971 | ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname); | |
29a05dee | 972 | rcu_read_unlock(); |
12d23384 NB |
973 | return ret; |
974 | } | |
12d23384 | 975 | |
2eafd729 CH |
976 | static ssize_t target_stat_auth_map_indx_show(struct config_item *item, |
977 | char *page) | |
12d23384 | 978 | { |
2eafd729 | 979 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
980 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
981 | struct se_dev_entry *deve; | |
982 | ssize_t ret; | |
983 | ||
29a05dee NB |
984 | rcu_read_lock(); |
985 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
986 | if (!deve) { | |
987 | rcu_read_unlock(); | |
12d23384 NB |
988 | return -ENODEV; |
989 | } | |
990 | /* FIXME: scsiAuthIntrLunMapIndex */ | |
991 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
29a05dee | 992 | rcu_read_unlock(); |
12d23384 NB |
993 | return ret; |
994 | } | |
12d23384 | 995 | |
2eafd729 CH |
996 | static ssize_t target_stat_auth_att_count_show(struct config_item *item, |
997 | char *page) | |
12d23384 | 998 | { |
2eafd729 | 999 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1000 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1001 | struct se_dev_entry *deve; | |
1002 | ssize_t ret; | |
1003 | ||
29a05dee NB |
1004 | rcu_read_lock(); |
1005 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1006 | if (!deve) { | |
1007 | rcu_read_unlock(); | |
12d23384 NB |
1008 | return -ENODEV; |
1009 | } | |
1010 | /* scsiAuthIntrAttachedTimes */ | |
1011 | ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count); | |
29a05dee | 1012 | rcu_read_unlock(); |
12d23384 NB |
1013 | return ret; |
1014 | } | |
12d23384 | 1015 | |
2eafd729 CH |
1016 | static ssize_t target_stat_auth_num_cmds_show(struct config_item *item, |
1017 | char *page) | |
12d23384 | 1018 | { |
2eafd729 | 1019 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1020 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1021 | struct se_dev_entry *deve; | |
1022 | ssize_t ret; | |
1023 | ||
29a05dee NB |
1024 | rcu_read_lock(); |
1025 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1026 | if (!deve) { | |
1027 | rcu_read_unlock(); | |
12d23384 NB |
1028 | return -ENODEV; |
1029 | } | |
1030 | /* scsiAuthIntrOutCommands */ | |
29a05dee NB |
1031 | ret = snprintf(page, PAGE_SIZE, "%lu\n", |
1032 | atomic_long_read(&deve->total_cmds)); | |
1033 | rcu_read_unlock(); | |
12d23384 NB |
1034 | return ret; |
1035 | } | |
12d23384 | 1036 | |
2eafd729 CH |
1037 | static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item, |
1038 | char *page) | |
12d23384 | 1039 | { |
2eafd729 | 1040 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1041 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1042 | struct se_dev_entry *deve; | |
1043 | ssize_t ret; | |
1044 | ||
29a05dee NB |
1045 | rcu_read_lock(); |
1046 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1047 | if (!deve) { | |
1048 | rcu_read_unlock(); | |
12d23384 NB |
1049 | return -ENODEV; |
1050 | } | |
1051 | /* scsiAuthIntrReadMegaBytes */ | |
29a05dee NB |
1052 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
1053 | (u32)(atomic_long_read(&deve->read_bytes) >> 20)); | |
1054 | rcu_read_unlock(); | |
12d23384 NB |
1055 | return ret; |
1056 | } | |
12d23384 | 1057 | |
2eafd729 CH |
1058 | static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item, |
1059 | char *page) | |
12d23384 | 1060 | { |
2eafd729 | 1061 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1062 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1063 | struct se_dev_entry *deve; | |
1064 | ssize_t ret; | |
1065 | ||
29a05dee NB |
1066 | rcu_read_lock(); |
1067 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1068 | if (!deve) { | |
1069 | rcu_read_unlock(); | |
12d23384 NB |
1070 | return -ENODEV; |
1071 | } | |
1072 | /* scsiAuthIntrWrittenMegaBytes */ | |
29a05dee NB |
1073 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
1074 | (u32)(atomic_long_read(&deve->write_bytes) >> 20)); | |
1075 | rcu_read_unlock(); | |
12d23384 NB |
1076 | return ret; |
1077 | } | |
12d23384 | 1078 | |
2eafd729 CH |
1079 | static ssize_t target_stat_auth_hs_num_cmds_show(struct config_item *item, |
1080 | char *page) | |
12d23384 | 1081 | { |
2eafd729 | 1082 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1083 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1084 | struct se_dev_entry *deve; | |
1085 | ssize_t ret; | |
1086 | ||
29a05dee NB |
1087 | rcu_read_lock(); |
1088 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1089 | if (!deve) { | |
1090 | rcu_read_unlock(); | |
12d23384 NB |
1091 | return -ENODEV; |
1092 | } | |
1093 | /* FIXME: scsiAuthIntrHSOutCommands */ | |
1094 | ret = snprintf(page, PAGE_SIZE, "%u\n", 0); | |
29a05dee | 1095 | rcu_read_unlock(); |
12d23384 NB |
1096 | return ret; |
1097 | } | |
12d23384 | 1098 | |
2eafd729 CH |
1099 | static ssize_t target_stat_auth_creation_time_show(struct config_item *item, |
1100 | char *page) | |
12d23384 | 1101 | { |
2eafd729 | 1102 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1103 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1104 | struct se_dev_entry *deve; | |
1105 | ssize_t ret; | |
1106 | ||
29a05dee NB |
1107 | rcu_read_lock(); |
1108 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1109 | if (!deve) { | |
1110 | rcu_read_unlock(); | |
12d23384 NB |
1111 | return -ENODEV; |
1112 | } | |
1113 | /* scsiAuthIntrLastCreation */ | |
1114 | ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time - | |
1115 | INITIAL_JIFFIES) * 100 / HZ)); | |
29a05dee | 1116 | rcu_read_unlock(); |
12d23384 NB |
1117 | return ret; |
1118 | } | |
12d23384 | 1119 | |
2eafd729 CH |
1120 | static ssize_t target_stat_auth_row_status_show(struct config_item *item, |
1121 | char *page) | |
12d23384 | 1122 | { |
2eafd729 | 1123 | struct se_lun_acl *lacl = auth_to_lacl(item); |
12d23384 NB |
1124 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1125 | struct se_dev_entry *deve; | |
1126 | ssize_t ret; | |
1127 | ||
29a05dee NB |
1128 | rcu_read_lock(); |
1129 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1130 | if (!deve) { | |
1131 | rcu_read_unlock(); | |
12d23384 NB |
1132 | return -ENODEV; |
1133 | } | |
1134 | /* FIXME: scsiAuthIntrRowStatus */ | |
1135 | ret = snprintf(page, PAGE_SIZE, "Ready\n"); | |
29a05dee | 1136 | rcu_read_unlock(); |
12d23384 NB |
1137 | return ret; |
1138 | } | |
12d23384 | 1139 | |
2eafd729 CH |
1140 | CONFIGFS_ATTR_RO(target_stat_auth_, inst); |
1141 | CONFIGFS_ATTR_RO(target_stat_auth_, dev); | |
1142 | CONFIGFS_ATTR_RO(target_stat_auth_, port); | |
1143 | CONFIGFS_ATTR_RO(target_stat_auth_, indx); | |
1144 | CONFIGFS_ATTR_RO(target_stat_auth_, dev_or_port); | |
1145 | CONFIGFS_ATTR_RO(target_stat_auth_, intr_name); | |
1146 | CONFIGFS_ATTR_RO(target_stat_auth_, map_indx); | |
1147 | CONFIGFS_ATTR_RO(target_stat_auth_, att_count); | |
1148 | CONFIGFS_ATTR_RO(target_stat_auth_, num_cmds); | |
1149 | CONFIGFS_ATTR_RO(target_stat_auth_, read_mbytes); | |
1150 | CONFIGFS_ATTR_RO(target_stat_auth_, write_mbytes); | |
1151 | CONFIGFS_ATTR_RO(target_stat_auth_, hs_num_cmds); | |
1152 | CONFIGFS_ATTR_RO(target_stat_auth_, creation_time); | |
1153 | CONFIGFS_ATTR_RO(target_stat_auth_, row_status); | |
12d23384 NB |
1154 | |
1155 | static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = { | |
2eafd729 CH |
1156 | &target_stat_auth_attr_inst, |
1157 | &target_stat_auth_attr_dev, | |
1158 | &target_stat_auth_attr_port, | |
1159 | &target_stat_auth_attr_indx, | |
1160 | &target_stat_auth_attr_dev_or_port, | |
1161 | &target_stat_auth_attr_intr_name, | |
1162 | &target_stat_auth_attr_map_indx, | |
1163 | &target_stat_auth_attr_att_count, | |
1164 | &target_stat_auth_attr_num_cmds, | |
1165 | &target_stat_auth_attr_read_mbytes, | |
1166 | &target_stat_auth_attr_write_mbytes, | |
1167 | &target_stat_auth_attr_hs_num_cmds, | |
1168 | &target_stat_auth_attr_creation_time, | |
1169 | &target_stat_auth_attr_row_status, | |
12d23384 NB |
1170 | NULL, |
1171 | }; | |
1172 | ||
12d23384 | 1173 | static struct config_item_type target_stat_scsi_auth_intr_cit = { |
12d23384 NB |
1174 | .ct_attrs = target_stat_scsi_auth_intr_attrs, |
1175 | .ct_owner = THIS_MODULE, | |
1176 | }; | |
1177 | ||
1178 | /* | |
1179 | * SCSI Attached Initiator Port Table | |
1180 | */ | |
1181 | ||
2eafd729 CH |
1182 | static struct se_lun_acl *iport_to_lacl(struct config_item *item) |
1183 | { | |
1184 | struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), | |
1185 | struct se_ml_stat_grps, scsi_att_intr_port_group); | |
1186 | return container_of(lgrps, struct se_lun_acl, ml_stat_grps); | |
1187 | } | |
1188 | ||
1189 | static ssize_t target_stat_iport_inst_show(struct config_item *item, | |
1190 | char *page) | |
1191 | { | |
1192 | struct se_lun_acl *lacl = iport_to_lacl(item); | |
12d23384 NB |
1193 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1194 | struct se_dev_entry *deve; | |
1195 | struct se_portal_group *tpg; | |
1196 | ssize_t ret; | |
1197 | ||
29a05dee NB |
1198 | rcu_read_lock(); |
1199 | deve = target_nacl_find_deve(nacl, lacl->mapped_lun); | |
1200 | if (!deve) { | |
1201 | rcu_read_unlock(); | |
12d23384 NB |
1202 | return -ENODEV; |
1203 | } | |
1204 | tpg = nacl->se_tpg; | |
1205 | /* scsiInstIndex */ | |
1206 | ret = snprintf(page, PAGE_SIZE, "%u\n", | |
e3d6f909 | 1207 | tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); |
29a05dee | 1208 | rcu_read_unlock(); |
12d23384 NB |
1209 | return ret; |
1210 | } | |
12d23384 | 1211 | |
2eafd729 CH |
1212 | static ssize_t target_stat_iport_dev_show(struct config_item *item, |
1213 | char *page) | |
12d23384 | 1214 | { |
2eafd729 | 1215 | struct se_lun_acl *lacl = iport_to_lacl(item); |
12d23384 NB |
1216 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1217 | struct se_dev_entry *deve; | |
1218 | struct se_lun *lun; | |
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 | } | |
29a05dee | 1227 | lun = rcu_dereference(deve->se_lun); |
12d23384 | 1228 | /* scsiDeviceIndex */ |
29a05dee NB |
1229 | ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index); |
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 | ||
12d23384 | 1345 | static 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 | } |