2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_MCP_API_H__
10 #define __ECORE_MCP_API_H__
12 #include "ecore_status.h"
14 struct ecore_mcp_link_speed_params {
16 u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */
17 u32 forced_speed; /* In Mb/s */
20 struct ecore_mcp_link_pause_params {
26 struct ecore_mcp_link_params {
27 struct ecore_mcp_link_speed_params speed;
28 struct ecore_mcp_link_pause_params pause;
29 u32 loopback_mode; /* in PMM_LOOPBACK values */
32 struct ecore_mcp_link_capabilities {
33 u32 speed_capabilities;
34 bool default_speed_autoneg; /* In Mb/s */
35 u32 default_speed; /* In Mb/s */
38 struct ecore_mcp_link_state {
41 u32 line_speed; /* In Mb/s */
42 u32 min_pf_rate; /* In Mb/s */
43 u32 speed; /* In Mb/s */
48 bool parallel_detection;
51 #define ECORE_LINK_PARTNER_SPEED_1G_HD (1 << 0)
52 #define ECORE_LINK_PARTNER_SPEED_1G_FD (1 << 1)
53 #define ECORE_LINK_PARTNER_SPEED_10G (1 << 2)
54 #define ECORE_LINK_PARTNER_SPEED_20G (1 << 3)
55 #define ECORE_LINK_PARTNER_SPEED_25G (1 << 4)
56 #define ECORE_LINK_PARTNER_SPEED_40G (1 << 5)
57 #define ECORE_LINK_PARTNER_SPEED_50G (1 << 6)
58 #define ECORE_LINK_PARTNER_SPEED_100G (1 << 7)
59 u32 partner_adv_speed;
61 bool partner_tx_flow_ctrl_en;
62 bool partner_rx_flow_ctrl_en;
64 #define ECORE_LINK_PARTNER_SYMMETRIC_PAUSE (1)
65 #define ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
66 #define ECORE_LINK_PARTNER_BOTH_PAUSE (3)
72 struct ecore_mcp_function_info {
75 enum ecore_pci_personality protocol;
85 #define ECORE_MCP_VLAN_UNSET (0xffff)
89 struct ecore_mcp_nvm_common {
96 struct ecore_mcp_nvm_rd {
101 struct ecore_mcp_nvm_wr {
106 struct ecore_mcp_nvm_params {
107 #define ECORE_MCP_CMD (1 << 0)
108 #define ECORE_MCP_NVM_RD (1 << 1)
109 #define ECORE_MCP_NVM_WR (1 << 2)
112 struct ecore_mcp_nvm_common nvm_common;
115 struct ecore_mcp_nvm_rd nvm_rd;
116 struct ecore_mcp_nvm_wr nvm_wr;
120 #ifndef __EXTRACT__LINUX__
121 enum ecore_nvm_images {
122 ECORE_NVM_IMAGE_ISCSI_CFG,
123 ECORE_NVM_IMAGE_FCOE_CFG,
127 struct ecore_mcp_drv_version {
129 u8 name[MCP_DRV_VER_STR_SIZE - 4];
132 struct ecore_mcp_lan_stats {
138 #ifndef ECORE_PROTO_STATS
139 #define ECORE_PROTO_STATS
140 struct ecore_mcp_fcoe_stats {
147 struct ecore_mcp_iscsi_stats {
154 struct ecore_mcp_rdma_stats {
161 enum ecore_mcp_protocol_type {
163 ECORE_MCP_FCOE_STATS,
164 ECORE_MCP_ISCSI_STATS,
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;
176 enum ecore_ov_config_method {
182 enum ecore_ov_client {
184 ECORE_OV_CLIENT_USER,
185 ECORE_OV_CLIENT_VENDOR_SPEC
188 enum ecore_ov_driver_state {
189 ECORE_OV_DRIVER_STATE_NOT_LOADED,
190 ECORE_OV_DRIVER_STATE_DISABLED,
191 ECORE_OV_DRIVER_STATE_ACTIVE
194 #define ECORE_MAX_NPIV_ENTRIES 128
195 #define ECORE_WWN_SIZE 8
196 struct ecore_fc_npiv_tbl {
198 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
199 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
202 #ifndef __EXTRACT__LINUX__
203 enum ecore_led_mode {
206 ECORE_LED_MODE_RESTORE
210 struct ecore_temperature_sensor {
217 #define ECORE_MAX_NUM_OF_SENSORS 7
218 struct ecore_temperature_info {
220 struct ecore_temperature_sensor sensors[ECORE_MAX_NUM_OF_SENSORS];
223 enum ecore_mba_img_idx {
224 ECORE_MBA_LEGACY_IDX,
225 ECORE_MBA_PCI3CLP_IDX,
232 ECORE_MAX_NUM_OF_ROMIMG
235 struct ecore_mba_vers {
236 u32 mba_vers[ECORE_MAX_NUM_OF_ROMIMG];
240 * @brief - returns the link params of the hw function
244 * @returns pointer to link params
246 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
249 * @brief - return the link state of the hw function
253 * @returns pointer to link state
255 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
258 * @brief - return the link capabilities of the hw function
262 * @returns pointer to link capabilities
264 struct ecore_mcp_link_capabilities
265 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
268 * @brief Request the MFW to set the the link according to 'link_input'.
272 * @param b_up - raise link if `true'. Reset link if `false'.
274 * @return enum _ecore_status_t
276 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
277 struct ecore_ptt *p_ptt,
281 * @brief Get the management firmware version value
285 * @param p_mfw_ver - mfw version value
286 * @param p_running_bundle_id - image id in nvram; Optional.
288 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
290 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
291 struct ecore_ptt *p_ptt,
293 u32 *p_running_bundle_id);
296 * @brief Get media type value of the port.
298 * @param p_dev - ecore dev pointer
299 * @param mfw_ver - media type value
301 * @return enum _ecore_status_t -
302 * ECORE_SUCCESS - Operation was successful.
303 * ECORE_BUSY - Operation failed
305 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev,
309 * @brief - Sends a command to the MCP mailbox.
311 * @param p_hwfn - hw function
312 * @param p_ptt - PTT required for register access
313 * @param cmd - command to be sent to the MCP
314 * @param param - optional param
315 * @param o_mcp_resp - the MCP response code (exclude sequence)
316 * @param o_mcp_param - optional parameter provided by the MCP response
318 * @return enum _ecore_status_t -
319 * ECORE_SUCCESS - operation was successful
320 * ECORE_BUSY - operation failed
322 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
323 struct ecore_ptt *p_ptt, u32 cmd, u32 param,
324 u32 *o_mcp_resp, u32 *o_mcp_param);
327 * @brief - drains the nig, allowing completion to pass in case of pauses.
328 * (Should be called only from sleepable context)
333 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
334 struct ecore_ptt *p_ptt);
338 * @brief - return the mcp function info of the hw function
342 * @returns pointer to mcp function info
344 const struct ecore_mcp_function_info
345 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
349 * @brief - Function for reading/manipulating the nvram. Following are supported
351 * 1. Read: Read the specified nvram offset.
353 * type - ECORE_MCP_NVM_RD
354 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM)
355 * offset - nvm offset
359 * buf_size - buffer size
361 * 2. Write: Write the data at the specified nvram offset
363 * type - ECORE_MCP_NVM_WR
364 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM)
365 * offset - nvm offset
367 * buf_size - buffer size
369 * 3. Command: Send the NVM command to MCP.
371 * type - ECORE_MCP_CMD
372 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE)
373 * offset - nvm offset
380 * @return ECORE_SUCCESS - operation was successful.
382 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn,
383 struct ecore_ptt *p_ptt,
384 struct ecore_mcp_nvm_params *params);
388 * @brief - count number of function with a matching personality on engine.
392 * @param personalities - a bitmask of ecore_pci_personality values
394 * @returns the count of all devices on engine whose personality match one of
397 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
398 struct ecore_ptt *p_ptt,
403 * @brief Get the flash size value
407 * @param p_flash_size - flash size in bytes to be filled.
409 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
411 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
412 struct ecore_ptt *p_ptt,
416 * @brief Send driver version to MFW
420 * @param version - Version value
421 * @param name - Protocol driver name
423 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
426 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
427 struct ecore_mcp_drv_version *p_ver);
430 * @brief Read the MFW process kill counter
437 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
438 struct ecore_ptt *p_ptt);
441 * @brief Trigger a recovery process
446 * @return enum _ecore_status_t
448 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
449 struct ecore_ptt *p_ptt);
452 * @brief Notify MFW about the change in base device properties
456 * @param config - Configuation that has been updated
457 * @param client - ecore client type
459 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
462 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
463 struct ecore_ptt *p_ptt,
464 enum ecore_ov_config_method config,
465 enum ecore_ov_client client);
468 * @brief Notify MFW about the driver state
472 * @param drv_state - Driver state
474 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
477 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
478 struct ecore_ptt *p_ptt,
479 enum ecore_ov_driver_state drv_state);
482 * @brief Read NPIV settings form the MFW
486 * @param p_table - Array to hold the FC NPIV data. Client need allocate the
487 * required buffer. The field 'count' specifies number of NPIV
488 * entries. A value of 0 means the table was not populated.
490 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
493 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
494 struct ecore_fc_npiv_tbl *p_table);
497 * @brief Send MTU size to MFW
501 * @param mtu - MTU size
503 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
505 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
506 struct ecore_ptt *p_ptt, u16 mtu);
509 * @brief Set LED status
513 * @param mode - LED mode
515 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
517 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
518 struct ecore_ptt *p_ptt,
519 enum ecore_led_mode mode);
522 * @brief Set secure mode
525 * @param addr - nvm offset
527 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
529 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
533 * @brief Write to phy
536 * @param addr - nvm offset
537 * @param cmd - nvm command
538 * @param p_buf - nvm write buffer
539 * @param len - buffer len
541 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
543 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
544 u32 addr, u8 *p_buf, u32 len);
547 * @brief Write to nvm
550 * @param addr - nvm offset
551 * @param cmd - nvm command
552 * @param p_buf - nvm write buffer
553 * @param len - buffer len
555 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
557 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
558 u32 addr, u8 *p_buf, u32 len);
561 * @brief Put file begin
564 * @param addr - nvm offset
566 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
568 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
575 * @param addr - nvm offset
577 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
579 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev,
583 * @brief Check latest response
586 * @param p_buf - nvm write buffer
588 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
590 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
593 * @brief Read from phy
596 * @param addr - nvm offset
597 * @param cmd - nvm command
598 * @param p_buf - nvm write buffer
599 * @param len - buffer len
601 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
603 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
604 u32 addr, u8 *p_buf, u32 len);
607 * @brief Read from nvm
610 * @param addr - nvm offset
611 * @param p_buf - nvm write buffer
612 * @param len - buffer len
614 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
616 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
620 * @brief Read from sfp
622 * @param p_hwfn - hw function
623 * @param p_ptt - PTT required for register access
624 * @param port - transceiver port
625 * @param addr - I2C address
626 * @param offset - offset in sfp
627 * @param len - buffer length
628 * @param p_buf - buffer to read into
630 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
632 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
633 struct ecore_ptt *p_ptt,
634 u32 port, u32 addr, u32 offset,
638 * @brief Write to sfp
640 * @param p_hwfn - hw function
641 * @param p_ptt - PTT required for register access
642 * @param port - transceiver port
643 * @param addr - I2C address
644 * @param offset - offset in sfp
645 * @param len - buffer length
646 * @param p_buf - buffer to write from
648 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
650 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
651 struct ecore_ptt *p_ptt,
652 u32 port, u32 addr, u32 offset,
658 * @param p_hwfn - hw function
659 * @param p_ptt - PTT required for register access
660 * @param gpio - gpio number
661 * @param gpio_val - value read from gpio
663 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
665 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
666 struct ecore_ptt *p_ptt,
667 u16 gpio, u32 *gpio_val);
672 * @param p_hwfn - hw function
673 * @param p_ptt - PTT required for register access
674 * @param gpio - gpio number
675 * @param gpio_val - value to write to gpio
677 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
679 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
680 struct ecore_ptt *p_ptt,
681 u16 gpio, u16 gpio_val);
684 * @brief Gpio get information
686 * @param p_hwfn - hw function
687 * @param p_ptt - PTT required for register access
688 * @param gpio - gpio number
689 * @param gpio_direction - gpio is output (0) or input (1)
690 * @param gpio_ctrl - gpio control is uninitialized (0),
691 * path 0 (1), path 1 (2) or shared(3)
693 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
695 enum _ecore_status_t ecore_mcp_gpio_info(struct ecore_hwfn *p_hwfn,
696 struct ecore_ptt *p_ptt,
697 u16 gpio, u32 *gpio_direction,
701 * @brief Bist register test
703 * @param p_hwfn - hw function
704 * @param p_ptt - PTT required for register access
706 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
708 enum _ecore_status_t ecore_mcp_bist_register_test(struct ecore_hwfn *p_hwfn,
709 struct ecore_ptt *p_ptt);
712 * @brief Bist clock test
714 * @param p_hwfn - hw function
715 * @param p_ptt - PTT required for register access
717 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
719 enum _ecore_status_t ecore_mcp_bist_clock_test(struct ecore_hwfn *p_hwfn,
720 struct ecore_ptt *p_ptt);
723 * @brief Bist nvm test - get number of images
725 * @param p_hwfn - hw function
726 * @param p_ptt - PTT required for register access
727 * @param num_images - number of images if operation was
728 * successful. 0 if not.
730 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
732 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_num_images(
733 struct ecore_hwfn *p_hwfn,
734 struct ecore_ptt *p_ptt,
738 * @brief Bist nvm test - get image attributes by index
740 * @param p_hwfn - hw function
741 * @param p_ptt - PTT required for register access
742 * @param p_image_att - Attributes of image
743 * @param image_index - Index of image to get information for
745 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
747 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_image_att(
748 struct ecore_hwfn *p_hwfn,
749 struct ecore_ptt *p_ptt,
750 struct bist_nvm_image_att *p_image_att,
754 * @brief ecore_mcp_get_temperature_info - get the status of the temperature
757 * @param p_hwfn - hw function
758 * @param p_ptt - PTT required for register access
759 * @param p_temp_status - A pointer to an ecore_temperature_info structure to
760 * be filled with the temperature data
762 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
765 ecore_mcp_get_temperature_info(struct ecore_hwfn *p_hwfn,
766 struct ecore_ptt *p_ptt,
767 struct ecore_temperature_info *p_temp_info);
770 * @brief Get MBA versions - get MBA sub images versions
772 * @param p_hwfn - hw function
773 * @param p_ptt - PTT required for register access
774 * @param p_mba_vers - MBA versions array to fill
776 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
778 enum _ecore_status_t ecore_mcp_get_mba_versions(
779 struct ecore_hwfn *p_hwfn,
780 struct ecore_ptt *p_ptt,
781 struct ecore_mba_vers *p_mba_vers);
784 * @brief Count memory ecc events
786 * @param p_hwfn - hw function
787 * @param p_ptt - PTT required for register access
788 * @param num_events - number of memory ecc events
790 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
792 enum _ecore_status_t ecore_mcp_mem_ecc_events(struct ecore_hwfn *p_hwfn,
793 struct ecore_ptt *p_ptt,
796 struct ecore_mdump_info {
806 * @brief - Gets the MFW crash dump configuration and logs info.
810 * @param p_mdump_info
812 * @param return ECORE_SUCCESS upon success.
815 ecore_mcp_mdump_get_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
816 struct ecore_mdump_info *p_mdump_info);
819 * @brief - Clears the MFW crash dump logs.
824 * @param return ECORE_SUCCESS upon success.
826 enum _ecore_status_t ecore_mcp_mdump_clear_logs(struct ecore_hwfn *p_hwfn,
827 struct ecore_ptt *p_ptt);