From patchwork Tue Sep 15 09:47:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 77704 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 614F0A04C7; Tue, 15 Sep 2020 11:43:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A9991BE8E; Tue, 15 Sep 2020 11:43:22 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 6D5BBE07 for ; Tue, 15 Sep 2020 11:43:20 +0200 (CEST) IronPort-SDR: m+WhmGp6NZon2ZuCj0nyr4fPCIjmRyFIbS+tvkqmqIezXWar3wCE5ou4BtbPTUXKq/azrzb3gL BxOfp1YY6Gug== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="220784676" X-IronPort-AV: E=Sophos;i="5.76,429,1592895600"; d="scan'208";a="220784676" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 02:43:19 -0700 IronPort-SDR: DXIx1556+0eI7/WWRGY6sR/LSmJb8p8BD9GB8Fcs8SjtrX4ob6s2MzA2tCTkTp/5fEACWzmEwV PxdEtVTS5WyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,429,1592895600"; d="scan'208";a="286754278" Received: from dpdk51.sh.intel.com ([10.67.111.142]) by fmsmga007.fm.intel.com with ESMTP; 15 Sep 2020 02:43:17 -0700 From: Qi Zhang To: beilei.xing@intel.com Cc: dev@dpdk.org, junfeng.guo@intel.com, jia.guo@intel.com, Qi Zhang Date: Tue, 15 Sep 2020 17:47:15 +0800 Message-Id: <20200915094715.57997-1-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] net/iavf: reject floating RSS attribute X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For RSS attribute don't have an associated RSS type, we need to reject it. Signed-off-by: Qi Zhang --- v2: - fix checkpatch warning 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..42c20c8af 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); }