Skip to content

Commit 6124872

Browse files
committed
Merge branch 'mlx4-stats-fixes'
Eric Dumazet says: ==================== net/mlx4_en: fix stats mlx4 has various bugs in its ndo_get_stats() and related functions. This patch series address the obvious issues. Remaining ones will be discussed later. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents bed187b + f73a6f4 commit 6124872

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

drivers/net/ethernet/mellanox/mlx4/en_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
362362

363363
for (i = 0; i < NUM_MAIN_STATS; i++, bitmap_iterator_inc(&it))
364364
if (bitmap_iterator_test(&it))
365-
data[index++] = ((unsigned long *)&priv->stats)[i];
365+
data[index++] = ((unsigned long *)&dev->stats)[i];
366366

367367
for (i = 0; i < NUM_PORT_STATS; i++, bitmap_iterator_inc(&it))
368368
if (bitmap_iterator_test(&it))

drivers/net/ethernet/mellanox/mlx4/en_netdev.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,15 +1296,16 @@ static void mlx4_en_tx_timeout(struct net_device *dev)
12961296
}
12971297

12981298

1299-
static struct net_device_stats *mlx4_en_get_stats(struct net_device *dev)
1299+
static struct rtnl_link_stats64 *
1300+
mlx4_en_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
13001301
{
13011302
struct mlx4_en_priv *priv = netdev_priv(dev);
13021303

13031304
spin_lock_bh(&priv->stats_lock);
1304-
memcpy(&priv->ret_stats, &priv->stats, sizeof(priv->stats));
1305+
netdev_stats_to_stats64(stats, &dev->stats);
13051306
spin_unlock_bh(&priv->stats_lock);
13061307

1307-
return &priv->ret_stats;
1308+
return stats;
13081309
}
13091310

13101311
static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
@@ -1876,7 +1877,6 @@ static void mlx4_en_clear_stats(struct net_device *dev)
18761877
if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1))
18771878
en_dbg(HW, priv, "Failed dumping statistics\n");
18781879

1879-
memset(&priv->stats, 0, sizeof(priv->stats));
18801880
memset(&priv->pstats, 0, sizeof(priv->pstats));
18811881
memset(&priv->pkstats, 0, sizeof(priv->pkstats));
18821882
memset(&priv->port_stats, 0, sizeof(priv->port_stats));
@@ -1892,6 +1892,11 @@ static void mlx4_en_clear_stats(struct net_device *dev)
18921892
priv->tx_ring[i]->bytes = 0;
18931893
priv->tx_ring[i]->packets = 0;
18941894
priv->tx_ring[i]->tx_csum = 0;
1895+
priv->tx_ring[i]->tx_dropped = 0;
1896+
priv->tx_ring[i]->queue_stopped = 0;
1897+
priv->tx_ring[i]->wake_queue = 0;
1898+
priv->tx_ring[i]->tso_packets = 0;
1899+
priv->tx_ring[i]->xmit_more = 0;
18951900
}
18961901
for (i = 0; i < priv->rx_ring_num; i++) {
18971902
priv->rx_ring[i]->bytes = 0;
@@ -2482,7 +2487,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
24822487
.ndo_stop = mlx4_en_close,
24832488
.ndo_start_xmit = mlx4_en_xmit,
24842489
.ndo_select_queue = mlx4_en_select_queue,
2485-
.ndo_get_stats = mlx4_en_get_stats,
2490+
.ndo_get_stats64 = mlx4_en_get_stats64,
24862491
.ndo_set_rx_mode = mlx4_en_set_rx_mode,
24872492
.ndo_set_mac_address = mlx4_en_set_mac,
24882493
.ndo_validate_addr = eth_validate_addr,
@@ -2514,7 +2519,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
25142519
.ndo_stop = mlx4_en_close,
25152520
.ndo_start_xmit = mlx4_en_xmit,
25162521
.ndo_select_queue = mlx4_en_select_queue,
2517-
.ndo_get_stats = mlx4_en_get_stats,
2522+
.ndo_get_stats64 = mlx4_en_get_stats64,
25182523
.ndo_set_rx_mode = mlx4_en_set_rx_mode,
25192524
.ndo_set_mac_address = mlx4_en_set_mac,
25202525
.ndo_validate_addr = eth_validate_addr,

drivers/net/ethernet/mellanox/mlx4/en_port.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
152152
struct mlx4_counter tmp_counter_stats;
153153
struct mlx4_en_stat_out_mbox *mlx4_en_stats;
154154
struct mlx4_en_stat_out_flow_control_mbox *flowstats;
155-
struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]);
156-
struct net_device_stats *stats = &priv->stats;
155+
struct net_device *dev = mdev->pndev[port];
156+
struct mlx4_en_priv *priv = netdev_priv(dev);
157+
struct net_device_stats *stats = &dev->stats;
157158
struct mlx4_cmd_mailbox *mailbox;
158159
u64 in_mod = reset << 8 | port;
159160
int err;
@@ -188,6 +189,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
188189
}
189190
stats->tx_packets = 0;
190191
stats->tx_bytes = 0;
192+
stats->tx_dropped = 0;
191193
priv->port_stats.tx_chksum_offload = 0;
192194
priv->port_stats.queue_stopped = 0;
193195
priv->port_stats.wake_queue = 0;
@@ -199,6 +201,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
199201

