Skip to content

Commit 86b0ca5

Browse files
Binary-Eaterkuba-moo
authored andcommitted
net/mlx5e: Do not produce metadata freelist entries in Tx port ts WQE xmit
Free Tx port timestamping metadata entries in the NAPI poll context and consume metadata enties in the WQE xmit path. Do not free a Tx port timestamping metadata entry in the WQE xmit path even in the error path to avoid a race between two metadata entry producers. Fixes: 3178308 ("net/mlx5e: Make tx_port_ts logic resilient to out-of-order CQEs") Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://lore.kernel.org/r/20240409190820.227554-10-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2f436f1 commit 86b0ca5

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,15 @@ static inline void mlx5e_ptp_metadata_fifo_push(struct mlx5e_ptp_metadata_fifo *
9595
}
9696

9797
static inline u8
98+
mlx5e_ptp_metadata_fifo_peek(struct mlx5e_ptp_metadata_fifo *fifo)
99+
{
100+
return fifo->data[fifo->mask & fifo->cc];
101+
}
102+
103+
static inline void
98104
mlx5e_ptp_metadata_fifo_pop(struct mlx5e_ptp_metadata_fifo *fifo)
99105
{
100-
return fifo->data[fifo->mask & fifo->cc++];
106+
fifo->cc++;
101107
}
102108

103109
static inline void

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ mlx5e_txwqe_complete(struct mlx5e_txqsq *sq, struct sk_buff *skb,
398398
(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))) {
399399
u8 metadata_index = be32_to_cpu(eseg->flow_table_metadata);
400400

401+
mlx5e_ptp_metadata_fifo_pop(&sq->ptpsq->metadata_freelist);
402+
401403
mlx5e_skb_cb_hwtstamp_init(skb);
402404
mlx5e_ptp_metadata_map_put(&sq->ptpsq->metadata_map, skb,
403405
metadata_index);
@@ -496,9 +498,6 @@ mlx5e_sq_xmit_wqe(struct mlx5e_txqsq *sq, struct sk_buff *skb,
496498

497499
err_drop:
498500
stats->dropped++;
499-
if (unlikely(sq->ptpsq && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)))
500-
mlx5e_ptp_metadata_fifo_push(&sq->ptpsq->metadata_freelist,
501-
be32_to_cpu(eseg->flow_table_metadata));
502501
dev_kfree_skb_any(skb);
503502
mlx5e_tx_flush(sq);
504503
}
@@ -657,7 +656,7 @@ static void mlx5e_cqe_ts_id_eseg(struct mlx5e_ptpsq *ptpsq, struct sk_buff *skb,
657656
{
658657
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))
659658
eseg->flow_table_metadata =
660-
cpu_to_be32(mlx5e_ptp_metadata_fifo_pop(&ptpsq->metadata_freelist));
659+
cpu_to_be32(mlx5e_ptp_metadata_fifo_peek(&ptpsq->metadata_freelist));
661660
}
662661

663662
static void mlx5e_txwqe_build_eseg(struct mlx5e_priv *priv, struct mlx5e_txqsq *sq,

0 commit comments

Comments
 (0)