Skip to content

Commit 7301177

Browse files
committed
eth: bnxt: fix counting packets discarded due to OOM and netpoll
I added OOM and netpoll discard counters, naively assuming that the cpr pointer is pointing to a common completion ring. Turns out that is usually *a* completion ring but not *the* completion ring which bnapi->cp_ring points to. bnapi->cp_ring is where the stats are read from, so we end up reporting 0 thru ethtool -S and qstat even though the drop events have happened. Make 100% sure we're recording statistics in the correct structure. Fixes: 907fd4a ("bnxt: count discards due to memory allocation errors") Reviewed-by: Michael Chan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c04d1b9 commit 7301177

File tree

1 file changed

+18
-26
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+18
-26
lines changed

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

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
17781778
skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping);
17791779
if (!skb) {
17801780
bnxt_abort_tpa(cpr, idx, agg_bufs);
1781-
cpr->sw_stats.rx.rx_oom_discards += 1;
1781+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
17821782
return NULL;
17831783
}
17841784
} else {
@@ -1788,7 +1788,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
17881788
new_data = __bnxt_alloc_rx_frag(bp, &new_mapping, GFP_ATOMIC);
17891789
if (!new_data) {
17901790
bnxt_abort_tpa(cpr, idx, agg_bufs);
1791-
cpr->sw_stats.rx.rx_oom_discards += 1;
1791+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
17921792
return NULL;
17931793
}
17941794

@@ -1804,7 +1804,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
18041804
if (!skb) {
18051805
skb_free_frag(data);
18061806
bnxt_abort_tpa(cpr, idx, agg_bufs);
1807-
cpr->sw_stats.rx.rx_oom_discards += 1;
1807+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
18081808
return NULL;
18091809
}
18101810
skb_reserve(skb, bp->rx_offset);
@@ -1815,7 +1815,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
18151815
skb = bnxt_rx_agg_pages_skb(bp, cpr, skb, idx, agg_bufs, true);
18161816
if (!skb) {
18171817
/* Page reuse already handled by bnxt_rx_pages(). */
1818-
cpr->sw_stats.rx.rx_oom_discards += 1;
1818+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
18191819
return NULL;
18201820
}
18211821
}
@@ -2094,11 +2094,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
20942094
u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp,
20952095
cp_cons, agg_bufs,
20962096
false);
2097-
if (!frag_len) {
2098-
cpr->sw_stats.rx.rx_oom_discards += 1;
2099-
rc = -ENOMEM;
2100-
goto next_rx;
2101-
}
2097+
if (!frag_len)
2098+
goto oom_next_rx;
21022099
}
21032100
xdp_active = true;
21042101
}
@@ -2121,9 +2118,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
21212118
else
21222119
bnxt_xdp_buff_frags_free(rxr, &xdp);
21232120
}
2124-
cpr->sw_stats.rx.rx_oom_discards += 1;
2125-
rc = -ENOMEM;
2126-
goto next_rx;
2121+
goto oom_next_rx;
21272122
}
21282123
} else {
21292124
u32 payload;
@@ -2134,29 +2129,21 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
21342129
payload = 0;
21352130
skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr,
21362131
payload | len);
2137-
if (!skb) {
2138-
cpr->sw_stats.rx.rx_oom_discards += 1;
2139-
rc = -ENOMEM;
2140-
goto next_rx;
2141-
}
2132+
if (!skb)
2133+
goto oom_next_rx;
21422134
}
21432135

21442136
if (agg_bufs) {
21452137
if (!xdp_active) {
21462138
skb = bnxt_rx_agg_pages_skb(bp, cpr, skb, cp_cons, agg_bufs, false);
2147-
if (!skb) {
2148-
cpr->sw_stats.rx.rx_oom_discards += 1;
2149-
rc = -ENOMEM;
2150-
goto next_rx;
2151-
}
2139+
if (!skb)
2140+
goto oom_next_rx;
21522141
} else {
21532142
skb = bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr->page_pool, &xdp, rxcmp1);
21542143
if (!skb) {
21552144
/* we should be able to free the old skb here */
21562145
bnxt_xdp_buff_frags_free(rxr, &xdp);
2157-
cpr->sw_stats.rx.rx_oom_discards += 1;
2158-
rc = -ENOMEM;
2159-
goto next_rx;
2146+
goto oom_next_rx;
21602147
}
21612148
}
21622149
}
@@ -2234,6 +2221,11 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
22342221
*raw_cons = tmp_raw_cons;
22352222

22362223
return rc;
2224+
2225+
oom_next_rx:
2226+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
2227+
rc = -ENOMEM;
2228+
goto next_rx;
22372229
}
22382230

22392231
/* In netpoll mode, if we are using a combined completion ring, we need to
@@ -2280,7 +2272,7 @@ static int bnxt_force_rx_discard(struct bnxt *bp,
22802272
}
22812273
rc = bnxt_rx_pkt(bp, cpr, raw_cons, event);
22822274
if (rc && rc != -EBUSY)
2283-
cpr->sw_stats.rx.rx_netpoll_discards += 1;
2275+
cpr->bnapi->cp_ring.sw_stats.rx.rx_netpoll_discards += 1;
22842276
return rc;
22852277
}
22862278

0 commit comments

Comments
 (0)