Skip to content

Commit c0f1147

Browse files
Mohamad Haj Yahiadavem330
authored andcommitted
net/mlx5e: Change the SQ/RQ operational state to positive logic
When using the negative logic (i.e. FLUSH state), after the RQ/SQ reopen we will have a time interval that the RQ/SQ is not really ready and the state indicates that its not in FLUSH state because the initial SQ/RQ struct memory starts as zeros. Now we changed the state to indicate if the SQ/RQ is opened and we will set the READY state after finishing preparing all the SQ/RQ resources. Fixes: 6e8dd6d ("net/mlx5e: Don't wait for SQ completions on close") Fixes: f2fde18 ("net/mlx5e: Don't wait for RQ completions on close") Signed-off-by: Mohamad Haj Yahia <mohamad@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3c8591d commit c0f1147

5 files changed

Lines changed: 17 additions & 13 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ struct mlx5e_tstamp {
241241
};
242242

243243
enum {
244-
MLX5E_RQ_STATE_FLUSH,
244+
MLX5E_RQ_STATE_ENABLED,
245245
MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
246246
MLX5E_RQ_STATE_AM,
247247
};
@@ -394,7 +394,7 @@ struct mlx5e_sq_dma {
394394
};
395395

396396
enum {
397-
MLX5E_SQ_STATE_FLUSH,
397+
MLX5E_SQ_STATE_ENABLED,
398398
MLX5E_SQ_STATE_BF_ENABLE,
399399
};
400400

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
759759
if (err)
760760
goto err_destroy_rq;
761761

762+
set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
762763
err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RST, MLX5_RQC_STATE_RDY);
763764
if (err)
764765
goto err_disable_rq;
@@ -773,6 +774,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
773774
return 0;
774775

775776
err_disable_rq:
777+
clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
776778
mlx5e_disable_rq(rq);
777779
err_destroy_rq:
778780
mlx5e_destroy_rq(rq);
@@ -782,7 +784,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
782784

783785
static void mlx5e_close_rq(struct mlx5e_rq *rq)
784786
{
785-
set_bit(MLX5E_RQ_STATE_FLUSH, &rq->state);
787+
clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
786788
napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */
787789
cancel_work_sync(&rq->am.work);
788790

@@ -1082,6 +1084,7 @@ static int mlx5e_open_sq(struct mlx5e_channel *c,
10821084
if (err)
10831085
goto err_destroy_sq;
10841086

1087+
set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
10851088
err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RST, MLX5_SQC_STATE_RDY,
10861089
false, 0);
10871090
if (err)
@@ -1095,6 +1098,7 @@ static int mlx5e_open_sq(struct mlx5e_channel *c,
10951098
return 0;
10961099

10971100
err_disable_sq:
1101+
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
10981102
mlx5e_disable_sq(sq);
10991103
err_destroy_sq:
11001104
mlx5e_destroy_sq(sq);
@@ -1111,7 +1115,7 @@ static inline void netif_tx_disable_queue(struct netdev_queue *txq)
11111115

11121116
static void mlx5e_close_sq(struct mlx5e_sq *sq)
11131117
{
1114-
set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state);
1118+
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
11151119
/* prevent netif_tx_wake_queue */
11161120
napi_synchronize(&sq->channel->napi);
11171121

@@ -3091,7 +3095,7 @@ static void mlx5e_tx_timeout(struct net_device *dev)
30913095
if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i)))
30923096
continue;
30933097
sched_work = true;
3094-
set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state);
3098+
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
30953099
netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n",
30963100
i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc);
30973101
}
@@ -3146,13 +3150,13 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
31463150
for (i = 0; i < priv->params.num_channels; i++) {
31473151
struct mlx5e_channel *c = priv->channel[i];
31483152

3149-
set_bit(MLX5E_RQ_STATE_FLUSH, &c->rq.state);
3153+
clear_bit(MLX5E_RQ_STATE_ENABLED, &c->rq.state);
31503154
napi_synchronize(&c->napi);
31513155
/* prevent mlx5e_poll_rx_cq from accessing rq->xdp_prog */
31523156

31533157
old_prog = xchg(&c->rq.xdp_prog, prog);
31543158

3155-
clear_bit(MLX5E_RQ_STATE_FLUSH, &c->rq.state);
3159+
set_bit(MLX5E_RQ_STATE_ENABLED, &c->rq.state);
31563160
/* napi_schedule in case we have missed anything */
31573161
set_bit(MLX5E_CHANNEL_NAPI_SCHED, &c->flags);
31583162
napi_schedule(&c->napi);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq)
412412

413413
clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
414414

415-
if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) {
415+
if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state))) {
416416
mlx5e_free_rx_mpwqe(rq, &rq->mpwqe.info[wq->head]);
417417
return;
418418
}
@@ -445,7 +445,7 @@ void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
445445
}
446446

447447
#define RQ_CANNOT_POST(rq) \
448-
(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state) || \
448+
(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state) || \
449449
test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state))
450450

451451
bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
@@ -924,7 +924,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
924924
struct mlx5e_sq *xdp_sq = &rq->channel->xdp_sq;
925925
int work_done = 0;
926926

927-
if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state)))
927+
if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state)))
928928
return 0;
929929

930930
if (cq->decmprs_left)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
409409

410410
sq = container_of(cq, struct mlx5e_sq, cq);
411411

412-
if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state)))
412+
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
413413
return false;
414414

415415
npkts = 0;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
5656
struct mlx5_cqe64 *cqe;
5757
u16 sqcc;
5858

59-
if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state)))
59+
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
6060
return;
6161

6262
cqe = mlx5e_get_cqe(cq);
@@ -113,7 +113,7 @@ static inline bool mlx5e_poll_xdp_tx_cq(struct mlx5e_cq *cq)
113113

114114
sq = container_of(cq, struct mlx5e_sq, cq);
115115

116-
if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state)))
116+
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
117117
return false;
118118

119119
/* sq->cc must be updated only after mlx5_cqwq_update_db_record(),

0 commit comments

Comments
 (0)