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
48struct 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
71enum csio_dev_master { CSIO_MASTER_CANT, CSIO_MASTER_MAY, CSIO_MASTER_MUST };
72
73enum csio_mb_owner { CSIO_MBOWNER_NONE, CSIO_MBOWNER_FW, CSIO_MBOWNER_PL };
74
75enum 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(FW_PARAMS_MNEM_DEV) | \
83 FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_##param))
84
85#define FW_PARAM_PFVF(param) \
86 (FW_PARAMS_MNEM(FW_PARAMS_MNEM_PFVF) | \
87 FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_PFVF_##param)| \
88 FW_PARAMS_PARAM_Y(0) | \
89 FW_PARAMS_PARAM_Z(0))
90
91enum {
92 PAUSE_RX = 1 << 0,
93 PAUSE_TX = 1 << 1,
94 PAUSE_AUTONEG = 1 << 2
95};
96
97#define CSIO_INIT_MBP(__mbp, __cp, __tmo, __priv, __fn, __clear) \
98do { \
99 if (__clear) \
100 memset((__cp), 0, \
101 CSIO_MB_MAX_REGS * sizeof(__be64)); \
102 INIT_LIST_HEAD(&(__mbp)->list); \
103 (__mbp)->tmo = (__tmo); \
104 (__mbp)->priv = (void *)(__priv); \
105 (__mbp)->mb_cbfn = (__fn); \
106 (__mbp)->mb_size = sizeof(*(__cp)); \
107} while (0)
108
109struct csio_mbm_stats {
110 uint32_t n_req;
111 uint32_t n_rsp;
112 uint32_t n_activeq;
113 uint32_t n_cbfnq;
114 uint32_t n_tmo;
115 uint32_t n_cancel;
116 uint32_t n_err;
117};
118
119
120struct csio_mb {
121 struct list_head list;
122
123 __be64 mb[CSIO_MB_MAX_REGS];
124 int mb_size;
125
126
127 uint32_t tmo;
128 struct completion cmplobj;
129
130
131 void (*mb_cbfn) (struct csio_hw *, struct csio_mb *);
132
133 void *priv;
134};
135
136struct csio_mbm {
137 uint32_t a_mbox;
138 uint32_t intr_idx;
139 struct timer_list timer;
140 struct list_head req_q;
141 struct list_head cbfn_q;
142 struct csio_mb *mcurrent;
143 uint32_t req_q_cnt;
144
145
146 struct csio_mbm_stats stats;
147};
148
149#define csio_set_mb_intr_idx(_m, _i) ((_m)->intr_idx = (_i))
150#define csio_get_mb_intr_idx(_m) ((_m)->intr_idx)
151
152struct csio_iq_params;
153struct csio_eq_params;
154
155enum fw_retval csio_mb_fw_retval(struct csio_mb *);
156
157
158void csio_mb_hello(struct csio_hw *, struct csio_mb *, uint32_t,
159 uint32_t, uint32_t, enum csio_dev_master,
160 void (*)(struct csio_hw *, struct csio_mb *));
161
162void csio_mb_process_hello_rsp(struct csio_hw *, struct csio_mb *,
163 enum fw_retval *, enum csio_dev_state *,
164 uint8_t *);
165
166void csio_mb_bye(struct csio_hw *, struct csio_mb *, uint32_t,
167 void (*)(struct csio_hw *, struct csio_mb *));
168
169void csio_mb_reset(struct csio_hw *, struct csio_mb *, uint32_t, int, int,
170 void (*)(struct csio_hw *, struct csio_mb *));
171
172void csio_mb_params(struct csio_hw *, struct csio_mb *, uint32_t, unsigned int,
173 unsigned int, unsigned int, const u32 *, u32 *, bool,
174 void (*)(struct csio_hw *, struct csio_mb *));
175
176void csio_mb_process_read_params_rsp(struct csio_hw *, struct csio_mb *,
177 enum fw_retval *, unsigned int , u32 *);
178
179void csio_mb_ldst(struct csio_hw *hw, struct csio_mb *mbp, uint32_t tmo,
180 int reg);
181
182void csio_mb_caps_config(struct csio_hw *, struct csio_mb *, uint32_t,
183 bool, bool, bool, bool,
184 void (*)(struct csio_hw *, struct csio_mb *));
185
186void csio_rss_glb_config(struct csio_hw *, struct csio_mb *,
187 uint32_t, uint8_t, unsigned int,
188 void (*)(struct csio_hw *, struct csio_mb *));
189
190void csio_mb_pfvf(struct csio_hw *, struct csio_mb *, uint32_t,
191 unsigned int, unsigned int, unsigned int,
192 unsigned int, unsigned int, unsigned int,
193 unsigned int, unsigned int, unsigned int,
194 unsigned int, unsigned int, unsigned int,
195 unsigned int, void (*) (struct csio_hw *, struct csio_mb *));
196
197void csio_mb_port(struct csio_hw *, struct csio_mb *, uint32_t,
198 uint8_t, bool, uint32_t, uint16_t,
199 void (*) (struct csio_hw *, struct csio_mb *));
200
201void csio_mb_process_read_port_rsp(struct csio_hw *, struct csio_mb *,
202 enum fw_retval *, uint16_t *);
203
204void csio_mb_initialize(struct csio_hw *, struct csio_mb *, uint32_t,
205 void (*)(struct csio_hw *, struct csio_mb *));
206
207void csio_mb_iq_alloc_write(struct csio_hw *, struct csio_mb *, void *,
208 uint32_t, struct csio_iq_params *,
209 void (*) (struct csio_hw *, struct csio_mb *));
210
211void csio_mb_iq_alloc_write_rsp(struct csio_hw *, struct csio_mb *,
212 enum fw_retval *, struct csio_iq_params *);
213
214void csio_mb_iq_free(struct csio_hw *, struct csio_mb *, void *,
215 uint32_t, struct csio_iq_params *,
216 void (*) (struct csio_hw *, struct csio_mb *));
217
218void csio_mb_eq_ofld_alloc_write(struct csio_hw *, struct csio_mb *, void *,
219 uint32_t, struct csio_eq_params *,
220 void (*) (struct csio_hw *, struct csio_mb *));
221
222void csio_mb_eq_ofld_alloc_write_rsp(struct csio_hw *, struct csio_mb *,
223 enum fw_retval *, struct csio_eq_params *);
224
225void csio_mb_eq_ofld_free(struct csio_hw *, struct csio_mb *, void *,
226 uint32_t , struct csio_eq_params *,
227 void (*) (struct csio_hw *, struct csio_mb *));
228
229void csio_fcoe_read_res_info_init_mb(struct csio_hw *, struct csio_mb *,
230 uint32_t,
231 void (*) (struct csio_hw *, struct csio_mb *));
232
233void csio_write_fcoe_link_cond_init_mb(struct csio_lnode *, struct csio_mb *,
234 uint32_t, uint8_t, uint32_t, uint8_t, bool, uint32_t,
235 void (*) (struct csio_hw *, struct csio_mb *));
236
237void csio_fcoe_vnp_alloc_init_mb(struct csio_lnode *, struct csio_mb *,
238 uint32_t, uint32_t , uint32_t , uint16_t,
239 uint8_t [8], uint8_t [8],
240 void (*) (struct csio_hw *, struct csio_mb *));
241
242void csio_fcoe_vnp_read_init_mb(struct csio_lnode *, struct csio_mb *,
243 uint32_t, uint32_t , uint32_t ,
244 void (*) (struct csio_hw *, struct csio_mb *));
245
246void csio_fcoe_vnp_free_init_mb(struct csio_lnode *, struct csio_mb *,
247 uint32_t , uint32_t, uint32_t ,
248 void (*) (struct csio_hw *, struct csio_mb *));
249
250void csio_fcoe_read_fcf_init_mb(struct csio_lnode *, struct csio_mb *,
251 uint32_t, uint32_t, uint32_t,
252 void (*cbfn) (struct csio_hw *, struct csio_mb *));
253
254void csio_fcoe_read_portparams_init_mb(struct csio_hw *hw,
255 struct csio_mb *mbp, uint32_t mb_tmo,
256 struct fw_fcoe_port_cmd_params *portparams,
257 void (*cbfn)(struct csio_hw *, struct csio_mb *));
258
259void csio_mb_process_portparams_rsp(struct csio_hw *hw, struct csio_mb *mbp,
260 enum fw_retval *retval,
261 struct fw_fcoe_port_cmd_params *portparams,
262 struct fw_fcoe_port_stats *portstats);
263
264
265int csio_mbm_init(struct csio_mbm *, struct csio_hw *,
266 void (*)(uintptr_t));
267void csio_mbm_exit(struct csio_mbm *);
268void csio_mb_intr_enable(struct csio_hw *);
269void csio_mb_intr_disable(struct csio_hw *);
270
271int csio_mb_issue(struct csio_hw *, struct csio_mb *);
272void csio_mb_completions(struct csio_hw *, struct list_head *);
273int csio_mb_fwevt_handler(struct csio_hw *, __be64 *);
274int csio_mb_isr_handler(struct csio_hw *);
275struct csio_mb *csio_mb_tmo_handler(struct csio_hw *);
276void csio_mb_cancel_all(struct csio_hw *, struct list_head *);
277
278#endif
279