Skip to content

Commit 8956492

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Restrict usage of mlx5e_priv in params logic functions
Do not use generic struct mlx5e_priv as a parameter to param functions, as it is too generic. All calculations of the channel's param should be mainly based on struct mlx5_core_dev and struct mlx5e_params. Additional info can be explicitly passed. Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Aya Levin <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b3a131c commit 8956492

File tree

8 files changed

+77
-75
lines changed

8 files changed

+77
-75
lines changed

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

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *par
174174
return stop_room;
175175
}
176176

177-
int mlx5e_validate_params(struct mlx5e_priv *priv, struct mlx5e_params *params)
177+
int mlx5e_validate_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params)
178178
{
179179
size_t sq_size = 1 << params->log_sq_size;
180180
u16 stop_room;
181181

182-
stop_room = mlx5e_calc_sq_stop_room(priv->mdev, params);
182+
stop_room = mlx5e_calc_sq_stop_room(mdev, params);
183183
if (stop_room >= sq_size) {
184-
netdev_err(priv->netdev, "Stop room %u is bigger than the SQ size %zu\n",
185-
stop_room, sq_size);
184+
mlx5_core_err(mdev, "Stop room %u is bigger than the SQ size %zu\n",
185+
stop_room, sq_size);
186186
return -EINVAL;
187187
}
188188

@@ -421,22 +421,21 @@ static u8 mlx5e_get_rqwq_log_stride(u8 wq_type, int ndsegs)
421421
return order_base_2(sz);
422422
}
423423

