Skip to content

Commit 8d94b59

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Turn XSK ICOSQ into a general asynchronous one
There is an upcoming demand (in downstream patches) for an ICOSQ to be populated out of the NAPI context, asynchronously. There is already an existing one serving XSK-related use case. In this patch, promote this ICOSQ to serve as general async ICOSQ, to be used for XSK and non-XSK flows. As part of this, the reg_umr bit of the SQ context is now set (if capable), as the general async ICOSQ should support possible posts of UMR WQEs. Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent e396ecc commit 8d94b59

File tree

5 files changed

+42
-61
lines changed

5 files changed

+42
-61
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,11 @@ struct mlx5e_channel {
651651
/* AF_XDP zero-copy */
652652
struct mlx5e_rq xskrq;
653653
struct mlx5e_xdpsq xsksq;
654-
struct mlx5e_icosq xskicosq;
655-
/* xskicosq can be accessed from any CPU - the spinlock protects it. */
656-
spinlock_t xskicosq_lock;
654+
655+
/* Async ICOSQ */
656+
struct mlx5e_icosq async_icosq;
657+
/* async_icosq can be accessed from any CPU - the spinlock protects it. */
658+
spinlock_t async_icosq_lock;
657659

658660
/* data path - accessed per napi poll */
659661
struct irq_desc *irq_desc;

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

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,22 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
3434
}
3535
}
3636

37-
static void mlx5e_build_xskicosq_param(struct mlx5e_priv *priv,
38-
u8 log_wq_size,
39-
struct mlx5e_sq_param *param)
40-
{
41-
void *sqc = param->sqc;
42-
void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
43-
44-
mlx5e_build_sq_param_common(priv, param);
45-
46-
MLX5_SET(wq, wq, log_wq_sz, log_wq_size);
47-
}
48-
4937
static void mlx5e_build_xsk_cparam(struct mlx5e_priv *priv,
5038
struct mlx5e_params *params,
5139
struct mlx5e_xsk_param *xsk,
5240
struct mlx5e_channel_param *cparam)
5341
{
54-
const u8 xskicosq_size = MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE;
55-
5642
mlx5e_build_rq_param(priv, params, xsk, &cparam->rq);
5743
mlx5e_build_xdpsq_param(priv, params, &cparam->xdp_sq);
58-
mlx5e_build_xskicosq_param(priv, xskicosq_size, &cparam->icosq);
5944
mlx5e_build_rx_cq_param(priv, params, xsk, &cparam->rx_cq);
6045
mlx5e_build_tx_cq_param(priv, params, &cparam->tx_cq);
61-
mlx5e_build_ico_cq_param(priv, xskicosq_size, &cparam->icosq_cq);
6246
}
6347

6448
int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
6549
struct mlx5e_xsk_param *xsk, struct xdp_umem *umem,
6650
struct mlx5e_channel *c)
6751
{
6852
struct mlx5e_channel_param *cparam;
69-
struct dim_cq_moder icocq_moder = {};
7053
int err;
7154

7255
if (!mlx5e_validate_xsk_param(params, xsk, priv->mdev))
@@ -100,31 +83,12 @@ int mlx5e_open_xsk(struct mlx5e_priv *priv, struct mlx5e_params *params,
10083
if (unlikely(err))
10184
goto err_close_tx_cq;
10285

103-
err = mlx5e_open_cq(c, icocq_moder, &cparam->icosq_cq, &c->xskicosq.cq);
104-
if (unlikely(err))
105-
goto err_close_sq;
106-
107-
/* Create a dedicated SQ for posting NOPs whenever we need an IRQ to be
108-
* triggered and NAPI to be called on the correct CPU.
109-
*/
110-
err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->xskicosq);
111-
if (unlikely(err))
112-
goto err_close_icocq;
113-
11486
kvfree(cparam);
11587

116-
spin_lock_init(&c->xskicosq_lock);
117-
11888
set_bit(MLX5E_CHANNEL_STATE_XSK, c->state);
11989

12090
return 0;
12191

122-
err_close_icocq:
123-
mlx5e_close_cq(&c->xskicosq.cq);
124-
125-
err_close_sq:
126-
mlx5e_close_xdpsq(&c->xsksq);
127-
12892
err_close_tx_cq:
12993
mlx5e_close_cq(&c->xsksq.cq);
13094

@@ -148,32 +112,27 @@ void mlx5e_close_xsk(struct mlx5e_channel *c)
148112

149113
mlx5e_close_rq(&c->xskrq);
150114
mlx5e_close_cq(&c->xskrq.cq);
151-
mlx5e_close_icosq(&c->xskicosq);
152-
mlx5e_close_cq(&c->xskicosq.cq);
153115
mlx5e_close_xdpsq(&c->xsksq);
154116
mlx5e_close_cq(&c->xsksq.cq);
155117

156118
memset(&c->xskrq, 0, sizeof(c->xskrq));
157119
memset(&c->xsksq, 0, sizeof(c->xsksq));
158-
memset(&c->xskicosq, 0, sizeof(c->xskicosq));
159120
}
160121

