From patchwork Wed Feb 8 03:06:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 123413 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 0440741C37; Wed, 8 Feb 2023 04:07:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8AED42B7E; Wed, 8 Feb 2023 04:07:03 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) by mails.dpdk.org (Postfix) with ESMTP id 76F0340DDB for ; Wed, 8 Feb 2023 04:07:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWGjAyHEdwgoJVqZCm0ohmI0MC/7PZ2pbZknucwXiHtUkQPQum03CN19veE3dF9sqKGD04i4Ya2dCnE2AP9WYYc8xwRP10tVHn80c1UltkuRzyGsWosHkzb08Rr4r19o7QbW1bepMC5pcUbb9XJBELojcE7Bg3sN9vaEAEZNRTq3PTLe3fZZclpTuPMuFq+sPqTuiVz6GZUzDKmlN3zEX0aBGOZq6+Igt+BFK7iGqOiTnizpcJnhgbyZR50yEPU4BX5hvfgNXgyKrPEarmc/oZ/vo3xprhCFGkXjk5r+f67FGRktAv2NprZn5EvWrgLG+A7eEbmKvomZjvbnwh7+kg== 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=jF6WaOix9N7nYRi+o1Ty2a8cniMJH4E3pyfYJa0d5Dc=; b=A2EakWR2tqzXWWlqNRHd1ssa6w/lcetJEVn31vCki0yPXPyeYdmoLHTBm3ssObRcvAX0XDPZzR76OE/Q4UCNnXKsveks/XMKToLSF14EzQF9x3Y3A+CjQPkknZ2Gm8nnt9xJOgy+6ZAIEKmBJ8QoIzpFv81Let5ERk/4X7Flg0FlX0FYMkDkulJ4q6NHdgKH1Feq72RIT6jACvdOsBuG84867S1VpT/pSywSCYiVCmb+YBb6iuAOFxxmtXiSoEtadPNCy2OuUCmQpiMLYu7C8rIi4dgO2Ym5mfDJ+2Sf2In+CPuHT04XiO84iHLXXV2hjAs/Qa1tcMjVDIJqYWVuLg== 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=jF6WaOix9N7nYRi+o1Ty2a8cniMJH4E3pyfYJa0d5Dc=; b=dPB6GHTyN2BhscsUg9fhlCBTFAvKjT9OxCEAfDqnse94O6nO429jD3K2uMYyDtQtaAFSiynaP+AFO6/gB15g3SvSloIEWCgjo13rtvP/NVX5KY9mEj7/4HLSdyR/JQ2CW/4IjfS4/0CTmIEUEnypykbJD5uJFkRb1Vw5eR3zDqY7OX+2Uv27fDbrPeH791f9MHBm0Yxx0AG37irPTrw5ZB2l1bciuLm35bJs2IcihIulo6DgJl3Yvwei4eAnb3RZ4own/jC0aReoDx5nENblxyCX7uspmqmpEbq5otwj/jBhCYVkP7jUwyCdu78ddSWd2p4CMLdSdygGBCmH3IE8aA== Received: from MW4P222CA0024.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::29) by MN2PR12MB4408.namprd12.prod.outlook.com (2603:10b6:208:26c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.28; Wed, 8 Feb 2023 03:06:57 +0000 Received: from CO1NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::c6) by MW4P222CA0024.outlook.office365.com (2603:10b6:303:114::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36 via Frontend Transport; Wed, 8 Feb 2023 03:06:57 +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 CO1NAM11FT049.mail.protection.outlook.com (10.13.175.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:06:56 +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.36; Tue, 7 Feb 2023 19:06:48 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.37) 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.36; Tue, 7 Feb 2023 19:06:46 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4 1/4] ethdev: add template table insertion type Date: Wed, 8 Feb 2023 05:06:21 +0200 Message-ID: <20230208030624.78465-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208030624.78465-1-akozyrev@nvidia.com> References: <20230208024755.72743-1-akozyrev@nvidia.com> <20230208030624.78465-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] 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: CO1NAM11FT049:EE_|MN2PR12MB4408:EE_ X-MS-Office365-Filtering-Correlation-Id: a6fd265a-9b7b-43fd-eb9d-08db098189ce 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: jnSLt/KnLmwlKTo1G63vXu3uvOtmFVqlTWW9TURikVWaOhZxKcxAzTUIZN4PejJr+/aZkbGYV8Ub1x6SBqVKhrYbU/EJsGNnu33bj4ZPlAqD9V4+q0y464LRB8UriN9vyN9mV4fJ6mMhjbaqGgSiI3k58UQthnHlfQn0/D6gD5elop7D3P6R3whhX1qm9sy0E6R/7y+zvLS0HW/raxjjWL1/irMYoYw8YCUxmi8WullS5CSkf6tb56pD6vNfNiZKlwvRQ1Dcn9HZHVuepGZQWKQ+VDfQckkYF86IdSFkF7bUMDbQrvCKLxCQHjSZShjGHNgYiTfrHET8t1mdSV2G4hFc6IzXTh4Qxct8lSEweMCzCzwB6y0w7A1NGhQa1+qd+9+yRqoaASrMLI04bxlLcFJ8bBonv8WzS4wsRDVN+p47W/Nx2VqLpZfxJp6hIYPOkiZH0+8RbTUR4exqzlF5zjfiBOjj0aAdhODM/ATJKKWTNyQxzE77iFFXAC14/9yweXRDjnO+JMcTf/+nzRLOJ0ZQrejw9Sdbu2fHItdbhHKaANLLjH3NXNZFKlvMYyhtu5/CIHPgcZNrHraTG4CZwbc9sR8GvwEZ3R7P8edUXkntugaiBxubsF4KjmQk0May4Z1M7kKioqEumGC/WDdA2zJoPSVQNy1jmldOnp7UKZtueaXyA3DqZlOnhQ5+nvit0cZqCxRToMif/FY72okdyw== 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:(13230025)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199018)(40470700004)(46966006)(36840700001)(83380400001)(316002)(36756003)(7636003)(82740400003)(54906003)(47076005)(86362001)(40460700003)(41300700001)(2906002)(356005)(426003)(1076003)(40480700001)(107886003)(6666004)(186003)(26005)(16526019)(36860700001)(5660300002)(8936002)(336012)(82310400005)(4326008)(6916009)(8676002)(478600001)(2616005)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 03:06:56.9590 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6fd265a-9b7b-43fd-eb9d-08db098189ce 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: CO1NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4408 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 Allow user to specify insertion type used in template tables. The insertion type is responsible for choosing the appropriate key value used to map inserted flow rules into a template table. Flow rules can be inserted by calculating the hash value for the pattern or inserted by index via the new create_by_index() API. The idea of the index-based insertion is to avoid additional matches and simply execute predefined actions after jumping to the index. This is how the regular pattern-based table works: 1. The hash is calculated on a 5-tuple of a packet. 2. The corresponding entry in the table is checked for collisions. 3. Actions are executed once the final entry is found. The index-based table skips any lookups for the packet: 1. The index value is taken from a specified field. 2. Actions are executed at the specified index in the table. The insertion into an already occupied index results in an error. The old rule must be destroyed first. An index cannot be bigger than the size of the table, otherwise, the rule is rejected as well. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 20 ++++++++ doc/guides/rel_notes/release_23_03.rst | 7 +++ lib/ethdev/rte_flow.c | 24 ++++++++++ lib/ethdev/rte_flow.h | 65 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 11 +++++ lib/ethdev/version.map | 3 ++ 6 files changed, 130 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..fbed7da9d8 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3669,6 +3669,26 @@ Enqueueing a flow rule creation operation is similar to simple creation. 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 operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Enqueueing a flow rule creation operation to insert a rule at a table index. + +.. code-block:: c + + struct rte_flow * + rte_flow_async_create_by_index(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_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *error); + +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 destruction operation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index c15f6fbb9f..d3bddfb0f5 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -69,6 +69,13 @@ New Features ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter required for eth_rx, eth_tx, crypto and timer eventdev adapters. +* **Added index-based rules insertion in flow API.** + + * Added ``rte_flow_table_insertion_type`` to allow the creation + of index-based template tables in addition to pattern-based tables. + * Introduced new function ``rte_flow_async_create_by_index()`` + to insert rules by index into index-based template tables. + Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..013eb355ca 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -1765,6 +1765,30 @@ rte_flow_async_create(uint16_t port_id, return flow; } +struct rte_flow * +rte_flow_async_create_by_index(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_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]; + const struct rte_flow_ops *ops = rte_flow_ops_get(port_id, error); + struct rte_flow *flow; + + flow = ops->async_create_by_index(dev, queue_id, + op_attr, template_table, rule_index, + actions, actions_template_index, + user_data, error); + if (flow == NULL) + flow_err(port_id, -rte_errno, error); + return flow; +} + int rte_flow_async_destroy(uint16_t port_id, uint32_t queue_id, diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..2ba616eeb1 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -5187,6 +5187,23 @@ rte_flow_actions_template_destroy(uint16_t port_id, */ struct rte_flow_template_table; +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Template table flow rules insertion type. + */ +enum rte_flow_table_insertion_type { + /** + * Pattern-based insertion. + */ + RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN, + /** + * Index-based insertion. + */ + RTE_FLOW_TABLE_INSERTION_TYPE_INDEX, +}; + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -5202,6 +5219,10 @@ struct rte_flow_template_table_attr { * Maximum number of flow rules that this table holds. */ uint32_t nb_flows; + /** + * Insertion type for flow rules. + */ + enum rte_flow_table_insertion_type insertion_type; }; /** @@ -5336,6 +5357,50 @@ rte_flow_async_create(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 operation. + * + * @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. + * @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(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_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 c7d0699c91..b5b597dd28 100644 --- a/lib/ethdev/rte_flow_driver.h +++ b/lib/ethdev/rte_flow_driver.h @@ -221,6 +221,17 @@ struct rte_flow_ops { uint8_t actions_template_index, void *user_data, struct rte_flow_error *err); + /** See rte_flow_async_create_by_index() */ + struct rte_flow *(*async_create_by_index) + (struct rte_eth_dev *dev, + 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_action actions[], + uint8_t actions_template_index, + void *user_data, + struct rte_flow_error *err); /** See rte_flow_async_destroy() */ int (*async_destroy) (struct rte_eth_dev *dev, diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 17201fbe0f..dbc2bffe64 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -298,6 +298,9 @@ EXPERIMENTAL { rte_flow_get_q_aged_flows; rte_mtr_meter_policy_get; rte_mtr_meter_profile_get; + + # added in 23.03 + rte_flow_async_create_by_index; }; INTERNAL { From patchwork Wed Feb 8 03:06:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 123415 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 9832741C37; Wed, 8 Feb 2023 04:07:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E005342C4D; Wed, 8 Feb 2023 04:07:14 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2082.outbound.protection.outlook.com [40.107.96.82]) by mails.dpdk.org (Postfix) with ESMTP id 9B0CC42D0E for ; Wed, 8 Feb 2023 04:07:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJua+FXVEC5OrtawlBzHwl8N2h5y2295suDDWk9N3PeiNFdK7NTdeuZK0NRe1cZqztLYgU4aPD8OVxwMeiVDHcBXPxLf98Bob+QDdAYEbGUG/jDPTqZNFMHQTsvitqOfDIOB0NHsKY4mI8yiU7wxvA9eqnMJzwOUUmseJYOfkvlYwk1dSSidq6Gdq17U3cGYEgbnBeqC55FcfoZiD5edW+SYQu7ef6n1L6BuzSzYCD6YHD5qS1VHL6uSZMxgWXwV1odO74AAODwHho7DoGcxd80u5OuRqzSD5+zcs563rkuQg1IrnypIt3aawG21gVZlG4OzCmcQReOU02FMgTHaAA== 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=hfDdMsVNKLqs9BfFZVR/9DwboR6oI/JHvUrxj0fMVqM=; b=ZMJweS3B0AMdkJ7eyFCppn7Kk+wbdqLVkt32cz0qYysgrte/Lb4xmhWaReHqc2wUl11UtH/bOUOc6hLkxwRV18TdX/vf9kkT5IVX/DFY2pnPrTen8lM9kZFf8AupPIqAxcuCntCVKc9DAy1HMLwzY412dCIsGDdjae3BwlK8N+ERIatJfWRY0Kf02cE5YG1HC+5vjh+J3Ed4j8UMpvN7PWSuVB8TS56Xy1tifhfMDgwWWo9ngE/eXVDpn4pKd2dVG59+JurDAeFXwUS60m810RMbQVA2nNNHuVOKIUjLAY/hhsvs+UnNpL3eDBF6PrBJBTdTuiEQmdInn6vAmOQo0Q== 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=hfDdMsVNKLqs9BfFZVR/9DwboR6oI/JHvUrxj0fMVqM=; b=kTVWU72ktJl/usR3woNJ7jfhtY25rf+HgKdJJYBooQPleQLvsV7d1bAOYSdEECoTk3M9h1drCZFXjWE9cFoayYnLvo8CIT2myQiSacytTyIGng+InMjxd/8CU2xtn4vViuLVrwyExLm+ZZw5iW2evG+DXQpC6rz6DSYUwM4g19OSqm/qMEEi5sDdvRylqkJ79IeIfg12LVrVN/gOllxASGBPIDwmSQTZAZ00g9kT6tBzfJWC2FXXHfWn+L3IRzBUJbXa8DkmiwrwNsC+r0rhBp8CW9Cd+MpHKD/6+s3XJ8JgwwNcZbb4iFuacDrKL+pBzsyZfV33BYVUir+sRm5FEw== Received: from MW4PR02CA0012.namprd02.prod.outlook.com (2603:10b6:303:16d::35) by DS0PR12MB7512.namprd12.prod.outlook.com (2603:10b6:8:13a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Wed, 8 Feb 2023 03:07:00 +0000 Received: from CO1NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::93) by MW4PR02CA0012.outlook.office365.com (2603:10b6:303:16d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:07:00 +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 CO1NAM11FT012.mail.protection.outlook.com (10.13.175.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:07:00 +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.36; Tue, 7 Feb 2023 19:06:50 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.37) 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.36; Tue, 7 Feb 2023 19:06:48 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4 2/4] ethdev: add template table hash calculation function Date: Wed, 8 Feb 2023 05:06:22 +0200 Message-ID: <20230208030624.78465-3-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208030624.78465-1-akozyrev@nvidia.com> References: <20230208024755.72743-1-akozyrev@nvidia.com> <20230208030624.78465-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] 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: CO1NAM11FT012:EE_|DS0PR12MB7512:EE_ X-MS-Office365-Filtering-Correlation-Id: 742e4581-12a9-444e-fb2e-08db09818bbb 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: YOjRC7tHEgQnqz/D6bK42rHWwaoc1YgfHICwd1v3NWedfnaxgBuRYTYVLAtyAtOuwa61KXNw8i0OwycvdlFx4kdKqPDqx4slVZeUm709lIOtYQgpwv2P6Ygpy8H7096yntbYcSwAMjgFWA4FIcI81+5kiD1B/FyjNcyGW2eBvyO/M/fHUcFgNXC0GU7/L6C9Sf9evoLRpB0Ryl6naMBwuzcuxAr7mknSD1jm3qtylClFC14qA7/blJ/X50IGT/X/Nd5XTrNZCBJgwOP0mlxa3Ap58UIft7Dv+sLtNXQooFldiM8oNNvMgTjETRx0uiJwH1dR/J2PgIszhGgGFIEPdU8gwwOwtfdJE1isGk/Kr1NC8stboDhSgMsH4McUWkkGxaFKlRSOZRi8dhwcH+g3gKQ+BavS+KvT5uO5fKhFtdZbznsWOkQll25SFp/GyrZgAovaHwcDZKNY1Vm+P9y8lmQOQ2bkVIlnM8o223Dpf8VHVnKeGcyiJQZpF72UJXT1thdt6LGmRUcNTwIZP6QfV0sLbrUu5oIvPaV5Hyhm3hbMLnzEJfscNSqDlCh1DYCzlqcQ4p/B1vyJTFZcuiUZCalARHqWQmK8iGRWwVnmfrnQtUTaqwzj/8IVfJSQCtNvGLkhXENUItJjBQlxVdZuYKCGxFOzPkFI3LWXn4L+0mDrN9xGjboG2FOj7wwjsK24YrIF+afdqmHaVKHfAlQghw== 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:(13230025)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199018)(36840700001)(46966006)(40470700004)(47076005)(70206006)(70586007)(6916009)(41300700001)(356005)(316002)(478600001)(36860700001)(54906003)(83380400001)(426003)(336012)(186003)(82740400003)(8676002)(7636003)(2906002)(2616005)(86362001)(40480700001)(26005)(16526019)(6666004)(8936002)(82310400005)(5660300002)(40460700003)(107886003)(36756003)(1076003)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 03:07:00.1747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 742e4581-12a9-444e-fb2e-08db09818bbb 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: CO1NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7512 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 Allow user to specify hash calculation function used in template tables. The hash calculation type is responsible for the calculation of the flow rule index a packet would hit upon arrival at the table. Control over this is useful for applications with custom RSS algorithms, for example. An application can select various packet fields to serve as a hash calculation source and jump to the appropriate flow rule location. The RSS hash result will be used as the index in the table. For the linear hash function, the mapping is one-to-one and the hash result is the index. For other hash functions, the index is the hash result module table size. The RSS hash result can be retrieved via modify_field API: HASH_RESULT. Signed-off-by: Alexander Kozyrev --- doc/guides/rel_notes/release_23_03.rst | 2 ++ lib/ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index d3bddfb0f5..5228e0f405 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -75,6 +75,8 @@ New Features of index-based template tables in addition to pattern-based tables. * Introduced new function ``rte_flow_async_create_by_index()`` to insert rules by index into index-based template tables. + * Added hash calculation function used in template tables + to allow control over the calculation of the rule index for a packet. Removed Items diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 2ba616eeb1..6ce61e3f53 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3528,6 +3528,7 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */ RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ + RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */ }; /** @@ -5204,6 +5205,31 @@ enum rte_flow_table_insertion_type { RTE_FLOW_TABLE_INSERTION_TYPE_INDEX, }; +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Template table hash index calculation function. + */ +enum rte_flow_table_hash_func { + /** + * Default hash calculation. + */ + RTE_FLOW_TABLE_HASH_FUNC_DEFAULT, + /** + * Linear hash calculation. + */ + RTE_FLOW_TABLE_HASH_FUNC_LINEAR, + /** + * 32-bit checksum hash calculation. + */ + RTE_FLOW_TABLE_HASH_FUNC_CRC32, + /** + * 16-bit checksum hash calculation. + */ + RTE_FLOW_TABLE_HASH_FUNC_CRC16, +}; + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -5223,6 +5249,10 @@ struct rte_flow_template_table_attr { * Insertion type for flow rules. */ enum rte_flow_table_insertion_type insertion_type; + /** + * Hash calculation function for the packet matching. + */ + enum rte_flow_table_hash_func hash_func; }; /** From patchwork Wed Feb 8 03:06:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 123414 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 3459741C37; Wed, 8 Feb 2023 04:07:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3C4842C54; Wed, 8 Feb 2023 04:07:07 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by mails.dpdk.org (Postfix) with ESMTP id 8CBEC40DDB for ; Wed, 8 Feb 2023 04:07:06 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=noZf7kl7mtfCietcJ4zZXVTI59MqDWA0AMyf7Whfgx+ltokdexUqwp30x/QhGoczG3mPPMEN22LYSqSf4/RR+or+swHlLoYAY8D5/uGwOQGk1Gyol0ll9SmRvXcy4b41PdOM4D6ozQoUchvOGE1ciLk1UTcrGwNHPxG+tx7KisLuGVTj4xc+iS5Eeo/R79N95+38ef8mTRv4F9olWPQjEtCVeaXiPltd4awLBrBfXfLjQQy1oj4X7LW89YtXifybiMq2tCFLvoOc7SiCwXe7i66Rl4zIFOwE/CcekpmQv4ISRapFQolABXiStPjhBbDstNNfnNLVG4NSTyauzSiYhA== 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=GelJ1nuhvqrn9p+RpgUtTZZp1RFvJ8PBtkHX1F43tyE=; b=NZMIexELDaSvUayXX/7w42HxacT55FVqJdeGerygOKIMzD2SjLH+IvK1Ql5q/Q2NtVGwEHlyTKn4WLqgAIegC1lnuVdP/gyOOnE523ynuzcPQOYZgpdfLCRGRMNM1LWVUdp8R9GVM/alkWKBotiFG3pJXkxcesdWBUHU26Hg/jhQeZaT78zdyUJqycTYM2oJDaQtWRQovs69etkza1Iq336/PllE+mV/eN4OgRA5ILHES0f+WHOKxpG2qJO2uID6GKALo7C2gi5N8k41fDbkwDjH/u89CNI7/y5Wg9II7FvKkyqA43DPOuEf0gLPizh7DRV76WZLKHUq+KPFLc1eVw== 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=GelJ1nuhvqrn9p+RpgUtTZZp1RFvJ8PBtkHX1F43tyE=; b=ga7QaqZgd7Ql5wANCgHDJfpEiuWoq5ugYz1DnSGCyXZEHi+8X+wSX1b62PHH0MoqsS+4ByJgFW+YBYzWfVuLf7n7fOhGHlmT/w+tkicZYCUQMRQpnvY79IkB8vfIVdJL6X3VtPaQ42Nxpw/XZFJXuRKk87qNlJyMl8P0kQVRMZ3JA6krxQhQxlXnUcaXpONdMqcLhyYI/8KaNBRrUM+eQNcc9JLAtQjPg80aNQj7dN/4/n9B/VsjBSR/YbEvHWwJHtkZ2UFgX8ciUaKSYXkr+ARJHDd3czM1VKJsLmofxBb8zQM9d1dK5rj+9HxPnnA+xDE0OXhHvvHo0cGTlwN5+w== Received: from CY5PR19CA0058.namprd19.prod.outlook.com (2603:10b6:930:1a::14) by CH2PR12MB4953.namprd12.prod.outlook.com (2603:10b6:610:36::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Wed, 8 Feb 2023 03:07:04 +0000 Received: from CY4PEPF0000C96E.namprd02.prod.outlook.com (2603:10b6:930:1a:cafe::23) by CY5PR19CA0058.outlook.office365.com (2603:10b6:930:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:07:04 +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 CY4PEPF0000C96E.mail.protection.outlook.com (10.167.242.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.16 via Frontend Transport; Wed, 8 Feb 2023 03:07:04 +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.36; Tue, 7 Feb 2023 19:06:52 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.37) 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.36; Tue, 7 Feb 2023 19:06:50 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4 3/4] app/testpmd: add template table insertion type Date: Wed, 8 Feb 2023 05:06:23 +0200 Message-ID: <20230208030624.78465-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208030624.78465-1-akozyrev@nvidia.com> References: <20230208024755.72743-1-akozyrev@nvidia.com> <20230208030624.78465-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] 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: CY4PEPF0000C96E:EE_|CH2PR12MB4953:EE_ X-MS-Office365-Filtering-Correlation-Id: d789d1fd-f8c0-4478-c849-08db09818e5e 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: jrjigzWyu6umbJQG1yfLoDICDGgxIvgWHMusqW46doufDx1qOeJ0pbkZGNGPgWP22hSPuAqWYwPFeRPmvIsrXVQyp/Qg5Xk8nbpGh/PCroBIjx84Whx1vbVHahkad3qxzQI9vG8VhmWAVk0eSdshKJrlLVW/PBwmVUj43FNtnlJdZq5ts91zDkl6/vWd2DeRZdJs6Xi2zP8Cw2kQREsTk5uiL5hSzdQp0Ru+Pob9WmQjMwTA1AOdfIGHkJGK+BQBaCuHZaqMAiU+3FoP6HLS5qJTrnGGDAqJqC2+Hj5We/DYD6whe/qKdTZh+cr+dJpNeLOw5fnVdDWtAeggsFec5zxc1ksH01p9uYYffKBf4UDYHP+IafR6BfyDbGKVnGsCbxFislqZszBttqXIa36WgbzazIEkA+u2YL7gBqymtk+WUA7g1ijyziSuf7mer3loR3jJChWOcabHdekz+Ddj6wIr3BOifFx0eehCUaU9Kpi4B47Gp7+p/0OTnvsDS5BNVladssWjdJSeYTM31cP9LLH0A4+qWQjt4sRvqfJvGJevqV6HDJH0WJFNiAeOOl8w45F/8CH5+4503QGPgqxS/rmiXEbyneuTKl7Eiu/tgMkEJHIRFc7pv+MRO0aEOV98wjjG052Aq6WXoePUlsYCFnmbDIRXtZqloV8ckNOMwvO4i56LHS5oM7ReYMQv3EG0jwhYHCRRiCEja0rPnyM3jw== 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:(13230025)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199018)(46966006)(40470700004)(36840700001)(8936002)(2906002)(5660300002)(41300700001)(6916009)(8676002)(70206006)(4326008)(70586007)(316002)(54906003)(83380400001)(26005)(186003)(36756003)(6666004)(107886003)(478600001)(16526019)(2616005)(40460700003)(1076003)(426003)(47076005)(336012)(40480700001)(36860700001)(82740400003)(82310400005)(7636003)(86362001)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 03:07:04.5502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d789d1fd-f8c0-4478-c849-08db09818e5e 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: CY4PEPF0000C96E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4953 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 testpmd CLI interface for specifying a template table insertion type. Available types are: pattern and index. flow template_table 0 create table_id 0 insertion_type index ... Allow specifying the rule index instead of the pattern template index: flow queue 0 create 0 template_table 0 rule_index 5 actions_template 0 ... Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 97 ++++++++++++++++++++++++++++++++++--- app/test-pmd/config.c | 10 ++-- app/test-pmd/testpmd.h | 2 +- 3 files changed, 99 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 88108498e0..f1d6813baa 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -133,12 +133,11 @@ enum index { QUEUE_INDIRECT_ACTION, /* Queue create arguments. */ - QUEUE_CREATE_ID, QUEUE_CREATE_POSTPONE, QUEUE_TEMPLATE_TABLE, QUEUE_PATTERN_TEMPLATE, QUEUE_ACTIONS_TEMPLATE, - QUEUE_SPEC, + QUEUE_RULE_ID, /* Queue destroy arguments. */ QUEUE_DESTROY_ID, @@ -179,6 +178,8 @@ enum index { TABLE_DESTROY, TABLE_CREATE_ID, TABLE_DESTROY_ID, + TABLE_INSERTION_TYPE, + TABLE_INSERTION_TYPE_NAME, TABLE_GROUP, TABLE_PRIORITY, TABLE_INGRESS, @@ -814,6 +815,12 @@ static const char *const meter_colors[] = { "green", "yellow", "red", "all", NULL }; +static const char *const table_insertion_types[] = { + "pattern", "index", NULL +}; + +#define RAW_IPSEC_CONFS_MAX_NUM 8 + /** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16 @@ -1015,6 +1022,7 @@ struct buffer { struct { uint32_t table_id; uint32_t pat_templ_id; + uint32_t rule_id; uint32_t act_templ_id; struct rte_flow_attr attr; struct tunnel_ops tunnel_ops; @@ -1154,6 +1162,7 @@ static const enum index next_table_subcmd[] = { static const enum index next_table_attr[] = { TABLE_CREATE_ID, TABLE_GROUP, + TABLE_INSERTION_TYPE, TABLE_PRIORITY, TABLE_INGRESS, TABLE_EGRESS, @@ -1287,6 +1296,12 @@ static const enum index next_ia_destroy_attr[] = { ZERO, }; +static const enum index next_async_insert_subcmd[] = { + QUEUE_PATTERN_TEMPLATE, + QUEUE_RULE_ID, + ZERO, +}; + static const enum index item_param[] = { ITEM_PARAM_IS, ITEM_PARAM_SPEC, @@ -2399,6 +2414,9 @@ static int parse_meter_policy_id2ptr(struct context *ctx, static int parse_meter_color(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int parse_insertion_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); static int comp_none(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_boolean(struct context *, const struct token *, @@ -2431,6 +2449,8 @@ static int comp_queue_id(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_meter_color(struct context *, const struct token *, unsigned int, char *, unsigned int); +static int comp_insertion_table_type(struct context *, const struct token *, + unsigned int, char *, unsigned int); /** Token definitions. */ static const struct token token_list[] = { @@ -2901,6 +2921,20 @@ static const struct token token_list[] = { args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_INSERTION_TYPE] = { + .name = "insertion_type", + .help = "specify insertion type", + .next = NEXT(next_table_attr, + NEXT_ENTRY(TABLE_INSERTION_TYPE_NAME)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.insertion_type)), + }, + [TABLE_INSERTION_TYPE_NAME] = { + .name = "insertion_type_name", + .help = "insertion type name", + .call = parse_insertion_table_type, + .comp = comp_insertion_table_type, + }, [TABLE_GROUP] = { .name = "group", .help = "specify a group", @@ -3002,7 +3036,7 @@ static const struct token token_list[] = { [QUEUE_TEMPLATE_TABLE] = { .name = "template_table", .help = "specify table id", - .next = NEXT(NEXT_ENTRY(QUEUE_PATTERN_TEMPLATE), + .next = NEXT(next_async_insert_subcmd, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.table_id)), @@ -3026,6 +3060,15 @@ static const struct token token_list[] = { args.vc.act_templ_id)), .call = parse_qo, }, + [QUEUE_RULE_ID] = { + .name = "rule_index", + .help = "specify flow rule index", + .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE), + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.rule_id)), + .call = parse_qo, + }, [QUEUE_CREATE_POSTPONE] = { .name = "postpone", .help = "postpone create operation", @@ -9069,11 +9112,13 @@ parse_qo(struct context *ctx, const struct token *token, ctx->objdata = 0; ctx->object = out; ctx->objmask = NULL; + out->args.vc.rule_id = UINT32_MAX; return len; case QUEUE_TEMPLATE_TABLE: case QUEUE_PATTERN_TEMPLATE: case QUEUE_ACTIONS_TEMPLATE: case QUEUE_CREATE_POSTPONE: + case QUEUE_RULE_ID: return len; case ITEM_PATTERN: out->args.vc.pattern = @@ -10052,6 +10097,32 @@ parse_meter_color(struct context *ctx, const struct token *token, return len; } +/** Parse Insertion Table Type name */ +static int +parse_insertion_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + const struct arg *arg = pop_args(ctx); + unsigned int i; + char tmp[2]; + int ret; + + (void)size; + /* Argument is expected. */ + if (!arg) + return -1; + for (i = 0; table_insertion_types[i]; ++i) + if (!strcmp_partial(table_insertion_types[i], str, len)) + break; + if (!table_insertion_types[i]) + return -1; + push_args(ctx, arg); + snprintf(tmp, sizeof(tmp), "%u", i); + ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i)); + return ret > 0 ? (int)len : ret; +} + /** No completion. */ static int comp_none(struct context *ctx, const struct token *token, @@ -10357,6 +10428,20 @@ comp_meter_color(struct context *ctx, const struct token *token, return -1; } +/** Complete available Insertion Table types. */ +static int +comp_insertion_table_type(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(table_insertion_types); + if (ent < RTE_DIM(table_insertion_types) - 1) + return rte_strscpy(buf, table_insertion_types[ent], size); + return -1; +} + /** Internal context. */ static struct context cmd_flow_context; @@ -10670,9 +10755,9 @@ cmd_flow_parsed(const struct buffer *in) break; case QUEUE_CREATE: port_queue_flow_create(in->port, in->queue, in->postpone, - in->args.vc.table_id, in->args.vc.pat_templ_id, - in->args.vc.act_templ_id, in->args.vc.pattern, - in->args.vc.actions); + in->args.vc.table_id, in->args.vc.rule_id, + in->args.vc.pat_templ_id, in->args.vc.act_templ_id, + in->args.vc.pattern, in->args.vc.actions); break; case QUEUE_DESTROY: port_queue_flow_destroy(in->port, in->queue, in->postpone, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index acccb6b035..41484c3dde 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2609,7 +2609,7 @@ port_flow_template_table_flush(portid_t port_id) /** Enqueue create flow rule operation. */ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, - bool postpone, uint32_t table_id, + bool postpone, uint32_t table_id, uint32_t rule_idx, uint32_t pattern_idx, uint32_t actions_idx, const struct rte_flow_item *pattern, const struct rte_flow_action *actions) @@ -2685,8 +2685,12 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id, } /* Poisoning to make sure PMDs update it in case of error. */ memset(&error, 0x11, sizeof(error)); - flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table, - pattern, pattern_idx, actions, actions_idx, job, &error); + if (rule_idx == UINT32_MAX) + flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table, + pattern, pattern_idx, actions, actions_idx, job, &error); + else + flow = rte_flow_async_create_by_index(port_id, queue_id, &op_attr, pt->table, + rule_idx, actions, actions_idx, job, &error); if (!flow) { uint32_t flow_id = pf->id; port_queue_flow_destroy(port_id, queue_id, true, 1, &flow_id); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 7d24d25970..22d02a742c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -930,7 +930,7 @@ int port_flow_template_table_destroy(portid_t port_id, uint32_t n, const uint32_t *table); int port_flow_template_table_flush(portid_t port_id); int port_queue_flow_create(portid_t port_id, queueid_t queue_id, - bool postpone, uint32_t table_id, + bool postpone, uint32_t table_id, uint32_t rule_idx, uint32_t pattern_idx, uint32_t actions_idx, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); From patchwork Wed Feb 8 03:06:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 123416 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 A559841C37; Wed, 8 Feb 2023 04:07:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 119E442D16; Wed, 8 Feb 2023 04:07:16 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2066.outbound.protection.outlook.com [40.107.102.66]) by mails.dpdk.org (Postfix) with ESMTP id 51AD942BC9 for ; Wed, 8 Feb 2023 04:07:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LWRzUk4o1uNNM9ESDp4MsNTkiJJ0HfG300zsbe4pgANBnqYmjniCLQdgc8ds/EXH+Mxx5yj+mFjPEl/SRFHcEo22VRg2qSXpl3cGYOUpyYVoPkW2R6Pf5FNNad2BFRUaoqlODTP0tFJU2vpva8PX+G6Jj1AOiab/xJM12pcn5+0jS3F5hK+n3Ld5j8UYlA34rq2UBXynFbtlm62TCfhhECX5zvkgwR+UaBWtumJcgQG+5/gLEri3Dsc/npkG7lMBJ5Abkd2qtoP5qIPK7SzjRfQYW/SqUnyDHabBbKB1SUfGtumlIP5aZHiFlAzXRwqPN5MxlBRAhZo4fMsAooFH4w== 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=iYZMtTDg56l+/XXxXlQ0dmmRZhKgO2DmYs3VJ4Q+6/4=; b=Ps/Mvbj68ZAfiW2vBgIFrNz+dPFcGzGF3/Icqp7LQysHrJbkxP7B/VGBnUMNyQbZbhczUFQki9qAJ4Q3ZD1UXnE9f1fW8R8KJ6lG6Rqyz4Zm2P/JmafwoO8rmRSD7E1NFqYcX7swTooo/7CX8f8WKOYMBaj01IWkKCsWhDXsv3WPyoWUSf/lUXkV3jDqXoguoDlmC64rWTXfgbpEsI8vD0tF8ih7rUReVNjhYxmOtkclfNQS9DnK0x8uGh7CSjasEgF50U2mo5o84Z5tvar0LEL0cKM4Nar0RnYkQXd5aQ6EwP0GT5cXa2B2YzD+23DT9HI0agItlcUFHVkD1Idd7Q== 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=iYZMtTDg56l+/XXxXlQ0dmmRZhKgO2DmYs3VJ4Q+6/4=; b=sywwzdruVQALqYXKuaEICBkvFcqzCezNKK3zizkQigRUxmupLoyN2nOvqSlPyBYCoZIDg9iUF4PNKCWLBgV8XBPV1/2Sh2+tDzLLo49GxotcHdMONp0pHpp2079tWqCjAm0jrzdkDagGcw2dSvBXIODyanbvJDWEhmj+j9MzWHdm3orgsTKVykKHR7eRWyr5tunmA5B/rzWXQT1lyfsLL0JCL1F1qOiXybvKA/7ud1sFn7Qz9DF4/TnxUsiSl1uIO6g4QI7yUiVFn0x1Cm2iwcYDB1+xnO5eZW/Cy/Ky8Ho1y+4sWtGUES2d+ZGV0gcVx5JqjvvkF31NuoTFBSTqLw== Received: from MW4PR04CA0128.namprd04.prod.outlook.com (2603:10b6:303:84::13) by CH3PR12MB8353.namprd12.prod.outlook.com (2603:10b6:610:12c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Wed, 8 Feb 2023 03:07:04 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::df) by MW4PR04CA0128.outlook.office365.com (2603:10b6:303:84::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36 via Frontend Transport; Wed, 8 Feb 2023 03:07:04 +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 CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 03:07:04 +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.36; Tue, 7 Feb 2023 19:06:54 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.230.37) 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.36; Tue, 7 Feb 2023 19:06:52 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH v4 4/4] app/testpmd: add template table hash calculation function Date: Wed, 8 Feb 2023 05:06:24 +0200 Message-ID: <20230208030624.78465-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230208030624.78465-1-akozyrev@nvidia.com> References: <20230208024755.72743-1-akozyrev@nvidia.com> <20230208030624.78465-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] 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: CO1NAM11FT066:EE_|CH3PR12MB8353:EE_ X-MS-Office365-Filtering-Correlation-Id: 797f9ff7-7721-4eac-c39c-08db09818e34 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: n+EfRa84D5uzeeuANqFN7k9n1SSPyeyoiD2cYjaJBhl5hzvCHM5rhCfKvi9+EE06SU4XqyZ/E+dgKwnaGjdtQv/WBgoLPkXzMToyGGJhxF8H+65N9E0fVLqhqi8ATE3ZYtvxXu1fsuiwnWGCC7xncAwhdGrz3SjpK1qGCeSL7xaNCuR1qTf86tNLCx1qYjCXs2w97FoE8pIvs290gG6BMeC2MoY+nIkJ1+HwAQXKe7X+jL03LpHZxS/zTd6L1r2KXt9f8uBTsxrZ5Mj0oKrB9hROTbrMAnAUMTTuoCpS0uEo/DPh0PzjPewlrlYmGRUL1CXSTeuoSpisfokwlHtf5PdQuuZXZn4afWeN57WfiTphwzwdiOTIgu2l8cnYi2OxKrN+76Y9B14D6Y2YUJMLtD0CYrrDCCBt2KwX8n9eVtdQ4GhxPVuhVAKIVUSvtiBGLC9whJAUZTw9C61gJ5V7YVBRyYFyHTNgmbjYT3gOW7dfqMeqIpbxfbzGL9plA8jCqs8OSv79zBbgmA9tuyMc+R3GwlnMV9JpJ4xF2xqWwWekxI1vmfu7nCXnJZxFTUpC7hLjTPMyc5ueW1RqJyoVWBWnlBEw/4RmVDo4alvGUOwxmwQzaJJIdXgJVa+ET4kJKh/d4Y1W7mQ/k8/vYNPZJhKkm7hu7u0dhXns8hBtAEGEMMAFRbArzoMLXgxHazxm8g18/PpbDCkC6UJ0JoBPkg== 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:(13230025)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199018)(36840700001)(40470700004)(46966006)(40460700003)(16526019)(82740400003)(7636003)(83380400001)(356005)(316002)(8936002)(4326008)(6916009)(41300700001)(70586007)(2906002)(36860700001)(70206006)(5660300002)(107886003)(2616005)(6666004)(1076003)(478600001)(8676002)(336012)(186003)(26005)(82310400005)(86362001)(54906003)(426003)(47076005)(36756003)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 03:07:04.3217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 797f9ff7-7721-4eac-c39c-08db09818e34 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: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8353 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 testpmd CLI interface for a template table hash function. Available types are: default, linear, crc32 and crc16. flow template_table 0 create table_id 0 hash_func linear ... Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 69 ++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f1d6813baa..007d31c5cf 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -180,6 +180,8 @@ enum index { TABLE_DESTROY_ID, TABLE_INSERTION_TYPE, TABLE_INSERTION_TYPE_NAME, + TABLE_HASH_FUNC, + TABLE_HASH_FUNC_NAME, TABLE_GROUP, TABLE_PRIORITY, TABLE_INGRESS, @@ -808,7 +810,8 @@ static const char *const modify_field_ids[] = { "udp_port_src", "udp_port_dst", "vxlan_vni", "geneve_vni", "gtp_teid", "tag", "mark", "meta", "pointer", "value", - "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL + "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", + "hash_result", NULL }; static const char *const meter_colors[] = { @@ -819,6 +822,10 @@ static const char *const table_insertion_types[] = { "pattern", "index", NULL }; +static const char *const table_hash_funcs[] = { + "default", "linear", "crc32", "crc16", NULL +}; + #define RAW_IPSEC_CONFS_MAX_NUM 8 /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -1163,6 +1170,7 @@ static const enum index next_table_attr[] = { TABLE_CREATE_ID, TABLE_GROUP, TABLE_INSERTION_TYPE, + TABLE_HASH_FUNC, TABLE_PRIORITY, TABLE_INGRESS, TABLE_EGRESS, @@ -2417,6 +2425,9 @@ static int parse_meter_color(struct context *ctx, const struct token *token, static int parse_insertion_table_type(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int parse_hash_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); static int comp_none(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_boolean(struct context *, const struct token *, @@ -2451,6 +2462,8 @@ static int comp_meter_color(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_insertion_table_type(struct context *, const struct token *, unsigned int, char *, unsigned int); +static int comp_hash_table_type(struct context *, const struct token *, + unsigned int, char *, unsigned int); /** Token definitions. */ static const struct token token_list[] = { @@ -2935,6 +2948,20 @@ static const struct token token_list[] = { .call = parse_insertion_table_type, .comp = comp_insertion_table_type, }, + [TABLE_HASH_FUNC] = { + .name = "hash_func", + .help = "specify hash calculation function", + .next = NEXT(next_table_attr, + NEXT_ENTRY(TABLE_HASH_FUNC_NAME)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.hash_func)), + }, + [TABLE_HASH_FUNC_NAME] = { + .name = "hash_func_name", + .help = "hash calculation function name", + .call = parse_hash_table_type, + .comp = comp_hash_table_type, + }, [TABLE_GROUP] = { .name = "group", .help = "specify a group", @@ -10123,6 +10150,32 @@ parse_insertion_table_type(struct context *ctx, const struct token *token, return ret > 0 ? (int)len : ret; } +/** Parse Hash Calculation Table Type name */ +static int +parse_hash_table_type(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + const struct arg *arg = pop_args(ctx); + unsigned int i; + char tmp[2]; + int ret; + + (void)size; + /* Argument is expected. */ + if (!arg) + return -1; + for (i = 0; table_hash_funcs[i]; ++i) + if (!strcmp_partial(table_hash_funcs[i], str, len)) + break; + if (!table_hash_funcs[i]) + return -1; + push_args(ctx, arg); + snprintf(tmp, sizeof(tmp), "%u", i); + ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i)); + return ret > 0 ? (int)len : ret; +} + /** No completion. */ static int comp_none(struct context *ctx, const struct token *token, @@ -10442,6 +10495,20 @@ comp_insertion_table_type(struct context *ctx, const struct token *token, return -1; } +/** Complete available Hash Calculation Table types. */ +static int +comp_hash_table_type(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(table_hash_funcs); + if (ent < RTE_DIM(table_hash_funcs) - 1) + return rte_strscpy(buf, table_hash_funcs[ent], size); + return -1; +} + /** Internal context. */ static struct context cmd_flow_context;