xref: /OK3568_Linux_fs/kernel/drivers/scsi/bfa/bfa_plog.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4*4882a593Smuzhiyun  * Copyright (c) 2014- QLogic Corporation.
5*4882a593Smuzhiyun  * All rights reserved
6*4882a593Smuzhiyun  * www.qlogic.com
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun #ifndef __BFA_PORTLOG_H__
11*4882a593Smuzhiyun #define __BFA_PORTLOG_H__
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include "bfa_fc.h"
14*4882a593Smuzhiyun #include "bfa_defs.h"
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #define BFA_PL_NLOG_ENTS 256
17*4882a593Smuzhiyun #define BFA_PL_LOG_REC_INCR(_x) ((_x)++, (_x) %= BFA_PL_NLOG_ENTS)
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #define BFA_PL_STRING_LOG_SZ   32   /* number of chars in string log */
20*4882a593Smuzhiyun #define BFA_PL_INT_LOG_SZ      8    /* number of integers in the integer log */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun enum bfa_plog_log_type {
23*4882a593Smuzhiyun 	BFA_PL_LOG_TYPE_INVALID	= 0,
24*4882a593Smuzhiyun 	BFA_PL_LOG_TYPE_INT	= 1,
25*4882a593Smuzhiyun 	BFA_PL_LOG_TYPE_STRING	= 2,
26*4882a593Smuzhiyun };
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun  * the (fixed size) record format for each entry in the portlog
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun struct bfa_plog_rec_s {
32*4882a593Smuzhiyun 	u64	tv;	/* timestamp */
33*4882a593Smuzhiyun 	u8	 port;	/* Source port that logged this entry */
34*4882a593Smuzhiyun 	u8	 mid;	/* module id */
35*4882a593Smuzhiyun 	u8	 eid;	/* indicates Rx, Tx, IOCTL, etc.  bfa_plog_eid */
36*4882a593Smuzhiyun 	u8	 log_type; /* string/integer log, bfa_plog_log_type_t */
37*4882a593Smuzhiyun 	u8	 log_num_ints;
38*4882a593Smuzhiyun 	/*
39*4882a593Smuzhiyun 	 * interpreted only if log_type is INT_LOG. indicates number of
40*4882a593Smuzhiyun 	 * integers in the int_log[] (0-PL_INT_LOG_SZ).
41*4882a593Smuzhiyun 	 */
42*4882a593Smuzhiyun 	u8	 rsvd;
43*4882a593Smuzhiyun 	u16	misc;	/* can be used to indicate fc frame length */
44*4882a593Smuzhiyun 	union {
45*4882a593Smuzhiyun 		char	    string_log[BFA_PL_STRING_LOG_SZ];
46*4882a593Smuzhiyun 		u32	int_log[BFA_PL_INT_LOG_SZ];
47*4882a593Smuzhiyun 	} log_entry;
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun };
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun /*
52*4882a593Smuzhiyun  * the following #defines will be used by the logging entities to indicate
53*4882a593Smuzhiyun  * their module id. BFAL will convert the integer value to string format
54*4882a593Smuzhiyun  *
55*4882a593Smuzhiyun * process to be used while changing the following #defines:
56*4882a593Smuzhiyun  *  - Always add new entries at the end
57*4882a593Smuzhiyun  *  - define corresponding string in BFAL
58*4882a593Smuzhiyun  *  - Do not remove any entry or rearrange the order.
59*4882a593Smuzhiyun  */
60*4882a593Smuzhiyun enum bfa_plog_mid {
61*4882a593Smuzhiyun 	BFA_PL_MID_INVALID	= 0,
62*4882a593Smuzhiyun 	BFA_PL_MID_DEBUG	= 1,
63*4882a593Smuzhiyun 	BFA_PL_MID_DRVR		= 2,
64*4882a593Smuzhiyun 	BFA_PL_MID_HAL		= 3,
65*4882a593Smuzhiyun 	BFA_PL_MID_HAL_FCXP	= 4,
66*4882a593Smuzhiyun 	BFA_PL_MID_HAL_UF	= 5,
67*4882a593Smuzhiyun 	BFA_PL_MID_FCS		= 6,
68*4882a593Smuzhiyun 	BFA_PL_MID_LPS		= 7,
69*4882a593Smuzhiyun 	BFA_PL_MID_MAX		= 8
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun #define BFA_PL_MID_STRLEN    8
73*4882a593Smuzhiyun struct bfa_plog_mid_strings_s {
74*4882a593Smuzhiyun 	char	    m_str[BFA_PL_MID_STRLEN];
75*4882a593Smuzhiyun };
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /*
78*4882a593Smuzhiyun  * the following #defines will be used by the logging entities to indicate
79*4882a593Smuzhiyun  * their event type. BFAL will convert the integer value to string format
80*4882a593Smuzhiyun  *
81*4882a593Smuzhiyun * process to be used while changing the following #defines:
82*4882a593Smuzhiyun  *  - Always add new entries at the end
83*4882a593Smuzhiyun  *  - define corresponding string in BFAL
84*4882a593Smuzhiyun  *  - Do not remove any entry or rearrange the order.
85*4882a593Smuzhiyun  */
86*4882a593Smuzhiyun enum bfa_plog_eid {
87*4882a593Smuzhiyun 	BFA_PL_EID_INVALID		= 0,
88*4882a593Smuzhiyun 	BFA_PL_EID_IOC_DISABLE		= 1,
89*4882a593Smuzhiyun 	BFA_PL_EID_IOC_ENABLE		= 2,
90*4882a593Smuzhiyun 	BFA_PL_EID_PORT_DISABLE		= 3,
91*4882a593Smuzhiyun 	BFA_PL_EID_PORT_ENABLE		= 4,
92*4882a593Smuzhiyun 	BFA_PL_EID_PORT_ST_CHANGE	= 5,
93*4882a593Smuzhiyun 	BFA_PL_EID_TX			= 6,
94*4882a593Smuzhiyun 	BFA_PL_EID_TX_ACK1		= 7,
95*4882a593Smuzhiyun 	BFA_PL_EID_TX_RJT		= 8,
96*4882a593Smuzhiyun 	BFA_PL_EID_TX_BSY		= 9,
97*4882a593Smuzhiyun 	BFA_PL_EID_RX			= 10,
98*4882a593Smuzhiyun 	BFA_PL_EID_RX_ACK1		= 11,
99*4882a593Smuzhiyun 	BFA_PL_EID_RX_RJT		= 12,
100*4882a593Smuzhiyun 	BFA_PL_EID_RX_BSY		= 13,
101*4882a593Smuzhiyun 	BFA_PL_EID_CT_IN		= 14,
102*4882a593Smuzhiyun 	BFA_PL_EID_CT_OUT		= 15,
103*4882a593Smuzhiyun 	BFA_PL_EID_DRIVER_START		= 16,
104*4882a593Smuzhiyun 	BFA_PL_EID_RSCN			= 17,
105*4882a593Smuzhiyun 	BFA_PL_EID_DEBUG		= 18,
106*4882a593Smuzhiyun 	BFA_PL_EID_MISC			= 19,
107*4882a593Smuzhiyun 	BFA_PL_EID_FIP_FCF_DISC		= 20,
108*4882a593Smuzhiyun 	BFA_PL_EID_FIP_FCF_CVL		= 21,
109*4882a593Smuzhiyun 	BFA_PL_EID_LOGIN		= 22,
110*4882a593Smuzhiyun 	BFA_PL_EID_LOGO			= 23,
111*4882a593Smuzhiyun 	BFA_PL_EID_TRUNK_SCN		= 24,
112*4882a593Smuzhiyun 	BFA_PL_EID_MAX
113*4882a593Smuzhiyun };
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun #define BFA_PL_ENAME_STRLEN	8
116*4882a593Smuzhiyun struct bfa_plog_eid_strings_s {
117*4882a593Smuzhiyun 	char	    e_str[BFA_PL_ENAME_STRLEN];
118*4882a593Smuzhiyun };
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun #define BFA_PL_SIG_LEN	8
121*4882a593Smuzhiyun #define BFA_PL_SIG_STR  "12pl123"
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun /*
124*4882a593Smuzhiyun  * per port circular log buffer
125*4882a593Smuzhiyun  */
126*4882a593Smuzhiyun struct bfa_plog_s {
127*4882a593Smuzhiyun 	char	    plog_sig[BFA_PL_SIG_LEN];	/* Start signature */
128*4882a593Smuzhiyun 	u8	 plog_enabled;
129*4882a593Smuzhiyun 	u8	 rsvd[7];
130*4882a593Smuzhiyun 	u32	ticks;
131*4882a593Smuzhiyun 	u16	head;
132*4882a593Smuzhiyun 	u16	tail;
133*4882a593Smuzhiyun 	struct bfa_plog_rec_s  plog_recs[BFA_PL_NLOG_ENTS];
134*4882a593Smuzhiyun };
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun void bfa_plog_init(struct bfa_plog_s *plog);
137*4882a593Smuzhiyun void bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
138*4882a593Smuzhiyun 			enum bfa_plog_eid event, u16 misc, char *log_str);
139*4882a593Smuzhiyun void bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
140*4882a593Smuzhiyun 			enum bfa_plog_eid event, u16 misc,
141*4882a593Smuzhiyun 			u32 *intarr, u32 num_ints);
142*4882a593Smuzhiyun void bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
143*4882a593Smuzhiyun 		enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr);
144*4882a593Smuzhiyun void bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
145*4882a593Smuzhiyun 			enum bfa_plog_eid event, u16 misc,
146*4882a593Smuzhiyun 			struct fchs_s *fchdr, u32 pld_w0);
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun #endif /* __BFA_PORTLOG_H__ */
149