Skip to content

Commit 2d51eb0

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Add MSIX check in bnxt_check_rings()
bnxt_check_rings() is called to ensure that we have the hardware ring resources before committing to reinitialize with the new number of rings. MSIX vectors are never checked at this point, because up until recently we must first disable MSIX before we can allocate the new set of MSIX vectors. Now that we support dynamic MSIX allocation, check to make sure we can dynamically allocate the new MSIX vectors as the last step in bnxt_check_rings() if dynamic MSIX is supported. For example, the IOMMU group may limit the number of MSIX vectors for the device. With this patch, the ring change will fail more gracefully when there is not enough MSIX vectors. It is also better to move bnxt_check_rings() to be called as the last step when changing ethtool rings. Reviewed-by: Somnath Kotur <[email protected]> Reviewed-by: Kalesh AP <[email protected]> Reviewed-by: Andy Gospodarek <[email protected]> Signed-off-by: Michael Chan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f775cb1 commit 2d51eb0

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13803,6 +13803,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
1380313803
int max_rx, max_tx, max_cp, tx_sets = 1, tx_cp;
1380413804
struct bnxt_hw_rings hwr = {0};
1380513805
int rx_rings = rx;
13806+
int rc;
1380613807

1380713808
if (tcs)
1380813809
tx_sets = tcs;
@@ -13835,7 +13836,23 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
1383513836
}
1383613837
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
1383713838
hwr.cp_p5 = hwr.tx + rx;
13838-
return bnxt_hwrm_check_rings(bp, &hwr);
13839+
rc = bnxt_hwrm_check_rings(bp, &hwr);
13840+
if (!rc && pci_msix_can_alloc_dyn(bp->pdev)) {
13841+
if (!bnxt_ulp_registered(bp->edev)) {
13842+
hwr.cp += bnxt_get_ulp_msix_num(bp);
13843+
hwr.cp = min_t(int, hwr.cp, bnxt_get_max_func_irqs(bp));
13844+
}
13845+
if (hwr.cp > bp->total_irqs) {
13846+
int total_msix = bnxt_change_msix(bp, hwr.cp);
13847+
13848+
if (total_msix < hwr.cp) {
13849+
netdev_warn(bp->dev, "Unable to allocate %d MSIX vectors, maximum available %d\n",
13850+
hwr.cp, total_msix);
13851+
rc = -ENOSPC;
13852+
}
13853+
}
13854+
}
13855+
return rc;
1383913856
}
1384013857

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

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,11 +955,6 @@ static int bnxt_set_channels(struct net_device *dev,
955955
}
956956
tx_xdp = req_rx_rings;
957957
}
958-
rc = bnxt_check_rings(bp, req_tx_rings, req_rx_rings, sh, tcs, tx_xdp);
959-
if (rc) {
960-
netdev_warn(dev, "Unable to allocate the requested rings\n");
961-
return rc;
962-
}
963958

964959
if (bnxt_get_nr_rss_ctxs(bp, req_rx_rings) !=
965960
bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) &&
@@ -968,6 +963,12 @@ static int bnxt_set_channels(struct net_device *dev,
968963
return -EINVAL;
969964
}
970965

966+
rc = bnxt_check_rings(bp, req_tx_rings, req_rx_rings, sh, tcs, tx_xdp);
967+
if (rc) {
968+
netdev_warn(dev, "Unable to allocate the requested rings\n");
969+
return rc;
970+
}
971+
971972
if (netif_running(dev)) {
972973
if (BNXT_PF(bp)) {
973974
/* TODO CHIMP_FW: Send message to all VF's

0 commit comments

Comments
 (0)