161122
void mlx5e_activate_xsk(struct mlx5e_channel *c)
162123
{
163-
mlx5e_activate_icosq(&c->xskicosq);
164124
set_bit(MLX5E_RQ_STATE_ENABLED, &c->xskrq.state);
165125
/* TX queue is created active. */
166126

167-
spin_lock(&c->xskicosq_lock);
168-
mlx5e_trigger_irq(&c->xskicosq);
169-
spin_unlock(&c->xskicosq_lock);
127+
spin_lock(&c->async_icosq_lock);
128+
mlx5e_trigger_irq(&c->async_icosq);
129+
spin_unlock(&c->async_icosq_lock);
170130
}
171131

172132
void mlx5e_deactivate_xsk(struct mlx5e_channel *c)
173133
{
174134
mlx5e_deactivate_rq(&c->xskrq);
175135
/* TX queue is disabled on close. */
176-
mlx5e_deactivate_icosq(&c->xskicosq);
177136
}
178137

179138
static int mlx5e_redirect_xsk_rqt(struct mlx5e_priv *priv, u16 ix, u32 rqn)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
2626
return -ENXIO;
2727

2828
if (!napi_if_scheduled_mark_missed(&c->napi)) {
29-
/* To avoid WQE overrun, don't post a NOP if XSKICOSQ is not
29+
/* To avoid WQE overrun, don't post a NOP if async_icosq is not
3030
* active and not polled by NAPI. Return 0, because the upcoming
3131
* activate will trigger the IRQ for us.
3232
*/
33-
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &c->xskicosq.state)))
33+
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &c->async_icosq.state)))
3434
return 0;
3535

36-
if (test_and_set_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->xskicosq.state))
36+
if (test_and_set_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->async_icosq.state))
3737
return 0;
3838

39-
spin_lock(&c->xskicosq_lock);
40-
mlx5e_trigger_irq(&c->xskicosq);
41-
spin_unlock(&c->xskicosq_lock);
39+
spin_lock(&c->async_icosq_lock);
40+
mlx5e_trigger_irq(&c->async_icosq);
41+
spin_unlock(&c->async_icosq_lock);
4242
}
4343

4444
return 0;

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,10 +1817,14 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
18171817
struct dim_cq_moder icocq_moder = {0, 0};
18181818
int err;
18191819

1820-
err = mlx5e_open_cq(c, icocq_moder, &cparam->icosq_cq, &c->icosq.cq);
1820+
err = mlx5e_open_cq(c, icocq_moder, &cparam->icosq_cq, &c->async_icosq.cq);
18211821
if (err)
18221822
return err;
18231823

1824+
err = mlx5e_open_cq(c, icocq_moder, &cparam->icosq_cq, &c->icosq.cq);
1825+
if (err)
1826+
goto err_close_async_icosq_cq;
1827+
18241828
err = mlx5e_open_tx_cqs(c, params, cparam);
18251829
if (err)
18261830
goto err_close_icosq_cq;
@@ -1841,10 +1845,16 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
18411845

18421846
napi_enable(&c->napi);
18431847

1844-
err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->icosq);
1848+
spin_lock_init(&c->async_icosq_lock);
1849+
1850+
err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->async_icosq);
18451851
if (err)
18461852
goto err_disable_napi;
18471853

1854+
err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->icosq);
1855+
if (err)
1856+
goto err_close_async_icosq;
1857+
18481858
err = mlx5e_open_sqs(c, params, cparam);
18491859
if (err)
18501860
goto err_close_icosq;
@@ -1879,6 +1889,9 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
18791889
err_close_icosq:
18801890
mlx5e_close_icosq(&c->icosq);
18811891