200202
stats->tx_packets += ring->packets;
201203
stats->tx_bytes += ring->bytes;
204+
stats->tx_dropped += ring->tx_dropped;
202205
priv->port_stats.tx_chksum_offload += ring->tx_csum;
203206
priv->port_stats.queue_stopped += ring->queue_stopped;
204207
priv->port_stats.wake_queue += ring->wake_queue;
@@ -237,21 +240,12 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
237240
stats->multicast = en_stats_adder(&mlx4_en_stats->MCAST_prio_0,
238241
&mlx4_en_stats->MCAST_prio_1,
239242
NUM_PRIORITIES);
240-
stats->collisions = 0;
241243
stats->rx_dropped = be32_to_cpu(mlx4_en_stats->RDROP) +
242244
sw_rx_dropped;
243245
stats->rx_length_errors = be32_to_cpu(mlx4_en_stats->RdropLength);
244-
stats->rx_over_errors = 0;
245246
stats->rx_crc_errors = be32_to_cpu(mlx4_en_stats->RCRC);
246-
stats->rx_frame_errors = 0;
247247
stats->rx_fifo_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw);
248-
stats->rx_missed_errors = 0;
249-
stats->tx_aborted_errors = 0;
250-
stats->tx_carrier_errors = 0;
251-
stats->tx_fifo_errors = 0;
252-
stats->tx_heartbeat_errors = 0;
253-
stats->tx_window_errors = 0;
254-
stats->tx_dropped = be32_to_cpu(mlx4_en_stats->TDROP);
248+
stats->tx_dropped += be32_to_cpu(mlx4_en_stats->TDROP);
255249

256250
/* RX stats */
257251
priv->pkstats.rx_multicast_packets = stats->multicast;

drivers/net/ethernet/mellanox/mlx4/en_tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,12 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
726726
bool inline_ok;
727727
u32 ring_cons;
728728

729-
if (!priv->port_up)
730-
goto tx_drop;
731-
732729
tx_ind = skb_get_queue_mapping(skb);
733730
ring = priv->tx_ring[tx_ind];
734731

732+
if (!priv->port_up)
733+
goto tx_drop;
734+
735735
/* fetch ring->cons far ahead before needing it to avoid stall */
736736
ring_cons = ACCESS_ONCE(ring->cons);
737737

@@ -1030,7 +1030,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
10301030

10311031
tx_drop:
10321032
dev_kfree_skb_any(skb);
1033-
priv->stats.tx_dropped++;
1033+
ring->tx_dropped++;
10341034
return NETDEV_TX_OK;
10351035
}
10361036

drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ struct mlx4_en_tx_ring {
270270
unsigned long tx_csum;
271271
unsigned long tso_packets;
272272
unsigned long xmit_more;
273+
unsigned int tx_dropped;
273274
struct mlx4_bf bf;
274275
unsigned long queue_stopped;
275276

@@ -482,8 +483,6 @@ struct mlx4_en_priv {
482483
struct mlx4_en_port_profile *prof;
483484
struct net_device *dev;
484485
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
485-
struct net_device_stats stats;
486-
struct net_device_stats ret_stats;
487486
struct mlx4_en_port_state port_state;
488487
spinlock_t stats_lock;
489488
struct ethtool_flow_id ethtool_rules[MAX_NUM_OF_FS_RULES];

0 commit comments

Comments
 (0)