net/qede/base: fix to handle stag update event
[dpdk.git] / drivers / net / qede / base / ecore_mcp_api.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6
7 #ifndef __ECORE_MCP_API_H__
8 #define __ECORE_MCP_API_H__
9
10 #include "ecore_status.h"
11
12 struct ecore_mcp_link_speed_params {
13         bool autoneg;
14         u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */
15         u32 forced_speed; /* In Mb/s */
16 };
17
18 struct ecore_mcp_link_pause_params {
19         bool autoneg;
20         bool forced_rx;
21         bool forced_tx;
22 };
23
24 enum ecore_mcp_eee_mode {
25         ECORE_MCP_EEE_DISABLED,
26         ECORE_MCP_EEE_ENABLED,
27         ECORE_MCP_EEE_UNSUPPORTED
28 };
29
30 struct ecore_link_eee_params {
31         u32 tx_lpi_timer;
32 #define ECORE_EEE_1G_ADV        (1 << 0)
33 #define ECORE_EEE_10G_ADV       (1 << 1)
34         /* Capabilities are represented using ECORE_EEE_*_ADV values */
35         u8 adv_caps;
36         u8 lp_adv_caps;
37         bool enable;
38         bool tx_lpi_enable;
39 };
40
41 struct ecore_mcp_link_params {
42         struct ecore_mcp_link_speed_params speed;
43         struct ecore_mcp_link_pause_params pause;
44         u32 loopback_mode; /* in PMM_LOOPBACK values */
45         struct ecore_link_eee_params eee;
46 };
47
48 struct ecore_mcp_link_capabilities {
49         u32 speed_capabilities;
50         bool default_speed_autoneg; /* In Mb/s */
51         u32 default_speed; /* In Mb/s */
52         enum ecore_mcp_eee_mode default_eee;
53         u32 eee_lpi_timer;
54         u8 eee_speed_caps;
55 };
56
57 struct ecore_mcp_link_state {
58         bool link_up;
59
60         u32 min_pf_rate; /* In Mb/s */
61
62         /* Actual link speed in Mb/s */
63         u32 line_speed;
64
65         /* PF max speed in MB/s, deduced from line_speed
66          * according to PF max bandwidth configuration.
67          */
68         u32 speed;
69         bool full_duplex;
70
71         bool an;
72         bool an_complete;
73         bool parallel_detection;
74         bool pfc_enabled;
75
76 #define ECORE_LINK_PARTNER_SPEED_1G_HD  (1 << 0)
77 #define ECORE_LINK_PARTNER_SPEED_1G_FD  (1 << 1)
78 #define ECORE_LINK_PARTNER_SPEED_10G    (1 << 2)
79 #define ECORE_LINK_PARTNER_SPEED_20G    (1 << 3)
80 #define ECORE_LINK_PARTNER_SPEED_25G    (1 << 4)
81 #define ECORE_LINK_PARTNER_SPEED_40G    (1 << 5)
82 #define ECORE_LINK_PARTNER_SPEED_50G    (1 << 6)
83 #define ECORE_LINK_PARTNER_SPEED_100G   (1 << 7)
84         u32 partner_adv_speed;
85
86         bool partner_tx_flow_ctrl_en;
87         bool partner_rx_flow_ctrl_en;
88
89 #define ECORE_LINK_PARTNER_SYMMETRIC_PAUSE (1)
90 #define ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
91 #define ECORE_LINK_PARTNER_BOTH_PAUSE (3)
92         u8 partner_adv_pause;
93
94         bool sfp_tx_fault;
95
96         bool eee_active;
97         u8 eee_adv_caps;
98         u8 eee_lp_adv_caps;
99 };
100
101 struct ecore_mcp_function_info {
102         u8 pause_on_host;
103
104         enum ecore_pci_personality protocol;
105
106         u8 bandwidth_min;
107         u8 bandwidth_max;
108
109         u8 mac[ETH_ALEN];
110
111         u64 wwn_port;
112         u64 wwn_node;
113
114 #define ECORE_MCP_VLAN_UNSET            (0xffff)
115         u16 ovlan;
116
117         u16 mtu;
118 };
119
120 #ifndef __EXTRACT__LINUX__
121 enum ecore_nvm_images {
122         ECORE_NVM_IMAGE_ISCSI_CFG,
123         ECORE_NVM_IMAGE_FCOE_CFG,
124 };
125 #endif
126
127 struct ecore_mcp_drv_version {
128         u32 version;
129         u8 name[MCP_DRV_VER_STR_SIZE - 4];
130 };
131
132 struct ecore_mcp_lan_stats {
133         u64 ucast_rx_pkts;
134         u64 ucast_tx_pkts;
135         u32 fcs_err;
136 };
137
138 #ifndef ECORE_PROTO_STATS
139 #define ECORE_PROTO_STATS
140 struct ecore_mcp_fcoe_stats {
141         u64 rx_pkts;
142         u64 tx_pkts;
143         u32 fcs_err;
144         u32 login_failure;
145 };
146
147 struct ecore_mcp_iscsi_stats {
148         u64 rx_pdus;
149         u64 tx_pdus;
150         u64 rx_bytes;
151         u64 tx_bytes;
152 };
153
154 struct ecore_mcp_rdma_stats {
155         u64 rx_pkts;
156         u64 tx_pkts;
157         u64 rx_bytes;
158         u64 tx_byts;
159 };
160
161 enum ecore_mcp_protocol_type {
162         ECORE_MCP_LAN_STATS,
163         ECORE_MCP_FCOE_STATS,
164         ECORE_MCP_ISCSI_STATS,
165         ECORE_MCP_RDMA_STATS
166 };
167
168 union ecore_mcp_protocol_stats {
169         struct ecore_mcp_lan_stats lan_stats;
170         struct ecore_mcp_fcoe_stats fcoe_stats;
171         struct ecore_mcp_iscsi_stats iscsi_stats;
172         struct ecore_mcp_rdma_stats rdma_stats;
173 };
174 #endif
175
176 enum ecore_ov_client {
177         ECORE_OV_CLIENT_DRV,
178         ECORE_OV_CLIENT_USER,
179         ECORE_OV_CLIENT_VENDOR_SPEC
180 };
181
182 enum ecore_ov_driver_state {
183         ECORE_OV_DRIVER_STATE_NOT_LOADED,
184         ECORE_OV_DRIVER_STATE_DISABLED,
185         ECORE_OV_DRIVER_STATE_ACTIVE
186 };
187
188 #define ECORE_MAX_NPIV_ENTRIES 128
189 #define ECORE_WWN_SIZE 8
190 struct ecore_fc_npiv_tbl {
191         u32 count;
192         u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
193         u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
194 };
195
196 #ifndef __EXTRACT__LINUX__
197 enum ecore_led_mode {
198         ECORE_LED_MODE_OFF,
199         ECORE_LED_MODE_ON,
200         ECORE_LED_MODE_RESTORE
201 };
202 #endif
203
204 struct ecore_temperature_sensor {
205         u8 sensor_location;
206         u8 threshold_high;
207         u8 critical;
208         u8 current_temp;
209 };
210
211 #define ECORE_MAX_NUM_OF_SENSORS        7
212 struct ecore_temperature_info {
213         u32 num_sensors;
214         struct ecore_temperature_sensor sensors[ECORE_MAX_NUM_OF_SENSORS];
215 };
216
217 enum ecore_mba_img_idx {
218         ECORE_MBA_LEGACY_IDX,
219         ECORE_MBA_PCI3CLP_IDX,
220         ECORE_MBA_PCI3_IDX,
221         ECORE_MBA_FCODE_IDX,
222         ECORE_EFI_X86_IDX,
223         ECORE_EFI_IPF_IDX,
224         ECORE_EFI_EBC_IDX,
225         ECORE_EFI_X64_IDX,
226         ECORE_MAX_NUM_OF_ROMIMG
227 };
228
229 struct ecore_mba_vers {
230         u32 mba_vers[ECORE_MAX_NUM_OF_ROMIMG];
231 };
232
233 enum ecore_mfw_tlv_type {
234         ECORE_MFW_TLV_GENERIC = 0x1, /* Core driver TLVs */
235         ECORE_MFW_TLV_ETH = 0x2, /* L2 driver TLVs */
236         ECORE_MFW_TLV_FCOE = 0x4, /* FCoE protocol TLVs */
237         ECORE_MFW_TLV_ISCSI = 0x8, /* SCSI protocol TLVs */
238         ECORE_MFW_TLV_MAX = 0x16,
239 };
240
241 struct ecore_mfw_tlv_generic {
242         u16 feat_flags;
243         bool feat_flags_set;
244         u64 local_mac;
245         bool local_mac_set;
246         u64 additional_mac1;
247         bool additional_mac1_set;
248         u64 additional_mac2;
249         bool additional_mac2_set;
250         u8 drv_state;
251         bool drv_state_set;
252         u8 pxe_progress;
253         bool pxe_progress_set;
254         u64 rx_frames;
255         bool rx_frames_set;
256         u64 rx_bytes;
257         bool rx_bytes_set;
258         u64 tx_frames;
259         bool tx_frames_set;
260         u64 tx_bytes;
261         bool tx_bytes_set;
262 };
263
264 struct ecore_mfw_tlv_eth {
265         u16 lso_maxoff_size;
266         bool lso_maxoff_size_set;
267         u16 lso_minseg_size;
268         bool lso_minseg_size_set;
269         u8 prom_mode;
270         bool prom_mode_set;
271         u16 tx_descr_size;
272         bool tx_descr_size_set;
273         u16 rx_descr_size;
274         bool rx_descr_size_set;
275         u16 netq_count;
276         bool netq_count_set;
277         u32 tcp4_offloads;
278         bool tcp4_offloads_set;
279         u32 tcp6_offloads;
280         bool tcp6_offloads_set;
281         u16 tx_descr_qdepth;
282         bool tx_descr_qdepth_set;
283         u16 rx_descr_qdepth;
284         bool rx_descr_qdepth_set;
285         u8 iov_offload;
286         bool iov_offload_set;
287         u8 txqs_empty;
288         bool txqs_empty_set;
289         u8 rxqs_empty;
290         bool rxqs_empty_set;
291         u8 num_txqs_full;
292         bool num_txqs_full_set;
293         u8 num_rxqs_full;
294         bool num_rxqs_full_set;
295 };
296
297 struct ecore_mfw_tlv_fcoe {
298         u8 scsi_timeout;
299         bool scsi_timeout_set;
300         u32 rt_tov;
301         bool rt_tov_set;
302         u32 ra_tov;
303         bool ra_tov_set;
304         u32 ed_tov;
305         bool ed_tov_set;
306         u32 cr_tov;
307         bool cr_tov_set;
308         u8 boot_type;
309         bool boot_type_set;
310         u8 npiv_state;
311         bool npiv_state_set;
312         u32 num_npiv_ids;
313         bool num_npiv_ids_set;
314         u8 switch_name[8];
315         bool switch_name_set;
316         u16 switch_portnum;
317         bool switch_portnum_set;
318         u8 switch_portid[3];
319         bool switch_portid_set;
320         u8 vendor_name[8];
321         bool vendor_name_set;
322         u8 switch_model[8];
323         bool switch_model_set;
324         u8 switch_fw_version[8];
325         bool switch_fw_version_set;
326         u8 qos_pri;
327         bool qos_pri_set;
328         u8 port_alias[3];
329         bool port_alias_set;
330         u8 port_state;
331         bool port_state_set;
332         u16 fip_tx_descr_size;
333         bool fip_tx_descr_size_set;
334         u16 fip_rx_descr_size;
335         bool fip_rx_descr_size_set;
336         u16 link_failures;
337         bool link_failures_set;
338         u8 fcoe_boot_progress;
339         bool fcoe_boot_progress_set;
340         u64 rx_bcast;
341         bool rx_bcast_set;
342         u64 tx_bcast;
343         bool tx_bcast_set;
344         u16 fcoe_txq_depth;
345         bool fcoe_txq_depth_set;
346         u16 fcoe_rxq_depth;
347         bool fcoe_rxq_depth_set;
348         u64 fcoe_rx_frames;
349         bool fcoe_rx_frames_set;
350         u64 fcoe_rx_bytes;
351         bool fcoe_rx_bytes_set;
352         u64 fcoe_tx_frames;
353         bool fcoe_tx_frames_set;
354         u64 fcoe_tx_bytes;
355         bool fcoe_tx_bytes_set;
356         u16 crc_count;
357         bool crc_count_set;
358         u32 crc_err_src_fcid[5];
359         bool crc_err_src_fcid_set[5];
360         u8 crc_err_tstamp[5][14];
361         bool crc_err_tstamp_set[5];
362         u16 losync_err;
363         bool losync_err_set;
364         u16 losig_err;
365         bool losig_err_set;
366         u16 primtive_err;
367         bool primtive_err_set;
368         u16 disparity_err;
369         bool disparity_err_set;
370         u16 code_violation_err;
371         bool code_violation_err_set;
372         u32 flogi_param[4];
373         bool flogi_param_set[4];
374         u8 flogi_tstamp[14];
375         bool flogi_tstamp_set;
376         u32 flogi_acc_param[4];
377         bool flogi_acc_param_set[4];
378         u8 flogi_acc_tstamp[14];
379         bool flogi_acc_tstamp_set;
380         u32 flogi_rjt;
381         bool flogi_rjt_set;
382         u8 flogi_rjt_tstamp[14];
383         bool flogi_rjt_tstamp_set;
384         u32 fdiscs;
385         bool fdiscs_set;
386         u8 fdisc_acc;
387         bool fdisc_acc_set;
388         u8 fdisc_rjt;
389         bool fdisc_rjt_set;
390         u8 plogi;
391         bool plogi_set;
392         u8 plogi_acc;
393         bool plogi_acc_set;
394         u8 plogi_rjt;
395         bool plogi_rjt_set;
396         u32 plogi_dst_fcid[5];
397         bool plogi_dst_fcid_set[5];
398         u8 plogi_tstamp[5][14];
399         bool plogi_tstamp_set[5];
400         u32 plogi_acc_src_fcid[5];
401         bool plogi_acc_src_fcid_set[5];
402         u8 plogi_acc_tstamp[5][14];
403         bool plogi_acc_tstamp_set[5];
404         u8 tx_plogos;
405         bool tx_plogos_set;
406         u8 plogo_acc;
407         bool plogo_acc_set;
408         u8 plogo_rjt;
409         bool plogo_rjt_set;
410         u32 plogo_src_fcid[5];
411         bool plogo_src_fcid_set[5];
412         u8 plogo_tstamp[5][14];
413         bool plogo_tstamp_set[5];
414         u8 rx_logos;
415         bool rx_logos_set;
416         u8 tx_accs;
417         bool tx_accs_set;
418         u8 tx_prlis;
419         bool tx_prlis_set;
420         u8 rx_accs;
421         bool rx_accs_set;
422         u8 tx_abts;
423         bool tx_abts_set;
424         u8 rx_abts_acc;
425         bool rx_abts_acc_set;
426         u8 rx_abts_rjt;
427         bool rx_abts_rjt_set;
428         u32 abts_dst_fcid[5];
429         bool abts_dst_fcid_set[5];
430         u8 abts_tstamp[5][14];
431         bool abts_tstamp_set[5];
432         u8 rx_rscn;
433         bool rx_rscn_set;
434         u32 rx_rscn_nport[4];
435         bool rx_rscn_nport_set[4];
436         u8 tx_lun_rst;
437         bool tx_lun_rst_set;
438         u8 abort_task_sets;
439         bool abort_task_sets_set;
440         u8 tx_tprlos;
441         bool tx_tprlos_set;
442         u8 tx_nos;
443         bool tx_nos_set;
444         u8 rx_nos;
445         bool rx_nos_set;
446         u8 ols;
447         bool ols_set;
448         u8 lr;
449         bool lr_set;
450         u8 lrr;
451         bool lrr_set;
452         u8 tx_lip;
453         bool tx_lip_set;
454         u8 rx_lip;
455         bool rx_lip_set;
456         u8 eofa;
457         bool eofa_set;
458         u8 eofni;
459         bool eofni_set;
460         u8 scsi_chks;
461         bool scsi_chks_set;
462         u8 scsi_cond_met;
463         bool scsi_cond_met_set;
464         u8 scsi_busy;
465         bool scsi_busy_set;
466         u8 scsi_inter;
467         bool scsi_inter_set;
468         u8 scsi_inter_cond_met;
469         bool scsi_inter_cond_met_set;
470         u8 scsi_rsv_conflicts;
471         bool scsi_rsv_conflicts_set;
472         u8 scsi_tsk_full;
473         bool scsi_tsk_full_set;
474         u8 scsi_aca_active;
475         bool scsi_aca_active_set;
476         u8 scsi_tsk_abort;
477         bool scsi_tsk_abort_set;
478         u32 scsi_rx_chk[5];
479         bool scsi_rx_chk_set[5];
480         u8 scsi_chk_tstamp[5][14];
481         bool scsi_chk_tstamp_set[5];
482 };
483
484 struct ecore_mfw_tlv_iscsi {
485         u8 target_llmnr;
486         bool target_llmnr_set;
487         u8 header_digest;
488         bool header_digest_set;
489         u8 data_digest;
490         bool data_digest_set;
491         u8 auth_method;
492         bool auth_method_set;
493         u16 boot_taget_portal;
494         bool boot_taget_portal_set;
495         u16 frame_size;
496         bool frame_size_set;
497         u16 tx_desc_size;
498         bool tx_desc_size_set;
499         u16 rx_desc_size;
500         bool rx_desc_size_set;
501         u8 boot_progress;
502         bool boot_progress_set;
503         u16 tx_desc_qdepth;
504         bool tx_desc_qdepth_set;
505         u16 rx_desc_qdepth;
506         bool rx_desc_qdepth_set;
507         u64 rx_frames;
508         bool rx_frames_set;
509         u64 rx_bytes;
510         bool rx_bytes_set;
511         u64 tx_frames;
512         bool tx_frames_set;
513         u64 tx_bytes;
514         bool tx_bytes_set;
515 };
516
517 union ecore_mfw_tlv_data {
518         struct ecore_mfw_tlv_generic generic;
519         struct ecore_mfw_tlv_eth eth;
520         struct ecore_mfw_tlv_fcoe fcoe;
521         struct ecore_mfw_tlv_iscsi iscsi;
522 };
523
524 enum ecore_hw_info_change {
525         ECORE_HW_INFO_CHANGE_OVLAN,
526 };
527
528 /**
529  * @brief - returns the link params of the hw function
530  *
531  * @param p_hwfn
532  *
533  * @returns pointer to link params
534  */
535 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
536
537 /**
538  * @brief - return the link state of the hw function
539  *
540  * @param p_hwfn
541  *
542  * @returns pointer to link state
543  */
544 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
545
546 /**
547  * @brief - return the link capabilities of the hw function
548  *
549  * @param p_hwfn
550  *
551  * @returns pointer to link capabilities
552  */
553 struct ecore_mcp_link_capabilities
554 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
555
556 /**
557  * @brief Request the MFW to set the link according to 'link_input'.
558  *
559  * @param p_hwfn
560  * @param p_ptt
561  * @param b_up - raise link if `true'. Reset link if `false'.
562  *
563  * @return enum _ecore_status_t
564  */
565 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
566                                         struct ecore_ptt *p_ptt,
567                                         bool b_up);
568
569 /**
570  * @brief Get the management firmware version value
571  *
572  * @param p_hwfn
573  * @param p_ptt
574  * @param p_mfw_ver    - mfw version value
575  * @param p_running_bundle_id   - image id in nvram; Optional.
576  *
577  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
578  */
579 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
580                                            struct ecore_ptt *p_ptt,
581                                            u32 *p_mfw_ver,
582                                            u32 *p_running_bundle_id);
583
584 /**
585  * @brief Get media type value of the port.
586  *
587  * @param p_dev      - ecore dev pointer
588  * @param p_ptt
589  * @param mfw_ver    - media type value
590  *
591  * @return enum _ecore_status_t -
592  *      ECORE_SUCCESS - Operation was successful.
593  *      ECORE_BUSY - Operation failed
594  */
595 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_hwfn *p_hwfn,
596                                               struct ecore_ptt *p_ptt,
597                                               u32 *media_type);
598
599 /**
600  * @brief Get transceiver data of the port.
601  *
602  * @param p_dev      - ecore dev pointer
603  * @param p_ptt
604  * @param p_transceiver_type - media type value
605  *
606  * @return enum _ecore_status_t -
607  *      ECORE_SUCCESS - Operation was successful.
608  *      ECORE_BUSY - Operation failed
609  */
610 enum _ecore_status_t ecore_mcp_get_transceiver_data(struct ecore_hwfn *p_hwfn,
611                                                     struct ecore_ptt *p_ptt,
612                                                     u32 *p_tranceiver_type);
613
614 /**
615  * @brief Get transceiver supported speed mask.
616  *
617  * @param p_dev      - ecore dev pointer
618  * @param p_ptt
619  * @param p_speed_mask - Bit mask of all supported speeds.
620  *
621  * @return enum _ecore_status_t -
622  *      ECORE_SUCCESS - Operation was successful.
623  *      ECORE_BUSY - Operation failed
624  */
625
626 enum _ecore_status_t ecore_mcp_trans_speed_mask(struct ecore_hwfn *p_hwfn,
627                                                 struct ecore_ptt *p_ptt,
628                                                 u32 *p_speed_mask);
629
630 /**
631  * @brief Get board configuration.
632  *
633  * @param p_dev      - ecore dev pointer
634  * @param p_ptt
635  * @param p_board_config - Board config.
636  *
637  * @return enum _ecore_status_t -
638  *      ECORE_SUCCESS - Operation was successful.
639  *      ECORE_BUSY - Operation failed
640  */
641 enum _ecore_status_t ecore_mcp_get_board_config(struct ecore_hwfn *p_hwfn,
642                                                 struct ecore_ptt *p_ptt,
643                                                 u32 *p_board_config);
644
645 /**
646  * @brief - Sends a command to the MCP mailbox.
647  *
648  * @param p_hwfn      - hw function
649  * @param p_ptt       - PTT required for register access
650  * @param cmd         - command to be sent to the MCP
651  * @param param       - Optional param
652  * @param o_mcp_resp  - The MCP response code (exclude sequence)
653  * @param o_mcp_param - Optional parameter provided by the MCP response
654  *
655  * @return enum _ecore_status_t -
656  *      ECORE_SUCCESS - operation was successful
657  *      ECORE_BUSY    - operation failed
658  */
659 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
660                                    struct ecore_ptt *p_ptt, u32 cmd, u32 param,
661                                    u32 *o_mcp_resp, u32 *o_mcp_param);
662
663 /**
664  * @brief - drains the nig, allowing completion to pass in case of pauses.
665  *          (Should be called only from sleepable context)
666  *
667  * @param p_hwfn
668  * @param p_ptt
669  */
670 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
671                                      struct ecore_ptt *p_ptt);
672
673 #ifndef LINUX_REMOVE
674 /**
675  * @brief - return the mcp function info of the hw function
676  *
677  * @param p_hwfn
678  *
679  * @returns pointer to mcp function info
680  */
681 const struct ecore_mcp_function_info
682 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
683 #endif
684
685 #ifndef LINUX_REMOVE
686 /**
687  * @brief - count number of function with a matching personality on engine.
688  *
689  * @param p_hwfn
690  * @param p_ptt
691  * @param personalities - a bitmask of ecore_pci_personality values
692  *
693  * @returns the count of all devices on engine whose personality match one of
694  *          the bitsmasks.
695  */
696 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
697                                   struct ecore_ptt *p_ptt,
698                                   u32 personalities);
699 #endif
700
701 /**
702  * @brief Get the flash size value
703  *
704  * @param p_hwfn
705  * @param p_ptt
706  * @param p_flash_size  - flash size in bytes to be filled.
707  *
708  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
709  */
710 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
711                                               struct ecore_ptt *p_ptt,
712                                               u32 *p_flash_size);
713
714 /**
715  * @brief Send driver version to MFW
716  *
717  * @param p_hwfn
718  * @param p_ptt
719  * @param version - Version value
720  * @param name - Protocol driver name
721  *
722  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
723  */
724 enum _ecore_status_t
725 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
726                            struct ecore_mcp_drv_version *p_ver);
727
728 /**
729  * @brief Read the MFW process kill counter
730  *
731  * @param p_hwfn
732  * @param p_ptt
733  *
734  * @return u32
735  */
736 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
737                                    struct ecore_ptt *p_ptt);
738
739 /**
740  * @brief Trigger a recovery process
741  *
742  *  @param p_hwfn
743  *  @param p_ptt
744  *
745  * @return enum _ecore_status_t
746  */
747 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
748                                                   struct ecore_ptt *p_ptt);
749
750 /**
751  * @brief A recovery handler must call this function as its first step.
752  *        It is assumed that the handler is not run from an interrupt context.
753  *
754  *  @param p_dev
755  *  @param p_ptt
756  *
757  * @return enum _ecore_status_t
758  */
759 enum _ecore_status_t ecore_recovery_prolog(struct ecore_dev *p_dev);
760
761 /**
762  * @brief Notify MFW about the change in base device properties
763  *
764  *  @param p_hwfn
765  *  @param p_ptt
766  *  @param client - ecore client type
767  *
768  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
769  */
770 enum _ecore_status_t
771 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
772                                    struct ecore_ptt *p_ptt,
773                                    enum ecore_ov_client client);
774
775 /**
776  * @brief Notify MFW about the driver state
777  *
778  *  @param p_hwfn
779  *  @param p_ptt
780  *  @param drv_state - Driver state
781  *
782  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
783  */
784 enum _ecore_status_t
785 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
786                                  struct ecore_ptt *p_ptt,
787                                  enum ecore_ov_driver_state drv_state);
788
789 /**
790  * @brief Read NPIV settings form the MFW
791  *
792  *  @param p_hwfn
793  *  @param p_ptt
794  *  @param p_table - Array to hold the FC NPIV data. Client need allocate the
795  *                   required buffer. The field 'count' specifies number of NPIV
796  *                   entries. A value of 0 means the table was not populated.
797  *
798  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
799  */
800 enum _ecore_status_t
801 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
802                          struct ecore_fc_npiv_tbl *p_table);
803
804 /**
805  * @brief Send MTU size to MFW
806  *
807  *  @param p_hwfn
808  *  @param p_ptt
809  *  @param mtu - MTU size
810  *
811  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
812  */
813 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
814                                              struct ecore_ptt *p_ptt, u16 mtu);
815
816 /**
817  * @brief Set LED status
818  *
819  *  @param p_hwfn
820  *  @param p_ptt
821  *  @param mode - LED mode
822  *
823  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
824  */
825 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
826                                        struct ecore_ptt *p_ptt,
827                                        enum ecore_led_mode mode);
828
829 /**
830  * @brief Set secure mode
831  *
832  *  @param p_dev
833  *  @param addr - nvm offset
834  *
835  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
836  */
837 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
838                                                    u32 addr);
839
840 /**
841  * @brief Write to phy
842  *
843  *  @param p_dev
844  *  @param addr - nvm offset
845  *  @param cmd - nvm command
846  *  @param p_buf - nvm write buffer
847  *  @param len - buffer len
848  *
849  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
850  */
851 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
852                                          u32 addr, u8 *p_buf, u32 len);
853
854 /**
855  * @brief Write to nvm
856  *
857  *  @param p_dev
858  *  @param addr - nvm offset
859  *  @param cmd - nvm command
860  *  @param p_buf - nvm write buffer
861  *  @param len - buffer len
862  *
863  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
864  */
865 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
866                                          u32 addr, u8 *p_buf, u32 len);
867
868 /**
869  * @brief Put file begin
870  *
871  *  @param p_dev
872  *  @param addr - nvm offset
873  *
874  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
875  */
876 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
877                                                   u32 addr);
878
879 /**
880  * @brief Delete file
881  *
882  *  @param p_dev
883  *  @param addr - nvm offset
884  *
885  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
886  */
887 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev,
888                                             u32 addr);
889
890 /**
891  * @brief Check latest response
892  *
893  *  @param p_dev
894  *  @param p_buf - nvm write buffer
895  *
896  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
897  */
898 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
899
900 /**
901  * @brief Read from phy
902  *
903  *  @param p_dev
904  *  @param addr - nvm offset
905  *  @param cmd - nvm command
906  *  @param p_buf - nvm read buffer
907  *  @param len - buffer len
908  *
909  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
910  */
911 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
912                                         u32 addr, u8 *p_buf, u32 len);
913
914 /**
915  * @brief Read from nvm
916  *
917  *  @param p_dev
918  *  @param addr - nvm offset
919  *  @param p_buf - nvm read buffer
920  *  @param len - buffer len
921  *
922  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
923  */
924 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
925                            u8 *p_buf, u32 len);
926
927 /**
928  * @brief - Sends an NVM write command request to the MFW with
929  *          payload.
930  *
931  * @param p_hwfn
932  * @param p_ptt
933  * @param cmd - Command: Either DRV_MSG_CODE_NVM_WRITE_NVRAM or
934  *            DRV_MSG_CODE_NVM_PUT_FILE_DATA
935  * @param param - [0:23] - Offset [24:31] - Size
936  * @param o_mcp_resp - MCP response
937  * @param o_mcp_param - MCP response param
938  * @param i_txn_size -  Buffer size
939  * @param i_buf - Pointer to the buffer
940  *
941  * @param return ECORE_SUCCESS upon success.
942  */
943 enum _ecore_status_t ecore_mcp_nvm_wr_cmd(struct ecore_hwfn *p_hwfn,
944                                           struct ecore_ptt *p_ptt,
945                                           u32 cmd,
946                                           u32 param,
947                                           u32 *o_mcp_resp,
948                                           u32 *o_mcp_param,
949                                           u32 i_txn_size,
950                                           u32 *i_buf);
951
952 /**
953  * @brief - Sends an NVM read command request to the MFW to get
954  *        a buffer.
955  *
956  * @param p_hwfn
957  * @param p_ptt
958  * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
959  *            DRV_MSG_CODE_NVM_READ_NVRAM commands
960  * @param param - [0:23] - Offset [24:31] - Size
961  * @param o_mcp_resp - MCP response
962  * @param o_mcp_param - MCP response param
963  * @param o_txn_size -  Buffer size output
964  * @param o_buf - Pointer to the buffer returned by the MFW.
965  *
966  * @param return ECORE_SUCCESS upon success.
967  */
968 enum _ecore_status_t ecore_mcp_nvm_rd_cmd(struct ecore_hwfn *p_hwfn,
969                                           struct ecore_ptt *p_ptt,
970                                           u32 cmd,
971                                           u32 param,
972                                           u32 *o_mcp_resp,
973                                           u32 *o_mcp_param,
974                                           u32 *o_txn_size,
975                                           u32 *o_buf);
976
977 /**
978  * @brief Read from sfp
979  *
980  *  @param p_hwfn - hw function
981  *  @param p_ptt  - PTT required for register access
982  *  @param port   - transceiver port
983  *  @param addr   - I2C address
984  *  @param offset - offset in sfp
985  *  @param len    - buffer length
986  *  @param p_buf  - buffer to read into
987  *
988  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
989  */
990 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
991                                             struct ecore_ptt *p_ptt,
992                                             u32 port, u32 addr, u32 offset,
993                                             u32 len, u8 *p_buf);
994
995 /**
996  * @brief Write to sfp
997  *
998  *  @param p_hwfn - hw function
999  *  @param p_ptt  - PTT required for register access
1000  *  @param port   - transceiver port
1001  *  @param addr   - I2C address
1002  *  @param offset - offset in sfp
1003  *  @param len    - buffer length
1004  *  @param p_buf  - buffer to write from
1005  *
1006  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1007  */
1008 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
1009                                              struct ecore_ptt *p_ptt,
1010                                              u32 port, u32 addr, u32 offset,
1011                                              u32 len, u8 *p_buf);
1012
1013 /**
1014  * @brief Gpio read
1015  *
1016  *  @param p_hwfn    - hw function
1017  *  @param p_ptt     - PTT required for register access
1018  *  @param gpio      - gpio number
1019  *  @param gpio_val  - value read from gpio
1020  *
1021  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1022  */
1023 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
1024                                          struct ecore_ptt *p_ptt,
1025                                          u16 gpio, u32 *gpio_val);
1026
1027 /**
1028  * @brief Gpio write
1029  *
1030  *  @param p_hwfn    - hw function
1031  *  @param p_ptt     - PTT required for register access
1032  *  @param gpio      - gpio number
1033  *  @param gpio_val  - value to write to gpio
1034  *
1035  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1036  */
1037 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
1038                                           struct ecore_ptt *p_ptt,
1039                                           u16 gpio, u16 gpio_val);
1040
1041 /**
1042  * @brief Gpio get information
1043  *
1044  *  @param p_hwfn          - hw function
1045  *  @param p_ptt           - PTT required for register access
1046  *  @param gpio            - gpio number
1047  *  @param gpio_direction  - gpio is output (0) or input (1)
1048  *  @param gpio_ctrl       - gpio control is uninitialized (0),
1049  *                         path 0 (1), path 1 (2) or shared(3)
1050  *
1051  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1052  */
1053 enum _ecore_status_t ecore_mcp_gpio_info(struct ecore_hwfn *p_hwfn,
1054                                          struct ecore_ptt *p_ptt,
1055                                          u16 gpio, u32 *gpio_direction,
1056                                          u32 *gpio_ctrl);
1057
1058 /**
1059  * @brief Bist register test
1060  *
1061  *  @param p_hwfn    - hw function
1062  *  @param p_ptt     - PTT required for register access
1063  *
1064  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1065  */
1066 enum _ecore_status_t ecore_mcp_bist_register_test(struct ecore_hwfn *p_hwfn,
1067                                                    struct ecore_ptt *p_ptt);
1068
1069 /**
1070  * @brief Bist clock test
1071  *
1072  *  @param p_hwfn    - hw function
1073  *  @param p_ptt     - PTT required for register access
1074  *
1075  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1076  */
1077 enum _ecore_status_t ecore_mcp_bist_clock_test(struct ecore_hwfn *p_hwfn,
1078                                                 struct ecore_ptt *p_ptt);
1079
1080 /**
1081  * @brief Bist nvm test - get number of images
1082  *
1083  *  @param p_hwfn       - hw function
1084  *  @param p_ptt        - PTT required for register access
1085  *  @param num_images   - number of images if operation was
1086  *                        successful. 0 if not.
1087  *
1088  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1089  */
1090 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_num_images(
1091                                                 struct ecore_hwfn *p_hwfn,
1092                                                 struct ecore_ptt *p_ptt,
1093                                                 u32 *num_images);
1094
1095 /**
1096  * @brief Bist nvm test - get image attributes by index
1097  *
1098  *  @param p_hwfn      - hw function
1099  *  @param p_ptt       - PTT required for register access
1100  *  @param p_image_att - Attributes of image
1101  *  @param image_index - Index of image to get information for
1102  *
1103  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1104  */
1105 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_image_att(
1106                                         struct ecore_hwfn *p_hwfn,
1107                                         struct ecore_ptt *p_ptt,
1108                                         struct bist_nvm_image_att *p_image_att,
1109                                         u32 image_index);
1110
1111 /**
1112  * @brief ecore_mcp_get_temperature_info - get the status of the temperature
1113  *                                         sensors
1114  *
1115  *  @param p_hwfn        - hw function
1116  *  @param p_ptt         - PTT required for register access
1117  *  @param p_temp_status - A pointer to an ecore_temperature_info structure to
1118  *                         be filled with the temperature data
1119  *
1120  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1121  */
1122 enum _ecore_status_t
1123 ecore_mcp_get_temperature_info(struct ecore_hwfn *p_hwfn,
1124                                struct ecore_ptt *p_ptt,
1125                                struct ecore_temperature_info *p_temp_info);
1126
1127 /**
1128  * @brief Get MBA versions - get MBA sub images versions
1129  *
1130  *  @param p_hwfn      - hw function
1131  *  @param p_ptt       - PTT required for register access
1132  *  @param p_mba_vers  - MBA versions array to fill
1133  *
1134  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1135  */
1136 enum _ecore_status_t ecore_mcp_get_mba_versions(
1137         struct ecore_hwfn *p_hwfn,
1138         struct ecore_ptt *p_ptt,
1139         struct ecore_mba_vers *p_mba_vers);
1140
1141 /**
1142  * @brief Count memory ecc events
1143  *
1144  *  @param p_hwfn      - hw function
1145  *  @param p_ptt       - PTT required for register access
1146  *  @param num_events  - number of memory ecc events
1147  *
1148  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
1149  */
1150 enum _ecore_status_t ecore_mcp_mem_ecc_events(struct ecore_hwfn *p_hwfn,
1151                                               struct ecore_ptt *p_ptt,
1152                                               u64 *num_events);
1153
1154 struct ecore_mdump_info {
1155         u32 reason;
1156         u32 version;
1157         u32 config;
1158         u32 epoch;
1159         u32 num_of_logs;
1160         u32 valid_logs;
1161 };
1162
1163 /**
1164  * @brief - Gets the MFW crash dump configuration and logs info.
1165  *
1166  * @param p_hwfn
1167  * @param p_ptt
1168  * @param p_mdump_info
1169  *
1170  * @param return ECORE_SUCCESS upon success.
1171  */
1172 enum _ecore_status_t
1173 ecore_mcp_mdump_get_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
1174                          struct ecore_mdump_info *p_mdump_info);
1175
1176 /**
1177  * @brief - Clears the MFW crash dump logs.
1178  *
1179  * @param p_hwfn
1180  * @param p_ptt
1181  *
1182  * @param return ECORE_SUCCESS upon success.
1183  */
1184 enum _ecore_status_t ecore_mcp_mdump_clear_logs(struct ecore_hwfn *p_hwfn,
1185                                                 struct ecore_ptt *p_ptt);
1186
1187 /**
1188  * @brief - Clear the mdump retained data.
1189  *
1190  * @param p_hwfn
1191  * @param p_ptt
1192  *
1193  * @param return ECORE_SUCCESS upon success.
1194  */
1195 enum _ecore_status_t ecore_mcp_mdump_clr_retain(struct ecore_hwfn *p_hwfn,
1196                                                 struct ecore_ptt *p_ptt);
1197
1198 /**
1199  * @brief - Processes the TLV request from MFW i.e., get the required TLV info
1200  *          from the ecore client and send it to the MFW.
1201  *
1202  * @param p_hwfn
1203  * @param p_ptt
1204  *
1205  * @param return ECORE_SUCCESS upon success.
1206  */
1207 enum _ecore_status_t ecore_mfw_process_tlv_req(struct ecore_hwfn *p_hwfn,
1208                                                struct ecore_ptt *p_ptt);
1209
1210
1211 /**
1212  * @brief - Return whether management firmware support smart AN
1213  *
1214  * @param p_hwfn
1215  *
1216  * @return bool - true iff feature is supported.
1217  */
1218 bool ecore_mcp_is_smart_an_supported(struct ecore_hwfn *p_hwfn);
1219 #endif