Skip to content

Commit ed56c51

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Update NIC HW stats on demand only
Disable periodic stats update background thread and update stats in background on demand when ndo_get_stats is called. Having a background thread running in the driver all the time is bad for power consumption and normally a user space daemon will query the stats once every specific interval, so ideally the background thread and its interval can be done in user space.. Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Eran Ben Elisha <[email protected]>
1 parent 2ad9ecd commit ed56c51

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ struct page_pool;
137137
#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
138138
#define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
139139
#define MLX5E_TX_CQ_POLL_BUDGET 128
140-
#define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */
141140
#define MLX5E_SQ_RECOVER_MIN_INTERVAL 500 /* msecs */
142141

143142
#define MLX5E_UMR_WQE_INLINE_SZ \

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,9 @@ void mlx5e_update_stats_work(struct work_struct *work)
270270
struct delayed_work *dwork = to_delayed_work(work);
271271
struct mlx5e_priv *priv = container_of(dwork, struct mlx5e_priv,
272272
update_stats_work);
273+
273274
mutex_lock(&priv->state_lock);
274-
if (test_bit(MLX5E_STATE_OPENED, &priv->state)) {
275-
priv->profile->update_stats(priv);
276-
queue_delayed_work(priv->wq, dwork,
277-
msecs_to_jiffies(MLX5E_UPDATE_STATS_INTERVAL));
278-
}
275+
priv->profile->update_stats(priv);
279276
mutex_unlock(&priv->state_lock);
280277
}
281278

@@ -3405,6 +3402,9 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
34053402
struct mlx5e_vport_stats *vstats = &priv->stats.vport;
34063403
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
34073404

3405+
/* update HW stats in background for next time */
3406+
queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
3407+
34083408
if (mlx5e_is_uplink_rep(priv)) {
34093409
stats->rx_packets = PPORT_802_3_GET(pstats, a_frames_received_ok);
34103410
stats->rx_bytes = PPORT_802_3_GET(pstats, a_octets_received_ok);

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
893893
{
894894
struct mlx5e_priv *priv = netdev_priv(dev);
895895

896+
/* update HW stats in background for next time */
897+
queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
898+
896899
memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
897900
}
898901

0 commit comments

Comments
 (0)