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 2E83C43016; Wed, 9 Aug 2023 09:42:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E191432A1; Wed, 9 Aug 2023 09:41:52 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2089.outbound.protection.outlook.com [40.107.220.89]) by mails.dpdk.org (Postfix) with ESMTP id 7C11643292 for ; Wed, 9 Aug 2023 09:41:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q5bOvbcm2L8qCCxcMRC0jJxJe35oYwDujlAbshpV7GeLTfSLPSWr9MkYGgMKJj9RZJm5bIZ1oq7xs+lL5uc8XoA/lzOlPWZC4FWKymALDfphUO/VjLzKjv1fZ8uO6UoEwBs7RYETnsSwBNiSJK6jcs4RQhTrnLWIBNGQULiPSFeYwHS1S3qpomshdg1LS2b8ar5l1GeU7w1PrCzqQ886QIvIxhGaE6qYt/dcKO+x+C3mTpHUNuWOlWeyAwAs4ZxLnm4xb7HwqjJhHlxhvgX41PY26A0O+Ji+/jREGyU3Y7y+MhPck1G6lVels4/NqYkiNYBEhaCCVAi056M1u/YNOg== 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=ARiXSBCjEqaSC3gkSFv9LhZ4NIyLMXzLB+R9ZRd9Cws=; b=UVhQYrHgfpkheFl7/we75vARwtuPkd3m60CyC7DB9C7MqszlZ2H9c6QTSnpabjvAO37RHGKDVa+efbfwncVOoMsVDiHKol1iGU4cWuG8VK4uYPLSHyDCJ3LRNPDVoXadVGsBMJGNjKHjEc+TI9/5RGNOmHBLVk8x8elP+FVD3Uf9qqvxWKUow4cvq06EpJdlqs4AigoozcyPkFx0oZ/ZuHZIksDdltxWsIglrbsSaQ3bnusmI18HiMc6e0D6WYfR3h9sYyIkH1Wun4zZ0XWeAFt30DbgUoPqxzHS4Livv/fLJ0MKH70RoOtWd8kzN1labWWzvklKf4PjhRWe9FQxbw== 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=ARiXSBCjEqaSC3gkSFv9LhZ4NIyLMXzLB+R9ZRd9Cws=; b=qAchJKMN6Z3/QV7gTSZDYCqMG5mGRMApENhm9Q4Ys9mD2OssULwHL4Bj5ZQbgo2YBDEVaonM6O+k8BucFcPd4xEHvuvTLNktI06ul2CJLEZa0qU8NLpl1u3hyqet9HXXTSHBrKZ7PoWvH3CFWwO+tBSg94XjpzPErrJCfS2fKLlRYgbLTPZ1t7z4JDQpDC3VGFwKNcDpuJ51Y8etTzZkTNfAp8VofaCh+E0CLpPxdU0QXT/xDE2a35kYRRmcJnwwU+zKkkQMwH7RBwfjQYx2YI0Do/s4O7FcCEq8AX8wrxvC+FXKpiO+ejuOFuVqauGGEjQVFk2G5FQu4PPR6qK95Q== Received: from MW2PR16CA0038.namprd16.prod.outlook.com (2603:10b6:907:1::15) by IA0PR12MB8716.namprd12.prod.outlook.com (2603:10b6:208:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28; Wed, 9 Aug 2023 07:41:48 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:907:1:cafe::d6) by MW2PR16CA0038.outlook.office365.com (2603:10b6:907:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27 via Frontend Transport; Wed, 9 Aug 2023 07:41:48 +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 MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.19 via Frontend Transport; Wed, 9 Aug 2023 07:41:48 +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; Wed, 9 Aug 2023 00:41:30 -0700 Received: from nvidia.com (10.126.230.35) 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; Wed, 9 Aug 2023 00:41:27 -0700 From: Haifei Luo To: , , , , Suanming Mou CC: , , , , Subject: [PATCH 5/5] net/mlx5: add support for item NSH Date: Wed, 9 Aug 2023 10:40:46 +0300 Message-ID: <20230809074046.121807-6-haifeil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230809074046.121807-1-haifeil@nvidia.com> References: <20230809074046.121807-1-haifeil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] 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: MWH0EPF000989E9:EE_|IA0PR12MB8716:EE_ X-MS-Office365-Filtering-Correlation-Id: ae3eb578-1ba4-4c25-af32-08db98ac168b X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vRVT+Y1SiHYiGEkBk6QK4cIRU4RNZkj/5owJAWlbXhsidBOh05X3WPuaMd7BXshwayxaP3CcQ9EEendIWHs5DQssruUIQOhn6VHtHD+iDeV9R+pJPdIs82xqsYAOqsZ43scxPiQ0hoZ7rMDhwp8lnQSJ9MseNoiPBF73BvVMSetWtt1e8W7xK5cSgINKc092ivNqa1cCWiSrk3JCMS+SHlcrAIlLywcWI0FEWZ/n/ZTF+yH5aiKggBcEXlKmGpztSoZjJdy+RVISN9lWY4tiEWFOn3Rl3NjAsXMcI3A0bBTDEiPSu8LgFoPt4+HUMCfBrN6am5gSJWShNlOJgMIrzxossm250V1DLYKVirg4ZMeE1sx9vO/JSCy+XncYb65C8TQtK0ok2BXghtyhYgVlq7q3bqNVnrqHCW3XlxqEBp3OyL5Hc1lVqDXsB1Ydqx5JY3UweeN0cHqe4KJ+LefUZ8ZTZJCOxKl0k7WueMk75wcWXs8G7L5wYgNVZm0Yt3vd/Z/M24jJOzX5SgR6BtgZoYCXt/+o1Nry3xCAXt2bpfwIuhn8qJ6CNTJUl3VLztvkNxg4ekUjcTKgHtwm4oLte7nUw6t848WkhE/nhh5NBpG+nYJpuXDouwhEqJ9zYxVs01UnUoL3CEwOIe0lI5cKJZ4VCBIFNYBqsdxr5PkJUY7RXwmhrFHxUsKgiYnAwAOys/sW8+/SHGL4zOQo3m4pySiaef6rqkVfnT4daVkE8Nx1coSj6IXSaZIsGoW7IIo0 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)(136003)(346002)(39860400002)(396003)(376002)(186006)(1800799006)(451199021)(82310400008)(36840700001)(46966006)(40470700004)(82740400003)(7636003)(36756003)(86362001)(40460700003)(55016003)(40480700001)(6636002)(316002)(70586007)(107886003)(1076003)(6286002)(336012)(26005)(356005)(16526019)(5660300002)(6666004)(7696005)(110136005)(8676002)(8936002)(41300700001)(54906003)(4326008)(2616005)(426003)(47076005)(83380400001)(2906002)(70206006)(36860700001)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2023 07:41:48.2325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae3eb578-1ba4-4c25-af32-08db98ac168b 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8716 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 --- 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 7de6640ecd..0e241acd62 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 a8dd9920e6..4a46793758 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.34.1