]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bnxt_en: Add support for RoCE sriov configuration
authorVikas Gupta <vikas.gupta@broadcom.com>
Wed, 6 Nov 2024 08:44:34 +0000 (00:44 -0800)
committerLeon Romanovsky <leon@kernel.org>
Tue, 12 Nov 2024 08:04:04 +0000 (03:04 -0500)
During driver load, PF RDMA driver provisions resources
to the RDMA VFs. This logic takes into consideration of
the total number of VFs supported on the PF while
allocating resources. Firmware now advertises a capability
where NIC driver can allocate resources for RDMA VFs when
the user actually creates a VF. So this resource
distribution can be based on the number of active VFs.

This patch adds the support to check for the firmware
capability and follow the new RDMA VF resource allocation
strategy. The current logic in the RDMA driver will be
removed for the newer Firmware versions in a subsequent
patch in this series.

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Selvin Xavier <selvin.xavier@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Link: https://patch.msgid.link/1730882676-24434-2-git-send-email-selvin.xavier@broadcom.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

index 6e422e24750a281b9337ef3cc443b2dbe7af5abb..70230c53d7b8d76423f119a41694ca80c5d1865a 100644 (file)
@@ -8151,6 +8151,9 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
        if (flags & FUNC_QCFG_RESP_FLAGS_RING_MONITOR_ENABLED)
                bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR;
 
+       if (flags & FUNC_QCFG_RESP_FLAGS_ENABLE_RDMA_SRIOV)
+               bp->fw_cap |= BNXT_FW_CAP_ENABLE_RDMA_SRIOV;
+
        switch (resp->port_partition_type) {
        case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0:
        case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_5:
@@ -9177,6 +9180,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
                bp->flags |= BNXT_FLAG_UDP_GSO_CAP;
        if (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_TX_PKT_TS_CMPL_SUPPORTED)
                bp->fw_cap |= BNXT_FW_CAP_TX_TS_CMP;
+       if (BNXT_PF(bp) &&
+           (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_ROCE_VF_RESOURCE_MGMT_SUPPORTED))
+               bp->fw_cap |= BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED;
 
        bp->tx_push_thresh = 0;
        if ((flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED) &&
index 69231e85140b2e25401f978c9d533199facc9990..2da6c7ba5238359d1834abca38075ac1c552e949 100644 (file)
@@ -2406,6 +2406,8 @@ struct bnxt {
        #define BNXT_FW_CAP_DCBX_AGENT                  BIT_ULL(2)
        #define BNXT_FW_CAP_NEW_RM                      BIT_ULL(3)
        #define BNXT_FW_CAP_IF_CHANGE                   BIT_ULL(4)
+       #define BNXT_FW_CAP_ENABLE_RDMA_SRIOV           BIT_ULL(5)
+       #define BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED BIT_ULL(6)
        #define BNXT_FW_CAP_KONG_MB_CHNL                BIT_ULL(7)
        #define BNXT_FW_CAP_OVS_64BIT_HANDLE            BIT_ULL(10)
        #define BNXT_FW_CAP_TRUSTED_VF                  BIT_ULL(11)
@@ -2452,6 +2454,10 @@ struct bnxt {
 #define BNXT_SUPPORTS_QUEUE_API(bp)                            \
        (BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) &&        \
         ((bp)->fw_cap & BNXT_FW_CAP_VNIC_RE_FLUSH))
+#define BNXT_RDMA_SRIOV_EN(bp)         \
+       ((bp)->fw_cap & BNXT_FW_CAP_ENABLE_RDMA_SRIOV)
+#define BNXT_ROCE_VF_RESC_CAP(bp)      \
+       ((bp)->fw_cap & BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED)
 
        u32                     hwrm_spec_code;
        u16                     hwrm_cmd_seq;
index 7bb8a5d744308ae74b6a517ddd7fa16817e16da3..12b6ed51fd884c1069f7db271e1edb026b0d1221 100644 (file)
@@ -520,6 +520,56 @@ static int __bnxt_set_vf_params(struct bnxt *bp, int vf_id)
        return hwrm_req_send(bp, req);
 }
 
+static void bnxt_hwrm_roce_sriov_cfg(struct bnxt *bp, int num_vfs)
+{
+       struct hwrm_func_qcaps_output *resp;
+       struct hwrm_func_cfg_input *cfg_req;
+       struct hwrm_func_qcaps_input *req;
+       int rc;
+
+       rc = hwrm_req_init(bp, req, HWRM_FUNC_QCAPS);
+       if (rc)
+               return;
+
+       req->fid = cpu_to_le16(0xffff);
+       resp = hwrm_req_hold(bp, req);
+       rc = hwrm_req_send(bp, req);
+       if (rc)
+               goto err;
+
+       rc = hwrm_req_init(bp, cfg_req, HWRM_FUNC_CFG);
+       if (rc)
+               goto err;
+
+       cfg_req->fid = cpu_to_le16(0xffff);
+       cfg_req->enables2 =
+               cpu_to_le32(FUNC_CFG_REQ_ENABLES2_ROCE_MAX_AV_PER_VF |
+                           FUNC_CFG_REQ_ENABLES2_ROCE_MAX_CQ_PER_VF |
+                           FUNC_CFG_REQ_ENABLES2_ROCE_MAX_MRW_PER_VF |
+                           FUNC_CFG_REQ_ENABLES2_ROCE_MAX_QP_PER_VF |
+                           FUNC_CFG_REQ_ENABLES2_ROCE_MAX_SRQ_PER_VF |
+                           FUNC_CFG_REQ_ENABLES2_ROCE_MAX_GID_PER_VF);
+       cfg_req->roce_max_av_per_vf =
+               cpu_to_le32(le32_to_cpu(resp->roce_vf_max_av) / num_vfs);
+       cfg_req->roce_max_cq_per_vf =
+               cpu_to_le32(le32_to_cpu(resp->roce_vf_max_cq) / num_vfs);
+       cfg_req->roce_max_mrw_per_vf =
+               cpu_to_le32(le32_to_cpu(resp->roce_vf_max_mrw) / num_vfs);
+       cfg_req->roce_max_qp_per_vf =
+               cpu_to_le32(le32_to_cpu(resp->roce_vf_max_qp) / num_vfs);
+       cfg_req->roce_max_srq_per_vf =
+               cpu_to_le32(le32_to_cpu(resp->roce_vf_max_srq) / num_vfs);
+       cfg_req->roce_max_gid_per_vf =
+               cpu_to_le32(le32_to_cpu(resp->roce_vf_max_gid) / num_vfs);
+
+       rc = hwrm_req_send(bp, cfg_req);
+
+err:
+       hwrm_req_drop(bp, req);
+       if (rc)
+               netdev_err(bp->dev, "RoCE sriov configuration failed\n");
+}
+
 /* Only called by PF to reserve resources for VFs, returns actual number of
  * VFs configured, or < 0 on error.
  */
@@ -759,6 +809,9 @@ int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)
                *num_vfs = rc;
        }
 
+       if (BNXT_RDMA_SRIOV_EN(bp) && BNXT_ROCE_VF_RESC_CAP(bp))
+               bnxt_hwrm_roce_sriov_cfg(bp, *num_vfs);
+
        return 0;
 }