Skip to content

Commit 521f31a

Browse files
ayalevinSaeed Mahameed
authored andcommitted
net/mlx5e: Allow RQ outside of channel context
In order to be able to create an RQ outside of a channel context, remove rq->channel direct pointer. This requires adding a direct pointer to: ICOSQ and priv in order to support RQs that are part of mlx5e_channel. Use channel_stats from the corresponding CQ. Signed-off-by: Aya Levin <[email protected]> Signed-off-by: Eran Ben Elisha <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4d0b7ef commit 521f31a

File tree

7 files changed

+59
-53
lines changed

7 files changed

+59
-53
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ struct mlx5e_rq {
595595
u8 map_dir; /* dma map direction */
596596
} buff;
597597

598-
struct mlx5e_channel *channel;
599598
struct device *pdev;
600599
struct net_device *netdev;
601600
struct mlx5e_rq_stats *stats;
@@ -604,6 +603,8 @@ struct mlx5e_rq {
604603
struct mlx5e_page_cache page_cache;
605604
struct hwtstamp_config *tstamp;
606605
struct mlx5_clock *clock;
606+
struct mlx5e_icosq *icosq;
607+
struct mlx5e_priv *priv;
607608

608609
mlx5e_fp_handle_rx_cqe handle_rx_cqe;
609610
mlx5e_fp_post_rx_wqes post_wqes;

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,22 @@ int mlx5e_health_recover_channels(struct mlx5e_priv *priv)
205205
return err;
206206
}
207207

