From patchwork Sat Jan 21 05:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 122435 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 3CC8C42436; Sat, 21 Jan 2023 06:22:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D0F6427F2; Sat, 21 Jan 2023 06:22:29 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by mails.dpdk.org (Postfix) with ESMTP id C6BF142DB4 for ; Sat, 21 Jan 2023 06:22:27 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SgJtOcqmx4Rvu/+Bf9Ydo19iVDA3oDJnzcuZrdoJxuZcG5sl0JR/sJJR2r6oQMCc2HV7syrY1WGy+kU8RhumITdOmUQl20fUwCNxRat6MgtojTlaRQU3yhZaYjNfGOT7thWEFerz/1KGY1Wv9y13PCA0rQrbsr07wnYwwE6V0oYS5GTV2XNrlRTSoVFQ2yf1dUOJB02nI3PQpKJMbi972qoqAAEQ/S6rExHhNyYGfT26UPMSIbW/769EeEvyCuMcemqtPki3vklBnjknRx0ZpHJTdZBn+goQ/ch7hIA/PdCANZEauGDkp1m+uFn/rVD9epK5w3Z63oZ0XQPbtBseIw== 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=CVqVWYTIX/SkkV+ClGWwWt8k5ltHZ7wTVtMIYrAtJU0=; b=O/tnUnmuXmajeY4tC9twPOqoZSerwDms93PQyIw8QUXKVO+cMqfha20u+n5nuZbPQcXa/i4E0g+PPDPUPX2HyQVi6tMAnqkzrftyUdcnvx85x3PJ8myMy9DifIUaew6r/D/NzLc8fmZ6ruBTDpn/a0VrKHlowcjKzNCUIF2e9hC0URyEkGB8YD1U5ZTf9azzM61xs/iQC8R0TUmYrMCA2BaAmw5BPavXKxPOtf2zbS9ss5LcNSxbss5cNpdjBmS6DQUzcXz6lr/xKQP2Ab8ciB4y0dHwFh/ccfT7ZU6ciMnpCVq/A9WUNBHRd/1FaNCniuKHRRbEjvMg1hff3qoBcQ== 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=CVqVWYTIX/SkkV+ClGWwWt8k5ltHZ7wTVtMIYrAtJU0=; b=g2ZLDYSKZtvg4Vn56dEjaqz+4i84ESyW01TyIfbDdp22LxSWLc9spYQaGMOBvGHDq/Z2v7KmWmQxpogbLaCeLgA+tFj9LrSg1V1hVGq4lP+RrocvTju/F3CvAI+0e3wnHoLzsIuaG6I+m7g+SMg6gNp9UwaA/IHigeEoQG5eKiHq78scikYpb1X8njUXL+KLb1vqmIlesemLTdvhnfLyswBZ/+xDiuiDZ1EoV8E8kBbM5Und9LqHq1AYa+vw5hXsc0hSGbiTyS9kyW08lzhheYvOJhcHvHr4X83IyI8R/lfDPesPsSVZmoipgn38kQCOzOKr/K1CJFttIJIYK+QWUA== Received: from BN9PR03CA0538.namprd03.prod.outlook.com (2603:10b6:408:131::33) by DM4PR12MB5055.namprd12.prod.outlook.com (2603:10b6:5:39a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27; Sat, 21 Jan 2023 05:22:26 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::a1) by BN9PR03CA0538.outlook.office365.com (2603:10b6:408:131::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27 via Frontend Transport; Sat, 21 Jan 2023 05:22:25 +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 BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Sat, 21 Jan 2023 05:22:25 +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; Fri, 20 Jan 2023 21:22:22 -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; Fri, 20 Jan 2023 21:22:20 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH 1/4] ethdev: add template table insertion type Date: Sat, 21 Jan 2023 07:21:55 +0200 Message-ID: <20230121052158.2928238-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230121052158.2928238-1-akozyrev@nvidia.com> References: <20221214022110.393410-1-akozyrev@nvidia.com> <20230121052158.2928238-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: BN8NAM11FT050:EE_|DM4PR12MB5055:EE_ X-MS-Office365-Filtering-Correlation-Id: 80a59ee0-44c1-451f-07ae-08dafb6f7b5f 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: cgF34XQ0Ea+pobom1xrTycPUXDQkK1kxJYXv069QY6J9XuE9jhiPho1gsj6Fo+YRiDgkdl+SWNsPyPPtWAw+GeXoVOQlpy7AnQtA4Ig2ULSZXuRHtSGTeMwcPiYnO9lcyO4gOTAYvaOeDJZCH3N9YXaKGKtg89S8nP0YtQ3fLYELnXOIzEnp4CbqqQ5Cj/r9z0aSkprQzcC1TpnU1bsxiPksTR7WKbhrr6YYE6DYONLlB4Rnm2JeQ/vY/wdKzhhFRAxkbyq7j1TXfw4MazfBZQMQGqIh6Zyy0/mt9E/D0lRqtbM26vaYvVDP72tgNPCUVRfB+7ia+OKrH/XunVbx17FQp1hhqklEaXZJ5nMKfyQ+4Arw5unPtEgZjz29tpE2uLrs5vko1logV+7f47Xd1RDtAumsVJYf1CiE5VBvHDQ4sy5ORDVPRVUWGxjEnB6OEFiJbfPBlhTxDvHac8eb1oaNl/AD5tQBr8CnasAH2ZL31+obfPZtrP4mFzAcP7LWT+9v/eUDu1aIGhmGSCLCSYClAR/MnGOeIQ6o7jN3pJBX86/891TpRGRX9YBJQNJYORq96JGUIuarR1nZVIKmkAMFhZ/+HxL0Q6EyclbtYJdMAbIZ4baH8ftPnxgx4UUe3dmLjPwTXtUr+sZp3w+e94Xe0FcGzeIjLPS4eUvEtZCWkqtAwJBMr6CGHU+v4UZwdaxo99yPBQyLflvLybrS1g== 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:(13230022)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(5660300002)(8936002)(4326008)(82310400005)(8676002)(6916009)(70206006)(70586007)(6666004)(107886003)(54906003)(16526019)(26005)(186003)(2906002)(36756003)(478600001)(2616005)(316002)(36860700001)(83380400001)(41300700001)(40480700001)(82740400003)(40460700003)(356005)(7636003)(86362001)(426003)(47076005)(336012)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 05:22:25.4082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80a59ee0-44c1-451f-07ae-08dafb6f7b5f 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: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5055 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 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 new create_by_index() API. The idea of the index-based insertion is to avoid additional match and simply execute predefined actions after jumping to the index. The insertion to already existing index is undefined and depends on PMD implementation. Old rule must be destroyed first. Index cannot be bigger than the size of the table. 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 | 66 ++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 11 +++++ lib/ethdev/version.map | 3 ++ 6 files changed, 131 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3e6242803d..7d05acb2db 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 the rule at a table index. + +.. code-block:: c + + struct rte_flow * + rte_flow_async_create(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 b8c5b68d6c..13dd368f2e 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -56,6 +56,13 @@ New Features ======================================================= +* **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..88d0c6a724 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,51 @@ 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. + * Inserting a rule to already occupied index results in undefined behavior. + * @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 Sat Jan 21 05:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 122437 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 35B1E42436; Sat, 21 Jan 2023 06:22:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E013542DCD; Sat, 21 Jan 2023 06:22:36 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) by mails.dpdk.org (Postfix) with ESMTP id 73E9541101 for ; Sat, 21 Jan 2023 06:22:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+P/SIenosJ/omykB7DHTrhCcK3smSvL+HLdxWI79Z09oLnTrBJhdvFi9mG5myuQZili2wVUTbAHeSWAA5hQBJ0X595mdKDlfqcjB5DMEu7+D+TSjLUobNE0gMljP5mBpKoVRVnGdz1RL+zfk6fMMbuLzbYrrDEScDP2ehH2OADY34QCk3J0+zojxyZFXWatJiZ6YTddanQ06/zuJu8in9z7WJ+763NKsAQUYVidUnCgwXqJ4Kgk4nXi2qsHIRuzwmZdLRbDaomft8dFaDUEGe3LVXmGAoDnEk0sKC/xjZURzRuFi9MBci8cKyKIq2WMxsbmhge6A0PWPTu+t3kycA== 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=eOgbcHkKdQghWMYTBB+h8FaJrB1aYMdDoIPI6g7oVGg=; b=n51W1eoQs2Ht6XXf/mzBqaT+i5Jb6QvkaUm+XoY3tx70wbIyzfGEBIM41WrPQB+hP15bvve5QSrVxgHSP9fd2kUTkvZVrBJ7TgtKa7pDtYVV9R/0LfbWFyKOpZcTU8LwX20WHosQKpgrjHCBG1HAv2RSPibZHDb5yx8aVFxJXGYWzDsqQsZ74MZAN9ovu/hlOIO0NpmBiFzo/IKP7+aXPKdrDMEr3lswpWdvIjjn84vNmo1GepjIW9PXKVbRkeRSUbzhr4F6FwKF54dta+FbKnQA3FHTOhdi3jlYyUMxPaQ3/30fUNp7lnDcpU6PnwUOowX8XTZrbcWJbodjuxxcXw== 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=eOgbcHkKdQghWMYTBB+h8FaJrB1aYMdDoIPI6g7oVGg=; b=RvTFihkjtoSXR9JeMW3PC25FnmChQ/t7uz0yYSmvfJsceBYUmnlrINpsHUunuf6sSCvTARnO5niRueGR4u+QcMZwC6YUVi66IRlLL/Rr46oboEKxriGs11AhVkqCPUkR+u5aGfDilU2xi4da1go3LMjh5fTJL36VUmu6WHG0kxAh9u3o3c/rHsW51NwPBR/Z1W1+yRt7xBmYt97xzqI99Us3okCZfaxfsGQz1EG12TGzBP4Ed3OWCYK0WBjbIEUNsER/qk5ZPeG516F0AwfhNN7OSq7E4aviwokyobIsHsSXaTIKWPDs+WT/zkSrBTVhiNdLZVXGJKHTGBtMiM0jyw== Received: from MW4PR03CA0107.namprd03.prod.outlook.com (2603:10b6:303:b7::22) by BY5PR12MB4243.namprd12.prod.outlook.com (2603:10b6:a03:20f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.28; Sat, 21 Jan 2023 05:22:29 +0000 Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b7:cafe::86) by MW4PR03CA0107.outlook.office365.com (2603:10b6:303:b7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27 via Frontend Transport; Sat, 21 Jan 2023 05:22:29 +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 CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Sat, 21 Jan 2023 05:22:28 +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; Fri, 20 Jan 2023 21:22:24 -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; Fri, 20 Jan 2023 21:22:23 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH 2/4] ethdev: add template table hash calculation function Date: Sat, 21 Jan 2023 07:21:56 +0200 Message-ID: <20230121052158.2928238-3-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230121052158.2928238-1-akozyrev@nvidia.com> References: <20221214022110.393410-1-akozyrev@nvidia.com> <20230121052158.2928238-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: CO1NAM11FT033:EE_|BY5PR12MB4243:EE_ X-MS-Office365-Filtering-Correlation-Id: d63d2ef4-9d3b-4aa8-fa34-08dafb6f7d54 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: znmBZIBYm0VOylMvAR2aMiK+sX0dTjWq+SW0uv2oHZxdIpwH9b7zgoWMFoOC/RmBQG2e6rEAHPqCBZ8uqrHjz7kxlBsmWewCQjLtLx/2kXNpbi4IYjPlhuYCw/xlBD6QNeEea/lQC8TJ9slat6oYlHx7Z9CqY9EETepuOpj6CyqWDan2Q21avsuYM1w8zNS0qD2DRXe2e32j0uJ3Jw+3wFITPYfd4CgD2A0GnLW5UzCDymw+MwodeHJwSU8QR2lwGI9LiNCZ74sjF698VybQ3CIA5D6PrNvQRcxsRrJnDRNooA+a+iOXxtUexAy0QZMiL1JTjlBJj+bIgQRXL8U8GnuQrwa48ETAOiEvoQE7tOY4ImX5sQEJe60yEWJgnU/ZLSs3ab2UfazZa/iomJxd+zXIRrlf/7SqrEg0rMb2d6MZGZwPMjdHWsvBLtECosGKLnk/9F/2IMDSFHDGmriPmy/N1CNIHKSnJdFdbxKRuBoR+c6//P8fqeXCRyH7cC+4CsmTcAl+l1BVya4CznU0S7qSFpucowZZrmXVgdGHKgYg/NFkAA+zQSgKqdRgf+MAOPMYS/9rYCWd+HZq/gizMxyHcSt5ERUNdqPengm7Vjg5v6DgW3aJpzBqt5mOM1OHSvREliCtZw2KHlbryFRmE3hrAGp05BqaK8Fou2ujkaA= 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(36840700001)(46966006)(86362001)(2906002)(40480700001)(70206006)(70586007)(16526019)(186003)(26005)(336012)(41300700001)(426003)(4326008)(6916009)(8676002)(1076003)(2616005)(47076005)(478600001)(316002)(54906003)(107886003)(6666004)(82740400003)(7636003)(356005)(8936002)(5660300002)(83380400001)(36860700001)(82310400005)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 05:22:28.8071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d63d2ef4-9d3b-4aa8-fa34-08dafb6f7d54 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: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4243 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 | 4 ++++ lib/ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 13dd368f2e..0535205c8b 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -63,6 +63,10 @@ New Features Introduced new function ``rte_flow_async_create_by_index()`` to insert rules by index into index-based template tables. +* **Added index-based rules insertion in flow API.** + 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 88d0c6a724..0c793bce8a 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 Sat Jan 21 05:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 122436 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 3755D42436; Sat, 21 Jan 2023 06:22:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 872B542DBF; Sat, 21 Jan 2023 06:22:35 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2050.outbound.protection.outlook.com [40.107.220.50]) by mails.dpdk.org (Postfix) with ESMTP id 5CC774067E for ; Sat, 21 Jan 2023 06:22:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=naftYVaIxctXsFP1YtT9sjCxuF/6sRyhBaKekZ8GSJKS+za1BRQTsh1b1V9ZDg67rUlP0OYadvI6QefHJVG8JpR75MnV/evzvDt4fl+Avb2M1YRXwnhI+O7XyWwHA6xKojtM3GamQATr/RPLal6M6Doh/POSgixcFihpFqNEmgKB2lKib7Sp37+i5p1B9wt5PW2xuoQxvpJvsiawwRDqGZp3d1z2gVG+sIrXBZ9qAucCKDZNphgQvtV78QAgsJz+KIZ4aVA34xFl192QQ5GEXbnxD5LFbOxtQ9E9VetUQpIbVZcosBZE9tbNFDUYehOeDaFYOyo4gUN9ixvZoyufsQ== 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=H7sHCVi+Av0RE7MqXqEll92rXVextRZYIXQBjX4WxCosfCrzaYt53XQZSO7tmUNhKSKpmnyxE54/iS6fabdq/19TkPjShWJKb0VP2Vdx9RxFajfna2PUGgwpF+Bzv7edI86UG41fE69GiXnw0FLJifAmmVkhIXAAr0cEJ9pV0le78MtyjxGOaPSEAFQJ490WcGwKVbtajnvuuNysfs/FL2YTMcFkyy9cKoWGaF8EfHjm9USddK0sfyeguKWyjnJyAWCmDzKX/ZPIuvkHy9F/g9f7LGq1+fOSYWfcxVfSOEmMsZHTyZNNwvmCJCVGF7lkSEyquM/aKAD25/slhcdzOg== 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=LPGQR7e2zff7QByA6sdZeUavWgRI9J42xxHHwmfhDhBxpZ5RlQIXuJPZdBli8Hi7jYsI3VTYpR1ohiC9gCwLhfPerbPXCHuzFVyERwzIwXczHS/NFqTW01dAudbvuxjIRLPOxIpXZqwhBeRHMw8jgHiC+sgx/I4nQizc/QK96ymKymcH7m2utlfTllIT81A1/BcikLt8HwYXwQqKRkDAmd1KDLkgv+rrETCBYGVbHanPXQjnrxfjBnkOWmyHsnyuRW+xJhswbxwhU8IpvI+DpYR+OzYxHBxsBCGceHBjZneKElYA0QoN/HKeYlSt0HK+s80g6NGWU+LxeEV0Hj5Ujg== Received: from BN9PR03CA0516.namprd03.prod.outlook.com (2603:10b6:408:131::11) by PH7PR12MB8013.namprd12.prod.outlook.com (2603:10b6:510:27c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25; Sat, 21 Jan 2023 05:22:30 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::b4) by BN9PR03CA0516.outlook.office365.com (2603:10b6:408:131::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.28 via Frontend Transport; Sat, 21 Jan 2023 05:22:30 +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 BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Sat, 21 Jan 2023 05:22:29 +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; Fri, 20 Jan 2023 21:22:27 -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; Fri, 20 Jan 2023 21:22:25 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH 3/4] app/testpmd: add template table insertion type Date: Sat, 21 Jan 2023 07:21:57 +0200 Message-ID: <20230121052158.2928238-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230121052158.2928238-1-akozyrev@nvidia.com> References: <20221214022110.393410-1-akozyrev@nvidia.com> <20230121052158.2928238-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: BN8NAM11FT050:EE_|PH7PR12MB8013:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b4516ff-e449-45a4-a07b-08dafb6f7dfa 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: M6YH7QBsw4JP5FuOm/f+gUhN3RTU7j7E7SD13wOV2CDtmFYoC4zl+c2HqgEbe3ObR8EyhKSKhGvBW43fcGjO4I8XeTkAn0Z0LCEOuANIxL4jdEu0ac58OzRQDgT0lsUQpEjmdegXUvv8es2YHHwv/OaY8w3JN0ewzOufspy8+yDNYJFqoDoy8uqVvF8vIw6b6XnQZgSdYE6ALeOASF/vMuyeARN9V9sk5OZaCBFKaQrDVHfWZoJIWt5O90JVrAOM6A+6GWdL9xlLz/XZJ4mGklGcPluYMlQ6vf7tceGvpXh/r/7GiPXNgn4hY3ClBeSahhEnn2qeEooVxSs1ZtbjOtaLqF/aGU2bF4Opq21Xi4lKLbGeSgDS6fuCR8340HZzulWGTtnUSpLVHKBcnRbLGWPe48VHERxHBuIvV/HTeWhxjTtPQAMQfEJDPw8aaM+m6y0OIdX9HvEWTVz7gSGJSNpDjbCsRWRRmErwkZIvnCRonS37QciNTvfqJUVLctt9+ZJiOwEb+TjHn9ssP9KZ1syegL9FnLycob35l9BQEWiwzjpc3fNEPOVgaTRUb8+A5xnEXQvS217ORl1mAZxT8HClOWmhW6j4+dQj2z13+96tjah2bEBamL1UePaJ2+EsBVCeVFeFbKck08vYFoNmjgRTmQU5wZugWBkrrJ5yf2EsR1ZXQ+0oBQUZ1xGJPZxMrcGlewQ9q+MW/MUzCRsO/Q== 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:(13230022)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(40470700004)(107886003)(86362001)(316002)(40460700003)(36756003)(40480700001)(478600001)(6666004)(8936002)(5660300002)(70206006)(186003)(8676002)(6916009)(36860700001)(82740400003)(4326008)(41300700001)(70586007)(82310400005)(16526019)(26005)(356005)(47076005)(426003)(1076003)(7636003)(83380400001)(2616005)(336012)(2906002)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 05:22:29.7365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b4516ff-e449-45a4-a07b-08dafb6f7dfa 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: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8013 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 Sat Jan 21 05:21:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 122438 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 31B5C42436; Sat, 21 Jan 2023 06:22:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2686642DC3; Sat, 21 Jan 2023 06:22:47 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id 91F92410EC for ; Sat, 21 Jan 2023 06:22:45 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EwRuP879d0TYBDgi9WZUWvUE84SabPwMLincRVC6EpuaXWCaga7NbAzzcViHSFy7GK9uHDUkFlJOcNERXAa0wL5loGPVE0Qw/c/cMhl3nvudjJd6izlD/jZ+lQ8tGAqfdB/NmvFG8BXn1VvxuHAPjpr73iMiBv12k7EAEIIVYhejjgckvOz30kQFBdsBij+Cb3YnJR6dBk+FJL5xdHGUKxIG7G0Pg1ZyYYoZTJ7etDWpgCCCaykya1vbkeu8whXvbw9NPZ8akgElPdilJ8sRDRNhNW+JtCqgk5u2jX7hBCTWyFKiNJYqhshfUppUf71QsCdJbEaH+K7N49pLiEkW/w== 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=jei6AV2sbgbB7VZqDwkQzJIEzJnUnB2IDoeSQE1KpgwS6O+5xciO6Y0pgh01Y1J+1hijLZGDLoxQqvOHWORnfyp6Kt3cKaxFL104FxGw+a+2TMY1wmMwln1htL8vWr2LcxBGA59U8XdH24zEhG9H9eJN6Uts3EeD7GOi5FJplsZAbo6q0zGFplP2fwRELKpND7zmq3gRSGx2wxnqHFaECKV5DylIvUxTwD4cFt5SthYA44ASqAyAYe0IAWhiVI1JFlCKB/l7p3hrtYSc+8At8NiydSWAIOvVhAJ8k9lPUXXvmUFEop9aHgyk/BtJjhSYQDlxn5jR0ta0+mG9SnAGpw== 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=ncvVn5SsZ9YxK0dv85gMmLcpO7CZQOfhFh+xqNEIcjj2X4UYZ22SeKpSY4cvdHtx+RWyvtWSrG8qB1TtQdktYvvCzStPWIOP8xTHOX65VwEfuh/dBfhJCslgk4GqfWEwCJuGNoEsfiutpZO5ymf8zUMdQMw9ChS/PNs37HmkukFjJZmgQKISVxS3JgHCENXqm0H5Vh7Y6v6xxghLVh95GG0KUjUmEAYbCnx42p6jH5zOYlkB87ATQFlG7PQzrBF7Hhvf9NeUK0PknDRYVHeVZ0a7heZgAm4Nxct5vOC4rG0r0aUa4bJ2N8VLb3ZGRqXTjNbwllt0/N7SMWLM+k3Ftw== Received: from MW4PR02CA0014.namprd02.prod.outlook.com (2603:10b6:303:16d::29) by SA1PR12MB7127.namprd12.prod.outlook.com (2603:10b6:806:29e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Sat, 21 Jan 2023 05:22:44 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::72) by MW4PR02CA0014.outlook.office365.com (2603:10b6:303:16d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27 via Frontend Transport; Sat, 21 Jan 2023 05:22:43 +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 CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6023.16 via Frontend Transport; Sat, 21 Jan 2023 05:22:43 +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; Fri, 20 Jan 2023 21:22:30 -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; Fri, 20 Jan 2023 21:22:27 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [PATCH 4/4] app/testpmd: add template table hash calculation function Date: Sat, 21 Jan 2023 07:21:58 +0200 Message-ID: <20230121052158.2928238-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230121052158.2928238-1-akozyrev@nvidia.com> References: <20221214022110.393410-1-akozyrev@nvidia.com> <20230121052158.2928238-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: CO1NAM11FT080:EE_|SA1PR12MB7127:EE_ X-MS-Office365-Filtering-Correlation-Id: 80f689a9-005b-4a6b-8c6a-08dafb6f860d 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: bMmejC+I42XF0mQdIQTqZ1rmhoKdrz60KkKtwQmI3EdsIKCf6k5cj0GfQN0BqRyFr7u/griTpRzvm+wRWx0eAN6AyijoQlzamlkcnW1hx0TjzZ+nJrQ11v3E4tLZimFUHzO4U6MMpwTboX8HM0DgZIY2bESAa44T3xzYzBGjQcWlxbkKkQo5vvU8pkkGqkhmnxQIADGGwRfOcXaCGVlTbeYt6929GljzZz5XJ9J0RDSlyqLcgOkMFqLqLloUjTmWz/ud1e6G0SID6oyd1wE8R8oqxtr5Si7hZ+9BamyjWiBckAU4LiUZ7Kf5RF4EwKla2VqjzarZKQXBJwep0Yq8JhlpwL1yH0FX6HKS0XdFQh9/1RACaV5hYl5j3h0mZQGp1s5t6wFhuNOJ3U3d60xgwLViuz6kvCG0Exq4CbJdB39Mgb5C54Q2wclUtif4FTuFfWe+uXP4cQIeMsSQqLa/UT9ubK9U1bNL+IIYAtKPDULbzG7tA6/gsbUYvNDmI6qsgF7IQCKZtpM0qOULdLai4o3AU42qydbKxEafxr4QgTyUaZJmxnAghdH+1RzTwgGOB0xOlgos6zHG4O8xbJpypQd4V6+/81jZaxm40IpN0lt+Toasau2QJ7HfER98u0HEjd4hBt/QCyduqxesuJ8DpHdhGwyjXorcxk02hR5XP92RYFdMolJE9NO9rm480q1Pc8x7Rw/11sRQUAsDyP7hMA== 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:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(376002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(86362001)(356005)(36756003)(40480700001)(7636003)(82740400003)(107886003)(2616005)(6666004)(186003)(26005)(40460700003)(478600001)(16526019)(36860700001)(336012)(5660300002)(2906002)(70206006)(6916009)(70586007)(8676002)(4326008)(1076003)(8936002)(41300700001)(316002)(54906003)(47076005)(426003)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2023 05:22:43.4385 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80f689a9-005b-4a6b-8c6a-08dafb6f860d 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: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7127 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;