From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E091FA0A02 for ; Mon, 17 May 2021 18:12:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA173410E2; Mon, 17 May 2021 18:12:09 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 2D45840041 for ; Mon, 17 May 2021 18:12:08 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifqh-0007ge-Ur; Mon, 17 May 2021 16:12:08 +0000 From: Christian Ehrhardt To: Viacheslav Ovsiienko Cc: Matan Azrad , dpdk stable Date: Mon, 17 May 2021 18:07:46 +0200 Message-Id: <20210517161039.3132619-37-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx5: fix Rx metadata leftovers' has been queued to stable release 19.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/8598a62e39342b3f1f98e5cb199a58e545ec169a Thanks. Christian Ehrhardt --- >From 8598a62e39342b3f1f98e5cb199a58e545ec169a Mon Sep 17 00:00:00 2001 From: Viacheslav Ovsiienko Date: Sun, 7 Mar 2021 11:45:47 +0000 Subject: [PATCH] net/mlx5: fix Rx metadata leftovers [ upstream commit 4eefb20faacab6eae03c860c5d622603f7499ff4 ] The Rx metadata might use the metadata register C0 to keep the values. The same register C0 might be used by kernel for source vport value handling, kernel uses upper half of the register, leaving the lower half for application usage. In the extended metadata mode 1 (dv_xmeta_en devarg is assigned with value 1) the metadata width is 16 bits only, the Rx datapath code fetched the entire 32-bit value of the metadata register and presented one to application. The patch provides data masking depending on the chosen metadata mode. Fixes: 6c55b622a956 ("net/mlx5: set dynamic flow metadata in Rx queues") Signed-off-by: Viacheslav Ovsiienko Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 4 ++++ drivers/net/mlx5/mlx5_rxtx.c | 13 +++++++++---- drivers/net/mlx5/mlx5_rxtx.h | 1 + drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 11 ++++++----- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 13 +++++++++---- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 9 +++++---- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 74f17d3710..2311f424e0 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -894,10 +894,14 @@ mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev) data->dynf_meta = 0; data->flow_meta_mask = 0; data->flow_meta_offset = -1; + data->flow_meta_port_mask = 0; } else { 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; } } } diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 6904a23cff..73dbf68d2b 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1259,10 +1259,15 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, pkt->hash.fdir.hi = mlx5_flow_mark_get(mark); } } - if (rxq->dynf_meta && cqe->flow_table_metadata) { - pkt->ol_flags |= rxq->flow_meta_mask; - *RTE_MBUF_DYNFIELD(pkt, rxq->flow_meta_offset, uint32_t *) = - cqe->flow_table_metadata; + if (rxq->dynf_meta) { + uint32_t meta = cqe->flow_table_metadata & + rxq->flow_meta_port_mask; + + if (meta) { + pkt->ol_flags |= rxq->flow_meta_mask; + *RTE_MBUF_DYNFIELD(pkt, rxq->flow_meta_offset, + uint32_t *) = meta; + } } if (rxq->csum) pkt->ol_flags |= rxq_cq_to_ol_flags(cqe); diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index daa67e2f5c..34ec66a3ae 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -156,6 +156,7 @@ struct mlx5_rxq_data { uint32_t tunnel; /* Tunnel information. */ uint64_t flow_meta_mask; int32_t flow_meta_offset; + uint32_t flow_meta_port_mask; } __rte_cache_aligned; enum mlx5_rxq_obj_type { diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h index c167672f52..7160d202dd 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h @@ -1036,22 +1036,23 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, if (rxq->dynf_meta) { uint64_t flag = rxq->flow_meta_mask; int32_t offs = rxq->flow_meta_offset; - uint32_t metadata; + uint32_t metadata, mask; + mask = rxq->flow_meta_port_mask; /* This code is subject for futher optimization. */ - metadata = cq[pos].flow_table_metadata; + metadata = cq[pos].flow_table_metadata & mask; *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = metadata; pkts[pos]->ol_flags |= metadata ? flag : 0ULL; - metadata = cq[pos + 1].flow_table_metadata; + metadata = 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 = cq[pos + 2].flow_table_metadata; + metadata = 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 = cq[pos + 3].flow_table_metadata; + metadata = 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; diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h index 607659a629..01b834bb7c 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h @@ -713,19 +713,24 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, if (rxq->dynf_meta) { /* This code is subject for futher optimization. */ int32_t offs = rxq->flow_meta_offset; + uint32_t mask = rxq->flow_meta_port_mask; *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = container_of(p0, struct mlx5_cqe, - pkt_info)->flow_table_metadata; + pkt_info)->flow_table_metadata & + mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = container_of(p1, struct mlx5_cqe, - pkt_info)->flow_table_metadata; + pkt_info)->flow_table_metadata & + mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = container_of(p2, struct mlx5_cqe, - pkt_info)->flow_table_metadata; + pkt_info)->flow_table_metadata & + mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = container_of(p3, struct mlx5_cqe, - pkt_info)->flow_table_metadata; + 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 *)) diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h index 9935299d59..a9d9e8e7d9 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h @@ -665,15 +665,16 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, if (rxq->dynf_meta) { /* This code is subject for futher optimization. */ int32_t offs = rxq->flow_meta_offset; + uint32_t mask = rxq->flow_meta_port_mask; *RTE_MBUF_DYNFIELD(pkts[pos], offs, uint32_t *) = - cq[pos].flow_table_metadata; + cq[pos].flow_table_metadata & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 1], offs, uint32_t *) = - cq[pos + p1].flow_table_metadata; + cq[pos + p1].flow_table_metadata & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 2], offs, uint32_t *) = - cq[pos + p2].flow_table_metadata; + cq[pos + p2].flow_table_metadata & mask; *RTE_MBUF_DYNFIELD(pkts[pos + 3], offs, uint32_t *) = - cq[pos + p3].flow_table_metadata; + 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 *)) -- 2.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:31.003999081 +0200 +++ 0037-net-mlx5-fix-Rx-metadata-leftovers.patch 2021-05-17 17:40:29.171809476 +0200 @@ -1 +1 @@ -From 4eefb20faacab6eae03c860c5d622603f7499ff4 Mon Sep 17 00:00:00 2001 +From 8598a62e39342b3f1f98e5cb199a58e545ec169a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 4eefb20faacab6eae03c860c5d622603f7499ff4 ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -32 +33 @@ -index 773f3e63f4..d46fc333d1 100644 +index 74f17d3710..2311f424e0 100644 @@ -35 +36 @@ -@@ -1267,10 +1267,14 @@ mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev) +@@ -894,10 +894,14 @@ mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev) @@ -51 +52 @@ -index e3ce9fd224..c76b9951bc 100644 +index 6904a23cff..73dbf68d2b 100644 @@ -54,2 +55,2 @@ -@@ -1388,10 +1388,15 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, - } +@@ -1259,10 +1259,15 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, + pkt->hash.fdir.hi = mlx5_flow_mark_get(mark); @@ -75 +76 @@ -index 0fd98af9d1..4f0fda0dec 100644 +index daa67e2f5c..34ec66a3ae 100644 @@ -78,2 +79,2 @@ -@@ -168,6 +168,7 @@ struct mlx5_rxq_data { - uint64_t timestamp_rx_flag; /* Dynamic mbuf flag for timestamp. */ +@@ -156,6 +156,7 @@ struct mlx5_rxq_data { + uint32_t tunnel; /* Tunnel information. */ @@ -83,3 +84,3 @@ - uint32_t rxseg_n; /* Number of split segment descriptions. */ - struct mlx5_eth_rxseg rxseg[MLX5_MAX_RXQ_NSEG]; - /* Buffer split segment descriptions - sizes, offsets, pools. */ + } __rte_cache_aligned; + + enum mlx5_rxq_obj_type { @@ -87 +88 @@ -index 48b677e40d..2d1154b624 100644 +index c167672f52..7160d202dd 100644 @@ -90 +91 @@ -@@ -1221,22 +1221,23 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, +@@ -1036,22 +1036,23 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, @@ -120 +121 @@ -index 4c067d8801..2234fbe6b2 100644 +index 607659a629..01b834bb7c 100644 @@ -123 +124 @@ -@@ -832,19 +832,24 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, +@@ -713,19 +713,24 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, @@ -153 +154 @@ -index 0b3f240e10..c508a7a4f2 100644 +index 9935299d59..a9d9e8e7d9 100644 @@ -156 +157 @@ -@@ -768,15 +768,16 @@ rxq_cq_process_v(struct mlx5_rxq_data *rxq, volatile struct mlx5_cqe *cq, +@@ -665,15 +665,16 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n,