Skip to content

Commit 0a3e5c1

Browse files
jdamato-fslydavem330
authored andcommitted
net/mlx5e: Add txq to sq stats mapping
mlx5 currently maps txqs to an sq via priv->txq2sq. It is useful to map txqs to sq_stats, as well, for direct access to stats. Add priv->txq2sq_stats and insert mappings. The mappings will be used next to tabulate stats information. Signed-off-by: Joe Damato <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 934c299 commit 0a3e5c1

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,8 @@ struct mlx5e_priv {
867867
/* priv data path fields - start */
868868
struct mlx5e_selq selq;
869869
struct mlx5e_txqsq **txq2sq;
870+
struct mlx5e_sq_stats **txq2sq_stats;
871+
870872
#ifdef CONFIG_MLX5_CORE_EN_DCB
871873
struct mlx5e_dcbx_dp dcbx_dp;
872874
#endif

drivers/net/ethernet/mellanox/mlx5/core/en/qos.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ int mlx5e_activate_qos_sq(void *data, u16 node_qid, u32 hw_id)
170170
mlx5e_tx_disable_queue(netdev_get_tx_queue(priv->netdev, qid));
171171

172172
priv->txq2sq[qid] = sq;
173+
priv->txq2sq_stats[qid] = sq->stats;
173174

174175
/* Make the change to txq2sq visible before the queue is started.
175176
* As mlx5e_xmit runs under a spinlock, there is an implicit ACQUIRE,
@@ -186,6 +187,7 @@ int mlx5e_activate_qos_sq(void *data, u16 node_qid, u32 hw_id)
186187
void mlx5e_deactivate_qos_sq(struct mlx5e_priv *priv, u16 qid)
187188
{
188189
struct mlx5e_txqsq *sq;
190+
u16 txq_ix;
189191

190192
sq = mlx5e_get_qos_sq(priv, qid);
191193
if (!sq) /* Handle the case when the SQ failed to open. */
@@ -194,7 +196,10 @@ void mlx5e_deactivate_qos_sq(struct mlx5e_priv *priv, u16 qid)
194196
qos_dbg(sq->mdev, "Deactivate QoS SQ qid %u\n", qid);
195197
mlx5e_deactivate_txqsq(sq);
196198

197-
priv->txq2sq[mlx5e_qid_from_qos(&priv->channels, qid)] = NULL;
199+
txq_ix = mlx5e_qid_from_qos(&priv->channels, qid);
200+
201+
priv->txq2sq[txq_ix] = NULL;
202+
priv->txq2sq_stats[txq_ix] = NULL;
198203

199204
/* Make the change to txq2sq visible before the queue is started again.
200205
* As mlx5e_xmit runs under a spinlock, there is an implicit ACQUIRE,
@@ -325,6 +330,7 @@ void mlx5e_qos_deactivate_queues(struct mlx5e_channel *c)
325330
{
326331
struct mlx5e_params *params = &c->priv->channels.params;
327332
struct mlx5e_txqsq __rcu **qos_sqs;
333+
u16 txq_ix;
328334
int i;
329335

330336
qos_sqs = mlx5e_state_dereference(c->priv, c->qos_sqs);
@@ -342,8 +348,11 @@ void mlx5e_qos_deactivate_queues(struct mlx5e_channel *c)
342348
qos_dbg(c->mdev, "Deactivate QoS SQ qid %u\n", qid);
343349
mlx5e_deactivate_txqsq(sq);
344350

351+
txq_ix = mlx5e_qid_from_qos(&c->priv->channels, qid);
352+
345353
/* The queue is disabled, no synchronization with datapath is needed. */
346-
c->priv->txq2sq[mlx5e_qid_from_qos(&c->priv->channels, qid)] = NULL;
354+
c->priv->txq2sq[txq_ix] = NULL;
355+
c->priv->txq2sq_stats[txq_ix] = NULL;
347356
}
348357
}
349358

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,7 @@ static void mlx5e_build_txq_maps(struct mlx5e_priv *priv)
31253125
struct mlx5e_txqsq *sq = &c->sq[tc];
31263126

31273127
priv->txq2sq[sq->txq_ix] = sq;
3128+
priv->txq2sq_stats[sq->txq_ix] = sq->stats;
31283129
}
31293130
}
31303131

@@ -3139,6 +3140,7 @@ static void mlx5e_build_txq_maps(struct mlx5e_priv *priv)
31393140
struct mlx5e_txqsq *sq = &c->ptpsq[tc].txqsq;
31403141

31413142
priv->txq2sq[sq->txq_ix] = sq;
3143+
priv->txq2sq_stats[sq->txq_ix] = sq->stats;
31423144
}
31433145

31443146
out:
@@ -5848,9 +5850,13 @@ int mlx5e_priv_init(struct mlx5e_priv *priv,
58485850
if (!priv->txq2sq)
58495851
goto err_destroy_workqueue;
58505852

5853+
priv->txq2sq_stats = kcalloc_node(num_txqs, sizeof(*priv->txq2sq_stats), GFP_KERNEL, node);
5854+
if (!priv->txq2sq_stats)
5855+
goto err_free_txq2sq;
5856+
58515857
priv->tx_rates = kcalloc_node(num_txqs, sizeof(*priv->tx_rates), GFP_KERNEL, node);
58525858
if (!priv->tx_rates)
5853-
goto err_free_txq2sq;
5859+
goto err_free_txq2sq_stats;
58545860

58555861
priv->channel_stats =
58565862
kcalloc_node(nch, sizeof(*priv->channel_stats), GFP_KERNEL, node);
@@ -5861,6 +5867,8 @@ int mlx5e_priv_init(struct mlx5e_priv *priv,
58615867

58625868
err_free_tx_rates:
58635869
kfree(priv->tx_rates);
5870+
err_free_txq2sq_stats:
5871+
kfree(priv->txq2sq_stats);
58645872
err_free_txq2sq:
58655873
kfree(priv->txq2sq);
58665874
err_destroy_workqueue:
@@ -5884,6 +5892,7 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv)
58845892
kvfree(priv->channel_stats[i]);
58855893
kfree(priv->channel_stats);
58865894
kfree(priv->tx_rates);
5895+
kfree(priv->txq2sq_stats);
58875896
kfree(priv->txq2sq);
58885897
destroy_workqueue(priv->wq);
58895898
mlx5e_selq_cleanup(&priv->selq);

0 commit comments

Comments
 (0)