Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /* QLogic qed NIC Driver
0003  * Copyright (c) 2015-2017  QLogic Corporation
0004  * Copyright (c) 2019-2020 Marvell International Ltd.
0005  */
0006 
0007 #ifndef _QED_MCP_H
0008 #define _QED_MCP_H
0009 
0010 #include <linux/types.h>
0011 #include <linux/delay.h>
0012 #include <linux/slab.h>
0013 #include <linux/spinlock.h>
0014 #include <linux/qed/qed_fcoe_if.h>
0015 #include "qed_hsi.h"
0016 #include "qed_dev_api.h"
0017 
0018 #define QED_MFW_REPORT_STR_SIZE 256
0019 
0020 struct qed_mcp_link_speed_params {
0021     bool                    autoneg;
0022 
0023     u32                 advertised_speeds;
0024 #define QED_EXT_SPEED_MASK_RES          0x1
0025 #define QED_EXT_SPEED_MASK_1G           0x2
0026 #define QED_EXT_SPEED_MASK_10G          0x4
0027 #define QED_EXT_SPEED_MASK_20G          0x8
0028 #define QED_EXT_SPEED_MASK_25G          0x10
0029 #define QED_EXT_SPEED_MASK_40G          0x20
0030 #define QED_EXT_SPEED_MASK_50G_R        0x40
0031 #define QED_EXT_SPEED_MASK_50G_R2       0x80
0032 #define QED_EXT_SPEED_MASK_100G_R2      0x100
0033 #define QED_EXT_SPEED_MASK_100G_R4      0x200
0034 #define QED_EXT_SPEED_MASK_100G_P4      0x400
0035 
0036     u32                 forced_speed;      /* In Mb/s */
0037 #define QED_EXT_SPEED_1G            0x1
0038 #define QED_EXT_SPEED_10G           0x2
0039 #define QED_EXT_SPEED_20G           0x4
0040 #define QED_EXT_SPEED_25G           0x8
0041 #define QED_EXT_SPEED_40G           0x10
0042 #define QED_EXT_SPEED_50G_R         0x20
0043 #define QED_EXT_SPEED_50G_R2            0x40
0044 #define QED_EXT_SPEED_100G_R2           0x80
0045 #define QED_EXT_SPEED_100G_R4           0x100
0046 #define QED_EXT_SPEED_100G_P4           0x200
0047 };
0048 
0049 struct qed_mcp_link_pause_params {
0050     bool                    autoneg;
0051     bool                    forced_rx;
0052     bool                    forced_tx;
0053 };
0054 
0055 enum qed_mcp_eee_mode {
0056     QED_MCP_EEE_DISABLED,
0057     QED_MCP_EEE_ENABLED,
0058     QED_MCP_EEE_UNSUPPORTED
0059 };
0060 
0061 struct qed_mcp_link_params {
0062     struct qed_mcp_link_speed_params    speed;
0063     struct qed_mcp_link_pause_params    pause;
0064     u32                 loopback_mode;
0065     struct qed_link_eee_params      eee;
0066     u32                 fec;
0067 
0068     struct qed_mcp_link_speed_params    ext_speed;
0069     u32                 ext_fec_mode;
0070 };
0071 
0072 struct qed_mcp_link_capabilities {
0073     u32                 speed_capabilities;
0074     bool                    default_speed_autoneg;
0075     u32                 fec_default;
0076     enum qed_mcp_eee_mode           default_eee;
0077     u32                 eee_lpi_timer;
0078     u8                  eee_speed_caps;
0079 
0080     u32                 default_ext_speed_caps;
0081     u32                 default_ext_autoneg;
0082     u32                 default_ext_speed;
0083     u32                 default_ext_fec;
0084 };
0085 
0086 struct qed_mcp_link_state {
0087     bool                    link_up;
0088     u32                 min_pf_rate;
0089 
0090     /* Actual link speed in Mb/s */
0091     u32                 line_speed;
0092 
0093     /* PF max speed in Mb/s, deduced from line_speed
0094      * according to PF max bandwidth configuration.
0095      */
0096     u32                 speed;
0097 
0098     bool                    full_duplex;
0099     bool                    an;
0100     bool                    an_complete;
0101     bool                    parallel_detection;
0102     bool                    pfc_enabled;
0103 
0104     u32                 partner_adv_speed;
0105 #define QED_LINK_PARTNER_SPEED_1G_HD        BIT(0)
0106 #define QED_LINK_PARTNER_SPEED_1G_FD        BIT(1)
0107 #define QED_LINK_PARTNER_SPEED_10G      BIT(2)
0108 #define QED_LINK_PARTNER_SPEED_20G      BIT(3)
0109 #define QED_LINK_PARTNER_SPEED_25G      BIT(4)
0110 #define QED_LINK_PARTNER_SPEED_40G      BIT(5)
0111 #define QED_LINK_PARTNER_SPEED_50G      BIT(6)
0112 #define QED_LINK_PARTNER_SPEED_100G     BIT(7)
0113 
0114     bool                    partner_tx_flow_ctrl_en;
0115     bool                    partner_rx_flow_ctrl_en;
0116 
0117     u8                  partner_adv_pause;
0118 #define QED_LINK_PARTNER_SYMMETRIC_PAUSE    0x1
0119 #define QED_LINK_PARTNER_ASYMMETRIC_PAUSE   0x2
0120 #define QED_LINK_PARTNER_BOTH_PAUSE     0x3
0121 
0122     bool                    sfp_tx_fault;
0123     bool                    eee_active;
0124     u8                  eee_adv_caps;
0125     u8                  eee_lp_adv_caps;
0126 
0127     u32                 fec_active;
0128 };
0129 
0130 struct qed_mcp_function_info {
0131     u8              pause_on_host;
0132 
0133     enum qed_pci_personality    protocol;
0134 
0135     u8              bandwidth_min;
0136     u8              bandwidth_max;
0137 
0138     u8              mac[ETH_ALEN];
0139 
0140     u64             wwn_port;
0141     u64             wwn_node;
0142 
0143 #define QED_MCP_VLAN_UNSET              (0xffff)
0144     u16             ovlan;
0145 
0146     u16             mtu;
0147 };
0148 
0149 struct qed_mcp_nvm_common {
0150     u32 offset;
0151     u32 param;
0152     u32 resp;
0153     u32 cmd;
0154 };
0155 
0156 struct qed_mcp_drv_version {
0157     u32 version;
0158     u8  name[MCP_DRV_VER_STR_SIZE - 4];
0159 };
0160 
0161 struct qed_mcp_lan_stats {
0162     u64 ucast_rx_pkts;
0163     u64 ucast_tx_pkts;
0164     u32 fcs_err;
0165 };
0166 
0167 struct qed_mcp_fcoe_stats {
0168     u64 rx_pkts;
0169     u64 tx_pkts;
0170     u32 fcs_err;
0171     u32 login_failure;
0172 };
0173 
0174 struct qed_mcp_iscsi_stats {
0175     u64 rx_pdus;
0176     u64 tx_pdus;
0177     u64 rx_bytes;
0178     u64 tx_bytes;
0179 };
0180 
0181 struct qed_mcp_rdma_stats {
0182     u64 rx_pkts;
0183     u64 tx_pkts;
0184     u64 rx_bytes;
0185     u64 tx_byts;
0186 };
0187 
0188 enum qed_mcp_protocol_type {
0189     QED_MCP_LAN_STATS,
0190     QED_MCP_FCOE_STATS,
0191     QED_MCP_ISCSI_STATS,
0192     QED_MCP_RDMA_STATS
0193 };
0194 
0195 union qed_mcp_protocol_stats {
0196     struct qed_mcp_lan_stats lan_stats;
0197     struct qed_mcp_fcoe_stats fcoe_stats;
0198     struct qed_mcp_iscsi_stats iscsi_stats;
0199     struct qed_mcp_rdma_stats rdma_stats;
0200 };
0201 
0202 enum qed_ov_eswitch {
0203     QED_OV_ESWITCH_NONE,
0204     QED_OV_ESWITCH_VEB,
0205     QED_OV_ESWITCH_VEPA
0206 };
0207 
0208 enum qed_ov_client {
0209     QED_OV_CLIENT_DRV,
0210     QED_OV_CLIENT_USER,
0211     QED_OV_CLIENT_VENDOR_SPEC
0212 };
0213 
0214 enum qed_ov_driver_state {
0215     QED_OV_DRIVER_STATE_NOT_LOADED,
0216     QED_OV_DRIVER_STATE_DISABLED,
0217     QED_OV_DRIVER_STATE_ACTIVE
0218 };
0219 
0220 enum qed_ov_wol {
0221     QED_OV_WOL_DEFAULT,
0222     QED_OV_WOL_DISABLED,
0223     QED_OV_WOL_ENABLED
0224 };
0225 
0226 enum qed_mfw_tlv_type {
0227     QED_MFW_TLV_GENERIC = 0x1,  /* Core driver TLVs */
0228     QED_MFW_TLV_ETH = 0x2,      /* L2 driver TLVs */
0229     QED_MFW_TLV_FCOE = 0x4,     /* FCoE protocol TLVs */
0230     QED_MFW_TLV_ISCSI = 0x8,    /* SCSI protocol TLVs */
0231     QED_MFW_TLV_MAX = 0x16,
0232 };
0233 
0234 struct qed_mfw_tlv_generic {
0235 #define QED_MFW_TLV_FLAGS_SIZE  2
0236     struct {
0237         u8 ipv4_csum_offload;
0238         u8 lso_supported;
0239         bool b_set;
0240     } flags;
0241 
0242 #define QED_MFW_TLV_MAC_COUNT 3
0243     /* First entry for primary MAC, 2 secondary MACs possible */
0244     u8 mac[QED_MFW_TLV_MAC_COUNT][6];
0245     bool mac_set[QED_MFW_TLV_MAC_COUNT];
0246 
0247     u64 rx_frames;
0248     bool rx_frames_set;
0249     u64 rx_bytes;
0250     bool rx_bytes_set;
0251     u64 tx_frames;
0252     bool tx_frames_set;
0253     u64 tx_bytes;
0254     bool tx_bytes_set;
0255 };
0256 
0257 union qed_mfw_tlv_data {
0258     struct qed_mfw_tlv_generic generic;
0259     struct qed_mfw_tlv_eth eth;
0260     struct qed_mfw_tlv_fcoe fcoe;
0261     struct qed_mfw_tlv_iscsi iscsi;
0262 };
0263 
0264 #define QED_NVM_CFG_OPTION_ALL      BIT(0)
0265 #define QED_NVM_CFG_OPTION_INIT     BIT(1)
0266 #define QED_NVM_CFG_OPTION_COMMIT       BIT(2)
0267 #define QED_NVM_CFG_OPTION_FREE     BIT(3)
0268 #define QED_NVM_CFG_OPTION_ENTITY_SEL   BIT(4)
0269 
0270 /**
0271  * qed_mcp_get_link_params(): Returns the link params of the hw function.
0272  *
0273  * @p_hwfn: HW device data.
0274  *
0275  * Returns: Pointer to link params.
0276  */
0277 struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *p_hwfn);
0278 
0279 /**
0280  * qed_mcp_get_link_state(): Return the link state of the hw function.
0281  *
0282  * @p_hwfn: HW device data.
0283  *
0284  * Returns: Pointer to link state.
0285  */
0286 struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *p_hwfn);
0287 
0288 /**
0289  * qed_mcp_get_link_capabilities(): Return the link capabilities of the
0290  *                                  hw function.
0291  *
0292  * @p_hwfn: HW device data.
0293  *
0294  * Returns: Pointer to link capabilities.
0295  */
0296 struct qed_mcp_link_capabilities
0297     *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
0298 
0299 /**
0300  * qed_mcp_set_link(): Request the MFW to set the link according
0301  *                     to 'link_input'.
0302  *
0303  * @p_hwfn: HW device data.
0304  * @p_ptt: P_ptt.
0305  * @b_up: Raise link if `true'. Reset link if `false'.
0306  *
0307  * Return: Int.
0308  */
0309 int qed_mcp_set_link(struct qed_hwfn   *p_hwfn,
0310              struct qed_ptt     *p_ptt,
0311              bool               b_up);
0312 
0313 /**
0314  * qed_mcp_get_mfw_ver(): Get the management firmware version value.
0315  *
0316  * @p_hwfn: HW device data.
0317  * @p_ptt: P_ptt.
0318  * @p_mfw_ver: MFW version value.
0319  * @p_running_bundle_id: Image id in nvram; Optional.
0320  *
0321  * Return: Int - 0 - operation was successful.
0322  */
0323 int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
0324             struct qed_ptt *p_ptt,
0325             u32 *p_mfw_ver, u32 *p_running_bundle_id);
0326 
0327 /**
0328  * qed_mcp_get_mbi_ver(): Get the MBI version value.
0329  *
0330  * @p_hwfn: HW device data.
0331  * @p_ptt: P_ptt.
0332  * @p_mbi_ver: A pointer to a variable to be filled with the MBI version.
0333  *
0334  * Return: Int - 0 - operation was successful.
0335  */
0336 int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
0337             struct qed_ptt *p_ptt, u32 *p_mbi_ver);
0338 
0339 /**
0340  * qed_mcp_get_media_type(): Get media type value of the port.
0341  *
0342  * @p_hwfn: HW device data.
0343  * @p_ptt: P_ptt.
0344  * @media_type: Media type value
0345  *
0346  * Return: Int - 0 - Operation was successul.
0347  *              -EBUSY - Operation failed
0348  */
0349 int qed_mcp_get_media_type(struct qed_hwfn *p_hwfn,
0350                struct qed_ptt *p_ptt, u32 *media_type);
0351 
0352 /**
0353  * qed_mcp_get_transceiver_data(): Get transceiver data of the port.
0354  *
0355  * @p_hwfn: HW device data.
0356  * @p_ptt: P_ptt.
0357  * @p_transceiver_state: Transceiver state.
0358  * @p_tranceiver_type: Media type value.
0359  *
0360  * Return: Int - 0 - Operation was successul.
0361  *              -EBUSY - Operation failed
0362  */
0363 int qed_mcp_get_transceiver_data(struct qed_hwfn *p_hwfn,
0364                  struct qed_ptt *p_ptt,
0365                  u32 *p_transceiver_state,
0366                  u32 *p_tranceiver_type);
0367 
0368 /**
0369  * qed_mcp_trans_speed_mask(): Get transceiver supported speed mask.
0370  *
0371  * @p_hwfn: HW device data.
0372  * @p_ptt: P_ptt.
0373  * @p_speed_mask: Bit mask of all supported speeds.
0374  *
0375  * Return: Int - 0 - Operation was successul.
0376  *              -EBUSY - Operation failed
0377  */
0378 
0379 int qed_mcp_trans_speed_mask(struct qed_hwfn *p_hwfn,
0380                  struct qed_ptt *p_ptt, u32 *p_speed_mask);
0381 
0382 /**
0383  * qed_mcp_get_board_config(): Get board configuration.
0384  *
0385  * @p_hwfn: HW device data.
0386  * @p_ptt: P_ptt.
0387  * @p_board_config: Board config.
0388  *
0389  * Return: Int - 0 - Operation was successul.
0390  *              -EBUSY - Operation failed
0391  */
0392 int qed_mcp_get_board_config(struct qed_hwfn *p_hwfn,
0393                  struct qed_ptt *p_ptt, u32 *p_board_config);
0394 
0395 /**
0396  * qed_mcp_cmd(): Sleepable function for sending commands to the MCP
0397  *                mailbox. It acquire mutex lock for the entire
0398  *                operation, from sending the request until the MCP
0399  *                response. Waiting for MCP response will be checked up
0400  *                to 5 seconds every 10ms. Should not be called from atomic
0401  *                context.
0402  *
0403  * @p_hwfn: HW device data.
0404  * @p_ptt: PTT required for register access.
0405  * @cmd: command to be sent to the MCP.
0406  * @param: Optional param
0407  * @o_mcp_resp: The MCP response code (exclude sequence).
0408  * @o_mcp_param: Optional parameter provided by the MCP
0409  *                     response
0410  *
0411  * Return: Int - 0 - Operation was successul.
0412  */
0413 int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
0414         struct qed_ptt *p_ptt,
0415         u32 cmd,
0416         u32 param,
0417         u32 *o_mcp_resp,
0418         u32 *o_mcp_param);
0419 
0420 /**
0421  * qed_mcp_cmd_nosleep(): Function for sending commands to the MCP
0422  *                        mailbox. It acquire mutex lock for the entire
0423  *                        operation, from sending the request until the MCP
0424  *                        response. Waiting for MCP response will be checked up
0425  *                        to 5 seconds every 10us. Should be called when sleep
0426  *                        is not allowed.
0427  *
0428  * @p_hwfn: HW device data.
0429  * @p_ptt: PTT required for register access.
0430  * @cmd: command to be sent to the MCP.
0431  * @param: Optional param
0432  * @o_mcp_resp: The MCP response code (exclude sequence).
0433  * @o_mcp_param: Optional parameter provided by the MCP
0434  *                     response
0435  *
0436  * Return: Int - 0 - Operation was successul.
0437  */
0438 int qed_mcp_cmd_nosleep(struct qed_hwfn *p_hwfn,
0439             struct qed_ptt *p_ptt,
0440             u32 cmd,
0441             u32 param,
0442             u32 *o_mcp_resp,
0443             u32 *o_mcp_param);
0444 
0445 /**
0446  * qed_mcp_drain(): drains the nig, allowing completion to pass in
0447  *                  case of pauses.
0448  *                  (Should be called only from sleepable context)
0449  *
0450  * @p_hwfn: HW device data.
0451  * @p_ptt: PTT required for register access.
0452  *
0453  * Return: Int.
0454  */
0455 int qed_mcp_drain(struct qed_hwfn *p_hwfn,
0456           struct qed_ptt *p_ptt);
0457 
0458 /**
0459  * qed_mcp_get_flash_size(): Get the flash size value.
0460  *
0461  * @p_hwfn: HW device data.
0462  * @p_ptt: PTT required for register access.
0463  * @p_flash_size: Flash size in bytes to be filled.
0464  *
0465  * Return: Int - 0 - Operation was successul.
0466  */
0467 int qed_mcp_get_flash_size(struct qed_hwfn     *p_hwfn,
0468                struct qed_ptt       *p_ptt,
0469                u32 *p_flash_size);
0470 
0471 /**
0472  * qed_mcp_send_drv_version(): Send driver version to MFW.
0473  *
0474  * @p_hwfn: HW device data.
0475  * @p_ptt: PTT required for register access.
0476  * @p_ver: Version value.
0477  *
0478  * Return: Int - 0 - Operation was successul.
0479  */
0480 int
0481 qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
0482              struct qed_ptt *p_ptt,
0483              struct qed_mcp_drv_version *p_ver);
0484 
0485 /**
0486  * qed_get_process_kill_counter(): Read the MFW process kill counter.
0487  *
0488  * @p_hwfn: HW device data.
0489  * @p_ptt: PTT required for register access.
0490  *
0491  * Return: u32.
0492  */
0493 u32 qed_get_process_kill_counter(struct qed_hwfn *p_hwfn,
0494                  struct qed_ptt *p_ptt);
0495 
0496 /**
0497  * qed_start_recovery_process(): Trigger a recovery process.
0498  *
0499  * @p_hwfn: HW device data.
0500  * @p_ptt: PTT required for register access.
0501  *
0502  * Return: Int.
0503  */
0504 int qed_start_recovery_process(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0505 
0506 /**
0507  * qed_recovery_prolog(): A recovery handler must call this function
0508  *                        as its first step.
0509  *                        It is assumed that the handler is not run from
0510  *                        an interrupt context.
0511  *
0512  * @cdev: Qed dev pointer.
0513  *
0514  * Return: int.
0515  */
0516 int qed_recovery_prolog(struct qed_dev *cdev);
0517 
0518 /**
0519  * qed_mcp_ov_update_current_config(): Notify MFW about the change in base
0520  *                                    device properties
0521  *
0522  * @p_hwfn: HW device data.
0523  * @p_ptt: P_ptt.
0524  * @client: Qed client type.
0525  *
0526  * Return: Int - 0 - Operation was successul.
0527  */
0528 int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
0529                      struct qed_ptt *p_ptt,
0530                      enum qed_ov_client client);
0531 
0532 /**
0533  * qed_mcp_ov_update_driver_state(): Notify MFW about the driver state.
0534  *
0535  * @p_hwfn: HW device data.
0536  * @p_ptt: P_ptt.
0537  * @drv_state: Driver state.
0538  *
0539  * Return: Int - 0 - Operation was successul.
0540  */
0541 int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
0542                    struct qed_ptt *p_ptt,
0543                    enum qed_ov_driver_state drv_state);
0544 
0545 /**
0546  * qed_mcp_ov_update_mtu(): Send MTU size to MFW.
0547  *
0548  * @p_hwfn: HW device data.
0549  * @p_ptt: P_ptt.
0550  * @mtu: MTU size.
0551  *
0552  * Return: Int - 0 - Operation was successul.
0553  */
0554 int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
0555               struct qed_ptt *p_ptt, u16 mtu);
0556 
0557 /**
0558  * qed_mcp_ov_update_mac(): Send MAC address to MFW.
0559  *
0560  * @p_hwfn: HW device data.
0561  * @p_ptt: P_ptt.
0562  * @mac: MAC address.
0563  *
0564  * Return: Int - 0 - Operation was successul.
0565  */
0566 int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
0567               struct qed_ptt *p_ptt, const u8 *mac);
0568 
0569 /**
0570  * qed_mcp_ov_update_wol(): Send WOL mode to MFW.
0571  *
0572  * @p_hwfn: HW device data.
0573  * @p_ptt: P_ptt.
0574  * @wol: WOL mode.
0575  *
0576  * Return: Int - 0 - Operation was successul.
0577  */
0578 int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
0579               struct qed_ptt *p_ptt,
0580               enum qed_ov_wol wol);
0581 
0582 /**
0583  * qed_mcp_set_led(): Set LED status.
0584  *
0585  * @p_hwfn: HW device data.
0586  * @p_ptt: P_ptt.
0587  * @mode: LED mode.
0588  *
0589  * Return: Int - 0 - Operation was successul.
0590  */
0591 int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
0592             struct qed_ptt *p_ptt,
0593             enum qed_led_mode mode);
0594 
0595 /**
0596  * qed_mcp_nvm_read(): Read from NVM.
0597  *
0598  * @cdev: Qed dev pointer.
0599  * @addr: NVM offset.
0600  * @p_buf: NVM read buffer.
0601  * @len: Buffer len.
0602  *
0603  * Return: Int - 0 - Operation was successul.
0604  */
0605 int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
0606 
0607 /**
0608  * qed_mcp_nvm_write(): Write to NVM.
0609  *
0610  * @cdev: Qed dev pointer.
0611  * @addr: NVM offset.
0612  * @cmd: NVM command.
0613  * @p_buf: NVM write buffer.
0614  * @len: Buffer len.
0615  *
0616  * Return: Int - 0 - Operation was successul.
0617  */
0618 int qed_mcp_nvm_write(struct qed_dev *cdev,
0619               u32 cmd, u32 addr, u8 *p_buf, u32 len);
0620 
0621 /**
0622  * qed_mcp_nvm_resp(): Check latest response.
0623  *
0624  * @cdev: Qed dev pointer.
0625  * @p_buf: NVM write buffer.
0626  *
0627  * Return: Int - 0 - Operation was successul.
0628  */
0629 int qed_mcp_nvm_resp(struct qed_dev *cdev, u8 *p_buf);
0630 
0631 struct qed_nvm_image_att {
0632     u32 start_addr;
0633     u32 length;
0634 };
0635 
0636 /**
0637  * qed_mcp_get_nvm_image_att(): Allows reading a whole nvram image.
0638  *
0639  * @p_hwfn: HW device data.
0640  * @image_id: Image to get attributes for.
0641  * @p_image_att: Image attributes structure into which to fill data.
0642  *
0643  * Return: Int - 0 - Operation was successul.
0644  */
0645 int
0646 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
0647               enum qed_nvm_images image_id,
0648               struct qed_nvm_image_att *p_image_att);
0649 
0650 /**
0651  * qed_mcp_get_nvm_image(): Allows reading a whole nvram image.
0652  *
0653  * @p_hwfn: HW device data.
0654  * @image_id: image requested for reading.
0655  * @p_buffer: allocated buffer into which to fill data.
0656  * @buffer_len: length of the allocated buffer.
0657  *
0658  * Return: 0 if p_buffer now contains the nvram image.
0659  */
0660 int qed_mcp_get_nvm_image(struct qed_hwfn *p_hwfn,
0661               enum qed_nvm_images image_id,
0662               u8 *p_buffer, u32 buffer_len);
0663 
0664 /**
0665  * qed_mcp_bist_register_test(): Bist register test.
0666  *
0667  * @p_hwfn: HW device data.
0668  * @p_ptt: PTT required for register access.
0669  *
0670  * Return: Int - 0 - Operation was successul.
0671  */
0672 int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
0673                    struct qed_ptt *p_ptt);
0674 
0675 /**
0676  * qed_mcp_bist_clock_test(): Bist clock test.
0677  *
0678  * @p_hwfn: HW device data.
0679  * @p_ptt: PTT required for register access.
0680  *
0681  * Return: Int - 0 - Operation was successul.
0682  */
0683 int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
0684                 struct qed_ptt *p_ptt);
0685 
0686 /**
0687  * qed_mcp_bist_nvm_get_num_images(): Bist nvm test - get number of images.
0688  *
0689  * @p_hwfn: HW device data.
0690  * @p_ptt: PTT required for register access.
0691  * @num_images: number of images if operation was
0692  *            successful. 0 if not.
0693  *
0694  * Return: Int - 0 - Operation was successul.
0695  */
0696 int qed_mcp_bist_nvm_get_num_images(struct qed_hwfn *p_hwfn,
0697                     struct qed_ptt *p_ptt,
0698                     u32 *num_images);
0699 
0700 /**
0701  * qed_mcp_bist_nvm_get_image_att(): Bist nvm test - get image attributes
0702  *                                   by index.
0703  *
0704  * @p_hwfn: HW device data.
0705  * @p_ptt: PTT required for register access.
0706  * @p_image_att: Attributes of image.
0707  * @image_index: Index of image to get information for.
0708  *
0709  * Return: Int - 0 - Operation was successul.
0710  */
0711 int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
0712                    struct qed_ptt *p_ptt,
0713                    struct bist_nvm_image_att *p_image_att,
0714                    u32 image_index);
0715 
0716 /**
0717  * qed_mfw_process_tlv_req(): Processes the TLV request from MFW i.e.,
0718  *                            get the required TLV info
0719  *                            from the qed client and send it to the MFW.
0720  *
0721  * @p_hwfn: HW device data.
0722  * @p_ptt: P_ptt.
0723  *
0724  * Return: 0 upon success.
0725  */
0726 int qed_mfw_process_tlv_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0727 
0728 /**
0729  * qed_mcp_send_raw_debug_data(): Send raw debug data to the MFW
0730  *
0731  * @p_hwfn: HW device data.
0732  * @p_ptt: P_ptt.
0733  * @p_buf: raw debug data buffer.
0734  * @size: Buffer size.
0735  *
0736  * Return : Int.
0737  */
0738 int
0739 qed_mcp_send_raw_debug_data(struct qed_hwfn *p_hwfn,
0740                 struct qed_ptt *p_ptt, u8 *p_buf, u32 size);
0741 
0742 /* Using hwfn number (and not pf_num) is required since in CMT mode,
0743  * same pf_num may be used by two different hwfn
0744  * TODO - this shouldn't really be in .h file, but until all fields
0745  * required during hw-init will be placed in their correct place in shmem
0746  * we need it in qed_dev.c [for readin the nvram reflection in shmem].
0747  */
0748 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ?        \
0749                         ((rel_pfid) |              \
0750                          ((p_hwfn)->abs_pf_id & 1) << 3) : \
0751                         rel_pfid)
0752 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
0753 
0754 struct qed_mcp_info {
0755     /* List for mailbox commands which were sent and wait for a response */
0756     struct list_head            cmd_list;
0757 
0758     /* Spinlock used for protecting the access to the mailbox commands list
0759      * and the sending of the commands.
0760      */
0761     spinlock_t              cmd_lock;
0762 
0763     /* Flag to indicate whether sending a MFW mailbox command is blocked */
0764     bool                    b_block_cmd;
0765 
0766     /* Spinlock used for syncing SW link-changes and link-changes
0767      * originating from attention context.
0768      */
0769     spinlock_t              link_lock;
0770 
0771     u32                 public_base;
0772     u32                 drv_mb_addr;
0773     u32                 mfw_mb_addr;
0774     u32                 port_addr;
0775     u16                 drv_mb_seq;
0776     u16                 drv_pulse_seq;
0777     struct qed_mcp_link_params      link_input;
0778     struct qed_mcp_link_state       link_output;
0779     struct qed_mcp_link_capabilities    link_capabilities;
0780     struct qed_mcp_function_info        func_info;
0781     u8                  *mfw_mb_cur;
0782     u8                  *mfw_mb_shadow;
0783     u16                 mfw_mb_length;
0784     u32                 mcp_hist;
0785 
0786     /* Capabilties negotiated with the MFW */
0787     u32                 capabilities;
0788 
0789     /* S/N for debug data mailbox commands */
0790     atomic_t dbg_data_seq;
0791 
0792     /* Spinlock used to sync the flag mcp_handling_status with
0793      * the mfw events handler
0794      */
0795     spinlock_t unload_lock;
0796     unsigned long mcp_handling_status;
0797 #define QED_MCP_BYPASS_PROC_BIT 0
0798 #define QED_MCP_IN_PROCESSING_BIT       1
0799 };
0800 
0801 struct qed_mcp_mb_params {
0802     u32 cmd;
0803     u32 param;
0804     void *p_data_src;
0805     void *p_data_dst;
0806     u8 data_src_size;
0807     u8 data_dst_size;
0808     u32 mcp_resp;
0809     u32 mcp_param;
0810     u32 flags;
0811 #define QED_MB_FLAG_CAN_SLEEP   (0x1 << 0)
0812 #define QED_MB_FLAG_AVOID_BLOCK (0x1 << 1)
0813 #define QED_MB_FLAGS_IS_SET(params, flag) \
0814     ({ typeof(params) __params = (params); \
0815        (__params && (__params->flags & QED_MB_FLAG_ ## flag)); })
0816 };
0817 
0818 struct qed_drv_tlv_hdr {
0819     u8 tlv_type;
0820     u8 tlv_length;  /* In dwords - not including this header */
0821     u8 tlv_reserved;
0822 #define QED_DRV_TLV_FLAGS_CHANGED 0x01
0823     u8 tlv_flags;
0824 };
0825 
0826 /**
0827  * qed_mcp_is_ext_speed_supported() - Check if management firmware supports
0828  *                                    extended speeds.
0829  * @p_hwfn: HW device data.
0830  *
0831  * Return: true if supported, false otherwise.
0832  */
0833 static inline bool
0834 qed_mcp_is_ext_speed_supported(const struct qed_hwfn *p_hwfn)
0835 {
0836     return !!(p_hwfn->mcp_info->capabilities &
0837           FW_MB_PARAM_FEATURE_SUPPORT_EXT_SPEED_FEC_CONTROL);
0838 }
0839 
0840 /**
0841  * qed_mcp_cmd_init(): Initialize the interface with the MCP.
0842  *
0843  * @p_hwfn: HW device data.
0844  * @p_ptt: PTT required for register access.
0845  *
0846  * Return: Int.
0847  */
0848 int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
0849              struct qed_ptt *p_ptt);
0850 
0851 /**
0852  * qed_mcp_cmd_port_init(): Initialize the port interface with the MCP
0853  *
0854  * @p_hwfn: HW device data.
0855  * @p_ptt: P_ptt.
0856  *
0857  * Return: Void.
0858  *
0859  * Can only be called after `num_ports_in_engines' is set
0860  */
0861 void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
0862                struct qed_ptt *p_ptt);
0863 /**
0864  * qed_mcp_free(): Releases resources allocated during the init process.
0865  *
0866  * @p_hwfn: HW function.
0867  *
0868  * Return: Int.
0869  */
0870 
0871 int qed_mcp_free(struct qed_hwfn *p_hwfn);
0872 
0873 /**
0874  * qed_mcp_handle_events(): This function is called from the DPC context.
0875  *           After pointing PTT to the mfw mb, check for events sent by
0876  *           the MCP to the driver and ack them. In case a critical event
0877  *           detected, it will be handled here, otherwise the work will be
0878  *            queued to a sleepable work-queue.
0879  *
0880  * @p_hwfn: HW function.
0881  * @p_ptt: PTT required for register access.
0882  *
0883  * Return: Int - 0 - Operation was successul.
0884  */
0885 int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
0886               struct qed_ptt *p_ptt);
0887 
0888 enum qed_drv_role {
0889     QED_DRV_ROLE_OS,
0890     QED_DRV_ROLE_KDUMP,
0891 };
0892 
0893 struct qed_load_req_params {
0894     /* Input params */
0895     enum qed_drv_role drv_role;
0896     u8 timeout_val;
0897     bool avoid_eng_reset;
0898     enum qed_override_force_load override_force_load;
0899 
0900     /* Output params */
0901     u32 load_code;
0902 };
0903 
0904 /**
0905  * qed_mcp_load_req(): Sends a LOAD_REQ to the MFW, and in case the
0906  *                     operation succeeds, returns whether this PF is
0907  *                     the first on the engine/port or function.
0908  *
0909  * @p_hwfn: HW device data.
0910  * @p_ptt: P_ptt.
0911  * @p_params: Params.
0912  *
0913  * Return: Int - 0 - Operation was successul.
0914  */
0915 int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
0916              struct qed_ptt *p_ptt,
0917              struct qed_load_req_params *p_params);
0918 
0919 /**
0920  * qed_mcp_load_done(): Sends a LOAD_DONE message to the MFW.
0921  *
0922  * @p_hwfn: HW device data.
0923  * @p_ptt: P_ptt.
0924  *
0925  * Return: Int - 0 - Operation was successul.
0926  */
0927 int qed_mcp_load_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0928 
0929 /**
0930  * qed_mcp_unload_req(): Sends a UNLOAD_REQ message to the MFW.
0931  *
0932  * @p_hwfn: HW device data.
0933  * @p_ptt: P_ptt.
0934  *
0935  * Return: Int - 0 - Operation was successul.
0936  */
0937 int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0938 
0939 /**
0940  * qed_mcp_unload_done(): Sends a UNLOAD_DONE message to the MFW
0941  *
0942  * @p_hwfn: HW device data.
0943  * @p_ptt: P_ptt.
0944  *
0945  * Return: Int - 0 - Operation was successul.
0946  */
0947 int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0948 
0949 /**
0950  * qed_mcp_read_mb(): Read the MFW mailbox into Current buffer.
0951  *
0952  * @p_hwfn: HW device data.
0953  * @p_ptt: P_ptt.
0954  *
0955  * Return: Void.
0956  */
0957 void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
0958              struct qed_ptt *p_ptt);
0959 
0960 /**
0961  * qed_mcp_ack_vf_flr(): Ack to mfw that driver finished FLR process for VFs
0962  *
0963  * @p_hwfn: HW device data.
0964  * @p_ptt: P_ptt.
0965  * @vfs_to_ack: bit mask of all engine VFs for which the PF acks.
0966  *
0967  * Return: Int - 0 - Operation was successul.
0968  */
0969 int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
0970                struct qed_ptt *p_ptt, u32 *vfs_to_ack);
0971 
0972 /**
0973  * qed_mcp_fill_shmem_func_info(): Calls during init to read shmem of
0974  *                                 all function-related info.
0975  *
0976  * @p_hwfn: HW device data.
0977  * @p_ptt: P_ptt.
0978  *
0979  * Return: 0 upon success.
0980  */
0981 int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
0982                  struct qed_ptt *p_ptt);
0983 
0984 /**
0985  * qed_mcp_reset(): Reset the MCP using mailbox command.
0986  *
0987  * @p_hwfn: HW device data.
0988  * @p_ptt: P_ptt.
0989  *
0990  * Return: 0 upon success.
0991  */
0992 int qed_mcp_reset(struct qed_hwfn *p_hwfn,
0993           struct qed_ptt *p_ptt);
0994 
0995 /**
0996  * qed_mcp_nvm_rd_cmd(): Sends an NVM read command request to the MFW to get
0997  *                       a buffer.
0998  *
0999  * @p_hwfn: HW device data.
1000  * @p_ptt: P_ptt.
1001  * @cmd: (Command) DRV_MSG_CODE_NVM_GET_FILE_DATA or
1002  *            DRV_MSG_CODE_NVM_READ_NVRAM commands.
1003  * @param: [0:23] - Offset [24:31] - Size.
1004  * @o_mcp_resp: MCP response.
1005  * @o_mcp_param: MCP response param.
1006  * @o_txn_size: Buffer size output.
1007  * @o_buf: Pointer to the buffer returned by the MFW.
1008  * @b_can_sleep: Can sleep.
1009  *
1010  * Return: 0 upon success.
1011  */
1012 int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
1013                struct qed_ptt *p_ptt,
1014                u32 cmd,
1015                u32 param,
1016                u32 *o_mcp_resp,
1017                u32 *o_mcp_param,
1018                u32 *o_txn_size, u32 *o_buf, bool b_can_sleep);
1019 
1020 /**
1021  * qed_mcp_phy_sfp_read(): Read from sfp.
1022  *
1023  * @p_hwfn: HW device data.
1024  * @p_ptt: PTT required for register access.
1025  * @port: transceiver port.
1026  * @addr: I2C address.
1027  * @offset: offset in sfp.
1028  * @len: buffer length.
1029  * @p_buf: buffer to read into.
1030  *
1031  * Return: Int - 0 - Operation was successul.
1032  */
1033 int qed_mcp_phy_sfp_read(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1034              u32 port, u32 addr, u32 offset, u32 len, u8 *p_buf);
1035 
1036 /**
1037  * qed_mcp_is_init(): indicates whether the MFW objects [under mcp_info]
1038  *                    are accessible
1039  *
1040  * @p_hwfn: HW device data.
1041  *
1042  * Return: true if MFW is running and mcp_info is initialized.
1043  */
1044 bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
1045 
1046 /**
1047  * qed_mcp_config_vf_msix(): Request MFW to configure MSI-X for a VF.
1048  *
1049  * @p_hwfn: HW device data.
1050  * @p_ptt: P_ptt.
1051  * @vf_id: absolute inside engine.
1052  * @num: number of entries to request.
1053  *
1054  * Return: Int.
1055  */
1056 int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
1057                struct qed_ptt *p_ptt, u8 vf_id, u8 num);
1058 
1059 /**
1060  * qed_mcp_halt(): Halt the MCP.
1061  *
1062  * @p_hwfn: HW device data.
1063  * @p_ptt: P_ptt.
1064  *
1065  * Return: 0 upon success.
1066  */
1067 int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1068 
1069 /**
1070  * qed_mcp_resume: Wake up the MCP.
1071  *
1072  * @p_hwfn: HW device data.
1073  * @p_ptt: P_ptt.
1074  *
1075  * Return: 0 upon success.
1076  */
1077 int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1078 
1079 int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
1080 int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
1081 int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
1082                      struct qed_ptt *p_ptt,
1083                      struct qed_mcp_link_state *p_link,
1084                      u8 max_bw);
1085 int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
1086                      struct qed_ptt *p_ptt,
1087                      struct qed_mcp_link_state *p_link,
1088                      u8 min_bw);
1089 
1090 int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
1091               struct qed_ptt *p_ptt, u32 mask_parities);
1092 
1093 /* qed_mcp_mdump_get_retain(): Gets the mdump retained data from the MFW.
1094  *
1095  * @p_hwfn: HW device data.
1096  * @p_ptt: P_ptt.
1097  * @p_mdump_retain: mdump retain.
1098  *
1099  * Return: Int - 0 - Operation was successul.
1100  */
1101 int
1102 qed_mcp_mdump_get_retain(struct qed_hwfn *p_hwfn,
1103              struct qed_ptt *p_ptt,
1104              struct mdump_retain_data_stc *p_mdump_retain);
1105 
1106 /**
1107  * qed_mcp_set_resc_max_val(): Sets the MFW's max value for the given resource.
1108  *
1109  * @p_hwfn: HW device data.
1110  * @p_ptt: P_ptt.
1111  * @res_id: RES ID.
1112  * @resc_max_val: Resec max val.
1113  * @p_mcp_resp: MCP Resp
1114  *
1115  * Return: Int - 0 - Operation was successul.
1116  */
1117 int
1118 qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
1119              struct qed_ptt *p_ptt,
1120              enum qed_resources res_id,
1121              u32 resc_max_val, u32 *p_mcp_resp);
1122 
1123 /**
1124  * qed_mcp_get_resc_info(): Gets the MFW allocation info for the given
1125  *                          resource.
1126  *
1127  * @p_hwfn: HW device data.
1128  * @p_ptt: P_ptt.
1129  * @res_id: Res ID.
1130  * @p_mcp_resp: MCP resp.
1131  * @p_resc_num: Resc num.
1132  * @p_resc_start: Resc start.
1133  *
1134  * Return: Int - 0 - Operation was successul.
1135  */
1136 int
1137 qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
1138               struct qed_ptt *p_ptt,
1139               enum qed_resources res_id,
1140               u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start);
1141 
1142 /**
1143  * qed_mcp_ov_update_eswitch(): Send eswitch mode to MFW.
1144  *
1145  * @p_hwfn: HW device data.
1146  * @p_ptt: P_ptt.
1147  * @eswitch: eswitch mode.
1148  *
1149  * Return: Int - 0 - Operation was successul.
1150  */
1151 int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
1152                   struct qed_ptt *p_ptt,
1153                   enum qed_ov_eswitch eswitch);
1154 
1155 #define QED_MCP_RESC_LOCK_MIN_VAL       RESOURCE_DUMP
1156 #define QED_MCP_RESC_LOCK_MAX_VAL       31
1157 
1158 enum qed_resc_lock {
1159     QED_RESC_LOCK_DBG_DUMP = QED_MCP_RESC_LOCK_MIN_VAL,
1160     QED_RESC_LOCK_PTP_PORT0,
1161     QED_RESC_LOCK_PTP_PORT1,
1162     QED_RESC_LOCK_PTP_PORT2,
1163     QED_RESC_LOCK_PTP_PORT3,
1164     QED_RESC_LOCK_RESC_ALLOC = QED_MCP_RESC_LOCK_MAX_VAL,
1165     QED_RESC_LOCK_RESC_INVALID
1166 };
1167 
1168 /**
1169  * qed_mcp_initiate_pf_flr(): Initiates PF FLR.
1170  *
1171  * @p_hwfn: HW device data.
1172  * @p_ptt: P_ptt.
1173  *
1174  * Return: Int - 0 - Operation was successul.
1175  */
1176 int qed_mcp_initiate_pf_flr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1177 struct qed_resc_lock_params {
1178     /* Resource number [valid values are 0..31] */
1179     u8 resource;
1180 
1181     /* Lock timeout value in seconds [default, none or 1..254] */
1182     u8 timeout;
1183 #define QED_MCP_RESC_LOCK_TO_DEFAULT    0
1184 #define QED_MCP_RESC_LOCK_TO_NONE       255
1185 
1186     /* Number of times to retry locking */
1187     u8 retry_num;
1188 #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT        10
1189 
1190     /* The interval in usec between retries */
1191     u16 retry_interval;
1192 #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT        10000
1193 
1194     /* Use sleep or delay between retries */
1195     bool sleep_b4_retry;
1196 
1197     /* Will be set as true if the resource is free and granted */
1198     bool b_granted;
1199 
1200     /* Will be filled with the resource owner.
1201      * [0..15 = PF0-15, 16 = MFW]
1202      */
1203     u8 owner;
1204 };
1205 
1206 /**
1207  * qed_mcp_resc_lock(): Acquires MFW generic resource lock.
1208  *
1209  * @p_hwfn: HW device data.
1210  * @p_ptt: P_ptt.
1211  * @p_params: Params.
1212  *
1213  * Return: Int - 0 - Operation was successul.
1214  */
1215 int
1216 qed_mcp_resc_lock(struct qed_hwfn *p_hwfn,
1217           struct qed_ptt *p_ptt, struct qed_resc_lock_params *p_params);
1218 
1219 struct qed_resc_unlock_params {
1220     /* Resource number [valid values are 0..31] */
1221     u8 resource;
1222 
1223     /* Allow to release a resource even if belongs to another PF */
1224     bool b_force;
1225 
1226     /* Will be set as true if the resource is released */
1227     bool b_released;
1228 };
1229 
1230 /**
1231  * qed_mcp_resc_unlock(): Releases MFW generic resource lock.
1232  *
1233  * @p_hwfn: HW device data.
1234  * @p_ptt: P_ptt.
1235  * @p_params: Params.
1236  *
1237  * Return: Int - 0 - Operation was successul.
1238  */
1239 int
1240 qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
1241             struct qed_ptt *p_ptt,
1242             struct qed_resc_unlock_params *p_params);
1243 
1244 /**
1245  * qed_mcp_resc_lock_default_init(): Default initialization for
1246  *                                   lock/unlock resource structs.
1247  *
1248  * @p_lock: lock params struct to be initialized; Can be NULL.
1249  * @p_unlock: unlock params struct to be initialized; Can be NULL.
1250  * @resource: the requested resource.
1251  * @b_is_permanent: disable retries & aging when set.
1252  *
1253  * Return: Void.
1254  */
1255 void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params *p_lock,
1256                     struct qed_resc_unlock_params *p_unlock,
1257                     enum qed_resc_lock
1258                     resource, bool b_is_permanent);
1259 
1260 /**
1261  * qed_mcp_is_smart_an_supported(): Return whether management firmware
1262  *                                  support smart AN
1263  *
1264  * @p_hwfn: HW device data.
1265  *
1266  * Return: bool true if feature is supported.
1267  */
1268 bool qed_mcp_is_smart_an_supported(struct qed_hwfn *p_hwfn);
1269 
1270 /**
1271  * qed_mcp_get_capabilities(): Learn of supported MFW features;
1272  *                             To be done during early init.
1273  *
1274  * @p_hwfn: HW device data.
1275  * @p_ptt: P_ptt.
1276  *
1277  * Return: Int.
1278  */
1279 int qed_mcp_get_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1280 
1281 /**
1282  * qed_mcp_set_capabilities(): Inform MFW of set of features supported
1283  *                             by driver. Should be done inside the content
1284  *                             of the LOAD_REQ.
1285  *
1286  * @p_hwfn: HW device data.
1287  * @p_ptt: P_ptt.
1288  *
1289  * Return: Int.
1290  */
1291 int qed_mcp_set_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1292 
1293 /**
1294  * qed_mcp_read_ufp_config(): Read ufp config from the shared memory.
1295  *
1296  * @p_hwfn: HW device data.
1297  * @p_ptt: P_ptt.
1298  *
1299  * Return: Void.
1300  */
1301 void qed_mcp_read_ufp_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1302 
1303 /**
1304  * qed_mcp_nvm_info_populate(): Populate the nvm info shadow in the given
1305  *                              hardware function.
1306  *
1307  * @p_hwfn: HW device data.
1308  *
1309  * Return: Int.
1310  */
1311 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
1312 
1313 /**
1314  * qed_mcp_nvm_info_free(): Delete nvm info shadow in the given
1315  *                          hardware function.
1316  *
1317  * @p_hwfn: HW device data.
1318  *
1319  * Return: Void.
1320  */
1321 void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn);
1322 
1323 /**
1324  * qed_mcp_get_engine_config(): Get the engine affinity configuration.
1325  *
1326  * @p_hwfn: HW device data.
1327  * @p_ptt: P_ptt.
1328  *
1329  * Return: Int.
1330  */
1331 int qed_mcp_get_engine_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1332 
1333 /**
1334  * qed_mcp_get_ppfid_bitmap(): Get the PPFID bitmap.
1335  *
1336  * @p_hwfn: HW device data.
1337  * @p_ptt: P_ptt.
1338  *
1339  * Return: Int.
1340  */
1341 int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
1342 
1343 /**
1344  * qed_mcp_nvm_get_cfg(): Get NVM config attribute value.
1345  *
1346  * @p_hwfn: HW device data.
1347  * @p_ptt: P_ptt.
1348  * @option_id: Option ID.
1349  * @entity_id: Entity ID.
1350  * @flags: Flags.
1351  * @p_buf: Buf.
1352  * @p_len: Len.
1353  *
1354  * Return: Int.
1355  */
1356 int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1357             u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
1358             u32 *p_len);
1359 
1360 /**
1361  * qed_mcp_nvm_set_cfg(): Set NVM config attribute value.
1362  *
1363  * @p_hwfn: HW device data.
1364  * @p_ptt: P_ptt.
1365  * @option_id: Option ID.
1366  * @entity_id: Entity ID.
1367  * @flags: Flags.
1368  * @p_buf: Buf.
1369  * @len: Len.
1370  *
1371  * Return: Int.
1372  */
1373 int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1374             u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
1375             u32 len);
1376 
1377 /**
1378  * qed_mcp_is_esl_supported(): Return whether management firmware support ESL or not.
1379  *
1380  * @p_hwfn: hw function pointer
1381  *
1382  * Return: true if esl is supported, otherwise return false
1383  */
1384 bool qed_mcp_is_esl_supported(struct qed_hwfn *p_hwfn);
1385 
1386 /**
1387  * qed_mcp_get_esl_status(): Get enhanced system lockdown status
1388  *
1389  * @p_hwfn: hw function pointer
1390  * @p_ptt: ptt resource pointer
1391  * @active: ESL active status data pointer
1392  *
1393  * Return: 0 with esl status info on success, otherwise return error
1394  */
1395 int qed_mcp_get_esl_status(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, bool *active);
1396 #endif