aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Chan <michael.chan@broadcom.com>2018-03-31 13:54:19 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-31 23:24:20 -0400
commit4e41dc5deb6e5c36ac5f2e49575485920037b2aa (patch)
treed41ab998038d6a8f13c0cc50a3815b74221e9e72
parente5811b8c09df9bc80eabc95339fceded23f16289 (diff)
bnxt_en: Refactor bnxt_need_reserve_rings().
Refactor bnxt_need_reserve_rings() slightly so that __bnxt_reserve_rings() can call it and remove some duplicated code. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c380a0d5a2ec..a6237dd8cacd 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4753,6 +4753,30 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp)
4753 return cp; 4753 return cp;
4754} 4754}
4755 4755
4756static bool bnxt_need_reserve_rings(struct bnxt *bp)
4757{
4758 struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
4759 int cp = bp->cp_nr_rings;
4760 int rx = bp->rx_nr_rings;
4761 int vnic = 1, grp = rx;
4762
4763 if (bp->hwrm_spec_code < 0x10601)
4764 return false;
4765
4766 if (hw_resc->resv_tx_rings != bp->tx_nr_rings)
4767 return true;
4768
4769 if (bp->flags & BNXT_FLAG_RFS)
4770 vnic = rx + 1;
4771 if (bp->flags & BNXT_FLAG_AGG_RINGS)
4772 rx <<= 1;
4773 if ((bp->flags & BNXT_FLAG_NEW_RM) &&
4774 (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp ||
4775 hw_resc->resv_hw_ring_grps != grp || hw_resc->resv_vnics != vnic))
4776 return true;
4777 return false;
4778}
4779
4756static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max, 4780static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
4757 bool shared); 4781 bool shared);
4758 4782
@@ -4766,7 +4790,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
4766 bool sh = false; 4790 bool sh = false;
4767 int vnic = 1; 4791 int vnic = 1;
4768 4792
4769 if (bp->hwrm_spec_code < 0x10601) 4793 if (!bnxt_need_reserve_rings(bp))
4770 return 0; 4794 return 0;
4771 4795
4772 if (bp->flags & BNXT_FLAG_SHARED_RINGS) 4796 if (bp->flags & BNXT_FLAG_SHARED_RINGS)
@@ -4775,14 +4799,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
4775 vnic = rx + 1; 4799 vnic = rx + 1;
4776 if (bp->flags & BNXT_FLAG_AGG_RINGS) 4800 if (bp->flags & BNXT_FLAG_AGG_RINGS)
4777 rx <<= 1; 4801 rx <<= 1;
4778
4779 grp = bp->rx_nr_rings; 4802 grp = bp->rx_nr_rings;
4780 if (tx == hw_resc->resv_tx_rings &&
4781 (!(bp->flags & BNXT_FLAG_NEW_RM) ||
4782 (rx == hw_resc->resv_rx_rings &&
4783 grp == hw_resc->resv_hw_ring_grps &&
4784 cp == hw_resc->resv_cp_rings && vnic == hw_resc->resv_vnics)))
4785 return 0;
4786 4803
4787 rc = bnxt_hwrm_reserve_rings(bp, tx, rx, grp, cp, vnic); 4804 rc = bnxt_hwrm_reserve_rings(bp, tx, rx, grp, cp, vnic);
4788 if (rc) 4805 if (rc)
@@ -4826,30 +4843,6 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
4826 return rc; 4843 return rc;
4827} 4844}
4828 4845
4829static bool bnxt_need_reserve_rings(struct bnxt *bp)
4830{
4831 struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
4832 int rx = bp->rx_nr_rings;
4833 int vnic = 1;
4834
4835 if (bp->hwrm_spec_code < 0x10601)
4836 return false;
4837
4838 if (hw_resc->resv_tx_rings != bp->tx_nr_rings)
4839 return true;
4840
4841 if (bp->flags & BNXT_FLAG_RFS)
4842 vnic = rx + 1;
4843 if (bp->flags & BNXT_FLAG_AGG_RINGS)
4844 rx <<= 1;
4845 if ((bp->flags & BNXT_FLAG_NEW_RM) &&
4846 (hw_resc->resv_rx_rings != rx ||
4847 hw_resc->resv_cp_rings != bp->cp_nr_rings ||
4848 hw_resc->resv_vnics != vnic))
4849 return true;
4850 return false;
4851}
4852
4853static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, 4846static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
4854 int ring_grps, int cp_rings, int vnics) 4847 int ring_grps, int cp_rings, int vnics)
4855{ 4848{