1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #ifndef __CSIO_MB_H__
36 #define __CSIO_MB_H__
37
38 #include <linux/timer.h>
39 #include <linux/completion.h>
40
41 #include "t4fw_api.h"
42 #include "t4fw_api_stor.h"
43 #include "csio_defs.h"
44
45 #define CSIO_STATS_OFFSET (2)
46 #define CSIO_NUM_STATS_PER_MB (6)
47
48 struct fw_fcoe_port_cmd_params {
49 uint8_t portid;
50 uint8_t idx;
51 uint8_t nstats;
52 };
53
54 #define CSIO_DUMP_MB(__hw, __num, __mb) \
55 csio_dbg(__hw, "\t%llx %llx %llx %llx %llx %llx %llx %llx\n", \
56 (unsigned long long)csio_rd_reg64(__hw, __mb), \
57 (unsigned long long)csio_rd_reg64(__hw, __mb + 8), \
58 (unsigned long long)csio_rd_reg64(__hw, __mb + 16), \
59 (unsigned long long)csio_rd_reg64(__hw, __mb + 24), \
60 (unsigned long long)csio_rd_reg64(__hw, __mb + 32), \
61 (unsigned long long)csio_rd_reg64(__hw, __mb + 40), \
62 (unsigned long long)csio_rd_reg64(__hw, __mb + 48), \
63 (unsigned long long)csio_rd_reg64(__hw, __mb + 56))
64
65 #define CSIO_MB_MAX_REGS 8
66 #define CSIO_MAX_MB_SIZE 64
67 #define CSIO_MB_POLL_FREQ 5
68 #define CSIO_MB_DEFAULT_TMO FW_CMD_MAX_TIMEOUT
69
70
71 enum csio_dev_master { CSIO_MASTER_CANT, CSIO_MASTER_MAY, CSIO_MASTER_MUST };
72
73 enum csio_mb_owner { CSIO_MBOWNER_NONE, CSIO_MBOWNER_FW, CSIO_MBOWNER_PL };
74
75 enum csio_dev_state {
76 CSIO_DEV_STATE_UNINIT,
77 CSIO_DEV_STATE_INIT,
78 CSIO_DEV_STATE_ERR
79 };
80
81 #define FW_PARAM_DEV(param) \
82 (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) | \
83 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_##param))
84
85 #define FW_PARAM_PFVF(param) \
86 (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \
87 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param)| \
88 FW_PARAMS_PARAM_Y_V(0) | \
89 FW_PARAMS_PARAM_Z_V(0))
90
91 #define CSIO_INIT_MBP(__mbp, __cp, __tmo, __priv, __fn, __clear) \
92 do { \
93 if (__clear) \
94 memset((__cp), 0, \
95 CSIO_MB_MAX_REGS * sizeof(__be64)); \
96 INIT_LIST_HEAD(&(__mbp)->list); \
97 (__mbp)->tmo = (__tmo); \
98 (__mbp)->priv = (void *)(__priv); \
99 (__mbp)->mb_cbfn = (__fn); \
100 (__mbp)->mb_size = sizeof(*(__cp)); \
101 } while (0)
102
103 struct csio_mbm_stats {
104 uint32_t n_req;
105 uint32_t n_rsp;
106 uint32_t n_activeq;
107 uint32_t n_cbfnq;
108 uint32_t n_tmo;
109 uint32_t n_cancel;
110 uint32_t n_err;
111 };
112
113
114 struct csio_mb {
115 struct list_head list;
116
117 __be64 mb[CSIO_MB_MAX_REGS];
118 int mb_size;
119
120
121 uint32_t tmo;
122 struct completion cmplobj;
123
124
125 void (*mb_cbfn) (struct csio_hw *, struct csio_mb *);
126
127 void *priv;
128 };
129
130 struct csio_mbm {
131 uint32_t a_mbox;
132 uint32_t intr_idx;
133 struct timer_list timer;
134 struct csio_hw *hw;
135 struct list_head req_q;
136 struct list_head cbfn_q;
137 struct csio_mb *mcurrent;
138 uint32_t req_q_cnt;
139
140
141 struct csio_mbm_stats stats;
142 };
143
144 #define csio_set_mb_intr_idx(_m, _i) ((_m)->intr_idx = (_i))
145 #define csio_get_mb_intr_idx(_m) ((_m)->intr_idx)
146
147 struct csio_iq_params;
148 struct csio_eq_params;
149
150 enum fw_retval csio_mb_fw_retval(struct csio_mb *);
151
152
153 void csio_mb_hello(struct csio_hw *, struct csio_mb *, uint32_t,
154 uint32_t, uint32_t, enum csio_dev_master,
155 void (*)(struct csio_hw *, struct csio_mb *));
156
157 void csio_mb_process_hello_rsp(struct csio_hw *, struct csio_mb *,
158 enum fw_retval *, enum csio_dev_state *,
159 uint8_t *);
160
161 void csio_mb_bye(struct csio_hw *, struct csio_mb *, uint32_t,
162 void (*)(struct csio_hw *, struct csio_mb *));
163
164 void csio_mb_reset(struct csio_hw *, struct csio_mb *, uint32_t, int, int,
165 void (*)(struct csio_hw *, struct csio_mb *));
166
167 void csio_mb_params(struct csio_hw *, struct csio_mb *, uint32_t, unsigned int,
168 unsigned int, unsigned int, const u32 *, u32 *, bool,
169 void (*)(struct csio_hw *, struct csio_mb *));
170
171 void csio_mb_process_read_params_rsp(struct csio_hw *, struct csio_mb *,
172 enum fw_retval *, unsigned int , u32 *);
173
174 void csio_mb_ldst(struct csio_hw *hw, struct csio_mb *mbp, uint32_t tmo,
175 int reg);
176
177 void csio_mb_caps_config(struct csio_hw *, struct csio_mb *, uint32_t,
178 bool, bool, bool, bool,
179 void (*)(struct csio_hw *, struct csio_mb *));
180
181 void csio_mb_port(struct csio_hw *, struct csio_mb *, uint32_t,
182 uint8_t, bool, uint32_t, uint16_t,
183 void (*) (struct csio_hw *, struct csio_mb *));
184
185 void csio_mb_process_read_port_rsp(struct csio_hw *, struct csio_mb *,
186 enum fw_retval *, uint16_t,
187 uint32_t *, uint32_t *);
188
189 void csio_mb_initialize(struct csio_hw *, struct csio_mb *, uint32_t,
190 void (*)(struct csio_hw *, struct csio_mb *));
191
192 void csio_mb_iq_alloc_write(struct csio_hw *, struct csio_mb *, void *,
193 uint32_t, struct csio_iq_params *,
194 void (*) (struct csio_hw *, struct csio_mb *));
195
196 void csio_mb_iq_alloc_write_rsp(struct csio_hw *, struct csio_mb *,
197 enum fw_retval *, struct csio_iq_params *);
198
199 void csio_mb_iq_free(struct csio_hw *, struct csio_mb *, void *,
200 uint32_t, struct csio_iq_params *,
201 void (*) (struct csio_hw *, struct csio_mb *));
202
203 void csio_mb_eq_ofld_alloc_write(struct csio_hw *, struct csio_mb *, void *,
204 uint32_t, struct csio_eq_params *,
205 void (*) (struct csio_hw *, struct csio_mb *));
206
207 void csio_mb_eq_ofld_alloc_write_rsp(struct csio_hw *, struct csio_mb *,
208 enum fw_retval *, struct csio_eq_params *);
209
210 void csio_mb_eq_ofld_free(struct csio_hw *, struct csio_mb *, void *,
211 uint32_t , struct csio_eq_params *,
212 void (*) (struct csio_hw *, struct csio_mb *));
213
214 void csio_fcoe_read_res_info_init_mb(struct csio_hw *, struct csio_mb *,
215 uint32_t,
216 void (*) (struct csio_hw *, struct csio_mb *));
217
218 void csio_write_fcoe_link_cond_init_mb(struct csio_lnode *, struct csio_mb *,
219 uint32_t, uint8_t, uint32_t, uint8_t, bool, uint32_t,
220 void (*) (struct csio_hw *, struct csio_mb *));
221
222 void csio_fcoe_vnp_alloc_init_mb(struct csio_lnode *, struct csio_mb *,
223 uint32_t, uint32_t , uint32_t , uint16_t,
224 uint8_t [8], uint8_t [8],
225 void (*) (struct csio_hw *, struct csio_mb *));
226
227 void csio_fcoe_vnp_read_init_mb(struct csio_lnode *, struct csio_mb *,
228 uint32_t, uint32_t , uint32_t ,
229 void (*) (struct csio_hw *, struct csio_mb *));
230
231 void csio_fcoe_vnp_free_init_mb(struct csio_lnode *, struct csio_mb *,
232 uint32_t , uint32_t, uint32_t ,
233 void (*) (struct csio_hw *, struct csio_mb *));
234
235 void csio_fcoe_read_fcf_init_mb(struct csio_lnode *, struct csio_mb *,
236 uint32_t, uint32_t, uint32_t,
237 void (*cbfn) (struct csio_hw *, struct csio_mb *));
238
239 void csio_fcoe_read_portparams_init_mb(struct csio_hw *hw,
240 struct csio_mb *mbp, uint32_t mb_tmo,
241 struct fw_fcoe_port_cmd_params *portparams,
242 void (*cbfn)(struct csio_hw *, struct csio_mb *));
243
244 void csio_mb_process_portparams_rsp(struct csio_hw *hw, struct csio_mb *mbp,
245 enum fw_retval *retval,
246 struct fw_fcoe_port_cmd_params *portparams,
247 struct fw_fcoe_port_stats *portstats);
248
249
250 int csio_mbm_init(struct csio_mbm *, struct csio_hw *,
251 void (*)(struct timer_list *));
252 void csio_mbm_exit(struct csio_mbm *);
253 void csio_mb_intr_enable(struct csio_hw *);
254 void csio_mb_intr_disable(struct csio_hw *);
255
256 int csio_mb_issue(struct csio_hw *, struct csio_mb *);
257 void csio_mb_completions(struct csio_hw *, struct list_head *);
258 int csio_mb_fwevt_handler(struct csio_hw *, __be64 *);
259 int csio_mb_isr_handler(struct csio_hw *);
260 struct csio_mb *csio_mb_tmo_handler(struct csio_hw *);
261 void csio_mb_cancel_all(struct csio_hw *, struct list_head *);
262
263 #endif