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 790D442635; Mon, 25 Sep 2023 10:08:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E851D40DDC; Mon, 25 Sep 2023 10:08:46 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by mails.dpdk.org (Postfix) with ESMTP id D3C1840A6F for ; Mon, 25 Sep 2023 10:08:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JyWEWRlE/TmaMe/j6iTcRmd6Gpu2X2Ajqe3AKJoG1E9QZ02dRf+EXUbntV7YXeMFimvBH8y9GnSK+gEwVdjUYag6d398dwzasVRikFO7tSduwto2iQOC72Yn3N1ATIh8G/prfSJnDcasaHECoUPmRY2Dq+zF9eW6bc+RiSv8p5+11upZztS+cvxuzH4fQmNgY3H13tapPcJbaS2TAWsRoVncg4OT6uU0nc4nAc2U1XKtF1DyEL4pFdvLckL8PLnYUcIlVzG8hed8j+4jBdFByjHGp8QiCmYFpX6mpQc4fnYcmqCamEhNyaejHOau6IbA9+HMNQK/B9NxuzpNL6cY8A== 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=BNBrpWk2s/onZBKdk3g5QL9ragfTqISxyD6mBYDgUQ4=; b=JKeJuJv/0+9TBehQICWLpEXht6vLR12Gr10skrde7vI+froR6Lw33nBnx/tetqBiMnVfmTTFiVoOnoWZrJYlzXIp2oW0VCzpfo1rsfKw5/UB7/JIlz2dAl72gMLsaoI7pFCFtMDf6ue/j25e6Ofd/ZTeKjLGXFV8NrsPcE8zvz9nrPKuire65SVINQxfBRogfsMvc0k3B8S+935v4YCOKZCjf5A9++NXJQEBWWtUQGbyitb7tykPASUlobwxce465p/3ODsbtfZ0wFCTW7Zthe8ZxI0jI29QV4wMqFqalqV9IdlY5KL1XFHWf+5IjDusG2JIK/prYVN5+gDFsPR0tw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=BNBrpWk2s/onZBKdk3g5QL9ragfTqISxyD6mBYDgUQ4=; b=cmLsYUgRpWJpr6DsV/kqfbJ47T2mUrcrPX8ZYG/hutdmVdPZDGr3X8xmKwB4can/F1PI72ZKYx7C0UeftdMrwfMBBwVwkTW1kTAmQSwp9iCmqzUqJ5afyjruhAth9xjVZ9Eyst9af6bintuvITfpsltAJkSqRDDGS8dHWOhRc5b6JklA1K7CvzMGa0+CFKqvyuDwgsrgfYiafOXkzzp2G8KIM5/qIrjkEsNPE+nX5Akzw6HbfYAEKVwy+2FOSgoPknEO1ATEbViu6dQFNgGPdqyGOmdoStb8A/z40vho3nq3ilgeuibfxyYyjsjRS8mns7h+1P7Bey5aoTclBflmdw== Received: from BL1PR13CA0384.namprd13.prod.outlook.com (2603:10b6:208:2c0::29) by DM6PR12MB4185.namprd12.prod.outlook.com (2603:10b6:5:216::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Mon, 25 Sep 2023 08:08:42 +0000 Received: from MN1PEPF0000F0DF.namprd04.prod.outlook.com (2603:10b6:208:2c0:cafe::df) by BL1PR13CA0384.outlook.office365.com (2603:10b6:208:2c0::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.18 via Frontend Transport; Mon, 25 Sep 2023 08:08:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MN1PEPF0000F0DF.mail.protection.outlook.com (10.167.242.37) 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 08:08:41 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 25 Sep 2023 01:08:24 -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; Mon, 25 Sep 2023 01:08:21 -0700 From: Haifei Luo To: CC: , , , , , Dariusz Sosnowski , Suanming Mou , Matan Azrad Subject: [PATCH v3 5/5] net/mlx5: add support for item NSH Date: Mon, 25 Sep 2023 11:07:46 +0300 Message-ID: <20230925080746.16438-6-haifeil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230925080746.16438-1-haifeil@nvidia.com> References: <20230925020921.4607-1-haifeil@nvidia.com> <20230925080746.16438-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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0DF:EE_|DM6PR12MB4185:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a2231aa-80ef-4dfb-bb8a-08dbbd9ea1bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PoiSHavPNof48gDgafHviF/XO+b2U+EJPiI73kz7faSFB942IpmToJ3IlUk7JjP0VJQY1TPa0BqC0cEjRwk7Zym81LK10O3tAU4sD/XEs1BGyKWLn3WCPvWD5O6WsGxbYrs0oNSJuXkLDrJ3By1vNaEb9auIpJvMlDBUaswqSrTWQrlk35x03pXxhePQZwnXUJny/A9kUVcAOlmI8XB6YXdFbUeFkg4jQHxKTC8KI2kTJgpijPQUQtQgOIHAvyReORQtwaHdZcW5gU0w8F1Ksq3zkQgb+XteYQ5FnsNVhZn9KPB3v2uJ7v5VM1SzX3VwnsjmXU7vqXdug64JwBvxkD0vo6nslPInQI/dGYV0s1SjVl63+b6tAnePHcHfYxfHHe+VreErLL3J/Jtr0DieHtKxV4cU28TeWvjmS8xsuN/iRrrxhdGKLSCOgMEaOoEHm6evd7GiuVzt7pRgQsGel0CX96JZMZXaYwVraA7DBOnmizQxZDVb1Aww4EqfKUIgZDHKBB1+ANjAgfxlKdl8AjZ2LqfGnTpf5vmYFUzDQnSlTUSW+0N3zaQkCeQVUIWhPRIMxS2RqV3bf20LqRDudDHlJ83++IDYDLcBYzkSdPjBUdI84sWz4l8A5PlDXCcp5/8A9hZin7akMXSzTR835/cSqMt2qkohNKZ25JnOWYTJQb0TPKPeQDijuwk+GO/91+1wKYUdQXCJk4Xd9AWDR2nrlm5q3yiLeliEITPCqAytmD91/Epwtf5LknMF1FYs X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(346002)(376002)(136003)(230922051799003)(82310400011)(186009)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(8936002)(4326008)(5660300002)(8676002)(2906002)(316002)(6916009)(41300700001)(40460700003)(36860700001)(55016003)(40480700001)(54906003)(70206006)(70586007)(426003)(26005)(6286002)(16526019)(6666004)(107886003)(1076003)(2616005)(336012)(82740400003)(356005)(86362001)(7636003)(47076005)(478600001)(36756003)(7696005)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2023 08:08:41.6696 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a2231aa-80ef-4dfb-bb8a-08dbbd9ea1bc 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0DF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4185 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 Acked-by: Suanming Mou --- 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