DPDK patches and discussions
 help / color / mirror / Atom feed
From: Leyi Rong <leyi.rong@intel.com>
To: qi.z.zhang@intel.com, wenzhuo.lu@intel.com
Cc: dev@dpdk.org, Leyi Rong <leyi.rong@intel.com>
Subject: [dpdk-dev] [PATCH] net/iavf: fix VLAN tag extraction handling in AVX512 path
Date: Thu, 22 Apr 2021 10:48:30 +0800	[thread overview]
Message-ID: <20210422024830.10617-1-leyi.rong@intel.com> (raw)

The new VIRTCHNL_VF_OFFLOAD_VLAN_V2 capability added support that allows
the PF to set the location of the RX VLAN tag for stripping offloads.

So the VF needs to extract the VLAN tag according to the location flags.

This patch is the fix for AVX512 path, as AVX2 is already fixed.

Fixes: 9c9aa0040344 ("net/iavf: add offload path for Rx AVX512 flex descriptor")

Signed-off-by: Leyi Rong <leyi.rong@intel.com>
---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 215 +++++++++++++++++++-----
 1 file changed, 174 insertions(+), 41 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 7faa1f44aa..d99de2a8bc 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -952,6 +952,7 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 
 		/* merge flags */
 		__m256i mbuf_flags = _mm256_set1_epi32(0);
