net/mlx5: fix metadata calculation in legacy mode
PATCH 1/1 net/mlx5: fix metadata calculation in legacy mode
Currently, we store metadata in BE and need to change it to CPU endian when attaching to mbuf.
For dv_xmeta_en = 2, no bit shift.
For dv_xmeta_en = 1, 16 bits shift.
For the non-vector mode, endian change should be first, then bit shift.
For the vector mode, the behavior is right. In this update, we use __builtin_clz instead of __builtin_popcount to avoid confusing.
Fixes 743ac28ddf0b ("net/mlx5: fix metadata calculation in legacy mode")
Signed-off-by rongwei liu <[email protected]>
--- drivers/net/mlx5/mlx5_rx.c | 4 ++-- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 2 +- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 2 +- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5_rx.c +2 -2
@@ -740,8 +740,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, } }if (rxq->dynf_meta) { -uint32_t meta =rte_be_to_cpu_32 (cqe->flow_table_metadata >> -__builtin_popcount (rxq->flow_meta_port_mask)) & +uint32_t meta = (rte_be_to_cpu_32 (cqe->flow_table_metadata) >> +__builtin_clz (rxq->flow_meta_port_mask)) & rxq->flow_meta_port_mask;if (meta) {
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +1 -1
@@ -1223,7 +1223,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,int32_t offs = rxq->flow_meta_offset;uint32_t mask = rxq->flow_meta_port_mask;uint32_t shift = -__builtin_popcount (rxq->flow_meta_port_mask); +__builtin_clz (rxq->flow_meta_port_mask);uint32_t metadata;/* This code is subject for futher optimization. */
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +1 -1
@@ -834,7 +834,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,int32_t offs = rxq->flow_meta_offset;uint32_t mask = rxq->flow_meta_port_mask;uint32_t shift = -__builtin_popcount (rxq->flow_meta_port_mask); +__builtin_clz (rxq->flow_meta_port_mask); *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = (rte_be_to_cpu_32(container_of
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +1 -1
@@ -770,7 +770,7 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,int32_t offs = rxq->flow_meta_offset;uint32_t mask = rxq->flow_meta_port_mask;uint32_t shift = -__builtin_popcount (rxq->flow_meta_port_mask); +__builtin_clz (rxq->flow_meta_port_mask); *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = (rte_be_to_cpu_32
Signature · 1 line
2.27.0