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 911BA428F8 for ; Sun, 9 Apr 2023 17:33:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C05741156; Sun, 9 Apr 2023 17:33:16 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2042.outbound.protection.outlook.com [40.107.243.42]) by mails.dpdk.org (Postfix) with ESMTP id 8BFEC406B8 for ; Sun, 9 Apr 2023 17:33:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X0rtoCxFAM07DyYXyZ0hZnYuMbEKWUyse8gBeQiRwLP776cxiOU8mps2C9frakbm5uZ9I8NXDn+LVPjy6GyFElVHedvE3vlN2joxGjXBW3VdBpe3skAjMlijUeTVgaL0wYEQeMKiVbrc0ruH5zZcUOim9pjBjgbbpuI8LUOfz+sH2cLZ9aZ12djJtmaYIG6vRvRRWBccBFwm0R/dGha6NlCm/BrMIWl6DyH9M6MoMrUu13iHNwaWgJ0QclNHkoKcCW51JROc7ygm+4iLPZyATe365exS0P0WLgVIQMxc2yssZwC9gcDSXZwmdlpPBnpbZq5QqATOj+UB9mMreCDyCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OunvLXtMmKz3zDV0oqGCKAaSfNmjRZZs/0WoTljEw6s=; b=MGtyoyZWDqFs45+yfDw/yjxWuWl02sE3WEDyPuNTFwtZaMwCHY2EhFcZvuwE2o+WP6Ui/xdCOSg1DbA/9/eWHFj6PZL0xtIJVgimsjkdY6jT373mnXpYtnZF0sENPIHeNzmw/5JdG7yFOOzegIDtUIzp/P0sKv+BQygNBBrkJnkeCDe07P1fvLNss/ebEpDDGuygqB08RUYscKwhXtWQHS3cxu32BVCp3Ao3PVv80SoL7wGKc0M1QEhK+M5c3tiytKe6EXBD410QNGmrXrR2TFNo45Ky4fV0UrcLE8T8VJF9MO7A7mkX/xupOKNkt0DelttN1UiLsuFH7dhm78yYmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OunvLXtMmKz3zDV0oqGCKAaSfNmjRZZs/0WoTljEw6s=; b=iKd3e273tnobjUs2kd5MYSp3Kz3d6AuzwFizzN4y/sFHZIi9QHHEb3hWbXw7SwGbqt0GsnMn2NiYGCSMWIAKjVQEv9p1pX8aUUdGvxBD33KDq8t0Y+YWk3UqI3UL6sSmphfyXSY0fsso0ZS0S+Qg0ravDYqu/TzxwEVIkY8jgiFsEnlEu4zn5KaQG5Wlgjxn4RooD8qILytoQwCjz4KJ6XlPvJhWd5OIHNVHk3jleEIGkrFvUfiP8ETsAKHovlo7qH9YnDDYOhwALWkIlGPQ3aaQ85+2SbumP+96K9NM3kX5VACc+Asgc/TKykruG9R9jMW+HLkp3VP89W+FMAXD+g== Received: from BN9PR03CA0424.namprd03.prod.outlook.com (2603:10b6:408:113::9) by PH7PR12MB7820.namprd12.prod.outlook.com (2603:10b6:510:268::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.34; Sun, 9 Apr 2023 15:33:12 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:113:cafe::b0) by BN9PR03CA0424.outlook.office365.com (2603:10b6:408:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Sun, 9 Apr 2023 15:33:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.20 via Frontend Transport; Sun, 9 Apr 2023 15:33:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 9 Apr 2023 08:33:02 -0700 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 9 Apr 2023 08:33:01 -0700 From: Xueming Li To: Huisong Li CC: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: add verification of RSS types' has been queued to stable release 22.11.2 Date: Sun, 9 Apr 2023 23:24:35 +0800 Message-ID: <20230409152529.5308-88-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230409152529.5308-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230409152529.5308-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|PH7PR12MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f2e229a-68f9-458c-ae0f-08db390fba46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CUuXCog6jqrsg00W/RGCQIOaqa/K+wcAgVZACwxvBgRlHX7Te0Oq5v1fI6QYWzskPdrb5M+APl8u+OJp1B/ogCzUebHs0/jkouW6gm2irdJ5VdJ2RTJofLy850NKhNy4fhl7nnmWmRtMs8AtSujd5easZyrdrRj2NYmct2RyVRvnCjXKVVN1B+w4lHCwi35Yu+Mx4hDPe3TCXnqxB52SaSnXd6TAUYx/Dqc2wkIGoAXcvYZ1sB2dl8OE/IdB1R30D3k9iUrTtzEROk77DwMom9n6w0lEVHL/Oqs+mK8CDZNcmZQsuwV5XBMzrIC/INrgf24qeaioYLTvtTE7fzPh5XkkgbWZTJNmJxziJz+BI4AzDYwKd0lOdttt/6iotqsVoB428RqMwaqTrv0g+mxCf4+46+xOrm03vjyAiw6h95F5O5+q9c6+SCNxAeClmWxxRDgGTbmpnoadNWkc62kJ/y8QRDlNZDYcUs1EXtXDaY1L0nTyKrCQCImI3P1TGKG9rNTRI6VdWRReuKZjp3ZRWfVxGxR8z/TB9ncezKDO0ZF3iimNjVYiUvTVh43KBWCVz084L4UV4qpq0CkE5qh1bqV8IWBqSayHnoe1nj2cndR2V6fvXGoqBNjD+S3QbFcIMX/iEfxfJWIKg1GuIx0qw1xCecBdllOnC2aDXj6LNwOM3be7TELRTDKyPDKZeEKOQ4h4f4c67xGgChaBJjCQPOgbfr6tfBrKWDO2GCtPimgNax87hlPSaJbAIe3QOmv3ABnoVtQZa7Th1vF+hCkcd9Hgsv8FoaKDmasdp1iKZXC3c+UykUI4S5PapOQlgcLjqCFSL0wpJsZ7mZ9omrehJw== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(426003)(2906002)(15650500001)(336012)(2616005)(26005)(16526019)(186003)(53546011)(1076003)(6286002)(47076005)(83380400001)(6916009)(8676002)(70586007)(70206006)(54906003)(41300700001)(4326008)(316002)(478600001)(5660300002)(7696005)(8936002)(966005)(40480700001)(6666004)(55016003)(356005)(7636003)(36860700001)(82740400003)(82310400005)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2023 15:33:11.3356 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f2e229a-68f9-458c-ae0f-08db390fba46 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7820 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 Hi, FYI, your patch has been queued to stable release 22.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/11/23. 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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/5af10c2a20aea82a13078ef07fc1deaf2d13617b Thanks. Xueming Li --- >From 5af10c2a20aea82a13078ef07fc1deaf2d13617b Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Fri, 10 Mar 2023 17:35:18 +0800 Subject: [PATCH] net/hns3: add verification of RSS types Cc: Xueming Li [ upstream commit eb3ef9e0d7eb54b47ab58d3d14f9f5fff3f4120b ] Add the verification of RSS types from ethdev ops and rte flow without pattern attribute. The following cases are invalid: 1. types contains unsupported RSS type but hasn't type driver support. 2. types has L3 src/dst but hasn't supported packet type. 3. types has L4 src/dst but hasn't supported packet type and hasn't IP packet type. Fixes: 13c3993240c8 ("net/hns3: add L3 and L4 RSS types") Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 12 +++--- drivers/net/hns3/hns3_rss.c | 74 +++++++++++++++++++++++++----------- drivers/net/hns3/hns3_rss.h | 3 +- 3 files changed, 60 insertions(+), 29 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index c38bd9dd8b..c1f4f5cb0b 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1652,9 +1652,10 @@ hns3_flow_parse_rss_types(struct hns3_hw *hw, /* no pattern specified to set global RSS types. */ if (pattern_type == 0) { - if (rss_act->types & ~HNS3_ETH_RSS_SUPPORT) - hns3_warn(hw, "some types in the requested RSS types (0x%" PRIx64 ") aren't supported, they are ignored.", - rss_act->types); + if (!hns3_check_rss_types_valid(hw, rss_act->types)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + NULL, "RSS types is invalid."); rss_conf->hw_pctypes = hns3_flow_get_all_hw_pctypes(rss_act->types); return 0; @@ -1929,15 +1930,14 @@ hns3_flow_set_rss_ptype_tuple(struct hns3_hw *hw, uint64_t pctype = BIT_ULL(idx); tuple_mask = hns3_flow_get_pctype_tuple_mask(pctype); - tuples = hns3_rss_calc_tuple_filed(hw, - rss_conf->conf.types); + tuples = hns3_rss_calc_tuple_filed(rss_conf->conf.types); new_tuple_fields &= ~tuple_mask; new_tuple_fields |= tuples; hw_pctypes &= ~pctype; } } else { new_tuple_fields = - hns3_rss_calc_tuple_filed(hw, rss_conf->conf.types); + hns3_rss_calc_tuple_filed(rss_conf->conf.types); } ret = hns3_set_rss_tuple_field(hw, new_tuple_fields); diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index dfa2901ae3..6126512bd7 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -492,34 +492,62 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) return ret; } -static void -hns3_rss_check_l3l4_types(struct hns3_hw *hw, uint64_t rss_hf) +bool +hns3_check_rss_types_valid(struct hns3_hw *hw, uint64_t types) { uint64_t ip_mask = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_OTHER; - uint64_t l4_mask = RTE_ETH_RSS_NONFRAG_IPV4_TCP | - RTE_ETH_RSS_NONFRAG_IPV4_UDP | - RTE_ETH_RSS_NONFRAG_IPV4_SCTP | - RTE_ETH_RSS_NONFRAG_IPV6_TCP | - RTE_ETH_RSS_NONFRAG_IPV6_UDP | - RTE_ETH_RSS_NONFRAG_IPV6_SCTP; - uint64_t l3_src_dst_mask = RTE_ETH_RSS_L3_SRC_ONLY | - RTE_ETH_RSS_L3_DST_ONLY; - uint64_t l4_src_dst_mask = RTE_ETH_RSS_L4_SRC_ONLY | - RTE_ETH_RSS_L4_DST_ONLY; - - if (rss_hf & l3_src_dst_mask && - !(rss_hf & ip_mask || rss_hf & l4_mask)) - hns3_warn(hw, "packet type isn't specified, L3_SRC/DST_ONLY is ignored."); - - if (rss_hf & l4_src_dst_mask && !(rss_hf & l4_mask)) - hns3_warn(hw, "packet type isn't specified, L4_SRC/DST_ONLY is ignored."); + uint64_t ip_l4_mask = RTE_ETH_RSS_NONFRAG_IPV4_TCP | + RTE_ETH_RSS_NONFRAG_IPV4_UDP | + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | + RTE_ETH_RSS_NONFRAG_IPV6_TCP | + RTE_ETH_RSS_NONFRAG_IPV6_UDP | + RTE_ETH_RSS_NONFRAG_IPV6_SCTP; + bool has_l4_src_dst = !!(types & HNS3_RSS_SUPPORT_L4_SRC_DST); + bool has_ip_pkt = !!(types & ip_mask); + uint64_t final_types; + + if (types == 0) + return true; + + if ((types & HNS3_ETH_RSS_SUPPORT) == 0) { + hns3_err(hw, "specified types(0x%" PRIx64 ") are unsupported.", + types); + return false; + } + + if ((types & HNS3_RSS_SUPPORT_L3_SRC_DST) != 0 && + (types & HNS3_RSS_SUPPORT_FLOW_TYPE) == 0) { + hns3_err(hw, "IP or IP-TCP/UDP/SCTP packet type isn't specified, L3_SRC/DST_ONLY cannot be set."); + return false; + } + + if (has_l4_src_dst && (types & ip_l4_mask) == 0) { + if (!has_ip_pkt) { + hns3_err(hw, "IP-TCP/UDP/SCTP packet type isn't specified, L4_SRC/DST_ONLY cannot be set."); + return false; + } + /* + * For the case that the types has L4_SRC/DST_ONLY but hasn't + * IP-TCP/UDP/SCTP packet type, this types is considered valid + * if it also has IP packet type. + */ + hns3_warn(hw, "L4_SRC/DST_ONLY is ignored because of no including L4 packet."); + } + + if ((types & ~HNS3_ETH_RSS_SUPPORT) != 0) { + final_types = types & HNS3_ETH_RSS_SUPPORT; + hns3_warn(hw, "set RSS types based on hardware support, requested:0x%" PRIx64 " configured:0x%" PRIx64 "", + types, final_types); + } + + return true; } uint64_t -hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) +hns3_rss_calc_tuple_filed(uint64_t rss_hf) { uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY; @@ -548,7 +576,6 @@ hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf) !has_l3_l4_only) tuple |= hns3_set_tuple_table[i].rss_field; } - hns3_rss_check_l3l4_types(hw, rss_hf); return tuple; } @@ -576,7 +603,7 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf) uint64_t tuple_fields; int ret; - tuple_fields = hns3_rss_calc_tuple_filed(hw, rss_hf); + tuple_fields = hns3_rss_calc_tuple_filed(rss_hf); ret = hns3_set_rss_tuple_field(hw, tuple_fields); if (ret != 0) hns3_err(hw, "Update RSS flow types tuples failed, ret = %d", @@ -611,6 +638,9 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, return -EINVAL; } + if (!hns3_check_rss_types_valid(hw, rss_hf)) + return -EINVAL; + rte_spinlock_lock(&hw->lock); ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf); if (ret) diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index d672481a14..415430a399 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -186,6 +186,7 @@ int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, int hns3_rss_reset_indir_table(struct hns3_hw *hw); int hns3_config_rss(struct hns3_adapter *hns); void hns3_rss_uninit(struct hns3_adapter *hns); +bool hns3_check_rss_types_valid(struct hns3_hw *hw, uint64_t types); int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf); int hns3_set_rss_tuple_field(struct hns3_hw *hw, uint64_t tuple_fields); int hns3_get_rss_tuple_field(struct hns3_hw *hw, uint64_t *tuple_fields); @@ -193,7 +194,7 @@ int hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, const uint8_t *key, uint8_t key_len); int hns3_rss_get_algo_key(struct hns3_hw *hw, uint8_t *hash_algo, uint8_t *key, uint8_t key_len); -uint64_t hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf); +uint64_t hns3_rss_calc_tuple_filed(uint64_t rss_hf); int hns3_update_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, uint8_t *key, uint8_t key_len); -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-04-09 21:45:40.998672600 +0800 +++ 0087-net-hns3-add-verification-of-RSS-types.patch 2023-04-09 21:45:38.709042200 +0800 @@ -1 +1 @@ -From eb3ef9e0d7eb54b47ab58d3d14f9f5fff3f4120b Mon Sep 17 00:00:00 2001 +From 5af10c2a20aea82a13078ef07fc1deaf2d13617b Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit eb3ef9e0d7eb54b47ab58d3d14f9f5fff3f4120b ] @@ -14 +16,0 @@ -Cc: stable@dpdk.org @@ -25 +27 @@ -index 6ac623bea9..e132d88fa1 100644 +index c38bd9dd8b..c1f4f5cb0b 100644