bnxt_en: Fix statistics context reservation logic for RDMA driver.
authorMichael Chan <michael.chan@broadcom.com>
Sat, 29 Jun 2019 15:16:46 +0000 (11:16 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 30 Jun 2019 23:00:26 +0000 (16:00 -0700)
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: 780baad44f0f ("bnxt_en: Reserve 1 stat_ctx for RDMA driver.")
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index b9bc829aa9da9b44b20e0ff2d2c1555134315987..9090c79387c1f48075dc0eb666767be0e50396ef 100644 (file)
@@ -5508,7 +5508,16 @@ static int bnxt_cp_rings_in_use(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)
@@ -7477,11 +7486,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 stat;
-
-       stat = bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_ulp_stat_ctxs(bp);
-       stat -= bp->cp_nr_rings;
-       return stat;
+       return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp);
 }
 
 int bnxt_get_avail_msix(struct bnxt *bp, int num)