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 9A44CA0C47; Tue, 12 Oct 2021 09:53:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 824E9410DA; Tue, 12 Oct 2021 09:53:22 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2070.outbound.protection.outlook.com [40.107.220.70]) by mails.dpdk.org (Postfix) with ESMTP id D8447410D7 for ; Tue, 12 Oct 2021 09:53:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BtIT04FUre0jYyh14xHDYlSXYsQx16ytLTydZ0dnCTtBWuCiyqUF00qFuHcznHu7TF/o8VjBi1eISSpxrch77YiEhxcySlxszD55RofKx63uP7KEFMxldlJGyziOeTvQfq/qmlAb1Eew3ou83Q4JBOFRJ5A6KRc8rSnbzAX3uiHE4ttyJQs8nXqC3ehsaFoEMhDpGccb9nmhODHLXzuhrggeAmGNHxo758X6VKtxesoofyPrl8OLjZgn818sITNdPQ6QCPp+raQAJ7W5X4CJrGw3gaY+LgJcZ/Gyj0er1SGDPElsWRF2bKp6nV8MZKIKzecWWTEViTiLV1qoLsqx7g== 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=8MNYZH4XH2mxLsxfor3ySqS7SVTdgJvgI5HPwunZ+X0=; b=MFH0DX46ONoUQp4/d+lQQTE2+JqmDc/53y9FegCmYO0BubUviOH2q8lByfkkw8rw+didXshJ4yyPwxQ4s+Dr4onmTFnY4zzBMP8A+nZOkp0a20bzsvuNCdt2dPGR+gpe0UBqusCgiMa3u7gSCbV8UEK73nRKepfuX1E1v1izjXTLLbvMx02ji0XBlw9O+2hvX5fvQfpMVu+09w6zknud12MCSmnAPFAoceUGrbUi4KDMShIYRX75fgzz2LejeAbaSNQCgWemajrF4wAXKAr6D5zmNDETuY7mWpyVtXh09Nfz04R7yacukaadcOLtfQQDh0uK6phQdhGRlmwgxEEl5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=8MNYZH4XH2mxLsxfor3ySqS7SVTdgJvgI5HPwunZ+X0=; b=t9O9gtMp2tAH4YSV6bxnIND36FeYb7cb+lgL03eWzsBtFnUgOp0N7FHFC/DtdeQlw0SjsSstB3a5eIVxheZTtm5Ye9+l3CQVcektFqfQV4DXkAwCu45fXxpTBFp34YFjjX6cNdLRxDbjLKXzNOwU1VJSe3s6GfSdAhD6hkIfhDPNXfQnO+np5YH4zQmmR5XlwLo0yJ2bP6bjuikzF5JWz0s4LyDLjmLznSDkosQB9oYdFt3jMn3Bl6w4kM6iqZqmfpRTZuatA4TGF7M2KdfGG3b4ydPAeYmkX/eViXgES2D+/Zpk+uL2QBI8Zd6spOpe5hg4ajybVgTSW4fQ2hNFrA== Received: from DM8PR12MB5400.namprd12.prod.outlook.com (2603:10b6:8:3b::12) by DM4PR12MB5263.namprd12.prod.outlook.com (2603:10b6:5:39b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 07:53:19 +0000 Received: from DM8PR12MB5400.namprd12.prod.outlook.com ([fe80::d03d:1f75:ca20:6a32]) by DM8PR12MB5400.namprd12.prod.outlook.com ([fe80::d03d:1f75:ca20:6a32%6]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 07:53:19 +0000 From: Ori Kam To: Slava Ovsiienko , "dev@dpdk.org" CC: Raslan Darawsheh , Matan Azrad , Shahaf Shuler , Gregory Etelson , NBU-Contact-Thomas Monjalon Thread-Topic: [dpdk-dev] [PATCH v3 2/5] ethdev: support flow elements with variable length Thread-Index: AQHXvswSTg8dtGBrJEiEsyuAIFdw16vO94QA Date: Tue, 12 Oct 2021 07:53:19 +0000 Message-ID: References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211011181528.517-1-viacheslavo@nvidia.com> <20211011181528.517-3-viacheslavo@nvidia.com> In-Reply-To: <20211011181528.517-3-viacheslavo@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 008685c7-5ef2-4ef9-72df-08d98d555b61 x-ms-traffictypediagnostic: DM4PR12MB5263: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:176; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cz/WCCWqx/Ww0F75BKvUslMZ/bhTPxPpzXVJItg7p1LjAFJ9VPKLD3IIBHhSNRxgliEVfwN7RhWwj396tcWrImLUPdhHDXG0nm5EUeSXk/qvMxN8XcqDXS3vaZTeQUTKAyK4YpMltiQ/webRDRDnYdp9CqK3l0fstZvXoBey0jT4rnVyDAqJ7kVl89f3ypbO7i+5UgoRe4qLYTAtXfmo3HZjYYnbGTtKnitXUHrCyYUd0KMyna0Ztz5tS7gXFZvGOsLdybLjH5CJLnT2L3eSF7wrP2b/pT0U8P2qANFb/I3wSOe5t75XXgHJN6viXGDelTw11mGAzBmnhU4EIDcXLFlrGPBfvZkkHdC35nvUaMtpRqBZvxqs4B7DCjZ76WdTrGO35SRkPHVXOronvPRznKjggBMynb2EUivuejEYPPK7Q/Dl6VWEk/cWDZvJ6x4D/qlPsIi8IliRMHZJMv0YwhIDQ34LMVFZm0ZZnqt46uulW67gSQu7IEjxJl71Wq/TVkYOn86qDAhgwGKjSdIXGKE6x3scsIlge9G9buiwgOFfzzfqSZNWl6tgspn4OjeQ9ZJtHUPJusq1oQ3PpdoQF8+aTqlQyd72eKkIv/lVOFWFweZizJIv1Oznkjg1mVet7sCdkG8N04m6mnWeiWT8KPw4+4+r6sdkNOPkrfCJ3XWgKgheQu/+k4zcR4+G6LRaf6BJLYBgccU1op0/B2N/Tg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM8PR12MB5400.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(5660300002)(76116006)(86362001)(33656002)(54906003)(110136005)(66556008)(4326008)(66446008)(316002)(64756008)(7696005)(66946007)(6506007)(508600001)(38070700005)(66476007)(53546011)(122000001)(2906002)(52536014)(26005)(55016002)(9686003)(186003)(8676002)(71200400001)(8936002)(83380400001)(38100700002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?PbYYd5HJ43uNx/SutBazZk75I3Rx2B+USTlaG3AFIo/XG0EAf2wmpCdRnEcK?= =?us-ascii?Q?kD+V+CGbic/3C+8uOJFua35NAz77hTMCxcPW1QCtmxccQeZYrpN2N5d6fyaG?= =?us-ascii?Q?3UDirt8hqs0gRnl3cIfQbiYuRmKvDi0fivG01SXRqFfKUcxuVKqs4K6LKLo9?= =?us-ascii?Q?dcxFLMW544U378R+OmqiE05I3cgvd1wg3zVsJsyECIe7ODIFAvfR4X768eaE?= =?us-ascii?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8YVjo2pD9ysmS+8HigwMTs?= =?us-ascii?Q?8FVB3CQdZQtMp49AmsHI+volu5q4qeWP0sRlwtiG6DtEpvNWfdcy4rdjTIKl?= =?us-ascii?Q?GDW9dxzMIZrvcM7flu/94nnp/+H9kG4pf9QLw9sxD3zd5OWbDMFCwAVsvuE7?= =?us-ascii?Q?iATsxeB7iUBr7D991HolvmU1h+PJZbABVxJa/Ie4l6V4F6ORMJ5rp4Ak+ZUE?= =?us-ascii?Q?VzWquJdF5PlbrbezAcDjcadl?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR12MB5400.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 008685c7-5ef2-4ef9-72df-08d98d555b61 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2021 07:53:19.3365 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QPMVdtGpa8zMqx5nl2vHI0FZsLBIPONiTpQSICsImJ40x4ZdW1mMxab7zgpVqV3Lz+LdotfsLmuCyc9W0ZAZgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5263 Subject: Re: [dpdk-dev] [PATCH v3 2/5] ethdev: support flow elements with variable length 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" Hi Slava and Gregory, > -----Original Message----- > From: dev On Behalf Of Viacheslav Ovsiienko > Sent: Monday, October 11, 2021 9:15 PM > Subject: [dpdk-dev] [PATCH v3 2/5] ethdev: support flow elements with var= iable length >=20 > From: Gregory Etelson >=20 > RTE flow API provides RAW item type for packet patterns of variable lengt= h. The RAW item structure has > fixed size members that describe the variable pattern length and methods = to process it. >=20 > A new RTE flow item type with variable length pattern that does not fit t= he RAW item meta description > could not use the RAW item. > For example, the new flow item that references 64 bits PMD handler cannot= be described by the RAW > item. >=20 > The patch allows RTE conv helper functions to process custom flow items w= ith variable length pattern. >=20 > Signed-off-by: Gregory Etelson > Reviewed-by: Viacheslav Ovsiienko > --- > lib/ethdev/rte_flow.c | 83 ++++++++++++++++++++++++++++++++++++------- > 1 file changed, 70 insertions(+), 13 deletions(-) >=20 > diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8cb7a069= c8..100983ca59 100644 > --- a/lib/ethdev/rte_flow.c > +++ b/lib/ethdev/rte_flow.c > @@ -30,13 +30,67 @@ uint64_t rte_flow_dynf_metadata_mask; struct rte_flo= w_desc_data { > const char *name; > size_t size; > + size_t (*desc_fn)(void *dst, const void *src); > }; >=20 > +/** > + * > + * @param buf > + * Destination memory. > + * @param data > + * Source memory > + * @param size > + * Requested copy size > + * @param desc > + * rte_flow_desc_item - for flow item conversion. > + * rte_flow_desc_action - for flow action conversion. > + * @param type > + * Offset into the desc param or negative value for private flow element= s. > + */ > +static inline size_t > +rte_flow_conv_copy(void *buf, const void *data, const size_t size, > + const struct rte_flow_desc_data *desc, int type) { > + /** > + * allow PMD private flow item > + * see 5d1bff8fe2 There shouldn't be commit reference in source. > + * "ethdev: allow negative values in flow rule types" > + */ > + size_t sz =3D type >=3D 0 ? desc[type].size : sizeof(void *); > + if (buf =3D=3D NULL || data =3D=3D NULL) > + return 0; > + rte_memcpy(buf, data, (size > sz ? sz : size)); > + if (desc[type].desc_fn) > + sz +=3D desc[type].desc_fn(size > 0 ? buf : NULL, data); > + return sz; > +} > + > +static size_t > +rte_flow_item_flex_conv(void *buf, const void *data) { > + struct rte_flow_item_flex *dst =3D buf; > + const struct rte_flow_item_flex *src =3D data; > + if (buf) { > + dst->pattern =3D rte_memcpy > + ((void *)((uintptr_t)(dst + 1)), src->pattern, > + src->length); > + } > + return src->length; > +} > + > /** Generate flow_item[] entry. */ > #define MK_FLOW_ITEM(t, s) \ > [RTE_FLOW_ITEM_TYPE_ ## t] =3D { \ > .name =3D # t, \ > - .size =3D s, \ > + .size =3D s, \ > + .desc_fn =3D NULL,\ > + } > + > +#define MK_FLOW_ITEM_FN(t, s, fn) \ > + [RTE_FLOW_ITEM_TYPE_ ## t] =3D {\ > + .name =3D # t, \ > + .size =3D s, \ > + .desc_fn =3D fn, \ > } >=20 > /** Information about known flow pattern items. */ @@ -100,6 +154,8 @@ s= tatic const struct > rte_flow_desc_data rte_flow_desc_item[] =3D { > MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)), > MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), > MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), > + MK_FLOW_ITEM_FN(FLEX, sizeof(struct rte_flow_item_flex), > + rte_flow_item_flex_conv), > }; >=20 > /** Generate flow_action[] entry. */ > @@ -107,8 +163,17 @@ static const struct rte_flow_desc_data rte_flow_desc= _item[] =3D { > [RTE_FLOW_ACTION_TYPE_ ## t] =3D { \ > .name =3D # t, \ > .size =3D s, \ > + .desc_fn =3D NULL,\ > + } > + > +#define MK_FLOW_ACTION_FN(t, fn) \ > + [RTE_FLOW_ACTION_TYPE_ ## t] =3D { \ > + .name =3D # t, \ > + .size =3D 0, \ > + .desc_fn =3D fn,\ > } >=20 > + > /** Information about known flow actions. */ static const struct rte_fl= ow_desc_data > rte_flow_desc_action[] =3D { > MK_FLOW_ACTION(END, 0), > @@ -527,12 +592,8 @@ rte_flow_conv_item_spec(void *buf, const size_t size= , > } > break; > default: > - /** > - * allow PMD private flow item > - */ > - off =3D (int)item->type >=3D 0 ? > - rte_flow_desc_item[item->type].size : sizeof(void *); > - rte_memcpy(buf, data, (size > off ? off : size)); > + off =3D rte_flow_conv_copy(buf, data, size, > + rte_flow_desc_item, item->type); > break; > } > return off; > @@ -634,12 +695,8 @@ rte_flow_conv_action_conf(void *buf, const size_t si= ze, > } > break; > default: > - /** > - * allow PMD private flow action > - */ > - off =3D (int)action->type >=3D 0 ? > - rte_flow_desc_action[action->type].size : sizeof(void *); > - rte_memcpy(buf, action->conf, (size > off ? off : size)); > + off =3D rte_flow_conv_copy(buf, action->conf, size, > + rte_flow_desc_action, action->type); > break; > } > return off; > -- > 2.18.1 Best, Ori