DPDK patches and discussions
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
To: beilei.xing@intel.com
Cc: dev@dpdk.org, junfeng.guo@intel.com, jia.guo@intel.com,
	Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH] net/iavf: reject floating RSS attribute
Date: Tue, 15 Sep 2020 17:40:04 +0800
Message-ID: <20200915094004.57631-1-qi.z.zhang@intel.com> (raw)

For RSS attribute don't have an associated RSS type, we need
to reject it.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/iavf/iavf_hash.c | 74 +++++++++++++++++++++++++-----------
 1 file changed, 52 insertions(+), 22 deletions(-)

diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index 61466c072..99e7eb641 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -766,6 +766,51 @@ static uint64_t invalid_rss_comb[] = {
 	RTE_ETH_RSS_L3_PRE96
 };
 
+struct rss_attr_type {
+	uint64_t attr;
+	uint64_t type;
+};
+
+#define VALID_RSS_IPV4 		(ETH_RSS_IPV4			| \
+				 ETH_RSS_NONFRAG_IPV4_UDP	| \
+				 ETH_RSS_NONFRAG_IPV4_TCP	| \
+				 ETH_RSS_NONFRAG_IPV4_SCTP)
+
+#define VALID_RSS_IPV6		(ETH_RSS_IPV6			| \
+				 ETH_RSS_NONFRAG_IPV6_UDP	| \
+				 ETH_RSS_NONFRAG_IPV6_TCP	| \
+				 ETH_RSS_NONFRAG_IPV6_SCTP)
+
+#define VALID_RSS_IPV4_L4	(ETH_RSS_NONFRAG_IPV4_UDP	| \
+				 ETH_RSS_NONFRAG_IPV4_TCP	| \
+				 ETH_RSS_NONFRAG_IPV4_SCTP)
+
+#define VALID_RSS_IPV6_L4	(ETH_RSS_NONFRAG_IPV6_UDP	| \
+				 ETH_RSS_NONFRAG_IPV6_TCP 	| \
+				 ETH_RSS_NONFRAG_IPV6_SCTP)
+
+#define VALID_RSS_ATTR		(ETH_RSS_L3_SRC_ONLY	| \
+				 ETH_RSS_L3_DST_ONLY	| \
+				 ETH_RSS_L4_SRC_ONLY	| \
+				 ETH_RSS_L4_DST_ONLY	| \
+				 ETH_RSS_L2_SRC_ONLY	| \
+				 ETH_RSS_L2_DST_ONLY	| \
+				 RTE_ETH_RSS_L3_PRE64)
+
+#define INVALID_RSS_ATTR	(RTE_ETH_RSS_L3_PRE32	| \
+				 RTE_ETH_RSS_L3_PRE40	| \
+				 RTE_ETH_RSS_L3_PRE48	| \
+				 RTE_ETH_RSS_L3_PRE56	| \
+				 RTE_ETH_RSS_L3_PRE96)
+
+static struct rss_attr_type rss_attr_to_valid_type[] = {
+	{ETH_RSS_L3_SRC_ONLY | ETH_RSS_L3_DST_ONLY,	VALID_RSS_IPV4 | VALID_RSS_IPV6},
+	{ETH_RSS_L4_SRC_ONLY | ETH_RSS_L4_DST_ONLY,	VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4},
+	/* current ipv6 prefix only supports prefix 64 bits*/
+	{RTE_ETH_RSS_L3_PRE64,				VALID_RSS_IPV6},
+	{INVALID_RSS_ATTR,				0}
+};
+
 static bool
 iavf_any_invalid_rss_type(uint64_t rss_type, uint64_t allow_rss_type)
 {
@@ -777,31 +822,16 @@ iavf_any_invalid_rss_type(uint64_t rss_type, uint64_t allow_rss_type)
 			return true;
 	}
 
-	/* current ipv6 prefix only supports prefix 64 bits*/
-#define _invalid_prefix_ (RTE_ETH_RSS_L3_PRE32	| \
-			  RTE_ETH_RSS_L3_PRE40	| \
-			  RTE_ETH_RSS_L3_PRE48	| \
-			  RTE_ETH_RSS_L3_PRE56	| \
-			  RTE_ETH_RSS_L3_PRE96)
+	/* check invalid RSS attribute */
+	for (i = 0; i < RTE_DIM(rss_attr_to_valid_type); i++) {
+		struct rss_attr_type *rat = &rss_attr_to_valid_type[i];
 
-	if (rss_type & _invalid_prefix_)
-		return true;
+		if (rat->attr & rss_type && !(rat->type & rss_type))
+			return true;
+	}
 
 	/* check not allowed RSS type */
-#define _RSS_ATTR_ (ETH_RSS_L3_SRC_ONLY		| \
-		    ETH_RSS_L3_DST_ONLY		| \
-		    ETH_RSS_L4_SRC_ONLY		| \
-		    ETH_RSS_L4_DST_ONLY		| \
-		    ETH_RSS_L2_SRC_ONLY		| \
-		    ETH_RSS_L2_DST_ONLY		| \
-		    RTE_ETH_RSS_L3_PRE32	| \
-		    RTE_ETH_RSS_L3_PRE40	| \
-		    RTE_ETH_RSS_L3_PRE48	| \
-		    RTE_ETH_RSS_L3_PRE56	| \
-		    RTE_ETH_RSS_L3_PRE64	| \
-		    RTE_ETH_RSS_L3_PRE96)
-
-	rss_type &= ~_RSS_ATTR_;
+	rss_type &= ~VALID_RSS_ATTR;
 
 	return ((rss_type & allow_rss_type) != rss_type);
 }
-- 
2.25.4


             reply	other threads:[~2020-09-15  9:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  9:40 Qi Zhang [this message]
2020-09-16  6:25 Qi Zhang

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=20200915094004.57631-1-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jia.guo@intel.com \
    --cc=junfeng.guo@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git