bnxt_en: Fix _bnxt_get_max_rings() for 57500 chips.

The CP rings are accounted differently on the new 57500 chips. There
must be enough CP rings for the sum of RX and TX rings on the new
chips. The current logic may be over-estimating the RX and TX rings.

The output parameter max_cp should be the maximum NQs capped by
MSIX vectors available for networking in the context of 57500 chips.
The existing code which uses CMPL rings capped by the MSIX vectors
works most of the time but is not always correct.

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

authored by Michael Chan and committed by David S. Miller e30fbc33 c0b8cda0

Changed files
+12 -4
drivers
net
ethernet
broadcom
bnxt
+12 -4
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 9827 9827 int *max_cp) 9828 9828 { 9829 9829 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; 9830 - int max_ring_grps = 0; 9830 + int max_ring_grps = 0, max_irq; 9831 9831 9832 9832 *max_tx = hw_resc->max_tx_rings; 9833 9833 *max_rx = hw_resc->max_rx_rings; 9834 - *max_cp = min_t(int, bnxt_get_max_func_cp_rings_for_en(bp), 9835 - hw_resc->max_irqs - bnxt_get_ulp_msix_num(bp)); 9836 - *max_cp = min_t(int, *max_cp, hw_resc->max_stat_ctxs); 9834 + *max_cp = bnxt_get_max_func_cp_rings_for_en(bp); 9835 + max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - 9836 + bnxt_get_ulp_msix_num(bp), 9837 + bnxt_get_max_func_stat_ctxs(bp)); 9838 + if (!(bp->flags & BNXT_FLAG_CHIP_P5)) 9839 + *max_cp = min_t(int, *max_cp, max_irq); 9837 9840 max_ring_grps = hw_resc->max_hw_ring_grps; 9838 9841 if (BNXT_CHIP_TYPE_NITRO_A0(bp) && BNXT_PF(bp)) { 9839 9842 *max_cp -= 1; ··· 9844 9841 } 9845 9842 if (bp->flags & BNXT_FLAG_AGG_RINGS) 9846 9843 *max_rx >>= 1; 9844 + if (bp->flags & BNXT_FLAG_CHIP_P5) { 9845 + bnxt_trim_rings(bp, max_rx, max_tx, *max_cp, false); 9846 + /* On P5 chips, max_cp output param should be available NQs */ 9847 + *max_cp = max_irq; 9848 + } 9847 9849 *max_rx = min_t(int, *max_rx, max_ring_grps); 9848 9850 } 9849 9851