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 EA4B2436E9; Thu, 14 Dec 2023 04:13:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF85C42FD9; Thu, 14 Dec 2023 04:13:12 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by mails.dpdk.org (Postfix) with ESMTP id 3D98442F97 for ; Thu, 14 Dec 2023 04:13:09 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SzYFH/VcUd7lrYAOVjRbsbUujWiCKG2PzWBe4yp4Q0ps5w4atqPdTyu55YcanpObLFKYcCsi8ooo86vX5Vs8Bu1uM+1rk5OKHHCpftMkI1plph94NH389hNZ/OBkCf0BAhXPQnJ1F1YpWGC9JY+KUnskzqTzL/vvoWQw194pf6Fwx2XUxzPKWrMHH8+Onz93WkpJge+OXBAi2Lmv6z/YUGKqIdIJ+bgqjDL4wibk6lKuXvO+J36eoz+OYU+P9QJxHrAte4ZIHbUA/GmJ1FOljBo3cmR64g9EQjWABz2Ie/amgnVKw1CHxJM72zFJscIxqGSZYqQDWHesVVqTXQr1nA== 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=ermkPpHVZ1MCmAlMBQT6Vsyb7fTFNbF2TcqPT0JhB7M=; b=m9Q3McnEVHxKSCeh4eWBZMhA6PkSEUAbi71Ku+QrIw/ydtalDOYxnE8XepBM7EGZDLlK+XWnByrfPZqNG1MjKD9V4R8N2asHpRqg6zwfrXmJIiaMSl+U7yEMm74c0st/knHtmQUq86+EbmMfTv0EZALnGdmjOcP8YH4B3MEBTzqJ+akETBozHj5jnbU+V0gt56iX88v+6Ck+FWopKu17TIOBzJ6CgJMxk4ROQ0xEzw9pG4zwrHs5Iy5eXGsiJKC6SRhh+ElpcXmC0Lvxgy1uFRQdx3YTh+X9ZeYbersXCkRcVUKHaHswSa1KVMWGPS7Pbw7pOOscbK5DCFA3pHtGog== 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 (0) 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=ermkPpHVZ1MCmAlMBQT6Vsyb7fTFNbF2TcqPT0JhB7M=; b=J82ah2hbtD30LZi3GuWCNG/7zkN4kPVJ8JznMNq/1J94wGae0CTha50igB4ChczrBz0goFWL1ZqxBz/JzK+pLxfsydB4FA9mgSX4aqCzdn11l+eKQp4naZCEH1tdpfqNYN4kOxl5yEPxK+PsQOm+gD1PAC2yv70tDuKuvUA/TvIaMYNFzRyVPvs2ve8xif8jllai20Q+iDTNymILaA1wT6R1UBXbWz2MwaOzxRYeitq5Qp/RTmXwKBFlD5zI9nM0QMz5ntYU9OvCV7EQyPs/Yw+Kp45ZSEMcN/wqytPaVlLrhCRc66bgMBe1lW6oA05VR3yY2a2VJtUhKrpqHXS+ig== Received: from BL1PR13CA0270.namprd13.prod.outlook.com (2603:10b6:208:2ba::35) by CH3PR12MB8548.namprd12.prod.outlook.com (2603:10b6:610:165::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Thu, 14 Dec 2023 03:13:06 +0000 Received: from BL6PEPF0001AB55.namprd02.prod.outlook.com (2603:10b6:208:2ba:cafe::d9) by BL1PR13CA0270.outlook.office365.com (2603:10b6:208:2ba::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.8 via Frontend Transport; Thu, 14 Dec 2023 03:13:06 +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 BL6PEPF0001AB55.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Thu, 14 Dec 2023 03:13:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Wed, 13 Dec 2023 19:12:54 -0800 Received: from nvidia.com (10.126.231.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.41; Wed, 13 Dec 2023 19:12:50 -0800 From: Suanming Mou To: , Dariusz Sosnowski , "Viacheslav Ovsiienko" , Matan Azrad CC: , Subject: [PATCH 2/2] net/mlx5: add compare item support Date: Thu, 14 Dec 2023 11:12:27 +0800 Message-ID: <20231214031227.363911-3-suanmingm@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231214031227.363911-1-suanmingm@nvidia.com> References: <20231214031227.363911-1-suanmingm@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 rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB55:EE_|CH3PR12MB8548:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fff9bbd-7b32-445c-ae6b-08dbfc52979e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R6uptSwqn5SIimvQ1f816KU8GDh02qDgpCsE1D6E4FHQatyKS/1qomLxPFORBS+27ewgm7YUJkEDYxi/prFHeiu7ixzkg8XgGqVVKhJ8iqNwEjtVcb5bklfRM85JGrPXaNa8Tg/luxntmeKc7h8WqVVRRo6XkJ3eVQ7z6KbmA1qZ2B1mp975zN6l1m8JgHe/dv8eOtWZlqyAGYeXTf5kSXj1x7WbePu/MmZMGzqwVrPQSEYDgwGpQ1qST9voaisF2KJ8XCtuWz9HTtfQE7bVGctzJ9UEGCsWTqFreQbE2s+h6qSOQLxMR+RHjZUTzFu3W5JurTBVaS/POdWvG5v88G/MuF5g2e04Jf/4cAmEz3bRiioHEKPOH9Lk9Rj0XzVsthCwaZXlV9tyQ2iN+XdSnsBeHEGK5zB40WfYdMHdCaeRmTO4sNr3gNx1SXi35Tcez4SOzIuuR/4E4jBQUGZNz+MgWOt1jGbNK9gS5IXjieT+fjduWw1ELzOzg36cs0NAWnlDPUZHqe6VNC3NFaYAbrAPnJX2rzNmY/EZVWI/kLR/2RqVBIFnxohnockuJsQWOz62KmnXaDE0hJIUJgf2QlFjbQtAGv2RDuPBI6wfd9LFIksQii6k6pGM0kxVWv3zHREJPBCwSJZGs7fNHXlHxRyzTjhwX1su+bs/zhMESN25FcWRkLVPmfXKRxksj1uq6p/NSsGYnhM1C/wW0Rb95mIoem0pYbIcPOILrChb4rVLBQLQyTm98L3oqjjtgdoZ 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)(39860400002)(136003)(346002)(376002)(396003)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(40470700004)(36840700001)(46966006)(8936002)(4326008)(8676002)(6666004)(426003)(336012)(83380400001)(478600001)(40480700001)(2616005)(107886003)(6286002)(47076005)(16526019)(26005)(110136005)(70586007)(70206006)(54906003)(6636002)(316002)(55016003)(5660300002)(7696005)(36860700001)(1076003)(2906002)(40460700003)(356005)(7636003)(82740400003)(41300700001)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2023 03:13:06.2302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fff9bbd-7b32-445c-ae6b-08dbfc52979e 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: BL6PEPF0001AB55.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8548 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 The compare item allows adding flow match with comparison result. This commit adds compare item support to the pmd code. Due to HW limitation: - Only HWS supported. - Only 32-bit comparison is supported. - Only single compare flow is supported in the flow table. - Only match with compare result between packet fields is supported. Signed-off-by: Suanming Mou --- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 7 +++ doc/guides/rel_notes/release_24_03.rst | 2 +- drivers/net/mlx5/mlx5_flow.h | 3 ++ drivers/net/mlx5/mlx5_flow_hw.c | 73 ++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/mlx5.ini b/doc/guides/nics/features/mlx5.ini index 0739fe9d63..00e9348fc6 100644 --- a/doc/guides/nics/features/mlx5.ini +++ b/doc/guides/nics/features/mlx5.ini @@ -56,6 +56,7 @@ Usage doc = Y [rte_flow items] aggr_affinity = Y +compare = Y conntrack = Y ecpri = Y esp = Y diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 6b52fb93c5..18b40bc22d 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -778,6 +778,13 @@ Limitations The flow engine of a process cannot move from active to standby mode if preceding active application rules are still present and vice versa. +- Match with compare result item (``RTE_FLOW_ITEM_TYPE_COMPARE``): + + - Only supported in HW steering(``dv_flow_en`` = 2) mode. + - Only single flow is supported to the flow table. + - Only 32-bit comparison is supported. + - Only match with compare result between packet fields is supported. + Statistics ---------- diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 71ebd67dbd..5693ea4628 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -63,7 +63,7 @@ New Features * **Updated NVIDIA mlx5 driver.** * Added support for accumulating from src field to dst field. - + * Added support for comparing result between packet fields or value. Removed Items ------------- diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 120609c595..9c9bdc3f6a 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -277,6 +277,9 @@ enum mlx5_feature_name { /* NSH ITEM */ #define MLX5_FLOW_ITEM_NSH (1ull << 53) +/* COMPARE ITEM */ +#define MLX5_FLOW_ITEM_COMPARE (1ull << 54) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index c4a90a3690..82d7fa006f 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -426,6 +426,9 @@ flow_hw_matching_item_flags_get(const struct rte_flow_item items[]) case RTE_FLOW_ITEM_TYPE_GTP: last_item = MLX5_FLOW_LAYER_GTP; break; + case RTE_FLOW_ITEM_TYPE_COMPARE: + last_item = MLX5_FLOW_ITEM_COMPARE; + break; default: break; } @@ -4390,6 +4393,8 @@ flow_hw_table_create(struct rte_eth_dev *dev, rte_errno = EINVAL; goto it_error; } + if (item_templates[i]->item_flags & MLX5_FLOW_ITEM_COMPARE) + matcher_attr.mode = MLX5DR_MATCHER_RESOURCE_MODE_HTABLE; ret = __atomic_fetch_add(&item_templates[i]->refcnt, 1, __ATOMIC_RELAXED) + 1; if (ret <= 1) { @@ -6670,6 +6675,66 @@ flow_hw_prepend_item(const struct rte_flow_item *items, return copied_items; } +static inline bool +flow_hw_item_compare_field_supported(enum rte_flow_field_id field) +{ + switch (field) { + case RTE_FLOW_FIELD_TAG: + case RTE_FLOW_FIELD_META: + case RTE_FLOW_FIELD_VALUE: + return true; + default: + break; + } + return false; +} + +static int +flow_hw_validate_item_compare(const struct rte_flow_item *item, + struct rte_flow_error *error) +{ + const struct rte_flow_item_compare *comp_m = item->mask; + const struct rte_flow_item_compare *comp_v = item->spec; + + if (unlikely(!comp_m)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item mask is missing"); + if (comp_m->width != UINT32_MAX) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item only support full mask"); + if (!flow_hw_item_compare_field_supported(comp_m->a.field) || + !flow_hw_item_compare_field_supported(comp_m->b.field)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item field not support"); + if (comp_m->a.field == RTE_FLOW_FIELD_VALUE && + comp_m->b.field == RTE_FLOW_FIELD_VALUE) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare between value is not valid"); + if (comp_v) { + if (comp_v->operation != comp_m->operation || + comp_v->a.field != comp_m->a.field || + comp_v->b.field != comp_m->b.field) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item spec/mask not matching"); + if ((comp_v->width & comp_m->width) != 32) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "compare item only support full mask"); + } + return 0; +} + static int flow_hw_pattern_validate(struct rte_eth_dev *dev, const struct rte_flow_pattern_template_attr *attr, @@ -6680,6 +6745,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, int i, tag_idx; bool items_end = false; uint32_t tag_bitmap = 0; + int ret; if (!attr->ingress && !attr->egress && !attr->transfer) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR, NULL, @@ -6817,6 +6883,13 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, " attribute"); break; } + case RTE_FLOW_ITEM_TYPE_COMPARE: + { + ret = flow_hw_validate_item_compare(&items[i], error); + if (ret) + return ret; + break; + } case RTE_FLOW_ITEM_TYPE_VOID: case RTE_FLOW_ITEM_TYPE_ETH: case RTE_FLOW_ITEM_TYPE_VLAN: -- 2.34.1