From patchwork Wed Dec 14 02:21:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 120851 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 BB752A0543; Wed, 14 Dec 2022 03:21:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5FFCE4021D; Wed, 14 Dec 2022 03:21:32 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2062.outbound.protection.outlook.com [40.107.95.62]) by mails.dpdk.org (Postfix) with ESMTP id 2C3C94003F for ; Wed, 14 Dec 2022 03:21:31 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iI5yCg4h+mZvRdjGnXQvRxeWji0u5cI9cO1gBmf3UpsIw7FTrK/keRCLfuOYz9kYMX/ELaHIvg/S3TzRFvsWiI23uOOEozP6lXl8uDgh/bFW86IKZyCb6Bd2n4nXVSAdVUGg0+yEb1K7GoqRimhwL9mph7GHEmtQl5q3NjaTYsYx4KRU+GvVO/zYUalsHnmCXtBdxhs9gt2HEWnk+MkTvbLVaTqefcvQsdP7eYbY87ie1uD7gfhlvlZ83fUy1MdwajnKdTRzZU3MevgrMzimxWpNyGeDvLP0aM0x//DD/y3bVG64tqIWXM1Gi3c2S1tTe12C7OyELGHanLnSbSIx+A== 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=x16dbQvhKlK9vJPRQuux7TB/H2PpN+xXIiBJpnfYu/E=; b=Kgj9xkZuW28hR4k+W7Qf3iUPGLea8QCOZqiG5T7/XwqQSPqNCl1kQb0ioaByz4ssezse/FXL9MTOfOFPMU1efylUS7KcNBHsYvCRIlDtet4NKmVJVOZLrhRdpBsqrYR1R0xPVO6S+woNJBfFzuU6bEhfZhOUstm1vAGIWmnFiEpZYKP8cy6Yjxso/iCNnU9e523NMPBNIXNrWW73c2+dvwzU9fShzlqO4qiImexpsHblUzZET9EY1bmhocJAsF8MoYYFtRdOrE33oCp2uD2NTmV9TUOh3Us6RwBq7fI+9rgr2e0ijHGEjwXXxS9WhS5fBQ7SoIIg5S7I4ZH7kTNWKg== 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=x16dbQvhKlK9vJPRQuux7TB/H2PpN+xXIiBJpnfYu/E=; b=XKJl3H2abM3utnRcoYr8hRx+ToqrE+cDelH+Aj5erButkP3VGnMcJ634XKRFH4OGo119mauTx4Xf6Kbaj5H8ABXt7E2HNH9Gxv9t5MUwvPuewqkL9k9/36EhX8bTBa3z9p1oBWkwT/qxssQu/rqxr3ocjM+6sust1LVnNitfT5ngYuVtjG2Iz/TekFx70g8R/R4FQjMuM4FZ3xcOjSM9LqwT+UYQyO+UDRt4N8+SWWZQlmrzBSosb/dgMIUQAnnWTixMsAeDFU29Ncaz/T8t/UDESN6VAgjstzhw22H9UJvamEc/VXDJYI6Zxem/4C7HAx2Az6GRUbgxy/JIujHLBA== Received: from DS7PR07CA0022.namprd07.prod.outlook.com (2603:10b6:5:3af::24) by PH7PR12MB7163.namprd12.prod.outlook.com (2603:10b6:510:202::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 02:21:29 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::25) by DS7PR07CA0022.outlook.office365.com (2603:10b6:5:3af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 02:21: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 DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 02:21: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; Tue, 13 Dec 2022 18:21:28 -0800 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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, 13 Dec 2022 18:21:25 -0800 From: Alexander Kozyrev To: CC: , , , Subject: [RFC] ethdev: add template table insertion and matching types Date: Wed, 14 Dec 2022 04:21:10 +0200 Message-ID: <20221214022110.393410-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.126.231.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: DM6NAM11FT057:EE_|PH7PR12MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: a93a0886-4d80-4453-f07e-08dadd79e897 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: TV45rqk+Aak4YxIfFSb1MKWingN5W2vvXHDrd6Q/MzBN70wQRjFOvUg0JCTUFWbKH53UTrjtXNN/5RpglGZkBfjSF7spkw3+gI8gaWH/I4T+RHUOYlukNAkArZkX05Dt6lGr58CIz85gm5lor18WX89NutgwbnFEIO0p1iubT3s57TokRNp1Ug3+RBNNLRyYuPc9z1u/CNyFPdTTPeN/9n7eQQ9D6UGnTaX7SzHKrL5atDVsHtCad5U3tE5qTSH3A11ExYagGeEnx7zDN0k1O1RBtGCwGSE6/ce5si6moy74QqzkpXxp1qfn5bW06yhmFWOCOMkyYm+Ojk2KZfjnY8RygnJJTRQwdDrwcSNkwii1pKe6XX2xql0RUvm9TpdHCm0qd/e5vdAi0JSqJbKdGH46LDs2XnlC2QdLDeUa4GQeGUZ4qutW5iwWNLpxwzeKf35IdCXmqlGKUzJ6PCei2kFKUce+PmjP6WTmlZRS0Md3+2BgPiq2EVG5rk0tZaZuriF+1JFeYAiGiIDuHp+CPyCWnxQwmmcrNnYDCjhzmROiiytPmk4FALhmPCP0SGprH72qG9wRZsbSpaBtLNOSPbF1IpmOUej58MXn+lK10WV3PrEelszCXbLzS4mRc3dQYXM313X6L7IQejSXAbQYzghtTBXVMhm2Zff6V01lB6bm+yHybzaspWiZyhctmkM1ZlJb25o/Iyi96EIzjKihsg== 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)(376002)(346002)(396003)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(2906002)(8936002)(41300700001)(186003)(2616005)(82310400005)(70206006)(86362001)(70586007)(8676002)(40460700003)(36756003)(5660300002)(4326008)(6916009)(54906003)(316002)(356005)(478600001)(107886003)(40480700001)(7636003)(1076003)(47076005)(6666004)(336012)(82740400003)(16526019)(83380400001)(26005)(36860700001)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 02:21:28.7993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a93a0886-4d80-4453-f07e-08dadd79e897 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: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7163 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 Bring more flexibility and control over both flow rule insertion and packet matching mechanisms. Introduce 2 new flow table types: 1. Allow a user to specify the 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. The insertion to an already existing index is undefined and depends on PMD implementation. An old rule must be destroyed first. The index cannot be bigger than the size of the table. 2. Allow a user to specify the 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 Acked-by: Ori Kam --- doc/guides/prog_guide/rte_flow.rst | 20 +++++++ lib/ethdev/rte_flow.c | 24 ++++++++ lib/ethdev/rte_flow.h | 96 ++++++++++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 11 ++++ lib/ethdev/version.map | 3 + 5 files changed, 154 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/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..858992893c 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. */ }; /** @@ -5187,6 +5188,48 @@ 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. + * + * 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. @@ -5202,6 +5245,14 @@ 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; + /** + * Hash calculation function for the packet matching. + */ + enum rte_flow_table_hash_func hash_func; }; /** @@ -5336,6 +5387,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 {