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
{
21 u32 advertised_speeds
;
22 #define QED_EXT_SPEED_MASK_RES 0x1
23 #define QED_EXT_SPEED_MASK_1G 0x2
24 #define QED_EXT_SPEED_MASK_10G 0x4
25 #define QED_EXT_SPEED_MASK_20G 0x8
26 #define QED_EXT_SPEED_MASK_25G 0x10
27 #define QED_EXT_SPEED_MASK_40G 0x20
28 #define QED_EXT_SPEED_MASK_50G_R 0x40
29 #define QED_EXT_SPEED_MASK_50G_R2 0x80
30 #define QED_EXT_SPEED_MASK_100G_R2 0x100
31 #define QED_EXT_SPEED_MASK_100G_R4 0x200
32 #define QED_EXT_SPEED_MASK_100G_P4 0x400
34 u32 forced_speed
; /* In Mb/s */
35 #define QED_EXT_SPEED_1G 0x1
36 #define QED_EXT_SPEED_10G 0x2
37 #define QED_EXT_SPEED_20G 0x4
38 #define QED_EXT_SPEED_25G 0x8
39 #define QED_EXT_SPEED_40G 0x10
40 #define QED_EXT_SPEED_50G_R 0x20
41 #define QED_EXT_SPEED_50G_R2 0x40
42 #define QED_EXT_SPEED_100G_R2 0x80
43 #define QED_EXT_SPEED_100G_R4 0x100
44 #define QED_EXT_SPEED_100G_P4 0x200
47 struct qed_mcp_link_pause_params
{
53 enum qed_mcp_eee_mode
{
56 QED_MCP_EEE_UNSUPPORTED
59 struct qed_mcp_link_params
{
60 struct qed_mcp_link_speed_params speed
;
61 struct qed_mcp_link_pause_params pause
;
63 struct qed_link_eee_params eee
;
66 struct qed_mcp_link_speed_params ext_speed
;
70 struct qed_mcp_link_capabilities
{
71 u32 speed_capabilities
;
72 bool default_speed_autoneg
;
74 enum qed_mcp_eee_mode default_eee
;
78 u32 default_ext_speed_caps
;
79 u32 default_ext_autoneg
;
80 u32 default_ext_speed
;
84 struct qed_mcp_link_state
{
88 /* Actual link speed in Mb/s */
91 /* PF max speed in Mb/s, deduced from line_speed
92 * according to PF max bandwidth configuration.
99 bool parallel_detection
;
102 u32 partner_adv_speed
;
103 #define QED_LINK_PARTNER_SPEED_1G_HD BIT(0)
104 #define QED_LINK_PARTNER_SPEED_1G_FD BIT(1)
105 #define QED_LINK_PARTNER_SPEED_10G BIT(2)
106 #define QED_LINK_PARTNER_SPEED_20G BIT(3)
107 #define QED_LINK_PARTNER_SPEED_25G BIT(4)
108 #define QED_LINK_PARTNER_SPEED_40G BIT(5)
109 #define QED_LINK_PARTNER_SPEED_50G BIT(6)
110 #define QED_LINK_PARTNER_SPEED_100G BIT(7)
112 bool partner_tx_flow_ctrl_en
;
113 bool partner_rx_flow_ctrl_en
;
115 u8 partner_adv_pause
;
116 #define QED_LINK_PARTNER_SYMMETRIC_PAUSE 0x1
117 #define QED_LINK_PARTNER_ASYMMETRIC_PAUSE 0x2
118 #define QED_LINK_PARTNER_BOTH_PAUSE 0x3
128 struct qed_mcp_function_info
{
131 enum qed_pci_personality protocol
;
141 #define QED_MCP_VLAN_UNSET (0xffff)
147 struct qed_mcp_nvm_common
{
154 struct qed_mcp_drv_version
{
156 u8 name
[MCP_DRV_VER_STR_SIZE
- 4];
159 struct qed_mcp_lan_stats
{
165 struct qed_mcp_fcoe_stats
{
172 struct qed_mcp_iscsi_stats
{
179 struct qed_mcp_rdma_stats
{
186 enum qed_mcp_protocol_type
{
193 union qed_mcp_protocol_stats
{
194 struct qed_mcp_lan_stats lan_stats
;
195 struct qed_mcp_fcoe_stats fcoe_stats
;
196 struct qed_mcp_iscsi_stats iscsi_stats
;
197 struct qed_mcp_rdma_stats rdma_stats
;
200 enum qed_ov_eswitch
{
209 QED_OV_CLIENT_VENDOR_SPEC
212 enum qed_ov_driver_state
{
213 QED_OV_DRIVER_STATE_NOT_LOADED
,
214 QED_OV_DRIVER_STATE_DISABLED
,
215 QED_OV_DRIVER_STATE_ACTIVE
224 enum qed_mfw_tlv_type
{
225 QED_MFW_TLV_GENERIC
= 0x1, /* Core driver TLVs */
226 QED_MFW_TLV_ETH
= 0x2, /* L2 driver TLVs */
227 QED_MFW_TLV_FCOE
= 0x4, /* FCoE protocol TLVs */
228 QED_MFW_TLV_ISCSI
= 0x8, /* SCSI protocol TLVs */
229 QED_MFW_TLV_MAX
= 0x16,
232 struct qed_mfw_tlv_generic
{
233 #define QED_MFW_TLV_FLAGS_SIZE 2
235 u8 ipv4_csum_offload
;
240 #define QED_MFW_TLV_MAC_COUNT 3
241 /* First entry for primary MAC, 2 secondary MACs possible */
242 u8 mac
[QED_MFW_TLV_MAC_COUNT
][6];
243 bool mac_set
[QED_MFW_TLV_MAC_COUNT
];
255 union qed_mfw_tlv_data
{
256 struct qed_mfw_tlv_generic generic
;
257 struct qed_mfw_tlv_eth eth
;
258 struct qed_mfw_tlv_fcoe fcoe
;
259 struct qed_mfw_tlv_iscsi iscsi
;
262 #define QED_NVM_CFG_OPTION_ALL BIT(0)
263 #define QED_NVM_CFG_OPTION_INIT BIT(1)
264 #define QED_NVM_CFG_OPTION_COMMIT BIT(2)
265 #define QED_NVM_CFG_OPTION_FREE BIT(3)
266 #define QED_NVM_CFG_OPTION_ENTITY_SEL BIT(4)
269 * @brief - returns the link params of the hw function
273 * @returns pointer to link params
275 struct qed_mcp_link_params
*qed_mcp_get_link_params(struct qed_hwfn
*);
278 * @brief - return the link state of the hw function
282 * @returns pointer to link state
284 struct qed_mcp_link_state
*qed_mcp_get_link_state(struct qed_hwfn
*);
287 * @brief - return the link capabilities of the hw function
291 * @returns pointer to link capabilities
293 struct qed_mcp_link_capabilities
294 *qed_mcp_get_link_capabilities(struct qed_hwfn
*p_hwfn
);
297 * @brief Request the MFW to set the the link according to 'link_input'.
301 * @param b_up - raise link if `true'. Reset link if `false'.
305 int qed_mcp_set_link(struct qed_hwfn
*p_hwfn
,
306 struct qed_ptt
*p_ptt
,
310 * @brief Get the management firmware version value
314 * @param p_mfw_ver - mfw version value
315 * @param p_running_bundle_id - image id in nvram; Optional.
317 * @return int - 0 - operation was successful.
319 int qed_mcp_get_mfw_ver(struct qed_hwfn
*p_hwfn
,
320 struct qed_ptt
*p_ptt
,
321 u32
*p_mfw_ver
, u32
*p_running_bundle_id
);
324 * @brief Get the MBI version value
328 * @param p_mbi_ver - A pointer to a variable to be filled with the MBI version.
330 * @return int - 0 - operation was successful.
332 int qed_mcp_get_mbi_ver(struct qed_hwfn
*p_hwfn
,
333 struct qed_ptt
*p_ptt
, u32
*p_mbi_ver
);
336 * @brief Get media type value of the port.
338 * @param cdev - qed dev pointer
340 * @param mfw_ver - media type value
343 * 0 - Operation was successul.
344 * -EBUSY - Operation failed
346 int qed_mcp_get_media_type(struct qed_hwfn
*p_hwfn
,
347 struct qed_ptt
*p_ptt
, u32
*media_type
);
350 * @brief Get transceiver data of the port.
352 * @param cdev - qed dev pointer
354 * @param p_transceiver_state - transceiver state.
355 * @param p_transceiver_type - media type value
358 * 0 - Operation was successful.
359 * -EBUSY - Operation failed
361 int qed_mcp_get_transceiver_data(struct qed_hwfn
*p_hwfn
,
362 struct qed_ptt
*p_ptt
,
363 u32
*p_transceiver_state
,
364 u32
*p_tranceiver_type
);
367 * @brief Get transceiver supported speed mask.
369 * @param cdev - qed dev pointer
371 * @param p_speed_mask - Bit mask of all supported speeds.
374 * 0 - Operation was successful.
375 * -EBUSY - Operation failed
378 int qed_mcp_trans_speed_mask(struct qed_hwfn
*p_hwfn
,
379 struct qed_ptt
*p_ptt
, u32
*p_speed_mask
);
382 * @brief Get board configuration.
384 * @param cdev - qed dev pointer
386 * @param p_board_config - Board config.
389 * 0 - Operation was successful.
390 * -EBUSY - Operation failed
392 int qed_mcp_get_board_config(struct qed_hwfn
*p_hwfn
,
393 struct qed_ptt
*p_ptt
, u32
*p_board_config
);
396 * @brief General function for sending commands to the MCP
397 * mailbox. It acquire mutex lock for the entire
398 * operation, from sending the request until the MCP
399 * response. Waiting for MCP response will be checked up
400 * to 5 seconds every 5ms.
402 * @param p_hwfn - hw function
403 * @param p_ptt - PTT required for register access
404 * @param cmd - command to be sent to the MCP.
405 * @param param - Optional param
406 * @param o_mcp_resp - The MCP response code (exclude sequence).
407 * @param o_mcp_param- Optional parameter provided by the MCP
409 * @return int - 0 - operation
412 int qed_mcp_cmd(struct qed_hwfn
*p_hwfn
,
413 struct qed_ptt
*p_ptt
,
420 * @brief - drains the nig, allowing completion to pass in case of pauses.
421 * (Should be called only from sleepable context)
426 int qed_mcp_drain(struct qed_hwfn
*p_hwfn
,
427 struct qed_ptt
*p_ptt
);
430 * @brief Get the flash size value
434 * @param p_flash_size - flash size in bytes to be filled.
436 * @return int - 0 - operation was successul.
438 int qed_mcp_get_flash_size(struct qed_hwfn
*p_hwfn
,
439 struct qed_ptt
*p_ptt
,
443 * @brief Send driver version to MFW
447 * @param version - Version value
448 * @param name - Protocol driver name
450 * @return int - 0 - operation was successul.
453 qed_mcp_send_drv_version(struct qed_hwfn
*p_hwfn
,
454 struct qed_ptt
*p_ptt
,
455 struct qed_mcp_drv_version
*p_ver
);
458 * @brief Read the MFW process kill counter
465 u32
qed_get_process_kill_counter(struct qed_hwfn
*p_hwfn
,
466 struct qed_ptt
*p_ptt
);
469 * @brief Trigger a recovery process
476 int qed_start_recovery_process(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
479 * @brief A recovery handler must call this function as its first step.
480 * It is assumed that the handler is not run from an interrupt context.
487 int qed_recovery_prolog(struct qed_dev
*cdev
);
490 * @brief Notify MFW about the change in base device properties
494 * @param client - qed client type
496 * @return int - 0 - operation was successful.
498 int qed_mcp_ov_update_current_config(struct qed_hwfn
*p_hwfn
,
499 struct qed_ptt
*p_ptt
,
500 enum qed_ov_client client
);
503 * @brief Notify MFW about the driver state
507 * @param drv_state - Driver state
509 * @return int - 0 - operation was successful.
511 int qed_mcp_ov_update_driver_state(struct qed_hwfn
*p_hwfn
,
512 struct qed_ptt
*p_ptt
,
513 enum qed_ov_driver_state drv_state
);
516 * @brief Send MTU size to MFW
520 * @param mtu - MTU size
522 * @return int - 0 - operation was successful.
524 int qed_mcp_ov_update_mtu(struct qed_hwfn
*p_hwfn
,
525 struct qed_ptt
*p_ptt
, u16 mtu
);
528 * @brief Send MAC address to MFW
532 * @param mac - MAC address
534 * @return int - 0 - operation was successful.
536 int qed_mcp_ov_update_mac(struct qed_hwfn
*p_hwfn
,
537 struct qed_ptt
*p_ptt
, u8
*mac
);
540 * @brief Send WOL mode to MFW
544 * @param wol - WOL mode
546 * @return int - 0 - operation was successful.
548 int qed_mcp_ov_update_wol(struct qed_hwfn
*p_hwfn
,
549 struct qed_ptt
*p_ptt
,
550 enum qed_ov_wol wol
);
553 * @brief Set LED status
557 * @param mode - LED mode
559 * @return int - 0 - operation was successful.
561 int qed_mcp_set_led(struct qed_hwfn
*p_hwfn
,
562 struct qed_ptt
*p_ptt
,
563 enum qed_led_mode mode
);
566 * @brief Read from nvm
569 * @param addr - nvm offset
570 * @param p_buf - nvm read buffer
571 * @param len - buffer len
573 * @return int - 0 - operation was successful.
575 int qed_mcp_nvm_read(struct qed_dev
*cdev
, u32 addr
, u8
*p_buf
, u32 len
);
578 * @brief Write to nvm
581 * @param addr - nvm offset
582 * @param cmd - nvm command
583 * @param p_buf - nvm write buffer
584 * @param len - buffer len
586 * @return int - 0 - operation was successful.
588 int qed_mcp_nvm_write(struct qed_dev
*cdev
,
589 u32 cmd
, u32 addr
, u8
*p_buf
, u32 len
);
592 * @brief Check latest response
595 * @param p_buf - nvm write buffer
597 * @return int - 0 - operation was successful.
599 int qed_mcp_nvm_resp(struct qed_dev
*cdev
, u8
*p_buf
);
601 struct qed_nvm_image_att
{
607 * @brief Allows reading a whole nvram image
610 * @param image_id - image to get attributes for
611 * @param p_image_att - image attributes structure into which to fill data
613 * @return int - 0 - operation was successful.
616 qed_mcp_get_nvm_image_att(struct qed_hwfn
*p_hwfn
,
617 enum qed_nvm_images image_id
,
618 struct qed_nvm_image_att
*p_image_att
);
621 * @brief Allows reading a whole nvram image
624 * @param image_id - image requested for reading
625 * @param p_buffer - allocated buffer into which to fill data
626 * @param buffer_len - length of the allocated buffer.
628 * @return 0 iff p_buffer now contains the nvram image.
630 int qed_mcp_get_nvm_image(struct qed_hwfn
*p_hwfn
,
631 enum qed_nvm_images image_id
,
632 u8
*p_buffer
, u32 buffer_len
);
635 * @brief Bist register test
637 * @param p_hwfn - hw function
638 * @param p_ptt - PTT required for register access
640 * @return int - 0 - operation was successful.
642 int qed_mcp_bist_register_test(struct qed_hwfn
*p_hwfn
,
643 struct qed_ptt
*p_ptt
);
646 * @brief Bist clock test
648 * @param p_hwfn - hw function
649 * @param p_ptt - PTT required for register access
651 * @return int - 0 - operation was successful.
653 int qed_mcp_bist_clock_test(struct qed_hwfn
*p_hwfn
,
654 struct qed_ptt
*p_ptt
);
657 * @brief Bist nvm test - get number of images
659 * @param p_hwfn - hw function
660 * @param p_ptt - PTT required for register access
661 * @param num_images - number of images if operation was
662 * successful. 0 if not.
664 * @return int - 0 - operation was successful.
666 int qed_mcp_bist_nvm_get_num_images(struct qed_hwfn
*p_hwfn
,
667 struct qed_ptt
*p_ptt
,
671 * @brief Bist nvm test - get image attributes by index
673 * @param p_hwfn - hw function
674 * @param p_ptt - PTT required for register access
675 * @param p_image_att - Attributes of image
676 * @param image_index - Index of image to get information for
678 * @return int - 0 - operation was successful.
680 int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn
*p_hwfn
,
681 struct qed_ptt
*p_ptt
,
682 struct bist_nvm_image_att
*p_image_att
,
686 * @brief - Processes the TLV request from MFW i.e., get the required TLV info
687 * from the qed client and send it to the MFW.
692 * @param return 0 upon success.
694 int qed_mfw_process_tlv_req(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
697 * @brief Send raw debug data to the MFW
701 * @param p_buf - raw debug data buffer
702 * @param size - buffer size
705 qed_mcp_send_raw_debug_data(struct qed_hwfn
*p_hwfn
,
706 struct qed_ptt
*p_ptt
, u8
*p_buf
, u32 size
);
708 /* Using hwfn number (and not pf_num) is required since in CMT mode,
709 * same pf_num may be used by two different hwfn
710 * TODO - this shouldn't really be in .h file, but until all fields
711 * required during hw-init will be placed in their correct place in shmem
712 * we need it in qed_dev.c [for readin the nvram reflection in shmem].
714 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
716 ((p_hwfn)->abs_pf_id & 1) << 3) : \
718 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
720 struct qed_mcp_info
{
721 /* List for mailbox commands which were sent and wait for a response */
722 struct list_head cmd_list
;
724 /* Spinlock used for protecting the access to the mailbox commands list
725 * and the sending of the commands.
729 /* Flag to indicate whether sending a MFW mailbox command is blocked */
732 /* Spinlock used for syncing SW link-changes and link-changes
733 * originating from attention context.
735 spinlock_t link_lock
;
743 struct qed_mcp_link_params link_input
;
744 struct qed_mcp_link_state link_output
;
745 struct qed_mcp_link_capabilities link_capabilities
;
746 struct qed_mcp_function_info func_info
;
752 /* Capabilties negotiated with the MFW */
755 /* S/N for debug data mailbox commands */
756 atomic_t dbg_data_seq
;
759 struct qed_mcp_mb_params
{
769 #define QED_MB_FLAG_CAN_SLEEP (0x1 << 0)
770 #define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
771 #define QED_MB_FLAGS_IS_SET(params, flag) \
772 ({ typeof(params) __params = (params); \
773 (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
776 struct qed_drv_tlv_hdr
{
778 u8 tlv_length
; /* In dwords - not including this header */
780 #define QED_DRV_TLV_FLAGS_CHANGED 0x01
785 * qed_mcp_is_ext_speed_supported() - Check if management firmware supports
787 * @p_hwfn: HW device data.
789 * Return: true if supported, false otherwise.
792 qed_mcp_is_ext_speed_supported(const struct qed_hwfn
*p_hwfn
)
794 return !!(p_hwfn
->mcp_info
->capabilities
&
795 FW_MB_PARAM_FEATURE_SUPPORT_EXT_SPEED_FEC_CONTROL
);
799 * @brief Initialize the interface with the MCP
801 * @param p_hwfn - HW func
802 * @param p_ptt - PTT required for register access
806 int qed_mcp_cmd_init(struct qed_hwfn
*p_hwfn
,
807 struct qed_ptt
*p_ptt
);
810 * @brief Initialize the port interface with the MCP
814 * Can only be called after `num_ports_in_engines' is set
816 void qed_mcp_cmd_port_init(struct qed_hwfn
*p_hwfn
,
817 struct qed_ptt
*p_ptt
);
819 * @brief Releases resources allocated during the init process.
821 * @param p_hwfn - HW func
822 * @param p_ptt - PTT required for register access
827 int qed_mcp_free(struct qed_hwfn
*p_hwfn
);
830 * @brief This function is called from the DPC context. After
831 * pointing PTT to the mfw mb, check for events sent by the MCP
832 * to the driver and ack them. In case a critical event
833 * detected, it will be handled here, otherwise the work will be
834 * queued to a sleepable work-queue.
836 * @param p_hwfn - HW function
837 * @param p_ptt - PTT required for register access
838 * @return int - 0 - operation
841 int qed_mcp_handle_events(struct qed_hwfn
*p_hwfn
,
842 struct qed_ptt
*p_ptt
);
849 struct qed_load_req_params
{
851 enum qed_drv_role drv_role
;
853 bool avoid_eng_reset
;
854 enum qed_override_force_load override_force_load
;
861 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
862 * returns whether this PF is the first on the engine/port or function.
868 * @return int - 0 - Operation was successful.
870 int qed_mcp_load_req(struct qed_hwfn
*p_hwfn
,
871 struct qed_ptt
*p_ptt
,
872 struct qed_load_req_params
*p_params
);
875 * @brief Sends a LOAD_DONE message to the MFW
880 * @return int - 0 - Operation was successful.
882 int qed_mcp_load_done(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
885 * @brief Sends a UNLOAD_REQ message to the MFW
890 * @return int - 0 - Operation was successful.
892 int qed_mcp_unload_req(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
895 * @brief Sends a UNLOAD_DONE message to the MFW
900 * @return int - 0 - Operation was successful.
902 int qed_mcp_unload_done(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
905 * @brief Read the MFW mailbox into Current buffer.
910 void qed_mcp_read_mb(struct qed_hwfn
*p_hwfn
,
911 struct qed_ptt
*p_ptt
);
914 * @brief Ack to mfw that driver finished FLR process for VFs
918 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
920 * @param return int - 0 upon success.
922 int qed_mcp_ack_vf_flr(struct qed_hwfn
*p_hwfn
,
923 struct qed_ptt
*p_ptt
, u32
*vfs_to_ack
);
926 * @brief - calls during init to read shmem of all function-related info.
930 * @param return 0 upon success.
932 int qed_mcp_fill_shmem_func_info(struct qed_hwfn
*p_hwfn
,
933 struct qed_ptt
*p_ptt
);
936 * @brief - Reset the MCP using mailbox command.
941 * @param return 0 upon success.
943 int qed_mcp_reset(struct qed_hwfn
*p_hwfn
,
944 struct qed_ptt
*p_ptt
);
947 * @brief - Sends an NVM read command request to the MFW to get
952 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
953 * DRV_MSG_CODE_NVM_READ_NVRAM commands
954 * @param param - [0:23] - Offset [24:31] - Size
955 * @param o_mcp_resp - MCP response
956 * @param o_mcp_param - MCP response param
957 * @param o_txn_size - Buffer size output
958 * @param o_buf - Pointer to the buffer returned by the MFW.
960 * @param return 0 upon success.
962 int qed_mcp_nvm_rd_cmd(struct qed_hwfn
*p_hwfn
,
963 struct qed_ptt
*p_ptt
,
967 u32
*o_mcp_param
, u32
*o_txn_size
, u32
*o_buf
);
970 * @brief Read from sfp
972 * @param p_hwfn - hw function
973 * @param p_ptt - PTT required for register access
974 * @param port - transceiver port
975 * @param addr - I2C address
976 * @param offset - offset in sfp
977 * @param len - buffer length
978 * @param p_buf - buffer to read into
980 * @return int - 0 - operation was successful.
982 int qed_mcp_phy_sfp_read(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
983 u32 port
, u32 addr
, u32 offset
, u32 len
, u8
*p_buf
);
986 * @brief indicates whether the MFW objects [under mcp_info] are accessible
990 * @return true iff MFW is running and mcp_info is initialized
992 bool qed_mcp_is_init(struct qed_hwfn
*p_hwfn
);
995 * @brief request MFW to configure MSI-X for a VF
999 * @param vf_id - absolute inside engine
1000 * @param num_sbs - number of entries to request
1004 int qed_mcp_config_vf_msix(struct qed_hwfn
*p_hwfn
,
1005 struct qed_ptt
*p_ptt
, u8 vf_id
, u8 num
);
1008 * @brief - Halt the MCP.
1013 * @param return 0 upon success.
1015 int qed_mcp_halt(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1018 * @brief - Wake up the MCP.
1023 * @param return 0 upon success.
1025 int qed_mcp_resume(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1027 int qed_configure_pf_min_bandwidth(struct qed_dev
*cdev
, u8 min_bw
);
1028 int qed_configure_pf_max_bandwidth(struct qed_dev
*cdev
, u8 max_bw
);
1029 int __qed_configure_pf_max_bandwidth(struct qed_hwfn
*p_hwfn
,
1030 struct qed_ptt
*p_ptt
,
1031 struct qed_mcp_link_state
*p_link
,
1033 int __qed_configure_pf_min_bandwidth(struct qed_hwfn
*p_hwfn
,
1034 struct qed_ptt
*p_ptt
,
1035 struct qed_mcp_link_state
*p_link
,
1038 int qed_mcp_mask_parities(struct qed_hwfn
*p_hwfn
,
1039 struct qed_ptt
*p_ptt
, u32 mask_parities
);
1041 /* @brief - Gets the mdump retained data from the MFW.
1045 * @param p_mdump_retain
1047 * @param return 0 upon success.
1050 qed_mcp_mdump_get_retain(struct qed_hwfn
*p_hwfn
,
1051 struct qed_ptt
*p_ptt
,
1052 struct mdump_retain_data_stc
*p_mdump_retain
);
1055 * @brief - Sets the MFW's max value for the given resource
1060 * @param resc_max_val
1063 * @return int - 0 - operation was successful.
1066 qed_mcp_set_resc_max_val(struct qed_hwfn
*p_hwfn
,
1067 struct qed_ptt
*p_ptt
,
1068 enum qed_resources res_id
,
1069 u32 resc_max_val
, u32
*p_mcp_resp
);
1072 * @brief - Gets the MFW allocation info for the given resource
1079 * @param p_resc_start
1081 * @return int - 0 - operation was successful.
1084 qed_mcp_get_resc_info(struct qed_hwfn
*p_hwfn
,
1085 struct qed_ptt
*p_ptt
,
1086 enum qed_resources res_id
,
1087 u32
*p_mcp_resp
, u32
*p_resc_num
, u32
*p_resc_start
);
1090 * @brief Send eswitch mode to MFW
1094 * @param eswitch - eswitch mode
1096 * @return int - 0 - operation was successful.
1098 int qed_mcp_ov_update_eswitch(struct qed_hwfn
*p_hwfn
,
1099 struct qed_ptt
*p_ptt
,
1100 enum qed_ov_eswitch eswitch
);
1102 #define QED_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP
1103 #define QED_MCP_RESC_LOCK_MAX_VAL 31
1105 enum qed_resc_lock
{
1106 QED_RESC_LOCK_DBG_DUMP
= QED_MCP_RESC_LOCK_MIN_VAL
,
1107 QED_RESC_LOCK_PTP_PORT0
,
1108 QED_RESC_LOCK_PTP_PORT1
,
1109 QED_RESC_LOCK_PTP_PORT2
,
1110 QED_RESC_LOCK_PTP_PORT3
,
1111 QED_RESC_LOCK_RESC_ALLOC
= QED_MCP_RESC_LOCK_MAX_VAL
,
1112 QED_RESC_LOCK_RESC_INVALID
1116 * @brief - Initiates PF FLR
1121 * @return int - 0 - operation was successful.
1123 int qed_mcp_initiate_pf_flr(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1124 struct qed_resc_lock_params
{
1125 /* Resource number [valid values are 0..31] */
1128 /* Lock timeout value in seconds [default, none or 1..254] */
1130 #define QED_MCP_RESC_LOCK_TO_DEFAULT 0
1131 #define QED_MCP_RESC_LOCK_TO_NONE 255
1133 /* Number of times to retry locking */
1135 #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT 10
1137 /* The interval in usec between retries */
1139 #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT 10000
1141 /* Use sleep or delay between retries */
1142 bool sleep_b4_retry
;
1144 /* Will be set as true if the resource is free and granted */
1147 /* Will be filled with the resource owner.
1148 * [0..15 = PF0-15, 16 = MFW]
1154 * @brief Acquires MFW generic resource lock
1160 * @return int - 0 - operation was successful.
1163 qed_mcp_resc_lock(struct qed_hwfn
*p_hwfn
,
1164 struct qed_ptt
*p_ptt
, struct qed_resc_lock_params
*p_params
);
1166 struct qed_resc_unlock_params
{
1167 /* Resource number [valid values are 0..31] */
1170 /* Allow to release a resource even if belongs to another PF */
1173 /* Will be set as true if the resource is released */
1178 * @brief Releases MFW generic resource lock
1184 * @return int - 0 - operation was successful.
1187 qed_mcp_resc_unlock(struct qed_hwfn
*p_hwfn
,
1188 struct qed_ptt
*p_ptt
,
1189 struct qed_resc_unlock_params
*p_params
);
1192 * @brief - default initialization for lock/unlock resource structs
1194 * @param p_lock - lock params struct to be initialized; Can be NULL
1195 * @param p_unlock - unlock params struct to be initialized; Can be NULL
1196 * @param resource - the requested resource
1197 * @paral b_is_permanent - disable retries & aging when set
1199 void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params
*p_lock
,
1200 struct qed_resc_unlock_params
*p_unlock
,
1202 resource
, bool b_is_permanent
);
1205 * @brief - Return whether management firmware support smart AN
1209 * @return bool - true if feature is supported.
1211 bool qed_mcp_is_smart_an_supported(struct qed_hwfn
*p_hwfn
);
1214 * @brief Learn of supported MFW features; To be done during early init
1219 int qed_mcp_get_capabilities(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1222 * @brief Inform MFW of set of features supported by driver. Should be done
1223 * inside the content of the LOAD_REQ.
1228 int qed_mcp_set_capabilities(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1231 * @brief Read ufp config from the shared memory.
1236 void qed_mcp_read_ufp_config(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1239 * @brief Populate the nvm info shadow in the given hardware function
1243 int qed_mcp_nvm_info_populate(struct qed_hwfn
*p_hwfn
);
1246 * @brief Delete nvm info shadow in the given hardware function
1250 void qed_mcp_nvm_info_free(struct qed_hwfn
*p_hwfn
);
1253 * @brief Get the engine affinity configuration.
1258 int qed_mcp_get_engine_config(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1261 * @brief Get the PPFID bitmap.
1266 int qed_mcp_get_ppfid_bitmap(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
);
1269 * @brief Get NVM config attribute value.
1279 int qed_mcp_nvm_get_cfg(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
1280 u16 option_id
, u8 entity_id
, u16 flags
, u8
*p_buf
,
1284 * @brief Set NVM config attribute value.
1294 int qed_mcp_nvm_set_cfg(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
1295 u16 option_id
, u8 entity_id
, u16 flags
, u8
*p_buf
,