1892+
err_close_async_icosq:
1893+
mlx5e_close_icosq(&c->async_icosq);
1894+
18821895
err_disable_napi:
18831896
napi_disable(&c->napi);
18841897

@@ -1897,6 +1910,9 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
18971910
err_close_icosq_cq:
18981911
mlx5e_close_cq(&c->icosq.cq);
18991912

1913+
err_close_async_icosq_cq:
1914+
mlx5e_close_cq(&c->async_icosq.cq);
1915+
19001916
return err;
19011917
}
19021918

@@ -1908,13 +1924,15 @@ static void mlx5e_close_queues(struct mlx5e_channel *c)
19081924
mlx5e_close_xdpsq(&c->rq_xdpsq);
19091925
mlx5e_close_sqs(c);
19101926
mlx5e_close_icosq(&c->icosq);
1927+
mlx5e_close_icosq(&c->async_icosq);
19111928
napi_disable(&c->napi);
19121929
if (c->xdp)
19131930
mlx5e_close_cq(&c->rq_xdpsq.cq);
19141931
mlx5e_close_cq(&c->rq.cq);
19151932
mlx5e_close_cq(&c->xdpsq.cq);
19161933
mlx5e_close_tx_cqs(c);
19171934
mlx5e_close_cq(&c->icosq.cq);
1935+
mlx5e_close_cq(&c->async_icosq.cq);
19181936
}
19191937

19201938
static u8 mlx5e_enumerate_lag_port(struct mlx5_core_dev *mdev, int ix)
@@ -1995,6 +2013,7 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)
19952013
for (tc = 0; tc < c->num_tc; tc++)
19962014
mlx5e_activate_txqsq(&c->sq[tc]);
19972015
mlx5e_activate_icosq(&c->icosq);
2016+
mlx5e_activate_icosq(&c->async_icosq);
19982017
mlx5e_activate_rq(&c->rq);
19992018

20002019
if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
@@ -2009,6 +2028,7 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
20092028
mlx5e_deactivate_xsk(c);
20102029

20112030
mlx5e_deactivate_rq(&c->rq);
2031+
mlx5e_deactivate_icosq(&c->async_icosq);
20122032
mlx5e_deactivate_icosq(&c->icosq);
20132033
for (tc = 0; tc < c->num_tc; tc++)
20142034
mlx5e_deactivate_txqsq(&c->sq[tc]);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
149149
}
150150

151151
mlx5e_poll_ico_cq(&c->icosq.cq);
152+
if (mlx5e_poll_ico_cq(&c->async_icosq.cq))
153+
/* Don't clear the flag if nothing was polled to prevent
154+
* queueing more WQEs and overflowing the async ICOSQ.
155+
*/
156+
clear_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->async_icosq.state);
152157

153158
busy |= INDIRECT_CALL_2(rq->post_wqes,
154159
mlx5e_post_rx_mpwqes,
155160
mlx5e_post_rx_wqes,
156161
rq);
157162
if (xsk_open) {
158-
if (mlx5e_poll_ico_cq(&c->xskicosq.cq))
159-
/* Don't clear the flag if nothing was polled to prevent
160-
* queueing more WQEs and overflowing XSKICOSQ.
161-
*/
162-
clear_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->xskicosq.state);
163163
busy |= mlx5e_poll_xdpsq_cq(&xsksq->cq);
164164
busy_xsk |= mlx5e_napi_xsk_post(xsksq, xskrq);
165165
}
@@ -189,11 +189,11 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
189189

190190
mlx5e_cq_arm(&rq->cq);
191191
mlx5e_cq_arm(&c->icosq.cq);
192+
mlx5e_cq_arm(&c->async_icosq.cq);
192193
mlx5e_cq_arm(&c->xdpsq.cq);
193194

194195
if (xsk_open) {
195196
mlx5e_handle_rx_dim(xskrq);
196-
mlx5e_cq_arm(&c->xskicosq.cq);
197197
mlx5e_cq_arm(&xsksq->cq);
198198
mlx5e_cq_arm(&xskrq->cq);
199199
}

0 commit comments

Comments
 (0)