From patchwork Thu Aug 3 13:10:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ori Kam X-Patchwork-Id: 129904 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 D908D42FC6; Thu, 3 Aug 2023 15:11:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C5D740C35; Thu, 3 Aug 2023 15:11:03 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2043.outbound.protection.outlook.com [40.107.237.43]) by mails.dpdk.org (Postfix) with ESMTP id 41630406BA for ; Thu, 3 Aug 2023 15:11:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwtQxZkLWNA+jBFV1zoLpcIRrAEXIyj6ZcqVZB2AxX0Bmz8aBKcxfciYWpLO6iA7Z55Ah1wxNOH988wO27Yp2YrSIBTfkxVqu8M6RWWqP0Yu0Q5gwA0WOT4yueUginA7gtPFT5LIldzNlwkry3fsLLN+yRKJZt1sLMQ5y9IDX8DCe9SWkobYx2u/oHhsDYG1MOkdYO+Gg1WfYQ3f48NTptki5wbPYfXzTxbeupcvAf5A4WMqltLlSqQA7rvbyx0rW7fVANpnBWjGBtc8WhXMQi4BdoHYpKgxkXO5QSdNlvVNoTHV5C8aw9BTzwPaVIKM2Y1pJUcvMYY+T1GhJc6VDg== 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=zBoB85gxgfCcDaHXlz9MTvqdtBoZbhq4HKA9aGgUpRU=; b=ZKPQ9CLkJPyfl3vFrNdI2UQCUh+ibljyUClfMPLYjKefwAQNealTn/NNuFWkQTWuq2j/bp085yM6l/6bqcDTIXQJX7k7fVQKU1lcSwcKEyVykTRNid8mM0JuMT5W/mtawrJU0o1K+3bB2Oy0nv2fTfoq0Jvk0v76O2MhL7tlehTYC+xMFdWkVBuQAIsoR664zlJBqJ6gQ6TE7oPOCq9SFZpdFB7e8tMAvC2Hgt2remPcFqgCf5bfS8a/X0IKqHcegNh7Z7RssOlHanbSFQbSmz8+S58r7tuU0WM4i4INQTNkECb2dA+nYDJHaOalvck+oY2m9yCmS06qNC9+/IZwrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net 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=zBoB85gxgfCcDaHXlz9MTvqdtBoZbhq4HKA9aGgUpRU=; b=FAn1aVpSRk5wh2M/vU+VhRurtRUdgMtw6zoRL4qpqoRD7NSpJP2ph0LLhB8Cdy6lxIjzmFz8xp3t4n2/gTKIZnzpSceNylne6PUbt3nCa9Plg9vnQsZzZlteip88L/yLzdRRXrfYbDl0g0ivv6ZQRxKK4bWSj4U+QJW207C4ttPtuEFjF7yDYmacbmKiCFomm//EjiPW8uY6EN2O5whBsJdl0I+vpz9RNub/jOA1yiwuBin0zZAVZ/u0I348o0ORDRhBJ0vwKykCXXKUsnsqZWpb+M+obmzz5hxUtCNbDCKEmsZVQcGw5OFmDyKfM045oDFIPsSEVSRi97LG4pYQ9g== Received: from SN7PR04CA0218.namprd04.prod.outlook.com (2603:10b6:806:127::13) by MW4PR12MB5643.namprd12.prod.outlook.com (2603:10b6:303:188::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 13:10:59 +0000 Received: from SN1PEPF0002529F.namprd05.prod.outlook.com (2603:10b6:806:127:cafe::d0) by SN7PR04CA0218.outlook.office365.com (2603:10b6:806:127::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.19 via Frontend Transport; Thu, 3 Aug 2023 13:10:58 +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 SN1PEPF0002529F.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.6652.19 via Frontend Transport; Thu, 3 Aug 2023 13:10:58 +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.5; Thu, 3 Aug 2023 06:10:47 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 3 Aug 2023 06:10:44 -0700 From: Ori Kam To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [RFC] ethdev: add calcualte hash function Date: Thu, 3 Aug 2023 16:10:14 +0300 Message-ID: <20230803131014.3436-1-orika@nvidia.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002529F:EE_|MW4PR12MB5643:EE_ X-MS-Office365-Filtering-Correlation-Id: e6e2f413-14e9-40da-4faa-08db9423140d 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: HNZ4o0pnEhDwLRdn4uZlHbuESebR/Gi3qdshINwYgWD0b521rbnZYFUhL5GGMi/Frymrp+DW9SbD6Ehi51jC2HzICfbkO5CEXx+hopZSAO6NKEnbhUXwpgI4kt+kSjYy6Tgi1UaXn9DW6XAuzT6Bsmw6kbCdG0M0l0cfWgFIFI5PViUArLbUymUfu6XhnuNKZzpRjOtxnoxQJEm7L7lkS3MRekrsXXie6woM2dkxVyK26IqSPhEGxgyjjoJlCjJ4YaopBP9NytwbP/55CJUvedGDFyMcyvEk2qoYTKKyT+20NZ0aFrNmJDBo1bCnqnOKblSuhE7+R+SPQ2aALnUjF2bzh3k+VtWCMb7Rjj00g0U+BNpUThEI/FHBcky8SK4EZbD4/LZXqzSerJ9alyFHFZJXL9Ej1BsEsybTwWy8R+RAi2eYqg5VXsI2QvOu6fNpiSkCfl8cys3ydhCmo61SikldYoDMP4pjgOfD97cwA72EP2GtKV6ksinX9quXnXuHmNaaSS3PgLjQVEhUWuyrfVXd+TibLMA0ycd3BsrGClianKppqo3zSxSMK7vP/T28QaZh/92t97LF/fSFw0NX0axN+HEIu3YBCSLYpm/Akxus9WX/50+vKKqqXZmp8tbqTlGSMC7jYP+R5xRU1GAvE+F9jdcCA5neeQHiPyLM6tUsKZTsgiVoOoMuqlCWxx3IQmbwRmDWEc7TcG7S5YzgaWCbUn25kapwQmuE2eJ/Sd0HdnErog92DU6t9+XKJ7zK234b4oKFLmOP8w6B9A0SLQ== 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:(13230028)(4636009)(376002)(396003)(136003)(39860400002)(346002)(82310400008)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(6286002)(16526019)(426003)(2616005)(1076003)(336012)(107886003)(83380400001)(26005)(186003)(47076005)(41300700001)(36860700001)(70586007)(2906002)(70206006)(4326008)(5660300002)(316002)(8676002)(8936002)(6666004)(7696005)(966005)(478600001)(54906003)(110136005)(40480700001)(55016003)(356005)(7636003)(82740400003)(36756003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2023 13:10:58.2990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6e2f413-14e9-40da-4faa-08db9423140d 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: SN1PEPF0002529F.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5643 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 rte_flow supports insert by index table[1]. Using the above table, the application can create rules that are based on hash. For example application can create the following logic in order to create load balancing: 1. Create insert by index table with 2 rules, that hashes based on dmac 2. Insert to index 0 a rule that sends the traffic to port A. 3. Insert to index 1 a rule that sends the traffic to port B. Let's also assume that before this table, there is a 5 tuple match table that jumps to the above table. So each packet that matches one of the 5 tuple rules is RSSed to port A or B, based on dmac hash. The issue arises when there is a miss on the 5 tuple table, which resulted due to the packet being the first packet of this flow, or fragmented packet or any other reason. In this case, the application must calculate what would be the hash calculated by the HW so it can send the packet to the correct port. This new API allows applications to calculate the hash value of a given packet for a given table. [1] - http://patches.dpdk.org/project/dpdk/patch/20230208030624.78465-2-akozyrev@nvidia.com/ Signed-off-by: Ori Kam --- lib/ethdev/rte_flow.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 86ed98c562..85a9964437 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -6636,6 +6636,38 @@ rte_flow_async_action_list_handle_query_update(uint16_t port_id, uint32_t queue_ void *user_data, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Calculate the hash for a given pattern in a given table as + * calculated by the HW. + * + * @param port_id + * Port identifier of Ethernet device. + * @param table + * The table the SW wishes to simulate. + * @param pattern_template_index + * The pattern index in the table to be used for the calculation. + * @param pattern + * The values to be used in the hash calculation. + * @param hash + * Used to return the calculated hash. + * @param error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + */ +__rte_experimental +int +rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table *table, + uint8_t pattern_template_index, const struct rte_flow_item pattern[], + uint32_t *hash, struct rte_flow_error *error); + #ifdef __cplusplus } #endif