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 struct ecore_mcp_drv_version {
120 u8 name[MCP_DRV_VER_STR_SIZE - 4];
123 struct ecore_mcp_lan_stats {
129 #ifndef ECORE_PROTO_STATS
130 #define ECORE_PROTO_STATS
132 enum ecore_mcp_protocol_type {
136 union ecore_mcp_protocol_stats {
137 struct ecore_mcp_lan_stats lan_stats;
141 enum ecore_ov_config_method {
147 enum ecore_ov_client {
152 enum ecore_ov_driver_state {
153 ECORE_OV_DRIVER_STATE_NOT_LOADED,
154 ECORE_OV_DRIVER_STATE_DISABLED,
155 ECORE_OV_DRIVER_STATE_ACTIVE
158 #define ECORE_MAX_NPIV_ENTRIES 128
159 #define ECORE_WWN_SIZE 8
160 struct ecore_fc_npiv_tbl {
162 u8 wwpn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
163 u8 wwnn[ECORE_MAX_NPIV_ENTRIES][ECORE_WWN_SIZE];
166 #ifndef __EXTRACT__LINUX__
167 enum ecore_led_mode {
170 ECORE_LED_MODE_RESTORE
175 * @brief - returns the link params of the hw function
179 * @returns pointer to link params
181 struct ecore_mcp_link_params *ecore_mcp_get_link_params(struct ecore_hwfn *);
184 * @brief - return the link state of the hw function
188 * @returns pointer to link state
190 struct ecore_mcp_link_state *ecore_mcp_get_link_state(struct ecore_hwfn *);
193 * @brief - return the link capabilities of the hw function
197 * @returns pointer to link capabilities
199 struct ecore_mcp_link_capabilities
200 *ecore_mcp_get_link_capabilities(struct ecore_hwfn *p_hwfn);
203 * @brief Request the MFW to set the the link according to 'link_input'.
207 * @param b_up - raise link if `true'. Reset link if `false'.
209 * @return enum _ecore_status_t
211 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
212 struct ecore_ptt *p_ptt, bool b_up);
215 * @brief Get the management firmware version value
217 * @param p_dev - ecore dev pointer
219 * @param p_mfw_ver - mfw version value
220 * @param p_running_bundle_id - image id in nvram; Optional.
222 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
224 enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_dev *p_dev,
225 struct ecore_ptt *p_ptt,
227 u32 *p_running_bundle_id);
230 * @brief Get media type value of the port.
232 * @param p_dev - ecore dev pointer
233 * @param mfw_ver - media type value
235 * @return enum _ecore_status_t -
236 * ECORE_SUCCESS - Operation was successful.
237 * ECORE_BUSY - Operation failed
239 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_dev *p_dev,
243 * @brief - Sends a command to the MCP mailbox.
245 * @param p_hwfn - hw function
246 * @param p_ptt - PTT required for register access
247 * @param cmd - command to be sent to the MCP
248 * @param param - optional param
249 * @param o_mcp_resp - the MCP response code (exclude sequence)
250 * @param o_mcp_param - optional parameter provided by the MCP response
252 * @return enum _ecore_status_t -
253 * ECORE_SUCCESS - operation was successful
254 * ECORE_BUSY - operation failed
256 enum _ecore_status_t ecore_mcp_cmd(struct ecore_hwfn *p_hwfn,
257 struct ecore_ptt *p_ptt, u32 cmd, u32 param,
258 u32 *o_mcp_resp, u32 *o_mcp_param);
261 * @brief - drains the nig, allowing completion to pass in case of pauses.
262 * (Should be called only from sleepable context)
267 enum _ecore_status_t ecore_mcp_drain(struct ecore_hwfn *p_hwfn,
268 struct ecore_ptt *p_ptt);
271 * @brief - return the mcp function info of the hw function
275 * @returns pointer to mcp function info
277 const struct ecore_mcp_function_info
278 *ecore_mcp_get_function_info(struct ecore_hwfn *p_hwfn);
281 * @brief - Function for reading/manipulating the nvram. Following are supported
283 * 1. Read: Read the specified nvram offset.
285 * type - ECORE_MCP_NVM_RD
286 * cmd - command code (e.g. DRV_MSG_CODE_NVM_READ_NVRAM)
287 * offset - nvm offset
291 * buf_size - buffer size
293 * 2. Write: Write the data at the specified nvram offset
295 * type - ECORE_MCP_NVM_WR
296 * cmd - command code (e.g. DRV_MSG_CODE_NVM_WRITE_NVRAM)
297 * offset - nvm offset
299 * buf_size - buffer size
301 * 3. Command: Send the NVM command to MCP.
303 * type - ECORE_MCP_CMD
304 * cmd - command code (e.g. DRV_MSG_CODE_NVM_DEL_FILE)
305 * offset - nvm offset
312 * @return ECORE_SUCCESS - operation was successful.
314 enum _ecore_status_t ecore_mcp_nvm_command(struct ecore_hwfn *p_hwfn,
315 struct ecore_ptt *p_ptt,
316 struct ecore_mcp_nvm_params *params);
319 * @brief - count number of function with a matching personality on engine.
323 * @param personalities - a bitmask of ecore_pci_personality values
325 * @returns the count of all devices on engine whose personality match one of
328 int ecore_mcp_get_personality_cnt(struct ecore_hwfn *p_hwfn,
329 struct ecore_ptt *p_ptt, u32 personalities);
332 * @brief Get the flash size value
336 * @param p_flash_size - flash size in bytes to be filled.
338 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
340 enum _ecore_status_t ecore_mcp_get_flash_size(struct ecore_hwfn *p_hwfn,
341 struct ecore_ptt *p_ptt,
345 * @brief Send driver version to MFW
349 * @param version - Version value
350 * @param name - Protocol driver name
352 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
355 ecore_mcp_send_drv_version(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
356 struct ecore_mcp_drv_version *p_ver);
359 * @brief Read the MFW process kill counter
366 u32 ecore_get_process_kill_counter(struct ecore_hwfn *p_hwfn,
367 struct ecore_ptt *p_ptt);
370 * @brief Trigger a recovery process
375 * @return enum _ecore_status_t
377 enum _ecore_status_t ecore_start_recovery_process(struct ecore_hwfn *p_hwfn,
378 struct ecore_ptt *p_ptt);
381 * @brief Notify MFW about the change in base device properties
385 * @param config - Configuation that has been updated
386 * @param client - ecore client type
388 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
391 ecore_mcp_ov_update_current_config(struct ecore_hwfn *p_hwfn,
392 struct ecore_ptt *p_ptt,
393 enum ecore_ov_config_method config,
394 enum ecore_ov_client client);
397 * @brief Notify MFW about the driver state
401 * @param drv_state - Driver state
403 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
406 ecore_mcp_ov_update_driver_state(struct ecore_hwfn *p_hwfn,
407 struct ecore_ptt *p_ptt,
408 enum ecore_ov_driver_state drv_state);
411 * @brief Read NPIV settings form the MFW
415 * @param p_table - Array to hold the FC NPIV data. Client need allocate the
416 * required buffer. The field 'count' specifies number of NPIV
417 * entries. A value of 0 means the table was not populated.
419 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
422 ecore_mcp_ov_get_fc_npiv(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
423 struct ecore_fc_npiv_tbl *p_table);
426 * @brief Send MTU size to MFW
430 * @param mtu - MTU size
432 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
434 enum _ecore_status_t ecore_mcp_ov_update_mtu(struct ecore_hwfn *p_hwfn,
435 struct ecore_ptt *p_ptt, u16 mtu);
438 * @brief Set LED status
442 * @param mode - LED mode
444 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
446 enum _ecore_status_t ecore_mcp_set_led(struct ecore_hwfn *p_hwfn,
447 struct ecore_ptt *p_ptt,
448 enum ecore_led_mode mode);
451 * @brief Set secure mode
454 * @param addr - nvm offset
456 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
458 enum _ecore_status_t ecore_mcp_nvm_set_secure_mode(struct ecore_dev *p_dev,
462 * @brief Write to phy
465 * @param addr - nvm offset
466 * @param cmd - nvm command
467 * @param p_buf - nvm write buffer
468 * @param len - buffer len
470 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
472 enum _ecore_status_t ecore_mcp_phy_write(struct ecore_dev *p_dev, u32 cmd,
473 u32 addr, u8 *p_buf, u32 len);
476 * @brief Write to nvm
479 * @param addr - nvm offset
480 * @param cmd - nvm command
481 * @param p_buf - nvm write buffer
482 * @param len - buffer len
484 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
486 enum _ecore_status_t ecore_mcp_nvm_write(struct ecore_dev *p_dev, u32 cmd,
487 u32 addr, u8 *p_buf, u32 len);
490 * @brief Put file begin
493 * @param addr - nvm offset
495 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
497 enum _ecore_status_t ecore_mcp_nvm_put_file_begin(struct ecore_dev *p_dev,
504 * @param addr - nvm offset
506 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
508 enum _ecore_status_t ecore_mcp_nvm_del_file(struct ecore_dev *p_dev, u32 addr);
511 * @brief Check latest response
514 * @param p_buf - nvm write buffer
516 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
518 enum _ecore_status_t ecore_mcp_nvm_resp(struct ecore_dev *p_dev, u8 *p_buf);
521 * @brief Read from phy
524 * @param addr - nvm offset
525 * @param cmd - nvm command
526 * @param p_buf - nvm write buffer
527 * @param len - buffer len
529 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
531 enum _ecore_status_t ecore_mcp_phy_read(struct ecore_dev *p_dev, u32 cmd,
532 u32 addr, u8 *p_buf, u32 len);
535 * @brief Read from nvm
538 * @param addr - nvm offset
539 * @param p_buf - nvm write buffer
540 * @param len - buffer len
542 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
544 enum _ecore_status_t ecore_mcp_nvm_read(struct ecore_dev *p_dev, u32 addr,
548 * @brief Read from sfp
550 * @param p_hwfn - hw function
551 * @param p_ptt - PTT required for register access
552 * @param port - transceiver port
553 * @param addr - I2C address
554 * @param offset - offset in sfp
555 * @param len - buffer length
556 * @param p_buf - buffer to read into
558 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
560 enum _ecore_status_t ecore_mcp_phy_sfp_read(struct ecore_hwfn *p_hwfn,
561 struct ecore_ptt *p_ptt,
562 u32 port, u32 addr, u32 offset,
566 * @brief Write to sfp
568 * @param p_hwfn - hw function
569 * @param p_ptt - PTT required for register access
570 * @param port - transceiver port
571 * @param addr - I2C address
572 * @param offset - offset in sfp
573 * @param len - buffer length
574 * @param p_buf - buffer to write from
576 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
578 enum _ecore_status_t ecore_mcp_phy_sfp_write(struct ecore_hwfn *p_hwfn,
579 struct ecore_ptt *p_ptt,
580 u32 port, u32 addr, u32 offset,
586 * @param p_hwfn - hw function
587 * @param p_ptt - PTT required for register access
588 * @param gpio - gpio number
589 * @param gpio_val - value read from gpio
591 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
593 enum _ecore_status_t ecore_mcp_gpio_read(struct ecore_hwfn *p_hwfn,
594 struct ecore_ptt *p_ptt,
595 u16 gpio, u32 *gpio_val);
600 * @param p_hwfn - hw function
601 * @param p_ptt - PTT required for register access
602 * @param gpio - gpio number
603 * @param gpio_val - value to write to gpio
605 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
607 enum _ecore_status_t ecore_mcp_gpio_write(struct ecore_hwfn *p_hwfn,
608 struct ecore_ptt *p_ptt,
609 u16 gpio, u16 gpio_val);