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 {
187 enum ecore_ov_driver_state {
188 ECORE_OV_DRIVER_STATE_NOT_LOADED,
189 ECORE_OV_DRIVER_STATE_DISABLED,
190 ECORE_OV_DRIVER_STATE_ACTIVE
193 #define ECORE_MAX_NPIV_ENTRIES 128
194 #define ECORE_WWN_SIZE 8
195 struct ecore_fc_npiv_tbl {
197 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
198 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
201 #ifndef __EXTRACT__LINUX__
202 enum ecore_led_mode {
205 ECORE_LED_MODE_RESTORE
209 struct ecore_temperature_sensor {
216 #define ECORE_MAX_NUM_OF_SENSORS 7
217 struct ecore_temperature_info {
219 struct ecore_temperature_sensor sensors[ECORE_MAX_NUM_OF_SENSORS];
222 enum ecore_mba_img_idx {
223 ECORE_MBA_LEGACY_IDX,
224 ECORE_MBA_PCI3CLP_IDX,
231 ECORE_MAX_NUM_OF_ROMIMG
234 struct ecore_mba_vers {
235 u32 mba_vers[ECORE_MAX_NUM_OF_ROMIMG];
239 * @brief - returns the link params of the hw function
243 * @returns pointer to link params
245 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
248 * @brief - return the link state of the hw function
252 * @returns pointer to link state
254 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
257 * @brief - return the link capabilities of the hw function
261 * @returns pointer to link capabilities
263 struct ecore_mcp_link_capabilities
264 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
267 * @brief Request the MFW to set the the link according to 'link_input'.
271 * @param b_up - raise link if `true'. Reset link if `false'.
273 * @return enum _ecore_status_t
275 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
276 struct ecore_ptt *p_ptt,
280 * @brief Get the management firmware version value
284 * @param p_mfw_ver - mfw version value
285 * @param p_running_bundle_id - image id in nvram; Optional.
287 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
289 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
290 struct ecore_ptt *p_ptt,
292 u32 *p_running_bundle_id);
295 * @brief Get media type value of the port.
297 * @param p_dev - ecore dev pointer
298 * @param mfw_ver - media type value
300 * @return enum _ecore_status_t -
301 * ECORE_SUCCESS - Operation was successful.
302 * ECORE_BUSY - Operation failed
304 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev,
308 * @brief - Sends a command to the MCP mailbox.
310 * @param p_hwfn - hw function
311 * @param p_ptt - PTT required for register access
312 * @param cmd - command to be sent to the MCP
313 * @param param - optional param
314 * @param o_mcp_resp - the MCP response code (exclude sequence)
315 * @param o_mcp_param - optional parameter provided by the MCP response
317 * @return enum _ecore_status_t -
318 * ECORE_SUCCESS - operation was successful
319 * ECORE_BUSY - operation failed
321 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
322 struct ecore_ptt *p_ptt, u32 cmd, u32 param,
323 u32 *o_mcp_resp, u32 *o_mcp_param);
326 * @brief - drains the nig, allowing completion to pass in case of pauses.
327 * (Should be called only from sleepable context)
332 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
333 struct ecore_ptt *p_ptt);
337 * @brief - return the mcp function info of the hw function
341 * @returns pointer to mcp function info
343 const struct ecore_mcp_function_info
344 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
348 * @brief - Function for reading/manipulating the nvram. Following are supported
350 * 1. Read: Read the specified nvram offset.
352 * type - ECORE_MCP_NVM_RD
353 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM)
354 * offset - nvm offset
358 * buf_size - buffer size
360 * 2. Write: Write the data at the specified nvram offset
362 * type - ECORE_MCP_NVM_WR
363 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM)
364 * offset - nvm offset
366 * buf_size - buffer size
368 * 3. Command: Send the NVM command to MCP.
370 * type - ECORE_MCP_CMD
371 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE)
372 * offset - nvm offset
379 * @return ECORE_SUCCESS - operation was successful.
381 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn,
382 struct ecore_ptt *p_ptt,
383 struct ecore_mcp_nvm_params *params);
387 * @brief - count number of function with a matching personality on engine.
391 * @param personalities - a bitmask of ecore_pci_personality values
393 * @returns the count of all devices on engine whose personality match one of
396 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
397 struct ecore_ptt *p_ptt,
402 * @brief Get the flash size value
406 * @param p_flash_size - flash size in bytes to be filled.
408 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
410 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
411 struct ecore_ptt *p_ptt,
415 * @brief Send driver version to MFW
419 * @param version - Version value
420 * @param name - Protocol driver name
422 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
425 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
426 struct ecore_mcp_drv_version *p_ver);
429 * @brief Read the MFW process kill counter
436 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
437 struct ecore_ptt *p_ptt);
440 * @brief Trigger a recovery process
445 * @return enum _ecore_status_t
447 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
448 struct ecore_ptt *p_ptt);
451 * @brief Notify MFW about the change in base device properties
455 * @param config - Configuation that has been updated
456 * @param client - ecore client type
458 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
461 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
462 struct ecore_ptt *p_ptt,
463 enum ecore_ov_config_method config,
464 enum ecore_ov_client client);
467 * @brief Notify MFW about the driver state
471 * @param drv_state - Driver state
473 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
476 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
477 struct ecore_ptt *p_ptt,
478 enum ecore_ov_driver_state drv_state);
481 * @brief Read NPIV settings form the MFW
485 * @param p_table - Array to hold the FC NPIV data. Client need allocate the
486 * required buffer. The field 'count' specifies number of NPIV
487 * entries. A value of 0 means the table was not populated.
489 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
492 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
493 struct ecore_fc_npiv_tbl *p_table);
496 * @brief Send MTU size to MFW
500 * @param mtu - MTU size
502 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
504 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
505 struct ecore_ptt *p_ptt, u16 mtu);
508 * @brief Set LED status
512 * @param mode - LED mode
514 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
516 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
517 struct ecore_ptt *p_ptt,
518 enum ecore_led_mode mode);
521 * @brief Set secure mode
524 * @param addr - nvm offset
526 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
528 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
532 * @brief Write to phy
535 * @param addr - nvm offset
536 * @param cmd - nvm command
537 * @param p_buf - nvm write buffer
538 * @param len - buffer len
540 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
542 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
543 u32 addr, u8 *p_buf, u32 len);
546 * @brief Write to nvm
549 * @param addr - nvm offset
550 * @param cmd - nvm command
551 * @param p_buf - nvm write buffer
552 * @param len - buffer len
554 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
556 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
557 u32 addr, u8 *p_buf, u32 len);
560 * @brief Put file begin
563 * @param addr - nvm offset
565 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
567 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
574 * @param addr - nvm offset
576 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
578 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev,
582 * @brief Check latest response
585 * @param p_buf - nvm write buffer
587 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
589 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
592 * @brief Read from phy
595 * @param addr - nvm offset
596 * @param cmd - nvm command
597 * @param p_buf - nvm write buffer
598 * @param len - buffer len
600 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
602 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
603 u32 addr, u8 *p_buf, u32 len);
606 * @brief Read from nvm
609 * @param addr - nvm offset
610 * @param p_buf - nvm write buffer
611 * @param len - buffer len
613 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
615 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
619 * @brief Read from sfp
621 * @param p_hwfn - hw function
622 * @param p_ptt - PTT required for register access
623 * @param port - transceiver port
624 * @param addr - I2C address
625 * @param offset - offset in sfp
626 * @param len - buffer length
627 * @param p_buf - buffer to read into
629 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
631 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
632 struct ecore_ptt *p_ptt,
633 u32 port, u32 addr, u32 offset,
637 * @brief Write to sfp
639 * @param p_hwfn - hw function
640 * @param p_ptt - PTT required for register access
641 * @param port - transceiver port
642 * @param addr - I2C address
643 * @param offset - offset in sfp
644 * @param len - buffer length
645 * @param p_buf - buffer to write from
647 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
649 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
650 struct ecore_ptt *p_ptt,
651 u32 port, u32 addr, u32 offset,
657 * @param p_hwfn - hw function
658 * @param p_ptt - PTT required for register access
659 * @param gpio - gpio number
660 * @param gpio_val - value read from gpio
662 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
664 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
665 struct ecore_ptt *p_ptt,
666 u16 gpio, u32 *gpio_val);
671 * @param p_hwfn - hw function
672 * @param p_ptt - PTT required for register access
673 * @param gpio - gpio number
674 * @param gpio_val - value to write to gpio
676 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
678 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
679 struct ecore_ptt *p_ptt,
680 u16 gpio, u16 gpio_val);
683 * @brief Gpio get information
685 * @param p_hwfn - hw function
686 * @param p_ptt - PTT required for register access
687 * @param gpio - gpio number
688 * @param gpio_direction - gpio is output (0) or input (1)
689 * @param gpio_ctrl - gpio control is uninitialized (0),
690 * path 0 (1), path 1 (2) or shared(3)
692 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
694 enum _ecore_status_t ecore_mcp_gpio_info(struct ecore_hwfn *p_hwfn,
695 struct ecore_ptt *p_ptt,
696 u16 gpio, u32 *gpio_direction,
700 * @brief Bist register test
702 * @param p_hwfn - hw function
703 * @param p_ptt - PTT required for register access
705 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
707 enum _ecore_status_t ecore_mcp_bist_register_test(struct ecore_hwfn *p_hwfn,
708 struct ecore_ptt *p_ptt);
711 * @brief Bist clock test
713 * @param p_hwfn - hw function
714 * @param p_ptt - PTT required for register access
716 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
718 enum _ecore_status_t ecore_mcp_bist_clock_test(struct ecore_hwfn *p_hwfn,
719 struct ecore_ptt *p_ptt);
722 * @brief Bist nvm test - get number of images
724 * @param p_hwfn - hw function
725 * @param p_ptt - PTT required for register access
726 * @param num_images - number of images if operation was
727 * successful. 0 if not.
729 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
731 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_num_images(
732 struct ecore_hwfn *p_hwfn,
733 struct ecore_ptt *p_ptt,
737 * @brief Bist nvm test - get image attributes by index
739 * @param p_hwfn - hw function
740 * @param p_ptt - PTT required for register access
741 * @param p_image_att - Attributes of image
742 * @param image_index - Index of image to get information for
744 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
746 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_image_att(
747 struct ecore_hwfn *p_hwfn,
748 struct ecore_ptt *p_ptt,
749 struct bist_nvm_image_att *p_image_att,
753 * @brief ecore_mcp_get_temperature_info - get the status of the temperature
756 * @param p_hwfn - hw function
757 * @param p_ptt - PTT required for register access
758 * @param p_temp_status - A pointer to an ecore_temperature_info structure to
759 * be filled with the temperature data
761 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
764 ecore_mcp_get_temperature_info(struct ecore_hwfn *p_hwfn,
765 struct ecore_ptt *p_ptt,
766 struct ecore_temperature_info *p_temp_info);
769 * @brief Get MBA versions - get MBA sub images versions
771 * @param p_hwfn - hw function
772 * @param p_ptt - PTT required for register access
773 * @param p_mba_vers - MBA versions array to fill
775 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
777 enum _ecore_status_t ecore_mcp_get_mba_versions(
778 struct ecore_hwfn *p_hwfn,
779 struct ecore_ptt *p_ptt,
780 struct ecore_mba_vers *p_mba_vers);
783 * @brief Count memory ecc events
785 * @param p_hwfn - hw function
786 * @param p_ptt - PTT required for register access
787 * @param num_events - number of memory ecc events
789 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
791 enum _ecore_status_t ecore_mcp_mem_ecc_events(struct ecore_hwfn *p_hwfn,
792 struct ecore_ptt *p_ptt,
795 struct ecore_mdump_info {
805 * @brief - Gets the MFW crash dump configuration and logs info.
809 * @param p_mdump_info
811 * @param return ECORE_SUCCESS upon success.
814 ecore_mcp_mdump_get_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
815 struct ecore_mdump_info *p_mdump_info);
818 * @brief - Clears the MFW crash dump logs.
823 * @param return ECORE_SUCCESS upon success.
825 enum _ecore_status_t ecore_mcp_mdump_clear_logs(struct ecore_hwfn *p_hwfn,
826 struct ecore_ptt *p_ptt);