Commit 0201bda1 authored by Sameeh Jubran's avatar Sameeh Jubran Committed by David S. Miller

net: ena: ethtool: add stats printing to XDP queues

Added statistics for TX queues that are used for XDP TX. The statistics
are the same as the ones printed for regular non-XDP TX queues.

The XDP queue statistics can be queried using
`ethtool -S <ifname>`
Signed-off-by: default avatarShay Agroskin <shayagr@amazon.com>
Signed-off-by: default avatarSameeh Jubran <sameehj@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 713865da
...@@ -152,7 +152,7 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data) ...@@ -152,7 +152,7 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data)
u64 *ptr; u64 *ptr;
int i, j; int i, j;
for (i = 0; i < adapter->num_io_queues; i++) { for (i = 0; i < adapter->num_io_queues + adapter->xdp_num_queues; i++) {
/* Tx stats */ /* Tx stats */
ring = &adapter->tx_ring[i]; ring = &adapter->tx_ring[i];
...@@ -163,17 +163,19 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data) ...@@ -163,17 +163,19 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data)
ena_safe_update_stat(ptr, (*data)++, &ring->syncp); ena_safe_update_stat(ptr, (*data)++, &ring->syncp);
} }
/* XDP TX queues don't have a RX queue counterpart */
if (!ENA_IS_XDP_INDEX(adapter, i)) {
/* Rx stats */
ring = &adapter->rx_ring[i];
/* Rx stats */ for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
ring = &adapter->rx_ring[i]; ena_stats = &ena_stats_rx_strings[j];
for (j = 0; j < ENA_STATS_ARRAY_RX; j++) { ptr = (u64 *)&ring->rx_stats +
ena_stats = &ena_stats_rx_strings[j]; ena_stats->stat_offset;
ptr = (u64 *)&ring->rx_stats + ena_safe_update_stat(ptr, (*data)++, &ring->syncp);
ena_stats->stat_offset; }
ena_safe_update_stat(ptr, (*data)++, &ring->syncp);
} }
} }
} }
...@@ -238,6 +240,7 @@ static void ena_get_ethtool_stats(struct net_device *netdev, ...@@ -238,6 +240,7 @@ static void ena_get_ethtool_stats(struct net_device *netdev,
static int ena_get_sw_stats_count(struct ena_adapter *adapter) static int ena_get_sw_stats_count(struct ena_adapter *adapter)
{ {
return adapter->num_io_queues * (ENA_STATS_ARRAY_TX + ENA_STATS_ARRAY_RX) return adapter->num_io_queues * (ENA_STATS_ARRAY_TX + ENA_STATS_ARRAY_RX)
+ adapter->xdp_num_queues * ENA_STATS_ARRAY_TX
+ ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENA_COM; + ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENA_COM;
} }
...@@ -259,24 +262,32 @@ int ena_get_sset_count(struct net_device *netdev, int sset) ...@@ -259,24 +262,32 @@ int ena_get_sset_count(struct net_device *netdev, int sset)
static void ena_queue_strings(struct ena_adapter *adapter, u8 **data) static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
{ {
const struct ena_stats *ena_stats; const struct ena_stats *ena_stats;
bool is_xdp;
int i, j; int i, j;
for (i = 0; i < adapter->num_io_queues; i++) { for (i = 0; i < adapter->num_io_queues + adapter->xdp_num_queues; i++) {
is_xdp = ENA_IS_XDP_INDEX(adapter, i);
/* Tx stats */ /* Tx stats */
for (j = 0; j < ENA_STATS_ARRAY_TX; j++) { for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
ena_stats = &ena_stats_tx_strings[j]; ena_stats = &ena_stats_tx_strings[j];
snprintf(*data, ETH_GSTRING_LEN, snprintf(*data, ETH_GSTRING_LEN,
"queue_%u_tx_%s", i, ena_stats->name); "queue_%u_%s_%s", i,
is_xdp ? "xdp_tx" : "tx", ena_stats->name);
(*data) += ETH_GSTRING_LEN; (*data) += ETH_GSTRING_LEN;
} }
/* Rx stats */
for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
ena_stats = &ena_stats_rx_strings[j];
snprintf(*data, ETH_GSTRING_LEN, if (!is_xdp) {
"queue_%u_rx_%s", i, ena_stats->name); /* RX stats, in XDP there isn't a RX queue
(*data) += ETH_GSTRING_LEN; * counterpart
*/
for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
ena_stats = &ena_stats_rx_strings[j];
snprintf(*data, ETH_GSTRING_LEN,
"queue_%u_rx_%s", i, ena_stats->name);
(*data) += ETH_GSTRING_LEN;
}
} }
} }
} }
......
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