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 5ACB4A0C4B; Thu, 14 Oct 2021 18:12:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E646140E01; Thu, 14 Oct 2021 18:12:25 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 5D2774003C for ; Thu, 14 Oct 2021 18:12:24 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="288581027" X-IronPort-AV: E=Sophos;i="5.85,372,1624345200"; d="scan'208";a="288581027" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2021 09:09:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,372,1624345200"; d="scan'208";a="481318853" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga007.jf.intel.com with ESMTP; 14 Oct 2021 09:09:37 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 14 Oct 2021 09:09:37 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 14 Oct 2021 09:09:36 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Thu, 14 Oct 2021 09:09:36 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.105) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 14 Oct 2021 09:09:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H73c3MfoSJmR87OCARMoLSBGi3al7dcHp7lJ0k1x9gJgiHfE2ol4Nytdo041Y17m6Z8mk88Zd8Fmv8dUzBQydich98dojMaaPjGEgzg2mW6kaLXDyAYGI8emAC5VCBlwijxipeGu2DR2Pnfs0kZCLJXNkNTSc8GUPKhSyfLqbqc60JnvHeaMZSKd4IC+Rx/ntzeJH4GtDVFBuZ6xz7/6h+WADTKCZkChDgUtJ9jiRai1am10V9jg+N4QUejaUu8VuVfDtQE8rccFgO97ZNdlbEyHH9L7LMSpOBlezfleHLqw1kOOTF6AJbxqvrwteFU7f6dZwxc2576VEe8quTvmqg== 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=KIqHffoTOAx0iHD3yFd6RrJONQuxKUSuzkQaObH/RzY=; b=fVFV6OornG7pOTv/uRu9cWpTjxVy5KHgfpXRxzAtYvr67QZC9LPy/AoAnGQXOVEpSj1+K4vDTqTbLwJI5lZNSuyQOs10Mkx4SraXDyNUZHmZeE4/P6nZ6CAG3vLLezrKYbPNggS1Wf9XDnYP5cFJ3fkOGJVuDalB9ZpvLsdVhwbwHSzSHM1AIIc74H0KP//Wu1rA8RFRDGqVa8vv1mYjDjXaesMz/6BA0rNQpF3hzb+gh6eWBBHl6CAS7Dihbafk9cP+QvqOaRxVB4gKd2kohIxY6h5xSx9x0zyICgJSKYVDQGIWUgCFEfT9BENHhZDwtkwMUesVKak9IAGNjwQEXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KIqHffoTOAx0iHD3yFd6RrJONQuxKUSuzkQaObH/RzY=; b=Q6nh9sEhK1w/0Pyu+DGN2A9ds8f4aJaRUFFzhgHodmVxynOml8wgU5wzBp46pocZiSJrf6tVzei5Q3J4phxOg7krZOu7ilJPQG1+Q6TmhafLqNaS5up53MXBb/ixd0wgj/hbj5MtpdIn52Cjeo5MJPUHD1Mvsr4bcKpmJ6+r2AA= Authentication-Results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB4807.namprd11.prod.outlook.com (2603:10b6:510:3a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25; Thu, 14 Oct 2021 16:09:33 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c%5]) with mapi id 15.20.4608.017; Thu, 14 Oct 2021 16:09:33 +0000 Message-ID: <44a1a93e-5581-8dc5-dba5-0ba2087dfb07@intel.com> Date: Thu, 14 Oct 2021 17:09:26 +0100 Content-Language: en-US To: Viacheslav Ovsiienko , CC: , , , , , , Qi Zhang References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211012125433.31647-1-viacheslavo@nvidia.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: <20211012125433.31647-1-viacheslavo@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB6PR0402CA0001.eurprd04.prod.outlook.com (2603:10a6:4:91::11) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by DB6PR0402CA0001.eurprd04.prod.outlook.com (2603:10a6:4:91::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Thu, 14 Oct 2021 16:09:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75e3fa77-cae3-4d58-3514-08d98f2d0281 X-MS-TrafficTypeDiagnostic: PH0PR11MB4807: X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tJbhTSFPe5R38HGRNIPuY8gbjltwtoj8l8uln6Ms2SkMqhcgj2UWkbx4wsOJoiiql/CisXCyZR1/PeWZKM6VaBlDs+zZ1GOacCcW581/XcY5EmJ1/ObF2jo4VK46olcwZu3hSAMAWkU9hMSd453/SSUxKG6ahk9l9HAVIuFIoah5EzMfqyz68KurEjt4LN0fD6kFGYdsLnxN+ThbENyuo0sQluYdRgzPgxY3hKoB0uf88PZ7HiLkmY4h0YkfZdyX5GBUgPPSfm825GNDXmuOBDWhQM5jvVYODEXyi+WZHsDSGqgOcRMDXZud8Xfzo4PFE6nSHZfLqEoTL0aJOIm1GZu8JCV7I3GMDYnoav1EHRf/PCy1rZE4k0Mc1zinu4DoISaXavvbcq0DYnDGYgjulbx/pZgWItbAGb1oxfyNwKCyoK6MkDOBQVUdc9MzkFuHFxdGbu7o0hlS2J6wbZ6uaMWaJ37R2o/iNnH2v0w8gcJgFY82W7YdJb7G9LjqyzCFeku88I0gvEVq8+g0Grh3+Y5vL45TGJzYsAY/FRfdL5dRUuQ3DKywRcUl0yrY/KrDmP7OiTmEKQilvMSZSffVHX5CeaPFdRF3yq6i3cphn25tb8aocE8NbQYHeYM/Wee2p6sfxOWD02dTv2IMqTkJGAoZC32QIK0rJR4dDJHfxHFlf9NIimt9DHMb10XiSVyoXIUYht54LWb3yaueG+u87l/HhyyVN3hX1iRFi8aTpn3zPFaBqToy4IiJ2SOZm9Eb5xNyAbofhSBYfZR9qijpXGhkfN1oomdrMvrMzRVvtDnSjbbmWyFGDj4rDVTUHRBPuR0h5TNfwcyuwdjA7iEwdQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(316002)(2906002)(4326008)(8676002)(36756003)(6486002)(16576012)(186003)(956004)(86362001)(38100700002)(31696002)(5660300002)(44832011)(26005)(2616005)(966005)(66556008)(107886003)(30864003)(508600001)(66476007)(83380400001)(53546011)(31686004)(82960400001)(8936002)(66946007)(6666004)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d2x5QW9CVGdBcldZWWs3TjZDTTFmQmE5YkNWRU5FQ0o2cTJHMi9EUCtGZVV2?= =?utf-8?B?MG1UbXJURll6L0xvdGdITWh6NGlRTG4yZE5Yc29SZzZGTVh3LzRldkFvTUpo?= =?utf-8?B?NnU4aDY3Y283Rnh2SDhmbkpiYmUxMTR4a2RjT3c2MmlZbmZ0WG5Za2xSV3ky?= =?utf-8?B?TE54SjI2RnhDd2FxVm1iYmozaE5JeVlvZWowOHdBekJZcFJFenhkVGpFT3lP?= =?utf-8?B?Z2lJbU5kc0NxbjJOQXJNcXdkbGo0aGxuWnYrRFN1cUZxSkZSdWtsbjByTzlj?= =?utf-8?B?Slh0WjVER3E5TlZxWDIxanJBamg2QjVldDNhQmtuaXBOTy9kY0haV1cxQlVt?= =?utf-8?B?TFYxeGlBTkh6TUdQeFRFRldDRjRiTjdKOXR3NGhhNVhmWHlSV21OU0dMSis4?= =?utf-8?B?TlZaTTdESGxFK3BpNWdmNkpVM1I4N1NQRkJFLzM5cnE2NnFpaDdPWnZtaHVB?= =?utf-8?B?cC8xK2x5YVYxbHdOYkIyUUlDVjFjcE8wMFE1Z0k1cUtDdUhLcTVQSU9hSnVz?= =?utf-8?B?WEcyTEhpaDI0WHU0L2JFeXMyYVdJYmM4clFPcVdaS0dUVXJXMUp1QmoycWVO?= =?utf-8?B?WEdwa0IvYW1SS25OSjEySEZ5OGorL2lqcEwvMkJCLzNUWEhTdldsSjBwamU3?= =?utf-8?B?WHBrcFE5WlB0bTFiVjIrYWd6dVVZK2wvdVVrbTBKcUk0eWNKUmtsSjFodG5l?= =?utf-8?B?Q21ZcEloaEZsUVU3SkgzYXlHckw4VGhZRVZMbjBXb21GdXI5UCs3YWtiSG1U?= =?utf-8?B?WTNjOEJmMWpROGpaL1ZyRHRDYVdTNnViWTJEbEtRMlNRbE8reitLZWM1Qm1U?= =?utf-8?B?WHlzOW8vVHJxa2ZFcDltcWxCT3F2YzVsdmh1Z05iRWdpeG1vd2xlOXpiL0Ir?= =?utf-8?B?d1ZuWUcvdHhrT0pRbjBJeDg2ZXJ4Zmo0N1Z2NWJQeU9QY2tISmJGY0t1RWM5?= =?utf-8?B?QitmR0RGYXlPWGlQQXU0cGxac2Z0eVRyWFVGS3RQRmpyay9lM2NrRjhNUWho?= =?utf-8?B?SktBQUYrUTB4ZUtWOHlicHp5aVVHcHhYYmFsalhOTks0dCtsSUlGMi9URG5v?= =?utf-8?B?Skh2bDdRV3pKeEZxUkthY1NlbUhlVmZHaDFBWkEwTTBMUmcxOXU5dDJKQUkz?= =?utf-8?B?dFFBU3hFZlpaNVRCUEdsK29BUnp5VXJ1TCtITXE4TS93RjBDYkMzdFdkSnpG?= =?utf-8?B?WDRBcHhlNUt3cHhVVEMweDB5S1BRaWJFM1BvZDg3cDdsT2piSjF1TngrYitH?= =?utf-8?B?eldrTjVKY3RjVXJGSWRQaFZzNitlR0p1MCtwZXFFaEJSODhJQnh2bWV1ai80?= =?utf-8?B?RVF6VjV2d2hKWUpVSWFMZUVJUFVScEF1dGs2SGJnWWR5ek1TVjZHaGQrQVVw?= =?utf-8?B?Qkw1YlRUd2RnRkMwQU9lQmRQU0pHcUdNYXFoUU14N0QxSkhwdkNnVyt4OTgw?= =?utf-8?B?cmVWTDhhRHhpRFBMV2xrK1R4ZmJxcW1BbjBPZUhHQ1ROWWNHQXNheTZiRWpW?= =?utf-8?B?Vm9QR1pUUjkxMmhCWi83RzlSRXRXOCtPaWJDM0YyZ1V3NHhTREZaYURSM1Bk?= =?utf-8?B?cFg5UnpPTmx1T0NnMnJtZjZCOFhaMklOdEFmbC9VN0JRQmlUeVRCZXRScjgx?= =?utf-8?B?VXkyVXhJaWRrUytEeDcvY3h3VnNKSlQ0V0Y5N2pDR3pKQkRWLzJNOU9TczNy?= =?utf-8?B?TFJLeFlvNWZJaWd6a3VFZ3NmOGEvT3piNk84R1JPaE1RUGQ5OEd5dHBxLzUy?= =?utf-8?Q?js4IpryX3z3ddoKRcfJHnLHw+FPBLFIaROVGo/4?= X-MS-Exchange-CrossTenant-Network-Message-Id: 75e3fa77-cae3-4d58-3514-08d98f2d0281 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 16:09:33.2806 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p5rfMZACjmEkOc6OqU/BA3YkQ+Ki2vqI5Y7Cx7iQmOwPP7lWDofQTJpQlPLPPeBb6N/kr+NAjF7VD3aNDKZTCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4807 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v5 0/5] ethdev: introduce configurable flexible item 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 Sender: "dev" On 10/12/2021 1:54 PM, Viacheslav Ovsiienko wrote: > 1. Introduction and Retrospective > > Nowadays the networks are evolving fast and wide, the network > structures are getting more and more complicated, the new > application areas are emerging. To address these challenges > the new network protocols are continuously being developed, > considered by technical communities, adopted by industry and, > eventually implemented in hardware and software. The DPDK > framework follows the common trends and if we bother > to glance at the RTE Flow API header we see the multiple > new items were introduced during the last years since > the initial release. > > The new protocol adoption and implementation process is > not straightforward and takes time, the new protocol passes > development, consideration, adoption, and implementation > phases. The industry tries to mitigate and address the > forthcoming network protocols, for example, many hardware > vendors are implementing flexible and configurable network > protocol parsers. As DPDK developers, could we anticipate > the near future in the same fashion and introduce the similar > flexibility in RTE Flow API? > > Let's check what we already have merged in our project, and > we see the nice raw item (rte_flow_item_raw). At the first > glance, it looks superior and we can try to implement a flow > matching on the header of some relatively new tunnel protocol, > say on the GENEVE header with variable length options. And, > under further consideration, we run into the raw item > limitations: > > - only fixed size network header can be represented > - the entire network header pattern of fixed format > (header field offsets are fixed) must be provided > - the search for patterns is not robust (the wrong matches > might be triggered), and actually is not supported > by existing PMDs > - no explicitly specified relations with preceding > and following items > - no tunnel hint support > > As the result, implementing the support for tunnel protocols > like aforementioned GENEVE with variable extra protocol option > with flow raw item becomes very complicated and would require > multiple flows and multiple raw items chained in the same > flow (by the way, there is no support found for chained raw > items in implemented drivers). > > This RFC introduces the dedicated flex item (rte_flow_item_flex) > to handle matches with existing and new network protocol headers > in a unified fashion. > > 2. Flex Item Life Cycle > > Let's assume there are the requirements to support the new > network protocol with RTE Flows. What is given within protocol > specification: > > - header format > - header length, (can be variable, depending on options) > - potential presence of extra options following or included > in the header the header > - the relations with preceding protocols. For example, > the GENEVE follows UDP, eCPRI can follow either UDP > or L2 header > - the relations with following protocols. For example, > the next layer after tunnel header can be L2 or L3 > - whether the new protocol is a tunnel and the header > is a splitting point between outer and inner layers > > The supposed way to operate with flex item: > > - application defines the header structures according to > protocol specification > > - application calls rte_flow_flex_item_create() with desired > configuration according to the protocol specification, it > creates the flex item object over specified ethernet device > and prepares PMD and underlying hardware to handle flex > item. On item creation call PMD backing the specified > ethernet device returns the opaque handle identifying > the object has been created > > - application uses the rte_flow_item_flex with obtained handle > in the flows, the values/masks to match with fields in the > header are specified in the flex item per flow as for regular > items (except that pattern buffer combines all fields) > > - flows with flex items match with packets in a regular fashion, > the values and masks for the new protocol header match are > taken from the flex items in the flows > > - application destroys flows with flex items > > - application calls rte_flow_flex_item_release() as part of > ethernet device API and destroys the flex item object in > PMD and releases the engaged hardware resources > > 3. Flex Item Structure > > The flex item structure is intended to be used as part of the flow > pattern like regular RTE flow items and provides the mask and > value to match with fields of the protocol item was configured > for. > > struct rte_flow_item_flex { > void *handle; > uint32_t length; > const uint8_t* pattern; > }; > > The handle is some opaque object maintained on per device basis > by underlying driver. > > The protocol header fields are considered as bit fields, all > offsets and widths are expressed in bits. The pattern is the > buffer containing the bit concatenation of all the fields > presented at item configuration time, in the same order and > same amount. If byte boundary alignment is needed an application > can use a dummy type field, this is just some kind of gap filler. > > The length field specifies the pattern buffer length in bytes > and is needed to allow rte_flow_copy() operations. The approach > of multiple pattern pointers and lengths (per field) was > considered and found clumsy - it seems to be much suitable for > the application to maintain the single structure within the > single pattern buffer. > > 4. Flex Item Configuration > > The flex item configuration consists of the following parts: > > - header field descriptors: > - next header > - next protocol > - sample to match > - input link descriptors > - output link descriptors > > The field descriptors tell the driver and hardware what data should > be extracted from the packet and then control the packet handling > in the flow engine. Besides this, sample fields can be presented > to match with patterns in the flows. Each field is a bit pattern. > It has width, offset from the header beginning, mode of offset > calculation, and offset related parameters. > > The next header field is special, no data are actually taken > from the packet, but its offset is used as a pointer to the next > header in the packet, in other words the next header offset > specifies the size of the header being parsed by flex item. > > There is one more special field - next protocol, it specifies > where the next protocol identifier is contained and packet data > sampled from this field will be used to determine the next > protocol header type to continue packet parsing. The next > protocol field is like eth_type field in MAC2, or proto field > in IPv4/v6 headers. > > The sample fields are used to represent the data be sampled > from the packet and then matched with established flows. > > There are several methods supposed to calculate field offset > in runtime depending on configuration and packet content: > > - FIELD_MODE_FIXED - fixed offset. The bit offset from > header beginning is permanent and defined by field_base > configuration parameter. > > - FIELD_MODE_OFFSET - the field bit offset is extracted > from other header field (indirect offset field). The > resulting field offset to match is calculated from as: > > field_base + (*offset_base & offset_mask) << offset_shift > > This mode is useful to sample some extra options following > the main header with field containing main header length. > Also, this mode can be used to calculate offset to the > next protocol header, for example - IPv4 header contains > the 4-bit field with IPv4 header length expressed in dwords. > One more example - this mode would allow us to skip GENEVE > header variable length options. > > - FIELD_MODE_BITMASK - the field bit offset is extracted > from other header field (indirect offset field), the latter > is considered as bitmask containing some number of one bits, > the resulting field offset to match is calculated as: > > field_base + bitcount(*offset_base & offset_mask) << offset_shift > > This mode would be useful to skip the GTP header and its > extra options with specified flags. > > - FIELD_MODE_DUMMY - dummy field, optionally used for byte > boundary alignment in pattern. Pattern mask and data are > ignored in the match. All configuration parameters besides > field size and offset are ignored. > > Note: "*" - means the indirect field offset is calculated > and actual data are extracted from the packet by this > offset (like data are fetched by pointer *p from memory). > > The offset mode list can be extended by vendors according to > hardware supported options. > > The input link configuration section tells the driver after > what protocols and at what conditions the flex item can follow. > Input link specified the preceding header pattern, for example > for GENEVE it can be UDP item specifying match on destination > port with value 6081. The flex item can follow multiple header > types and multiple input links should be specified. At flow > creation time the item with one of the input link types should > precede the flex item and driver will select the correct flex > item settings, depending on the actual flow pattern. > > The output link configuration section tells the driver how > to continue packet parsing after the flex item protocol. > If multiple protocols can follow the flex item header the > flex item should contain the field with the next protocol > identifier and the parsing will be continued depending > on the data contained in this field in the actual packet. > > The flex item fields can participate in RSS hash calculation, > the dedicated flag is present in the field description to specify > what fields should be provided for hashing. > > 5. Flex Item Chaining > > If there are multiple protocols supposed to be supported with > flex items in chained fashion - two or more flex items within > the same flow and these ones might be neighbors in the pattern, > it means the flex items are mutual referencing. In this case, > the item that occurred first should be created with empty > output link list or with the list including existing items, > and then the second flex item should be created referencing > the first flex item as input arc, drivers should adjust > the item confgiuration. > > Also, the hardware resources used by flex items to handle > the packet can be limited. If there are multiple flex items > that are supposed to be used within the same flow it would > be nice to provide some hint for the driver that these two > or more flex items are intended for simultaneous usage. > The fields of items should be assigned with hint indices > and these indices from two or more flex items supposed > to be provided within the same flow should be the same > as well. In other words, the field hint index specifies > the group of fields that can be matched simultaneously > within a single flow. If hint indices are specified, > the driver will try to engage not overlapping hardware > resources and provide independent handling of the field > groups with unique indices. If the hint index is zero > the driver assigns resources on its own. > > 6. Example of New Protocol Handling > > Let's suppose we have the requirements to handle the new tunnel > protocol that follows UDP header with destination port 0xFADE > and is followed by MAC header. Let the new protocol header format > be like this: > > struct new_protocol_header { > rte_be32 header_length; /* length in dwords, including options */ > rte_be32 specific0; /* some protocol data, no intention */ > rte_be32 specific1; /* to match in flows on these fields */ > rte_be32 crucial; /* data of interest, match is needed */ > rte_be32 options[0]; /* optional protocol data, variable length */ > }; > > The supposed flex item configuration: > > struct rte_flow_item_flex_field field0 = { > .field_mode = FIELD_MODE_DUMMY, /* Affects match pattern only */ > .field_size = 96, /* three dwords from the beginning */ > }; > struct rte_flow_item_flex_field field1 = { > .field_mode = FIELD_MODE_FIXED, > .field_size = 32, /* Field size is one dword */ > .field_base = 96, /* Skip three dwords from the beginning */ > }; > struct rte_flow_item_udp spec0 = { > .hdr = { > .dst_port = RTE_BE16(0xFADE), > } > }; > struct rte_flow_item_udp mask0 = { > .hdr = { > .dst_port = RTE_BE16(0xFFFF), > } > }; > struct rte_flow_item_flex_link link0 = { > .item = { > .type = RTE_FLOW_ITEM_TYPE_UDP, > .spec = &spec0, > .mask = &mask0, > }; > > struct rte_flow_item_flex_conf conf = { > .next_header = { > .tunnel = FLEX_TUNNEL_MODE_SINGLE, > .field_mode = FIELD_MODE_OFFSET, > .field_base = 0, > .offset_base = 0, > .offset_mask = 0xFFFFFFFF, > .offset_shift = 2 /* Expressed in dwords, shift left by 2 */ > }, > .sample = { > &field0, > &field1, > }, > .nb_samples = 2, > .input_link[0] = &link0, > .nb_inputs = 1 > }; > > Let's suppose we have created the flex item successfully, and PMD > returned the handle 0x123456789A. We can use the following item > pattern to match the crucial field in the packet with value 0x00112233: > > struct new_protocol_header spec_pattern = > { > .crucial = RTE_BE32(0x00112233), > }; > struct new_protocol_header mask_pattern = > { > .crucial = RTE_BE32(0xFFFFFFFF), > }; > struct rte_flow_item_flex spec_flex = { > .handle = 0x123456789A > .length = sizeiof(struct new_protocol_header), > .pattern = &spec_pattern, > }; > struct rte_flow_item_flex mask_flex = { > .length = sizeof(struct new_protocol_header), > .pattern = &mask_pattern, > }; > struct rte_flow_item item_to_match = { > .type = RTE_FLOW_ITEM_TYPE_FLEX, > .spec = &spec_flex, > .mask = &mask_flex, > }; > > 7. Notes: > > - v4: http://patches.dpdk.org/project/dpdk/patch/20211012113235.24975-2-viacheslavo@nvidia.com/ > - v3: http://patches.dpdk.org/project/dpdk/cover/20211011181528.517-1-viacheslavo@nvidia.com/ > - v2: http://patches.dpdk.org/project/dpdk/patch/20211001193415.23288-2-viacheslavo@nvidia.com/ > - v1: http://patches.dpdk.org/project/dpdk/patch/20210922180418.20663-2-viacheslavo@nvidia.com/ > - RFC: http://patches.dpdk.org/project/dpdk/patch/20210806085624.16497-1-viacheslavo@nvidia.com/ > > - v4 -> v5: > - comments addressed > - testpmd compilation issue fixed > > - v3 -> v4: > - comments addressed > - testpmd compilation issues fixed > - typos fixed > > - v2 -> v3: > - comments addressed > - flex item update removed as not supported > - RSS over flex item fields removed as not supported and non-complete > API > - tunnel mode configuration refactored > - testpmd updated > - documentation updated > - PMD patches are removed temporarily (updating WIP, be presented in rc2) > > - v1 -> v2: > - testpmd CLI to handle flex item is provided > - draft PMD code is introduced > > Signed-off-by: Viacheslav Ovsiienko > > Gregory Etelson (4): > ethdev: support flow elements with variable length > ethdev: implement RTE flex item API > app/testpmd: add jansson library > app/testpmd: add flex item CLI commands > > Viacheslav Ovsiienko (1): > ethdev: introduce configurable flexible item > Hi Viacheslav, This as a nice feature, thanks. But my concern/question is how to test it? I think testing requires HW that support custom (flexible) protocol, and I assume mellanox devices supports it, does it mean specific HW is required to test the feature? Or can we use flexible item to emulate an existing protocol and test it on any hardware? If so what do you think about adding more documentation to describe how this can be done? Thanks, ferruh