Skip to content

Commit f73a6f4

Browse files
edumazetdavem330
authored andcommitted
net/mlx4_en: get rid of private net_device_stats
We simply can use the standard net_device stats. We do not need to clear fields that are already 0. Signed-off-by: Eric Dumazet <[email protected]> Cc: Willem de Bruijn <[email protected]> Cc: Eugenia Emantayev <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9ed17db commit f73a6f4

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ mlx4_en_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
13021302
struct mlx4_en_priv *priv = netdev_priv(dev);
13031303

13041304
spin_lock_bh(&priv->stats_lock);
1305-
netdev_stats_to_stats64(stats, &priv->stats);
1305+
netdev_stats_to_stats64(stats, &dev->stats);
13061306
spin_unlock_bh(&priv->stats_lock);
13071307

13081308
return stats;
@@ -1877,7 +1877,6 @@ static void mlx4_en_clear_stats(struct net_device *dev)
18771877
if (mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 1))
18781878
en_dbg(HW, priv, "Failed dumping statistics\n");
18791879

1880-
memset(&priv->stats, 0, sizeof(priv->stats));
18811880
memset(&priv->pstats, 0, sizeof(priv->pstats));
18821881
memset(&priv->pkstats, 0, sizeof(priv->pkstats));
18831882
memset(&priv->port_stats, 0, sizeof(priv->port_stats));

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

Lines changed: 3 additions & 11 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;
@@ -239,20 +240,11 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
239240
stats->multicast = en_stats_adder(&mlx4_en_stats->MCAST_prio_0,
240241
&mlx4_en_stats->MCAST_prio_1,
241242
NUM_PRIORITIES);
242-
stats->collisions = 0;
243243
stats->rx_dropped = be32_to_cpu(mlx4_en_stats->RDROP) +
244244
sw_rx_dropped;
245245
stats->rx_length_errors = be32_to_cpu(mlx4_en_stats->RdropLength);
246-
stats->rx_over_errors = 0;
247246
stats->rx_crc_errors = be32_to_cpu(mlx4_en_stats->RCRC);
248-
stats->rx_frame_errors = 0;
249247
stats->rx_fifo_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw);
250-
stats->rx_missed_errors = 0;
251-
stats->tx_aborted_errors = 0;
252-
stats->tx_carrier_errors = 0;
253-
stats->tx_fifo_errors = 0;
254-
stats->tx_heartbeat_errors = 0;
255-
stats->tx_window_errors = 0;
256248
stats->tx_dropped += be32_to_cpu(mlx4_en_stats->TDROP);
257249

258250
/* RX stats */

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ struct mlx4_en_priv {
483483
struct mlx4_en_port_profile *prof;
484484
struct net_device *dev;
485485
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
486-
struct net_device_stats 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)