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;
36 struct ecore_mcp_link_state {
39 u32 line_speed; /* In Mb/s */
40 u32 min_pf_rate; /* In Mb/s */
41 u32 speed; /* In Mb/s */
46 bool parallel_detection;
49 #define ECORE_LINK_PARTNER_SPEED_1G_HD (1 << 0)
50 #define ECORE_LINK_PARTNER_SPEED_1G_FD (1 << 1)
51 #define ECORE_LINK_PARTNER_SPEED_10G (1 << 2)
52 #define ECORE_LINK_PARTNER_SPEED_20G (1 << 3)
53 #define ECORE_LINK_PARTNER_SPEED_25G (1 << 4)
54 #define ECORE_LINK_PARTNER_SPEED_40G (1 << 5)
55 #define ECORE_LINK_PARTNER_SPEED_50G (1 << 6)
56 #define ECORE_LINK_PARTNER_SPEED_100G (1 << 7)
57 u32 partner_adv_speed;
59 bool partner_tx_flow_ctrl_en;
60 bool partner_rx_flow_ctrl_en;
62 #define ECORE_LINK_PARTNER_SYMMETRIC_PAUSE (1)
63 #define ECORE_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
64 #define ECORE_LINK_PARTNER_BOTH_PAUSE (3)
70 struct ecore_mcp_function_info {
73 enum ecore_pci_personality protocol;
83 #define ECORE_MCP_VLAN_UNSET (0xffff)
87 struct ecore_mcp_nvm_common {
94 struct ecore_mcp_nvm_rd {
99 struct ecore_mcp_nvm_wr {
104 struct ecore_mcp_nvm_params {
105 #define ECORE_MCP_CMD (1 << 0)
106 #define ECORE_MCP_NVM_RD (1 << 1)
107 #define ECORE_MCP_NVM_WR (1 << 2)
110 struct ecore_mcp_nvm_common nvm_common;
113 struct ecore_mcp_nvm_rd nvm_rd;
114 struct ecore_mcp_nvm_wr nvm_wr;
118 enum ecore_nvm_images {
119 ECORE_NVM_IMAGE_ISCSI_CFG,
120 ECORE_NVM_IMAGE_FCOE_CFG,
123 struct ecore_mcp_drv_version {
125 u8 name[MCP_DRV_VER_STR_SIZE - 4];
128 struct ecore_mcp_lan_stats {
134 #ifndef ECORE_PROTO_STATS
135 #define ECORE_PROTO_STATS
137 enum ecore_mcp_protocol_type {
141 union ecore_mcp_protocol_stats {
142 struct ecore_mcp_lan_stats lan_stats;
146 enum ecore_ov_config_method {
152 enum ecore_ov_client {
157 enum ecore_ov_driver_state {
158 ECORE_OV_DRIVER_STATE_NOT_LOADED,
159 ECORE_OV_DRIVER_STATE_DISABLED,
160 ECORE_OV_DRIVER_STATE_ACTIVE
163 #define ECORE_MAX_NPIV_ENTRIES 128
164 #define ECORE_WWN_SIZE 8
165 struct ecore_fc_npiv_tbl {
167 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
168 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
171 #ifndef __EXTRACT__LINUX__
172 enum ecore_led_mode {
175 ECORE_LED_MODE_RESTORE
179 struct ecore_temperature_sensor {
186 #define ECORE_MAX_NUM_OF_SENSORS 7
187 struct ecore_temperature_info {
189 struct ecore_temperature_sensor sensors[ECORE_MAX_NUM_OF_SENSORS];
192 enum ecore_mba_img_idx {
193 ECORE_MBA_LEGACY_IDX,
194 ECORE_MBA_PCI3CLP_IDX,
201 ECORE_MAX_NUM_OF_ROMIMG
204 struct ecore_mba_vers {
205 u32 mba_vers[ECORE_MAX_NUM_OF_ROMIMG];
209 * @brief - returns the link params of the hw function
213 * @returns pointer to link params
215 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
218 * @brief - return the link state of the hw function
222 * @returns pointer to link state
224 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
227 * @brief - return the link capabilities of the hw function
231 * @returns pointer to link capabilities
233 struct ecore_mcp_link_capabilities
234 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
237 * @brief Request the MFW to set the the link according to 'link_input'.
241 * @param b_up - raise link if `true'. Reset link if `false'.
243 * @return enum _ecore_status_t
245 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
246 struct ecore_ptt *p_ptt, bool b_up);
249 * @brief Get the management firmware version value
251 * @param p_dev - ecore dev pointer
253 * @param p_mfw_ver - mfw version value
254 * @param p_running_bundle_id - image id in nvram; Optional.
256 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
258 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_dev *p_dev,
259 struct ecore_ptt *p_ptt,
261 u32 *p_running_bundle_id);
264 * @brief Get media type value of the port.
266 * @param p_dev - ecore dev pointer
267 * @param mfw_ver - media type value
269 * @return enum _ecore_status_t -
270 * ECORE_SUCCESS - Operation was successful.
271 * ECORE_BUSY - Operation failed
273 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev,
277 * @brief - Sends a command to the MCP mailbox.
279 * @param p_hwfn - hw function
280 * @param p_ptt - PTT required for register access
281 * @param cmd - command to be sent to the MCP
282 * @param param - optional param
283 * @param o_mcp_resp - the MCP response code (exclude sequence)
284 * @param o_mcp_param - optional parameter provided by the MCP response
286 * @return enum _ecore_status_t -
287 * ECORE_SUCCESS - operation was successful
288 * ECORE_BUSY - operation failed
290 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
291 struct ecore_ptt *p_ptt, u32 cmd, u32 param,
292 u32 *o_mcp_resp, u32 *o_mcp_param);
295 * @brief - drains the nig, allowing completion to pass in case of pauses.
296 * (Should be called only from sleepable context)
301 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
302 struct ecore_ptt *p_ptt);
305 * @brief - return the mcp function info of the hw function
309 * @returns pointer to mcp function info
311 const struct ecore_mcp_function_info
312 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
315 * @brief - Function for reading/manipulating the nvram. Following are supported
317 * 1. Read: Read the specified nvram offset.
319 * type - ECORE_MCP_NVM_RD
320 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM)
321 * offset - nvm offset
325 * buf_size - buffer size
327 * 2. Write: Write the data at the specified nvram offset
329 * type - ECORE_MCP_NVM_WR
330 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM)
331 * offset - nvm offset
333 * buf_size - buffer size
335 * 3. Command: Send the NVM command to MCP.
337 * type - ECORE_MCP_CMD
338 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE)
339 * offset - nvm offset
346 * @return ECORE_SUCCESS - operation was successful.
348 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn,
349 struct ecore_ptt *p_ptt,
350 struct ecore_mcp_nvm_params *params);
353 * @brief - count number of function with a matching personality on engine.
357 * @param personalities - a bitmask of ecore_pci_personality values
359 * @returns the count of all devices on engine whose personality match one of
362 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
363 struct ecore_ptt *p_ptt, u32 personalities);
366 * @brief Get the flash size value
370 * @param p_flash_size - flash size in bytes to be filled.
372 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
374 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
375 struct ecore_ptt *p_ptt,
379 * @brief Send driver version to MFW
383 * @param version - Version value
384 * @param name - Protocol driver name
386 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
389 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
390 struct ecore_mcp_drv_version *p_ver);
393 * @brief Read the MFW process kill counter
400 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
401 struct ecore_ptt *p_ptt);
404 * @brief Trigger a recovery process
409 * @return enum _ecore_status_t
411 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
412 struct ecore_ptt *p_ptt);
415 * @brief Notify MFW about the change in base device properties
419 * @param config - Configuation that has been updated
420 * @param client - ecore client type
422 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
425 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
426 struct ecore_ptt *p_ptt,
427 enum ecore_ov_config_method config,
428 enum ecore_ov_client client);
431 * @brief Notify MFW about the driver state
435 * @param drv_state - Driver state
437 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
440 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
441 struct ecore_ptt *p_ptt,
442 enum ecore_ov_driver_state drv_state);
445 * @brief Read NPIV settings form the MFW
449 * @param p_table - Array to hold the FC NPIV data. Client need allocate the
450 * required buffer. The field 'count' specifies number of NPIV
451 * entries. A value of 0 means the table was not populated.
453 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
456 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
457 struct ecore_fc_npiv_tbl *p_table);
460 * @brief Send MTU size to MFW
464 * @param mtu - MTU size
466 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
468 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
469 struct ecore_ptt *p_ptt, u16 mtu);
472 * @brief Set LED status
476 * @param mode - LED mode
478 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
480 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
481 struct ecore_ptt *p_ptt,
482 enum ecore_led_mode mode);
485 * @brief Set secure mode
488 * @param addr - nvm offset
490 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
492 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
496 * @brief Write to phy
499 * @param addr - nvm offset
500 * @param cmd - nvm command
501 * @param p_buf - nvm write buffer
502 * @param len - buffer len
504 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
506 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
507 u32 addr, u8 *p_buf, u32 len);
510 * @brief Write to nvm
513 * @param addr - nvm offset
514 * @param cmd - nvm command
515 * @param p_buf - nvm write buffer
516 * @param len - buffer len
518 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
520 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
521 u32 addr, u8 *p_buf, u32 len);
524 * @brief Put file begin
527 * @param addr - nvm offset
529 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
531 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
538 * @param addr - nvm offset
540 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
542 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev, u32 addr);
545 * @brief Check latest response
548 * @param p_buf - nvm write buffer
550 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
552 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
555 * @brief Read from phy
558 * @param addr - nvm offset
559 * @param cmd - nvm command
560 * @param p_buf - nvm write buffer
561 * @param len - buffer len
563 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
565 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
566 u32 addr, u8 *p_buf, u32 len);
569 * @brief Read from nvm
572 * @param addr - nvm offset
573 * @param p_buf - nvm write buffer
574 * @param len - buffer len
576 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
578 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
582 * @brief Read from sfp
584 * @param p_hwfn - hw function
585 * @param p_ptt - PTT required for register access
586 * @param port - transceiver port
587 * @param addr - I2C address
588 * @param offset - offset in sfp
589 * @param len - buffer length
590 * @param p_buf - buffer to read into
592 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
594 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
595 struct ecore_ptt *p_ptt,
596 u32 port, u32 addr, u32 offset,
600 * @brief Write to sfp
602 * @param p_hwfn - hw function
603 * @param p_ptt - PTT required for register access
604 * @param port - transceiver port
605 * @param addr - I2C address
606 * @param offset - offset in sfp
607 * @param len - buffer length
608 * @param p_buf - buffer to write from
610 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
612 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
613 struct ecore_ptt *p_ptt,
614 u32 port, u32 addr, u32 offset,
620 * @param p_hwfn - hw function
621 * @param p_ptt - PTT required for register access
622 * @param gpio - gpio number
623 * @param gpio_val - value read from gpio
625 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
627 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
628 struct ecore_ptt *p_ptt,
629 u16 gpio, u32 *gpio_val);
634 * @param p_hwfn - hw function
635 * @param p_ptt - PTT required for register access
636 * @param gpio - gpio number
637 * @param gpio_val - value to write to gpio
639 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
641 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
642 struct ecore_ptt *p_ptt,
643 u16 gpio, u16 gpio_val);
645 * @brief Gpio get information
647 * @param p_hwfn - hw function
648 * @param p_ptt - PTT required for register access
649 * @param gpio - gpio number
650 * @param gpio_direction - gpio is output (0) or input (1)
651 * @param gpio_ctrl - gpio control is uninitialized (0),
652 * path 0 (1), path 1 (2) or shared(3)
654 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
656 enum _ecore_status_t ecore_mcp_gpio_info(struct ecore_hwfn *p_hwfn,
657 struct ecore_ptt *p_ptt,
658 u16 gpio, u32 *gpio_direction,
662 * @brief Bist register test
664 * @param p_hwfn - hw function
665 * @param p_ptt - PTT required for register access
667 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
669 enum _ecore_status_t ecore_mcp_bist_register_test(struct ecore_hwfn *p_hwfn,
670 struct ecore_ptt *p_ptt);
673 * @brief Bist clock test
675 * @param p_hwfn - hw function
676 * @param p_ptt - PTT required for register access
678 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
680 enum _ecore_status_t ecore_mcp_bist_clock_test(struct ecore_hwfn *p_hwfn,
681 struct ecore_ptt *p_ptt);
684 * @brief Bist nvm test - get number of images
686 * @param p_hwfn - hw function
687 * @param p_ptt - PTT required for register access
688 * @param num_images - number of images if operation was
689 * successful. 0 if not.
691 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
694 ecore_mcp_bist_nvm_test_get_num_images(struct ecore_hwfn *p_hwfn,
695 struct ecore_ptt *p_ptt,
699 * @brief Bist nvm test - get image attributes by index
701 * @param p_hwfn - hw function
702 * @param p_ptt - PTT required for register access
703 * @param p_image_att - Attributes of image
704 * @param image_index - Index of image to get information for
706 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
709 ecore_mcp_bist_nvm_test_get_image_att(struct ecore_hwfn *p_hwfn,
710 struct ecore_ptt *p_ptt,
711 struct bist_nvm_image_att *p_image_att,
715 * @brief ecore_mcp_get_temperature_info - get the status of the temperature
718 * @param p_hwfn - hw function
719 * @param p_ptt - PTT required for register access
720 * @param p_temp_status - A pointer to an ecore_temperature_info structure to
721 * be filled with the temperature data
723 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
726 ecore_mcp_get_temperature_info(struct ecore_hwfn *p_hwfn,
727 struct ecore_ptt *p_ptt,
728 struct ecore_temperature_info *p_temp_info);
730 * @brief Get MBA versions - get MBA sub images versions
732 * @param p_hwfn - hw function
733 * @param p_ptt - PTT required for register access
734 * @param p_mba_vers - MBA versions array to fill
736 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
738 enum _ecore_status_t ecore_mcp_get_mba_versions(
739 struct ecore_hwfn *p_hwfn,
740 struct ecore_ptt *p_ptt,
741 struct ecore_mba_vers *p_mba_vers);
744 * @brief Count memory ecc events
746 * @param p_hwfn - hw function
747 * @param p_ptt - PTT required for register access
748 * @param num_events - number of memory ecc events
750 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
752 enum _ecore_status_t ecore_mcp_mem_ecc_events(struct ecore_hwfn *p_hwfn,
753 struct ecore_ptt *p_ptt,
757 * @brief Sets whether a critical error notification from the MFW is acked, or
758 * is it being ignored and thus allowing the MFW crash dump.
761 * @param mdump_enable
764 void ecore_mcp_mdump_enable(struct ecore_dev *p_dev, bool mdump_enable);