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_client {
178 ECORE_OV_CLIENT_USER,
179 ECORE_OV_CLIENT_VENDOR_SPEC
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
188 #define ECORE_MAX_NPIV_ENTRIES 128
189 #define ECORE_WWN_SIZE 8
190 struct ecore_fc_npiv_tbl {
192 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
193 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
196 #ifndef __EXTRACT__LINUX__
197 enum ecore_led_mode {
200 ECORE_LED_MODE_RESTORE
204 struct ecore_temperature_sensor {
211 #define ECORE_MAX_NUM_OF_SENSORS 7
212 struct ecore_temperature_info {
214 struct ecore_temperature_sensor sensors[ECORE_MAX_NUM_OF_SENSORS];
217 enum ecore_mba_img_idx {
218 ECORE_MBA_LEGACY_IDX,
219 ECORE_MBA_PCI3CLP_IDX,
226 ECORE_MAX_NUM_OF_ROMIMG
229 struct ecore_mba_vers {
230 u32 mba_vers[ECORE_MAX_NUM_OF_ROMIMG];
234 * @brief - returns the link params of the hw function
238 * @returns pointer to link params
240 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
243 * @brief - return the link state of the hw function
247 * @returns pointer to link state
249 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
252 * @brief - return the link capabilities of the hw function
256 * @returns pointer to link capabilities
258 struct ecore_mcp_link_capabilities
259 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
262 * @brief Request the MFW to set the the link according to 'link_input'.
266 * @param b_up - raise link if `true'. Reset link if `false'.
268 * @return enum _ecore_status_t
270 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
271 struct ecore_ptt *p_ptt,
275 * @brief Get the management firmware version value
279 * @param p_mfw_ver - mfw version value
280 * @param p_running_bundle_id - image id in nvram; Optional.
282 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
284 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
285 struct ecore_ptt *p_ptt,
287 u32 *p_running_bundle_id);
290 * @brief Get media type value of the port.
292 * @param p_dev - ecore dev pointer
293 * @param mfw_ver - media type value
295 * @return enum _ecore_status_t -
296 * ECORE_SUCCESS - Operation was successful.
297 * ECORE_BUSY - Operation failed
299 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev,
303 * @brief - Sends a command to the MCP mailbox.
305 * @param p_hwfn - hw function
306 * @param p_ptt - PTT required for register access
307 * @param cmd - command to be sent to the MCP
308 * @param param - optional param
309 * @param o_mcp_resp - the MCP response code (exclude sequence)
310 * @param o_mcp_param - optional parameter provided by the MCP response
312 * @return enum _ecore_status_t -
313 * ECORE_SUCCESS - operation was successful
314 * ECORE_BUSY - operation failed
316 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
317 struct ecore_ptt *p_ptt, u32 cmd, u32 param,
318 u32 *o_mcp_resp, u32 *o_mcp_param);
321 * @brief - drains the nig, allowing completion to pass in case of pauses.
322 * (Should be called only from sleepable context)
327 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
328 struct ecore_ptt *p_ptt);
332 * @brief - return the mcp function info of the hw function
336 * @returns pointer to mcp function info
338 const struct ecore_mcp_function_info
339 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
343 * @brief - Function for reading/manipulating the nvram. Following are supported
345 * 1. Read: Read the specified nvram offset.
347 * type - ECORE_MCP_NVM_RD
348 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM)
349 * offset - nvm offset
353 * buf_size - buffer size
355 * 2. Write: Write the data at the specified nvram offset
357 * type - ECORE_MCP_NVM_WR
358 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM)
359 * offset - nvm offset
361 * buf_size - buffer size
363 * 3. Command: Send the NVM command to MCP.
365 * type - ECORE_MCP_CMD
366 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE)
367 * offset - nvm offset
374 * @return ECORE_SUCCESS - operation was successful.
376 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn,
377 struct ecore_ptt *p_ptt,
378 struct ecore_mcp_nvm_params *params);
382 * @brief - count number of function with a matching personality on engine.
386 * @param personalities - a bitmask of ecore_pci_personality values
388 * @returns the count of all devices on engine whose personality match one of
391 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
392 struct ecore_ptt *p_ptt,
397 * @brief Get the flash size value
401 * @param p_flash_size - flash size in bytes to be filled.
403 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
405 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
406 struct ecore_ptt *p_ptt,
410 * @brief Send driver version to MFW
414 * @param version - Version value
415 * @param name - Protocol driver name
417 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
420 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
421 struct ecore_mcp_drv_version *p_ver);
424 * @brief Read the MFW process kill counter
431 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
432 struct ecore_ptt *p_ptt);
435 * @brief Trigger a recovery process
440 * @return enum _ecore_status_t
442 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
443 struct ecore_ptt *p_ptt);
446 * @brief Notify MFW about the change in base device properties
450 * @param client - ecore client type
452 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
455 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
456 struct ecore_ptt *p_ptt,
457 enum ecore_ov_client client);
460 * @brief Notify MFW about the driver state
464 * @param drv_state - Driver state
466 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
469 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
470 struct ecore_ptt *p_ptt,
471 enum ecore_ov_driver_state drv_state);
474 * @brief Read NPIV settings form the MFW
478 * @param p_table - Array to hold the FC NPIV data. Client need allocate the
479 * required buffer. The field 'count' specifies number of NPIV
480 * entries. A value of 0 means the table was not populated.
482 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
485 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
486 struct ecore_fc_npiv_tbl *p_table);
489 * @brief Send MTU size to MFW
493 * @param mtu - MTU size
495 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
497 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
498 struct ecore_ptt *p_ptt, u16 mtu);
501 * @brief Set LED status
505 * @param mode - LED mode
507 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
509 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
510 struct ecore_ptt *p_ptt,
511 enum ecore_led_mode mode);
514 * @brief Set secure mode
517 * @param addr - nvm offset
519 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
521 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
525 * @brief Write to phy
528 * @param addr - nvm offset
529 * @param cmd - nvm command
530 * @param p_buf - nvm write buffer
531 * @param len - buffer len
533 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
535 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
536 u32 addr, u8 *p_buf, u32 len);
539 * @brief Write to nvm
542 * @param addr - nvm offset
543 * @param cmd - nvm command
544 * @param p_buf - nvm write buffer
545 * @param len - buffer len
547 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
549 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
550 u32 addr, u8 *p_buf, u32 len);
553 * @brief Put file begin
556 * @param addr - nvm offset
558 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
560 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
567 * @param addr - nvm offset
569 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
571 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev,
575 * @brief Check latest response
578 * @param p_buf - nvm write buffer
580 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
582 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
585 * @brief Read from phy
588 * @param addr - nvm offset
589 * @param cmd - nvm command
590 * @param p_buf - nvm write buffer
591 * @param len - buffer len
593 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
595 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
596 u32 addr, u8 *p_buf, u32 len);
599 * @brief Read from nvm
602 * @param addr - nvm offset
603 * @param p_buf - nvm write buffer
604 * @param len - buffer len
606 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
608 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
612 * @brief Read from sfp
614 * @param p_hwfn - hw function
615 * @param p_ptt - PTT required for register access
616 * @param port - transceiver port
617 * @param addr - I2C address
618 * @param offset - offset in sfp
619 * @param len - buffer length
620 * @param p_buf - buffer to read into
622 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
624 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
625 struct ecore_ptt *p_ptt,
626 u32 port, u32 addr, u32 offset,
630 * @brief Write to sfp
632 * @param p_hwfn - hw function
633 * @param p_ptt - PTT required for register access
634 * @param port - transceiver port
635 * @param addr - I2C address
636 * @param offset - offset in sfp
637 * @param len - buffer length
638 * @param p_buf - buffer to write from
640 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
642 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
643 struct ecore_ptt *p_ptt,
644 u32 port, u32 addr, u32 offset,
650 * @param p_hwfn - hw function
651 * @param p_ptt - PTT required for register access
652 * @param gpio - gpio number
653 * @param gpio_val - value read from gpio
655 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
657 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
658 struct ecore_ptt *p_ptt,
659 u16 gpio, u32 *gpio_val);
664 * @param p_hwfn - hw function
665 * @param p_ptt - PTT required for register access
666 * @param gpio - gpio number
667 * @param gpio_val - value to write to gpio
669 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
671 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
672 struct ecore_ptt *p_ptt,
673 u16 gpio, u16 gpio_val);
676 * @brief Gpio get information
678 * @param p_hwfn - hw function
679 * @param p_ptt - PTT required for register access
680 * @param gpio - gpio number
681 * @param gpio_direction - gpio is output (0) or input (1)
682 * @param gpio_ctrl - gpio control is uninitialized (0),
683 * path 0 (1), path 1 (2) or shared(3)
685 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
687 enum _ecore_status_t ecore_mcp_gpio_info(struct ecore_hwfn *p_hwfn,
688 struct ecore_ptt *p_ptt,
689 u16 gpio, u32 *gpio_direction,
693 * @brief Bist register test
695 * @param p_hwfn - hw function
696 * @param p_ptt - PTT required for register access
698 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
700 enum _ecore_status_t ecore_mcp_bist_register_test(struct ecore_hwfn *p_hwfn,
701 struct ecore_ptt *p_ptt);
704 * @brief Bist clock test
706 * @param p_hwfn - hw function
707 * @param p_ptt - PTT required for register access
709 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
711 enum _ecore_status_t ecore_mcp_bist_clock_test(struct ecore_hwfn *p_hwfn,
712 struct ecore_ptt *p_ptt);
715 * @brief Bist nvm test - get number of images
717 * @param p_hwfn - hw function
718 * @param p_ptt - PTT required for register access
719 * @param num_images - number of images if operation was
720 * successful. 0 if not.
722 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
724 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_num_images(
725 struct ecore_hwfn *p_hwfn,
726 struct ecore_ptt *p_ptt,
730 * @brief Bist nvm test - get image attributes by index
732 * @param p_hwfn - hw function
733 * @param p_ptt - PTT required for register access
734 * @param p_image_att - Attributes of image
735 * @param image_index - Index of image to get information for
737 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
739 enum _ecore_status_t ecore_mcp_bist_nvm_test_get_image_att(
740 struct ecore_hwfn *p_hwfn,
741 struct ecore_ptt *p_ptt,
742 struct bist_nvm_image_att *p_image_att,
746 * @brief ecore_mcp_get_temperature_info - get the status of the temperature
749 * @param p_hwfn - hw function
750 * @param p_ptt - PTT required for register access
751 * @param p_temp_status - A pointer to an ecore_temperature_info structure to
752 * be filled with the temperature data
754 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
757 ecore_mcp_get_temperature_info(struct ecore_hwfn *p_hwfn,
758 struct ecore_ptt *p_ptt,
759 struct ecore_temperature_info *p_temp_info);
762 * @brief Get MBA versions - get MBA sub images versions
764 * @param p_hwfn - hw function
765 * @param p_ptt - PTT required for register access
766 * @param p_mba_vers - MBA versions array to fill
768 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
770 enum _ecore_status_t ecore_mcp_get_mba_versions(
771 struct ecore_hwfn *p_hwfn,
772 struct ecore_ptt *p_ptt,
773 struct ecore_mba_vers *p_mba_vers);
776 * @brief Count memory ecc events
778 * @param p_hwfn - hw function
779 * @param p_ptt - PTT required for register access
780 * @param num_events - number of memory ecc events
782 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
784 enum _ecore_status_t ecore_mcp_mem_ecc_events(struct ecore_hwfn *p_hwfn,
785 struct ecore_ptt *p_ptt,
788 struct ecore_mdump_info {
798 * @brief - Gets the MFW crash dump configuration and logs info.
802 * @param p_mdump_info
804 * @param return ECORE_SUCCESS upon success.
807 ecore_mcp_mdump_get_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
808 struct ecore_mdump_info *p_mdump_info);
811 * @brief - Clears the MFW crash dump logs.
816 * @param return ECORE_SUCCESS upon success.
818 enum _ecore_status_t ecore_mcp_mdump_clear_logs(struct ecore_hwfn *p_hwfn,
819 struct ecore_ptt *p_ptt);