Skip to content

Commit 86d747a

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Abstract MQPRIO params
Abstract the MQPRIO params into a struct. Use a getter for DCB mode num_tcs. Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 248d3b4 commit 86d747a

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ struct mlx5e_params {
248248
u8 rq_wq_type;
249249
u8 log_rq_mtu_frames;
250250
u16 num_channels;
251-
u8 num_tc;
251+
struct {
252+
u8 num_tc;
253+
} mqprio;
252254
bool rx_cqe_compress_def;
253255
bool tunneled_offload_en;
254256
struct dim_cq_moder rx_cq_moderation;
@@ -268,6 +270,11 @@ struct mlx5e_params {
268270
bool ptp_rx;
269271
};
270272

273+
static inline u8 mlx5e_get_dcb_num_tc(struct mlx5e_params *params)
274+
{
275+
return params->mqprio.num_tc;
276+
}
277+
271278
enum {
272279
MLX5E_RQ_STATE_ENABLED,
273280
MLX5E_RQ_STATE_RECOVERING,

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,14 @@ static int mlx5e_ptp_open_txqsqs(struct mlx5e_ptp *c,
326326
struct mlx5e_ptp_params *cparams)
327327
{
328328
struct mlx5e_params *params = &cparams->params;
329+
u8 num_tc = mlx5e_get_dcb_num_tc(params);
329330
int ix_base;
330331
int err;
331332
int tc;
332333

333-
ix_base = params->num_tc * params->num_channels;
334+
ix_base = num_tc * params->num_channels;
334335

335-
for (tc = 0; tc < params->num_tc; tc++) {
336+
for (tc = 0; tc < num_tc; tc++) {
336337
int txq_ix = ix_base + tc;
337338

338339
err = mlx5e_ptp_open_txqsq(c, c->priv->tisn[c->lag_port][tc], txq_ix,
@@ -365,25 +366,28 @@ static int mlx5e_ptp_open_tx_cqs(struct mlx5e_ptp *c,
365366
struct mlx5e_create_cq_param ccp = {};
366367
struct dim_cq_moder ptp_moder = {};
367368
struct mlx5e_cq_param *cq_param;
369+
u8 num_tc;
368370
int err;
369371
int tc;
370372

373+
num_tc = mlx5e_get_dcb_num_tc(params);
374+
371375
ccp.node = dev_to_node(mlx5_core_dma_dev(c->mdev));
372376
ccp.ch_stats = c->stats;
373377
ccp.napi = &c->napi;
374378
ccp.ix = MLX5E_PTP_CHANNEL_IX;
375379

376380
cq_param = &cparams->txq_sq_param.cqp;
377381

378-
for (tc = 0; tc < params->num_tc; tc++) {
382+
for (tc = 0; tc < num_tc; tc++) {
379383
struct mlx5e_cq *cq = &c->ptpsq[tc].txqsq.cq;
380384

381385
err = mlx5e_open_cq(c->priv, ptp_moder, cq_param, &ccp, cq);
382386
if (err)
383387
goto out_err_txqsq_cq;
384388
}
385389

386-
for (tc = 0; tc < params->num_tc; tc++) {
390+
for (tc = 0; tc < num_tc; tc++) {
387391
struct mlx5e_cq *cq = &c->ptpsq[tc].ts_cq;
388392
struct mlx5e_ptpsq *ptpsq = &c->ptpsq[tc];
389393

@@ -399,7 +403,7 @@ static int mlx5e_ptp_open_tx_cqs(struct mlx5e_ptp *c,
399403
out_err_ts_cq:
400404
for (--tc; tc >= 0; tc--)
401405
mlx5e_close_cq(&c->ptpsq[tc].ts_cq);
402-
tc = params->num_tc;
406+
tc = num_tc;
403407
out_err_txqsq_cq:
404408
for (--tc; tc >= 0; tc--)
405409
mlx5e_close_cq(&c->ptpsq[tc].txqsq.cq);
@@ -475,7 +479,7 @@ static void mlx5e_ptp_build_params(struct mlx5e_ptp *c,
475479
params->num_channels = orig->num_channels;
476480
params->hard_mtu = orig->hard_mtu;
477481
params->sw_mtu = orig->sw_mtu;
478-
params->num_tc = orig->num_tc;
482+
params->mqprio = orig->mqprio;
479483

480484
/* SQ */
481485
if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
@@ -680,7 +684,7 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
680684
c->pdev = mlx5_core_dma_dev(priv->mdev);
681685
c->netdev = priv->netdev;
682686
c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey.key);
683-
c->num_tc = params->num_tc;
687+
c->num_tc = mlx5e_get_dcb_num_tc(params);
684688
c->stats = &priv->ptp_stats.ch;
685689
c->lag_port = lag_port;
686690

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static u16 mlx5e_qid_from_qos(struct mlx5e_channels *chs, u16 qid)
132132
*/
133133
bool is_ptp = MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS);
134134

135-
return (chs->params.num_channels + is_ptp) * chs->params.num_tc + qid;
135+
return (chs->params.num_channels + is_ptp) * mlx5e_get_dcb_num_tc(&chs->params) + qid;
136136
}
137137

138138
int mlx5e_get_txq_by_classid(struct mlx5e_priv *priv, u16 classid)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
372372
for (i = 0; i < priv->channels.num; i++) {
373373
struct mlx5e_channel *c = priv->channels.c[i];
374374

375-
for (tc = 0; tc < priv->channels.params.num_tc; tc++) {
375+
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
376376
struct mlx5e_txqsq *sq = &c->sq[tc];
377377

378378
err = mlx5e_tx_reporter_build_diagnose_output(fmsg, sq, tc);
@@ -384,7 +384,7 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
384384
if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state))
385385
goto close_sqs_nest;
386386

387-
for (tc = 0; tc < priv->channels.params.num_tc; tc++) {
387+
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
388388
err = mlx5e_tx_reporter_build_diagnose_output_ptpsq(fmsg,
389389
&ptp_ch->ptpsq[tc],
390390
tc);
@@ -494,7 +494,7 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv,
494494
for (i = 0; i < priv->channels.num; i++) {
495495
struct mlx5e_channel *c = priv->channels.c[i];
496496

497-
for (tc = 0; tc < priv->channels.params.num_tc; tc++) {
497+
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
498498
struct mlx5e_txqsq *sq = &c->sq[tc];
499499

500500
err = mlx5e_health_queue_dump(priv, fmsg, sq->sqn, "SQ");
@@ -504,7 +504,7 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv,
504504
}
505505

506506
if (ptp_ch && test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state)) {
507-
for (tc = 0; tc < priv->channels.params.num_tc; tc++) {
507+
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
508508
struct mlx5e_txqsq *sq = &ptp_ch->ptpsq[tc].txqsq;
509509

510510
err = mlx5e_health_queue_dump(priv, fmsg, sq->sqn, "PTP SQ");

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c,
17111711
{
17121712
int err, tc;
17131713

1714-
for (tc = 0; tc < params->num_tc; tc++) {
1714+
for (tc = 0; tc < mlx5e_get_dcb_num_tc(params); tc++) {
17151715
int txq_ix = c->ix + tc * params->num_channels;
17161716

17171717
err = mlx5e_open_txqsq(c, c->priv->tisn[c->lag_port][tc], txq_ix,
@@ -1992,7 +1992,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
19921992
c->pdev = mlx5_core_dma_dev(priv->mdev);
19931993
c->netdev = priv->netdev;
19941994
c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey.key);
1995-
c->num_tc = params->num_tc;
1995+
c->num_tc = mlx5e_get_dcb_num_tc(params);
19961996
c->xdp = !!params->xdp_prog;
19971997
c->stats = &priv->channel_stats[ix].ch;
19981998
c->aff_mask = irq_get_effective_affinity_mask(irq);
@@ -2288,7 +2288,7 @@ int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv)
22882288
qos_queues = mlx5e_qos_cur_leaf_nodes(priv);
22892289

22902290
nch = priv->channels.params.num_channels;
2291-
ntc = priv->channels.params.num_tc;
2291+
ntc = mlx5e_get_dcb_num_tc(&priv->channels.params);
22922292
num_txqs = nch * ntc + qos_queues;
22932293
if (MLX5E_GET_PFLAG(&priv->channels.params, MLX5E_PFLAG_TX_PORT_TS))
22942294
num_txqs += ntc;
@@ -2312,7 +2312,7 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
23122312
old_ntc = netdev->num_tc ? : 1;
23132313

23142314
nch = priv->channels.params.num_channels;
2315-
ntc = priv->channels.params.num_tc;
2315+
ntc = mlx5e_get_dcb_num_tc(&priv->channels.params);
23162316
num_rxqs = nch * priv->profile->rq_groups;
23172317

23182318
mlx5e_netdev_set_tcs(netdev, nch, ntc);
@@ -2387,7 +2387,7 @@ static void mlx5e_build_txq_maps(struct mlx5e_priv *priv)
23872387
int i, ch, tc, num_tc;
23882388

23892389
ch = priv->channels.num;
2390-
num_tc = priv->channels.params.num_tc;
2390+
num_tc = mlx5e_get_dcb_num_tc(&priv->channels.params);
23912391

23922392
for (i = 0; i < ch; i++) {
23932393
for (tc = 0; tc < num_tc; tc++) {
@@ -2418,7 +2418,7 @@ static void mlx5e_update_num_tc_x_num_ch(struct mlx5e_priv *priv)
24182418
{
24192419
/* Sync with mlx5e_select_queue. */
24202420
WRITE_ONCE(priv->num_tc_x_num_ch,
2421-
priv->channels.params.num_tc * priv->channels.num);
2421+
mlx5e_get_dcb_num_tc(&priv->channels.params) * priv->channels.num);
24222422
}
24232423

24242424
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
@@ -2870,14 +2870,14 @@ static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,
28702870
}
28712871

28722872
new_params = priv->channels.params;
2873-
new_params.num_tc = tc ? tc : 1;
2873+
new_params.mqprio.num_tc = tc ? tc : 1;
28742874

28752875
err = mlx5e_safe_switch_params(priv, &new_params,
28762876
mlx5e_num_channels_changed_ctx, NULL, true);
28772877

28782878
out:
28792879
priv->max_opened_tc = max_t(u8, priv->max_opened_tc,
2880-
priv->channels.params.num_tc);
2880+
mlx5e_get_dcb_num_tc(&priv->channels.params));
28812881
mutex_unlock(&priv->state_lock);
28822882
return err;
28832883
}
@@ -4093,12 +4093,12 @@ void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16
40934093
params->hard_mtu = MLX5E_ETH_HARD_MTU;
40944094
params->num_channels = min_t(unsigned int, MLX5E_MAX_NUM_CHANNELS / 2,
40954095
priv->max_nch);
4096-
params->num_tc = 1;
4096+
params->mqprio.num_tc = 1;
40974097

40984098
/* Set an initial non-zero value, so that mlx5e_select_queue won't
40994099
* divide by zero if called before first activating channels.
41004100
*/
4101-
priv->num_tc_x_num_ch = params->num_channels * params->num_tc;
4101+
priv->num_tc_x_num_ch = params->num_channels * params->mqprio.num_tc;
41024102

41034103
/* SQ */
41044104
params->log_sq_size = is_kdump_kernel() ?

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
394394
int err = -ENOMEM;
395395
u32 *sqs;
396396

397-
sqs = kcalloc(priv->channels.num * priv->channels.params.num_tc, sizeof(*sqs), GFP_KERNEL);
397+
sqs = kcalloc(priv->channels.num * mlx5e_get_dcb_num_tc(&priv->channels.params),
398+
sizeof(*sqs), GFP_KERNEL);
398399
if (!sqs)
399400
goto out;
400401

@@ -611,7 +612,7 @@ static void mlx5e_build_rep_params(struct net_device *netdev)
611612
params->rx_dim_enabled = MLX5_CAP_GEN(mdev, cq_moderation);
612613
mlx5e_set_rx_cq_mode_params(params, cq_period_mode);
613614

614-
params->num_tc = 1;
615+
params->mqprio.num_tc = 1;
615616
params->tunneled_offload_en = false;
616617

617618
mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);

0 commit comments

Comments
 (0)