From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ACD1543AE1; Thu, 8 Feb 2024 18:13:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 314FF40295; Thu, 8 Feb 2024 18:13:24 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2057.outbound.protection.outlook.com [40.107.223.57]) by mails.dpdk.org (Postfix) with ESMTP id 9966B40278 for ; Thu, 8 Feb 2024 18:13:22 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXUgay0k4ss5dWfbsvSVR+GM6xFeXgSyHYoq+ApbFdgFZOpuSO4lothU3WlqDKUCcLeObiBDxKgw7PtAZSHDrrAP+m5uSCZ0ACqiFKYS4cy6tZ8ALw7VCi3nDGb6Brz5js8iko/pysxQYuHPReXfl9/ib2L9cZdokQm46qEP/e6OVB/b6c+hFeKUkKU6SvEQGQK7kTESMt0BsXmU2LbjQaIAMsKMG86LKEbz3zGFBNN40vJWP6uG9+HzLGMlDyrnsJZATPTG4wffaTTJicaf8H0KWJM11e4vAeym51cpvm0DjF95xj1hRM1gwzH2RtjVP6B7cZxq9/rnOg5hooymqQ== 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=+iOpj1H2IoXnjtM6I8wFlzCnzk39LpLj8ia4lwnTs/4=; b=lmSS0g6Q75dgUL8hi7Z6sVVY88J3p8/iGv4dKtPGGiz6gZcGrnwRAP13kt7QMUGj2Zv4RI4SRHEPDxyRW1mUHbkKOGYESKHy9nuu2hauBm1skaZ+tNYv3dwWpMNXl/F61WQfgFpCEko7tv4/vSwfMxchS6jZJsQq6WgIq9AzIQWQTuD8PLVLR0rSxrAjc2pnTgwgw+8IFkMS2XnxLy2YPQNEWWA1TNCw6/tbEYkpCiDN9cLf7rQAvwrpMz3mSrKpKi83PhoJvk+s5C+qhUXVXXK4WwUX8zzmb17lAlz13SitdQuDVyex6lfScbPEvKna9K858FxzXgh6f6UYGh6SAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+iOpj1H2IoXnjtM6I8wFlzCnzk39LpLj8ia4lwnTs/4=; b=F3IRkC3OdVV2rHoMPOMWUnIyfZCMbeRVM1Bm2PDai8/Wtwy7SmHgzfHY0zAXnZgnjRb8z7LcBOeg1Rml4OMR0aRd8xHyT+UO5ivcTfBw6mh7yExyojuBGrKhXDeAAcxmyAEjdC78AIXH5IcLIy3jO7slOho5a1bYlRLogYRSkAY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by DS0PR12MB7947.namprd12.prod.outlook.com (2603:10b6:8:150::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Thu, 8 Feb 2024 17:13:20 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::815a:45e6:cf5e:479f]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::815a:45e6:cf5e:479f%4]) with mapi id 15.20.7292.009; Thu, 8 Feb 2024 17:13:19 +0000 Message-ID: <50189a77-2c1f-4b31-935d-506fa98d22af@amd.com> Date: Thu, 8 Feb 2024 17:13:15 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] ethdev: introduce encap hash calculation Content-Language: en-US To: Ori Kam , dsosnowski@nvidia.com, cristian.dumitrescu@intel.com, andrew.rybchenko@oktetlabs.ru, stephen@networkplumber.org, Thomas Monjalon Cc: dev@dpdk.org, rasland@nvidia.com References: <20240128093943.4461-1-orika@nvidia.com> <20240208090919.11565-1-orika@nvidia.com> From: Ferruh Yigit Autocrypt: addr=ferruh.yigit@amd.com; keydata= xsFNBGJDD3EBEAC/M7Tk/DfQSmP1K96vyzdhfSBzlCaGtcxNXorq4fALruqVsD3oi0yfyEz9 4YN8x7py0o9EL8ZdpOX0skc0AMCDAaw033uWhCn0GLMeGRKUbfOAPvL6ecSDvGD7CJIO9j0J eZUvasBgPdM/435PEr9DmC6Ggzdzt8IuG4PoLi5jpFSfcqxZFCCxLUDEo/w0nuguk2FTuYJg B2zEZ4JTBZrw7hIHiFh8D8hr6YA6a5uTofq1tr+l048lbtdFUl8TR0aIExVzE4Z8qKZlcE+9 RQaewjK5Al1jLE4sHdmd3GN+IvgDF3D/fLsi25SKJDeGSdeHkOmaX0qGeM4WKIfU6iARRCiQ N3AmBIxZ/A7UXBKLaOyZ+/i3sE6Wb53nrO4i8+0K2Qwyh6LjTeiJAIjYKN43ppxz3DaI+QwQ vI+uyHr4Gg0Da9EPPz/YyKauSeOZCfCB5gIfICO0j6x0SCl8uQ2nLpjxcZkf0gjcwUzP3h+S 3x6NfDji9YEij0zczW/dcSpGgZ6vsFpPrtnP9ZXy6J53yp0kJtOJoOlkEFFdU2yCZnCDseum CoudmGLZVvS0/DzHDJejq+3kK3FDGktZBOxZIIpal+nFqS7lVgOZc4+huVv3jyhzoAUOEyXA XK5j6o7g8STUY+z33QNnHpdLvecMwuzmvqy0jR54yAbZ64mB9QARAQABzSNGZXJydWggWWln aXQgPGZlcnJ1aC55aWdpdEBhbWQuY29tPsLBlwQTAQgAQQIbAwULCQgHAgYVCgkICw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jkzAhmmbxl+8rM/LKBH dZUMTzME5PFCXJIZ83qkZQ795MTe2YScp9dIV7fsS5tpDwIs7BZNVM1l3NAdK+DLHqNxKuyO 8Zk= In-Reply-To: <20240208090919.11565-1-orika@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0208.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a5::15) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|DS0PR12MB7947:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bfcd64a-bd11-4291-7c93-08dc28c93f4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aB6FrJUE1sCfwrWBx59FqONjb+cCaph4EfT9Q2FccVkGa3L+GKOGvqnCKozUUogVxCccwrrxorCkaVRiUAbRjgc/0PLAJg1NaBi7okpbbRGSbD1kyrEwMJQB92N/DImQyCviHezfpRrPsAwoYAhPtTiBWhQEhvekPaez1wW9DOqdEqb6acbiMlNgL+RGG7vrGNif6UiMCYQ6qzGV/EXqF+Gi1s5bYSgPMZ1RWJkTyASEEJLoyuCTy75SfIDy2k9mpDNwozsXx4ENTjO0axizPnDyux4B/v5dBHAn9yarlc5VdvF8M8wXJ8n9qBtV7I3Uf2K3HRNjSlT7LU+ORpOTVJhSYfee0VOlH6fVNVmznZdEfyGJVhlwk/bP1Fg9Xh+p2xR7jqF1pB6CSovVKX5SjqrGV7E2rTW6o/Qlf4g+8EZfhfGg8Y3egSnMJzCAm4o6mgFU9gFNNqW8R4+nERnXMq+7Cv1FtWsHyLiNipi1ns92lIrWF7OZniWS6ifUdQYyD5MNZKK5/r86Yq9hr+k3vIRCEEryUioLKVqIy1bI+i4ch/gjl39v+VyBBLpWwBw5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(39860400002)(366004)(346002)(376002)(136003)(230273577357003)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(6506007)(53546011)(6666004)(316002)(38100700002)(83380400001)(31696002)(31686004)(8676002)(86362001)(26005)(6512007)(2616005)(41300700001)(4326008)(8936002)(36756003)(478600001)(5660300002)(2906002)(6486002)(66556008)(66476007)(66946007)(44832011)(110136005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aC9Gc1VRcmNFK3NRaTc2d21Rb2syMmVXQW00UVJTT28xUmRZSVQ4SUxIaThP?= =?utf-8?B?S1cyQkhOZHkwemQ2ZjMrOWsvZUMxdGNPN2prbHlaYy90TEdGQWVLOFF2V0I0?= =?utf-8?B?cFc4VWVuMkxyeUQ5RWhOZ3dJUTltTTFhbmEzbnh6bnNvem5rRzJUNEdQZmtN?= =?utf-8?B?eDdIcXA3REJua05xbWEzc1lsUzAxQnN2Vk0wcVNpQ0tacm5Nek9ob3Z4RlZj?= =?utf-8?B?SzBxWlgzME9vbVl5SFJUSUJnRUNVdHlCM1Qyc1lTR080VEMwN1NMaGJkeHhi?= =?utf-8?B?d09JWnA2S3h1dC92YU9KMjFlVDJNRzBXNXRHKzVYU3dXRlA4QjROMUEwNlZz?= =?utf-8?B?UzlXKzVpd3k0ZkkzZWpYKzNiZ1dudUpTWGo5S3V2OS82MUt5Ui9zNkJDVzll?= =?utf-8?B?ZkJuMlZJeUh5cUhHNUxNdFRJVTlxMEMyY0hLbEpLdlNxVFdoSGo5NHdaWFlK?= =?utf-8?B?aHhaRXhNZVJLeFM5SWhNR1l6QUFxWGVLTmdjZ3Jxd2FuTlpRMk9qMHA5b2cr?= =?utf-8?B?aXJ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T3BKZERS?= =?utf-8?B?dkE2ZzZsWnVSb0ZndDlIL0FDMUJwR0ZDcjc0WVB3MDk2VC9EaTI2T09XZjBY?= =?utf-8?B?ZlpjRmM0SUIwRGNSRGJ5VmJLa1QxWFp2a1hxckthTjh3YXozREcyaWNFbEJn?= =?utf-8?B?dVZLYUJ0OWFReGZlZTRNcEdFb2Z1QUpzd3lXWDFIZFR5R1VIYWhTVmJvdkxI?= =?utf-8?B?RWFiSVpyblFNQkRqWWEzS0cwemNTWGZwMUtiNnZhZEE2OUZSQXRLdGJCMGg5?= =?utf-8?B?YzdTeXcvR0NrWGlXd2RNSkExV1RCVGY2K2RUUE5pQkVUb2hRUjJOOEx5QlFv?= =?utf-8?B?RlFTalloaG04QUJFcGVtcGVBdjhFYnBLZ1RmSlpnUzlrTmtqR3ZHQ3ZsUWh1?= =?utf-8?B?d3dObGVGemtYc2Jlc3Myb09qVlZJcWkxUlFsTmh4NkdEeGZqbC84OHFLQkJ0?= =?utf-8?B?M2hRUjJsWTUvampuMWJYU050MmE3R1hJaXVpMFoySFQwNVZ5MzVheU5La3Ru?= =?utf-8?B?RVFUWWJoWDFiU21TVS9NR3hrSDI4UlRBbHRjcU9sWDdkaU44L2VFOCtHTU9F?= =?utf-8?B?b0x5ZWhVN1JyTllkMXBjQWVDYXV2cE5oSk1qZndpb2VVbVBvZCs1RGd1OTh6?= =?utf-8?B?cjdTdkRrZUxHcld2ZmVJN1ZaWXp0ZS9xRzBuNUFXaWdrT0ZqeFVUVnA4QnVk?= =?utf-8?Q?ny14HUmNt/A0yakvcpPlvhUcr?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bfcd64a-bd11-4291-7c93-08dc28c93f4a X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2024 17:13:19.7672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ILhMhwhTwbCxduL4MVeZcnUY3Lot/FcFACSv1ocL65VK4R+XkjYuzcCs4c7lyakQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7947 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 On 2/8/2024 9:09 AM, Ori Kam wrote: > During encapsulation of a packet, it is possible to change some > outer headers to improve flow destribution. > For example, from VXLAN RFC: > "It is recommended that the UDP source port number > be calculated using a hash of fields from the inner packet -- > one example being a hash of the inner Ethernet frame's headers. > This is to enable a level of entropy for the ECMP/load-balancing" > > The tunnel protocol defines which outer field should hold this hash, > but it doesn't define the hash calculation algorithm. > > An application that uses flow offloads gets the first few packets > (exception path) and then decides to offload the flow. > As a result, there are two > different paths that a packet from a given flow may take. > SW for the first few packets or HW for the rest. > When the packet goes through the SW, the SW encapsulates the packet > and must use the same hash calculation as the HW will do for > the rest of the packets in this flow. > > the new function rte_flow_calc_encap_hash can query the hash value > fromm the driver for a given packet as if the packet was passed > through the HW. > > Signed-off-by: Ori Kam > Acked-by: Dariusz Sosnowski > <...> > +int > +rte_flow_calc_encap_hash(uint16_t port_id, const struct rte_flow_item pattern[], > + enum rte_flow_encap_hash_field dest_field, uint8_t hash_len, > + uint8_t *hash, struct rte_flow_error *error) > +{ > + int ret; > + struct rte_eth_dev *dev; > + const struct rte_flow_ops *ops; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + ops = rte_flow_ops_get(port_id, error); > + if (!ops || !ops->flow_calc_encap_hash) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, > + "calc encap hash is not supported"); > + if ((dest_field == RTE_FLOW_ENCAP_HASH_FIELD_SRC_PORT && hash_len != 2) || > + (dest_field == RTE_FLOW_ENCAP_HASH_FIELD_NVGRE_FLOW_ID && hash_len != 1)) > If there is a fixed mapping with the dest_field and the size, instead of putting this information into check code, what do you think to put it into the data structure? I mean instead of using enum for dest_filed, it can be a struct that is holding enum and its expected size, this clarifies what the expected size for that field. > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, > + "hash len doesn't match the requested field len"); > + dev = &rte_eth_devices[port_id]; > + ret = ops->flow_calc_encap_hash(dev, pattern, dest_field, hash, error); > 'hash_len' is get by API, but it is not passed to dev_ops, does this mean this information hardcoded in the driver as well, if so why duplicate this information in driver instead off passing hash_len to driver? > + return flow_err(port_id, ret, error); > +} > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h > index 1267c146e5..2bdf3a4a17 100644 > --- a/lib/ethdev/rte_flow.h > +++ b/lib/ethdev/rte_flow.h > @@ -6783,6 +6783,57 @@ 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 hash calculation, when encap action is used. > + * > + * @see function rte_flow_calc_encap_hash > + */ > +enum rte_flow_encap_hash_field { > + /* Calculate hash placed in UDP source port field. */ > + RTE_FLOW_ENCAP_HASH_FIELD_SRC_PORT, > + /* Calculate hash placed in NVGRE flow ID field. */ > + RTE_FLOW_ENCAP_HASH_FIELD_NVGRE_FLOW_ID, > +}; > Indeed above enum represents a field in a network protocol, right? Instead of having a 'RTE_FLOW_ENCAP_HASH_' specific one, can re-using 'enum rte_flow_field_id' work?