Skip to content

Commit 61e7b03

Browse files
kuba-mooSasha Levin
authored andcommitted
eth: bnxt: fix counting packets discarded due to OOM and netpoll
[ Upstream commit 7301177 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 77040f8 commit 61e7b03

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
@@ -1659,7 +1659,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
16591659
skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping);
16601660
if (!skb) {
16611661
bnxt_abort_tpa(cpr, idx, agg_bufs);
1662-
cpr->sw_stats.rx.rx_oom_discards += 1;
1662+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
16631663
return NULL;
16641664
}
16651665
} else {
@@ -1669,7 +1669,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
16691669
new_data = __bnxt_alloc_rx_frag(bp, &new_mapping, GFP_ATOMIC);
16701670
if (!new_data) {
16711671
bnxt_abort_tpa(cpr, idx, agg_bufs);
1672-
cpr->sw_stats.rx.rx_oom_discards += 1;
1672+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
16731673
return NULL;
16741674
}
16751675

@@ -1685,7 +1685,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
16851685
if (!skb) {
16861686
skb_free_frag(data);
16871687
bnxt_abort_tpa(cpr, idx, agg_bufs);
1688-
cpr->sw_stats.rx.rx_oom_discards += 1;
1688+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
16891689
return NULL;
16901690
}
16911691
skb_reserve(skb, bp->rx_offset);
@@ -1696,7 +1696,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
16961696
skb = bnxt_rx_agg_pages_skb(bp, cpr, skb, idx, agg_bufs, true);
16971697
if (!skb) {
16981698
/* Page reuse already handled by bnxt_rx_pages(). */
1699-
cpr->sw_stats.rx.rx_oom_discards += 1;
1699+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
17001700
return NULL;
17011701
}
17021702
}
@@ -1914,11 +1914,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
19141914
u32 frag_len = bnxt_rx_agg_pages_xdp(bp, cpr, &xdp,
19151915
cp_cons, agg_bufs,
19161916
false);
1917-
if (!frag_len) {
1918-
cpr->sw_stats.rx.rx_oom_discards += 1;
1919-
rc = -ENOMEM;
1920-
goto next_rx;
1921-
}
1917+
if (!frag_len)
1918+
goto oom_next_rx;
19221919
}
19231920
xdp_active = true;
19241921
}
@@ -1941,9 +1938,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
19411938
else
19421939
bnxt_xdp_buff_frags_free(rxr, &xdp);
19431940
}
1944-
cpr->sw_stats.rx.rx_oom_discards += 1;
1945-
rc = -ENOMEM;
1946-
goto next_rx;
1941+
goto oom_next_rx;
19471942
}
19481943
} else {
19491944
u32 payload;
@@ -1954,29 +1949,21 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
19541949
payload = 0;
19551950
skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr,
19561951
payload | len);
1957-
if (!skb) {
1958-
cpr->sw_stats.rx.rx_oom_discards += 1;
1959-
rc = -ENOMEM;
1960-
goto next_rx;
1961-
}
1952+
if (!skb)
1953+
goto oom_next_rx;
19621954
}
19631955

19641956
if (agg_bufs) {
19651957
if (!xdp_active) {
19661958
skb = bnxt_rx_agg_pages_skb(bp, cpr, skb, cp_cons, agg_bufs, false);
1967-
if (!skb) {
1968-
cpr->sw_stats.rx.rx_oom_discards += 1;
1969-
rc = -ENOMEM;
1970-
goto next_rx;
1971-
}
1959+
if (!skb)
1960+
goto oom_next_rx;
19721961
} else {
19731962
skb = bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr->page_pool, &xdp, rxcmp1);
19741963
if (!skb) {
19751964
/* we should be able to free the old skb here */
19761965
bnxt_xdp_buff_frags_free(rxr, &xdp);
1977-
cpr->sw_stats.rx.rx_oom_discards += 1;
1978-
rc = -ENOMEM;
1979-
goto next_rx;
1966+
goto oom_next_rx;
19801967
}
19811968
}
19821969
}
@@ -2054,6 +2041,11 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
20542041
*raw_cons = tmp_raw_cons;
20552042

20562043
return rc;
2044+
2045+
oom_next_rx:
2046+
cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1;
2047+
rc = -ENOMEM;
2048+
goto next_rx;
20572049
}
20582050

20592051
/* In netpoll mode, if we are using a combined completion ring, we need to
@@ -2099,7 +2091,7 @@ static int bnxt_force_rx_discard(struct bnxt *bp,
20992091
}
21002092
rc = bnxt_rx_pkt(bp, cpr, raw_cons, event);
21012093
if (rc && rc != -EBUSY)
2102-
cpr->sw_stats.rx.rx_netpoll_discards += 1;
2094+
cpr->bnapi->cp_ring.sw_stats.rx.rx_netpoll_discards += 1;
21032095
return rc;
21042096
}
21052097

0 commit comments

Comments
 (0)