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 77480A0093; Fri, 17 Jun 2022 09:50:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5480D40DDD; Fri, 17 Jun 2022 09:50:48 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 86AA040698 for ; Fri, 17 Jun 2022 09:50:46 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25H3jswr020379; Fri, 17 Jun 2022 00:50:42 -0700 Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3grj05rt7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jun 2022 00:50:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YhDc1yu9Y/wkjIHt1EEKnfqdvV8olWde1n+fip+PyytFSSH2f8SCZvpx7PKq1ZQvJzE08KZQX9fMVW0/TyzTD0ywhWwk2wWhr8pykN21pRjRzapYuQYJBvBt9egGOMOwXDDyBbI9WoWK/5z0m8YTdCjf+LRaSuEu91qDP2F+Ekr/QYMxRinNnc7fOxDvMU3OCv0YAMkSXOWl+lbHjnXf7XOq/SuC9uGNAZQYPOnR0w5kmTz2gyYgnP9p/OjgrrrIo6A328XF4W306+muw1EaP64MKh3iDHfXqyqXVL1vq9deTbR0oDTWpEzg+bWgGv9+jYIhvil1+kuamUBEc8Mtqg== 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=sD2UNpY1u2FQ1E2l/js70wj2bD4sZaXRktYNyDjkqV0=; b=cgGULD04iINmxf0vfHBhJL2XijhZ/aMIEqC5Jwbv+JT9m/MU/UW7FQtfPBHu97Jiiv0sNJBj5jsnrErS7KjBoyGrsUYk1NuXE8433AzOsX7JaboQBMIRNWUJtXI2tc2L80EQxCgW0qVa9CF5lXFYgyiQpUJyOQo+9S2bS9D+GuFC23iJPHwCZ/Y9XDVOa1bpp9DtXE5PIhcWA/quxqtGvYqR4L9UW9makbIFXibRJl5VdTqeOfWU0MY7xIS8vk6ZjnCPEpsge8PNK8J34OfW5IuiLUZmVrYhYFrP3gyH6wOur7HFakSlDIHvkIpsQwqAiRGiWq1gcMRnhVdvcX9Zwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sD2UNpY1u2FQ1E2l/js70wj2bD4sZaXRktYNyDjkqV0=; b=E/LSNtI4sYCCXIZ5B1wAyQG/DPzgge2AMzM6THpfLUl8p8W1x+6g/pHYKt0UqsVUcLRph6+NxkbWcGuoJRKVmtd0Rc0BuuIZ6Y/v8jHMMLCz2hHIGrAqGGFsih+S6d2SGLwQTXC7AyJuRNbW8I0BF+cxViL0caujZ5cxavcvfvw= Received: from PH0PR18MB3846.namprd18.prod.outlook.com (2603:10b6:510:49::21) by DM6PR18MB2665.namprd18.prod.outlook.com (2603:10b6:5:15d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16; Fri, 17 Jun 2022 07:50:38 +0000 Received: from PH0PR18MB3846.namprd18.prod.outlook.com ([fe80::6163:7614:e7bd:d002]) by PH0PR18MB3846.namprd18.prod.outlook.com ([fe80::6163:7614:e7bd:d002%5]) with mapi id 15.20.5353.017; Fri, 17 Jun 2022 07:50:38 +0000 From: Rahul Bhansali To: Rahul Bhansali , "dev@dpdk.org" , Ruifeng Wang CC: Jerin Jacob Kollanukkaran , Konstantin Ananyev Subject: RE: [PATCH v2 1/2] examples/l3fwd: common packet group functionality Thread-Topic: [PATCH v2 1/2] examples/l3fwd: common packet group functionality Thread-Index: AQHYgh3mNRY3eOMteUWi8zAJsAPeuq1TOXOA Date: Fri, 17 Jun 2022 07:50:38 +0000 Message-ID: References: <20220524095717.3875284-1-rbhansali@marvell.com> <20220617074241.3260496-1-rbhansali@marvell.com> In-Reply-To: <20220617074241.3260496-1-rbhansali@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6e139de1-e888-4386-5620-08da503611e7 x-ms-traffictypediagnostic: DM6PR18MB2665:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SOgFsm66ryWZkXp+ihC/lb1CRm9uts0wGFAYaxKltSZwBocYOnb+aXvS3wlEpe+fz0F25WyD/WMgJ7P3HYVzyvgAi3TixucOqoBRbcJwzJEE6lmq8TNJu7LuCgMWRt3FxMmqZPkhtSXD7ct+iV9bF+64QQ7JijuwSRnZPkOcGZ6yu9b9hSmXlDHV1yACo23U1UrkuNMPaaVPCm1LimWJnKnqHnA3ndG1KifyAvFxbsYThHpCCJsw2eBIhKMW+nzAWvr9n4DLkrIK3besAMDk4FfFnKJO9p6WZa6oqqSAGie4DMFfvoT5IrcdZOXprpR2aT4qcnT4wakV1bPV7sP2CFi2plpYbNLugOhCVkOeK6yDlM09AqcAveevo5sCr5S7kV31pkMW5fdrYc1jNDCC2vErMGYJpwqkBMaUKca7bGGCvnDdZYCj5qYF3h0+5ySDtiyLISZH37Fnb+KVBBpDLs1oN+K3RnuLNNTNFTTy2FKBqCe6tB3/QW/0J0IefsRnGKhF00SY3Rp9MAwYKtows0Z9XBCNDj6qD50WT6UU0wPmlUu6vKLD0nLYWZaAMRMSc4xdYTPCS41tzNIcPW+wuXdWV5quyc3hIYphgkZB12oFNY+1XMq4hXcGGX15pbgcPbTEK9jjxESvleStIHG6HzUQx3ICB35u3tckvqfBqqC2O2S/Z+TOT9tfeSKj0plYYD3kfhXOW8Dd5RJNDKoIwg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR18MB3846.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(66556008)(38100700002)(64756008)(66446008)(76116006)(66476007)(122000001)(6506007)(66946007)(7696005)(8936002)(8676002)(2906002)(4326008)(52536014)(508600001)(53546011)(110136005)(5660300002)(33656002)(71200400001)(54906003)(83380400001)(316002)(38070700005)(186003)(9686003)(86362001)(26005)(30864003)(55016003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cyA73c+AzPA05ss+Bw6mQ5HctiAx1eTTOm19Y+UNva+3EUUVjtQHevd2D2SM?= =?us-ascii?Q?Y1NN+xXYaHGlyetKzIc+Tw55C7KLbzcCv5bQHc3oVeRfWWdcFcWDP2YgUDO9?= =?us-ascii?Q?wKyD0sucWg0uOf0iLLOwcNXacfZUgMa54FIc3eRtajzQtR7JO8K84MNdkufT?= =?us-ascii?Q?T4ANs4CbCxhMwRTwGk3E/H1ikUdMIueCtJlG5gpjPevpxMvKrn0/E8swSTfE?= =?us-ascii?Q?y7grztz/8phPT5Ld6M9/jsuWtLJemdRTQARDkFBsK4OcenU4tATgnR+Wetik?= =?us-ascii?Q?1S3A68kX96YY6AqCVlmy6tL+BhbNpp8qHDB8game++geV0pdW8142MtYlbBy?= =?us-ascii?Q?VPRxBXkH1p5GbZxoIQM2eN7j57B1qZUtPfD58C1jN2OF5mwvAWO08+xyPyPt?= =?us-ascii?Q?mkyaAABrI8Ff9nNfYZHYkivKT8mMe0CeDU5Qp3wFcrTQ+WWnWxY/vTvDWY/v?= =?us-ascii?Q?/SAvl3cCv6gJm3oPC+nrqkKngIG7WfEhq8Ybhf4Yzu4djjvIccrFWyYeo/yp?= =?us-ascii?Q?nAgSjb1WSm9stofa2w+qomKJZlUbbrA0XFh6ZhJCs1p97wsad35k0WzHtbJG?= =?us-ascii?Q?vnLoXJcKy4+GkC0tML5X69o00GxduhWQeim5pbWdkmYO/GvEPAEsQ04EImuD?= =?us-ascii?Q?6ZzuVfmhxKWF8451cdKO+Db0qUCvoU4LnuZJ5DQ6i276QKW85qxgu7kmw7/t?= =?us-ascii?Q?Qhs8oXbIEUz3WMvJZ/G22cM34czPPnhTDW5TBnIZ7SBt+Wv9SwqH+ORJTAcx?= =?us-ascii?Q?R0HGEWt5HBiuvpCk5tM/KepBVZuwbp4+y/SUPMpkx++8Uffu/F5swrFcgTO+?= =?us-ascii?Q?lsDlyMm6DP845tfufE6F2qOeZCISPnen1nwRD6bLNAEqBMQGr4mSJrnIDJYT?= =?us-ascii?Q?3Mr35eLIb0J0M6grlX+UfkEdztOO7dEwyDr5+2OG+jDaIO3pAKQg0lnOFXlT?= =?us-ascii?Q?fhHlmhWsXCFzkT2U8rH+v64a0hqSvtTodWXJkjPo5LZ0+asFMorz5pz8pg6X?= =?us-ascii?Q?mX25Pwz+rJttWJ8THsnUHq3P7zs7Q6esVp+565pj4ex+65qGh4I2RIarnDva?= =?us-ascii?Q?V9rR50DlO4kj9dpbtkf1xMrS4zMh3Eo11v9bDtAJpYMkR/wO9n7SuCEo8i76?= =?us-ascii?Q?1u0SgrvNtuDnv5K/kH4TjqCx5jSPABTSN8xXBZBgoAwBwxkYh9Sqyj2KudyY?= =?us-ascii?Q?Yebvoghd3MBbKwM4pVk+wG1dhtHCt7Y4T0fnkE+cBm67ZfWpHtfQQZpMPBSE?= =?us-ascii?Q?AZpAOGlF6qMrRRLZB/JAAZGLiNos/b7GIoZJfZJO0z4lBazjIUgQ4P3YgrN6?= =?us-ascii?Q?v1s5DMDz0Kz5UDiTcovMEYRDcWlsH+fmKCccWkpNc/w/g3/vDCv9hAsL0W3p?= =?us-ascii?Q?osmM5iBfuGQw0MCQOzlO7b1ymKNOWnVr496jqRb34fIUmGuFkfDzxVu3j6ur?= =?us-ascii?Q?/e1APRa2tHemHMLlwPBs4gs0NCnmwnJNifkpdVEKQ0ULh4pyBr7oTi1aPuF3?= =?us-ascii?Q?ceiU0UaXR3/RPkDbcECeBuFNJELKcoyBIEgfdYj1A4USaqyu8UCPZ2PRhMur?= =?us-ascii?Q?bT5GHzJG6yrULuY+7zyfTrIKiQdfpFGxgp7R+wh6Xhu+oJrP5Y8kInTCkYMm?= =?us-ascii?Q?Insio3654HA+q7xKxqCUwbSR0Usb4E1JySSMx10ceaUYH/v6+3Lsd2UPkDoe?= =?us-ascii?Q?DAfhp6Xrlv8ct2kSJIKrD/B94AKyuSn611QT2q+4mQhgB7bHnKGFQURoqTbR?= =?us-ascii?Q?ODB5EQYc/g=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR18MB3846.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e139de1-e888-4386-5620-08da503611e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jun 2022 07:50:38.4551 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ncOsg919Q8TUYIoXn9MLiyk2S6wPyLU+0wmKJq8ZjNRUde37UQayYB2bNz/gGP4ydeFlFhPW2aQfXaYeY/vzKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR18MB2665 X-Proofpoint-GUID: aqKh3FgDef9gt1OieQhk0wn_9JEBk9Wl X-Proofpoint-ORIG-GUID: aqKh3FgDef9gt1OieQhk0wn_9JEBk9Wl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-17_07,2022-06-16_01,2022-02-23_01 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 CC: Konstantin Ananyev > -----Original Message----- > From: Rahul Bhansali > Sent: Friday, June 17, 2022 1:13 PM > To: dev@dpdk.org; Ruifeng Wang > Cc: Jerin Jacob Kollanukkaran ; Rahul Bhansali > > Subject: [PATCH v2 1/2] examples/l3fwd: common packet group functionality >=20 > This will make the packet grouping function common, so that other example= s > can utilize as per need. >=20 > Signed-off-by: Rahul Bhansali > --- > Changes in v2: New patch to address review comment. >=20 > examples/common/neon_common.h | 50 ++++++++++++ > examples/common/pkt_group.h | 139 > ++++++++++++++++++++++++++++++++++ > examples/l3fwd/Makefile | 5 +- > examples/l3fwd/l3fwd.h | 2 - > examples/l3fwd/l3fwd_common.h | 129 +------------------------------ > examples/l3fwd/l3fwd_neon.h | 43 +---------- > examples/meson.build | 2 +- > 7 files changed, 198 insertions(+), 172 deletions(-) create mode 100644 > examples/common/neon_common.h create mode 100644 > examples/common/pkt_group.h >=20 > diff --git a/examples/common/neon_common.h > b/examples/common/neon_common.h new file mode 100644 index > 0000000000..f01b5ab6bc > --- /dev/null > +++ b/examples/common/neon_common.h > @@ -0,0 +1,50 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2018 Intel Corporation. > + * Copyright(c) 2017-2018 Linaro Limited. > + * Copyright(C) 2022 Marvell. > + */ > + > +#ifndef _NEON_COMMON_H_ > +#define _NEON_COMMON_H_ > + > +#include "pkt_group.h" > + > +/* > + * Group consecutive packets with the same destination port in bursts of= 4. > + * Suppose we have array of destination ports: > + * dst_port[] =3D {a, b, c, d,, e, ... } > + * dp1 should contain: , dp2: . > + * We doing 4 comparisons at once and the result is 4 bit mask. > + * This mask is used as an index into prebuild array of pnum values. > + */ > +static inline uint16_t * > +neon_port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1= , > + uint16x8_t dp2) > +{ > + union { > + uint16_t u16[FWDSTEP + 1]; > + uint64_t u64; > + } *pnum =3D (void *)pn; > + > + uint16x8_t mask =3D {1, 2, 4, 8, 0, 0, 0, 0}; > + int32_t v; > + > + dp1 =3D vceqq_u16(dp1, dp2); > + dp1 =3D vandq_u16(dp1, mask); > + v =3D vaddvq_u16(dp1); > + > + /* update last port counter. */ > + lp[0] +=3D gptbl[v].lpv; > + rte_compiler_barrier(); > + > + /* if dest port value has changed. */ > + if (v !=3D GRPMSK) { > + pnum->u64 =3D gptbl[v].pnum; > + pnum->u16[FWDSTEP] =3D 1; > + lp =3D pnum->u16 + gptbl[v].idx; > + } > + > + return lp; > +} > + > +#endif /* _NEON_COMMON_H_ */ > diff --git a/examples/common/pkt_group.h b/examples/common/pkt_group.h > new file mode 100644 index 0000000000..8b26d9380f > --- /dev/null > +++ b/examples/common/pkt_group.h > @@ -0,0 +1,139 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2018 Intel Corporation. > + * Copyright(c) 2017-2018 Linaro Limited. > + * Copyright(C) 2022 Marvell. > + */ > + > +#ifndef _PKT_GROUP_H_ > +#define _PKT_GROUP_H_ > + > +#define FWDSTEP 4 > + > +/* > + * Group consecutive packets with the same destination port into one bur= st. > + * To avoid extra latency this is done together with some other packet > + * processing, but after we made a final decision about packet's destina= tion. > + * To do this we maintain: > + * pnum - array of number of consecutive packets with the same dest > +port for > + * each packet in the input burst. > + * lp - pointer to the last updated element in the pnum. > + * dlp - dest port value lp corresponds to. > + */ > + > +#define GRPSZ (1 << FWDSTEP) > +#define GRPMSK (GRPSZ - 1) > + > +#define GROUP_PORT_STEP(dlp, dcp, lp, pn, idx) do { \ > + if (likely((dlp) =3D=3D (dcp)[(idx)])) { \ > + (lp)[0]++; \ > + } else { \ > + (dlp) =3D (dcp)[idx]; \ > + (lp) =3D (pn) + (idx); \ > + (lp)[0] =3D 1; \ > + } \ > +} while (0) > + > +static const struct { > + uint64_t pnum; /* prebuild 4 values for pnum[]. */ > + int32_t idx; /* index for new last updated elemnet. */ > + uint16_t lpv; /* add value to the last updated element. */ } > +gptbl[GRPSZ] =3D { > + { > + /* 0: a !=3D b, b !=3D c, c !=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000100010001), > + .idx =3D 4, > + .lpv =3D 0, > + }, > + { > + /* 1: a =3D=3D b, b !=3D c, c !=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000100010002), > + .idx =3D 4, > + .lpv =3D 1, > + }, > + { > + /* 2: a !=3D b, b =3D=3D c, c !=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000100020001), > + .idx =3D 4, > + .lpv =3D 0, > + }, > + { > + /* 3: a =3D=3D b, b =3D=3D c, c !=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000100020003), > + .idx =3D 4, > + .lpv =3D 2, > + }, > + { > + /* 4: a !=3D b, b !=3D c, c =3D=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000200010001), > + .idx =3D 4, > + .lpv =3D 0, > + }, > + { > + /* 5: a =3D=3D b, b !=3D c, c =3D=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000200010002), > + .idx =3D 4, > + .lpv =3D 1, > + }, > + { > + /* 6: a !=3D b, b =3D=3D c, c =3D=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000200030001), > + .idx =3D 4, > + .lpv =3D 0, > + }, > + { > + /* 7: a =3D=3D b, b =3D=3D c, c =3D=3D d, d !=3D e */ > + .pnum =3D UINT64_C(0x0001000200030004), > + .idx =3D 4, > + .lpv =3D 3, > + }, > + { > + /* 8: a !=3D b, b !=3D c, c !=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000100010001), > + .idx =3D 3, > + .lpv =3D 0, > + }, > + { > + /* 9: a =3D=3D b, b !=3D c, c !=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000100010002), > + .idx =3D 3, > + .lpv =3D 1, > + }, > + { > + /* 0xa: a !=3D b, b =3D=3D c, c !=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000100020001), > + .idx =3D 3, > + .lpv =3D 0, > + }, > + { > + /* 0xb: a =3D=3D b, b =3D=3D c, c !=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000100020003), > + .idx =3D 3, > + .lpv =3D 2, > + }, > + { > + /* 0xc: a !=3D b, b !=3D c, c =3D=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000300010001), > + .idx =3D 2, > + .lpv =3D 0, > + }, > + { > + /* 0xd: a =3D=3D b, b !=3D c, c =3D=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000300010002), > + .idx =3D 2, > + .lpv =3D 1, > + }, > + { > + /* 0xe: a !=3D b, b =3D=3D c, c =3D=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000300040001), > + .idx =3D 1, > + .lpv =3D 0, > + }, > + { > + /* 0xf: a =3D=3D b, b =3D=3D c, c =3D=3D d, d =3D=3D e */ > + .pnum =3D UINT64_C(0x0002000300040005), > + .idx =3D 0, > + .lpv =3D 4, > + }, > +}; > + > +#endif /* _PKT_GROUP_H_ */ > diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile index > 8efe6378e2..8dbe85c2e6 100644 > --- a/examples/l3fwd/Makefile > +++ b/examples/l3fwd/Makefile > @@ -22,6 +22,7 @@ shared: build/$(APP)-shared > static: build/$(APP)-static > ln -sf $(APP)-static build/$(APP) >=20 > +INCLUDES =3D-I../common > PC_FILE :=3D $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS +=3D= -O3 > $(shell $(PKGCONF) --cflags libdpdk) # Added for 'rte_eth_link_to_str()' > @@ -38,10 +39,10 @@ endif > endif >=20 > build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build > - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) > + $(CC) $(CFLAGS) $(SRCS-y) $(INCLUDES) -o $@ $(LDFLAGS) > +$(LDFLAGS_SHARED) >=20 > build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build > - $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) > + $(CC) $(CFLAGS) $(SRCS-y) $(INCLUDES) -o $@ $(LDFLAGS) > +$(LDFLAGS_STATIC) >=20 > build: > @mkdir -p $@ > diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index > 8a52c90755..40b5f32a9e 100644 > --- a/examples/l3fwd/l3fwd.h > +++ b/examples/l3fwd/l3fwd.h > @@ -44,8 +44,6 @@ > /* Used to mark destination port as 'invalid'. */ > #define BAD_PORT ((uint16_t)-1) >=20 > -#define FWDSTEP 4 > - > /* replace first 12B of the ethernet header. */ > #define MASK_ETH 0x3f >=20 > diff --git a/examples/l3fwd/l3fwd_common.h > b/examples/l3fwd/l3fwd_common.h index 8e4c27218f..224b1c08e8 100644 > --- a/examples/l3fwd/l3fwd_common.h > +++ b/examples/l3fwd/l3fwd_common.h > @@ -7,6 +7,8 @@ > #ifndef _L3FWD_COMMON_H_ > #define _L3FWD_COMMON_H_ >=20 > +#include "pkt_group.h" > + > #ifdef DO_RFC_1812_CHECKS >=20 > #define IPV4_MIN_VER_IHL 0x45 > @@ -50,133 +52,6 @@ rfc1812_process(struct rte_ipv4_hdr *ipv4_hdr, uint16= _t > *dp, uint32_t ptype) > #define rfc1812_process(mb, dp, ptype) do { } while (0) > #endif /* DO_RFC_1812_CHECKS */ >=20 > -/* > - * We group consecutive packets with the same destination port into one = burst. > - * To avoid extra latency this is done together with some other packet > - * processing, but after we made a final decision about packet's destina= tion. > - * To do this we maintain: > - * pnum - array of number of consecutive packets with the same dest port= for > - * each packet in the input burst. > - * lp - pointer to the last updated element in the pnum. > - * dlp - dest port value lp corresponds to. > - */ > - > -#define GRPSZ (1 << FWDSTEP) > -#define GRPMSK (GRPSZ - 1) > - > -#define GROUP_PORT_STEP(dlp, dcp, lp, pn, idx) do { \ > - if (likely((dlp) =3D=3D (dcp)[(idx)])) { \ > - (lp)[0]++; \ > - } else { \ > - (dlp) =3D (dcp)[idx]; \ > - (lp) =3D (pn) + (idx); \ > - (lp)[0] =3D 1; \ > - } \ > -} while (0) > - > -static const struct { > - uint64_t pnum; /* prebuild 4 values for pnum[]. */ > - int32_t idx; /* index for new last updated element. */ > - uint16_t lpv; /* add value to the last updated element. */ > -} gptbl[GRPSZ] =3D { > - { > - /* 0: a !=3D b, b !=3D c, c !=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000100010001), > - .idx =3D 4, > - .lpv =3D 0, > - }, > - { > - /* 1: a =3D=3D b, b !=3D c, c !=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000100010002), > - .idx =3D 4, > - .lpv =3D 1, > - }, > - { > - /* 2: a !=3D b, b =3D=3D c, c !=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000100020001), > - .idx =3D 4, > - .lpv =3D 0, > - }, > - { > - /* 3: a =3D=3D b, b =3D=3D c, c !=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000100020003), > - .idx =3D 4, > - .lpv =3D 2, > - }, > - { > - /* 4: a !=3D b, b !=3D c, c =3D=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000200010001), > - .idx =3D 4, > - .lpv =3D 0, > - }, > - { > - /* 5: a =3D=3D b, b !=3D c, c =3D=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000200010002), > - .idx =3D 4, > - .lpv =3D 1, > - }, > - { > - /* 6: a !=3D b, b =3D=3D c, c =3D=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000200030001), > - .idx =3D 4, > - .lpv =3D 0, > - }, > - { > - /* 7: a =3D=3D b, b =3D=3D c, c =3D=3D d, d !=3D e */ > - .pnum =3D UINT64_C(0x0001000200030004), > - .idx =3D 4, > - .lpv =3D 3, > - }, > - { > - /* 8: a !=3D b, b !=3D c, c !=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000100010001), > - .idx =3D 3, > - .lpv =3D 0, > - }, > - { > - /* 9: a =3D=3D b, b !=3D c, c !=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000100010002), > - .idx =3D 3, > - .lpv =3D 1, > - }, > - { > - /* 0xa: a !=3D b, b =3D=3D c, c !=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000100020001), > - .idx =3D 3, > - .lpv =3D 0, > - }, > - { > - /* 0xb: a =3D=3D b, b =3D=3D c, c !=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000100020003), > - .idx =3D 3, > - .lpv =3D 2, > - }, > - { > - /* 0xc: a !=3D b, b !=3D c, c =3D=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000300010001), > - .idx =3D 2, > - .lpv =3D 0, > - }, > - { > - /* 0xd: a =3D=3D b, b !=3D c, c =3D=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000300010002), > - .idx =3D 2, > - .lpv =3D 1, > - }, > - { > - /* 0xe: a !=3D b, b =3D=3D c, c =3D=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000300040001), > - .idx =3D 1, > - .lpv =3D 0, > - }, > - { > - /* 0xf: a =3D=3D b, b =3D=3D c, c =3D=3D d, d =3D=3D e */ > - .pnum =3D UINT64_C(0x0002000300040005), > - .idx =3D 0, > - .lpv =3D 4, > - }, > -}; > - > static __rte_always_inline void > send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf = *m[], > uint32_t num) > diff --git a/examples/l3fwd/l3fwd_neon.h b/examples/l3fwd/l3fwd_neon.h > index e3d33a5229..5fa765b640 100644 > --- a/examples/l3fwd/l3fwd_neon.h > +++ b/examples/l3fwd/l3fwd_neon.h > @@ -7,6 +7,7 @@ > #define _L3FWD_NEON_H_ >=20 > #include "l3fwd.h" > +#include "neon_common.h" > #include "l3fwd_common.h" >=20 > /* > @@ -62,44 +63,6 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], > uint16_t dst_port[FWDSTEP]) > &dst_port[3], pkt[3]->packet_type); > } >=20 > -/* > - * Group consecutive packets with the same destination port in bursts of= 4. > - * Suppose we have array of destination ports: > - * dst_port[] =3D {a, b, c, d,, e, ... } > - * dp1 should contain: , dp2: . > - * We doing 4 comparisons at once and the result is 4 bit mask. > - * This mask is used as an index into prebuild array of pnum values. > - */ > -static inline uint16_t * > -port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1, > - uint16x8_t dp2) > -{ > - union { > - uint16_t u16[FWDSTEP + 1]; > - uint64_t u64; > - } *pnum =3D (void *)pn; > - > - int32_t v; > - uint16x8_t mask =3D {1, 2, 4, 8, 0, 0, 0, 0}; > - > - dp1 =3D vceqq_u16(dp1, dp2); > - dp1 =3D vandq_u16(dp1, mask); > - v =3D vaddvq_u16(dp1); > - > - /* update last port counter. */ > - lp[0] +=3D gptbl[v].lpv; > - rte_compiler_barrier(); > - > - /* if dest port value has changed. */ > - if (v !=3D GRPMSK) { > - pnum->u64 =3D gptbl[v].pnum; > - pnum->u16[FWDSTEP] =3D 1; > - lp =3D pnum->u16 + gptbl[v].idx; > - } > - > - return lp; > -} > - > /** > * Process one packet: > * Update source and destination MAC addresses in the ethernet header. > @@ -161,7 +124,7 @@ send_packets_multi(struct lcore_conf *qconf, struct > rte_mbuf **pkts_burst, > * > */ > dp2 =3D vld1q_u16(&dst_port[j - FWDSTEP + 1]); > - lp =3D port_groupx4(&pnum[j - FWDSTEP], lp, dp1, dp2); > + lp =3D neon_port_groupx4(&pnum[j - FWDSTEP], lp, dp1, > dp2); >=20 > /* > * dp1: > @@ -175,7 +138,7 @@ send_packets_multi(struct lcore_conf *qconf, struct > rte_mbuf **pkts_burst, > */ > dp2 =3D vextq_u16(dp1, dp1, 1); > dp2 =3D vsetq_lane_u16(vgetq_lane_u16(dp2, 2), dp2, 3); > - lp =3D port_groupx4(&pnum[j - FWDSTEP], lp, dp1, dp2); > + lp =3D neon_port_groupx4(&pnum[j - FWDSTEP], lp, dp1, dp2); >=20 > /* > * remove values added by the last repeated diff --git > a/examples/meson.build b/examples/meson.build index > 78de0e1f37..81e93799f2 100644 > --- a/examples/meson.build > +++ b/examples/meson.build > @@ -97,7 +97,7 @@ foreach example: examples > ldflags =3D default_ldflags >=20 > ext_deps =3D [] > - includes =3D [include_directories(example)] > + includes =3D [include_directories(example, 'common')] > deps =3D ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] > subdir(example) >=20 > -- > 2.25.1