bnxt_en: Fix AGG ring check logic in bnxt_check_rings()
authorSomnath Kotur <somnath.kotur@broadcom.com>
Tue, 12 Dec 2023 00:51:11 +0000 (16:51 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 13 Dec 2023 00:05:57 +0000 (16:05 -0800)
_bnxt_get_max_rings() that is invoked in bnxt_check_rings() already
accounts for the AGG ring(s) and gives a max value based on that.
Increasing for AGG rings before calling _bnxt_get_max_rings() will
result in checking for twice the number of rings than required and
it can fail.  Fix it by adjusting for AGG rings after calling
_bnxt_get_max_rings().

Fixes: f5b29c6afe36 ("bnxt_en: Add helper to get the number of CP rings required for TX rings")
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20231212005122.2401-3-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 7afbbc71f92fc5ccd1cff0d3920cb39b49b96f0c..114beaa95e78fcfbcfce2cdade0bc38f40b7fb6c 100644 (file)
@@ -12724,14 +12724,14 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
        if (tcs)
                tx_sets = tcs;
 
-       if (bp->flags & BNXT_FLAG_AGG_RINGS)
-               rx_rings <<= 1;
-
        _bnxt_get_max_rings(bp, &max_rx, &max_tx, &max_cp);
 
        if (max_rx < rx_rings)
                return -ENOMEM;
 
+       if (bp->flags & BNXT_FLAG_AGG_RINGS)
+               rx_rings <<= 1;
+
        tx_rings_needed = tx * tx_sets + tx_xdp;
        if (max_tx < tx_rings_needed)
                return -ENOMEM;