1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #include <linux/types.h>
37 #include <linux/delay.h>
38 #include <linux/slab.h>
39 #include <linux/spinlock.h>
40 #include <linux/qed/qed_fcoe_if.h>
42 #include "qed_dev_api.h"
44 struct qed_mcp_link_speed_params {
46 u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */
47 u32 forced_speed; /* In Mb/s */
50 struct qed_mcp_link_pause_params {
56 enum qed_mcp_eee_mode {
59 QED_MCP_EEE_UNSUPPORTED
62 struct qed_mcp_link_params {
63 struct qed_mcp_link_speed_params speed;
64 struct qed_mcp_link_pause_params pause;
66 struct qed_link_eee_params eee;
69 struct qed_mcp_link_capabilities {
70 u32 speed_capabilities;
71 bool default_speed_autoneg;
72 enum qed_mcp_eee_mode default_eee;
77 struct qed_mcp_link_state {
82 /* Actual link speed in Mb/s */
85 /* PF max speed in Mb/s, deduced from line_speed
86 * according to PF max bandwidth configuration.
93 bool parallel_detection;
96 #define QED_LINK_PARTNER_SPEED_1G_HD BIT(0)
97 #define QED_LINK_PARTNER_SPEED_1G_FD BIT(1)
98 #define QED_LINK_PARTNER_SPEED_10G BIT(2)
99 #define QED_LINK_PARTNER_SPEED_20G BIT(3)
100 #define QED_LINK_PARTNER_SPEED_25G BIT(4)
101 #define QED_LINK_PARTNER_SPEED_40G BIT(5)
102 #define QED_LINK_PARTNER_SPEED_50G BIT(6)
103 #define QED_LINK_PARTNER_SPEED_100G BIT(7)
104 u32 partner_adv_speed;
106 bool partner_tx_flow_ctrl_en;
107 bool partner_rx_flow_ctrl_en;
109 #define QED_LINK_PARTNER_SYMMETRIC_PAUSE (1)
110 #define QED_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
111 #define QED_LINK_PARTNER_BOTH_PAUSE (3)
112 u8 partner_adv_pause;
120 struct qed_mcp_function_info {
123 enum qed_pci_personality protocol;
133 #define QED_MCP_VLAN_UNSET (0xffff)
139 struct qed_mcp_nvm_common {
146 struct qed_mcp_drv_version {
148 u8 name[MCP_DRV_VER_STR_SIZE - 4];
151 struct qed_mcp_lan_stats {
157 struct qed_mcp_fcoe_stats {
164 struct qed_mcp_iscsi_stats {
171 struct qed_mcp_rdma_stats {
178 enum qed_mcp_protocol_type {
185 union qed_mcp_protocol_stats {
186 struct qed_mcp_lan_stats lan_stats;
187 struct qed_mcp_fcoe_stats fcoe_stats;
188 struct qed_mcp_iscsi_stats iscsi_stats;
189 struct qed_mcp_rdma_stats rdma_stats;
192 enum qed_ov_eswitch {
201 QED_OV_CLIENT_VENDOR_SPEC
204 enum qed_ov_driver_state {
205 QED_OV_DRIVER_STATE_NOT_LOADED,
206 QED_OV_DRIVER_STATE_DISABLED,
207 QED_OV_DRIVER_STATE_ACTIVE
216 enum qed_mfw_tlv_type {
217 QED_MFW_TLV_GENERIC = 0x1, /* Core driver TLVs */
218 QED_MFW_TLV_ETH = 0x2, /* L2 driver TLVs */
219 QED_MFW_TLV_FCOE = 0x4, /* FCoE protocol TLVs */
220 QED_MFW_TLV_ISCSI = 0x8, /* SCSI protocol TLVs */
221 QED_MFW_TLV_MAX = 0x16,
224 struct qed_mfw_tlv_generic {
225 #define QED_MFW_TLV_FLAGS_SIZE 2
227 u8 ipv4_csum_offload;
232 #define QED_MFW_TLV_MAC_COUNT 3
233 /* First entry for primary MAC, 2 secondary MACs possible */
234 u8 mac[QED_MFW_TLV_MAC_COUNT][6];
235 bool mac_set[QED_MFW_TLV_MAC_COUNT];
247 union qed_mfw_tlv_data {
248 struct qed_mfw_tlv_generic generic;
249 struct qed_mfw_tlv_eth eth;
250 struct qed_mfw_tlv_fcoe fcoe;
251 struct qed_mfw_tlv_iscsi iscsi;
255 * @brief - returns the link params of the hw function
259 * @returns pointer to link params
261 struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *);
264 * @brief - return the link state of the hw function
268 * @returns pointer to link state
270 struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *);
273 * @brief - return the link capabilities of the hw function
277 * @returns pointer to link capabilities
279 struct qed_mcp_link_capabilities
280 *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
283 * @brief Request the MFW to set the the link according to 'link_input'.
287 * @param b_up - raise link if `true'. Reset link if `false'.
291 int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
292 struct qed_ptt *p_ptt,
296 * @brief Get the management firmware version value
300 * @param p_mfw_ver - mfw version value
301 * @param p_running_bundle_id - image id in nvram; Optional.
303 * @return int - 0 - operation was successful.
305 int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
306 struct qed_ptt *p_ptt,
307 u32 *p_mfw_ver, u32 *p_running_bundle_id);
310 * @brief Get the MBI version value
314 * @param p_mbi_ver - A pointer to a variable to be filled with the MBI version.
316 * @return int - 0 - operation was successful.
318 int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
319 struct qed_ptt *p_ptt, u32 *p_mbi_ver);
322 * @brief Get media type value of the port.
324 * @param cdev - qed dev pointer
326 * @param mfw_ver - media type value
329 * 0 - Operation was successul.
330 * -EBUSY - Operation failed
332 int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
333 struct qed_ptt *p_ptt, u32 *media_type);
336 * @brief Get transceiver data of the port.
338 * @param cdev - qed dev pointer
340 * @param p_transceiver_state - transceiver state.
341 * @param p_transceiver_type - media type value
344 * 0 - Operation was successful.
345 * -EBUSY - Operation failed
347 int qed_mcp_get_transceiver_data(struct qed_hwfn *p_hwfn,
348 struct qed_ptt *p_ptt,
349 u32 *p_transceiver_state,
350 u32 *p_tranceiver_type);
353 * @brief Get transceiver supported speed mask.
355 * @param cdev - qed dev pointer
357 * @param p_speed_mask - Bit mask of all supported speeds.
360 * 0 - Operation was successful.
361 * -EBUSY - Operation failed
364 int qed_mcp_trans_speed_mask(struct qed_hwfn *p_hwfn,
365 struct qed_ptt *p_ptt, u32 *p_speed_mask);
368 * @brief Get board configuration.
370 * @param cdev - qed dev pointer
372 * @param p_board_config - Board config.
375 * 0 - Operation was successful.
376 * -EBUSY - Operation failed
378 int qed_mcp_get_board_config(struct qed_hwfn *p_hwfn,
379 struct qed_ptt *p_ptt, u32 *p_board_config);
382 * @brief General function for sending commands to the MCP
383 * mailbox. It acquire mutex lock for the entire
384 * operation, from sending the request until the MCP
385 * response. Waiting for MCP response will be checked up
386 * to 5 seconds every 5ms.
388 * @param p_hwfn - hw function
389 * @param p_ptt - PTT required for register access
390 * @param cmd - command to be sent to the MCP.
391 * @param param - Optional param
392 * @param o_mcp_resp - The MCP response code (exclude sequence).
393 * @param o_mcp_param- Optional parameter provided by the MCP
395 * @return int - 0 - operation
398 int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
399 struct qed_ptt *p_ptt,
406 * @brief - drains the nig, allowing completion to pass in case of pauses.
407 * (Should be called only from sleepable context)
412 int qed_mcp_drain(struct qed_hwfn *p_hwfn,
413 struct qed_ptt *p_ptt);
416 * @brief Get the flash size value
420 * @param p_flash_size - flash size in bytes to be filled.
422 * @return int - 0 - operation was successul.
424 int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
425 struct qed_ptt *p_ptt,
429 * @brief Send driver version to MFW
433 * @param version - Version value
434 * @param name - Protocol driver name
436 * @return int - 0 - operation was successul.
439 qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
440 struct qed_ptt *p_ptt,
441 struct qed_mcp_drv_version *p_ver);
444 * @brief Notify MFW about the change in base device properties
448 * @param client - qed client type
450 * @return int - 0 - operation was successful.
452 int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
453 struct qed_ptt *p_ptt,
454 enum qed_ov_client client);
457 * @brief Notify MFW about the driver state
461 * @param drv_state - Driver state
463 * @return int - 0 - operation was successful.
465 int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
466 struct qed_ptt *p_ptt,
467 enum qed_ov_driver_state drv_state);
470 * @brief Send MTU size to MFW
474 * @param mtu - MTU size
476 * @return int - 0 - operation was successful.
478 int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
479 struct qed_ptt *p_ptt, u16 mtu);
482 * @brief Send MAC address to MFW
486 * @param mac - MAC address
488 * @return int - 0 - operation was successful.
490 int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
491 struct qed_ptt *p_ptt, u8 *mac);
494 * @brief Send WOL mode to MFW
498 * @param wol - WOL mode
500 * @return int - 0 - operation was successful.
502 int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
503 struct qed_ptt *p_ptt,
504 enum qed_ov_wol wol);
507 * @brief Set LED status
511 * @param mode - LED mode
513 * @return int - 0 - operation was successful.
515 int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
516 struct qed_ptt *p_ptt,
517 enum qed_led_mode mode);
520 * @brief Read from nvm
523 * @param addr - nvm offset
524 * @param p_buf - nvm read buffer
525 * @param len - buffer len
527 * @return int - 0 - operation was successful.
529 int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
532 * @brief Write to nvm
535 * @param addr - nvm offset
536 * @param cmd - nvm command
537 * @param p_buf - nvm write buffer
538 * @param len - buffer len
540 * @return int - 0 - operation was successful.
542 int qed_mcp_nvm_write(struct qed_dev *cdev,
543 u32 cmd, u32 addr, u8 *p_buf, u32 len);
546 * @brief Check latest response
549 * @param p_buf - nvm write buffer
551 * @return int - 0 - operation was successful.
553 int qed_mcp_nvm_resp(struct qed_dev *cdev, u8 *p_buf);
555 struct qed_nvm_image_att {
561 * @brief Allows reading a whole nvram image
564 * @param image_id - image to get attributes for
565 * @param p_image_att - image attributes structure into which to fill data
567 * @return int - 0 - operation was successful.
570 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
571 enum qed_nvm_images image_id,
572 struct qed_nvm_image_att *p_image_att);
575 * @brief Allows reading a whole nvram image
578 * @param image_id - image requested for reading
579 * @param p_buffer - allocated buffer into which to fill data
580 * @param buffer_len - length of the allocated buffer.
582 * @return 0 iff p_buffer now contains the nvram image.
584 int qed_mcp_get_nvm_image(struct qed_hwfn *p_hwfn,
585 enum qed_nvm_images image_id,
586 u8 *p_buffer, u32 buffer_len);
589 * @brief Bist register test
591 * @param p_hwfn - hw function
592 * @param p_ptt - PTT required for register access
594 * @return int - 0 - operation was successful.
596 int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
597 struct qed_ptt *p_ptt);
600 * @brief Bist clock 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_clock_test(struct qed_hwfn *p_hwfn,
608 struct qed_ptt *p_ptt);
611 * @brief Bist nvm test - get number of images
613 * @param p_hwfn - hw function
614 * @param p_ptt - PTT required for register access
615 * @param num_images - number of images if operation was
616 * successful. 0 if not.
618 * @return int - 0 - operation was successful.
620 int qed_mcp_bist_nvm_get_num_images(struct qed_hwfn *p_hwfn,
621 struct qed_ptt *p_ptt,
625 * @brief Bist nvm test - get image attributes by index
627 * @param p_hwfn - hw function
628 * @param p_ptt - PTT required for register access
629 * @param p_image_att - Attributes of image
630 * @param image_index - Index of image to get information for
632 * @return int - 0 - operation was successful.
634 int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
635 struct qed_ptt *p_ptt,
636 struct bist_nvm_image_att *p_image_att,
640 * @brief - Processes the TLV request from MFW i.e., get the required TLV info
641 * from the qed client and send it to the MFW.
646 * @param return 0 upon success.
648 int qed_mfw_process_tlv_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
650 /* Using hwfn number (and not pf_num) is required since in CMT mode,
651 * same pf_num may be used by two different hwfn
652 * TODO - this shouldn't really be in .h file, but until all fields
653 * required during hw-init will be placed in their correct place in shmem
654 * we need it in qed_dev.c [for readin the nvram reflection in shmem].
656 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
658 ((p_hwfn)->abs_pf_id & 1) << 3) : \
660 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
662 #define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
663 ((_p_hwfn)->cdev->num_ports_in_engine * \
664 qed_device_num_engines((_p_hwfn)->cdev)))
666 struct qed_mcp_info {
667 /* List for mailbox commands which were sent and wait for a response */
668 struct list_head cmd_list;
670 /* Spinlock used for protecting the access to the mailbox commands list
671 * and the sending of the commands.
675 /* Flag to indicate whether sending a MFW mailbox command is blocked */
678 /* Spinlock used for syncing SW link-changes and link-changes
679 * originating from attention context.
681 spinlock_t link_lock;
689 struct qed_mcp_link_params link_input;
690 struct qed_mcp_link_state link_output;
691 struct qed_mcp_link_capabilities link_capabilities;
692 struct qed_mcp_function_info func_info;
698 /* Capabilties negotiated with the MFW */
702 struct qed_mcp_mb_params {
712 #define QED_MB_FLAG_CAN_SLEEP (0x1 << 0)
713 #define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
714 #define QED_MB_FLAGS_IS_SET(params, flag) \
715 ({ typeof(params) __params = (params); \
716 (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
719 struct qed_drv_tlv_hdr {
721 u8 tlv_length; /* In dwords - not including this header */
723 #define QED_DRV_TLV_FLAGS_CHANGED 0x01
728 * @brief Initialize the interface with the MCP
730 * @param p_hwfn - HW func
731 * @param p_ptt - PTT required for register access
735 int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
736 struct qed_ptt *p_ptt);
739 * @brief Initialize the port interface with the MCP
743 * Can only be called after `num_ports_in_engines' is set
745 void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
746 struct qed_ptt *p_ptt);
748 * @brief Releases resources allocated during the init process.
750 * @param p_hwfn - HW func
751 * @param p_ptt - PTT required for register access
756 int qed_mcp_free(struct qed_hwfn *p_hwfn);
759 * @brief This function is called from the DPC context. After
760 * pointing PTT to the mfw mb, check for events sent by the MCP
761 * to the driver and ack them. In case a critical event
762 * detected, it will be handled here, otherwise the work will be
763 * queued to a sleepable work-queue.
765 * @param p_hwfn - HW function
766 * @param p_ptt - PTT required for register access
767 * @return int - 0 - operation
770 int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
771 struct qed_ptt *p_ptt);
778 struct qed_load_req_params {
780 enum qed_drv_role drv_role;
782 bool avoid_eng_reset;
783 enum qed_override_force_load override_force_load;
790 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
791 * returns whether this PF is the first on the engine/port or function.
797 * @return int - 0 - Operation was successful.
799 int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
800 struct qed_ptt *p_ptt,
801 struct qed_load_req_params *p_params);
804 * @brief Sends a LOAD_DONE message to the MFW
809 * @return int - 0 - Operation was successful.
811 int qed_mcp_load_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
814 * @brief Sends a UNLOAD_REQ message to the MFW
819 * @return int - 0 - Operation was successful.
821 int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
824 * @brief Sends a UNLOAD_DONE message to the MFW
829 * @return int - 0 - Operation was successful.
831 int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
834 * @brief Read the MFW mailbox into Current buffer.
839 void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
840 struct qed_ptt *p_ptt);
843 * @brief Ack to mfw that driver finished FLR process for VFs
847 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
849 * @param return int - 0 upon success.
851 int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
852 struct qed_ptt *p_ptt, u32 *vfs_to_ack);
855 * @brief - calls during init to read shmem of all function-related info.
859 * @param return 0 upon success.
861 int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
862 struct qed_ptt *p_ptt);
865 * @brief - Reset the MCP using mailbox command.
870 * @param return 0 upon success.
872 int qed_mcp_reset(struct qed_hwfn *p_hwfn,
873 struct qed_ptt *p_ptt);
876 * @brief - Sends an NVM read command request to the MFW to get
881 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
882 * DRV_MSG_CODE_NVM_READ_NVRAM commands
883 * @param param - [0:23] - Offset [24:31] - Size
884 * @param o_mcp_resp - MCP response
885 * @param o_mcp_param - MCP response param
886 * @param o_txn_size - Buffer size output
887 * @param o_buf - Pointer to the buffer returned by the MFW.
889 * @param return 0 upon success.
891 int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
892 struct qed_ptt *p_ptt,
896 u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf);
899 * @brief Read from sfp
901 * @param p_hwfn - hw function
902 * @param p_ptt - PTT required for register access
903 * @param port - transceiver port
904 * @param addr - I2C address
905 * @param offset - offset in sfp
906 * @param len - buffer length
907 * @param p_buf - buffer to read into
909 * @return int - 0 - operation was successful.
911 int qed_mcp_phy_sfp_read(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
912 u32 port, u32 addr, u32 offset, u32 len, u8 *p_buf);
915 * @brief indicates whether the MFW objects [under mcp_info] are accessible
919 * @return true iff MFW is running and mcp_info is initialized
921 bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
924 * @brief request MFW to configure MSI-X for a VF
928 * @param vf_id - absolute inside engine
929 * @param num_sbs - number of entries to request
933 int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
934 struct qed_ptt *p_ptt, u8 vf_id, u8 num);
937 * @brief - Halt the MCP.
942 * @param return 0 upon success.
944 int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
947 * @brief - Wake up the MCP.
952 * @param return 0 upon success.
954 int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
956 int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
957 int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
958 int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
959 struct qed_ptt *p_ptt,
960 struct qed_mcp_link_state *p_link,
962 int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
963 struct qed_ptt *p_ptt,
964 struct qed_mcp_link_state *p_link,
967 int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
968 struct qed_ptt *p_ptt, u32 mask_parities);
971 * @brief - Sets the MFW's max value for the given resource
976 * @param resc_max_val
979 * @return int - 0 - operation was successful.
982 qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
983 struct qed_ptt *p_ptt,
984 enum qed_resources res_id,
985 u32 resc_max_val, u32 *p_mcp_resp);
988 * @brief - Gets the MFW allocation info for the given resource
995 * @param p_resc_start
997 * @return int - 0 - operation was successful.
1000 qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
1001 struct qed_ptt *p_ptt,
1002 enum qed_resources res_id,
1003 u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start);
1006 * @brief Send eswitch mode to MFW
1010 * @param eswitch - eswitch mode
1012 * @return int - 0 - operation was successful.
1014 int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
1015 struct qed_ptt *p_ptt,
1016 enum qed_ov_eswitch eswitch);
1018 #define QED_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP
1019 #define QED_MCP_RESC_LOCK_MAX_VAL 31
1021 enum qed_resc_lock {
1022 QED_RESC_LOCK_DBG_DUMP = QED_MCP_RESC_LOCK_MIN_VAL,
1023 QED_RESC_LOCK_PTP_PORT0,
1024 QED_RESC_LOCK_PTP_PORT1,
1025 QED_RESC_LOCK_PTP_PORT2,
1026 QED_RESC_LOCK_PTP_PORT3,
1027 QED_RESC_LOCK_RESC_ALLOC = QED_MCP_RESC_LOCK_MAX_VAL,
1028 QED_RESC_LOCK_RESC_INVALID
1032 * @brief - Initiates PF FLR
1037 * @return int - 0 - operation was successful.
1039 int qed_mcp_initiate_pf_flr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1040 struct qed_resc_lock_params {
1041 /* Resource number [valid values are 0..31] */
1044 /* Lock timeout value in seconds [default, none or 1..254] */
1046 #define QED_MCP_RESC_LOCK_TO_DEFAULT 0
1047 #define QED_MCP_RESC_LOCK_TO_NONE 255
1049 /* Number of times to retry locking */
1051 #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT 10
1053 /* The interval in usec between retries */
1055 #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT 10000
1057 /* Use sleep or delay between retries */
1058 bool sleep_b4_retry;
1060 /* Will be set as true if the resource is free and granted */
1063 /* Will be filled with the resource owner.
1064 * [0..15 = PF0-15, 16 = MFW]
1070 * @brief Acquires MFW generic resource lock
1076 * @return int - 0 - operation was successful.
1079 qed_mcp_resc_lock(struct qed_hwfn *p_hwfn,
1080 struct qed_ptt *p_ptt, struct qed_resc_lock_params *p_params);
1082 struct qed_resc_unlock_params {
1083 /* Resource number [valid values are 0..31] */
1086 /* Allow to release a resource even if belongs to another PF */
1089 /* Will be set as true if the resource is released */
1094 * @brief Releases MFW generic resource lock
1100 * @return int - 0 - operation was successful.
1103 qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
1104 struct qed_ptt *p_ptt,
1105 struct qed_resc_unlock_params *p_params);
1108 * @brief - default initialization for lock/unlock resource structs
1110 * @param p_lock - lock params struct to be initialized; Can be NULL
1111 * @param p_unlock - unlock params struct to be initialized; Can be NULL
1112 * @param resource - the requested resource
1113 * @paral b_is_permanent - disable retries & aging when set
1115 void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params *p_lock,
1116 struct qed_resc_unlock_params *p_unlock,
1118 resource, bool b_is_permanent);
1120 * @brief Learn of supported MFW features; To be done during early init
1125 int qed_mcp_get_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1128 * @brief Inform MFW of set of features supported by driver. Should be done
1129 * inside the content of the LOAD_REQ.
1134 int qed_mcp_set_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1137 * @brief Read ufp config from the shared memory.
1142 void qed_mcp_read_ufp_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1145 * @brief Populate the nvm info shadow in the given hardware function
1149 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);