Skip to content

Commit 3834a5e

Browse files
Gal PressmanSaeed Mahameed
authored andcommitted
net/mlx5e: Optimize update stats work
Unlike ethtool stats, get_stats ndo provides information cached by update stats work that is running in the background without updating them explicitly. We cannot update all counters inside the ndo because some updates require firmware commands that cannot be performed under a spinlock. update_stats work does not need to update ALL counters, since only some of them are needed by ndo_get_stats. This patch will allow for a minimal run of update_stats using an extra parameter which will update necessary counters only and cut 13 firmware commands in each iteration of the work. Work duration previous to this patch: ~4200us. Work duration after this patch: ~700us (17% of the original time). Signed-off-by: Gal Pressman <[email protected]> Reviewed-by: Eran Ben Elisha <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Cc: [email protected]
1 parent 432609a commit 3834a5e

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ void mlx5e_rx_am(struct mlx5e_rq *rq);
822822
void mlx5e_rx_am_work(struct work_struct *work);
823823
struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
824824

825-
void mlx5e_update_stats(struct mlx5e_priv *priv);
825+
void mlx5e_update_stats(struct mlx5e_priv *priv, bool full);
826826

827827
int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
828828
void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);

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

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

312312
mutex_lock(&priv->state_lock);
313313
if (test_bit(MLX5E_STATE_OPENED, &priv->state))
314-
mlx5e_update_stats(priv);
314+
mlx5e_update_stats(priv, true);
315315
channels = &priv->channels;
316316
mutex_unlock(&priv->state_lock);
317317

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static void mlx5e_update_vport_counters(struct mlx5e_priv *priv)
244244
mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen);
245245
}
246246

247-
static void mlx5e_update_pport_counters(struct mlx5e_priv *priv)
247+
static void mlx5e_update_pport_counters(struct mlx5e_priv *priv, bool full)
248248
{
249249
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
250250
struct mlx5_core_dev *mdev = priv->mdev;
@@ -259,6 +259,9 @@ static void mlx5e_update_pport_counters(struct mlx5e_priv *priv)
259259
MLX5_SET(ppcnt_reg, in, grp, MLX5_IEEE_802_3_COUNTERS_GROUP);
260260
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0);
261261

262+
if (!full)
263+
return;
264+
262265
out = pstats->RFC_2863_counters;
263266
MLX5_SET(ppcnt_reg, in, grp, MLX5_RFC_2863_COUNTERS_GROUP);
264267
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0);
@@ -318,15 +321,21 @@ static void mlx5e_update_pcie_counters(struct mlx5e_priv *priv)
318321
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_MPCNT, 0, 0);
319322
}
320323

321-
void mlx5e_update_stats(struct mlx5e_priv *priv)
324+
void mlx5e_update_stats(struct mlx5e_priv *priv, bool full)
322325
{
323-
mlx5e_update_pcie_counters(priv);
324-
mlx5e_update_pport_counters(priv);
326+
if (full)
327+
mlx5e_update_pcie_counters(priv);
328+
mlx5e_update_pport_counters(priv, full);
325329
mlx5e_update_vport_counters(priv);
326330
mlx5e_update_q_counter(priv);
327331
mlx5e_update_sw_counters(priv);
328332
}
329333

334+
static void mlx5e_update_ndo_stats(struct mlx5e_priv *priv)
335+
{
336+
mlx5e_update_stats(priv, false);
337+
}
338+
330339
void mlx5e_update_stats_work(struct work_struct *work)
331340
{
332341
struct delayed_work *dwork = to_delayed_work(work);
@@ -4195,7 +4204,7 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
41954204
.cleanup_tx = mlx5e_cleanup_nic_tx,
41964205
.enable = mlx5e_nic_enable,
41974206
.disable = mlx5e_nic_disable,
4198-
.update_stats = mlx5e_update_stats,
4207+
.update_stats = mlx5e_update_ndo_stats,
41994208
.max_nch = mlx5e_get_max_num_channels,
42004209
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe,
42014210
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,

0 commit comments

Comments
 (0)