From patchwork Sun Dec 10 08:30:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ori Kam X-Patchwork-Id: 134994 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 3C5814342D; Sun, 10 Dec 2023 09:32:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EC27402D6; Sun, 10 Dec 2023 09:32:05 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2064.outbound.protection.outlook.com [40.107.223.64]) by mails.dpdk.org (Postfix) with ESMTP id C1B6040299 for ; Sun, 10 Dec 2023 09:32:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lbMuAZjP56iTwSVUOYj1zzcki14EzKW2aAJSSUXexq+gxREVBInVPtBkzAMt6pZyUJ20JRi97LrBMmwIGGlKr8QgdcsW0po6jD0ndnPJmuJ+VsvNjLuBmWZ6XQi10I9lK6AphkVs+qnUwvqWlgk2KqGMejc84Nfj6NFWCB3ubJsoekJlXqQ6BWiT/z+XpFlGZRfFh1vWem58SPd+EcyNisoLHK0VIdwGznvRiYOQ9Tfk8RQLsXyecoeAanwqLZKSrXKj7WW2c6s32m6X5/NpP6BiKtqkNumNaz4sWV1C7t5O8O0x24OEdTuEnwlDH3EEzTzY0Z1ONmFa3wCEXlyldQ== 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=DSH+q2FneD2a2jCrRDlV62HasxErQOYQaixFYDwLlDQ=; b=f26+tnmqt9xmwxCGr9tg5Y2cllWhSoU6SYhRLGPHxO4sGCLFgPAkzxu39mClVuRE6ZRcr9ng5tRHOPdAsycjucWZR4Hz7mc89rcWQ8yl+5O9IYWimqW7C2vben4rZ+aVkq9orKSweBpMiZfKSQZyAOAFyxxztUwKi5CZbH00bkelO72OzR0CwHOD4pKnRTgobsinFGf8XpbxTR1WqlTdEgMhbYIFJyLapVRg/L2M3YgzyQVNexPEqUcv9TrVk/E7MjqQBmqOFyMi+FDDcwjpP91TvFCzujHN/tYITKtFM1hQy1/q8hhc1O8DcfJg1QhrDWoVm+MooztLIpqZZmzhVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=amd.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DSH+q2FneD2a2jCrRDlV62HasxErQOYQaixFYDwLlDQ=; b=KrWfFh0oe8RRWaXncE4yroWne9/eIK4vbakXgSnmp/hVgcTgoUCDVGIeRd5TVT+C6QEJePJEEOdApepaBcRLoh7w57fBsxWUesxf1/pEjCbl96ALTC5OvZxnOjOn8nRyun4EvwyudzjhLHWiomrqaf+8ppUOY04PC3Ym+wqIqabZWO45Yolh19IuqoLITCki6Ehk3hh6QzMUo9QdS+1Wn0EJD3GLIYYY6KuqULwTbXKIVDWhBMTUtmdU3REC0sA61ESmhhdzX3iJwcgJRfo2UdFwoWJv4yPqAlsQ4EfLVpEIFkjzGehLjym/USmONXWY/NYSGWrqcILhbgpbY7ft2w== Received: from CY5PR22CA0019.namprd22.prod.outlook.com (2603:10b6:930:16::26) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Sun, 10 Dec 2023 08:32:01 +0000 Received: from CY4PEPF0000E9D2.namprd03.prod.outlook.com (2603:10b6:930:16:cafe::78) by CY5PR22CA0019.outlook.office365.com (2603:10b6:930:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32 via Frontend Transport; Sun, 10 Dec 2023 08:32:00 +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 CY4PEPF0000E9D2.mail.protection.outlook.com (10.167.241.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.18 via Frontend Transport; Sun, 10 Dec 2023 08:32:00 +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.41; Sun, 10 Dec 2023 00:31:51 -0800 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.41; Sun, 10 Dec 2023 00:31:48 -0800 From: Ori Kam To: , , , Thomas Monjalon , Andrew Rybchenko CC: , , Subject: [RFC] ethdev: introduce entropy calculation Date: Sun, 10 Dec 2023 10:30:59 +0200 Message-ID: <20231210083100.7893-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: CY4PEPF0000E9D2:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: 61ef4165-ff66-497d-9b12-08dbf95a7b0a 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: wwQVvENpuP+iIqVLNoi4d8GQAmMXrmpZYjfAfphy9Sep5BnVdbrrSTzHqMyS/plT4N56Pcl/yu+9ZrE1YfjBpgH7F5Q7cZvlLITIw3gTcF3GGYdBxIuDmTztle+YrEi4LpvtwH6SvNykYwJeefd12mxcmu2o+9ch6vQhXsr6IRRlcwIDKt7yrWQ9dilGIARR5hy+30AXXXypPsmF7lVH6tFzT0ypYFyjrWF/FyfpHyTP9vjspfG5iVUwbY9CHGCzEQX4odmKIZp49nlLkRFNadfkoHR1iZilP74x6sSigstOW5Tt8H8ywN/f8ZvYTmlnCQche64YBFvv8Y4KAzL0SWN5MTN1U6/soQM3MxHMULDNsScTMgb72pQ8bCtFui30+UqvoTdP88q2K8F10hgEcszgWLDPDS04rkd8t2jaCgJicee55yGGgIUfVAEQ/LU641bM0jw41sh8K0nQdyYEHoOvt/VwB6XSBMvCSL5VVfQMJyPO9oMnh2VA0TikRITsFYLFfhNYUB9LzrI/S19aSwh3CO0L/33DJOgi+cHvbwFgWpl1F4avpMTZ/gG34021DAes4WVYGyQZmNDs9iauyyFO9oU0v8u+NNSbjlh1K7FWedqPr/3MtiZdHwgzDKjgGAncrUM0b/lGRbT+dum2/36/yfZSWzsDKdc/7BktW/vE8tIxJeUQo5Kh/+25Om/a4XWNTsvFoFLtmbT+o9LK91qogEBFLhNu3n15an6f0YC6e8BAx+kVkjHqJdUoN2zh 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:(13230031)(4636009)(39860400002)(396003)(136003)(376002)(346002)(230273577357003)(230922051799003)(230173577357003)(451199024)(64100799003)(82310400011)(1800799012)(186009)(46966006)(36840700001)(36860700001)(5660300002)(6286002)(1076003)(47076005)(336012)(26005)(2616005)(16526019)(107886003)(36756003)(55016003)(7636003)(426003)(70586007)(70206006)(54906003)(40480700001)(2906002)(83380400001)(82740400003)(41300700001)(356005)(478600001)(7696005)(86362001)(8676002)(8936002)(4326008)(110136005)(316002)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2023 08:32:00.8628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61ef4165-ff66-497d-9b12-08dbf95a7b0a 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: CY4PEPF0000E9D2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 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 When offloading rules with the encap action, the HW may calculate entropy based on the encap protocol. Each HW can implement a different algorithm. When the application receives packets that should have been encaped by the HW, but didn't reach this stage yet (for example TCP SYN packets), then when encap is done in SW, application must apply the same entropy calculation algorithm. Using the new API application can request the PMD to calculate the value as if the packet passed in the HW. Signed-off-by: Ori Kam Acked-by: Dariusz Sosnowski --- lib/ethdev/rte_flow.h | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index affdc8121b..3989b089dd 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -6753,6 +6753,55 @@ rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Destination field type for the entropy calculation. + * + * @see function rte_flow_calc_encap_entropy + */ +enum rte_flow_entropy_dest { + /* Calculate entropy placed in UDP source port field. */ + RTE_FLOW_ENTROPY_DEST_UDP_SRC_PORT, + /* Calculate entropy placed in NVGRE flow ID field. */ + RTE_FLOW_ENTROPY_DEST_NVGRE_FLOW_ID, +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Calculate the entropy generated by the HW for a given pattern, + * when encapsulation flow action is executed. + * + * @param[in] port_id + * Port identifier of Ethernet device. + * @param[in] pattern + * The values to be used in the entropy calculation. + * @param[in] dest_field + * Type of destination field for entropy calculation. + * @param[out] entropy + * Used to return the calculated entropy. It will be written in network order, + * so entropy[0] is the MSB. + * The number of bytes is based on the destination field type. + * @param[out] 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. + * - (-EINVAL) if *pattern* doesn't hold enough information to calculate the entropy + * or the dest is not supported. + */ +__rte_experimental +int +rte_flow_calc_encap_entropy(uint16_t port_id, const struct rte_flow_item pattern[], + enum rte_flow_entropy_dest dest_field, uint8_t *entropy, + struct rte_flow_error *error); + #ifdef __cplusplus } #endif