]> git.dujemihanovic.xyz Git - linux.git/commitdiff
bnxt_en: Add MSIX check in bnxt_check_rings()
authorMichael Chan <michael.chan@broadcom.com>
Mon, 9 Sep 2024 20:27:36 +0000 (13:27 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 11 Sep 2024 01:42:45 +0000 (18:42 -0700)
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 <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240909202737.93852-3-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index c9248ed9330c6fc99bf635ceaa79dc8f2cb55c7e..6e422e24750a281b9337ef3cc443b2dbe7af5abb 100644 (file)
@@ -13803,6 +13803,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
        int max_rx, max_tx, max_cp, tx_sets = 1, tx_cp;
        struct bnxt_hw_rings hwr = {0};
        int rx_rings = rx;
+       int rc;
 
        if (tcs)
                tx_sets = tcs;
@@ -13835,7 +13836,23 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
        }
        if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
                hwr.cp_p5 = hwr.tx + rx;
-       return bnxt_hwrm_check_rings(bp, &hwr);
+       rc = bnxt_hwrm_check_rings(bp, &hwr);
+       if (!rc && pci_msix_can_alloc_dyn(bp->pdev)) {
+               if (!bnxt_ulp_registered(bp->edev)) {
+                       hwr.cp += bnxt_get_ulp_msix_num(bp);
+                       hwr.cp = min_t(int, hwr.cp, bnxt_get_max_func_irqs(bp));
+               }
+               if (hwr.cp > bp->total_irqs) {
+                       int total_msix = bnxt_change_msix(bp, hwr.cp);
+
+                       if (total_msix < hwr.cp) {
+                               netdev_warn(bp->dev, "Unable to allocate %d MSIX vectors, maximum available %d\n",
+                                           hwr.cp, total_msix);
+                               rc = -ENOSPC;
+                       }
+               }
+       }
+       return rc;
 }
 
 static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev)
index 094e0b5c8521ca8770b01074d0b2ae6b3a59133d..f71cc8188b4e5b83683c64cf4b65cc70022caebc 100644 (file)
@@ -955,11 +955,6 @@ static int bnxt_set_channels(struct net_device *dev,
                }
                tx_xdp = req_rx_rings;
        }
-       rc = bnxt_check_rings(bp, req_tx_rings, req_rx_rings, sh, tcs, tx_xdp);
-       if (rc) {
-               netdev_warn(dev, "Unable to allocate the requested rings\n");
-               return rc;
-       }
 
        if (bnxt_get_nr_rss_ctxs(bp, req_rx_rings) !=
            bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) &&
@@ -968,6 +963,12 @@ static int bnxt_set_channels(struct net_device *dev,
                return -EINVAL;
        }
 
+       rc = bnxt_check_rings(bp, req_tx_rings, req_rx_rings, sh, tcs, tx_xdp);
+       if (rc) {
+               netdev_warn(dev, "Unable to allocate the requested rings\n");
+               return rc;
+       }
+
        if (netif_running(dev)) {
                if (BNXT_PF(bp)) {
                        /* TODO CHIMP_FW: Send message to all VF's