Skip to content

Commit 8bfaf07

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5e: Present SW stats when state is not opened
The driver can present all SW stats even when the state not opened. Fixed get strings, count and stats to support it. In addition, fix tc2txq to hold a static mapping which doesn't depend on the amount of open channels, and cannot have the same value on two different cells while moving between configurations. Example: - OOB 16 channels - Change to 2 channels, 8 TCs - tc2txq[15][0] == tc2txq[1][7] == 15 This will cause multiple appearances of the same TX index in statistics output. Fixes: 76c3810bade3 ("net/mlx5e: Avoid reset netdev stats on configuration changes") Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent c90262f commit 8bfaf07

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,15 +2633,21 @@ static void mlx5e_netdev_set_tcs(struct net_device *netdev)
26332633
netdev_set_tc_queue(netdev, tc, nch, 0);
26342634
}
26352635

2636-
static void mlx5e_build_channels_tx_maps(struct mlx5e_priv *priv)
2636+
static void mlx5e_build_tc2txq_maps(struct mlx5e_priv *priv)
26372637
{
2638-
struct mlx5e_channel *c;
2639-
struct mlx5e_txqsq *sq;
2638+
int max_nch = priv->profile->max_nch(priv->mdev);
26402639
int i, tc;
26412640

2642-
for (i = 0; i < priv->profile->max_nch(priv->mdev); i++)
2641+
for (i = 0; i < max_nch; i++)
26432642
for (tc = 0; tc < priv->profile->max_tc; tc++)
2644-
priv->channel_tc2txq[i][tc] = i + tc * priv->channels.num;
2643+
priv->channel_tc2txq[i][tc] = i + tc * max_nch;
2644+
}
2645+
2646+
static void mlx5e_build_tx2sq_maps(struct mlx5e_priv *priv)
2647+
{
2648+
struct mlx5e_channel *c;
2649+
struct mlx5e_txqsq *sq;
2650+
int i, tc;
26452651

26462652
for (i = 0; i < priv->channels.num; i++) {
26472653
c = priv->channels.c[i];
@@ -2661,7 +2667,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
26612667
netif_set_real_num_tx_queues(netdev, num_txqs);
26622668
netif_set_real_num_rx_queues(netdev, priv->channels.num);
26632669

2664-
mlx5e_build_channels_tx_maps(priv);
2670+
mlx5e_build_tx2sq_maps(priv);
26652671
mlx5e_activate_channels(&priv->channels);
26662672
write_lock(&priv->stats_lock);
26672673
priv->channels_active = true;
@@ -4446,6 +4452,7 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
44464452
if (err)
44474453
mlx5_core_err(mdev, "TLS initialization failed, %d\n", err);
44484454
mlx5e_build_nic_netdev(netdev);
4455+
mlx5e_build_tc2txq_maps(priv);
44494456
mlx5e_vxlan_init(priv);
44504457
}
44514458

‎drivers/net/ethernet/mellanox/mlx5/core/en_stats.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,6 @@ static int mlx5e_grp_channels_get_num_stats(struct mlx5e_priv *priv)
11611161
{
11621162
int max_nch = priv->profile->max_nch(priv->mdev);
11631163

1164-
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
1165-
return 0;
1166-
11671164
return (NUM_RQ_STATS * max_nch) +
11681165
(NUM_CH_STATS * max_nch) +
11691166
(NUM_SQ_STATS * max_nch * priv->max_opened_tc);
@@ -1175,9 +1172,6 @@ static int mlx5e_grp_channels_fill_strings(struct mlx5e_priv *priv, u8 *data,
11751172
int max_nch = priv->profile->max_nch(priv->mdev);
11761173
int i, j, tc;
11771174

1178-
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
1179-
return idx;
1180-
11811175
for (i = 0; i < max_nch; i++)
11821176
for (j = 0; j < NUM_CH_STATS; j++)
11831177
sprintf(data + (idx++) * ETH_GSTRING_LEN,
@@ -1187,7 +1181,6 @@ static int mlx5e_grp_channels_fill_strings(struct mlx5e_priv *priv, u8 *data,
11871181
for (j = 0; j < NUM_RQ_STATS; j++)
11881182
sprintf(data + (idx++) * ETH_GSTRING_LEN, rq_stats_desc[j].format, i);
11891183

1190-
/* priv->channel_tc2txq[i][tc] is valid only when device is open */
11911184
for (tc = 0; tc < priv->max_opened_tc; tc++)
11921185
for (i = 0; i < max_nch; i++)
11931186
for (j = 0; j < NUM_SQ_STATS; j++)
@@ -1204,9 +1197,6 @@ static int mlx5e_grp_channels_fill_stats(struct mlx5e_priv *priv, u64 *data,
12041197
int max_nch = priv->profile->max_nch(priv->mdev);
12051198
int i, j, tc;
12061199

1207-
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
1208-
return idx;
1209-
12101200
for (i = 0; i < max_nch; i++)
12111201
for (j = 0; j < NUM_CH_STATS; j++)
12121202
data[idx++] =

0 commit comments

Comments
 (0)