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 * qed_mcp_get_link_params(): Returns the link params of the hw function.
271 * @p_hwfn: HW device data.
273 * Returns: Pointer to link params.
275 struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *p_hwfn);
278 * qed_mcp_get_link_state(): Return the link state of the hw function.
280 * @p_hwfn: HW device data.
282 * Returns: Pointer to link state.
284 struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *p_hwfn);
287 * qed_mcp_get_link_capabilities(): Return the link capabilities of the
290 * @p_hwfn: HW device data.
292 * Returns: Pointer to link capabilities.
294 struct qed_mcp_link_capabilities
295 *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
298 * qed_mcp_set_link(): Request the MFW to set the link according
301 * @p_hwfn: HW device data.
303 * @b_up: Raise link if `true'. Reset link if `false'.
307 int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
308 struct qed_ptt *p_ptt,
312 * qed_mcp_get_mfw_ver(): Get the management firmware version value.
314 * @p_hwfn: HW device data.
316 * @p_mfw_ver: MFW version value.
317 * @p_running_bundle_id: Image id in nvram; Optional.
319 * Return: Int - 0 - operation was successful.
321 int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
322 struct qed_ptt *p_ptt,
323 u32 *p_mfw_ver, u32 *p_running_bundle_id);
326 * qed_mcp_get_mbi_ver(): Get the MBI version value.
328 * @p_hwfn: HW device data.
330 * @p_mbi_ver: A pointer to a variable to be filled with the MBI version.
332 * Return: Int - 0 - operation was successful.
334 int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
335 struct qed_ptt *p_ptt, u32 *p_mbi_ver);
338 * qed_mcp_get_media_type(): Get media type value of the port.
340 * @p_hwfn: HW device data.
342 * @media_type: Media type value
344 * Return: Int - 0 - Operation was successul.
345 * -EBUSY - Operation failed
347 int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
348 struct qed_ptt *p_ptt, u32 *media_type);
351 * qed_mcp_get_transceiver_data(): Get transceiver data of the port.
353 * @p_hwfn: HW device data.
355 * @p_transceiver_state: Transceiver state.
356 * @p_tranceiver_type: Media type value.
358 * Return: Int - 0 - Operation was successul.
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 * qed_mcp_trans_speed_mask(): Get transceiver supported speed mask.
369 * @p_hwfn: HW device data.
371 * @p_speed_mask: Bit mask of all supported speeds.
373 * Return: Int - 0 - Operation was successul.
374 * -EBUSY - Operation failed
377 int qed_mcp_trans_speed_mask(struct qed_hwfn *p_hwfn,
378 struct qed_ptt *p_ptt, u32 *p_speed_mask);
381 * qed_mcp_get_board_config(): Get board configuration.
383 * @p_hwfn: HW device data.
385 * @p_board_config: Board config.
387 * Return: Int - 0 - Operation was successul.
388 * -EBUSY - Operation failed
390 int qed_mcp_get_board_config(struct qed_hwfn *p_hwfn,
391 struct qed_ptt *p_ptt, u32 *p_board_config);
394 * qed_mcp_cmd(): General function for sending commands to the MCP
395 * mailbox. It acquire mutex lock for the entire
396 * operation, from sending the request until the MCP
397 * response. Waiting for MCP response will be checked up
398 * to 5 seconds every 5ms.
400 * @p_hwfn: HW device data.
401 * @p_ptt: PTT required for register access.
402 * @cmd: command to be sent to the MCP.
403 * @param: Optional param
404 * @o_mcp_resp: The MCP response code (exclude sequence).
405 * @o_mcp_param: Optional parameter provided by the MCP
408 * Return: Int - 0 - Operation was successul.
410 int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
411 struct qed_ptt *p_ptt,
418 * qed_mcp_drain(): drains the nig, allowing completion to pass in
420 * (Should be called only from sleepable context)
422 * @p_hwfn: HW device data.
423 * @p_ptt: PTT required for register access.
427 int qed_mcp_drain(struct qed_hwfn *p_hwfn,
428 struct qed_ptt *p_ptt);
431 * qed_mcp_get_flash_size(): Get the flash size value.
433 * @p_hwfn: HW device data.
434 * @p_ptt: PTT required for register access.
435 * @p_flash_size: Flash size in bytes to be filled.
437 * Return: Int - 0 - Operation was successul.
439 int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
440 struct qed_ptt *p_ptt,
444 * qed_mcp_send_drv_version(): Send driver version to MFW.
446 * @p_hwfn: HW device data.
447 * @p_ptt: PTT required for register access.
448 * @p_ver: Version value.
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 * qed_get_process_kill_counter(): Read the MFW process kill counter.
460 * @p_hwfn: HW device data.
461 * @p_ptt: PTT required for register access.
465 u32 qed_get_process_kill_counter(struct qed_hwfn *p_hwfn,
466 struct qed_ptt *p_ptt);
469 * qed_start_recovery_process(): Trigger a recovery process.
471 * @p_hwfn: HW device data.
472 * @p_ptt: PTT required for register access.
476 int qed_start_recovery_process(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
479 * qed_recovery_prolog(): A recovery handler must call this function
481 * It is assumed that the handler is not run from
482 * an interrupt context.
484 * @cdev: Qed dev pointer.
488 int qed_recovery_prolog(struct qed_dev *cdev);
491 * qed_mcp_ov_update_current_config(): Notify MFW about the change in base
494 * @p_hwfn: HW device data.
496 * @client: Qed client type.
498 * Return: Int - 0 - Operation was successul.
500 int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
501 struct qed_ptt *p_ptt,
502 enum qed_ov_client client);
505 * qed_mcp_ov_update_driver_state(): Notify MFW about the driver state.
507 * @p_hwfn: HW device data.
509 * @drv_state: Driver state.
511 * Return: Int - 0 - Operation was successul.
513 int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
514 struct qed_ptt *p_ptt,
515 enum qed_ov_driver_state drv_state);
518 * qed_mcp_ov_update_mtu(): Send MTU size to MFW.
520 * @p_hwfn: HW device data.
524 * Return: Int - 0 - Operation was successul.
526 int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
527 struct qed_ptt *p_ptt, u16 mtu);
530 * qed_mcp_ov_update_mac(): Send MAC address to MFW.
532 * @p_hwfn: HW device data.
536 * Return: Int - 0 - Operation was successul.
538 int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
539 struct qed_ptt *p_ptt, const u8 *mac);
542 * qed_mcp_ov_update_wol(): Send WOL mode to MFW.
544 * @p_hwfn: HW device data.
548 * Return: Int - 0 - Operation was successul.
550 int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
551 struct qed_ptt *p_ptt,
552 enum qed_ov_wol wol);
555 * qed_mcp_set_led(): Set LED status.
557 * @p_hwfn: HW device data.
561 * Return: Int - 0 - Operation was successul.
563 int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
564 struct qed_ptt *p_ptt,
565 enum qed_led_mode mode);
568 * qed_mcp_nvm_read(): Read from NVM.
570 * @cdev: Qed dev pointer.
572 * @p_buf: NVM read buffer.
575 * Return: Int - 0 - Operation was successul.
577 int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
580 * qed_mcp_nvm_write(): Write to NVM.
582 * @cdev: Qed dev pointer.
585 * @p_buf: NVM write buffer.
588 * Return: Int - 0 - Operation was successul.
590 int qed_mcp_nvm_write(struct qed_dev *cdev,
591 u32 cmd, u32 addr, u8 *p_buf, u32 len);
594 * qed_mcp_nvm_resp(): Check latest response.
596 * @cdev: Qed dev pointer.
597 * @p_buf: NVM write buffer.
599 * Return: Int - 0 - Operation was successul.
601 int qed_mcp_nvm_resp(struct qed_dev *cdev, u8 *p_buf);
603 struct qed_nvm_image_att {
609 * qed_mcp_get_nvm_image_att(): Allows reading a whole nvram image.
611 * @p_hwfn: HW device data.
612 * @image_id: Image to get attributes for.
613 * @p_image_att: Image attributes structure into which to fill data.
615 * Return: Int - 0 - Operation was successul.
618 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
619 enum qed_nvm_images image_id,
620 struct qed_nvm_image_att *p_image_att);
623 * qed_mcp_get_nvm_image(): Allows reading a whole nvram image.
625 * @p_hwfn: HW device data.
626 * @image_id: image requested for reading.
627 * @p_buffer: allocated buffer into which to fill data.
628 * @buffer_len: length of the allocated buffer.
630 * Return: 0 if p_buffer now contains the nvram image.
632 int qed_mcp_get_nvm_image(struct qed_hwfn *p_hwfn,
633 enum qed_nvm_images image_id,
634 u8 *p_buffer, u32 buffer_len);
637 * qed_mcp_bist_register_test(): Bist register test.
639 * @p_hwfn: HW device data.
640 * @p_ptt: PTT required for register access.
642 * Return: Int - 0 - Operation was successul.
644 int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
645 struct qed_ptt *p_ptt);
648 * qed_mcp_bist_clock_test(): Bist clock test.
650 * @p_hwfn: HW device data.
651 * @p_ptt: PTT required for register access.
653 * Return: Int - 0 - Operation was successul.
655 int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
656 struct qed_ptt *p_ptt);
659 * qed_mcp_bist_nvm_get_num_images(): Bist nvm test - get number of images.
661 * @p_hwfn: HW device data.
662 * @p_ptt: PTT required for register access.
663 * @num_images: number of images if operation was
664 * successful. 0 if not.
666 * Return: Int - 0 - Operation was successul.
668 int qed_mcp_bist_nvm_get_num_images(struct qed_hwfn *p_hwfn,
669 struct qed_ptt *p_ptt,
673 * qed_mcp_bist_nvm_get_image_att(): Bist nvm test - get image attributes
676 * @p_hwfn: HW device data.
677 * @p_ptt: PTT required for register access.
678 * @p_image_att: Attributes of image.
679 * @image_index: Index of image to get information for.
681 * Return: Int - 0 - Operation was successul.
683 int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
684 struct qed_ptt *p_ptt,
685 struct bist_nvm_image_att *p_image_att,
689 * qed_mfw_process_tlv_req(): Processes the TLV request from MFW i.e.,
690 * get the required TLV info
691 * from the qed client and send it to the MFW.
693 * @p_hwfn: HW device data.
696 * Return: 0 upon success.
698 int qed_mfw_process_tlv_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
701 * qed_mcp_send_raw_debug_data(): Send raw debug data to the MFW
703 * @p_hwfn: HW device data.
705 * @p_buf: raw debug data buffer.
706 * @size: Buffer size.
711 qed_mcp_send_raw_debug_data(struct qed_hwfn *p_hwfn,
712 struct qed_ptt *p_ptt, u8 *p_buf, u32 size);
714 /* Using hwfn number (and not pf_num) is required since in CMT mode,
715 * same pf_num may be used by two different hwfn
716 * TODO - this shouldn't really be in .h file, but until all fields
717 * required during hw-init will be placed in their correct place in shmem
718 * we need it in qed_dev.c [for readin the nvram reflection in shmem].
720 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
722 ((p_hwfn)->abs_pf_id & 1) << 3) : \
724 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
726 struct qed_mcp_info {
727 /* List for mailbox commands which were sent and wait for a response */
728 struct list_head cmd_list;
730 /* Spinlock used for protecting the access to the mailbox commands list
731 * and the sending of the commands.
735 /* Flag to indicate whether sending a MFW mailbox command is blocked */
738 /* Spinlock used for syncing SW link-changes and link-changes
739 * originating from attention context.
741 spinlock_t link_lock;
749 struct qed_mcp_link_params link_input;
750 struct qed_mcp_link_state link_output;
751 struct qed_mcp_link_capabilities link_capabilities;
752 struct qed_mcp_function_info func_info;
758 /* Capabilties negotiated with the MFW */
761 /* S/N for debug data mailbox commands */
762 atomic_t dbg_data_seq;
765 struct qed_mcp_mb_params {
775 #define QED_MB_FLAG_CAN_SLEEP (0x1 << 0)
776 #define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
777 #define QED_MB_FLAGS_IS_SET(params, flag) \
778 ({ typeof(params) __params = (params); \
779 (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
782 struct qed_drv_tlv_hdr {
784 u8 tlv_length; /* In dwords - not including this header */
786 #define QED_DRV_TLV_FLAGS_CHANGED 0x01
791 * qed_mcp_is_ext_speed_supported() - Check if management firmware supports
793 * @p_hwfn: HW device data.
795 * Return: true if supported, false otherwise.
798 qed_mcp_is_ext_speed_supported(const struct qed_hwfn *p_hwfn)
800 return !!(p_hwfn->mcp_info->capabilities &
801 FW_MB_PARAM_FEATURE_SUPPORT_EXT_SPEED_FEC_CONTROL);
805 * qed_mcp_cmd_init(): Initialize the interface with the MCP.
807 * @p_hwfn: HW device data.
808 * @p_ptt: PTT required for register access.
812 int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
813 struct qed_ptt *p_ptt);
816 * qed_mcp_cmd_port_init(): Initialize the port interface with the MCP
818 * @p_hwfn: HW device data.
823 * Can only be called after `num_ports_in_engines' is set
825 void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
826 struct qed_ptt *p_ptt);
828 * qed_mcp_free(): Releases resources allocated during the init process.
830 * @p_hwfn: HW function.
835 int qed_mcp_free(struct qed_hwfn *p_hwfn);
838 * qed_mcp_handle_events(): This function is called from the DPC context.
839 * After pointing PTT to the mfw mb, check for events sent by
840 * the MCP to the driver and ack them. In case a critical event
841 * detected, it will be handled here, otherwise the work will be
842 * queued to a sleepable work-queue.
844 * @p_hwfn: HW function.
845 * @p_ptt: PTT required for register access.
847 * Return: Int - 0 - Operation was successul.
849 int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
850 struct qed_ptt *p_ptt);
857 struct qed_load_req_params {
859 enum qed_drv_role drv_role;
861 bool avoid_eng_reset;
862 enum qed_override_force_load override_force_load;
869 * qed_mcp_load_req(): Sends a LOAD_REQ to the MFW, and in case the
870 * operation succeeds, returns whether this PF is
871 * the first on the engine/port or function.
873 * @p_hwfn: HW device data.
877 * Return: Int - 0 - Operation was successul.
879 int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
880 struct qed_ptt *p_ptt,
881 struct qed_load_req_params *p_params);
884 * qed_mcp_load_done(): Sends a LOAD_DONE message to the MFW.
886 * @p_hwfn: HW device data.
889 * Return: Int - 0 - Operation was successul.
891 int qed_mcp_load_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
894 * qed_mcp_unload_req(): Sends a UNLOAD_REQ message to the MFW.
896 * @p_hwfn: HW device data.
899 * Return: Int - 0 - Operation was successul.
901 int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
904 * qed_mcp_unload_done(): Sends a UNLOAD_DONE message to the MFW
906 * @p_hwfn: HW device data.
909 * Return: Int - 0 - Operation was successul.
911 int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
914 * qed_mcp_read_mb(): Read the MFW mailbox into Current buffer.
916 * @p_hwfn: HW device data.
921 void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
922 struct qed_ptt *p_ptt);
925 * qed_mcp_ack_vf_flr(): Ack to mfw that driver finished FLR process for VFs
927 * @p_hwfn: HW device data.
929 * @vfs_to_ack: bit mask of all engine VFs for which the PF acks.
931 * Return: Int - 0 - Operation was successul.
933 int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
934 struct qed_ptt *p_ptt, u32 *vfs_to_ack);
937 * qed_mcp_fill_shmem_func_info(): Calls during init to read shmem of
938 * all function-related info.
940 * @p_hwfn: HW device data.
943 * Return: 0 upon success.
945 int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
946 struct qed_ptt *p_ptt);
949 * qed_mcp_reset(): Reset the MCP using mailbox command.
951 * @p_hwfn: HW device data.
954 * Return: 0 upon success.
956 int qed_mcp_reset(struct qed_hwfn *p_hwfn,
957 struct qed_ptt *p_ptt);
960 * qed_mcp_nvm_rd_cmd(): Sends an NVM read command request to the MFW to get
963 * @p_hwfn: HW device data.
965 * @cmd: (Command) DRV_MSG_CODE_NVM_GET_FILE_DATA or
966 * DRV_MSG_CODE_NVM_READ_NVRAM commands.
967 * @param: [0:23] - Offset [24:31] - Size.
968 * @o_mcp_resp: MCP response.
969 * @o_mcp_param: MCP response param.
970 * @o_txn_size: Buffer size output.
971 * @o_buf: Pointer to the buffer returned by the MFW.
972 * @b_can_sleep: Can sleep.
974 * Return: 0 upon success.
976 int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
977 struct qed_ptt *p_ptt,
982 u32 *o_txn_size, u32 *o_buf, bool b_can_sleep);
985 * qed_mcp_phy_sfp_read(): Read from sfp.
987 * @p_hwfn: HW device data.
988 * @p_ptt: PTT required for register access.
989 * @port: transceiver port.
990 * @addr: I2C address.
991 * @offset: offset in sfp.
992 * @len: buffer length.
993 * @p_buf: buffer to read into.
995 * Return: Int - 0 - Operation was successul.
997 int qed_mcp_phy_sfp_read(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
998 u32 port, u32 addr, u32 offset, u32 len, u8 *p_buf);
1001 * qed_mcp_is_init(): indicates whether the MFW objects [under mcp_info]
1004 * @p_hwfn: HW device data.
1006 * Return: true if MFW is running and mcp_info is initialized.
1008 bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
1011 * qed_mcp_config_vf_msix(): Request MFW to configure MSI-X for a VF.
1013 * @p_hwfn: HW device data.
1015 * @vf_id: absolute inside engine.
1016 * @num: number of entries to request.
1020 int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
1021 struct qed_ptt *p_ptt, u8 vf_id, u8 num);
1024 * qed_mcp_halt(): Halt the MCP.
1026 * @p_hwfn: HW device data.
1029 * Return: 0 upon success.
1031 int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1034 * qed_mcp_resume: Wake up the MCP.
1036 * @p_hwfn: HW device data.
1039 * Return: 0 upon success.
1041 int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1043 int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
1044 int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
1045 int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
1046 struct qed_ptt *p_ptt,
1047 struct qed_mcp_link_state *p_link,
1049 int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
1050 struct qed_ptt *p_ptt,
1051 struct qed_mcp_link_state *p_link,
1054 int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
1055 struct qed_ptt *p_ptt, u32 mask_parities);
1057 /* qed_mcp_mdump_get_retain(): Gets the mdump retained data from the MFW.
1059 * @p_hwfn: HW device data.
1061 * @p_mdump_retain: mdump retain.
1063 * Return: Int - 0 - Operation was successul.
1066 qed_mcp_mdump_get_retain(struct qed_hwfn *p_hwfn,
1067 struct qed_ptt *p_ptt,
1068 struct mdump_retain_data_stc *p_mdump_retain);
1071 * qed_mcp_set_resc_max_val(): Sets the MFW's max value for the given resource.
1073 * @p_hwfn: HW device data.
1076 * @resc_max_val: Resec max val.
1077 * @p_mcp_resp: MCP Resp
1079 * Return: Int - 0 - Operation was successul.
1082 qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
1083 struct qed_ptt *p_ptt,
1084 enum qed_resources res_id,
1085 u32 resc_max_val, u32 *p_mcp_resp);
1088 * qed_mcp_get_resc_info(): Gets the MFW allocation info for the given
1091 * @p_hwfn: HW device data.
1094 * @p_mcp_resp: MCP resp.
1095 * @p_resc_num: Resc num.
1096 * @p_resc_start: Resc start.
1098 * Return: Int - 0 - Operation was successul.
1101 qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
1102 struct qed_ptt *p_ptt,
1103 enum qed_resources res_id,
1104 u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start);
1107 * qed_mcp_ov_update_eswitch(): Send eswitch mode to MFW.
1109 * @p_hwfn: HW device data.
1111 * @eswitch: eswitch mode.
1113 * Return: Int - 0 - Operation was successul.
1115 int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
1116 struct qed_ptt *p_ptt,
1117 enum qed_ov_eswitch eswitch);
1119 #define QED_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP
1120 #define QED_MCP_RESC_LOCK_MAX_VAL 31
1122 enum qed_resc_lock {
1123 QED_RESC_LOCK_DBG_DUMP = QED_MCP_RESC_LOCK_MIN_VAL,
1124 QED_RESC_LOCK_PTP_PORT0,
1125 QED_RESC_LOCK_PTP_PORT1,
1126 QED_RESC_LOCK_PTP_PORT2,
1127 QED_RESC_LOCK_PTP_PORT3,
1128 QED_RESC_LOCK_RESC_ALLOC = QED_MCP_RESC_LOCK_MAX_VAL,
1129 QED_RESC_LOCK_RESC_INVALID
1133 * qed_mcp_initiate_pf_flr(): Initiates PF FLR.
1135 * @p_hwfn: HW device data.
1138 * Return: Int - 0 - Operation was successul.
1140 int qed_mcp_initiate_pf_flr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1141 struct qed_resc_lock_params {
1142 /* Resource number [valid values are 0..31] */
1145 /* Lock timeout value in seconds [default, none or 1..254] */
1147 #define QED_MCP_RESC_LOCK_TO_DEFAULT 0
1148 #define QED_MCP_RESC_LOCK_TO_NONE 255
1150 /* Number of times to retry locking */
1152 #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT 10
1154 /* The interval in usec between retries */
1156 #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT 10000
1158 /* Use sleep or delay between retries */
1159 bool sleep_b4_retry;
1161 /* Will be set as true if the resource is free and granted */
1164 /* Will be filled with the resource owner.
1165 * [0..15 = PF0-15, 16 = MFW]
1171 * qed_mcp_resc_lock(): Acquires MFW generic resource lock.
1173 * @p_hwfn: HW device data.
1175 * @p_params: Params.
1177 * Return: Int - 0 - Operation was successul.
1180 qed_mcp_resc_lock(struct qed_hwfn *p_hwfn,
1181 struct qed_ptt *p_ptt, struct qed_resc_lock_params *p_params);
1183 struct qed_resc_unlock_params {
1184 /* Resource number [valid values are 0..31] */
1187 /* Allow to release a resource even if belongs to another PF */
1190 /* Will be set as true if the resource is released */
1195 * qed_mcp_resc_unlock(): Releases MFW generic resource lock.
1197 * @p_hwfn: HW device data.
1199 * @p_params: Params.
1201 * Return: Int - 0 - Operation was successul.
1204 qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
1205 struct qed_ptt *p_ptt,
1206 struct qed_resc_unlock_params *p_params);
1209 * qed_mcp_resc_lock_default_init(): Default initialization for
1210 * lock/unlock resource structs.
1212 * @p_lock: lock params struct to be initialized; Can be NULL.
1213 * @p_unlock: unlock params struct to be initialized; Can be NULL.
1214 * @resource: the requested resource.
1215 * @b_is_permanent: disable retries & aging when set.
1219 void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params *p_lock,
1220 struct qed_resc_unlock_params *p_unlock,
1222 resource, bool b_is_permanent);
1225 * qed_mcp_is_smart_an_supported(): Return whether management firmware
1228 * @p_hwfn: HW device data.
1230 * Return: bool true if feature is supported.
1232 bool qed_mcp_is_smart_an_supported(struct qed_hwfn *p_hwfn);
1235 * qed_mcp_get_capabilities(): Learn of supported MFW features;
1236 * To be done during early init.
1238 * @p_hwfn: HW device data.
1243 int qed_mcp_get_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1246 * qed_mcp_set_capabilities(): Inform MFW of set of features supported
1247 * by driver. Should be done inside the content
1250 * @p_hwfn: HW device data.
1255 int qed_mcp_set_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1258 * qed_mcp_read_ufp_config(): Read ufp config from the shared memory.
1260 * @p_hwfn: HW device data.
1265 void qed_mcp_read_ufp_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1268 * qed_mcp_nvm_info_populate(): Populate the nvm info shadow in the given
1269 * hardware function.
1271 * @p_hwfn: HW device data.
1275 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
1278 * qed_mcp_nvm_info_free(): Delete nvm info shadow in the given
1279 * hardware function.
1281 * @p_hwfn: HW device data.
1285 void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn);
1288 * qed_mcp_get_engine_config(): Get the engine affinity configuration.
1290 * @p_hwfn: HW device data.
1295 int qed_mcp_get_engine_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1298 * qed_mcp_get_ppfid_bitmap(): Get the PPFID bitmap.
1300 * @p_hwfn: HW device data.
1305 int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1308 * qed_mcp_nvm_get_cfg(): Get NVM config attribute value.
1310 * @p_hwfn: HW device data.
1312 * @option_id: Option ID.
1313 * @entity_id: Entity ID.
1320 int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1321 u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
1325 * qed_mcp_nvm_set_cfg(): Set NVM config attribute value.
1327 * @p_hwfn: HW device data.
1329 * @option_id: Option ID.
1330 * @entity_id: Entity ID.
1337 int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1338 u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,