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_25G BIT(4)
64#define QED_LINK_PARTNER_SPEED_40G BIT(5)
65#define QED_LINK_PARTNER_SPEED_50G BIT(6)
66#define QED_LINK_PARTNER_SPEED_100G BIT(7)
67 u32 partner_adv_speed;
68
69 bool partner_tx_flow_ctrl_en;
70 bool partner_rx_flow_ctrl_en;
71
72#define QED_LINK_PARTNER_SYMMETRIC_PAUSE (1)
73#define QED_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
74#define QED_LINK_PARTNER_BOTH_PAUSE (3)
75 u8 partner_adv_pause;
76
77 bool sfp_tx_fault;
78};
79
80struct qed_mcp_function_info {
81 u8 pause_on_host;
82
83 enum qed_pci_personality protocol;
84
85 u8 bandwidth_min;
86 u8 bandwidth_max;
87
88 u8 mac[ETH_ALEN];
89
90 u64 wwn_port;
91 u64 wwn_node;
92
93#define QED_MCP_VLAN_UNSET (0xffff)
94 u16 ovlan;
95
96 u16 mtu;
97};
98
99struct qed_mcp_nvm_common {
100 u32 offset;
101 u32 param;
102 u32 resp;
103 u32 cmd;
104};
105
106struct qed_mcp_drv_version {
107 u32 version;
108 u8 name[MCP_DRV_VER_STR_SIZE - 4];
109};
110
111struct qed_mcp_lan_stats {
112 u64 ucast_rx_pkts;
113 u64 ucast_tx_pkts;
114 u32 fcs_err;
115};
116
117struct qed_mcp_fcoe_stats {
118 u64 rx_pkts;
119 u64 tx_pkts;
120 u32 fcs_err;
121 u32 login_failure;
122};
123
124struct qed_mcp_iscsi_stats {
125 u64 rx_pdus;
126 u64 tx_pdus;
127 u64 rx_bytes;
128 u64 tx_bytes;
129};
130
131struct qed_mcp_rdma_stats {
132 u64 rx_pkts;
133 u64 tx_pkts;
134 u64 rx_bytes;
135 u64 tx_byts;
136};
137
138enum qed_mcp_protocol_type {
139 QED_MCP_LAN_STATS,
140 QED_MCP_FCOE_STATS,
141 QED_MCP_ISCSI_STATS,
142 QED_MCP_RDMA_STATS
143};
144
145union qed_mcp_protocol_stats {
146 struct qed_mcp_lan_stats lan_stats;
147 struct qed_mcp_fcoe_stats fcoe_stats;
148 struct qed_mcp_iscsi_stats iscsi_stats;
149 struct qed_mcp_rdma_stats rdma_stats;
150};
151
152enum qed_ov_eswitch {
153 QED_OV_ESWITCH_NONE,
154 QED_OV_ESWITCH_VEB,
155 QED_OV_ESWITCH_VEPA
156};
157
158enum qed_ov_client {
159 QED_OV_CLIENT_DRV,
160 QED_OV_CLIENT_USER,
161 QED_OV_CLIENT_VENDOR_SPEC
162};
163
164enum qed_ov_driver_state {
165 QED_OV_DRIVER_STATE_NOT_LOADED,
166 QED_OV_DRIVER_STATE_DISABLED,
167 QED_OV_DRIVER_STATE_ACTIVE
168};
169
170enum qed_ov_wol {
171 QED_OV_WOL_DEFAULT,
172 QED_OV_WOL_DISABLED,
173 QED_OV_WOL_ENABLED
174};
175
176
177
178
179
180
181
182
183struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *);
184
185
186
187
188
189
190
191
192struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *);
193
194
195
196
197
198
199
200
201struct qed_mcp_link_capabilities
202 *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
203
204
205
206
207
208
209
210
211
212
213int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
214 struct qed_ptt *p_ptt,
215 bool b_up);
216
217
218
219
220
221
222
223
224
225
226
227int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
228 struct qed_ptt *p_ptt,
229 u32 *p_mfw_ver, u32 *p_running_bundle_id);
230
231
232
233
234
235
236
237
238
239
240
241int qed_mcp_get_media_type(struct qed_dev *cdev,
242 u32 *media_type);
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
262 struct qed_ptt *p_ptt,
263 u32 cmd,
264 u32 param,
265 u32 *o_mcp_resp,
266 u32 *o_mcp_param);
267
268
269
270
271
272
273
274
275int qed_mcp_drain(struct qed_hwfn *p_hwfn,
276 struct qed_ptt *p_ptt);
277
278
279
280
281
282
283
284
285
286
287int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
288 struct qed_ptt *p_ptt,
289 u32 *p_flash_size);
290
291
292
293
294
295
296
297
298
299
300
301int
302qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
303 struct qed_ptt *p_ptt,
304 struct qed_mcp_drv_version *p_ver);
305
306
307
308
309
310
311
312
313
314
315int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
316 struct qed_ptt *p_ptt,
317 enum qed_ov_client client);
318
319
320
321
322
323
324
325
326
327
328int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
329 struct qed_ptt *p_ptt,
330 enum qed_ov_driver_state drv_state);
331
332
333
334
335
336
337
338
339
340
341int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
342 struct qed_ptt *p_ptt, u16 mtu);
343
344
345
346
347
348
349
350
351
352
353int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
354 struct qed_ptt *p_ptt, u8 *mac);
355
356
357
358
359
360
361
362
363
364
365int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
366 struct qed_ptt *p_ptt,
367 enum qed_ov_wol wol);
368
369
370
371
372
373
374
375
376
377
378int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
379 struct qed_ptt *p_ptt,
380 enum qed_led_mode mode);
381
382
383
384
385
386
387
388
389
390
391
392int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
393
394
395
396
397
398
399
400
401
402int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
403 struct qed_ptt *p_ptt);
404
405
406
407
408
409
410
411
412
413int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
414 struct qed_ptt *p_ptt);
415
416
417
418
419
420
421
422
423
424
425
426int qed_mcp_bist_nvm_test_get_num_images(struct qed_hwfn *p_hwfn,
427 struct qed_ptt *p_ptt,
428 u32 *num_images);
429
430
431
432
433
434
435
436
437
438
439
440int qed_mcp_bist_nvm_test_get_image_att(struct qed_hwfn *p_hwfn,
441 struct qed_ptt *p_ptt,
442 struct bist_nvm_image_att *p_image_att,
443 u32 image_index);
444
445
446
447
448
449
450
451#define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
452 ((rel_pfid) | \
453 ((p_hwfn)->abs_pf_id & 1) << 3) : \
454 rel_pfid)
455#define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
456
457
458
459
460#define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
461 ((_p_hwfn)->cdev->num_ports_in_engines * 2))
462struct qed_mcp_info {
463 spinlock_t lock;
464 bool block_mb_sending;
465 u32 public_base;
466 u32 drv_mb_addr;
467 u32 mfw_mb_addr;
468 u32 port_addr;
469 u16 drv_mb_seq;
470 u16 drv_pulse_seq;
471 struct qed_mcp_link_params link_input;
472 struct qed_mcp_link_state link_output;
473 struct qed_mcp_link_capabilities link_capabilities;
474 struct qed_mcp_function_info func_info;
475 u8 *mfw_mb_cur;
476 u8 *mfw_mb_shadow;
477 u16 mfw_mb_length;
478 u16 mcp_hist;
479};
480
481struct qed_mcp_mb_params {
482 u32 cmd;
483 u32 param;
484 union drv_union_data *p_data_src;
485 union drv_union_data *p_data_dst;
486 u32 mcp_resp;
487 u32 mcp_param;
488};
489
490
491
492
493
494
495
496
497
498int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
499 struct qed_ptt *p_ptt);
500
501
502
503
504
505
506
507
508void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
509 struct qed_ptt *p_ptt);
510
511
512
513
514
515
516
517
518
519int qed_mcp_free(struct qed_hwfn *p_hwfn);
520
521
522
523
524
525
526
527
528
529
530
531
532
533int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
534 struct qed_ptt *p_ptt);
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
555 struct qed_ptt *p_ptt,
556 u32 *p_load_code);
557
558
559
560
561
562
563
564void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
565 struct qed_ptt *p_ptt);
566
567
568
569
570
571
572
573
574
575
576int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
577 struct qed_ptt *p_ptt, u32 *vfs_to_ack);
578
579
580
581
582
583
584
585
586int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
587 struct qed_ptt *p_ptt);
588
589
590
591
592
593
594
595
596
597int qed_mcp_reset(struct qed_hwfn *p_hwfn,
598 struct qed_ptt *p_ptt);
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
617 struct qed_ptt *p_ptt,
618 u32 cmd,
619 u32 param,
620 u32 *o_mcp_resp,
621 u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf);
622
623
624
625
626
627
628
629
630bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
631
632
633
634
635
636
637
638
639
640
641
642int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
643 struct qed_ptt *p_ptt, u8 vf_id, u8 num);
644
645
646
647
648
649
650
651
652
653int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
654
655
656
657
658
659
660
661
662
663int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
664
665int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
666int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
667int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
668 struct qed_ptt *p_ptt,
669 struct qed_mcp_link_state *p_link,
670 u8 max_bw);
671int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
672 struct qed_ptt *p_ptt,
673 struct qed_mcp_link_state *p_link,
674 u8 min_bw);
675
676int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
677 struct qed_ptt *p_ptt, u32 mask_parities);
678
679
680
681
682
683
684
685
686
687
688int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
689 struct qed_ptt *p_ptt,
690 enum qed_ov_eswitch eswitch);
691
692
693
694
695
696
697
698
699
700
701
702
703int qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
704 struct qed_ptt *p_ptt,
705 struct resource_info *p_resc_info,
706 u32 *p_mcp_resp, u32 *p_mcp_param);
707#endif
708