+		__m256i vlan_flags = _mm256_setzero_si256();
 
 		if (offload) {
 #if defined(IAVF_RX_CSUM_OFFLOAD) || defined(IAVF_RX_VLAN_OFFLOAD) || defined(IAVF_RX_RSS_OFFLOAD)
@@ -1010,19 +1011,33 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 			 * If RSS(bit12)/VLAN(bit13) are set,
 			 * shuffle moves appropriate flags in place.
 			 */
-			const __m256i rss_vlan_flags_shuf = _mm256_set_epi8(0, 0, 0, 0,
-					0, 0, 0, 0,
-					0, 0, 0, 0,
-					PKT_RX_RSS_HASH | PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
-					PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
-					PKT_RX_RSS_HASH, 0,
-					/* end up 128-bits */
-					0, 0, 0, 0,
-					0, 0, 0, 0,
-					0, 0, 0, 0,
-					PKT_RX_RSS_HASH | PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
-					PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
-					PKT_RX_RSS_HASH, 0);
+			const __m256i rss_flags_shuf = _mm256_set_epi8
+					(0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 PKT_RX_RSS_HASH, 0,
+					 PKT_RX_RSS_HASH, 0,
+					 /* end up 128-bits */
+					 0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 PKT_RX_RSS_HASH, 0,
+					 PKT_RX_RSS_HASH, 0);
+
+			const __m256i vlan_flags_shuf = _mm256_set_epi8
+					(0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
+					 PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
+					 0, 0,
+					 /* end up 128-bits */
+					 0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 0, 0, 0, 0,
+					 PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
+					 PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED,
+					 0, 0);
 #endif
 
 #if defined(IAVF_RX_CSUM_OFFLOAD) || defined(IAVF_RX_VLAN_OFFLOAD) || defined(IAVF_RX_RSS_OFFLOAD)
@@ -1044,9 +1059,18 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 			/* set rss and vlan flags */
 			const __m256i rss_vlan_flag_bits =
 				_mm256_srli_epi32(flag_bits, 12);
-			const __m256i rss_vlan_flags =
-				_mm256_shuffle_epi8(rss_vlan_flags_shuf,
+			const __m256i rss_flags =
+				_mm256_shuffle_epi8(rss_flags_shuf,
 						    rss_vlan_flag_bits);
+
+			if (rxq->rx_flags == IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1)
+				vlan_flags =
+					_mm256_shuffle_epi8(vlan_flags_shuf,
+							    rss_vlan_flag_bits);
+
+			const __m256i rss_vlan_flags =
+				_mm256_or_si256(rss_flags, vlan_flags);
+
 #endif
 
 #ifdef IAVF_RX_CSUM_OFFLOAD
@@ -1114,7 +1138,8 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 			 * will cause performance drop to get into this context.
 			 */
 			if (rxq->vsi->adapter->eth_dev->data->dev_conf.rxmode.offloads &
-			    DEV_RX_OFFLOAD_RSS_HASH) {
+			    DEV_RX_OFFLOAD_RSS_HASH ||
+			    rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
 				/* load bottom half of every 32B desc */
 				const __m128i raw_desc_bh7 =
 					_mm_load_si128
@@ -1165,36 +1190,144 @@ _iavf_recv_raw_pkts_vec_avx512_flex_rxd(struct iavf_rx_queue *rxq,
 						(_mm256_castsi128_si256(raw_desc_bh0),
 						 raw_desc_bh1, 1);
 
-				/**
-				 * to shift the 32b RSS hash value to the
-				 * highest 32b of each 128b before mask
-				 */
-				__m256i rss_hash6_7 =
-					_mm256_slli_epi64(raw_desc_bh6_7, 32);
-				__m256i rss_hash4_5 =
-					_mm256_slli_epi64(raw_desc_bh4_5, 32);
-				__m256i rss_hash2_3 =
-					_mm256_slli_epi64(raw_desc_bh2_3, 32);
-				__m256i rss_hash0_1 =
-					_mm256_slli_epi64(raw_desc_bh0_1, 32);
-
-				__m256i rss_hash_msk =
-					_mm256_set_epi32(0xFFFFFFFF, 0, 0, 0,
-							 0xFFFFFFFF, 0, 0, 0);
-
-				rss_hash6_7 = _mm256_and_si256
+				if (rxq->vsi->adapter->eth_dev->data->dev_conf.rxmode.offloads &
+						DEV_RX_OFFLOAD_RSS_HASH) {
+					/**
+					 * to shift the 32b RSS hash value to the
+					 * highest 32b of each 128b before mask
+					 */
+					__m256i rss_hash6_7 =
+						_mm256_slli_epi64
+						(raw_desc_bh6_7, 32);
+					__m256i rss_hash4_5 =
+						_mm256_slli_epi64
+						(raw_desc_bh4_5, 32);
+					__m256i rss_hash2_3 =
+						_mm256_slli_epi64
+						(raw_desc_bh2_3, 32);
+					__m256i rss_hash0_1 =
+						_mm256_slli_epi64
+						(raw_desc_bh0_1, 32);
+
+					const __m256i rss_hash_msk =
+						_mm256_set_epi32
+						(0xFFFFFFFF, 0, 0, 0,
+						 0xFFFFFFFF, 0, 0, 0);
+
+					rss_hash6_7 = _mm256_and_si256
 						(rss_hash6_7, rss_hash_msk);
-				rss_hash4_5 = _mm256_and_si256
+					rss_hash4_5 = _mm256_and_si256
 						(rss_hash4_5, rss_hash_msk);
-				rss_hash2_3 = _mm256_and_si256
+					rss_hash2_3 = _mm256_and_si256
 						(rss_hash2_3, rss_hash_msk);
-				rss_hash0_1 = _mm256_and_si256
+					rss_hash0_1 = _mm256_and_si256
 						(rss_hash0_1, rss_hash_msk);
 
-				mb6_7 = _mm256_or_si256(mb6_7, rss_hash6_7);
-				mb4_5 = _mm256_or_si256(mb4_5, rss_hash4_5);
-				mb2_3 = _mm256_or_si256(mb2_3, rss_hash2_3);
-				mb0_1 = _mm256_or_si256(mb0_1, rss_hash0_1);
+					mb6_7 = _mm256_or_si256
+						(mb6_7, rss_hash6_7);
+					mb4_5 = _mm256_or_si256
+						(mb4_5, rss_hash4_5);
+					mb2_3 = _mm256_or_si256
+						(mb2_3, rss_hash2_3);
+					mb0_1 = _mm256_or_si256
+						(mb0_1, rss_hash0_1);
+				}
+
+				if (rxq->rx_flags & IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2) {
+					/* merge the status/error-1 bits into one register */
+					const __m256i status1_4_7 =
+						_mm256_unpacklo_epi32
+						(raw_desc_bh6_7,
+						 raw_desc_bh4_5);
+					const __m256i status1_0_3 =
+						_mm256_unpacklo_epi32
+						(raw_desc_bh2_3,
+						 raw_desc_bh0_1);
+
+					const __m256i status1_0_7 =
+						_mm256_unpacklo_epi64
+						(status1_4_7, status1_0_3);
+
+					const __m256i l2tag2p_flag_mask =
+						_mm256_set1_epi32
+						(1 << IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S);
+
+					__m256i l2tag2p_flag_bits =
+						_mm256_and_si256
+						(status1_0_7,
+						 l2tag2p_flag_mask);
+
+					l2tag2p_flag_bits =
+						_mm256_srli_epi32
+						(l2tag2p_flag_bits,
+						 IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S);
+
+					const __m256i l2tag2_flags_shuf =
+						_mm256_set_epi8
+							(0, 0, 0, 0,
+							 0, 0, 0, 0,
+							 0, 0, 0, 0,
+							 0, 0, 0, 0,
+							 /* end up 128-bits */
+							 0, 0, 0, 0,
+							 0, 0, 0, 0,
+							 0, 0, 0, 0,
+							 0, 0,
+							 PKT_RX_VLAN |
+							 PKT_RX_VLAN_STRIPPED,
+							 0);
+
+					vlan_flags =
+						_mm256_shuffle_epi8
+							(l2tag2_flags_shuf,
+							 l2tag2p_flag_bits);
+
+					/* merge with vlan_flags */
+					mbuf_flags = _mm256_or_si256
+							(mbuf_flags,
+							 vlan_flags);
+
+					/* L2TAG2_2 */
+					__m256i vlan_tci6_7 =
+						_mm256_slli_si256
+							(raw_desc_bh6_7, 4);
+					__m256i vlan_tci4_5 =
+						_mm256_slli_si256
+							(raw_desc_bh4_5, 4);
+					__m256i vlan_tci2_3 =
+						_mm256_slli_si256
+							(raw_desc_bh2_3, 4);
+					__m256i vlan_tci0_1 =
+						_mm256_slli_si256
+							(raw_desc_bh0_1, 4);
+
+					const __m256i vlan_tci_msk =
+						_mm256_set_epi32
+						(0, 0xFFFF0000, 0, 0,
+						 0, 0xFFFF0000, 0, 0);
+
+					vlan_tci6_7 = _mm256_and_si256
+							(vlan_tci6_7,
+							 vlan_tci_msk);
+					vlan_tci4_5 = _mm256_and_si256
+							(vlan_tci4_5,
+							 vlan_tci_msk);
+					vlan_tci2_3 = _mm256_and_si256
+							(vlan_tci2_3,
+							 vlan_tci_msk);
+					vlan_tci0_1 = _mm256_and_si256
+							(vlan_tci0_1,
+							 vlan_tci_msk);
+
+					mb6_7 = _mm256_or_si256
+							(mb6_7, vlan_tci6_7);
+					mb4_5 = _mm256_or_si256
+							(mb4_5, vlan_tci4_5);
+					mb2_3 = _mm256_or_si256
+							(mb2_3, vlan_tci2_3);
+					mb0_1 = _mm256_or_si256
+							(mb0_1, vlan_tci0_1);
+				}
 			} /* if() on RSS hash parsing */
 #endif
 		}
-- 
2.17.1


             reply	other threads:[~2021-04-22  3:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  2:48 Leyi Rong [this message]
2021-04-27  7:11 ` Sun, QinX
2021-04-28  1:58   ` Zhang, Qi Z
2021-04-29  6:45 ` Sun, QinX
2021-04-30 14:07   ` Zhang, Qi Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210422024830.10617-1-leyi.rong@intel.com \
    --to=leyi.rong@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).