208-
int mlx5e_health_channel_eq_recover(struct mlx5_eq_comp *eq, struct mlx5e_channel *channel)
208+
int mlx5e_health_channel_eq_recover(struct net_device *dev, struct mlx5_eq_comp *eq,
209+
struct mlx5e_ch_stats *stats)
209210
{
210211
u32 eqe_count;
211212

212-
netdev_err(channel->netdev, "EQ 0x%x: Cons = 0x%x, irqn = 0x%x\n",
213+
netdev_err(dev, "EQ 0x%x: Cons = 0x%x, irqn = 0x%x\n",
213214
eq->core.eqn, eq->core.cons_index, eq->core.irqn);
214215

215216
eqe_count = mlx5_eq_poll_irq_disabled(eq);
216217
if (!eqe_count)
217218
return -EIO;
218219

219-
netdev_err(channel->netdev, "Recovered %d eqes on EQ 0x%x\n",
220+
netdev_err(dev, "Recovered %d eqes on EQ 0x%x\n",
220221
eqe_count, eq->core.eqn);
221222

222-
channel->stats->eq_rearm++;
223+
stats->eq_rearm++;
223224
return 0;
224225
}
225226

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ struct mlx5e_err_ctx {
4343
};
4444

4545
int mlx5e_health_sq_to_ready(struct mlx5e_channel *channel, u32 sqn);
46-
int mlx5e_health_channel_eq_recover(struct mlx5_eq_comp *eq, struct mlx5e_channel *channel);
46+
int mlx5e_health_channel_eq_recover(struct net_device *dev, struct mlx5_eq_comp *eq,
47+
struct mlx5e_ch_stats *stats);
4748
int mlx5e_health_recover_channels(struct mlx5e_priv *priv);
4849
int mlx5e_health_report(struct mlx5e_priv *priv,
4950
struct devlink_health_reporter *reporter, char *err_str,

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

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,16 @@ static int mlx5e_rx_reporter_err_rq_cqe_recover(void *ctx)
146146

147147
static int mlx5e_rx_reporter_timeout_recover(void *ctx)
148148
{
149-
struct mlx5e_icosq *icosq;
150149
struct mlx5_eq_comp *eq;
151150
struct mlx5e_rq *rq;
152151
int err;
153152

154153
rq = ctx;
155-
icosq = &rq->channel->icosq;
156154
eq = rq->cq.mcq.eq;
157-
err = mlx5e_health_channel_eq_recover(eq, rq->channel);
158-
if (err)
159-
clear_bit(MLX5E_SQ_STATE_ENABLED, &icosq->state);
155+
156+
err = mlx5e_health_channel_eq_recover(rq->netdev, eq, rq->cq.ch_stats);
157+
if (err && rq->icosq)
158+
clear_bit(MLX5E_SQ_STATE_ENABLED, &rq->icosq->state);
160159

161160
return err;
162161
}
@@ -233,21 +232,13 @@ static int mlx5e_reporter_icosq_diagnose(struct mlx5e_icosq *icosq, u8 hw_state,
233232
static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
234233
struct devlink_fmsg *fmsg)
235234
{
236-
struct mlx5e_priv *priv = rq->channel->priv;
237-
struct mlx5e_icosq *icosq;
238-
u8 icosq_hw_state;
239235
u16 wqe_counter;
240236
int wqes_sz;
241237
u8 hw_state;
242238
u16 wq_head;
243239
int err;
244240

245-
icosq = &rq->channel->icosq;
246-
err = mlx5e_query_rq_state(priv->mdev, rq->rqn, &hw_state);
247-
if (err)
248-
return err;
249-
250-
err = mlx5_core_query_sq_state(priv->mdev, icosq->sqn, &icosq_hw_state);
241+
err = mlx5e_query_rq_state(rq->mdev, rq->rqn, &hw_state);
251242
if (err)
252243
return err;
253244

@@ -259,7 +250,7 @@ static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
259250
if (err)
260251
return err;
261252

262-
err = devlink_fmsg_u32_pair_put(fmsg, "channel ix", rq->channel->ix);
253+
err = devlink_fmsg_u32_pair_put(fmsg, "channel ix", rq->ix);
263254
if (err)
264255
return err;
265256

@@ -295,9 +286,18 @@ static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
295286
if (err)
296287
return err;
297288

298-
err = mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
299-
if (err)
300-
return err;
289+
if (rq->icosq) {
290+
struct mlx5e_icosq *icosq = rq->icosq;
291+
u8 icosq_hw_state;
292+
293+
err = mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state);
294+
if (err)
295+
return err;
296+
297+
err = mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
298+
if (err)
299+
return err;
300+
}
301301

302302
err = devlink_fmsg_obj_nest_end(fmsg);
303303
if (err)
@@ -557,25 +557,29 @@ static int mlx5e_rx_reporter_dump(struct devlink_health_reporter *reporter,
557557

558558
void mlx5e_reporter_rx_timeout(struct mlx5e_rq *rq)
559559
{
560-
struct mlx5e_icosq *icosq = &rq->channel->icosq;
561-
struct mlx5e_priv *priv = rq->channel->priv;
560+
char icosq_str[MLX5E_REPORTER_PER_Q_MAX_LEN] = {};
562561
char err_str[MLX5E_REPORTER_PER_Q_MAX_LEN];
562+
struct mlx5e_icosq *icosq = rq->icosq;
563+
struct mlx5e_priv *priv = rq->priv;
563564
struct mlx5e_err_ctx err_ctx = {};
564565

565566
err_ctx.ctx = rq;
566567
err_ctx.recover = mlx5e_rx_reporter_timeout_recover;
567568
err_ctx.dump = mlx5e_rx_reporter_dump_rq;
569+
570+
if (icosq)
571+
snprintf(icosq_str, sizeof(icosq_str), "ICOSQ: 0x%x, ", icosq->sqn);
568572
snprintf(err_str, sizeof(err_str),
569-
"RX timeout on channel: %d, ICOSQ: 0x%x RQ: 0x%x, CQ: 0x%x",
570-
icosq->channel->ix, icosq->sqn, rq->rqn, rq->cq.mcq.cqn);
573+
"RX timeout on channel: %d, %sRQ: 0x%x, CQ: 0x%x",
574+
rq->ix, icosq_str, rq->rqn, rq->cq.mcq.cqn);
571575

572576
mlx5e_health_report(priv, priv->rx_reporter, err_str, &err_ctx);
573577
}
574578

575579
void mlx5e_reporter_rq_cqe_err(struct mlx5e_rq *rq)
576580
{
577-
struct mlx5e_priv *priv = rq->channel->priv;
578581
char err_str[MLX5E_REPORTER_PER_Q_MAX_LEN];
582+
struct mlx5e_priv *priv = rq->priv;
579583
struct mlx5e_err_ctx err_ctx = {};
580584

581585
err_ctx.ctx = rq;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int mlx5e_tx_reporter_timeout_recover(void *ctx)
100100
sq = to_ctx->sq;
101101
eq = sq->cq.mcq.eq;
102102
priv = sq->channel->priv;
103-
err = mlx5e_health_channel_eq_recover(eq, sq->channel);
103+
err = mlx5e_health_channel_eq_recover(sq->channel->netdev, eq, sq->channel->stats);
104104
if (!err) {
105105
to_ctx->status = 0; /* this sq recovered */
106106
return err;

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,10 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
412412
rq->wq_type = params->rq_wq_type;
413413
rq->pdev = c->pdev;
414414
rq->netdev = c->netdev;
415+
rq->priv = c->priv;
415416
rq->tstamp = c->tstamp;
416417
rq->clock = &mdev->clock;
417-
rq->channel = c;
418+
rq->icosq = &c->icosq;
418419
rq->ix = c->ix;
419420
rq->mdev = mdev;
420421
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
@@ -617,7 +618,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)
617618
int i;
618619

619620
old_prog = rcu_dereference_protected(rq->xdp_prog,
620-
lockdep_is_held(&rq->channel->priv->state_lock));
621+
lockdep_is_held(&rq->priv->state_lock));
621622
if (old_prog)
622623
bpf_prog_put(old_prog);
623624

@@ -717,9 +718,7 @@ int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state, int next_state)
717718

718719
static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
719720
{
720-
struct mlx5e_channel *c = rq->channel;
721-
struct mlx5e_priv *priv = c->priv;
722-
struct mlx5_core_dev *mdev = priv->mdev;
721+
struct mlx5_core_dev *mdev = rq->mdev;
723722

724723
void *in;
725724
void *rqc;
@@ -748,8 +747,7 @@ static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
748747

749748
static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
750749
{
751-
struct mlx5e_channel *c = rq->channel;
752-
struct mlx5_core_dev *mdev = c->mdev;
750+
struct mlx5_core_dev *mdev = rq->mdev;
753751
void *in;
754752
void *rqc;
755753
int inlen;
@@ -783,7 +781,6 @@ static void mlx5e_destroy_rq(struct mlx5e_rq *rq)
783781
int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time)
784782
{
785783
unsigned long exp_time = jiffies + msecs_to_jiffies(wait_time);
786-
struct mlx5e_channel *c = rq->channel;
787784

788785
u16 min_wqes = mlx5_min_rx_wqes(rq->wq_type, mlx5e_rqwq_get_size(rq));
789786

@@ -794,8 +791,8 @@ int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time)
794791
msleep(20);
795792
} while (time_before(jiffies, exp_time));
796793

797-
netdev_warn(c->netdev, "Failed to get min RX wqes on Channel[%d] RQN[0x%x] wq cur_sz(%d) min_rx_wqes(%d)\n",
798-
c->ix, rq->rqn, mlx5e_rqwq_get_cur_sz(rq), min_wqes);
794+
netdev_warn(rq->netdev, "Failed to get min RX wqes on Channel[%d] RQN[0x%x] wq cur_sz(%d) min_rx_wqes(%d)\n",
795+
rq->ix, rq->rqn, mlx5e_rqwq_get_cur_sz(rq), min_wqes);
799796

800797
mlx5e_reporter_rx_timeout(rq);
801798
return -ETIMEDOUT;
@@ -910,7 +907,7 @@ int mlx5e_open_rq(struct mlx5e_channel *c, struct mlx5e_params *params,
910907
void mlx5e_activate_rq(struct mlx5e_rq *rq)
911908
{
912909
set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
913-
mlx5e_trigger_irq(&rq->channel->icosq);
910+
mlx5e_trigger_irq(rq->icosq);
914911
}
915912

916913
void mlx5e_deactivate_rq(struct mlx5e_rq *rq)
@@ -922,7 +919,7 @@ void mlx5e_deactivate_rq(struct mlx5e_rq *rq)
922919
void mlx5e_close_rq(struct mlx5e_rq *rq)
923920
{
924921
cancel_work_sync(&rq->dim.work);
925-
cancel_work_sync(&rq->channel->icosq.recover_work);
922+
cancel_work_sync(&rq->icosq->recover_work);
926923
cancel_work_sync(&rq->recover_work);
927924
mlx5e_destroy_rq(rq);
928925
mlx5e_free_rx_descs(rq);
@@ -4411,7 +4408,7 @@ static void mlx5e_rq_replace_xdp_prog(struct mlx5e_rq *rq, struct bpf_prog *prog
44114408
struct bpf_prog *old_prog;
44124409

44134410
old_prog = rcu_replace_pointer(rq->xdp_prog, prog,
4414-
lockdep_is_held(&rq->channel->priv->state_lock));
4411+
lockdep_is_held(&rq->priv->state_lock));
44154412
if (old_prog)
44164413
bpf_prog_put(old_prog);
44174414
}

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
503503
{
504504
struct mlx5e_mpw_info *wi = &rq->mpwqe.info[ix];
505505
struct mlx5e_dma_info *dma_info = &wi->umr.dma_info[0];
506-
struct mlx5e_icosq *sq = &rq->channel->icosq;
506+
struct mlx5e_icosq *sq = rq->icosq;
507507
struct mlx5_wq_cyc *wq = &sq->wq;
508508
struct mlx5e_umr_wqe *umr_wqe;
509509
u16 xlt_offset = ix << (MLX5E_LOG_ALIGNED_MPWQE_PPW - 1);
@@ -713,9 +713,9 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
713713

714714
INDIRECT_CALLABLE_SCOPE bool mlx5e_post_rx_mpwqes(struct mlx5e_rq *rq)
715715
{
716-
struct mlx5e_icosq *sq = &rq->channel->icosq;
717716
struct mlx5_wq_ll *wq = &rq->mpwqe.wq;
718717
u8 umr_completed = rq->mpwqe.umr_completed;
718+
struct mlx5e_icosq *sq = rq->icosq;
719719
int alloc_err = 0;
720720
u8 missing, i;
721721
u16 head;
@@ -1218,11 +1218,12 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
12181218
static void trigger_report(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
12191219
{
12201220
struct mlx5_err_cqe *err_cqe = (struct mlx5_err_cqe *)cqe;
1221+
struct mlx5e_priv *priv = rq->priv;
12211222

12221223
if (cqe_syndrome_needs_recover(err_cqe->syndrome) &&
12231224
!test_and_set_bit(MLX5E_RQ_STATE_RECOVERING, &rq->state)) {
12241225
mlx5e_dump_error_cqe(&rq->cq, rq->rqn, err_cqe);
1225-
queue_work(rq->channel->priv->wq, &rq->recover_work);
1226+
queue_work(priv->wq, &rq->recover_work);
12261227
}
12271228
}
12281229

@@ -1771,8 +1772,9 @@ static void mlx5e_ipsec_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cq
17711772

17721773
int mlx5e_rq_set_handlers(struct mlx5e_rq *rq, struct mlx5e_params *params, bool xsk)
17731774
{
1775+
struct net_device *netdev = rq->netdev;
17741776
struct mlx5_core_dev *mdev = rq->mdev;
1775-
struct mlx5e_channel *c = rq->channel;
1777+
struct mlx5e_priv *priv = rq->priv;
17761778

17771779
switch (rq->wq_type) {
17781780
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
@@ -1784,15 +1786,15 @@ int mlx5e_rq_set_handlers(struct mlx5e_rq *rq, struct mlx5e_params *params, bool
17841786
rq->post_wqes = mlx5e_post_rx_mpwqes;
17851787
rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe;
17861788

1787-
rq->handle_rx_cqe = c->priv->profile->rx_handlers->handle_rx_cqe_mpwqe;
1789+
rq->handle_rx_cqe = priv->profile->rx_handlers->handle_rx_cqe_mpwqe;
17881790
#ifdef CONFIG_MLX5_EN_IPSEC
17891791
if (MLX5_IPSEC_DEV(mdev)) {
1790-
netdev_err(c->netdev, "MPWQE RQ with IPSec offload not supported\n");
1792+
netdev_err(netdev, "MPWQE RQ with IPSec offload not supported\n");
17911793
return -EINVAL;
17921794
}
17931795
#endif
17941796
if (!rq->handle_rx_cqe) {
1795-
netdev_err(c->netdev, "RX handler of MPWQE RQ is not set\n");
1797+
netdev_err(netdev, "RX handler of MPWQE RQ is not set\n");
17961798
return -EINVAL;
17971799
}
17981800
break;
@@ -1807,13 +1809,13 @@ int mlx5e_rq_set_handlers(struct mlx5e_rq *rq, struct mlx5e_params *params, bool
18071809

18081810
#ifdef CONFIG_MLX5_EN_IPSEC
18091811
if ((mlx5_fpga_ipsec_device_caps(mdev) & MLX5_ACCEL_IPSEC_CAP_DEVICE) &&
1810-
c->priv->ipsec)
1812+
priv->ipsec)
18111813
rq->handle_rx_cqe = mlx5e_ipsec_handle_rx_cqe;
18121814
else
18131815
#endif
1814-
rq->handle_rx_cqe = c->priv->profile->rx_handlers->handle_rx_cqe;
1816+
rq->handle_rx_cqe = priv->profile->rx_handlers->handle_rx_cqe;
18151817
if (!rq->handle_rx_cqe) {
1816-
netdev_err(c->netdev, "RX handler of RQ is not set\n");
1818+
netdev_err(netdev, "RX handler of RQ is not set\n");
18171819
return -EINVAL;
18181820
}
18191821
}

0 commit comments

Comments
 (0)