1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*******************************************************************************
3 * Modern ConfigFS group context specific iSCSI statistics based on original
4 * iscsi_target_mib.c code
6 * Copyright (c) 2011-2013 Datera, Inc.
8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
10 ******************************************************************************/
12 #include <linux/configfs.h>
13 #include <linux/export.h>
14 #include <scsi/iscsi_proto.h>
15 #include <target/target_core_base.h>
17 #include <target/iscsi/iscsi_target_core.h>
18 #include "iscsi_target_parameters.h"
19 #include "iscsi_target_device.h"
20 #include "iscsi_target_tpg.h"
21 #include "iscsi_target_util.h"
22 #include <target/iscsi/iscsi_target_stat.h>
24 #ifndef INITIAL_JIFFIES
25 #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
28 /* Instance Attributes Table */
29 #define ISCSI_INST_NUM_NODES 1
30 #define ISCSI_INST_DESCR "Storage Engine Target"
31 #define ISCSI_INST_LAST_FAILURE_TYPE 0
32 #define ISCSI_DISCONTINUITY_TIME 0
34 #define ISCSI_NODE_INDEX 1
36 #define ISPRINT(a) ((a >= ' ') && (a <= '~'))
38 /****************************************************************************
40 ****************************************************************************/
42 * Instance Attributes Table
44 static struct iscsi_tiqn
*iscsi_instance_tiqn(struct config_item
*item
)
46 struct iscsi_wwn_stat_grps
*igrps
= container_of(to_config_group(item
),
47 struct iscsi_wwn_stat_grps
, iscsi_instance_group
);
48 return container_of(igrps
, struct iscsi_tiqn
, tiqn_stat_grps
);
51 static ssize_t
iscsi_stat_instance_inst_show(struct config_item
*item
,
54 return snprintf(page
, PAGE_SIZE
, "%u\n",
55 iscsi_instance_tiqn(item
)->tiqn_index
);
58 static ssize_t
iscsi_stat_instance_min_ver_show(struct config_item
*item
,
61 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_DRAFT20_VERSION
);
64 static ssize_t
iscsi_stat_instance_max_ver_show(struct config_item
*item
,
67 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_DRAFT20_VERSION
);
70 static ssize_t
iscsi_stat_instance_portals_show(struct config_item
*item
,
73 return snprintf(page
, PAGE_SIZE
, "%u\n",
74 iscsi_instance_tiqn(item
)->tiqn_num_tpg_nps
);
77 static ssize_t
iscsi_stat_instance_nodes_show(struct config_item
*item
,
80 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_INST_NUM_NODES
);
83 static ssize_t
iscsi_stat_instance_sessions_show(struct config_item
*item
,
86 return snprintf(page
, PAGE_SIZE
, "%u\n",
87 iscsi_instance_tiqn(item
)->tiqn_nsessions
);
90 static ssize_t
iscsi_stat_instance_fail_sess_show(struct config_item
*item
,
93 struct iscsi_tiqn
*tiqn
= iscsi_instance_tiqn(item
);
94 struct iscsi_sess_err_stats
*sess_err
= &tiqn
->sess_err_stats
;
97 spin_lock_bh(&sess_err
->lock
);
98 sess_err_count
= (sess_err
->digest_errors
+
99 sess_err
->cxn_timeout_errors
+
100 sess_err
->pdu_format_errors
);
101 spin_unlock_bh(&sess_err
->lock
);
103 return snprintf(page
, PAGE_SIZE
, "%u\n", sess_err_count
);
106 static ssize_t
iscsi_stat_instance_fail_type_show(struct config_item
*item
,
109 struct iscsi_tiqn
*tiqn
= iscsi_instance_tiqn(item
);
110 struct iscsi_sess_err_stats
*sess_err
= &tiqn
->sess_err_stats
;
112 return snprintf(page
, PAGE_SIZE
, "%u\n",
113 sess_err
->last_sess_failure_type
);
116 static ssize_t
iscsi_stat_instance_fail_rem_name_show(struct config_item
*item
,
119 struct iscsi_tiqn
*tiqn
= iscsi_instance_tiqn(item
);
120 struct iscsi_sess_err_stats
*sess_err
= &tiqn
->sess_err_stats
;
122 return snprintf(page
, PAGE_SIZE
, "%s\n",
123 sess_err
->last_sess_fail_rem_name
[0] ?
124 sess_err
->last_sess_fail_rem_name
: NONE
);
127 static ssize_t
iscsi_stat_instance_disc_time_show(struct config_item
*item
,
130 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_DISCONTINUITY_TIME
);
133 static ssize_t
iscsi_stat_instance_description_show(struct config_item
*item
,
136 return snprintf(page
, PAGE_SIZE
, "%s\n", ISCSI_INST_DESCR
);
139 static ssize_t
iscsi_stat_instance_vendor_show(struct config_item
*item
,
142 return snprintf(page
, PAGE_SIZE
, "Datera, Inc. iSCSI-Target\n");
145 static ssize_t
iscsi_stat_instance_version_show(struct config_item
*item
,
148 return snprintf(page
, PAGE_SIZE
, "%s\n", ISCSIT_VERSION
);
151 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, inst
);
152 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, min_ver
);
153 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, max_ver
);
154 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, portals
);
155 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, nodes
);
156 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, sessions
);
157 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, fail_sess
);
158 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, fail_type
);
159 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, fail_rem_name
);
160 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, disc_time
);
161 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, description
);
162 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, vendor
);
163 CONFIGFS_ATTR_RO(iscsi_stat_instance_
, version
);
165 static struct configfs_attribute
*iscsi_stat_instance_attrs
[] = {
166 &iscsi_stat_instance_attr_inst
,
167 &iscsi_stat_instance_attr_min_ver
,
168 &iscsi_stat_instance_attr_max_ver
,
169 &iscsi_stat_instance_attr_portals
,
170 &iscsi_stat_instance_attr_nodes
,
171 &iscsi_stat_instance_attr_sessions
,
172 &iscsi_stat_instance_attr_fail_sess
,
173 &iscsi_stat_instance_attr_fail_type
,
174 &iscsi_stat_instance_attr_fail_rem_name
,
175 &iscsi_stat_instance_attr_disc_time
,
176 &iscsi_stat_instance_attr_description
,
177 &iscsi_stat_instance_attr_vendor
,
178 &iscsi_stat_instance_attr_version
,
182 const struct config_item_type iscsi_stat_instance_cit
= {
183 .ct_attrs
= iscsi_stat_instance_attrs
,
184 .ct_owner
= THIS_MODULE
,
188 * Instance Session Failure Stats Table
190 static struct iscsi_tiqn
*iscsi_sess_err_tiqn(struct config_item
*item
)
192 struct iscsi_wwn_stat_grps
*igrps
= container_of(to_config_group(item
),
193 struct iscsi_wwn_stat_grps
, iscsi_sess_err_group
);
194 return container_of(igrps
, struct iscsi_tiqn
, tiqn_stat_grps
);
197 static ssize_t
iscsi_stat_sess_err_inst_show(struct config_item
*item
,
200 return snprintf(page
, PAGE_SIZE
, "%u\n",
201 iscsi_sess_err_tiqn(item
)->tiqn_index
);
204 static ssize_t
iscsi_stat_sess_err_digest_errors_show(struct config_item
*item
,
207 struct iscsi_tiqn
*tiqn
= iscsi_sess_err_tiqn(item
);
208 struct iscsi_sess_err_stats
*sess_err
= &tiqn
->sess_err_stats
;
210 return snprintf(page
, PAGE_SIZE
, "%u\n", sess_err
->digest_errors
);
213 static ssize_t
iscsi_stat_sess_err_cxn_errors_show(struct config_item
*item
,
216 struct iscsi_tiqn
*tiqn
= iscsi_sess_err_tiqn(item
);
217 struct iscsi_sess_err_stats
*sess_err
= &tiqn
->sess_err_stats
;
219 return snprintf(page
, PAGE_SIZE
, "%u\n", sess_err
->cxn_timeout_errors
);
222 static ssize_t
iscsi_stat_sess_err_format_errors_show(struct config_item
*item
,
225 struct iscsi_tiqn
*tiqn
= iscsi_sess_err_tiqn(item
);
226 struct iscsi_sess_err_stats
*sess_err
= &tiqn
->sess_err_stats
;
228 return snprintf(page
, PAGE_SIZE
, "%u\n", sess_err
->pdu_format_errors
);
231 CONFIGFS_ATTR_RO(iscsi_stat_sess_err_
, inst
);
232 CONFIGFS_ATTR_RO(iscsi_stat_sess_err_
, digest_errors
);
233 CONFIGFS_ATTR_RO(iscsi_stat_sess_err_
, cxn_errors
);
234 CONFIGFS_ATTR_RO(iscsi_stat_sess_err_
, format_errors
);
236 static struct configfs_attribute
*iscsi_stat_sess_err_attrs
[] = {
237 &iscsi_stat_sess_err_attr_inst
,
238 &iscsi_stat_sess_err_attr_digest_errors
,
239 &iscsi_stat_sess_err_attr_cxn_errors
,
240 &iscsi_stat_sess_err_attr_format_errors
,
244 const struct config_item_type iscsi_stat_sess_err_cit
= {
245 .ct_attrs
= iscsi_stat_sess_err_attrs
,
246 .ct_owner
= THIS_MODULE
,
250 * Target Attributes Table
252 static struct iscsi_tiqn
*iscsi_tgt_attr_tiqn(struct config_item
*item
)
254 struct iscsi_wwn_stat_grps
*igrps
= container_of(to_config_group(item
),
255 struct iscsi_wwn_stat_grps
, iscsi_tgt_attr_group
);
256 return container_of(igrps
, struct iscsi_tiqn
, tiqn_stat_grps
);
259 static ssize_t
iscsi_stat_tgt_attr_inst_show(struct config_item
*item
,
262 return snprintf(page
, PAGE_SIZE
, "%u\n",
263 iscsi_tgt_attr_tiqn(item
)->tiqn_index
);
266 static ssize_t
iscsi_stat_tgt_attr_indx_show(struct config_item
*item
,
269 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_NODE_INDEX
);
272 static ssize_t
iscsi_stat_tgt_attr_login_fails_show(struct config_item
*item
,
275 struct iscsi_tiqn
*tiqn
= iscsi_tgt_attr_tiqn(item
);
276 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
279 spin_lock(&lstat
->lock
);
280 fail_count
= (lstat
->redirects
+ lstat
->authorize_fails
+
281 lstat
->authenticate_fails
+ lstat
->negotiate_fails
+
283 spin_unlock(&lstat
->lock
);
285 return snprintf(page
, PAGE_SIZE
, "%u\n", fail_count
);
288 static ssize_t
iscsi_stat_tgt_attr_last_fail_time_show(struct config_item
*item
,
291 struct iscsi_tiqn
*tiqn
= iscsi_tgt_attr_tiqn(item
);
292 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
295 spin_lock(&lstat
->lock
);
296 last_fail_time
= lstat
->last_fail_time
?
297 (u32
)(((u32
)lstat
->last_fail_time
-
298 INITIAL_JIFFIES
) * 100 / HZ
) : 0;
299 spin_unlock(&lstat
->lock
);
301 return snprintf(page
, PAGE_SIZE
, "%u\n", last_fail_time
);
304 static ssize_t
iscsi_stat_tgt_attr_last_fail_type_show(struct config_item
*item
,
307 struct iscsi_tiqn
*tiqn
= iscsi_tgt_attr_tiqn(item
);
308 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
311 spin_lock(&lstat
->lock
);
312 last_fail_type
= lstat
->last_fail_type
;
313 spin_unlock(&lstat
->lock
);
315 return snprintf(page
, PAGE_SIZE
, "%u\n", last_fail_type
);
318 static ssize_t
iscsi_stat_tgt_attr_fail_intr_name_show(struct config_item
*item
,
321 struct iscsi_tiqn
*tiqn
= iscsi_tgt_attr_tiqn(item
);
322 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
323 unsigned char buf
[ISCSI_IQN_LEN
];
325 spin_lock(&lstat
->lock
);
326 snprintf(buf
, ISCSI_IQN_LEN
, "%s", lstat
->last_intr_fail_name
[0] ?
327 lstat
->last_intr_fail_name
: NONE
);
328 spin_unlock(&lstat
->lock
);
330 return snprintf(page
, PAGE_SIZE
, "%s\n", buf
);
333 static ssize_t
iscsi_stat_tgt_attr_fail_intr_addr_type_show(struct config_item
*item
,
336 struct iscsi_tiqn
*tiqn
= iscsi_tgt_attr_tiqn(item
);
337 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
340 spin_lock(&lstat
->lock
);
341 if (lstat
->last_intr_fail_ip_family
== AF_INET6
)
342 ret
= snprintf(page
, PAGE_SIZE
, "ipv6\n");
344 ret
= snprintf(page
, PAGE_SIZE
, "ipv4\n");
345 spin_unlock(&lstat
->lock
);
350 static ssize_t
iscsi_stat_tgt_attr_fail_intr_addr_show(struct config_item
*item
,
353 struct iscsi_tiqn
*tiqn
= iscsi_tgt_attr_tiqn(item
);
354 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
357 spin_lock(&lstat
->lock
);
358 ret
= snprintf(page
, PAGE_SIZE
, "%pISc\n", &lstat
->last_intr_fail_sockaddr
);
359 spin_unlock(&lstat
->lock
);
364 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, inst
);
365 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, indx
);
366 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, login_fails
);
367 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, last_fail_time
);
368 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, last_fail_type
);
369 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, fail_intr_name
);
370 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, fail_intr_addr_type
);
371 CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_
, fail_intr_addr
);
373 static struct configfs_attribute
*iscsi_stat_tgt_attr_attrs
[] = {
374 &iscsi_stat_tgt_attr_attr_inst
,
375 &iscsi_stat_tgt_attr_attr_indx
,
376 &iscsi_stat_tgt_attr_attr_login_fails
,
377 &iscsi_stat_tgt_attr_attr_last_fail_time
,
378 &iscsi_stat_tgt_attr_attr_last_fail_type
,
379 &iscsi_stat_tgt_attr_attr_fail_intr_name
,
380 &iscsi_stat_tgt_attr_attr_fail_intr_addr_type
,
381 &iscsi_stat_tgt_attr_attr_fail_intr_addr
,
385 const struct config_item_type iscsi_stat_tgt_attr_cit
= {
386 .ct_attrs
= iscsi_stat_tgt_attr_attrs
,
387 .ct_owner
= THIS_MODULE
,
391 * Target Login Stats Table
393 static struct iscsi_tiqn
*iscsi_login_stat_tiqn(struct config_item
*item
)
395 struct iscsi_wwn_stat_grps
*igrps
= container_of(to_config_group(item
),
396 struct iscsi_wwn_stat_grps
, iscsi_login_stats_group
);
397 return container_of(igrps
, struct iscsi_tiqn
, tiqn_stat_grps
);
400 static ssize_t
iscsi_stat_login_inst_show(struct config_item
*item
, char *page
)
402 return snprintf(page
, PAGE_SIZE
, "%u\n",
403 iscsi_login_stat_tiqn(item
)->tiqn_index
);
406 static ssize_t
iscsi_stat_login_indx_show(struct config_item
*item
,
409 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_NODE_INDEX
);
412 static ssize_t
iscsi_stat_login_accepts_show(struct config_item
*item
,
415 struct iscsi_tiqn
*tiqn
= iscsi_login_stat_tiqn(item
);
416 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
419 spin_lock(&lstat
->lock
);
420 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lstat
->accepts
);
421 spin_unlock(&lstat
->lock
);
426 static ssize_t
iscsi_stat_login_other_fails_show(struct config_item
*item
,
429 struct iscsi_tiqn
*tiqn
= iscsi_login_stat_tiqn(item
);
430 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
433 spin_lock(&lstat
->lock
);
434 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lstat
->other_fails
);
435 spin_unlock(&lstat
->lock
);
440 static ssize_t
iscsi_stat_login_redirects_show(struct config_item
*item
,
443 struct iscsi_tiqn
*tiqn
= iscsi_login_stat_tiqn(item
);
444 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
447 spin_lock(&lstat
->lock
);
448 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lstat
->redirects
);
449 spin_unlock(&lstat
->lock
);
454 static ssize_t
iscsi_stat_login_authorize_fails_show(struct config_item
*item
,
457 struct iscsi_tiqn
*tiqn
= iscsi_login_stat_tiqn(item
);
458 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
461 spin_lock(&lstat
->lock
);
462 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lstat
->authorize_fails
);
463 spin_unlock(&lstat
->lock
);
468 static ssize_t
iscsi_stat_login_authenticate_fails_show(
469 struct config_item
*item
, char *page
)
471 struct iscsi_tiqn
*tiqn
= iscsi_login_stat_tiqn(item
);
472 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
475 spin_lock(&lstat
->lock
);
476 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lstat
->authenticate_fails
);
477 spin_unlock(&lstat
->lock
);
482 static ssize_t
iscsi_stat_login_negotiate_fails_show(struct config_item
*item
,
485 struct iscsi_tiqn
*tiqn
= iscsi_login_stat_tiqn(item
);
486 struct iscsi_login_stats
*lstat
= &tiqn
->login_stats
;
489 spin_lock(&lstat
->lock
);
490 ret
= snprintf(page
, PAGE_SIZE
, "%u\n", lstat
->negotiate_fails
);
491 spin_unlock(&lstat
->lock
);
496 CONFIGFS_ATTR_RO(iscsi_stat_login_
, inst
);
497 CONFIGFS_ATTR_RO(iscsi_stat_login_
, indx
);
498 CONFIGFS_ATTR_RO(iscsi_stat_login_
, accepts
);
499 CONFIGFS_ATTR_RO(iscsi_stat_login_
, other_fails
);
500 CONFIGFS_ATTR_RO(iscsi_stat_login_
, redirects
);
501 CONFIGFS_ATTR_RO(iscsi_stat_login_
, authorize_fails
);
502 CONFIGFS_ATTR_RO(iscsi_stat_login_
, authenticate_fails
);
503 CONFIGFS_ATTR_RO(iscsi_stat_login_
, negotiate_fails
);
505 static struct configfs_attribute
*iscsi_stat_login_stats_attrs
[] = {
506 &iscsi_stat_login_attr_inst
,
507 &iscsi_stat_login_attr_indx
,
508 &iscsi_stat_login_attr_accepts
,
509 &iscsi_stat_login_attr_other_fails
,
510 &iscsi_stat_login_attr_redirects
,
511 &iscsi_stat_login_attr_authorize_fails
,
512 &iscsi_stat_login_attr_authenticate_fails
,
513 &iscsi_stat_login_attr_negotiate_fails
,
517 const struct config_item_type iscsi_stat_login_cit
= {
518 .ct_attrs
= iscsi_stat_login_stats_attrs
,
519 .ct_owner
= THIS_MODULE
,
523 * Target Logout Stats Table
525 static struct iscsi_tiqn
*iscsi_logout_stat_tiqn(struct config_item
*item
)
527 struct iscsi_wwn_stat_grps
*igrps
= container_of(to_config_group(item
),
528 struct iscsi_wwn_stat_grps
, iscsi_logout_stats_group
);
529 return container_of(igrps
, struct iscsi_tiqn
, tiqn_stat_grps
);
532 static ssize_t
iscsi_stat_logout_inst_show(struct config_item
*item
, char *page
)
534 return snprintf(page
, PAGE_SIZE
, "%u\n",
535 iscsi_logout_stat_tiqn(item
)->tiqn_index
);
538 static ssize_t
iscsi_stat_logout_indx_show(struct config_item
*item
, char *page
)
540 return snprintf(page
, PAGE_SIZE
, "%u\n", ISCSI_NODE_INDEX
);
543 static ssize_t
iscsi_stat_logout_normal_logouts_show(struct config_item
*item
,
546 struct iscsi_tiqn
*tiqn
= iscsi_logout_stat_tiqn(item
);
547 struct iscsi_logout_stats
*lstats
= &tiqn
->logout_stats
;
549 return snprintf(page
, PAGE_SIZE
, "%u\n", lstats
->normal_logouts
);
552 static ssize_t
iscsi_stat_logout_abnormal_logouts_show(struct config_item
*item
,
555 struct iscsi_tiqn
*tiqn
= iscsi_logout_stat_tiqn(item
);
556 struct iscsi_logout_stats
*lstats
= &tiqn
->logout_stats
;
558 return snprintf(page
, PAGE_SIZE
, "%u\n", lstats
->abnormal_logouts
);
561 CONFIGFS_ATTR_RO(iscsi_stat_logout_
, inst
);
562 CONFIGFS_ATTR_RO(iscsi_stat_logout_
, indx
);
563 CONFIGFS_ATTR_RO(iscsi_stat_logout_
, normal_logouts
);
564 CONFIGFS_ATTR_RO(iscsi_stat_logout_
, abnormal_logouts
);
566 static struct configfs_attribute
*iscsi_stat_logout_stats_attrs
[] = {
567 &iscsi_stat_logout_attr_inst
,
568 &iscsi_stat_logout_attr_indx
,
569 &iscsi_stat_logout_attr_normal_logouts
,
570 &iscsi_stat_logout_attr_abnormal_logouts
,
574 const struct config_item_type iscsi_stat_logout_cit
= {
575 .ct_attrs
= iscsi_stat_logout_stats_attrs
,
576 .ct_owner
= THIS_MODULE
,
580 * Session Stats Table
582 static struct iscsi_node_acl
*iscsi_stat_nacl(struct config_item
*item
)
584 struct iscsi_node_stat_grps
*igrps
= container_of(to_config_group(item
),
585 struct iscsi_node_stat_grps
, iscsi_sess_stats_group
);
586 return container_of(igrps
, struct iscsi_node_acl
, node_stat_grps
);
589 static ssize_t
iscsi_stat_sess_inst_show(struct config_item
*item
, char *page
)
591 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
592 struct se_wwn
*wwn
= acl
->se_node_acl
.se_tpg
->se_tpg_wwn
;
593 struct iscsi_tiqn
*tiqn
= container_of(wwn
,
594 struct iscsi_tiqn
, tiqn_wwn
);
596 return snprintf(page
, PAGE_SIZE
, "%u\n", tiqn
->tiqn_index
);
599 static ssize_t
iscsi_stat_sess_node_show(struct config_item
*item
, char *page
)
601 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
602 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
603 struct iscsi_session
*sess
;
604 struct se_session
*se_sess
;
607 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
608 se_sess
= se_nacl
->nacl_sess
;
610 sess
= se_sess
->fabric_sess_ptr
;
612 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
613 sess
->sess_ops
->SessionType
? 0 : ISCSI_NODE_INDEX
);
615 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
620 static ssize_t
iscsi_stat_sess_indx_show(struct config_item
*item
, char *page
)
622 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
623 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
624 struct iscsi_session
*sess
;
625 struct se_session
*se_sess
;
628 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
629 se_sess
= se_nacl
->nacl_sess
;
631 sess
= se_sess
->fabric_sess_ptr
;
633 ret
= snprintf(page
, PAGE_SIZE
, "%u\n",
634 sess
->session_index
);
636 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
641 static ssize_t
iscsi_stat_sess_cmd_pdus_show(struct config_item
*item
,
644 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
645 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
646 struct iscsi_session
*sess
;
647 struct se_session
*se_sess
;
650 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
651 se_sess
= se_nacl
->nacl_sess
;
653 sess
= se_sess
->fabric_sess_ptr
;
655 ret
= snprintf(page
, PAGE_SIZE
, "%lu\n",
656 atomic_long_read(&sess
->cmd_pdus
));
658 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
663 static ssize_t
iscsi_stat_sess_rsp_pdus_show(struct config_item
*item
,
666 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
667 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
668 struct iscsi_session
*sess
;
669 struct se_session
*se_sess
;
672 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
673 se_sess
= se_nacl
->nacl_sess
;
675 sess
= se_sess
->fabric_sess_ptr
;
677 ret
= snprintf(page
, PAGE_SIZE
, "%lu\n",
678 atomic_long_read(&sess
->rsp_pdus
));
680 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
685 static ssize_t
iscsi_stat_sess_txdata_octs_show(struct config_item
*item
,
688 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
689 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
690 struct iscsi_session
*sess
;
691 struct se_session
*se_sess
;
694 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
695 se_sess
= se_nacl
->nacl_sess
;
697 sess
= se_sess
->fabric_sess_ptr
;
699 ret
= snprintf(page
, PAGE_SIZE
, "%lu\n",
700 atomic_long_read(&sess
->tx_data_octets
));
702 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
707 static ssize_t
iscsi_stat_sess_rxdata_octs_show(struct config_item
*item
,
710 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
711 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
712 struct iscsi_session
*sess
;
713 struct se_session
*se_sess
;
716 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
717 se_sess
= se_nacl
->nacl_sess
;
719 sess
= se_sess
->fabric_sess_ptr
;
721 ret
= snprintf(page
, PAGE_SIZE
, "%lu\n",
722 atomic_long_read(&sess
->rx_data_octets
));
724 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
729 static ssize_t
iscsi_stat_sess_conn_digest_errors_show(struct config_item
*item
,
732 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
733 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
734 struct iscsi_session
*sess
;
735 struct se_session
*se_sess
;
738 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
739 se_sess
= se_nacl
->nacl_sess
;
741 sess
= se_sess
->fabric_sess_ptr
;
743 ret
= snprintf(page
, PAGE_SIZE
, "%lu\n",
744 atomic_long_read(&sess
->conn_digest_errors
));
746 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
751 static ssize_t
iscsi_stat_sess_conn_timeout_errors_show(
752 struct config_item
*item
, char *page
)
754 struct iscsi_node_acl
*acl
= iscsi_stat_nacl(item
);
755 struct se_node_acl
*se_nacl
= &acl
->se_node_acl
;
756 struct iscsi_session
*sess
;
757 struct se_session
*se_sess
;
760 spin_lock_bh(&se_nacl
->nacl_sess_lock
);
761 se_sess
= se_nacl
->nacl_sess
;
763 sess
= se_sess
->fabric_sess_ptr
;
765 ret
= snprintf(page
, PAGE_SIZE
, "%lu\n",
766 atomic_long_read(&sess
->conn_timeout_errors
));
768 spin_unlock_bh(&se_nacl
->nacl_sess_lock
);
773 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, inst
);
774 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, node
);
775 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, indx
);
776 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, cmd_pdus
);
777 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, rsp_pdus
);
778 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, txdata_octs
);
779 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, rxdata_octs
);
780 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, conn_digest_errors
);
781 CONFIGFS_ATTR_RO(iscsi_stat_sess_
, conn_timeout_errors
);
783 static struct configfs_attribute
*iscsi_stat_sess_stats_attrs
[] = {
784 &iscsi_stat_sess_attr_inst
,
785 &iscsi_stat_sess_attr_node
,
786 &iscsi_stat_sess_attr_indx
,
787 &iscsi_stat_sess_attr_cmd_pdus
,
788 &iscsi_stat_sess_attr_rsp_pdus
,
789 &iscsi_stat_sess_attr_txdata_octs
,
790 &iscsi_stat_sess_attr_rxdata_octs
,
791 &iscsi_stat_sess_attr_conn_digest_errors
,
792 &iscsi_stat_sess_attr_conn_timeout_errors
,
796 const struct config_item_type iscsi_stat_sess_cit
= {
797 .ct_attrs
= iscsi_stat_sess_stats_attrs
,
798 .ct_owner
= THIS_MODULE
,