1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
10 #include <linux/types.h>
11 #include <linux/delay.h>
12 #include <linux/slab.h>
13 #include <linux/spinlock.h>
14 #include <linux/qed/qed_fcoe_if.h>
16 #include "qed_dev_api.h"
18 struct qed_mcp_link_speed_params {
20 u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */
21 u32 forced_speed; /* In Mb/s */
24 struct qed_mcp_link_pause_params {
30 enum qed_mcp_eee_mode {
33 QED_MCP_EEE_UNSUPPORTED
36 struct qed_mcp_link_params {
37 struct qed_mcp_link_speed_params speed;
38 struct qed_mcp_link_pause_params pause;
40 struct qed_link_eee_params eee;
43 struct qed_mcp_link_capabilities {
44 u32 speed_capabilities;
45 bool default_speed_autoneg;
46 enum qed_mcp_eee_mode default_eee;
51 struct qed_mcp_link_state {
55 /* Actual link speed in Mb/s */
58 /* PF max speed in Mb/s, deduced from line_speed
59 * according to PF max bandwidth configuration.
66 bool parallel_detection;
69 u32 partner_adv_speed;
70 #define QED_LINK_PARTNER_SPEED_1G_HD BIT(0)
71 #define QED_LINK_PARTNER_SPEED_1G_FD BIT(1)
72 #define QED_LINK_PARTNER_SPEED_10G BIT(2)
73 #define QED_LINK_PARTNER_SPEED_20G BIT(3)
74 #define QED_LINK_PARTNER_SPEED_25G BIT(4)
75 #define QED_LINK_PARTNER_SPEED_40G BIT(5)
76 #define QED_LINK_PARTNER_SPEED_50G BIT(6)
77 #define QED_LINK_PARTNER_SPEED_100G BIT(7)
79 bool partner_tx_flow_ctrl_en;
80 bool partner_rx_flow_ctrl_en;
83 #define QED_LINK_PARTNER_SYMMETRIC_PAUSE 0x1
84 #define QED_LINK_PARTNER_ASYMMETRIC_PAUSE 0x2
85 #define QED_LINK_PARTNER_BOTH_PAUSE 0x3
93 struct qed_mcp_function_info {
96 enum qed_pci_personality protocol;
106 #define QED_MCP_VLAN_UNSET (0xffff)
112 struct qed_mcp_nvm_common {
119 struct qed_mcp_drv_version {
121 u8 name[MCP_DRV_VER_STR_SIZE - 4];
124 struct qed_mcp_lan_stats {
130 struct qed_mcp_fcoe_stats {
137 struct qed_mcp_iscsi_stats {
144 struct qed_mcp_rdma_stats {
151 enum qed_mcp_protocol_type {
158 union qed_mcp_protocol_stats {
159 struct qed_mcp_lan_stats lan_stats;
160 struct qed_mcp_fcoe_stats fcoe_stats;
161 struct qed_mcp_iscsi_stats iscsi_stats;
162 struct qed_mcp_rdma_stats rdma_stats;
165 enum qed_ov_eswitch {
174 QED_OV_CLIENT_VENDOR_SPEC
177 enum qed_ov_driver_state {
178 QED_OV_DRIVER_STATE_NOT_LOADED,
179 QED_OV_DRIVER_STATE_DISABLED,
180 QED_OV_DRIVER_STATE_ACTIVE
189 enum qed_mfw_tlv_type {
190 QED_MFW_TLV_GENERIC = 0x1, /* Core driver TLVs */
191 QED_MFW_TLV_ETH = 0x2, /* L2 driver TLVs */
192 QED_MFW_TLV_FCOE = 0x4, /* FCoE protocol TLVs */
193 QED_MFW_TLV_ISCSI = 0x8, /* SCSI protocol TLVs */
194 QED_MFW_TLV_MAX = 0x16,
197 struct qed_mfw_tlv_generic {
198 #define QED_MFW_TLV_FLAGS_SIZE 2
200 u8 ipv4_csum_offload;
205 #define QED_MFW_TLV_MAC_COUNT 3
206 /* First entry for primary MAC, 2 secondary MACs possible */
207 u8 mac[QED_MFW_TLV_MAC_COUNT][6];
208 bool mac_set[QED_MFW_TLV_MAC_COUNT];
220 union qed_mfw_tlv_data {
221 struct qed_mfw_tlv_generic generic;
222 struct qed_mfw_tlv_eth eth;
223 struct qed_mfw_tlv_fcoe fcoe;
224 struct qed_mfw_tlv_iscsi iscsi;
227 #define QED_NVM_CFG_OPTION_ALL BIT(0)
228 #define QED_NVM_CFG_OPTION_INIT BIT(1)
229 #define QED_NVM_CFG_OPTION_COMMIT BIT(2)
230 #define QED_NVM_CFG_OPTION_FREE BIT(3)
231 #define QED_NVM_CFG_OPTION_ENTITY_SEL BIT(4)
234 * @brief - returns the link params of the hw function
238 * @returns pointer to link params
240 struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *);
243 * @brief - return the link state of the hw function
247 * @returns pointer to link state
249 struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *);
252 * @brief - return the link capabilities of the hw function
256 * @returns pointer to link capabilities
258 struct qed_mcp_link_capabilities
259 *qed_mcp_get_link_capabilities(struct qed_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'.
270 int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
271 struct qed_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 int - 0 - operation was successful.
284 int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
285 struct qed_ptt *p_ptt,
286 u32 *p_mfw_ver, u32 *p_running_bundle_id);
289 * @brief Get the MBI version value
293 * @param p_mbi_ver - A pointer to a variable to be filled with the MBI version.
295 * @return int - 0 - operation was successful.
297 int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
298 struct qed_ptt *p_ptt, u32 *p_mbi_ver);
301 * @brief Get media type value of the port.
303 * @param cdev - qed dev pointer
305 * @param mfw_ver - media type value
308 * 0 - Operation was successul.
309 * -EBUSY - Operation failed
311 int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
312 struct qed_ptt *p_ptt, u32 *media_type);
315 * @brief Get transceiver data of the port.
317 * @param cdev - qed dev pointer
319 * @param p_transceiver_state - transceiver state.
320 * @param p_transceiver_type - media type value
323 * 0 - Operation was successful.
324 * -EBUSY - Operation failed
326 int qed_mcp_get_transceiver_data(struct qed_hwfn *p_hwfn,
327 struct qed_ptt *p_ptt,
328 u32 *p_transceiver_state,
329 u32 *p_tranceiver_type);
332 * @brief Get transceiver supported speed mask.
334 * @param cdev - qed dev pointer
336 * @param p_speed_mask - Bit mask of all supported speeds.
339 * 0 - Operation was successful.
340 * -EBUSY - Operation failed
343 int qed_mcp_trans_speed_mask(struct qed_hwfn *p_hwfn,
344 struct qed_ptt *p_ptt, u32 *p_speed_mask);
347 * @brief Get board configuration.
349 * @param cdev - qed dev pointer
351 * @param p_board_config - Board config.
354 * 0 - Operation was successful.
355 * -EBUSY - Operation failed
357 int qed_mcp_get_board_config(struct qed_hwfn *p_hwfn,
358 struct qed_ptt *p_ptt, u32 *p_board_config);
361 * @brief General function for sending commands to the MCP
362 * mailbox. It acquire mutex lock for the entire
363 * operation, from sending the request until the MCP
364 * response. Waiting for MCP response will be checked up
365 * to 5 seconds every 5ms.
367 * @param p_hwfn - hw function
368 * @param p_ptt - PTT required for register access
369 * @param cmd - command to be sent to the MCP.
370 * @param param - Optional param
371 * @param o_mcp_resp - The MCP response code (exclude sequence).
372 * @param o_mcp_param- Optional parameter provided by the MCP
374 * @return int - 0 - operation
377 int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
378 struct qed_ptt *p_ptt,
385 * @brief - drains the nig, allowing completion to pass in case of pauses.
386 * (Should be called only from sleepable context)
391 int qed_mcp_drain(struct qed_hwfn *p_hwfn,
392 struct qed_ptt *p_ptt);
395 * @brief Get the flash size value
399 * @param p_flash_size - flash size in bytes to be filled.
401 * @return int - 0 - operation was successul.
403 int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
404 struct qed_ptt *p_ptt,
408 * @brief Send driver version to MFW
412 * @param version - Version value
413 * @param name - Protocol driver name
415 * @return int - 0 - operation was successul.
418 qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
419 struct qed_ptt *p_ptt,
420 struct qed_mcp_drv_version *p_ver);
423 * @brief Read the MFW process kill counter
430 u32 qed_get_process_kill_counter(struct qed_hwfn *p_hwfn,
431 struct qed_ptt *p_ptt);
434 * @brief Trigger a recovery process
441 int qed_start_recovery_process(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
444 * @brief A recovery handler must call this function as its first step.
445 * It is assumed that the handler is not run from an interrupt context.
452 int qed_recovery_prolog(struct qed_dev *cdev);
455 * @brief Notify MFW about the change in base device properties
459 * @param client - qed client type
461 * @return int - 0 - operation was successful.
463 int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
464 struct qed_ptt *p_ptt,
465 enum qed_ov_client client);
468 * @brief Notify MFW about the driver state
472 * @param drv_state - Driver state
474 * @return int - 0 - operation was successful.
476 int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
477 struct qed_ptt *p_ptt,
478 enum qed_ov_driver_state drv_state);
481 * @brief Send MTU size to MFW
485 * @param mtu - MTU size
487 * @return int - 0 - operation was successful.
489 int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
490 struct qed_ptt *p_ptt, u16 mtu);
493 * @brief Send MAC address to MFW
497 * @param mac - MAC address
499 * @return int - 0 - operation was successful.
501 int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
502 struct qed_ptt *p_ptt, u8 *mac);
505 * @brief Send WOL mode to MFW
509 * @param wol - WOL mode
511 * @return int - 0 - operation was successful.
513 int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
514 struct qed_ptt *p_ptt,
515 enum qed_ov_wol wol);
518 * @brief Set LED status
522 * @param mode - LED mode
524 * @return int - 0 - operation was successful.
526 int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
527 struct qed_ptt *p_ptt,
528 enum qed_led_mode mode);
531 * @brief Read from nvm
534 * @param addr - nvm offset
535 * @param p_buf - nvm read buffer
536 * @param len - buffer len
538 * @return int - 0 - operation was successful.
540 int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
543 * @brief Write to nvm
546 * @param addr - nvm offset
547 * @param cmd - nvm command
548 * @param p_buf - nvm write buffer
549 * @param len - buffer len
551 * @return int - 0 - operation was successful.
553 int qed_mcp_nvm_write(struct qed_dev *cdev,
554 u32 cmd, u32 addr, u8 *p_buf, u32 len);
557 * @brief Check latest response
560 * @param p_buf - nvm write buffer
562 * @return int - 0 - operation was successful.
564 int qed_mcp_nvm_resp(struct qed_dev *cdev, u8 *p_buf);
566 struct qed_nvm_image_att {
572 * @brief Allows reading a whole nvram image
575 * @param image_id - image to get attributes for
576 * @param p_image_att - image attributes structure into which to fill data
578 * @return int - 0 - operation was successful.
581 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
582 enum qed_nvm_images image_id,
583 struct qed_nvm_image_att *p_image_att);
586 * @brief Allows reading a whole nvram image
589 * @param image_id - image requested for reading
590 * @param p_buffer - allocated buffer into which to fill data
591 * @param buffer_len - length of the allocated buffer.
593 * @return 0 iff p_buffer now contains the nvram image.
595 int qed_mcp_get_nvm_image(struct qed_hwfn *p_hwfn,
596 enum qed_nvm_images image_id,
597 u8 *p_buffer, u32 buffer_len);
600 * @brief Bist register test
602 * @param p_hwfn - hw function
603 * @param p_ptt - PTT required for register access
605 * @return int - 0 - operation was successful.
607 int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
608 struct qed_ptt *p_ptt);
611 * @brief Bist clock test
613 * @param p_hwfn - hw function
614 * @param p_ptt - PTT required for register access
616 * @return int - 0 - operation was successful.
618 int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
619 struct qed_ptt *p_ptt);
622 * @brief Bist nvm test - get number of images
624 * @param p_hwfn - hw function
625 * @param p_ptt - PTT required for register access
626 * @param num_images - number of images if operation was
627 * successful. 0 if not.
629 * @return int - 0 - operation was successful.
631 int qed_mcp_bist_nvm_get_num_images(struct qed_hwfn *p_hwfn,
632 struct qed_ptt *p_ptt,
636 * @brief Bist nvm test - get image attributes by index
638 * @param p_hwfn - hw function
639 * @param p_ptt - PTT required for register access
640 * @param p_image_att - Attributes of image
641 * @param image_index - Index of image to get information for
643 * @return int - 0 - operation was successful.
645 int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
646 struct qed_ptt *p_ptt,
647 struct bist_nvm_image_att *p_image_att,
651 * @brief - Processes the TLV request from MFW i.e., get the required TLV info
652 * from the qed client and send it to the MFW.
657 * @param return 0 upon success.
659 int qed_mfw_process_tlv_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
662 * @brief Send raw debug data to the MFW
666 * @param p_buf - raw debug data buffer
667 * @param size - buffer size
670 qed_mcp_send_raw_debug_data(struct qed_hwfn *p_hwfn,
671 struct qed_ptt *p_ptt, u8 *p_buf, u32 size);
673 /* Using hwfn number (and not pf_num) is required since in CMT mode,
674 * same pf_num may be used by two different hwfn
675 * TODO - this shouldn't really be in .h file, but until all fields
676 * required during hw-init will be placed in their correct place in shmem
677 * we need it in qed_dev.c [for readin the nvram reflection in shmem].
679 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
681 ((p_hwfn)->abs_pf_id & 1) << 3) : \
683 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
685 struct qed_mcp_info {
686 /* List for mailbox commands which were sent and wait for a response */
687 struct list_head cmd_list;
689 /* Spinlock used for protecting the access to the mailbox commands list
690 * and the sending of the commands.
694 /* Flag to indicate whether sending a MFW mailbox command is blocked */
697 /* Spinlock used for syncing SW link-changes and link-changes
698 * originating from attention context.
700 spinlock_t link_lock;
708 struct qed_mcp_link_params link_input;
709 struct qed_mcp_link_state link_output;
710 struct qed_mcp_link_capabilities link_capabilities;
711 struct qed_mcp_function_info func_info;
717 /* Capabilties negotiated with the MFW */
720 /* S/N for debug data mailbox commands */
721 atomic_t dbg_data_seq;
724 struct qed_mcp_mb_params {
734 #define QED_MB_FLAG_CAN_SLEEP (0x1 << 0)
735 #define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
736 #define QED_MB_FLAGS_IS_SET(params, flag) \
737 ({ typeof(params) __params = (params); \
738 (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
741 struct qed_drv_tlv_hdr {
743 u8 tlv_length; /* In dwords - not including this header */
745 #define QED_DRV_TLV_FLAGS_CHANGED 0x01
750 * @brief Initialize the interface with the MCP
752 * @param p_hwfn - HW func
753 * @param p_ptt - PTT required for register access
757 int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
758 struct qed_ptt *p_ptt);
761 * @brief Initialize the port interface with the MCP
765 * Can only be called after `num_ports_in_engines' is set
767 void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
768 struct qed_ptt *p_ptt);
770 * @brief Releases resources allocated during the init process.
772 * @param p_hwfn - HW func
773 * @param p_ptt - PTT required for register access
778 int qed_mcp_free(struct qed_hwfn *p_hwfn);
781 * @brief This function is called from the DPC context. After
782 * pointing PTT to the mfw mb, check for events sent by the MCP
783 * to the driver and ack them. In case a critical event
784 * detected, it will be handled here, otherwise the work will be
785 * queued to a sleepable work-queue.
787 * @param p_hwfn - HW function
788 * @param p_ptt - PTT required for register access
789 * @return int - 0 - operation
792 int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
793 struct qed_ptt *p_ptt);
800 struct qed_load_req_params {
802 enum qed_drv_role drv_role;
804 bool avoid_eng_reset;
805 enum qed_override_force_load override_force_load;
812 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
813 * returns whether this PF is the first on the engine/port or function.
819 * @return int - 0 - Operation was successful.
821 int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
822 struct qed_ptt *p_ptt,
823 struct qed_load_req_params *p_params);
826 * @brief Sends a LOAD_DONE message to the MFW
831 * @return int - 0 - Operation was successful.
833 int qed_mcp_load_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
836 * @brief Sends a UNLOAD_REQ message to the MFW
841 * @return int - 0 - Operation was successful.
843 int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
846 * @brief Sends a UNLOAD_DONE message to the MFW
851 * @return int - 0 - Operation was successful.
853 int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
856 * @brief Read the MFW mailbox into Current buffer.
861 void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
862 struct qed_ptt *p_ptt);
865 * @brief Ack to mfw that driver finished FLR process for VFs
869 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
871 * @param return int - 0 upon success.
873 int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
874 struct qed_ptt *p_ptt, u32 *vfs_to_ack);
877 * @brief - calls during init to read shmem of all function-related info.
881 * @param return 0 upon success.
883 int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
884 struct qed_ptt *p_ptt);
887 * @brief - Reset the MCP using mailbox command.
892 * @param return 0 upon success.
894 int qed_mcp_reset(struct qed_hwfn *p_hwfn,
895 struct qed_ptt *p_ptt);
898 * @brief - Sends an NVM read command request to the MFW to get
903 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
904 * DRV_MSG_CODE_NVM_READ_NVRAM commands
905 * @param param - [0:23] - Offset [24:31] - Size
906 * @param o_mcp_resp - MCP response
907 * @param o_mcp_param - MCP response param
908 * @param o_txn_size - Buffer size output
909 * @param o_buf - Pointer to the buffer returned by the MFW.
911 * @param return 0 upon success.
913 int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
914 struct qed_ptt *p_ptt,
918 u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf);
921 * @brief Read from sfp
923 * @param p_hwfn - hw function
924 * @param p_ptt - PTT required for register access
925 * @param port - transceiver port
926 * @param addr - I2C address
927 * @param offset - offset in sfp
928 * @param len - buffer length
929 * @param p_buf - buffer to read into
931 * @return int - 0 - operation was successful.
933 int qed_mcp_phy_sfp_read(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
934 u32 port, u32 addr, u32 offset, u32 len, u8 *p_buf);
937 * @brief indicates whether the MFW objects [under mcp_info] are accessible
941 * @return true iff MFW is running and mcp_info is initialized
943 bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
946 * @brief request MFW to configure MSI-X for a VF
950 * @param vf_id - absolute inside engine
951 * @param num_sbs - number of entries to request
955 int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
956 struct qed_ptt *p_ptt, u8 vf_id, u8 num);
959 * @brief - Halt the MCP.
964 * @param return 0 upon success.
966 int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
969 * @brief - Wake up the MCP.
974 * @param return 0 upon success.
976 int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
978 int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
979 int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
980 int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
981 struct qed_ptt *p_ptt,
982 struct qed_mcp_link_state *p_link,
984 int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
985 struct qed_ptt *p_ptt,
986 struct qed_mcp_link_state *p_link,
989 int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
990 struct qed_ptt *p_ptt, u32 mask_parities);
992 /* @brief - Gets the mdump retained data from the MFW.
996 * @param p_mdump_retain
998 * @param return 0 upon success.
1001 qed_mcp_mdump_get_retain(struct qed_hwfn *p_hwfn,
1002 struct qed_ptt *p_ptt,
1003 struct mdump_retain_data_stc *p_mdump_retain);
1006 * @brief - Sets the MFW's max value for the given resource
1011 * @param resc_max_val
1014 * @return int - 0 - operation was successful.
1017 qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
1018 struct qed_ptt *p_ptt,
1019 enum qed_resources res_id,
1020 u32 resc_max_val, u32 *p_mcp_resp);
1023 * @brief - Gets the MFW allocation info for the given resource
1030 * @param p_resc_start
1032 * @return int - 0 - operation was successful.
1035 qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
1036 struct qed_ptt *p_ptt,
1037 enum qed_resources res_id,
1038 u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start);
1041 * @brief Send eswitch mode to MFW
1045 * @param eswitch - eswitch mode
1047 * @return int - 0 - operation was successful.
1049 int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
1050 struct qed_ptt *p_ptt,
1051 enum qed_ov_eswitch eswitch);
1053 #define QED_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP
1054 #define QED_MCP_RESC_LOCK_MAX_VAL 31
1056 enum qed_resc_lock {
1057 QED_RESC_LOCK_DBG_DUMP = QED_MCP_RESC_LOCK_MIN_VAL,
1058 QED_RESC_LOCK_PTP_PORT0,
1059 QED_RESC_LOCK_PTP_PORT1,
1060 QED_RESC_LOCK_PTP_PORT2,
1061 QED_RESC_LOCK_PTP_PORT3,
1062 QED_RESC_LOCK_RESC_ALLOC = QED_MCP_RESC_LOCK_MAX_VAL,
1063 QED_RESC_LOCK_RESC_INVALID
1067 * @brief - Initiates PF FLR
1072 * @return int - 0 - operation was successful.
1074 int qed_mcp_initiate_pf_flr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1075 struct qed_resc_lock_params {
1076 /* Resource number [valid values are 0..31] */
1079 /* Lock timeout value in seconds [default, none or 1..254] */
1081 #define QED_MCP_RESC_LOCK_TO_DEFAULT 0
1082 #define QED_MCP_RESC_LOCK_TO_NONE 255
1084 /* Number of times to retry locking */
1086 #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT 10
1088 /* The interval in usec between retries */
1090 #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT 10000
1092 /* Use sleep or delay between retries */
1093 bool sleep_b4_retry;
1095 /* Will be set as true if the resource is free and granted */
1098 /* Will be filled with the resource owner.
1099 * [0..15 = PF0-15, 16 = MFW]
1105 * @brief Acquires MFW generic resource lock
1111 * @return int - 0 - operation was successful.
1114 qed_mcp_resc_lock(struct qed_hwfn *p_hwfn,
1115 struct qed_ptt *p_ptt, struct qed_resc_lock_params *p_params);
1117 struct qed_resc_unlock_params {
1118 /* Resource number [valid values are 0..31] */
1121 /* Allow to release a resource even if belongs to another PF */
1124 /* Will be set as true if the resource is released */
1129 * @brief Releases MFW generic resource lock
1135 * @return int - 0 - operation was successful.
1138 qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
1139 struct qed_ptt *p_ptt,
1140 struct qed_resc_unlock_params *p_params);
1143 * @brief - default initialization for lock/unlock resource structs
1145 * @param p_lock - lock params struct to be initialized; Can be NULL
1146 * @param p_unlock - unlock params struct to be initialized; Can be NULL
1147 * @param resource - the requested resource
1148 * @paral b_is_permanent - disable retries & aging when set
1150 void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params *p_lock,
1151 struct qed_resc_unlock_params *p_unlock,
1153 resource, bool b_is_permanent);
1156 * @brief - Return whether management firmware support smart AN
1160 * @return bool - true if feature is supported.
1162 bool qed_mcp_is_smart_an_supported(struct qed_hwfn *p_hwfn);
1165 * @brief Learn of supported MFW features; To be done during early init
1170 int qed_mcp_get_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1173 * @brief Inform MFW of set of features supported by driver. Should be done
1174 * inside the content of the LOAD_REQ.
1179 int qed_mcp_set_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1182 * @brief Read ufp config from the shared memory.
1187 void qed_mcp_read_ufp_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1190 * @brief Populate the nvm info shadow in the given hardware function
1194 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
1197 * @brief Delete nvm info shadow in the given hardware function
1201 void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn);
1204 * @brief Get the engine affinity configuration.
1209 int qed_mcp_get_engine_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1212 * @brief Get the PPFID bitmap.
1217 int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1220 * @brief Get NVM config attribute value.
1230 int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1231 u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
1235 * @brief Set NVM config attribute value.
1245 int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1246 u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,