Commit dcbc804c authored by Michael Chan's avatar Michael Chan Committed by Greg Kroah-Hartman

bnxt_en: Fix statistics context reservation logic for RDMA driver.

[ Upstream commit d77b1ad8 ]

The current logic assumes that the RDMA driver uses one statistics
context adjacent to the ones used by the network driver.  This
assumption is not true and the statistics context used by the
RDMA driver is tied to its MSIX base vector.  This wrong assumption
can cause RDMA driver failure after changing ethtool rings on the
network side.  Fix the statistics reservation logic accordingly.

Fixes: 780baad4 ("bnxt_en: Reserve 1 stat_ctx for RDMA driver.")
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 51a21893
...@@ -5481,7 +5481,16 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp) ...@@ -5481,7 +5481,16 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp)
static int bnxt_get_func_stat_ctxs(struct bnxt *bp) static int bnxt_get_func_stat_ctxs(struct bnxt *bp)
{ {
return bp->cp_nr_rings + bnxt_get_ulp_stat_ctxs(bp); int ulp_stat = bnxt_get_ulp_stat_ctxs(bp);
int cp = bp->cp_nr_rings;
if (!ulp_stat)
return cp;
if (bnxt_nq_rings_in_use(bp) > cp + bnxt_get_ulp_msix_num(bp))
return bnxt_get_ulp_msix_base(bp) + ulp_stat;
return cp + ulp_stat;
} }
static bool bnxt_need_reserve_rings(struct bnxt *bp) static bool bnxt_need_reserve_rings(struct bnxt *bp)
...@@ -7373,11 +7382,7 @@ unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp) ...@@ -7373,11 +7382,7 @@ unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp)
unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp) unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp)
{ {
unsigned int stat; return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp);
stat = bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_ulp_stat_ctxs(bp);
stat -= bp->cp_nr_rings;
return stat;
} }
int bnxt_get_avail_msix(struct bnxt *bp, int num) int bnxt_get_avail_msix(struct bnxt *bp, int num)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment