Commit 782345d2 authored by David Arinzon's avatar David Arinzon Committed by Jakub Kicinski

net: ena: Take xdp packets stats into account in ena_get_stats64()

Queue stats using ifconfig and ip are retrieved
via ena_get_stats64(). This function currently does not take
the xdp sent or dropped packets stats into account.

This commit adds the following xdp stats to ena_get_stats64():
tx bytes sent
tx packets sent
rx dropped packets
Signed-off-by: default avatarArthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: default avatarDavid Arinzon <darinzon@amazon.com>
Link: https://lore.kernel.org/r/20240101190855.18739-12-darinzon@amazon.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4f28e789
...@@ -2795,6 +2795,7 @@ static void ena_get_stats64(struct net_device *netdev, ...@@ -2795,6 +2795,7 @@ static void ena_get_stats64(struct net_device *netdev,
{ {
struct ena_adapter *adapter = netdev_priv(netdev); struct ena_adapter *adapter = netdev_priv(netdev);
struct ena_ring *rx_ring, *tx_ring; struct ena_ring *rx_ring, *tx_ring;
u64 total_xdp_rx_drops = 0;
unsigned int start; unsigned int start;
u64 rx_drops; u64 rx_drops;
u64 tx_drops; u64 tx_drops;
...@@ -2803,8 +2804,8 @@ static void ena_get_stats64(struct net_device *netdev, ...@@ -2803,8 +2804,8 @@ static void ena_get_stats64(struct net_device *netdev,
if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
return; return;
for (i = 0; i < adapter->num_io_queues; i++) { for (i = 0; i < adapter->num_io_queues + adapter->xdp_num_queues; i++) {
u64 bytes, packets; u64 bytes, packets, xdp_rx_drops;
tx_ring = &adapter->tx_ring[i]; tx_ring = &adapter->tx_ring[i];
...@@ -2817,16 +2818,22 @@ static void ena_get_stats64(struct net_device *netdev, ...@@ -2817,16 +2818,22 @@ static void ena_get_stats64(struct net_device *netdev,
stats->tx_packets += packets; stats->tx_packets += packets;
stats->tx_bytes += bytes; stats->tx_bytes += bytes;
/* In XDP there isn't an RX queue counterpart */
if (ENA_IS_XDP_INDEX(adapter, i))
continue;
rx_ring = &adapter->rx_ring[i]; rx_ring = &adapter->rx_ring[i];
do { do {
start = u64_stats_fetch_begin(&rx_ring->syncp); start = u64_stats_fetch_begin(&rx_ring->syncp);
packets = rx_ring->rx_stats.cnt; packets = rx_ring->rx_stats.cnt;
bytes = rx_ring->rx_stats.bytes; bytes = rx_ring->rx_stats.bytes;
xdp_rx_drops = rx_ring->rx_stats.xdp_drop;
} while (u64_stats_fetch_retry(&rx_ring->syncp, start)); } while (u64_stats_fetch_retry(&rx_ring->syncp, start));
stats->rx_packets += packets; stats->rx_packets += packets;
stats->rx_bytes += bytes; stats->rx_bytes += bytes;
total_xdp_rx_drops += xdp_rx_drops;
} }
do { do {
...@@ -2835,7 +2842,7 @@ static void ena_get_stats64(struct net_device *netdev, ...@@ -2835,7 +2842,7 @@ static void ena_get_stats64(struct net_device *netdev,
tx_drops = adapter->dev_stats.tx_drops; tx_drops = adapter->dev_stats.tx_drops;
} while (u64_stats_fetch_retry(&adapter->syncp, start)); } while (u64_stats_fetch_retry(&adapter->syncp, start));
stats->rx_dropped = rx_drops; stats->rx_dropped = rx_drops + total_xdp_rx_drops;
stats->tx_dropped = tx_drops; stats->tx_dropped = tx_drops;
stats->multicast = 0; stats->multicast = 0;
......
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