Skip to content

Commit 376a5b8

Browse files
Michael Chandavem330
Michael Chan
authored andcommitted
bnxt_en: Add workaround to detect bad opaque in rx completion (part 1)
There is a rare hardware bug that can cause a bad opaque value in the RX or TPA completion. When this happens, the hardware may have used the same buffer twice for 2 rx packets. In addition, the driver will also crash later using the bad opaque as the index into the ring. The rx opaque value is predictable and is always monotonically increasing. The workaround is to keep track of the expected next opaque value and compare it with the one returned by hardware during RX and TPA start completions. If they miscompare, we will not process any more RX and TPA completions and exit NAPI. We will then schedule a workqueue to reset the function. This patch adds the logic to keep track of the next rx consumer index. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f46fea commit 376a5b8

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
867867

868868
rxr->rx_prod = NEXT_RX(prod);
869869
cons = NEXT_RX(cons);
870+
rxr->rx_next_cons = NEXT_RX(cons);
870871
cons_rx_buf = &rxr->rx_buf_ring[cons];
871872

872873
bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data);
@@ -1245,6 +1246,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi *bnapi, u32 *raw_cons,
12451246

12461247
next_rx:
12471248
rxr->rx_prod = NEXT_RX(prod);
1249+
rxr->rx_next_cons = NEXT_RX(cons);
12481250

12491251
next_rx_no_prod:
12501252
*raw_cons = tmp_raw_cons;
@@ -2486,6 +2488,7 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
24862488
rxr->rx_prod = 0;
24872489
rxr->rx_agg_prod = 0;
24882490
rxr->rx_sw_agg_prod = 0;
2491+
rxr->rx_next_cons = 0;
24892492
}
24902493
}
24912494
}

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ struct bnxt_rx_ring_info {
584584
u16 rx_prod;
585585
u16 rx_agg_prod;
586586
u16 rx_sw_agg_prod;
587+
u16 rx_next_cons;
587588
void __iomem *rx_doorbell;
588589
void __iomem *rx_agg_doorbell;
589590

0 commit comments

Comments
 (0)