Commit 907fd4a2 authored by Jakub Kicinski's avatar Jakub Kicinski

bnxt: count discards due to memory allocation errors

Count packets dropped due to buffer or skb allocation errors.
Report as part of rx_dropped.

v2: drop the ethtool -S entry [Vladimir]
Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
Reviewed-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 40bedf7c
...@@ -1651,6 +1651,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, ...@@ -1651,6 +1651,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping); skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping);
if (!skb) { if (!skb) {
bnxt_abort_tpa(cpr, idx, agg_bufs); bnxt_abort_tpa(cpr, idx, agg_bufs);
cpr->sw_stats.rx.rx_oom_discards += 1;
return NULL; return NULL;
} }
} else { } else {
...@@ -1660,6 +1661,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, ...@@ -1660,6 +1661,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
new_data = __bnxt_alloc_rx_data(bp, &new_mapping, GFP_ATOMIC); new_data = __bnxt_alloc_rx_data(bp, &new_mapping, GFP_ATOMIC);
if (!new_data) { if (!new_data) {
bnxt_abort_tpa(cpr, idx, agg_bufs); bnxt_abort_tpa(cpr, idx, agg_bufs);
cpr->sw_stats.rx.rx_oom_discards += 1;
return NULL; return NULL;
} }
...@@ -1675,6 +1677,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, ...@@ -1675,6 +1677,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
if (!skb) { if (!skb) {
kfree(data); kfree(data);
bnxt_abort_tpa(cpr, idx, agg_bufs); bnxt_abort_tpa(cpr, idx, agg_bufs);
cpr->sw_stats.rx.rx_oom_discards += 1;
return NULL; return NULL;
} }
skb_reserve(skb, bp->rx_offset); skb_reserve(skb, bp->rx_offset);
...@@ -1685,6 +1688,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, ...@@ -1685,6 +1688,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
skb = bnxt_rx_pages(bp, cpr, skb, idx, agg_bufs, true); skb = bnxt_rx_pages(bp, cpr, skb, idx, agg_bufs, true);
if (!skb) { if (!skb) {
/* Page reuse already handled by bnxt_rx_pages(). */ /* Page reuse already handled by bnxt_rx_pages(). */
cpr->sw_stats.rx.rx_oom_discards += 1;
return NULL; return NULL;
} }
} }
...@@ -1888,6 +1892,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, ...@@ -1888,6 +1892,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
if (agg_bufs) if (agg_bufs)
bnxt_reuse_rx_agg_bufs(cpr, cp_cons, 0, bnxt_reuse_rx_agg_bufs(cpr, cp_cons, 0,
agg_bufs, false); agg_bufs, false);
cpr->sw_stats.rx.rx_oom_discards += 1;
rc = -ENOMEM; rc = -ENOMEM;
goto next_rx; goto next_rx;
} }
...@@ -1901,6 +1906,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, ...@@ -1901,6 +1906,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr,
payload | len); payload | len);
if (!skb) { if (!skb) {
cpr->sw_stats.rx.rx_oom_discards += 1;
rc = -ENOMEM; rc = -ENOMEM;
goto next_rx; goto next_rx;
} }
...@@ -1909,6 +1915,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, ...@@ -1909,6 +1915,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
if (agg_bufs) { if (agg_bufs) {
skb = bnxt_rx_pages(bp, cpr, skb, cp_cons, agg_bufs, false); skb = bnxt_rx_pages(bp, cpr, skb, cp_cons, agg_bufs, false);
if (!skb) { if (!skb) {
cpr->sw_stats.rx.rx_oom_discards += 1;
rc = -ENOMEM; rc = -ENOMEM;
goto next_rx; goto next_rx;
} }
...@@ -10651,7 +10658,9 @@ static void bnxt_get_ring_stats(struct bnxt *bp, ...@@ -10651,7 +10658,9 @@ static void bnxt_get_ring_stats(struct bnxt *bp,
stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts); stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts);
stats->rx_dropped += cpr->sw_stats.rx.rx_netpoll_discards; stats->rx_dropped +=
cpr->sw_stats.rx.rx_netpoll_discards +
cpr->sw_stats.rx.rx_oom_discards;
} }
} }
......
...@@ -939,6 +939,7 @@ struct bnxt_rx_sw_stats { ...@@ -939,6 +939,7 @@ struct bnxt_rx_sw_stats {
u64 rx_l4_csum_errors; u64 rx_l4_csum_errors;
u64 rx_resets; u64 rx_resets;
u64 rx_buf_errors; u64 rx_buf_errors;
u64 rx_oom_discards;
u64 rx_netpoll_discards; u64 rx_netpoll_discards;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment