bnxt_en: Refactor code that determines RFS capability.
authorMichael Chan <michael.chan@broadcom.com>
Thu, 29 Dec 2016 17:13:37 +0000 (12:13 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Dec 2016 19:37:23 +0000 (14:37 -0500)
Add function bnxt_rfs_supported() that determines if the chip supports
RFS.  Refactor the existing function bnxt_rfs_capable() that determines
if run-time conditions support RFS.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 916832684ad56c5b2ff18f8fa6c691b072cbf9e5..f7ea99ff6fa36c778cae4e651d7873ef89111172 100644 (file)
@@ -4835,6 +4835,24 @@ static int bnxt_setup_int_mode(struct bnxt *bp)
        return rc;
 }
 
+static unsigned int bnxt_get_max_func_rss_ctxs(struct bnxt *bp)
+{
+#if defined(CONFIG_BNXT_SRIOV)
+       if (BNXT_VF(bp))
+               return bp->vf.max_rsscos_ctxs;
+#endif
+       return bp->pf.max_rsscos_ctxs;
+}
+
+static unsigned int bnxt_get_max_func_vnics(struct bnxt *bp)
+{
+#if defined(CONFIG_BNXT_SRIOV)
+       if (BNXT_VF(bp))
+               return bp->vf.max_vnics;
+#endif
+       return bp->pf.max_vnics;
+}
+
 unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp)
 {
 #if defined(CONFIG_BNXT_SRIOV)
@@ -5962,20 +5980,30 @@ skip_uc:
        return rc;
 }
 
+/* If the chip and firmware supports RFS */
+static bool bnxt_rfs_supported(struct bnxt *bp)
+{
+       if (BNXT_PF(bp) && !BNXT_CHIP_TYPE_NITRO_A0(bp))
+               return true;
+       return false;
+}
+
+/* If runtime conditions support RFS */
 static bool bnxt_rfs_capable(struct bnxt *bp)
 {
 #ifdef CONFIG_RFS_ACCEL
-       struct bnxt_pf_info *pf = &bp->pf;
-       int vnics;
+       int vnics, max_vnics, max_rss_ctxs;
 
        if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_MSIX_CAP))
                return false;
 
        vnics = 1 + bp->rx_nr_rings;
-       if (vnics > pf->max_rsscos_ctxs || vnics > pf->max_vnics) {
+       max_vnics = bnxt_get_max_func_vnics(bp);
+       max_rss_ctxs = bnxt_get_max_func_rss_ctxs(bp);
+       if (vnics > max_vnics || vnics > max_rss_ctxs) {
                netdev_warn(bp->dev,
                            "Not enough resources to support NTUPLE filters, enough resources for up to %d rx rings\n",
-                           min(pf->max_rsscos_ctxs - 1, pf->max_vnics - 1));
+                           min(max_rss_ctxs - 1, max_vnics - 1));
                return false;
        }
 
@@ -7092,7 +7120,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        bnxt_hwrm_vnic_qcaps(bp);
-       if (BNXT_PF(bp) && !BNXT_CHIP_TYPE_NITRO_A0(bp)) {
+       if (bnxt_rfs_supported(bp)) {
                dev->hw_features |= NETIF_F_NTUPLE;
                if (bnxt_rfs_capable(bp)) {
                        bp->flags |= BNXT_FLAG_RFS;