Commit cdec2141 authored by Björn Töpel's avatar Björn Töpel Committed by Jeff Kirsher

i40e: report correct statistics when XDP is enabled

When XDP is enabled, the driver will report incorrect
statistics. Received frames will reported as transmitted frames.

This commits fixes the i40e implementation of ndo_get_stats64 (struct
net_device_ops), so that iproute2 will report correct statistics
(e.g. when running "ip -stats link show dev eth0") even when XDP is
enabled.
Reported-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Fixes: 74608d17 ("i40e: add support for XDP_TX action")
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent cfe39699
...@@ -420,9 +420,9 @@ static void i40e_get_netdev_stats_struct(struct net_device *netdev, ...@@ -420,9 +420,9 @@ static void i40e_get_netdev_stats_struct(struct net_device *netdev,
struct rtnl_link_stats64 *stats) struct rtnl_link_stats64 *stats)
{ {
struct i40e_netdev_priv *np = netdev_priv(netdev); struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_ring *tx_ring, *rx_ring;
struct i40e_vsi *vsi = np->vsi; struct i40e_vsi *vsi = np->vsi;
struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi); struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi);
struct i40e_ring *ring;
int i; int i;
if (test_bit(__I40E_VSI_DOWN, vsi->state)) if (test_bit(__I40E_VSI_DOWN, vsi->state))
...@@ -436,24 +436,26 @@ static void i40e_get_netdev_stats_struct(struct net_device *netdev, ...@@ -436,24 +436,26 @@ static void i40e_get_netdev_stats_struct(struct net_device *netdev,
u64 bytes, packets; u64 bytes, packets;
unsigned int start; unsigned int start;
tx_ring = READ_ONCE(vsi->tx_rings[i]); ring = READ_ONCE(vsi->tx_rings[i]);
if (!tx_ring) if (!ring)
continue; continue;
i40e_get_netdev_stats_struct_tx(tx_ring, stats); i40e_get_netdev_stats_struct_tx(ring, stats);
rx_ring = &tx_ring[1]; if (i40e_enabled_xdp_vsi(vsi)) {
ring++;
i40e_get_netdev_stats_struct_tx(ring, stats);
}
ring++;
do { do {
start = u64_stats_fetch_begin_irq(&rx_ring->syncp); start = u64_stats_fetch_begin_irq(&ring->syncp);
packets = rx_ring->stats.packets; packets = ring->stats.packets;
bytes = rx_ring->stats.bytes; bytes = ring->stats.bytes;
} while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start)); } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
stats->rx_packets += packets; stats->rx_packets += packets;
stats->rx_bytes += bytes; stats->rx_bytes += bytes;
if (i40e_enabled_xdp_vsi(vsi))
i40e_get_netdev_stats_struct_tx(&rx_ring[1], stats);
} }
rcu_read_unlock(); rcu_read_unlock();
......
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