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)
91 struct ecore_mcp_nvm_common {
98 struct ecore_mcp_nvm_rd {
103 struct ecore_mcp_nvm_wr {
108 struct ecore_mcp_nvm_params {
109 #define ECORE_MCP_CMD (1 << 0)
110 #define ECORE_MCP_NVM_RD (1 << 1)
111 #define ECORE_MCP_NVM_WR (1 << 2)
114 struct ecore_mcp_nvm_common nvm_common;
117 struct ecore_mcp_nvm_rd nvm_rd;
118 struct ecore_mcp_nvm_wr nvm_wr;
122 #ifndef __EXTRACT__LINUX__
123 enum ecore_nvm_images {
124 ECORE_NVM_IMAGE_ISCSI_CFG,
125 ECORE_NVM_IMAGE_FCOE_CFG,
129 struct ecore_mcp_drv_version {
131 u8 name[MCP_DRV_VER_STR_SIZE - 4];
134 struct ecore_mcp_lan_stats {
140 #ifndef ECORE_PROTO_STATS
141 #define ECORE_PROTO_STATS
142 struct ecore_mcp_fcoe_stats {
149 struct ecore_mcp_iscsi_stats {
156 struct ecore_mcp_rdma_stats {
163 enum ecore_mcp_protocol_type {
165 ECORE_MCP_FCOE_STATS,
166 ECORE_MCP_ISCSI_STATS,
170 union ecore_mcp_protocol_stats {
171 struct ecore_mcp_lan_stats lan_stats;
172 struct ecore_mcp_fcoe_stats fcoe_stats;
173 struct ecore_mcp_iscsi_stats iscsi_stats;
174 struct ecore_mcp_rdma_stats rdma_stats;
178 enum ecore_ov_client {
180 ECORE_OV_CLIENT_USER,
181 ECORE_OV_CLIENT_VENDOR_SPEC
184 enum ecore_ov_driver_state {
185 ECORE_OV_DRIVER_STATE_NOT_LOADED,
186 ECORE_OV_DRIVER_STATE_DISABLED,
187 ECORE_OV_DRIVER_STATE_ACTIVE
190 #define ECORE_MAX_NPIV_ENTRIES 128
191 #define ECORE_WWN_SIZE 8
192 struct ecore_fc_npiv_tbl {
194 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
195 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
198 #ifndef __EXTRACT__LINUX__
199 enum ecore_led_mode {
202 ECORE_LED_MODE_RESTORE
206 struct ecore_temperature_sensor {
213 #define ECORE_MAX_NUM_OF_SENSORS 7
214 struct ecore_temperature_info {
216 struct ecore_temperature_sensor sensors[ECORE_MAX_NUM_OF_SENSORS];
219 enum ecore_mba_img_idx {
220 ECORE_MBA_LEGACY_IDX,
221 ECORE_MBA_PCI3CLP_IDX,
228 ECORE_MAX_NUM_OF_ROMIMG
231 struct ecore_mba_vers {
232 u32 mba_vers[ECORE_MAX_NUM_OF_ROMIMG];
236 * @brief - returns the link params of the hw function
240 * @returns pointer to link params
242 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
245 * @brief - return the link state of the hw function
249 * @returns pointer to link state
251 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
254 * @brief - return the link capabilities of the hw function
258 * @returns pointer to link capabilities
260 struct ecore_mcp_link_capabilities
261 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
264 * @brief Request the MFW to set the the link according to 'link_input'.
268 * @param b_up - raise link if `true'. Reset link if `false'.
270 * @return enum _ecore_status_t
272 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
273 struct ecore_ptt *p_ptt,
277 * @brief Get the management firmware version value
281 * @param p_mfw_ver - mfw version value
282 * @param p_running_bundle_id - image id in nvram; Optional.
284 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
286 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
287 struct ecore_ptt *p_ptt,
289 u32 *p_running_bundle_id);
292 * @brief Get media type value of the port.
294 * @param p_dev - ecore dev pointer
295 * @param mfw_ver - media type value
297 * @return enum _ecore_status_t -
298 * ECORE_SUCCESS - Operation was successful.
299 * ECORE_BUSY - Operation failed
301 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev,
305 * @brief - Sends a command to the MCP mailbox.
307 * @param p_hwfn - hw function
308 * @param p_ptt - PTT required for register access
309 * @param cmd - command to be sent to the MCP
310 * @param param - optional param
311 * @param o_mcp_resp - the MCP response code (exclude sequence)
312 * @param o_mcp_param - optional parameter provided by the MCP response
314 * @return enum _ecore_status_t -
315 * ECORE_SUCCESS - operation was successful
316 * ECORE_BUSY - operation failed
318 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
319 struct ecore_ptt *p_ptt, u32 cmd, u32 param,
320 u32 *o_mcp_resp, u32 *o_mcp_param);
323 * @brief - drains the nig, allowing completion to pass in case of pauses.
324 * (Should be called only from sleepable context)
329 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
330 struct ecore_ptt *p_ptt);
334 * @brief - return the mcp function info of the hw function
338 * @returns pointer to mcp function info
340 const struct ecore_mcp_function_info
341 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
345 * @brief - Function for reading/manipulating the nvram. Following are supported
347 * 1. Read: Read the specified nvram offset.
349 * type - ECORE_MCP_NVM_RD
350 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM)
351 * offset - nvm offset
355 * buf_size - buffer size
357 * 2. Write: Write the data at the specified nvram offset
359 * type - ECORE_MCP_NVM_WR
360 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM)
361 * offset - nvm offset
363 * buf_size - buffer size
365 * 3. Command: Send the NVM command to MCP.
367 * type - ECORE_MCP_CMD
368 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE)
369 * offset - nvm offset
376 * @return ECORE_SUCCESS - operation was successful.
378 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn,
379 struct ecore_ptt *p_ptt,
380 struct ecore_mcp_nvm_params *params);
384 * @brief - count number of function with a matching personality on engine.
388 * @param personalities - a bitmask of ecore_pci_personality values
390 * @returns the count of all devices on engine whose personality match one of
393 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
394 struct ecore_ptt *p_ptt,
399 * @brief Get the flash size value
403 * @param p_flash_size - flash size in bytes to be filled.
405 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
407 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
408 struct ecore_ptt *p_ptt,
412 * @brief Send driver version to MFW
416 * @param version - Version value
417 * @param name - Protocol driver name
419 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
422 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
423 struct ecore_mcp_drv_version *p_ver);
426 * @brief Read the MFW process kill counter
433 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
434 struct ecore_ptt *p_ptt);
437 * @brief Trigger a recovery process
442 * @return enum _ecore_status_t
444 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
445 struct ecore_ptt *p_ptt);
448 * @brief Notify MFW about the change in base device properties
452 * @param client - ecore client type
454 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
457 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
458 struct ecore_ptt *p_ptt,
459 enum ecore_ov_client client);
462 * @brief Notify MFW about the driver state
466 * @param drv_state - Driver state
468 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
471 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
472 struct ecore_ptt *p_ptt,
473 enum ecore_ov_driver_state drv_state);
476 * @brief Read NPIV settings form the MFW
480 * @param p_table - Array to hold the FC NPIV data. Client need allocate the
481 * required buffer. The field 'count' specifies number of NPIV
482 * entries. A value of 0 means the table was not populated.
484 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
487 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
488 struct ecore_fc_npiv_tbl *p_table);
491 * @brief Send MTU size to MFW
495 * @param mtu - MTU size
497 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
499 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
500 struct ecore_ptt *p_ptt, u16 mtu);
503 * @brief Set LED status
507 * @param mode - LED mode
509 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
511 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
512 struct ecore_ptt *p_ptt,
513 enum ecore_led_mode mode);
516 * @brief Set secure mode
519 * @param addr - nvm offset
521 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
523 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
527 * @brief Write to phy
530 * @param addr - nvm offset
531 * @param cmd - nvm command
532 * @param p_buf - nvm write buffer
533 * @param len - buffer len
535 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
537 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
538 u32 addr, u8 *p_buf, u32 len);
541 * @brief Write to nvm
544 * @param addr - nvm offset
545 * @param cmd - nvm command
546 * @param p_buf - nvm write buffer
547 * @param len - buffer len
549 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
551 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
552 u32 addr, u8 *p_buf, u32 len);
555 * @brief Put file begin
558 * @param addr - nvm offset
560 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
562 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
569 * @param addr - nvm offset
571 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
573 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev,
577 * @brief Check latest response
580 * @param p_buf - nvm write buffer
582 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
584 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
587 * @brief Read from phy
590 * @param addr - nvm offset
591 * @param cmd - nvm command
592 * @param p_buf - nvm write buffer
593 * @param len - buffer len
595 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
597 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
598 u32 addr, u8 *p_buf, u32 len);
601 * @brief Read from nvm
604 * @param addr - nvm offset
605 * @param p_buf - nvm write buffer
606 * @param len - buffer len
608 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
610 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
614 * @brief Read from sfp
616 * @param p_hwfn - hw function
617 * @param p_ptt - PTT required for register access
618 * @param port - transceiver port
619 * @param addr - I2C address
620 * @param offset - offset in sfp
621 * @param len - buffer length
622 * @param p_buf - buffer to read into
624 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
626 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
627 struct ecore_ptt *p_ptt,
628 u32 port, u32 addr, u32 offset,
632 * @brief Write to sfp
634 * @param p_hwfn - hw function
635 * @param p_ptt - PTT required for register access
636 * @param port - transceiver port
637 * @param addr - I2C address
638 * @param offset - offset in sfp
639 * @param len - buffer length
640 * @param p_buf - buffer to write from
642 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
644 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
645 struct ecore_ptt *p_ptt,
646 u32 port, u32 addr, u32 offset,
652 * @param p_hwfn - hw function
653 * @param p_ptt - PTT required for register access
654 * @param gpio - gpio number
655 * @param gpio_val - value read from gpio
657 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
659 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
660 struct ecore_ptt *p_ptt,
661 u16 gpio, u32 *gpio_val);
666 * @param p_hwfn - hw function
667 * @param p_ptt - PTT required for register access
668 * @param gpio - gpio number
669 * @param gpio_val - value to write to gpio
671 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
673 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
674 struct ecore_ptt *p_ptt,
675 u16 gpio, u16 gpio_val);
678 * @brief Gpio get information
680 * @param p_hwfn - hw function
681 * @param p_ptt - PTT required for register access
682 * @param gpio - gpio number
683 * @param gpio_direction - gpio is output (0) or input (1)
684 * @param gpio_ctrl - gpio control is uninitialized (0),
685 * path 0 (1), path 1 (2) or shared(3)
687 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
689 enum _ecore_status_t ecore_mcp_gpio_info(struct ecore_hwfn *p_hwfn,
690 struct ecore_ptt *p_ptt,
691 u16 gpio, u32 *gpio_direction,
695 * @brief Bist register test
697 * @param p_hwfn - hw function
698 * @param p_ptt - PTT required for register access
700 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
702 enum _ecore_status_t ecore_mcp_bist_register_test(struct ecore_hwfn *p_hwfn,
703 struct ecore_ptt *p_ptt);
706 * @brief Bist clock test
708 * @param p_hwfn - hw function
709 * @param p_ptt - PTT required for register access
711 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
713 enum _ecore_status_t ecore_mcp_bist_clock_test(struct ecore_hwfn *p_hwfn,
714 struct ecore_ptt *p_ptt);
717 * @brief Bist nvm test - get number of images
719 * @param p_hwfn - hw function
720 * @param p_ptt - PTT required for register access
721 * @param num_images - number of images if operation was
722 * successful. 0 if not.
724 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
726 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_num_images(
727 struct ecore_hwfn *p_hwfn,
728 struct ecore_ptt *p_ptt,
732 * @brief Bist nvm test - get image attributes by index
734 * @param p_hwfn - hw function
735 * @param p_ptt - PTT required for register access
736 * @param p_image_att - Attributes of image
737 * @param image_index - Index of image to get information for
739 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
741 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_image_att(
742 struct ecore_hwfn *p_hwfn,
743 struct ecore_ptt *p_ptt,
744 struct bist_nvm_image_att *p_image_att,
748 * @brief ecore_mcp_get_temperature_info - get the status of the temperature
751 * @param p_hwfn - hw function
752 * @param p_ptt - PTT required for register access
753 * @param p_temp_status - A pointer to an ecore_temperature_info structure to
754 * be filled with the temperature data
756 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
759 ecore_mcp_get_temperature_info(struct ecore_hwfn *p_hwfn,
760 struct ecore_ptt *p_ptt,
761 struct ecore_temperature_info *p_temp_info);
764 * @brief Get MBA versions - get MBA sub images versions
766 * @param p_hwfn - hw function
767 * @param p_ptt - PTT required for register access
768 * @param p_mba_vers - MBA versions array to fill
770 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
772 enum _ecore_status_t ecore_mcp_get_mba_versions(
773 struct ecore_hwfn *p_hwfn,
774 struct ecore_ptt *p_ptt,
775 struct ecore_mba_vers *p_mba_vers);
778 * @brief Count memory ecc events
780 * @param p_hwfn - hw function
781 * @param p_ptt - PTT required for register access
782 * @param num_events - number of memory ecc events
784 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
786 enum _ecore_status_t ecore_mcp_mem_ecc_events(struct ecore_hwfn *p_hwfn,
787 struct ecore_ptt *p_ptt,
790 struct ecore_mdump_info {
800 * @brief - Gets the MFW crash dump configuration and logs info.
804 * @param p_mdump_info
806 * @param return ECORE_SUCCESS upon success.
809 ecore_mcp_mdump_get_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
810 struct ecore_mdump_info *p_mdump_info);
813 * @brief - Clears the MFW crash dump logs.
818 * @param return ECORE_SUCCESS upon success.
820 enum _ecore_status_t ecore_mcp_mdump_clear_logs(struct ecore_hwfn *p_hwfn,
821 struct ecore_ptt *p_ptt);