From patchwork Wed Sep 25 18:05:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 144436 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB60F45A2C; Wed, 25 Sep 2024 20:06:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC0E740651; Wed, 25 Sep 2024 20:06:26 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) by mails.dpdk.org (Postfix) with ESMTP id 6235E402D5 for ; Wed, 25 Sep 2024 20:06:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d8CqkMPTK8yS+S4TSTkgI8g7bAkDvHdk+Ld1gCmliyD5HMX1g6hvBTnwpp9bq/5wjY4O7o+3SJrsxPxnyLd9J4YbjF3o7pdlnR5+hQcaHq85T+TPRKXRuOFsSracEWWPEbbP4Uk7toDoTeTqIsRYtJYuFo/6xq1WQYC9vU7EMuXybrOfVjTIMzm0wBVmPEEYp1LguvZIhg9ACwe4kXjjXbjjm0wN/3/5ildaMHR2XeCxnGHe3o7AfEsXZ/RVk/T93/g8DcgruRKPeA9VOiYVJQeOJV+1Z2Dzv4I+EcqJikfDNUV+woJN7T0CcqJ71u2pOVXvOTDtABQIhCzAyRLBGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=nI0xERp4yNtvgflKafsLoFz/vULT9tacI4LjZmCkYDk=; b=qoGEY+Jg8gxF6Gf3HVYsDi8aD/qc9M/A4hywjsO7w5OvgXd465TTVWoNtNtbKypRLceBCJZwLcrjrU4M5U71g1jn3HGjiT7ZfcNBDd0oF/pxW/MjLdMXNWeWH6JSc9j9w+RgysCx1FE07vF1U3ah3l3iVx+nIE3ExmTewvS6FPefKooWqbVMY+H2eLlbNtO5KtFkJJiqwqdSkQXWjo/PfKYA6tTISsDzOtvY34v4rjarq4v2kGhDcCH7UinJTZQG8GF6O2xaac+GxUbRuSrP6UV09CetNmFgdHAH2xEBzFx3V7WdukpBi5tZ1ZAktDgbdm0gROqjpd0C0XJDuQEP0Q== 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 (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=nI0xERp4yNtvgflKafsLoFz/vULT9tacI4LjZmCkYDk=; b=KHdbckmW1CqRF93CK/rjxutn9qDYLmhjaYuvxTulfM3kSCY0InCRk5D0dGJ5lGSs6nIZZM+3Zyzh2YT1nWASNhkTA43gRaU8ejD9E0JCWQOah+LXIXq+M8ncofSCUcMjWS3saTeNgsa7d91U9HH9Ahb6VBKqnjETQYoxIHI/7n8p2dBrvOYQ+GiJo88Xez5ZH7Ii173GqrB/QH5lMrFkHs8mKo/J1JCLvN8PD/IoHoU63iwFP6FHyeEjUHCaYbv1QV6TChF1lMZ3K/p2pL8aE0aWNT3AHm0eNA+2CuSYfJrnb9kqyQUsaZyIaFe+NIi3iGzLdRqhvgu42G2up+JWuQ== Received: from PH7P221CA0079.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:328::14) by SN7PR12MB8002.namprd12.prod.outlook.com (2603:10b6:806:34b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Wed, 25 Sep 2024 18:06:17 +0000 Received: from SN1PEPF000252A0.namprd05.prod.outlook.com (2603:10b6:510:328:cafe::80) by PH7P221CA0079.outlook.office365.com (2603:10b6:510:328::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.17 via Frontend Transport; Wed, 25 Sep 2024 18:06:16 +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 SN1PEPF000252A0.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.15 via Frontend Transport; Wed, 25 Sep 2024 18:06:16 +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.1544.4; Wed, 25 Sep 2024 11:05:58 -0700 Received: from pegasus01.mtr.labs.mlnx (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.1544.4; Wed, 25 Sep 2024 11:05:55 -0700 From: Alexander Kozyrev To: CC: , , , , , Subject: [PATCH v2 3/7] ethdev: add flow rule insertion by index with pattern Date: Wed, 25 Sep 2024 21:05:28 +0300 Message-ID: <20240925180532.3958656-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20240925180532.3958656-1-akozyrev@nvidia.com> References: <20240919004813.3158356-1-akozyrev@nvidia.com> <20240925180532.3958656-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A0:EE_|SN7PR12MB8002:EE_ X-MS-Office365-Filtering-Correlation-Id: d9c0d71a-83d5-40b5-6a8b-08dcdd8cbfec 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; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: icbb8zSX4L98UXWnQzyjQXDzlkHpNVExAPjBO7j6HvdFPALJmCEEMSxIqVZcqf7zTJ0LfeO1y4v+Rb8H4Q8B0YHnmUAAAvf1TyJ5m112agE04KX+g0eMCmsUGvVhiIUfO6pPxgeY6raizNYiv0rQsx9qbK5/wLf3TUcW9TKkDbvYT/PIllmxi00oQ/KyCIgH9ndi77Umpe0AkUkvHAR9Yssu5IGQXArgybRWXXc2I1ytpVqAYBPWgXW4TiRP7cC9CMqL8i/dVBrayBNiGEEfTgiy4r6wVb0D5cfrAd/r512mhnUu0m0NxO5uIJgOMbDlbT9TTPRQyOdELhel1w0W+N1OJkaJTk/UaKbEWC9DDeRqNWShnowiE8+gQspoEh5IooprmcNN0uD7HKss3L7nbVFo562ldo+CTTTNvJ14BZ6tpnPncio4XM8/YST6TWflQ/TZ8ZA6HQGwAo7aJr8yoMn5u58tP7yBjh7Th+1mY8X35yf8DVXrFIWKBsIckIAal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NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2024 18:06:16.3463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9c0d71a-83d5-40b5-6a8b-08dcdd8cbfec 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: SN1PEPF000252A0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8002 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 Add a new API to enqueue flow rule creation by index with pattern. The new template table rules insertion type, index-based insertion with pattern, requires a new flow rule creation function with both rule index and pattern provided. Packets will match on the provided pattern at the provided index. Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- doc/guides/prog_guide/rte_flow.rst | 20 ++++++++++ doc/guides/rel_notes/release_24_11.rst | 5 +++ lib/ethdev/rte_flow.c | 55 ++++++++++++++++++++++++++ lib/ethdev/rte_flow.h | 54 +++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 14 +++++++ lib/ethdev/version.map | 1 + 6 files changed, 149 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index dad588763f..adbd9b1c20 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -4156,6 +4156,26 @@ Enqueueing a flow rule creation operation to insert a rule at a table index. A valid handle in case of success is returned. It must be destroyed later by calling ``rte_flow_async_destroy()`` even if the rule is rejected by HW. +Enqueue creation by index with pattern +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Enqueueing a flow rule creation operation to insert a rule at a table index with pattern. + +.. code-block:: c + + struct rte_flow * + rte_flow_async_create_by_index_with_pattern(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); + Enqueue destruction operation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 8d311aead2..fd461128ee 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -60,6 +60,11 @@ New Features Extended rte_flow_table_insertion_type enum with new RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN type. +* **Added flow rule insertion by index with pattern to the Flow API.** + + Added API for inserting the rule by index with pattern. + Introduced rte_flow_async_create_by_index_with_pattern() function. + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 4076ae4ee1..f6259343e8 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -2109,6 +2109,42 @@ rte_flow_async_create_by_index(uint16_t port_id, user_data, error); } +struct rte_flow * +rte_flow_async_create_by_index_with_pattern(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + +#ifdef RTE_FLOW_DEBUG + if (!rte_eth_dev_is_valid_port(port_id)) { + rte_flow_error_set(error, ENODEV, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + rte_strerror(ENODEV)); + return NULL; + } + if (dev->flow_fp_ops == NULL || + dev->flow_fp_ops->async_create_by_index_with_pattern == NULL) { + rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + rte_strerror(ENOSYS)); + return NULL; + } +#endif + + return dev->flow_fp_ops->async_create_by_index_with_pattern(dev, queue_id, op_attr, + template_table, rule_index, + pattern, pattern_template_index, + actions, actions_template_index, + user_data, error); +} + int rte_flow_async_destroy(uint16_t port_id, uint32_t queue_id, @@ -2733,6 +2769,24 @@ rte_flow_dummy_async_create_by_index(struct rte_eth_dev *dev __rte_unused, return NULL; } +static struct rte_flow * +rte_flow_dummy_async_create_by_index_with_pattern(struct rte_eth_dev *dev __rte_unused, + uint32_t queue __rte_unused, + const struct rte_flow_op_attr *attr __rte_unused, + struct rte_flow_template_table *table __rte_unused, + uint32_t rule_index __rte_unused, + const struct rte_flow_item items[] __rte_unused, + uint8_t pattern_template_index __rte_unused, + const struct rte_flow_action actions[] __rte_unused, + uint8_t action_template_index __rte_unused, + void *user_data __rte_unused, + struct rte_flow_error *error) +{ + rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + rte_strerror(ENOSYS)); + return NULL; +} + static int rte_flow_dummy_async_actions_update(struct rte_eth_dev *dev __rte_unused, uint32_t queue_id __rte_unused, @@ -2899,6 +2953,7 @@ struct rte_flow_fp_ops rte_flow_fp_default_ops = { .async_create = rte_flow_dummy_async_create, .async_create_by_index = rte_flow_dummy_async_create_by_index, .async_actions_update = rte_flow_dummy_async_actions_update, + .async_create_by_index_with_pattern = rte_flow_dummy_async_create_by_index_with_pattern, .async_destroy = rte_flow_dummy_async_destroy, .push = rte_flow_dummy_push, .pull = rte_flow_dummy_pull, diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 6f30dd7ae9..84473241fb 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -6187,6 +6187,60 @@ rte_flow_async_create_by_index(uint16_t port_id, void *user_data, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue rule creation by index with pattern operation. + * Packets are only matched if there is a rule inserted at the index. + * + * @param port_id + * Port identifier of Ethernet device. + * @param queue_id + * Flow queue used to insert the rule. + * @param[in] op_attr + * Rule creation operation attributes. + * @param[in] template_table + * Template table to select templates from. + * @param[in] rule_index + * Rule index in the table. + * Inserting a rule to already occupied index results in undefined behavior. + * @param[in] pattern + * List of pattern items to be used. + * The list order should match the order in the pattern template. + * The spec is the only relevant member of the item that is being used. + * @param[in] pattern_template_index + * Pattern template index in the table. + * @param[in] actions + * List of actions to be used. + * The list order should match the order in the actions template. + * @param[in] actions_template_index + * Actions template index in the table. + * @param[in] user_data + * The user data that will be returned on the completion events. + * @param[out] error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * Handle on success, NULL otherwise and rte_errno is set. + * The rule handle doesn't mean that the rule has been populated. + * Only completion result indicates that if there was success or failure. + */ +__rte_experimental +struct rte_flow * +rte_flow_async_create_by_index_with_pattern(uint16_t port_id, + uint32_t queue_id, + const struct rte_flow_op_attr *op_attr, + struct rte_flow_template_table *template_table, + uint32_t rule_index, + const struct rte_flow_item pattern[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. diff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h index 506d1262ab..e00a5d7f7e 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -319,6 +319,19 @@ typedef struct rte_flow *(*rte_flow_async_create_by_index_t)(struct rte_eth_dev void *user_data, struct rte_flow_error *error); +/** @internal Enqueue rule creation by index with pattern operation. */ +typedef struct rte_flow *(*rte_flow_async_create_by_index_with_pattern_t)(struct rte_eth_dev *dev, + uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow_template_table *table, + uint32_t rule_index, + const struct rte_flow_item *items, + uint8_t pattern_template_index, + const struct rte_flow_action *actions, + uint8_t action_template_index, + void *user_data, + struct rte_flow_error *error); + /** @internal Enqueue rule update operation. */ typedef int (*rte_flow_async_actions_update_t)(struct rte_eth_dev *dev, uint32_t queue_id, @@ -436,6 +449,7 @@ struct __rte_cache_aligned rte_flow_fp_ops { rte_flow_async_create_t async_create; rte_flow_async_create_by_index_t async_create_by_index; rte_flow_async_actions_update_t async_actions_update; + rte_flow_async_create_by_index_with_pattern_t async_create_by_index_with_pattern; rte_flow_async_destroy_t async_destroy; rte_flow_push_t push; rte_flow_pull_t pull; diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index f6aca95069..37cc18c139 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -330,6 +330,7 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst_nonempty; __rte_eth_trace_call_rx_callbacks_empty; __rte_eth_trace_call_rx_callbacks_nonempty; + rte_flow_async_create_by_index_with_pattern; }; INTERNAL {