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