Skip to content

Commit c2dec36

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Fix statistics counters issue during ifdown with older firmware.
On older firmware, the hardware statistics are not cleared when the driver frees the hardware stats contexts during ifdown. The driver expects these stats to be cleared and saves a copy before freeing the stats contexts. During the next ifup, the driver will likely allocate the same hardware stats contexts and this will cause a big increase in the counters as the old counters are added back to the saved counters. We fix it by making an additional firmware call to clear the counters before freeing the hw stats contexts when the firmware is the older 20.x firmware. Fixes: b8875ca ("bnxt_en: Save ring statistics before reset.") Reported-by: Jakub Kicinski <[email protected]> Reviewed-by: Vasundhara Volam <[email protected]> Signed-off-by: Michael Chan <[email protected]> Tested-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fed7edd commit c2dec36

File tree

1 file changed

+7
-1
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+7
-1
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6292,6 +6292,7 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
62926292

62936293
static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
62946294
{
6295+
struct hwrm_stat_ctx_clr_stats_input req0 = {0};
62956296
struct hwrm_stat_ctx_free_input req = {0};
62966297
int i;
62976298

@@ -6301,6 +6302,7 @@ static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
63016302
if (BNXT_CHIP_TYPE_NITRO_A0(bp))
63026303
return;
63036304

6305+
bnxt_hwrm_cmd_hdr_init(bp, &req0, HWRM_STAT_CTX_CLR_STATS, -1, -1);
63046306
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_STAT_CTX_FREE, -1, -1);
63056307

63066308
mutex_lock(&bp->hwrm_cmd_lock);
@@ -6310,7 +6312,11 @@ static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
63106312

63116313
if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) {
63126314
req.stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id);
6313-
6315+
if (BNXT_FW_MAJ(bp) <= 20) {
6316+
req0.stat_ctx_id = req.stat_ctx_id;
6317+
_hwrm_send_message(bp, &req0, sizeof(req0),
6318+
HWRM_CMD_TIMEOUT);
6319+
}
63146320
_hwrm_send_message(bp, &req, sizeof(req),
63156321
HWRM_CMD_TIMEOUT);
63166322

0 commit comments

Comments
 (0)