Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5e: Prevent WQE metadata conflicts between timestamping and offloads

Update the WQE metadata assignment to avoid overriding existing
metadata when setting the sysport timestamp ID. Since timestamp IDs are
limited to 256 values, they use only the lower 8 bits of the metadata
field.

To avoid conflicts, move IPsec and MACsec metadata ID to bits 8 and 9,
and shift the MACsec fs_id accordingly. This ensures safe coexistence
of timestamping and offload features that use the same metadata field.

Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1757574619-604874-4-git-send-email-tariqt@nvidia.com
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Carolina Jubran and committed by
Leon Romanovsky
2ac20738 cce65f32

+5 -4
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
··· 653 653 struct mlx5_wqe_eth_seg *eseg) 654 654 { 655 655 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) 656 - eseg->flow_table_metadata = 656 + eseg->flow_table_metadata |= 657 657 cpu_to_be32(mlx5e_ptp_metadata_fifo_peek(&ptpsq->metadata_freelist)); 658 658 } 659 659
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
··· 2219 2219 mlx5_macsec_fs_set_tx_fs_id(fs_id)); 2220 2220 MLX5_SET(set_action_in, action, offset, 2221 2221 MLX5_ETH_WQE_FT_META_MACSEC_SHIFT); 2222 - MLX5_SET(set_action_in, action, length, 32); 2222 + MLX5_SET(set_action_in, action, length, 8); 2223 2223 2224 2224 modify_hdr = mlx5_modify_header_alloc(mdev, MLX5_FLOW_NAMESPACE_RDMA_TX_MACSEC, 2225 2225 1, action);
+3 -2
include/linux/mlx5/qp.h
··· 251 251 MLX5_ETH_WQE_SWP_OUTER_L4_UDP = 1 << 5, 252 252 }; 253 253 254 - /* Base shift for metadata bits used by timestamping, IPsec, and MACsec */ 255 - #define MLX5_ETH_WQE_FT_META_SHIFT 0 254 + /* Metadata bits 0-7 are used by timestamping */ 255 + /* Base shift for metadata bits used by IPsec and MACsec */ 256 + #define MLX5_ETH_WQE_FT_META_SHIFT 8 256 257 257 258 enum { 258 259 MLX5_ETH_WQE_FT_META_IPSEC = BIT(0) << MLX5_ETH_WQE_FT_META_SHIFT,