1
2
3
4
5
6
7
8
9#ifndef _QED_MCP_H
10#define _QED_MCP_H
11
12#include <linux/types.h>
13#include <linux/delay.h>
14#include <linux/slab.h>
15#include <linux/spinlock.h>
16#include "qed_hsi.h"
17
18struct qed_mcp_link_speed_params {
19 bool autoneg;
20 u32 advertised_speeds;
21 u32 forced_speed;
22};
23
24struct qed_mcp_link_pause_params {
25 bool autoneg;
26 bool forced_rx;
27 bool forced_tx;
28};
29
30struct qed_mcp_link_params {
31 struct qed_mcp_link_speed_params speed;
32 struct qed_mcp_link_pause_params pause;
33 u32 loopback_mode;
34};
35
36struct qed_mcp_link_capabilities {
37 u32 speed_capabilities;
38};
39
40struct qed_mcp_link_state {
41 bool link_up;
42
43 u32 min_pf_rate;
44
45
46 u32 line_speed;
47
48
49
50
51 u32 speed;
52 bool full_duplex;
53
54 bool an;
55 bool an_complete;
56 bool parallel_detection;
57 bool pfc_enabled;
58
59#define QED_LINK_PARTNER_SPEED_1G_HD BIT(0)
60#define QED_LINK_PARTNER_SPEED_1G_FD BIT(1)
61#define QED_LINK_PARTNER_SPEED_10G BIT(2)
62#define QED_LINK_PARTNER_SPEED_20G BIT(3)
63#define QED_LINK_PARTNER_SPEED_40G BIT(4)
64#define QED_LINK_PARTNER_SPEED_50G BIT(5)
65#define QED_LINK_PARTNER_SPEED_100G BIT(6)
66 u32 partner_adv_speed;
67
68 bool partner_tx_flow_ctrl_en;
69 bool partner_rx_flow_ctrl_en;
70
71#define QED_LINK_PARTNER_SYMMETRIC_PAUSE (1)
72#define QED_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
73#define QED_LINK_PARTNER_BOTH_PAUSE (3)
74 u8 partner_adv_pause;
75
76 bool sfp_tx_fault;
77};
78
79struct qed_mcp_function_info {
80 u8 pause_on_host;
81
82 enum qed_pci_personality protocol;
83
84 u8 bandwidth_min;
85 u8 bandwidth_max;
86
87 u8 mac[ETH_ALEN];
88
89 u64 wwn_port;
90 u64 wwn_node;
91
92#define QED_MCP_VLAN_UNSET (0xffff)
93 u16 ovlan;
94};
95
96struct qed_mcp_nvm_common {
97 u32 offset;
98 u32 param;
99 u32 resp;
100 u32 cmd;
101};
102
103struct qed_mcp_drv_version {
104 u32 version;
105 u8 name[MCP_DRV_VER_STR_SIZE - 4];
106};
107
108
109
110
111
112
113
114
115struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *);
116
117
118
119
120
121
122
123
124struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *);
125
126
127
128
129
130
131
132
133struct qed_mcp_link_capabilities
134 *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
135
136
137
138
139
140
141
142
143
144
145int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
146 struct qed_ptt *p_ptt,
147 bool b_up);
148
149
150
151
152
153
154
155
156
157
158
159int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
160 struct qed_ptt *p_ptt,
161 u32 *p_mfw_ver, u32 *p_running_bundle_id);
162
163
164
165
166
167
168
169
170
171
172
173int qed_mcp_get_media_type(struct qed_dev *cdev,
174 u32 *media_type);
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
194 struct qed_ptt *p_ptt,
195 u32 cmd,
196 u32 param,
197 u32 *o_mcp_resp,
198 u32 *o_mcp_param);
199
200
201
202
203
204
205
206
207int qed_mcp_drain(struct qed_hwfn *p_hwfn,
208 struct qed_ptt *p_ptt);
209
210
211
212
213
214
215
216
217
218
219int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
220 struct qed_ptt *p_ptt,
221 u32 *p_flash_size);
222
223
224
225
226
227
228
229
230
231
232
233int
234qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
235 struct qed_ptt *p_ptt,
236 struct qed_mcp_drv_version *p_ver);
237
238
239
240
241
242
243
244
245
246
247int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
248 struct qed_ptt *p_ptt,
249 enum qed_led_mode mode);
250
251
252
253
254
255
256
257
258
259int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
260 struct qed_ptt *p_ptt);
261
262
263
264
265
266
267
268
269
270int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
271 struct qed_ptt *p_ptt);
272
273
274
275
276
277
278
279#define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
280 ((rel_pfid) | \
281 ((p_hwfn)->abs_pf_id & 1) << 3) : \
282 rel_pfid)
283#define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
284
285
286
287
288#define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
289 ((_p_hwfn)->cdev->num_ports_in_engines * 2))
290struct qed_mcp_info {
291 spinlock_t lock;
292 bool block_mb_sending;
293 u32 public_base;
294 u32 drv_mb_addr;
295 u32 mfw_mb_addr;
296 u32 port_addr;
297 u16 drv_mb_seq;
298 u16 drv_pulse_seq;
299 struct qed_mcp_link_params link_input;
300 struct qed_mcp_link_state link_output;
301 struct qed_mcp_link_capabilities link_capabilities;
302 struct qed_mcp_function_info func_info;
303 u8 *mfw_mb_cur;
304 u8 *mfw_mb_shadow;
305 u16 mfw_mb_length;
306 u16 mcp_hist;
307};
308
309struct qed_mcp_mb_params {
310 u32 cmd;
311 u32 param;
312 union drv_union_data *p_data_src;
313 union drv_union_data *p_data_dst;
314 u32 mcp_resp;
315 u32 mcp_param;
316};
317
318
319
320
321
322
323
324
325
326int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
327 struct qed_ptt *p_ptt);
328
329
330
331
332
333
334
335
336void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
337 struct qed_ptt *p_ptt);
338
339
340
341
342
343
344
345
346
347int qed_mcp_free(struct qed_hwfn *p_hwfn);
348
349
350
351
352
353
354
355
356
357
358
359
360
361int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
362 struct qed_ptt *p_ptt);
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
383 struct qed_ptt *p_ptt,
384 u32 *p_load_code);
385
386
387
388
389
390
391
392void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
393 struct qed_ptt *p_ptt);
394
395
396
397
398
399
400
401
402
403
404int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
405 struct qed_ptt *p_ptt, u32 *vfs_to_ack);
406
407
408
409
410
411
412
413
414int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
415 struct qed_ptt *p_ptt);
416
417
418
419
420
421
422
423
424
425int qed_mcp_reset(struct qed_hwfn *p_hwfn,
426 struct qed_ptt *p_ptt);
427
428
429
430
431
432
433
434
435bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
436
437
438
439
440
441
442
443
444
445
446
447int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
448 struct qed_ptt *p_ptt, u8 vf_id, u8 num);
449
450int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
451int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
452int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
453 struct qed_ptt *p_ptt,
454 struct qed_mcp_link_state *p_link,
455 u8 max_bw);
456int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
457 struct qed_ptt *p_ptt,
458 struct qed_mcp_link_state *p_link,
459 u8 min_bw);
460
461int qed_hw_init_first_eth(struct qed_hwfn *p_hwfn,
462 struct qed_ptt *p_ptt, u8 *p_pf);
463#endif
464