Skip to content

Commit

Permalink
bnxt_en: Refactor code that determines RFS capability.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Chan authored and David S. Miller committed Dec 29, 2016
1 parent 8fdefd6 commit 8079e8f
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -5962,20 +5980,30 @@ static int bnxt_cfg_rx_mode(struct bnxt *bp)
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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8079e8f

Please sign in to comment.