bnxt_en: Simplify bnxt_rfs_capable()
authorMichael Chan <michael.chan@broadcom.com>
Mon, 25 Mar 2024 22:28:57 +0000 (15:28 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 29 Mar 2024 05:34:40 +0000 (22:34 -0700)
bnxt_rfs_capable() determines the number of VNICs and RSS_CTXs
required to support aRFS and then reserves the resources.  We already
have functions bnxt_get_total_vnics() and bnxt_get_total_rss_ctxs()
to do that.  Simplify the code by calling these functions.  It is
also more correct to do the resource reservation after
bnxt_can_reserve_rings() returns true.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20240325222902.220712-8-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 80ccb5a54dae8cc7d8dcc845e65fd27ba91a86b7..e968684ccb1d6bcf71f1f039625d6c5c3658e525 100644 (file)
@@ -12479,28 +12479,19 @@ static bool bnxt_rfs_capable(struct bnxt *bp)
        struct bnxt_hw_rings hwr = {0};
        int max_vnics, max_rss_ctxs;
 
-       hwr.rss_ctx = 1;
-       if (BNXT_SUPPORTS_NTUPLE_VNIC(bp)) {
-               /* 2 VNICS: default + Ntuple */
-               hwr.vnic = 2;
-               hwr.rss_ctx = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) *
-                             hwr.vnic;
-               goto check_reserve_vnic;
-       }
-       if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
+       if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) &&
+           !BNXT_SUPPORTS_NTUPLE_VNIC(bp))
                return bnxt_rfs_supported(bp);
+
        if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings)
                return false;
 
-       hwr.vnic = 1 + bp->rx_nr_rings;
-check_reserve_vnic:
+       hwr.grp = bp->rx_nr_rings;
+       hwr.vnic = bnxt_get_total_vnics(bp, bp->rx_nr_rings);
+       hwr.rss_ctx = bnxt_get_total_rss_ctxs(bp, &hwr);
        max_vnics = bnxt_get_max_func_vnics(bp);
        max_rss_ctxs = bnxt_get_max_func_rss_ctxs(bp);
 
-       if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) &&
-           !(bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP))
-               hwr.rss_ctx = hwr.vnic;
-
        if (hwr.vnic > max_vnics || hwr.rss_ctx > max_rss_ctxs) {
                if (bp->rx_nr_rings > 1)
                        netdev_warn(bp->dev,