net/mlx5: fix meta register conversion for extensive mode
PATCH 1/1 net/mlx5: fix meta register conversion for extensive mode
Register C is used in the extensive metadata mode number 1 and its width can vary from 0 to 32 bits depending on the kernel usage of it.
There are several issues associated with this mode (dv_xmeta_en=1):
1. The metadata setting assumes that the width is always 16 bits, which is the most common case in this mode. Use the proper mask.
2. The same is true for the modify_field Flow API. 16-bits witdh is hardcoded for dv_xmeta_en=1. Switch to the register C mask width.
3. Metadata is stored in the most significant bits in CQE in this mode because the registers copy code was not updated during the metadata conversion to the big-endian format. Update this code to avoid shifting the metadata in the datapath.
--- drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 96 +++++++++--------------- drivers/net/mlx5/mlx5_rx.c | 3 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 22 ++---- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 22 ++---- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 22 ++---- 6 files changed, 62 insertions(+), 107 deletions(-)
drivers/net/mlx5/mlx5_flow.c +1 -3
@@ -1321,9 +1321,7 @@ mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev) data->dynf_meta =1 ; data->flow_meta_mask = rte_flow_dynf_metadata_mask; data->flow_meta_offset = rte_flow_dynf_metadata_offs; - data->flow_meta_port_mask = (uint32_t )~0 ; -if (priv->config.dv_xmeta_en ==MLX5_XMETA_MODE_META16 ) - data->flow_meta_port_mask >>=16 ; + data->flow_meta_port_mask = priv->sh->dv_meta_mask; } } }
drivers/net/mlx5/mlx5_flow_dv.c +36 -60
188 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.c +1 -2
@@ -753,8 +753,7 @@ 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) & rxq->flow_meta_port_mask;if (meta) {
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +8 -14
@@ -1222,32 +1222,26 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,uint64_t flag = rxq->flow_meta_mask;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);uint32_t metadata;/* This code is subject for futher optimization. */ - metadata = (rte_be_to_cpu_32 - (cq[pos].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = metadata; pkts[pos]->ol_flags |= metadata ? flag :0ULL ; - metadata = (rte_be_to_cpu_32 - (cq[pos +1 ].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos +1 ].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = metadata; pkts[pos +1 ]->ol_flags |= metadata ? flag :0ULL ; - metadata = (rte_be_to_cpu_32 - (cq[pos +2 ].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos +2 ].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = metadata; pkts[pos +2 ]->ol_flags |= metadata ? flag :0ULL ; - metadata = (rte_be_to_cpu_32 - (cq[pos +3 ].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos +3 ].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = metadata; pkts[pos +3 ]->ol_flags |= metadata ? flag :0ULL ;
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +8 -14
@@ -832,29 +832,23 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,/* This code is subject for futher optimization. */ 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); *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p0, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p1, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p2, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p3, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; if (*RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *)) elts[pos]->ol_flags |= rxq->flow_meta_mask; if (*RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *))
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +8 -14
@@ -769,25 +769,19 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,/* This code is subject for futher optimization. */ 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); *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos + p1].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos + p1].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos + p2].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos + p2].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos + p3].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos + p3].flow_table_metadata) & mask; if (*RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *)) pkts[pos]->ol_flags |= rxq->flow_meta_mask; if (*RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *))
Signature · 1 line
2.18.2
PATCH v2 1/1 net/mlx5: fix meta register conversion for extensive mode
Register C is used in the extensive metadata mode number 1 and its width can vary from 0 to 32 bits depending on the kernel usage of it.
There are several issues associated with this mode (dv_xmeta_en=1):
1. The metadata setting assumes that the width is always 16 bits, which is the most common case in this mode. Use the proper mask.
2. The same is true for the modify_field Flow API. 16-bits width is hardcoded for dv_xmeta_en=1. Switch to the register C mask width.
3. Metadata is stored in the most significant bits in CQE in this mode because the registers copy code was not updated during the metadata conversion to the big-endian format. Update this code to avoid shifting the metadata in the datapath.
---
v2: fixed typo in the commit message
v1: https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
drivers/net/mlx5/mlx5_flow.c | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 96 +++++++++--------------- drivers/net/mlx5/mlx5_rx.c | 3 +- drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 22 ++---- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 22 ++---- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 22 ++---- 6 files changed, 62 insertions(+), 107 deletions(-)
drivers/net/mlx5/mlx5_flow.c +1 -3
@@ -1321,9 +1321,7 @@ mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev) data->dynf_meta =1 ; data->flow_meta_mask = rte_flow_dynf_metadata_mask; data->flow_meta_offset = rte_flow_dynf_metadata_offs; - data->flow_meta_port_mask = (uint32_t )~0 ; -if (priv->config.dv_xmeta_en ==MLX5_XMETA_MODE_META16 ) - data->flow_meta_port_mask >>=16 ; + data->flow_meta_port_mask = priv->sh->dv_meta_mask; } } }
drivers/net/mlx5/mlx5_flow_dv.c +36 -60
188 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.c +1 -2
@@ -753,8 +753,7 @@ 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) & rxq->flow_meta_port_mask;if (meta) {
drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +8 -14
@@ -1222,32 +1222,26 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,uint64_t flag = rxq->flow_meta_mask;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);uint32_t metadata;/* This code is subject for futher optimization. */ - metadata = (rte_be_to_cpu_32 - (cq[pos].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = metadata; pkts[pos]->ol_flags |= metadata ? flag :0ULL ; - metadata = (rte_be_to_cpu_32 - (cq[pos +1 ].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos +1 ].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = metadata; pkts[pos +1 ]->ol_flags |= metadata ? flag :0ULL ; - metadata = (rte_be_to_cpu_32 - (cq[pos +2 ].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos +2 ].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = metadata; pkts[pos +2 ]->ol_flags |= metadata ? flag :0ULL ; - metadata = (rte_be_to_cpu_32 - (cq[pos +3 ].flow_table_metadata) >> shift) & - mask; + metadata =rte_be_to_cpu_32 + (cq[pos +3 ].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = metadata; pkts[pos +3 ]->ol_flags |= metadata ? flag :0ULL ;
drivers/net/mlx5/mlx5_rxtx_vec_neon.h +8 -14
@@ -832,29 +832,23 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,/* This code is subject for futher optimization. */ 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); *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p0, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p1, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p2, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = - (rte_be_to_cpu_32(container_of +rte_be_to_cpu_32 (container_of (p3, struct mlx5_cqe, - pkt_info)->flow_table_metadata) >> shift) & - mask; + pkt_info)->flow_table_metadata) & mask; if (*RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *)) elts[pos]->ol_flags |= rxq->flow_meta_mask; if (*RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *))
drivers/net/mlx5/mlx5_rxtx_vec_sse.h +8 -14
@@ -769,25 +769,19 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq,/* This code is subject for futher optimization. */ 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); *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos + p1].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos + p1].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos + p2].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos + p2].flow_table_metadata) & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = - (rte_be_to_cpu_32 - (cq[pos + p3].flow_table_metadata) >> shift) & - mask; +rte_be_to_cpu_32 + (cq[pos + p3].flow_table_metadata) & mask; if (*RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *)) pkts[pos]->ol_flags |= rxq->flow_meta_mask; if (*RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *))
Signature · 1 line
2.18.2
Thomas Monjalon
Applied20/07/2021 09:51, Alexander Kozyrev:
Quoted 13 lines
Register C is used in the extensive metadata mode number 1 and its width can vary from 0 to 32 bits depending on the kernel usage of it.
There are several issues associated with this mode (dv_xmeta_en=1):
1. The metadata setting assumes that the width is always 16 bits, which is the most common case in this mode. Use the proper mask.
2. The same is true for themodify_fieldFlow API. 16-bits width is hardcoded for dv_xmeta_en=1. Switch to the register C mask width.
3. Metadata is stored in the most significant bits in CQE in this mode because the registers copy code was not updated during the metadata conversion to the big-endian format. Update this code to avoid shifting the metadata in the datapath.
Quoted 5 lines
Fixes b57e414b48 ("net/mlx5: convert meta register to big-endian")Signed-off-by Alexander Kozyrev <[email protected]>
Applied, thanks