424-
static void mlx5e_build_common_cq_param(struct mlx5e_priv *priv,
424+
static void mlx5e_build_common_cq_param(struct mlx5_core_dev *mdev,
425425
struct mlx5e_cq_param *param)
426426
{
427427
void *cqc = param->cqc;
428428

429-
MLX5_SET(cqc, cqc, uar_page, priv->mdev->priv.uar->index);
430-
if (MLX5_CAP_GEN(priv->mdev, cqe_128_always) && cache_line_size() >= 128)
429+
MLX5_SET(cqc, cqc, uar_page, mdev->priv.uar->index);
430+
if (MLX5_CAP_GEN(mdev, cqe_128_always) && cache_line_size() >= 128)
431431
MLX5_SET(cqc, cqc, cqe_sz, CQE_STRIDE_128_PAD);
432432
}
433433

434-
static void mlx5e_build_rx_cq_param(struct mlx5e_priv *priv,
434+
static void mlx5e_build_rx_cq_param(struct mlx5_core_dev *mdev,
435435
struct mlx5e_params *params,
436436
struct mlx5e_xsk_param *xsk,
437437
struct mlx5e_cq_param *param)
438438
{
439-
struct mlx5_core_dev *mdev = priv->mdev;
440439
bool hw_stridx = false;
441440
void *cqc = param->cqc;
442441
u8 log_cq_size;
@@ -458,17 +457,16 @@ static void mlx5e_build_rx_cq_param(struct mlx5e_priv *priv,
458457
MLX5_SET(cqc, cqc, cqe_comp_en, 1);
459458
}
460459

461-
mlx5e_build_common_cq_param(priv, param);
460+
mlx5e_build_common_cq_param(mdev, param);
462461
param->cq_period_mode = params->rx_cq_moderation.cq_period_mode;
463462
}
464463

465-
void mlx5e_build_rq_param(struct mlx5e_priv *priv,
464+
void mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
466465
struct mlx5e_params *params,
467466
struct mlx5e_xsk_param *xsk,
468467
u16 q_counter,
469468
struct mlx5e_rq_param *param)
470469
{
471-
struct mlx5_core_dev *mdev = priv->mdev;
472470
void *rqc = param->rqc;
473471
void *wq = MLX5_ADDR_OF(rqc, rqc, wq);
474472
int ndsegs = 1;
@@ -499,14 +497,13 @@ void mlx5e_build_rq_param(struct mlx5e_priv *priv,
499497
MLX5_SET(rqc, rqc, scatter_fcs, params->scatter_fcs_en);
500498

501499
param->wq.buf_numa_node = dev_to_node(mlx5_core_dma_dev(mdev));
502-
mlx5e_build_rx_cq_param(priv, params, xsk, &param->cqp);
500+
mlx5e_build_rx_cq_param(mdev, params, xsk, &param->cqp);
503501
}
504502

505-
void mlx5e_build_drop_rq_param(struct mlx5e_priv *priv,
503+
void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
506504
u16 q_counter,
507505
struct mlx5e_rq_param *param)
508506
{
509-
struct mlx5_core_dev *mdev = priv->mdev;
510507
void *rqc = param->rqc;
511508
void *wq = MLX5_ADDR_OF(rqc, rqc, wq);
512509

@@ -518,56 +515,57 @@ void mlx5e_build_drop_rq_param(struct mlx5e_priv *priv,
518515
param->wq.buf_numa_node = dev_to_node(mlx5_core_dma_dev(mdev));
519516
}
520517

521-
void mlx5e_build_tx_cq_param(struct mlx5e_priv *priv,
518+
void mlx5e_build_tx_cq_param(struct mlx5_core_dev *mdev,
522519
struct mlx5e_params *params,
523520
struct mlx5e_cq_param *param)
524521
{
525522
void *cqc = param->cqc;
526523

527524
MLX5_SET(cqc, cqc, log_cq_size, params->log_sq_size);
528525

529-
mlx5e_build_common_cq_param(priv, param);
526+
mlx5e_build_common_cq_param(mdev, param);
530527
param->cq_period_mode = params->tx_cq_moderation.cq_period_mode;
531528
}
532529

533-
void mlx5e_build_sq_param_common(struct mlx5e_priv *priv,
530+
void mlx5e_build_sq_param_common(struct mlx5_core_dev *mdev,
534531
struct mlx5e_sq_param *param)
535532
{
536533
void *sqc = param->sqc;
537534
void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
538535

539536
MLX5_SET(wq, wq, log_wq_stride, ilog2(MLX5_SEND_WQE_BB));
540-
MLX5_SET(wq, wq, pd, priv->mdev->mlx5e_res.hw_objs.pdn);
537+
MLX5_SET(wq, wq, pd, mdev->mlx5e_res.hw_objs.pdn);
541538

542-
param->wq.buf_numa_node = dev_to_node(mlx5_core_dma_dev(priv->mdev));
539+
param->wq.buf_numa_node = dev_to_node(mlx5_core_dma_dev(mdev));
543540
}
544541

545-
void mlx5e_build_sq_param(struct mlx5e_priv *priv, struct mlx5e_params *params,
542+
void mlx5e_build_sq_param(struct mlx5_core_dev *mdev,
543+
struct mlx5e_params *params,
546544
struct mlx5e_sq_param *param)
547545
{
548546
void *sqc = param->sqc;
549547
void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
550548
bool allow_swp;
551549

552-
allow_swp = mlx5_geneve_tx_allowed(priv->mdev) ||
553-
!!MLX5_IPSEC_DEV(priv->mdev);
554-
mlx5e_build_sq_param_common(priv, param);
550+
allow_swp = mlx5_geneve_tx_allowed(mdev) ||
551+
!!MLX5_IPSEC_DEV(mdev);
552+
mlx5e_build_sq_param_common(mdev, param);
555553
MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
556554
MLX5_SET(sqc, sqc, allow_swp, allow_swp);
557555
param->is_mpw = MLX5E_GET_PFLAG(params, MLX5E_PFLAG_SKB_TX_MPWQE);
558-
param->stop_room = mlx5e_calc_sq_stop_room(priv->mdev, params);
559-
mlx5e_build_tx_cq_param(priv, params, &param->cqp);
556+
param->stop_room = mlx5e_calc_sq_stop_room(mdev, params);
557+
mlx5e_build_tx_cq_param(mdev, params, &param->cqp);
560558
}
561559

562-
static void mlx5e_build_ico_cq_param(struct mlx5e_priv *priv,
560+
static void mlx5e_build_ico_cq_param(struct mlx5_core_dev *mdev,
563561
u8 log_wq_size,
564562
struct mlx5e_cq_param *param)
565563
{
566564
void *cqc = param->cqc;
567565

568566
MLX5_SET(cqc, cqc, log_cq_size, log_wq_size);
569567

570-
mlx5e_build_common_cq_param(priv, param);
568+
mlx5e_build_common_cq_param(mdev, param);
571569

572570
param->cq_period_mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
573571
}
@@ -592,69 +590,69 @@ static u8 mlx5e_build_icosq_log_wq_sz(struct mlx5e_params *params,
592590
}
593591
}
594592

595-
static u8 mlx5e_build_async_icosq_log_wq_sz(struct net_device *netdev)
593+
static u8 mlx5e_build_async_icosq_log_wq_sz(struct mlx5_core_dev *mdev)
596594
{
597-
if (netdev->hw_features & NETIF_F_HW_TLS_RX)
595+
if (mlx5_accel_is_ktls_rx(mdev))
598596
return MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
599597

600598
return MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE;
601599
}
602600

603-
static void mlx5e_build_icosq_param(struct mlx5e_priv *priv,
601+
static void mlx5e_build_icosq_param(struct mlx5_core_dev *mdev,
604602
u8 log_wq_size,
605603
struct mlx5e_sq_param *param)
606604
{
607605
void *sqc = param->sqc;
608606
void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
609607

610-
mlx5e_build_sq_param_common(priv, param);
608+
mlx5e_build_sq_param_common(mdev, param);
611609

612610
MLX5_SET(wq, wq, log_wq_sz, log_wq_size);
613-
MLX5_SET(sqc, sqc, reg_umr, MLX5_CAP_ETH(priv->mdev, reg_umr_sq));
614-
mlx5e_build_ico_cq_param(priv, log_wq_size, &param->cqp);
611+
MLX5_SET(sqc, sqc, reg_umr, MLX5_CAP_ETH(mdev, reg_umr_sq));
612+
mlx5e_build_ico_cq_param(mdev, log_wq_size, &param->cqp);
615613
}
616614

617-
static void mlx5e_build_async_icosq_param(struct mlx5e_priv *priv,
615+
static void mlx5e_build_async_icosq_param(struct mlx5_core_dev *mdev,
618616
u8 log_wq_size,
619617
struct mlx5e_sq_param *param)
620618
{
621619
void *sqc = param->sqc;
622620
void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
623621

624-
mlx5e_build_sq_param_common(priv, param);
622+
mlx5e_build_sq_param_common(mdev, param);
625623
param->stop_room = mlx5e_stop_room_for_wqe(1); /* for XSK NOP */
626-
MLX5_SET(sqc, sqc, reg_umr, MLX5_CAP_ETH(priv->mdev, reg_umr_sq));
624+
MLX5_SET(sqc, sqc, reg_umr, MLX5_CAP_ETH(mdev, reg_umr_sq));
627625
MLX5_SET(wq, wq, log_wq_sz, log_wq_size);
628-
mlx5e_build_ico_cq_param(priv, log_wq_size, &param->cqp);
626+
mlx5e_build_ico_cq_param(mdev, log_wq_size, &param->cqp);
629627
}
630628

631-
void mlx5e_build_xdpsq_param(struct mlx5e_priv *priv,
629+
void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
632630
struct mlx5e_params *params,
633631
struct mlx5e_sq_param *param)
634632
{
635633
void *sqc = param->sqc;
636634
void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
637635

638-
mlx5e_build_sq_param_common(priv, param);
636+
mlx5e_build_sq_param_common(mdev, param);
639637
MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
640638
param->is_mpw = MLX5E_GET_PFLAG(params, MLX5E_PFLAG_XDP_TX_MPWQE);
641-
mlx5e_build_tx_cq_param(priv, params, &param->cqp);
639+
mlx5e_build_tx_cq_param(mdev, params, &param->cqp);
642640
}
643641

644-
void mlx5e_build_channel_param(struct mlx5e_priv *priv,
642+
void mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
645643
struct mlx5e_params *params,
646644
u16 q_counter,
647645
struct mlx5e_channel_param *cparam)
648646
{
649647
u8 icosq_log_wq_sz, async_icosq_log_wq_sz;
650648

651-
mlx5e_build_rq_param(priv, params, NULL, q_counter, &cparam->rq);
649+
mlx5e_build_rq_param(mdev, params, NULL, q_counter, &cparam->rq);
652650

653651
icosq_log_wq_sz = mlx5e_build_icosq_log_wq_sz(params, &cparam->rq);
654-
async_icosq_log_wq_sz = mlx5e_build_async_icosq_log_wq_sz(priv->netdev);
652+
async_icosq_log_wq_sz = mlx5e_build_async_icosq_log_wq_sz(mdev);
655653

656-
mlx5e_build_sq_param(priv, params, &cparam->txq_sq);
657-
mlx5e_build_xdpsq_param(priv, params, &cparam->xdp_sq);
658-
mlx5e_build_icosq_param(priv, icosq_log_wq_sz, &cparam->icosq);
659-
mlx5e_build_async_icosq_param(priv, async_icosq_log_wq_sz, &cparam->async_icosq);
654+
mlx5e_build_sq_param(mdev, params, &cparam->txq_sq);
655+
mlx5e_build_xdpsq_param(mdev, params, &cparam->xdp_sq);
656+
mlx5e_build_icosq_param(mdev, icosq_log_wq_sz, &cparam->icosq);
657+
mlx5e_build_async_icosq_param(mdev, async_icosq_log_wq_sz, &cparam->async_icosq);
660658
}

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,30 +121,31 @@ u16 mlx5e_get_rq_headroom(struct mlx5_core_dev *mdev,
121121
/* Build queue parameters */
122122

123123
void mlx5e_build_create_cq_param(struct mlx5e_create_cq_param *ccp, struct mlx5e_channel *c);
124-
void mlx5e_build_rq_param(struct mlx5e_priv *priv,
124+
void mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
125125
struct mlx5e_params *params,
126126
struct mlx5e_xsk_param *xsk,
127127
u16 q_counter,
128128
struct mlx5e_rq_param *param);
129-
void mlx5e_build_drop_rq_param(struct mlx5e_priv *priv,
129+
void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev,
130130
u16 q_counter,
131131
struct mlx5e_rq_param *param);
132-
void mlx5e_build_sq_param_common(struct mlx5e_priv *priv,
132+
void mlx5e_build_sq_param_common(struct mlx5_core_dev *mdev,
133133
struct mlx5e_sq_param *param);
134-
void mlx5e_build_sq_param(struct mlx5e_priv *priv, struct mlx5e_params *params,
134+
void mlx5e_build_sq_param(struct mlx5_core_dev *mdev,
135+
struct mlx5e_params *params,
135136
struct mlx5e_sq_param *param);
136-
void mlx5e_build_tx_cq_param(struct mlx5e_priv *priv,
137+
void mlx5e_build_tx_cq_param(struct mlx5_core_dev *mdev,
137138
struct mlx5e_params *params,
138139
struct mlx5e_cq_param *param);
139-
void mlx5e_build_xdpsq_param(struct mlx5e_priv *priv,
140+
void mlx5e_build_xdpsq_param(struct mlx5_core_dev *mdev,
140141
struct mlx5e_params *params,
141142
struct mlx5e_sq_param *param);
142-
void mlx5e_build_channel_param(struct mlx5e_priv *priv,
143+
void mlx5e_build_channel_param(struct mlx5_core_dev *mdev,
143144
struct mlx5e_params *params,
144145
u16 q_counter,
145146
struct mlx5e_channel_param *cparam);
146147

147148
u16 mlx5e_calc_sq_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
148-
int mlx5e_validate_params(struct mlx5e_priv *priv, struct mlx5e_params *params);
149+
int mlx5e_validate_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
149150

150151
#endif /* __MLX5_EN_PARAMS_H__ */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,19 @@ static void mlx5e_ptp_close_cqs(struct mlx5e_port_ptp *c)
389389
mlx5e_close_cq(&c->ptpsq[tc].txqsq.cq);
390390
}
391391

392-
static void mlx5e_ptp_build_sq_param(struct mlx5e_priv *priv,
392+
static void mlx5e_ptp_build_sq_param(struct mlx5_core_dev *mdev,
393393
struct mlx5e_params *params,
394394
struct mlx5e_sq_param *param)
395395
{
396396
void *sqc = param->sqc;
397397
void *wq;
398398

399-
mlx5e_build_sq_param_common(priv, param);
399+
mlx5e_build_sq_param_common(mdev, param);
400400

401401
wq = MLX5_ADDR_OF(sqc, sqc, wq);
402402
MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
403403
param->stop_room = mlx5e_stop_room_for_wqe(MLX5_SEND_WQE_MAX_WQEBBS);
404-
mlx5e_build_tx_cq_param(priv, params, &param->cqp);
404+
mlx5e_build_tx_cq_param(mdev, params, &param->cqp);
405405
}
406406

407407
static void mlx5e_ptp_build_params(struct mlx5e_port_ptp *c,
@@ -419,7 +419,7 @@ static void mlx5e_ptp_build_params(struct mlx5e_port_ptp *c,
419419
/* SQ */
420420
params->log_sq_size = orig->log_sq_size;
421421

422-
mlx5e_ptp_build_sq_param(c->priv, params, &cparams->txq_sq_param);
422+
mlx5e_ptp_build_sq_param(c->mdev, params, &cparams->txq_sq_param);
423423
}
424424

425425
static int mlx5e_ptp_open_queues(struct mlx5e_port_ptp *c,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ static int mlx5e_open_qos_sq(struct mlx5e_priv *priv, struct mlx5e_channels *chs
232232

233233
memset(&param_sq, 0, sizeof(param_sq));
234234
memset(&param_cq, 0, sizeof(param_cq));
235-
mlx5e_build_sq_param(priv, params, &param_sq);
236-
mlx5e_build_tx_cq_param(priv, params, &param_cq);
235+
mlx5e_build_sq_param(priv->mdev, params, &param_sq);
236+
mlx5e_build_tx_cq_param(priv->mdev, params, &param_cq);
237237
err = mlx5e_open_cq(priv, params->tx_cq_moderation, &param_cq, &ccp, &sq->cq);
238238
if (err)
239239
goto err_free_sq;

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,16 @@ static void mlx5e_deactivate_trap_rq(struct mlx5e_rq *rq)
238238
clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
239239
}
240240

241-
static void mlx5e_build_trap_params(struct mlx5e_priv *priv, struct mlx5e_trap *t)
241+
static void mlx5e_build_trap_params(struct mlx5_core_dev *mdev,
242+
int max_mtu, u16 q_counter,
243+
struct mlx5e_trap *t)
242244
{
243245
struct mlx5e_params *params = &t->params;
244246

245247
params->rq_wq_type = MLX5_WQ_TYPE_CYCLIC;
246-
mlx5e_init_rq_type_params(priv->mdev, params);
247-
params->sw_mtu = priv->netdev->max_mtu;
248-
mlx5e_build_rq_param(priv, params, NULL, priv->q_counter, &t->rq_param);
248+
mlx5e_init_rq_type_params(mdev, params);
249+
params->sw_mtu = max_mtu;
250+
mlx5e_build_rq_param(mdev, params, NULL, q_counter, &t->rq_param);
249251
}
250252

251253
static struct mlx5e_trap *mlx5e_open_trap(struct mlx5e_priv *priv)
@@ -259,7 +261,7 @@ static struct mlx5e_trap *mlx5e_open_trap(struct mlx5e_priv *priv)
259261
if (!t)
260262
return ERR_PTR(-ENOMEM);
261263

262-
mlx5e_build_trap_params(priv, t);
264+
mlx5e_build_trap_params(priv->mdev, netdev->max_mtu, priv->q_counter, t);
263265

264266
t->priv = priv;
265267
t->mdev = priv->mdev;

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
3535
}
3636
}
3737

38-
static void mlx5e_build_xsk_cparam(struct mlx5e_priv *priv,
38+
static void mlx5e_build_xsk_cparam(struct mlx5_core_dev *mdev,
3939
struct mlx5e_params *params,
4040
struct mlx5e_xsk_param *xsk,
41+
u16 q_counter,
4142
struct mlx5e_channel_param *cparam)
4243
{
43-
mlx5e_build_rq_param(priv, params, xsk, priv->q_counter, &cparam->rq);
44-
mlx5e_build_xdpsq_param(priv, params, &cparam->xdp_sq);
44+
mlx5e_build_rq_param(mdev, params, xsk, q_counter, &cparam->rq);
45+
mlx5e_build_xdpsq_param(mdev, params, &cparam->xdp_sq);
4546
}
4647

4748
int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
@@ -61,7 +62,7 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
6162
if (!cparam)
6263
return -ENOMEM;
6364

64-
mlx5e_build_xsk_cparam(priv, params, xsk, cparam);
65+
mlx5e_build_xsk_cparam(priv->mdev, params, xsk, priv->q_counter, cparam);
6566

6667
err = mlx5e_open_cq(c->priv, params->rx_cq_moderation, &cparam->rq.cqp, &ccp,
6768
&c->xskrq.cq);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ int mlx5e_ethtool_set_ringparam(struct mlx5e_priv *priv,
368368
new_channels.params.log_rq_mtu_frames = log_rq_size;
369369
new_channels.params.log_sq_size = log_sq_size;
370370

371-
err = mlx5e_validate_params(priv, &new_channels.params);
371+
err = mlx5e_validate_params(priv->mdev, &new_channels.params);
372372
if (err)
373373
goto unlock;
374374

0 commit comments

Comments
 (0)