Skip to content

Commit 53371c5

Browse files
vikasbrcmrleon
authored andcommitted
bnxt_en: Add support for RoCE sriov configuration
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 <[email protected]> Reviewed-by: Selvin Xavier <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Reviewed-by: Michael Chan <[email protected]> Signed-off-by: Kalesh AP <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 6b526d1 commit 53371c5

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8151,6 +8151,9 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
81518151
if (flags & FUNC_QCFG_RESP_FLAGS_RING_MONITOR_ENABLED)
81528152
bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR;
81538153

8154+
if (flags & FUNC_QCFG_RESP_FLAGS_ENABLE_RDMA_SRIOV)
8155+
bp->fw_cap |= BNXT_FW_CAP_ENABLE_RDMA_SRIOV;
8156+
81548157
switch (resp->port_partition_type) {
81558158
case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0:
81568159
case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_5:
@@ -9177,6 +9180,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
91779180
bp->flags |= BNXT_FLAG_UDP_GSO_CAP;
91789181
if (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_TX_PKT_TS_CMPL_SUPPORTED)
91799182
bp->fw_cap |= BNXT_FW_CAP_TX_TS_CMP;
9183+
if (BNXT_PF(bp) &&
9184+
(flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_ROCE_VF_RESOURCE_MGMT_SUPPORTED))
9185+
bp->fw_cap |= BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED;
91809186

91819187
bp->tx_push_thresh = 0;
91829188
if ((flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED) &&

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,6 +2406,8 @@ struct bnxt {
24062406
#define BNXT_FW_CAP_DCBX_AGENT BIT_ULL(2)
24072407
#define BNXT_FW_CAP_NEW_RM BIT_ULL(3)
24082408
#define BNXT_FW_CAP_IF_CHANGE BIT_ULL(4)
2409+
#define BNXT_FW_CAP_ENABLE_RDMA_SRIOV BIT_ULL(5)
2410+
#define BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED BIT_ULL(6)
24092411
#define BNXT_FW_CAP_KONG_MB_CHNL BIT_ULL(7)
24102412
#define BNXT_FW_CAP_OVS_64BIT_HANDLE BIT_ULL(10)
24112413
#define BNXT_FW_CAP_TRUSTED_VF BIT_ULL(11)
@@ -2452,6 +2454,10 @@ struct bnxt {
24522454
#define BNXT_SUPPORTS_QUEUE_API(bp) \
24532455
(BNXT_PF(bp) && BNXT_SUPPORTS_NTUPLE_VNIC(bp) && \
24542456
((bp)->fw_cap & BNXT_FW_CAP_VNIC_RE_FLUSH))
2457+
#define BNXT_RDMA_SRIOV_EN(bp) \
2458+
((bp)->fw_cap & BNXT_FW_CAP_ENABLE_RDMA_SRIOV)
2459+
#define BNXT_ROCE_VF_RESC_CAP(bp) \
2460+
((bp)->fw_cap & BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED)
24552461

24562462
u32 hwrm_spec_code;
24572463
u16 hwrm_cmd_seq;

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,56 @@ static int __bnxt_set_vf_params(struct bnxt *bp, int vf_id)
520520
return hwrm_req_send(bp, req);
521521
}
522522

523+
static void bnxt_hwrm_roce_sriov_cfg(struct bnxt *bp, int num_vfs)
524+
{
525+
struct hwrm_func_qcaps_output *resp;
526+
struct hwrm_func_cfg_input *cfg_req;
527+
struct hwrm_func_qcaps_input *req;
528+
int rc;
529+
530+
rc = hwrm_req_init(bp, req, HWRM_FUNC_QCAPS);
531+
if (rc)
532+
return;
533+
534+
req->fid = cpu_to_le16(0xffff);
535+
resp = hwrm_req_hold(bp, req);
536+
rc = hwrm_req_send(bp, req);
537+
if (rc)
538+
goto err;
539+
540+
rc = hwrm_req_init(bp, cfg_req, HWRM_FUNC_CFG);
541+
if (rc)
542+
goto err;
543+
544+
cfg_req->fid = cpu_to_le16(0xffff);
545+
cfg_req->enables2 =
546+
cpu_to_le32(FUNC_CFG_REQ_ENABLES2_ROCE_MAX_AV_PER_VF |
547+
FUNC_CFG_REQ_ENABLES2_ROCE_MAX_CQ_PER_VF |
548+
FUNC_CFG_REQ_ENABLES2_ROCE_MAX_MRW_PER_VF |
549+
FUNC_CFG_REQ_ENABLES2_ROCE_MAX_QP_PER_VF |
550+
FUNC_CFG_REQ_ENABLES2_ROCE_MAX_SRQ_PER_VF |
551+
FUNC_CFG_REQ_ENABLES2_ROCE_MAX_GID_PER_VF);
552+
cfg_req->roce_max_av_per_vf =
553+
cpu_to_le32(le32_to_cpu(resp->roce_vf_max_av) / num_vfs);
554+
cfg_req->roce_max_cq_per_vf =
555+
cpu_to_le32(le32_to_cpu(resp->roce_vf_max_cq) / num_vfs);
556+
cfg_req->roce_max_mrw_per_vf =
557+
cpu_to_le32(le32_to_cpu(resp->roce_vf_max_mrw) / num_vfs);
558+
cfg_req->roce_max_qp_per_vf =
559+
cpu_to_le32(le32_to_cpu(resp->roce_vf_max_qp) / num_vfs);
560+
cfg_req->roce_max_srq_per_vf =
561+
cpu_to_le32(le32_to_cpu(resp->roce_vf_max_srq) / num_vfs);
562+
cfg_req->roce_max_gid_per_vf =
563+
cpu_to_le32(le32_to_cpu(resp->roce_vf_max_gid) / num_vfs);
564+
565+
rc = hwrm_req_send(bp, cfg_req);
566+
567+
err:
568+
hwrm_req_drop(bp, req);
569+
if (rc)
570+
netdev_err(bp->dev, "RoCE sriov configuration failed\n");
571+
}
572+
523573
/* Only called by PF to reserve resources for VFs, returns actual number of
524574
* VFs configured, or < 0 on error.
525575
*/
@@ -759,6 +809,9 @@ int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)
759809
*num_vfs = rc;
760810
}
761811

812+
if (BNXT_RDMA_SRIOV_EN(bp) && BNXT_ROCE_VF_RESC_CAP(bp))
813+
bnxt_hwrm_roce_sriov_cfg(bp, *num_vfs);
814+
762815
return 0;
763816
}
764817

0 commit comments

Comments
 (0)