Commit 0975d8b4 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'bnxt-add-rx-discards-stats-for-oom-and-netpool'

Jakub Kicinski says:

====================
bnxt: add rx discards stats for oom and netpoll

Drivers should avoid silently dropping frames. This set adds two
stats for previously unaccounted events to bnxt - packets dropped
due to allocation failures and packets dropped during emergency
ring polling.
====================

Link: https://lore.kernel.org/r/20210827152745.68812-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4baf0e0b 907fd4a2
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -1651,6 +1651,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
		skb = bnxt_copy_skb(bnapi, data_ptr, len, mapping);
		if (!skb) {
			bnxt_abort_tpa(cpr, idx, agg_bufs);
			cpr->sw_stats.rx.rx_oom_discards += 1;
			return NULL;
		}
	} else {
@@ -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);
		if (!new_data) {
			bnxt_abort_tpa(cpr, idx, agg_bufs);
			cpr->sw_stats.rx.rx_oom_discards += 1;
			return NULL;
		}

@@ -1675,6 +1677,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
		if (!skb) {
			kfree(data);
			bnxt_abort_tpa(cpr, idx, agg_bufs);
			cpr->sw_stats.rx.rx_oom_discards += 1;
			return NULL;
		}
		skb_reserve(skb, bp->rx_offset);
@@ -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);
		if (!skb) {
			/* Page reuse already handled by bnxt_rx_pages(). */
			cpr->sw_stats.rx.rx_oom_discards += 1;
			return NULL;
		}
	}
@@ -1888,6 +1892,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
			if (agg_bufs)
				bnxt_reuse_rx_agg_bufs(cpr, cp_cons, 0,
						       agg_bufs, false);
			cpr->sw_stats.rx.rx_oom_discards += 1;
			rc = -ENOMEM;
			goto next_rx;
		}
@@ -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,
				      payload | len);
		if (!skb) {
			cpr->sw_stats.rx.rx_oom_discards += 1;
			rc = -ENOMEM;
			goto next_rx;
		}
@@ -1909,6 +1915,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
	if (agg_bufs) {
		skb = bnxt_rx_pages(bp, cpr, skb, cp_cons, agg_bufs, false);
		if (!skb) {
			cpr->sw_stats.rx.rx_oom_discards += 1;
			rc = -ENOMEM;
			goto next_rx;
		}
@@ -2003,6 +2010,7 @@ static int bnxt_force_rx_discard(struct bnxt *bp,
	struct rx_cmp *rxcmp;
	u16 cp_cons;
	u8 cmp_type;
	int rc;

	cp_cons = RING_CMP(tmp_raw_cons);
	rxcmp = (struct rx_cmp *)
@@ -2031,7 +2039,10 @@ static int bnxt_force_rx_discard(struct bnxt *bp,
		tpa_end1->rx_tpa_end_cmp_errors_v2 |=
			cpu_to_le32(RX_TPA_END_CMP_ERRORS);
	}
	return bnxt_rx_pkt(bp, cpr, raw_cons, event);
	rc = bnxt_rx_pkt(bp, cpr, raw_cons, event);
	if (rc && rc != -EBUSY)
		cpr->sw_stats.rx.rx_netpoll_discards += 1;
	return rc;
}

u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx)
@@ -10646,6 +10657,10 @@ static void bnxt_get_ring_stats(struct bnxt *bp,
		stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts);

		stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts);

		stats->rx_dropped +=
			cpr->sw_stats.rx.rx_netpoll_discards +
			cpr->sw_stats.rx.rx_oom_discards;
	}
}

@@ -10660,6 +10675,7 @@ static void bnxt_add_prev_stats(struct bnxt *bp,
	stats->tx_bytes += prev_stats->tx_bytes;
	stats->rx_missed_errors += prev_stats->rx_missed_errors;
	stats->multicast += prev_stats->multicast;
	stats->rx_dropped += prev_stats->rx_dropped;
	stats->tx_dropped += prev_stats->tx_dropped;
}

+2 −0
Original line number Diff line number Diff line
@@ -939,6 +939,8 @@ struct bnxt_rx_sw_stats {
	u64			rx_l4_csum_errors;
	u64			rx_resets;
	u64			rx_buf_errors;
	u64			rx_oom_discards;
	u64			rx_netpoll_discards;
};

struct bnxt_cmn_sw_stats {
+4 −0
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ static const char * const bnxt_cmn_sw_stats_str[] = {
enum {
	RX_TOTAL_DISCARDS,
	TX_TOTAL_DISCARDS,
	RX_NETPOLL_DISCARDS,
};

static struct {
@@ -315,6 +316,7 @@ static struct {
} bnxt_sw_func_stats[] = {
	{0, "rx_total_discard_pkts"},
	{0, "tx_total_discard_pkts"},
	{0, "rx_total_netpoll_discards"},
};

#define NUM_RING_RX_SW_STATS		ARRAY_SIZE(bnxt_rx_sw_stats_str)
@@ -603,6 +605,8 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
			BNXT_GET_RING_STATS64(sw_stats, rx_discard_pkts);
		bnxt_sw_func_stats[TX_TOTAL_DISCARDS].counter +=
			BNXT_GET_RING_STATS64(sw_stats, tx_discard_pkts);
		bnxt_sw_func_stats[RX_NETPOLL_DISCARDS].counter +=
			cpr->sw_stats.rx.rx_netpoll_discards;
	}

	for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++, j++)