Skip to content

Commit feb2ff9

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: XDP, Change the XDP SQ redirect indication
Do not maintain an SQ state bit to indicate whether an XDP SQ serves redirect operations. Instead, rely on the fact that such an XDP SQ doesn't reside in an RQ instance, while the others do. This info is not known to the XDP SQ functions themselves, and they rely on their callers to distinguish between the cases. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 4fb2f51 commit feb2ff9

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ enum {
344344
MLX5E_SQ_STATE_IPSEC,
345345
MLX5E_SQ_STATE_AM,
346346
MLX5E_SQ_STATE_TLS,
347-
MLX5E_SQ_STATE_REDIRECT,
348347
};
349348

350349
struct mlx5e_sq_wqe_info {

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,10 @@ bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi)
164164
return true;
165165
}
166166

167-
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
167+
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq, struct mlx5e_rq *rq)
168168
{
169169
struct mlx5e_xdpsq *sq;
170170
struct mlx5_cqe64 *cqe;
171-
struct mlx5e_rq *rq;
172171
bool is_redirect;
173172
u16 sqcc;
174173
int i;
@@ -182,8 +181,7 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
182181
if (!cqe)
183182
return false;
184183

185-
is_redirect = test_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
186-
rq = container_of(sq, struct mlx5e_rq, xdpsq);
184+
is_redirect = !rq;
187185

188186
/* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
189187
* otherwise a cq overrun may occur
@@ -228,13 +226,9 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
228226
return (i == MLX5E_TX_CQ_POLL_BUDGET);
229227
}
230228

231-
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq)
229+
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq)
232230
{
233-
struct mlx5e_rq *rq;
234-
bool is_redirect;
235-
236-
is_redirect = test_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
237-
rq = is_redirect ? NULL : container_of(sq, struct mlx5e_rq, xdpsq);
231+
bool is_redirect = !rq;
238232

239233
while (sq->cc != sq->pc) {
240234
u16 ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343
bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
4444
void *va, u16 *rx_headroom, u32 *len);
45-
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq);
46-
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq);
45+
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq, struct mlx5e_rq *rq);
46+
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq);
4747
void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq);
4848
bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi);
4949
int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,6 @@ static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
15771577
csp.cqn = sq->cq.mcq.cqn;
15781578
csp.wq_ctrl = &sq->wq_ctrl;
15791579
csp.min_inline_mode = sq->min_inline_mode;
1580-
if (is_redirect)
1581-
set_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
15821580
set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
15831581
err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn);
15841582
if (err)
@@ -1612,15 +1610,15 @@ static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
16121610
return err;
16131611
}
16141612

1615-
static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
1613+
static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq)
16161614
{
16171615
struct mlx5e_channel *c = sq->channel;
16181616

16191617
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
16201618
napi_synchronize(&c->napi);
16211619

16221620
mlx5e_destroy_sq(c->mdev, sq->sqn);
1623-
mlx5e_free_xdpsq_descs(sq);
1621+
mlx5e_free_xdpsq_descs(sq, rq);
16241622
mlx5e_free_xdpsq(sq);
16251623
}
16261624

@@ -2008,7 +2006,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
20082006

20092007
err_close_xdp_sq:
20102008
if (c->xdp)
2011-
mlx5e_close_xdpsq(&c->rq.xdpsq);
2009+
mlx5e_close_xdpsq(&c->rq.xdpsq, &c->rq);
20122010

20132011
err_close_sqs:
20142012
mlx5e_close_sqs(c);
@@ -2061,10 +2059,10 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
20612059

20622060
static void mlx5e_close_channel(struct mlx5e_channel *c)
20632061
{
2064-
mlx5e_close_xdpsq(&c->xdpsq);
2062+
mlx5e_close_xdpsq(&c->xdpsq, NULL);
20652063
mlx5e_close_rq(&c->rq);
20662064
if (c->xdp)
2067-
mlx5e_close_xdpsq(&c->rq.xdpsq);
2065+
mlx5e_close_xdpsq(&c->rq.xdpsq, &c->rq);
20682066
mlx5e_close_sqs(c);
20692067
mlx5e_close_icosq(&c->icosq);
20702068
napi_disable(&c->napi);

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
7676
struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel,
7777
napi);
7878
struct mlx5e_ch_stats *ch_stats = c->stats;
79+
struct mlx5e_rq *rq = &c->rq;
7980
bool busy = false;
8081
int work_done = 0;
8182
int i;
@@ -85,17 +86,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
8586
for (i = 0; i < c->num_tc; i++)
8687
busy |= mlx5e_poll_tx_cq(&c->sq[i].cq, budget);
8788

88-
busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq.cq);
89+
busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq.cq, NULL);
8990

9091
if (c->xdp)
91-
busy |= mlx5e_poll_xdpsq_cq(&c->rq.xdpsq.cq);
92+
busy |= mlx5e_poll_xdpsq_cq(&rq->xdpsq.cq, rq);
9293

9394
if (likely(budget)) { /* budget=0 means: don't poll rx rings */
94-
work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget);
95+
work_done = mlx5e_poll_rx_cq(&rq->cq, budget);
9596
busy |= work_done == budget;
9697
}
9798

98-
busy |= c->rq.post_wqes(&c->rq);
99+
busy |= c->rq.post_wqes(rq);
99100

100101
if (busy) {
101102
if (likely(mlx5e_channel_no_affinity_change(c)))
@@ -115,9 +116,9 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
115116
mlx5e_cq_arm(&c->sq[i].cq);
116117
}
117118

118-
mlx5e_handle_rx_dim(&c->rq);
119+
mlx5e_handle_rx_dim(rq);
119120

120-
mlx5e_cq_arm(&c->rq.cq);
121+
mlx5e_cq_arm(&rq->cq);
121122
mlx5e_cq_arm(&c->icosq.cq);
122123
mlx5e_cq_arm(&c->xdpsq.cq);
123124

0 commit comments

Comments
 (0)