Skip to content

Commit 8f23d63

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Expand bnxt_check_rings() to check all resources.
bnxt_check_rings() is called by ethtool, XDP setup, and ndo_setup_tc() to see if there are enough resources to support the new configuration. Expand the call to test all resources if the firmware supports the new API. With the more flexible resource allocation scheme, this call must be made to check that all resources are available before committing to allocate the resources. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4673d66 commit 8f23d63

File tree

1 file changed

+84
-9
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+84
-9
lines changed

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

Lines changed: 84 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4737,28 +4737,99 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp)
47374737
return false;
47384738
}
47394739

4740-
static int bnxt_hwrm_check_tx_rings(struct bnxt *bp, int tx_rings)
4740+
static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
4741+
int ring_grps, int cp_rings)
47414742
{
4742-
struct hwrm_func_cfg_input req = {0};
4743+
struct hwrm_func_vf_cfg_input req = {0};
4744+
u32 flags, enables;
47434745
int rc;
47444746

4745-
if (bp->hwrm_spec_code < 0x10801)
4747+
if (!(bp->flags & BNXT_FLAG_NEW_RM))
47464748
return 0;
47474749

4748-
if (BNXT_VF(bp))
4749-
return 0;
4750+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1);
4751+
flags = FUNC_VF_CFG_REQ_FLAGS_TX_ASSETS_TEST |
4752+
FUNC_VF_CFG_REQ_FLAGS_RX_ASSETS_TEST |
4753+
FUNC_VF_CFG_REQ_FLAGS_CMPL_ASSETS_TEST |
4754+
FUNC_VF_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST |
4755+
FUNC_VF_CFG_REQ_FLAGS_STAT_CTX_ASSETS_TEST |
4756+
FUNC_VF_CFG_REQ_FLAGS_VNIC_ASSETS_TEST;
4757+
enables = FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS |
4758+
FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS |
4759+
FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS |
4760+
FUNC_VF_CFG_REQ_ENABLES_NUM_HW_RING_GRPS |
4761+
FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS |
4762+
FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS;
4763+
4764+
req.flags = cpu_to_le32(flags);
4765+
req.enables = cpu_to_le32(enables);
4766+
req.num_tx_rings = cpu_to_le16(tx_rings);
4767+
req.num_rx_rings = cpu_to_le16(rx_rings);
4768+
req.num_cmpl_rings = cpu_to_le16(cp_rings);
4769+
req.num_hw_ring_grps = cpu_to_le16(ring_grps);
4770+
req.num_stat_ctxs = cpu_to_le16(cp_rings);
4771+
req.num_vnics = cpu_to_le16(1);
4772+
if (bp->flags & BNXT_FLAG_RFS)
4773+
req.num_vnics = cpu_to_le16(rx_rings + 1);
4774+
rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
4775+
if (rc)
4776+
return -ENOMEM;
4777+
return 0;
4778+
}
4779+
4780+
static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
4781+
int ring_grps, int cp_rings)
4782+
{
4783+
struct hwrm_func_cfg_input req = {0};
4784+
u32 flags, enables;
4785+
int rc;
47504786

47514787
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
47524788
req.fid = cpu_to_le16(0xffff);
4753-
req.flags = cpu_to_le32(FUNC_CFG_REQ_FLAGS_TX_ASSETS_TEST);
4754-
req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS);
4789+
flags = FUNC_CFG_REQ_FLAGS_TX_ASSETS_TEST;
4790+
enables = FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS;
47554791
req.num_tx_rings = cpu_to_le16(tx_rings);
4792+
if (bp->flags & BNXT_FLAG_NEW_RM) {
4793+
flags |= FUNC_CFG_REQ_FLAGS_RX_ASSETS_TEST |
4794+
FUNC_CFG_REQ_FLAGS_CMPL_ASSETS_TEST |
4795+
FUNC_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST |
4796+
FUNC_CFG_REQ_FLAGS_STAT_CTX_ASSETS_TEST |
4797+
FUNC_CFG_REQ_FLAGS_VNIC_ASSETS_TEST;
4798+
enables |= FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS |
4799+
FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS |
4800+
FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS |
4801+
FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS |
4802+
FUNC_CFG_REQ_ENABLES_NUM_VNICS;
4803+
req.num_rx_rings = cpu_to_le16(rx_rings);
4804+
req.num_cmpl_rings = cpu_to_le16(cp_rings);
4805+
req.num_hw_ring_grps = cpu_to_le16(ring_grps);
4806+
req.num_stat_ctxs = cpu_to_le16(cp_rings);
4807+
req.num_vnics = cpu_to_le16(1);
4808+
if (bp->flags & BNXT_FLAG_RFS)
4809+
req.num_vnics = cpu_to_le16(rx_rings + 1);
4810+
}
4811+
req.flags = cpu_to_le32(flags);
4812+
req.enables = cpu_to_le32(enables);
47564813
rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
47574814
if (rc)
47584815
return -ENOMEM;
47594816
return 0;
47604817
}
47614818

4819+
static int bnxt_hwrm_check_rings(struct bnxt *bp, int tx_rings, int rx_rings,
4820+
int ring_grps, int cp_rings)
4821+
{
4822+
if (bp->hwrm_spec_code < 0x10801)
4823+
return 0;
4824+
4825+
if (BNXT_PF(bp))
4826+
return bnxt_hwrm_check_pf_rings(bp, tx_rings, rx_rings,
4827+
ring_grps, cp_rings);
4828+
4829+
return bnxt_hwrm_check_vf_rings(bp, tx_rings, rx_rings, ring_grps,
4830+
cp_rings);
4831+
}
4832+
47624833
static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal,
47634834
struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
47644835
{
@@ -7426,7 +7497,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
74267497
{
74277498
int max_rx, max_tx, tx_sets = 1;
74287499
int tx_rings_needed;
7429-
int rc;
7500+
int rx_rings = rx;
7501+
int cp, rc;
74307502

74317503
if (tcs)
74327504
tx_sets = tcs;
@@ -7442,7 +7514,10 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
74427514
if (max_tx < tx_rings_needed)
74437515
return -ENOMEM;
74447516

7445-
return bnxt_hwrm_check_tx_rings(bp, tx_rings_needed);
7517+
if (bp->flags & BNXT_FLAG_AGG_RINGS)
7518+
rx_rings <<= 1;
7519+
cp = sh ? max_t(int, tx_rings_needed, rx) : tx_rings_needed + rx;
7520+
return bnxt_hwrm_check_rings(bp, tx_rings_needed, rx_rings, rx, cp);
74467521
}
74477522

74487523
static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev)

0 commit comments

Comments
 (0)