Add 2 parameters tx_xdp and rx to these 2 helpers. tx_xdp will be passed in by the caller instead of always using bp->tx_nr_rings_xdp. All current callers will pass in bp->tx_nr_rings_xdp so there is no change in behavior. The rx parameter is unused until the next patch to clamp the XDP rings. The callers now pass in the correct rx value for this purpose. To be consistent in bnxt_num_cp_to_tx(), tcs is now correctly set to 1 when bp->num_tc is 0. Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 +++++++++++------------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b49e02fcde29..d76227d29282 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -8180,7 +8180,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp) rc = bnxt_trim_rings(bp, &rx_rings, &hwr.tx, hwr.cp, sh); if (bp->flags & BNXT_FLAG_AGG_RINGS) hwr.rx = rx_rings << 1; - tx_cp = bnxt_num_tx_to_cp(bp, hwr.tx); + tx_cp = bnxt_num_tx_to_cp(bp, hwr.tx, bp->tx_nr_rings_xdp, rx_rings); hwr.cp = sh ? max_t(int, tx_cp, rx_rings) : tx_cp + rx_rings; if (hwr.tx != bp->tx_nr_rings) { netdev_warn(bp->dev, @@ -11313,27 +11313,24 @@ static int __bnxt_num_tx_to_cp(struct bnxt *bp, int tx, int tx_sets, int tx_xdp) return (tx - tx_xdp) / tx_sets + tx_xdp; } -int bnxt_num_tx_to_cp(struct bnxt *bp, int tx) +int bnxt_num_tx_to_cp(struct bnxt *bp, int tx, int tx_xdp, int rx) { - int tcs = bp->num_tc; + int tcs = bp->num_tc ? bp->num_tc : 1; - if (!tcs) - tcs = 1; - return __bnxt_num_tx_to_cp(bp, tx, tcs, bp->tx_nr_rings_xdp); + return __bnxt_num_tx_to_cp(bp, tx, tcs, tx_xdp); } -static int bnxt_num_cp_to_tx(struct bnxt *bp, int tx_cp) +static int bnxt_num_cp_to_tx(struct bnxt *bp, int tx_cp, int tx_xdp, int rx) { - int tcs = bp->num_tc; + int tcs = bp->num_tc ? bp->num_tc : 1; - return (tx_cp - bp->tx_nr_rings_xdp) * tcs + - bp->tx_nr_rings_xdp; + return (tx_cp - tx_xdp) * tcs + tx_xdp; } static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max, bool sh) { - int tx_cp = bnxt_num_tx_to_cp(bp, *tx); + int tx_cp = bnxt_num_tx_to_cp(bp, *tx, bp->tx_nr_rings_xdp, *rx); if (tx_cp != *tx) { int tx_saved = tx_cp, rc; @@ -11342,7 +11339,8 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max, if (rc) return rc; if (tx_cp != tx_saved) - *tx = bnxt_num_cp_to_tx(bp, tx_cp); + *tx = bnxt_num_cp_to_tx(bp, tx_cp, bp->tx_nr_rings_xdp, + *rx); return 0; } return __bnxt_trim_rings(bp, rx, tx, max, sh); @@ -11556,7 +11554,8 @@ static int bnxt_init_int_mode(struct bnxt *bp) if (rc) goto msix_setup_exit; - tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); + tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings, bp->tx_nr_rings_xdp, + bp->rx_nr_rings); bp->cp_nr_rings = (min == 1) ? max_t(int, tx_cp, bp->rx_nr_rings) : tx_cp + bp->rx_nr_rings; @@ -15716,7 +15715,8 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu) void bnxt_set_cp_rings(struct bnxt *bp, bool sh) { - int tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); + int tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings, bp->tx_nr_rings_xdp, + bp->rx_nr_rings); bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : tx_cp + bp->rx_nr_rings; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 51a269d06c49..5ca98394a9ab 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -3003,7 +3003,7 @@ int bnxt_hwrm_set_coal(struct bnxt *); size_t bnxt_copy_ctx_mem(struct bnxt *bp, struct bnxt_ctx_mem_type *ctxm, void *buf, size_t offset); void bnxt_free_ctx_mem(struct bnxt *bp, bool force); -int bnxt_num_tx_to_cp(struct bnxt *bp, int tx); +int bnxt_num_tx_to_cp(struct bnxt *bp, int tx, int tx_xdp, int rx); unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp); unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp); unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); -- 2.51.0