mirror of https://gitee.com/openkylin/linux.git
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 <saeedm@mellanox.com> Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
This commit is contained in:
parent
2ad9ecdbe7
commit
ed56c5193a
|
@ -137,7 +137,6 @@ struct page_pool;
|
||||||
#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
|
#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
|
||||||
#define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
|
#define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
|
||||||
#define MLX5E_TX_CQ_POLL_BUDGET 128
|
#define MLX5E_TX_CQ_POLL_BUDGET 128
|
||||||
#define MLX5E_UPDATE_STATS_INTERVAL 200 /* msecs */
|
|
||||||
#define MLX5E_SQ_RECOVER_MIN_INTERVAL 500 /* msecs */
|
#define MLX5E_SQ_RECOVER_MIN_INTERVAL 500 /* msecs */
|
||||||
|
|
||||||
#define MLX5E_UMR_WQE_INLINE_SZ \
|
#define MLX5E_UMR_WQE_INLINE_SZ \
|
||||||
|
|
|
@ -270,12 +270,9 @@ void mlx5e_update_stats_work(struct work_struct *work)
|
||||||
struct delayed_work *dwork = to_delayed_work(work);
|
struct delayed_work *dwork = to_delayed_work(work);
|
||||||
struct mlx5e_priv *priv = container_of(dwork, struct mlx5e_priv,
|
struct mlx5e_priv *priv = container_of(dwork, struct mlx5e_priv,
|
||||||
update_stats_work);
|
update_stats_work);
|
||||||
|
|
||||||
mutex_lock(&priv->state_lock);
|
mutex_lock(&priv->state_lock);
|
||||||
if (test_bit(MLX5E_STATE_OPENED, &priv->state)) {
|
|
||||||
priv->profile->update_stats(priv);
|
priv->profile->update_stats(priv);
|
||||||
queue_delayed_work(priv->wq, dwork,
|
|
||||||
msecs_to_jiffies(MLX5E_UPDATE_STATS_INTERVAL));
|
|
||||||
}
|
|
||||||
mutex_unlock(&priv->state_lock);
|
mutex_unlock(&priv->state_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3405,6 +3402,9 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
||||||
struct mlx5e_vport_stats *vstats = &priv->stats.vport;
|
struct mlx5e_vport_stats *vstats = &priv->stats.vport;
|
||||||
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
|
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
|
||||||
|
|
||||||
|
/* update HW stats in background for next time */
|
||||||
|
queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
|
||||||
|
|
||||||
if (mlx5e_is_uplink_rep(priv)) {
|
if (mlx5e_is_uplink_rep(priv)) {
|
||||||
stats->rx_packets = PPORT_802_3_GET(pstats, a_frames_received_ok);
|
stats->rx_packets = PPORT_802_3_GET(pstats, a_frames_received_ok);
|
||||||
stats->rx_bytes = PPORT_802_3_GET(pstats, a_octets_received_ok);
|
stats->rx_bytes = PPORT_802_3_GET(pstats, a_octets_received_ok);
|
||||||
|
|
|
@ -893,6 +893,9 @@ mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
||||||
{
|
{
|
||||||
struct mlx5e_priv *priv = netdev_priv(dev);
|
struct mlx5e_priv *priv = netdev_priv(dev);
|
||||||
|
|
||||||
|
/* update HW stats in background for next time */
|
||||||
|
queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
|
||||||
|
|
||||||
memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
|
memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue