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 578DF42630; Mon, 25 Sep 2023 04:10:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C386840395; Mon, 25 Sep 2023 04:10:13 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2070.outbound.protection.outlook.com [40.107.94.70]) by mails.dpdk.org (Postfix) with ESMTP id 62357402E6 for ; Mon, 25 Sep 2023 04:10:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CT9MH9i954cVXyRmiPRiwF7gjZgVDgehFO61QKH2whD2tx+xxQFFcm83R7bIU8UA2FosVDlfJGmRF9p3bLSZo+jBaQS0CoQT3ZaI277QneamQyubbdTQEquEHq+F8y1nrLlWMQq31Qa2ojhbz5VjJsFsietIpMi8Syrho9MIZBfMITwwwgrDjp6bQ5yUzD4k6F6AWQ/OtvhBs0m3CA+qB4v7PxGsjmwaSjOM3vFLNgKlsJbf2OkxzATpgtXgd6SX3hAa/Vu+8m/Kgsrsg4TMYxS2fduAtwZld+swr6jw75Pl5xRVtWMEIyxbJyW39Ebo5/r5kLMJRKNELiFiynrlZA== 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=rGV/LEimjla1K0ZnIRY1yJ5U0T9chLatiNyHDiSQy/E=; b=i6GDWlRxLVQorSGBLRIKrktxqs1t6knArfGKcMksa9OPq6p29Sl0JHrXVJXK69kC9bKeaJ59G0dsmuUv0HpZqRh7q/iAz1jtxquo4lF9itLnORlS4dD7SbMQE2s3bxbHMOs4lrc97Kud6kaNv1pIC/atAyEkX8EgACBiicvHMp2EjQ2KHIBByJ4IFp6ygCsrq6NN6wKHbzYupaJwSkEH0qgBLLiN+rpVUcpggdqNFM2xwj3x4fzoLIQNSl2ThoPwhWS8ClEtc9p4JnevvGah5eI7cLQD/ip6SFT0qphEHWYcLOwmUtppR5iJ/eNLwtZ908SHcSZbcyGyr2YPD8HjUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org 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=rGV/LEimjla1K0ZnIRY1yJ5U0T9chLatiNyHDiSQy/E=; b=bv9xOZxercO30WSIUtzzpIzIb+f/H33tQnsqMcFbZhHHB96OHfo7iLhP1MpKqOgUxhbKOD0un5kZpftvUFcwtjT9QYp045wjS8nnBu09RCPIGV7zfJ48AmfFC2N5jpM8a4Z26ErZ3It18s0x6CDrT/UNsKVesdZ68hH3V7yPgXRr1PNd9pkBRgxWZthvpBXv5DcULsJh4q/FzzwcOUa8bEs5aBfDNjU9cXjMMlAuQxup6nzgJypdri8i6lejtp8xAByUXI3YGSYkjseNbWwf1cm8dEXT95u3CJaB6AXn0Ie1nlxw1OoLcd4azJfDTqp9d6qiS7X6Bz2AYOAHHPNc7w== Received: from MW4P223CA0008.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::13) by MW4PR12MB7032.namprd12.prod.outlook.com (2603:10b6:303:1e9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Mon, 25 Sep 2023 02:10:08 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:303:80:cafe::7f) by MW4P223CA0008.outlook.office365.com (2603:10b6:303:80::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.35 via Frontend Transport; Mon, 25 Sep 2023 02:10:08 +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 MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 25 Sep 2023 02:10:08 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Sun, 24 Sep 2023 19:09:52 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 24 Sep 2023 19:09:50 -0700 From: Haifei Luo To: CC: , , , , , Dariusz Sosnowski , Matan Azrad , Suanming Mou Subject: [PATCH v2 5/5] net/mlx5: add support for item NSH Date: Mon, 25 Sep 2023 05:09:20 +0300 Message-ID: <20230925020921.4607-6-haifeil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230925020921.4607-1-haifeil@nvidia.com> References: <20230809074046.121807-1-haifeil@nvidia.com> <20230925020921.4607-1-haifeil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|MW4PR12MB7032:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e0ed0a9-d5c0-49fe-ede1-08dbbd6c8ae1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aewivAFfN+5hxXtAxpJzrkX1OAj2vxnhHpNwf5VrS+Zo03V6+FetkHzXx2lmjtFv/S7eSxh9XSTEmTcygwqVHJU52k+8Myot/3ntV0h4gqbEjndCYls8Gw16VGq0jkcqKY8zHO0NLL3BDzb40IpUQyuLl/Cf7TVdXDzIeBjNjvyyYlBrJSbX9n4MfN8cXhozwJIxTRPkZEqeBMNxxoo2+GTzGlitKmBA7ytY7/EcVLlERNVTyz4c4sniIPQB1YjuWYZNMRtYCxS6dYAS/R6xFGYTJGcCiaMacXfqsZwilj1ReQbRP/Vj9TEzie+boaI5G7Tv68ePCXXGAHN10VmFTFbAD+7IvOTd3u7iJ8yRNJlvKqvz3QiTEr/OUMhbL6SBUC6qj1xqrB1mtGWfC8hQ5BIVYd/0Am+xpJyE9X/DY+AITJzS1m24f3k6EIVLdI9qgaw8w5wDEmqLkO3cpwxkxzilOJ3xci9WIpPi9guyivo6aOBiFHUTRSngl8wjWJ54hPH2kqLogVY0+vMleNWcYBppkRB3lf9FbClMeWE+7u9hTOc+UEQSScPCNTWVNHlDGfTVk0bseKZb6ipzROy6W2VPuPruqz7uPg8b0rgBmSJd3dzwMbWufVfj5dlSOSltrjYwvzF8Y+SrhcM31qqpjNR1QKLmKHrsK7iMh5ctM1w2zKZmxL4MwTxBxQUlDWwAept/MXb3AVDkVS1WmPADCrK9aZI+gEszJpBghw4KSCQDAhEoacOj99443DRE2+PR 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:(13230031)(4636009)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(82310400011)(1800799009)(451199024)(186009)(36840700001)(46966006)(40470700004)(7696005)(6666004)(47076005)(356005)(82740400003)(40480700001)(36756003)(40460700003)(7636003)(55016003)(86362001)(36860700001)(16526019)(6286002)(5660300002)(2616005)(478600001)(426003)(4326008)(107886003)(70206006)(83380400001)(8676002)(41300700001)(8936002)(26005)(316002)(54906003)(2906002)(1076003)(70586007)(6916009)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2023 02:10:08.5830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e0ed0a9-d5c0-49fe-ede1-08dbbd6c8ae1 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: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7032 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 1. Add validation for item NSH. It will fail if HCA cap for NSH is false. 2. Add item_flags for NSH. 3. For vxlan-gpe if next header is NSH, set next_protocol as NSH. Signed-off-by: Haifei Luo Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_flow.c | 39 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 6 +++++ drivers/net/mlx5/mlx5_flow_dv.c | 13 ++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 202e878ddf..8ad85e6027 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3905,6 +3905,45 @@ mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item, MLX5_ITEM_RANGE_NOT_ACCEPTED, error); } +/** + * Validate the NSH item. + * + * @param[in] dev + * Pointer to Ethernet device on which flow rule is being created on. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_validate_item_nsh(struct rte_eth_dev *dev, + const struct rte_flow_item *item, + struct rte_flow_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + + if (item->mask) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "NSH fields matching is not supported"); + } + + if (!priv->sh->config.dv_flow_en) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "NSH support requires DV flow interface"); + } + + if (!priv->sh->cdev->config.hca_attr.tunnel_stateless_vxlan_gpe_nsh) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Current FW does not support matching on NSH"); + } + + return 0; +} + static int flow_null_validate(struct rte_eth_dev *dev __rte_unused, const struct rte_flow_attr *attr __rte_unused, diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3a97975d69..ccb416e497 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -233,6 +233,9 @@ enum mlx5_feature_name { /* IB BTH ITEM. */ #define MLX5_FLOW_ITEM_IB_BTH (1ull << 51) +/* NSH ITEM */ +#define MLX5_FLOW_ITEM_NSH (1ull << 53) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) @@ -2453,6 +2456,9 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item, uint16_t ether_type, const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error); +int mlx5_flow_validate_item_nsh(struct rte_eth_dev *dev, + const struct rte_flow_item *item, + struct rte_flow_error *error); int mlx5_flow_create_mtr_tbls(struct rte_eth_dev *dev, struct mlx5_flow_meter_info *fm, uint32_t mtr_idx, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 3f4325c5c8..5cd04b1d93 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7815,6 +7815,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, last_item = MLX5_FLOW_ITEM_IB_BTH; break; + case RTE_FLOW_ITEM_TYPE_NSH: + ret = mlx5_flow_validate_item_nsh(dev, items, error); + if (ret < 0) + return ret; + last_item = MLX5_FLOW_ITEM_NSH; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, @@ -9720,7 +9726,9 @@ flow_dv_translate_item_vxlan_gpe(void *key, const struct rte_flow_item *item, v_protocol = vxlan_v->hdr.protocol; if (!m_protocol) { /* Force next protocol to ensure next headers parsing. */ - if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2) + if (pattern_flags & MLX5_FLOW_ITEM_NSH) + v_protocol = RTE_VXLAN_GPE_TYPE_NSH; + else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2) v_protocol = RTE_VXLAN_GPE_TYPE_ETH; else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4) v_protocol = RTE_VXLAN_GPE_TYPE_IPV4; @@ -13910,6 +13918,9 @@ flow_dv_translate_items(struct rte_eth_dev *dev, flow_dv_translate_item_ib_bth(key, items, tunnel, key_type); last_item = MLX5_FLOW_ITEM_IB_BTH; break; + case RTE_FLOW_ITEM_TYPE_NSH: + last_item = MLX5_FLOW_ITEM_NSH; + break; default: break; } -- 2.27.0