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