Commit 7d7bfc6a authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

mlx4: add rx_alloc_pages counter in ethtool -S

This new counter tracks number of pages that we allocated for one port.

lpaa24:~# ethtool -S eth0 | egrep 'rx_alloc_pages|rx_packets'
     rx_packets: 306755183
     rx_alloc_pages: 932897
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 34db548b
...@@ -117,7 +117,7 @@ static const char main_strings[][ETH_GSTRING_LEN] = { ...@@ -117,7 +117,7 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
/* port statistics */ /* port statistics */
"tso_packets", "tso_packets",
"xmit_more", "xmit_more",
"queue_stopped", "wake_queue", "tx_timeout", "rx_alloc_failed", "queue_stopped", "wake_queue", "tx_timeout", "rx_alloc_pages",
"rx_csum_good", "rx_csum_none", "rx_csum_complete", "tx_chksum_offload", "rx_csum_good", "rx_csum_none", "rx_csum_complete", "tx_chksum_offload",
/* pf statistics */ /* pf statistics */
......
...@@ -213,6 +213,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) ...@@ -213,6 +213,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
priv->port_stats.rx_chksum_good = 0; priv->port_stats.rx_chksum_good = 0;
priv->port_stats.rx_chksum_none = 0; priv->port_stats.rx_chksum_none = 0;
priv->port_stats.rx_chksum_complete = 0; priv->port_stats.rx_chksum_complete = 0;
priv->port_stats.rx_alloc_pages = 0;
priv->xdp_stats.rx_xdp_drop = 0; priv->xdp_stats.rx_xdp_drop = 0;
priv->xdp_stats.rx_xdp_tx = 0; priv->xdp_stats.rx_xdp_tx = 0;
priv->xdp_stats.rx_xdp_tx_full = 0; priv->xdp_stats.rx_xdp_tx_full = 0;
...@@ -223,6 +224,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) ...@@ -223,6 +224,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
priv->port_stats.rx_chksum_good += READ_ONCE(ring->csum_ok); priv->port_stats.rx_chksum_good += READ_ONCE(ring->csum_ok);
priv->port_stats.rx_chksum_none += READ_ONCE(ring->csum_none); priv->port_stats.rx_chksum_none += READ_ONCE(ring->csum_none);
priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete); priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
priv->xdp_stats.rx_xdp_drop += READ_ONCE(ring->xdp_drop); priv->xdp_stats.rx_xdp_drop += READ_ONCE(ring->xdp_drop);
priv->xdp_stats.rx_xdp_tx += READ_ONCE(ring->xdp_tx); priv->xdp_stats.rx_xdp_tx += READ_ONCE(ring->xdp_tx);
priv->xdp_stats.rx_xdp_tx_full += READ_ONCE(ring->xdp_tx_full); priv->xdp_stats.rx_xdp_tx_full += READ_ONCE(ring->xdp_tx_full);
......
...@@ -72,6 +72,7 @@ static int mlx4_alloc_page(struct mlx4_en_priv *priv, ...@@ -72,6 +72,7 @@ static int mlx4_alloc_page(struct mlx4_en_priv *priv,
} }
static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv, static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv,
struct mlx4_en_rx_ring *ring,
struct mlx4_en_rx_desc *rx_desc, struct mlx4_en_rx_desc *rx_desc,
struct mlx4_en_rx_alloc *frags, struct mlx4_en_rx_alloc *frags,
gfp_t gfp) gfp_t gfp)
...@@ -79,8 +80,11 @@ static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv, ...@@ -79,8 +80,11 @@ static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv,
int i; int i;
for (i = 0; i < priv->num_frags; i++, frags++) { for (i = 0; i < priv->num_frags; i++, frags++) {
if (!frags->page && mlx4_alloc_page(priv, frags, gfp)) if (!frags->page) {
return -ENOMEM; if (mlx4_alloc_page(priv, frags, gfp))
return -ENOMEM;
ring->rx_alloc_pages++;
}
rx_desc->data[i].addr = cpu_to_be64(frags->dma + rx_desc->data[i].addr = cpu_to_be64(frags->dma +
frags->page_offset); frags->page_offset);
} }
...@@ -133,7 +137,6 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv, ...@@ -133,7 +137,6 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv,
struct mlx4_en_rx_desc *rx_desc = ring->buf + (index * ring->stride); struct mlx4_en_rx_desc *rx_desc = ring->buf + (index * ring->stride);
struct mlx4_en_rx_alloc *frags = ring->rx_info + struct mlx4_en_rx_alloc *frags = ring->rx_info +
(index << priv->log_rx_info); (index << priv->log_rx_info);
if (ring->page_cache.index > 0) { if (ring->page_cache.index > 0) {
/* XDP uses a single page per frame */ /* XDP uses a single page per frame */
if (!frags->page) { if (!frags->page) {
...@@ -147,7 +150,7 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv, ...@@ -147,7 +150,7 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv,
return 0; return 0;
} }
return mlx4_en_alloc_frags(priv, rx_desc, frags, gfp); return mlx4_en_alloc_frags(priv, ring, rx_desc, frags, gfp);
} }
static bool mlx4_en_is_ring_empty(const struct mlx4_en_rx_ring *ring) static bool mlx4_en_is_ring_empty(const struct mlx4_en_rx_ring *ring)
......
...@@ -346,6 +346,7 @@ struct mlx4_en_rx_ring { ...@@ -346,6 +346,7 @@ struct mlx4_en_rx_ring {
unsigned long csum_ok; unsigned long csum_ok;
unsigned long csum_none; unsigned long csum_none;
unsigned long csum_complete; unsigned long csum_complete;
unsigned long rx_alloc_pages;
unsigned long xdp_drop; unsigned long xdp_drop;
unsigned long xdp_tx; unsigned long xdp_tx;
unsigned long xdp_tx_full; unsigned long xdp_tx_full;
......
...@@ -37,7 +37,7 @@ struct mlx4_en_port_stats { ...@@ -37,7 +37,7 @@ struct mlx4_en_port_stats {
unsigned long queue_stopped; unsigned long queue_stopped;
unsigned long wake_queue; unsigned long wake_queue;
unsigned long tx_timeout; unsigned long tx_timeout;
unsigned long rx_alloc_failed; unsigned long rx_alloc_pages;
unsigned long rx_chksum_good; unsigned long rx_chksum_good;
unsigned long rx_chksum_none; unsigned long rx_chksum_none;
unsigned long rx_chksum_complete; unsigned long rx_chksum_complete;
......
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