18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef ISCSI_TARGET_STAT_H
38c2ecf20Sopenharmony_ci#define ISCSI_TARGET_STAT_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/types.h>
68c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
78c2ecf20Sopenharmony_ci#include <linux/socket.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/*
108c2ecf20Sopenharmony_ci * For struct iscsi_tiqn->tiqn_wwn default groups
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ciextern const struct config_item_type iscsi_stat_instance_cit;
138c2ecf20Sopenharmony_ciextern const struct config_item_type iscsi_stat_sess_err_cit;
148c2ecf20Sopenharmony_ciextern const struct config_item_type iscsi_stat_tgt_attr_cit;
158c2ecf20Sopenharmony_ciextern const struct config_item_type iscsi_stat_login_cit;
168c2ecf20Sopenharmony_ciextern const struct config_item_type iscsi_stat_logout_cit;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/*
198c2ecf20Sopenharmony_ci * For struct iscsi_session->se_sess default groups
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ciextern const struct config_item_type iscsi_stat_sess_cit;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* iSCSI session error types */
248c2ecf20Sopenharmony_ci#define ISCSI_SESS_ERR_UNKNOWN		0
258c2ecf20Sopenharmony_ci#define ISCSI_SESS_ERR_DIGEST		1
268c2ecf20Sopenharmony_ci#define ISCSI_SESS_ERR_CXN_TIMEOUT	2
278c2ecf20Sopenharmony_ci#define ISCSI_SESS_ERR_PDU_FORMAT	3
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* iSCSI session error stats */
308c2ecf20Sopenharmony_cistruct iscsi_sess_err_stats {
318c2ecf20Sopenharmony_ci	spinlock_t	lock;
328c2ecf20Sopenharmony_ci	u32		digest_errors;
338c2ecf20Sopenharmony_ci	u32		cxn_timeout_errors;
348c2ecf20Sopenharmony_ci	u32		pdu_format_errors;
358c2ecf20Sopenharmony_ci	u32		last_sess_failure_type;
368c2ecf20Sopenharmony_ci	char		last_sess_fail_rem_name[ISCSI_IQN_LEN];
378c2ecf20Sopenharmony_ci} ____cacheline_aligned;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* iSCSI login failure types (sub oids) */
408c2ecf20Sopenharmony_ci#define ISCSI_LOGIN_FAIL_OTHER		2
418c2ecf20Sopenharmony_ci#define ISCSI_LOGIN_FAIL_REDIRECT	3
428c2ecf20Sopenharmony_ci#define ISCSI_LOGIN_FAIL_AUTHORIZE	4
438c2ecf20Sopenharmony_ci#define ISCSI_LOGIN_FAIL_AUTHENTICATE	5
448c2ecf20Sopenharmony_ci#define ISCSI_LOGIN_FAIL_NEGOTIATE	6
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* iSCSI login stats */
478c2ecf20Sopenharmony_cistruct iscsi_login_stats {
488c2ecf20Sopenharmony_ci	spinlock_t	lock;
498c2ecf20Sopenharmony_ci	u32		accepts;
508c2ecf20Sopenharmony_ci	u32		other_fails;
518c2ecf20Sopenharmony_ci	u32		redirects;
528c2ecf20Sopenharmony_ci	u32		authorize_fails;
538c2ecf20Sopenharmony_ci	u32		authenticate_fails;
548c2ecf20Sopenharmony_ci	u32		negotiate_fails;	/* used for notifications */
558c2ecf20Sopenharmony_ci	u64		last_fail_time;		/* time stamp (jiffies) */
568c2ecf20Sopenharmony_ci	u32		last_fail_type;
578c2ecf20Sopenharmony_ci	int		last_intr_fail_ip_family;
588c2ecf20Sopenharmony_ci	struct sockaddr_storage last_intr_fail_sockaddr;
598c2ecf20Sopenharmony_ci	char		last_intr_fail_name[ISCSI_IQN_LEN];
608c2ecf20Sopenharmony_ci} ____cacheline_aligned;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* iSCSI logout stats */
638c2ecf20Sopenharmony_cistruct iscsi_logout_stats {
648c2ecf20Sopenharmony_ci	spinlock_t	lock;
658c2ecf20Sopenharmony_ci	u32		normal_logouts;
668c2ecf20Sopenharmony_ci	u32		abnormal_logouts;
678c2ecf20Sopenharmony_ci} ____cacheline_aligned;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#endif   /*** ISCSI_TARGET_STAT_H ***/
70