From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F201CA04B1; Sat, 10 Oct 2020 11:35:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D14C1D73D; Sat, 10 Oct 2020 11:35:21 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20061.outbound.protection.outlook.com [40.107.2.61]) by dpdk.org (Postfix) with ESMTP id 6E31F1D73B for ; Sat, 10 Oct 2020 11:35:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uC2G7rUuo6C4ekpk/TBVJ+g0uZj9yAIyRLM/OBTo7ak=; b=gcKPgXVoyW6bo5C7vGy65vdJiQIuVg83T8jKAmXwrbWCtmS9hS1JAjm/FHnFo13TCVOrpZFugWEJHVDhNESOge+eaq9iCds6c4eg45axq9/IWo59SsKL8XI+ikis1eGQYowpvkhw4lqas8nzt3Zww0R7UcqiISDBMY44fq2txMI= Received: from DB3PR06CA0005.eurprd06.prod.outlook.com (2603:10a6:8:1::18) by VE1PR08MB5727.eurprd08.prod.outlook.com (2603:10a6:800:1a5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.27; Sat, 10 Oct 2020 09:35:07 +0000 Received: from DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:8:1:cafe::61) by DB3PR06CA0005.outlook.office365.com (2603:10a6:8:1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21 via Frontend Transport; Sat, 10 Oct 2020 09:35:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT026.mail.protection.outlook.com (10.152.20.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23 via Frontend Transport; Sat, 10 Oct 2020 09:35:07 +0000 Received: ("Tessian outbound 195a290eb161:v64"); Sat, 10 Oct 2020 09:35:07 +0000 X-CR-MTA-TID: 64aa7808 Received: from bb0927603a4a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A750B43E-6109-494B-84CA-40AB7723AE04.1; Sat, 10 Oct 2020 09:35:02 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bb0927603a4a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 10 Oct 2020 09:35:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HzPJDI++gOixcCLxhQf/pP+lsQwcuxaQ8/6cmYiJ2b74o/UzB7YVne3HcwSG3fmHc+RjyVN0d6H4IxBeD508Tc9V1eb0z3V14zNJpvxUGDonkS30UzmmHQ0HQujmA0m7mFvmn1Gtq+bw0bsfQnnY9DGM54BCrFlN3+YP6xRmoxUUwmfkXHWTlt8GZFfAjPSGVY8tqBw4V7d2odWaivtqiYnhM+I/n7vDpxRLqKtYMc0105if2COlRf68CqhvBbBSSGoIzDoH9ZBvRK4MiGEvoedSfmiSoG5arQ651+N095Ih6ucdr0EFFluiqFUDybB7OegMtmlHEK8GJ85AAfiSyQ== 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-SenderADCheck; bh=uC2G7rUuo6C4ekpk/TBVJ+g0uZj9yAIyRLM/OBTo7ak=; b=Q0QrSOoHkCp0QK6YEgYmhS4jyVmdfyNFrd3xN+m2/tfnnT/ZKK/Ts/8mJkC8eSHcEtKK0i1//sU3g+8lYuNp3OBegWS0Y+JzMgZShx7ik6OxBQSmjvglM7hK1Hf/kygGNdrUiUdof/66LBmDsxdV7vLqqc/AmzwP1mKjfESg2tuatwl2fBTREi8c5LIvMXkVA6EtZd2vEyCFOtgsxTXyfLc/B5MDkFdOvxkLz1aVrsd5rODHD6eh8wHKw0smnfdJq73YyrJrsHF4k/IPvNVA4LlQ/9GMKnBTb+uyHoG7wIS0BHx5r7W/+ddOi4E70HlnD2/fEZ2CkdbTc6Zx0gUytQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uC2G7rUuo6C4ekpk/TBVJ+g0uZj9yAIyRLM/OBTo7ak=; b=gcKPgXVoyW6bo5C7vGy65vdJiQIuVg83T8jKAmXwrbWCtmS9hS1JAjm/FHnFo13TCVOrpZFugWEJHVDhNESOge+eaq9iCds6c4eg45axq9/IWo59SsKL8XI+ikis1eGQYowpvkhw4lqas8nzt3Zww0R7UcqiISDBMY44fq2txMI= Received: from VI1PR0802MB2351.eurprd08.prod.outlook.com (2603:10a6:800:a0::10) by VI1PR08MB2704.eurprd08.prod.outlook.com (2603:10a6:802:1b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22; Sat, 10 Oct 2020 09:34:56 +0000 Received: from VI1PR0802MB2351.eurprd08.prod.outlook.com ([fe80::14d4:6ade:368a:204b]) by VI1PR0802MB2351.eurprd08.prod.outlook.com ([fe80::14d4:6ade:368a:204b%3]) with mapi id 15.20.3455.028; Sat, 10 Oct 2020 09:34:55 +0000 From: Ruifeng Wang To: Mairtin o Loingsigh , "jasvinder.singh@intel.com" , "bruce.richardson@intel.com" , "pablo.de.lara.guarch@intel.com" , "konstantin.ananyev@intel.com" CC: "dev@dpdk.org" , "brendan.ryan@intel.com" , "david.coyle@intel.com" , nd Thread-Topic: [dpdk-dev] [PATCH v5 1/2] net: add run-time architecture specific CRC selection Thread-Index: AQHWnkPpDTDq47ZrpEaoVSJovXOSvqmQlDKQ Date: Sat, 10 Oct 2020 09:34:55 +0000 Message-ID: References: <20201006162319.7981-1-mairtin.oloingsigh@intel.com> <20201009135045.8505-1-mairtin.oloingsigh@intel.com> <20201009135045.8505-2-mairtin.oloingsigh@intel.com> In-Reply-To: <20201009135045.8505-2-mairtin.oloingsigh@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 3860A64B075F974982B5FCCF49275B4D.0 x-checkrecipientchecked: true Authentication-Results-Original: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [203.126.0.112] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8d3970fb-25ad-4f0c-586b-08d86cffc6a3 x-ms-traffictypediagnostic: VI1PR08MB2704:|VE1PR08MB5727: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AWVBGJtKUHBij1KAlLkIdmjuRlRVTZC56hwRxQ//jAuNnjwjnWV4xGb6Nj2VPvKMDVX/a79H5MkzX1qSPHQzm3rl1f8VgVTdysPwQByoW6J3eDcmMoVapzMVRq3BqZAX4UrW0GOV0o4VCsSQWVUSFGGqr53PMkNPyyF1MVmoz+HOGpaAM0+daEi7hjvmwWyisD86se6eId54AWjlG5zCw5EovZ7PR/ubL0uFNwC+lFELt+I3dBkbKn969O7lrNCAaDFD/pXaL5NfnHehO9QYXufFJbZ6O7gm8RhgziZSW/n1RIUF+Z04ndoF01aoJl2wPa6IXDbYdZ8MaX6KMaC5nw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0802MB2351.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(136003)(39850400004)(396003)(55016002)(83380400001)(71200400001)(8936002)(478600001)(86362001)(5660300002)(7696005)(9686003)(6506007)(26005)(186003)(53546011)(52536014)(316002)(54906003)(110136005)(30864003)(2906002)(33656002)(76116006)(66946007)(66446008)(66556008)(66476007)(64756008)(4326008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: WskK+4FuEZwngQkKwlITn91sbr1XtlPp2HHJg1zbB/831RzRg9qlAlUrszcTMzlTTcT2FipvbxUTanRlpTT1JjS42yS5NtaeR73iv+hBjqhZWQy3XO/TfRFev69lJxkHFFotnRXQsN96LZGlJlsft5rsBPj3uo+IuKIz4yRatYQZ3ucGjv1BsxF6cd4YBWKiQWP8BZg5nZBADsgmu3urmYp+kIVK+olucMMtruT0XYoWwTUEUqcaifoc6bw+0AiH5demuU/CZbLYZV5znkjL7WfrpbrrGcT8AZc3pXW6LTvuI2Gfzk9AeknBaiUSmbx3deQ7SWCSOLLIgw69mkKlertRUsCQQoYwdJTAO0UvDOJgp6E/jghSsUXkNMpdpcoomEq/fOkH6sNd+JYOAdJdZHJoqyg3HPwNyB25e61bTJ0gFZ6CYVqo5WVmSDSd0Ppgw3s0mFZqHi38J9G1tfsTrQXB+tm+M4Kw0+DyDGw+jsRvRVIWKBnqMWbX+WhpeSAWw2Tyn/xD6/+Rt/G58W+eacC6gVpYDGqYKLOJ8ujNf4T9mBvLca1IRGZOqUPFvrG1bz5W91G5POORzI44kTTlXUc9IM4h9RYua1bUzFPKLQWueGQBhTGTMpz1l57I9NHz5jWou0tx3NTKBWfcK1AVBw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2704 Original-Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 0cf200a2-6e63-4d8c-6ba4-08d86cffbf9b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JVSyy+hOF8yZsJMdzFUakgvavZlIt09NYRUlRAbZsZR4V4TDphHB/brsmYRn8KFjIZxIg0N4uYtO4E0I+bKC5g1cWlZCvnEkqdWsSvjpN7A3CyWYi8JNjjIvH7RR3arZjYsDgpCEwPUEQkfpzLgY8TVyAoSHAPLwdwh2LsXzTwEiH5qWKXK3iUqfFDEvN+t2toNBhHyhWCrvTIpI6wjKEXL4QvPLLXyOojdRhUK1IdaVBv5aWr4TdAJ1E7+N6Lf3tKRUp4h//eoOkQBr31/Zeo2aVSiPQA31NSy6zgR4jhlzjTXW7L4aMS9MgjjY88LY8xbc2y+9rIRwWg9j04LL/5wtxXsPEGD4Pk9O6jCIpKwvZ8ZgCTjdFJ5ipuk2Rq1HlI7SX1aQ8DiCznP2j0tNJQ== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(136003)(346002)(376002)(39850400004)(396003)(46966005)(478600001)(7696005)(55016002)(6506007)(53546011)(9686003)(2906002)(70586007)(110136005)(70206006)(33656002)(336012)(82740400003)(47076004)(52536014)(4326008)(8936002)(83380400001)(86362001)(356005)(54906003)(81166007)(316002)(186003)(82310400003)(26005)(5660300002)(30864003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2020 09:35:07.7899 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d3970fb-25ad-4f0c-586b-08d86cffc6a3 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5727 Subject: Re: [dpdk-dev] [PATCH v5 1/2] net: add run-time architecture specific CRC selection X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" > -----Original Message----- > From: dev On Behalf Of Mairtin o Loingsigh > Sent: Friday, October 9, 2020 9:51 PM > To: jasvinder.singh@intel.com; bruce.richardson@intel.com; > pablo.de.lara.guarch@intel.com; konstantin.ananyev@intel.com > Cc: dev@dpdk.org; brendan.ryan@intel.com; mairtin.oloingsigh@intel.com; > david.coyle@intel.com > Subject: [dpdk-dev] [PATCH v5 1/2] net: add run-time architecture specifi= c > CRC selection >=20 > This patch adds support for run-time selection of the optimal architectur= e- > specific CRC path, based on the supported instruction set(s) of the CPU. >=20 > The compiler option checks have been moved from the C files to the meson > script. The rte_cpu_get_flag_enabled function is called automatically by = the > library at process initialization time to determine which instructions th= e CPU > supports, with the most optimal supported CRC path ultimately selected. >=20 > Signed-off-by: Mairtin o Loingsigh > Signed-off-by: David Coyle > Acked-by: Konstantin Ananyev > --- > doc/guides/rel_notes/release_20_11.rst | 4 + > lib/librte_net/meson.build | 34 ++++++- > lib/librte_net/net_crc.h | 34 +++++++ > lib/librte_net/{net_crc_neon.h =3D> net_crc_neon.c} | 26 ++--- > lib/librte_net/{net_crc_sse.h =3D> net_crc_sse.c} | 34 ++----- > lib/librte_net/rte_net_crc.c | 116 +++++++++++++++-= ------ > 6 files changed, 168 insertions(+), 80 deletions(-) create mode 100644 > lib/librte_net/net_crc.h rename lib/librte_net/{net_crc_neon.h =3D> > net_crc_neon.c} (95%) rename lib/librte_net/{net_crc_sse.h =3D> > net_crc_sse.c} (94%) >=20 > diff --git a/doc/guides/rel_notes/release_20_11.rst > b/doc/guides/rel_notes/release_20_11.rst > index 808bdc4e5..b77297f7e 100644 > --- a/doc/guides/rel_notes/release_20_11.rst > +++ b/doc/guides/rel_notes/release_20_11.rst > @@ -55,6 +55,10 @@ New Features > Also, make sure to start the actual text at the margin. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D >=20 > +* **Updated CRC modules of rte_net library.** > + > + * Added run-time selection of the optimal architecture-specific CRC pa= th. > + > * **Updated Broadcom bnxt driver.** >=20 > Updated the Broadcom bnxt driver with new features and improvements, > including: > diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build inde= x > 24ed8253b..fa439b9e5 100644 > --- a/lib/librte_net/meson.build > +++ b/lib/librte_net/meson.build > @@ -1,5 +1,5 @@ > # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2017 Intel > Corporation > +# Copyright(c) 2017-2020 Intel Corporation >=20 > headers =3D files('rte_ip.h', > 'rte_tcp.h', > @@ -20,3 +20,35 @@ headers =3D files('rte_ip.h', >=20 > sources =3D files('rte_arp.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.= c') deps +=3D > ['mbuf'] > + > +if dpdk_conf.has('RTE_ARCH_X86_64') > + net_crc_sse42_cpu_support =3D ( > + cc.get_define('__PCLMUL__', args: machine_args) !=3D '') > + net_crc_sse42_cc_support =3D ( > + cc.has_argument('-mpclmul') and cc.has_argument('-maes')) > + > + build_static_net_crc_sse42_lib =3D 0 > + > + if net_crc_sse42_cpu_support =3D=3D true > + sources +=3D files('net_crc_sse.c') > + cflags +=3D ['-DCC_X86_64_SSE42_PCLMULQDQ_SUPPORT'] > + elif net_crc_sse42_cc_support =3D=3D true > + build_static_net_crc_sse42_lib =3D 1 > + net_crc_sse42_lib_cflags =3D ['-mpclmul', '-maes'] > + cflags +=3D ['-DCC_X86_64_SSE42_PCLMULQDQ_SUPPORT'] > + endif > + > + if build_static_net_crc_sse42_lib =3D=3D 1 > + net_crc_sse42_lib =3D static_library( > + 'net_crc_sse42_lib', > + 'net_crc_sse.c', > + dependencies: static_rte_eal, > + c_args: [cflags, > + net_crc_sse42_lib_cflags]) > + objs +=3D net_crc_sse42_lib.extract_objects('net_crc_sse.c') > + endif > +elif (dpdk_conf.has('RTE_ARCH_ARM64') and > + cc.get_define('__ARM_FEATURE_CRYPTO', args: > machine_args) !=3D '') > + sources +=3D files('net_crc_neon.c') > + cflags +=3D ['-DCC_ARM64_NEON_PMULL_SUPPORT'] endif > diff --git a/lib/librte_net/net_crc.h b/lib/librte_net/net_crc.h new file= mode > 100644 index 000000000..a1578a56c > --- /dev/null > +++ b/lib/librte_net/net_crc.h > @@ -0,0 +1,34 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > +#ifndef _NET_CRC_H_ > +#define _NET_CRC_H_ > + > +/* > + * Different implementations of CRC > + */ > + > +/* SSE4.2 */ > + > +void > +rte_net_crc_sse42_init(void); > + > +uint32_t > +rte_crc16_ccitt_sse42_handler(const uint8_t *data, uint32_t data_len); > + > +uint32_t > +rte_crc32_eth_sse42_handler(const uint8_t *data, uint32_t data_len); > + > +/* NEON */ > + > +void > +rte_net_crc_neon_init(void); > + > +uint32_t > +rte_crc16_ccitt_neon_handler(const uint8_t *data, uint32_t data_len); > + > +uint32_t > +rte_crc32_eth_neon_handler(const uint8_t *data, uint32_t data_len); > + > +#endif /* _NET_CRC_H_ */ > diff --git a/lib/librte_net/net_crc_neon.h b/lib/librte_net/net_crc_neon.= c > similarity index 95% rename from lib/librte_net/net_crc_neon.h rename to > lib/librte_net/net_crc_neon.c index 63fa1d4a1..f61d75a8c 100644 > --- a/lib/librte_net/net_crc_neon.h > +++ b/lib/librte_net/net_crc_neon.c > @@ -2,17 +2,15 @@ > * Copyright(c) 2017 Cavium, Inc > */ >=20 > -#ifndef _NET_CRC_NEON_H_ > -#define _NET_CRC_NEON_H_ > +#include >=20 > +#include > #include > #include > #include > #include >=20 > -#ifdef __cplusplus > -extern "C" { > -#endif > +#include "net_crc.h" >=20 > /** PMULL CRC computation context structure */ struct crc_pmull_ctx > { @@ -218,7 +216,7 @@ crc32_eth_calc_pmull( > return n; > } >=20 > -static inline void > +void > rte_net_crc_neon_init(void) > { > /* Initialize CRC16 data */ > @@ -242,9 +240,8 @@ rte_net_crc_neon_init(void) > crc32_eth_pmull.rk7_rk8 =3D vld1q_u64(eth_k7_k8); } >=20 > -static inline uint32_t > -rte_crc16_ccitt_neon_handler(const uint8_t *data, > - uint32_t data_len) > +uint32_t > +rte_crc16_ccitt_neon_handler(const uint8_t *data, uint32_t data_len) > { > return (uint16_t)~crc32_eth_calc_pmull(data, > data_len, > @@ -252,18 +249,11 @@ rte_crc16_ccitt_neon_handler(const uint8_t *data, > &crc16_ccitt_pmull); > } >=20 > -static inline uint32_t > -rte_crc32_eth_neon_handler(const uint8_t *data, > - uint32_t data_len) > +uint32_t > +rte_crc32_eth_neon_handler(const uint8_t *data, uint32_t data_len) > { > return ~crc32_eth_calc_pmull(data, > data_len, > 0xffffffffUL, > &crc32_eth_pmull); > } > - > -#ifdef __cplusplus > -} > -#endif > - > -#endif /* _NET_CRC_NEON_H_ */ > diff --git a/lib/librte_net/net_crc_sse.h b/lib/librte_net/net_crc_sse.c > similarity index 94% rename from lib/librte_net/net_crc_sse.h rename to > lib/librte_net/net_crc_sse.c index 1c7b7a548..053b54b39 100644 > --- a/lib/librte_net/net_crc_sse.h > +++ b/lib/librte_net/net_crc_sse.c > @@ -1,18 +1,16 @@ > /* SPDX-License-Identifier: BSD-3-Clause > - * Copyright(c) 2017 Intel Corporation > + * Copyright(c) 2017-2020 Intel Corporation > */ >=20 > -#ifndef _RTE_NET_CRC_SSE_H_ > -#define _RTE_NET_CRC_SSE_H_ > +#include >=20 > +#include > #include > +#include >=20 > -#include > -#include > +#include "net_crc.h" >=20 > -#ifdef __cplusplus > -extern "C" { > -#endif > +#include >=20 > /** PCLMULQDQ CRC computation context structure */ struct > crc_pclmulqdq_ctx { @@ -259,8 +257,7 @@ crc32_eth_calc_pclmulqdq( > return n; > } >=20 > - > -static inline void > +void > rte_net_crc_sse42_init(void) > { > uint64_t k1, k2, k5, k6; > @@ -303,12 +300,10 @@ rte_net_crc_sse42_init(void) > * use other data types such as float, double, etc. > */ > _mm_empty(); > - > } >=20 > -static inline uint32_t > -rte_crc16_ccitt_sse42_handler(const uint8_t *data, > - uint32_t data_len) > +uint32_t > +rte_crc16_ccitt_sse42_handler(const uint8_t *data, uint32_t data_len) > { > /** return 16-bit CRC value */ > return (uint16_t)~crc32_eth_calc_pclmulqdq(data, > @@ -317,18 +312,11 @@ rte_crc16_ccitt_sse42_handler(const uint8_t *data, > &crc16_ccitt_pclmulqdq); > } >=20 > -static inline uint32_t > -rte_crc32_eth_sse42_handler(const uint8_t *data, > - uint32_t data_len) > +uint32_t > +rte_crc32_eth_sse42_handler(const uint8_t *data, uint32_t data_len) > { > return ~crc32_eth_calc_pclmulqdq(data, > data_len, > 0xffffffffUL, > &crc32_eth_pclmulqdq); > } > - > -#ifdef __cplusplus > -} > -#endif > - > -#endif /* _RTE_NET_CRC_SSE_H_ */ > diff --git a/lib/librte_net/rte_net_crc.c b/lib/librte_net/rte_net_crc.c = index > 4f5b9e828..d271d5205 100644 > --- a/lib/librte_net/rte_net_crc.c > +++ b/lib/librte_net/rte_net_crc.c > @@ -1,5 +1,5 @@ > /* SPDX-License-Identifier: BSD-3-Clause > - * Copyright(c) 2017 Intel Corporation > + * Copyright(c) 2017-2020 Intel Corporation > */ >=20 > #include > @@ -10,17 +10,7 @@ > #include > #include >=20 > -#if defined(RTE_ARCH_X86_64) && defined(__PCLMUL__) > -#define X86_64_SSE42_PCLMULQDQ 1 > -#elif defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_CRYPTO) > -#define ARM64_NEON_PMULL 1 > -#endif > - > -#ifdef X86_64_SSE42_PCLMULQDQ > -#include > -#elif defined ARM64_NEON_PMULL > -#include > -#endif > +#include "net_crc.h" >=20 > /** CRC polynomials */ > #define CRC32_ETH_POLYNOMIAL 0x04c11db7UL @@ -41,25 +31,27 @@ > rte_crc32_eth_handler(const uint8_t *data, uint32_t data_len); typedef > uint32_t (*rte_net_crc_handler)(const uint8_t *data, uint32_t data_len); >=20 > -static rte_net_crc_handler *handlers; > +static const rte_net_crc_handler *handlers; >=20 > -static rte_net_crc_handler handlers_scalar[] =3D { > +static const rte_net_crc_handler handlers_scalar[] =3D { > [RTE_NET_CRC16_CCITT] =3D rte_crc16_ccitt_handler, > [RTE_NET_CRC32_ETH] =3D rte_crc32_eth_handler, }; > - > -#ifdef X86_64_SSE42_PCLMULQDQ > -static rte_net_crc_handler handlers_sse42[] =3D { > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT static const > +rte_net_crc_handler handlers_sse42[] =3D { > [RTE_NET_CRC16_CCITT] =3D rte_crc16_ccitt_sse42_handler, > [RTE_NET_CRC32_ETH] =3D rte_crc32_eth_sse42_handler, }; -#elif > defined ARM64_NEON_PMULL -static rte_net_crc_handler handlers_neon[] > =3D { > +#endif > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > +static const rte_net_crc_handler handlers_neon[] =3D { > [RTE_NET_CRC16_CCITT] =3D rte_crc16_ccitt_neon_handler, > [RTE_NET_CRC32_ETH] =3D rte_crc32_eth_neon_handler, }; #endif >=20 > +/* Scalar handling */ > + > /** > * Reflect the bits about the middle > * > @@ -142,29 +134,82 @@ rte_crc32_eth_handler(const uint8_t *data, > uint32_t data_len) > crc32_eth_lut); > } >=20 > +/* SSE4.2/PCLMULQDQ handling */ > + > +#define SSE42_PCLMULQDQ_CPU_SUPPORTED \ > + rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ) > + > +static const rte_net_crc_handler * > +sse42_pclmulqdq_get_handlers(void) > +{ > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT > + if (SSE42_PCLMULQDQ_CPU_SUPPORTED) > + return handlers_sse42; > +#endif > + return NULL; > +} > + > +static uint8_t > +sse42_pclmulqdq_init(void) > +{ > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT > + if (SSE42_PCLMULQDQ_CPU_SUPPORTED) { > + rte_net_crc_sse42_init(); > + return 1; > + } > +#endif > + return 0; > +} > + > +/* NEON/PMULL handling */ > + > +#define NEON_PMULL_CPU_SUPPORTED \ > + rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL) > + > +static const rte_net_crc_handler * > +neon_pmull_get_handlers(void) > +{ > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > + if (NEON_PMULL_CPU_SUPPORTED) > + return handlers_neon; > +#endif > + return NULL; > +} > + > +static uint8_t > +neon_pmull_init(void) > +{ > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > + if (NEON_PMULL_CPU_SUPPORTED) { > + rte_net_crc_neon_init(); > + return 1; > + } > +#endif > + return 0; > +} > + > +/* Public API */ > + > void > rte_net_crc_set_alg(enum rte_net_crc_alg alg) { > + handlers =3D NULL; > + > switch (alg) { > -#ifdef X86_64_SSE42_PCLMULQDQ > case RTE_NET_CRC_SSE42: > - handlers =3D handlers_sse42; > - break; > -#elif defined ARM64_NEON_PMULL > - /* fall-through */ > + handlers =3D sse42_pclmulqdq_get_handlers(); > + break; /* for x86, always break here */ > case RTE_NET_CRC_NEON: > - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL)) { > - handlers =3D handlers_neon; > - break; > - } > -#endif > + handlers =3D neon_pmull_get_handlers(); > /* fall-through */ > case RTE_NET_CRC_SCALAR: > /* fall-through */ > default: > - handlers =3D handlers_scalar; > break; > } > + > + if (handlers =3D=3D NULL) > + handlers =3D handlers_scalar; > } >=20 > uint32_t > @@ -188,15 +233,10 @@ RTE_INIT(rte_net_crc_init) >=20 > rte_net_crc_scalar_init(); >=20 > -#ifdef X86_64_SSE42_PCLMULQDQ > - alg =3D RTE_NET_CRC_SSE42; > - rte_net_crc_sse42_init(); > -#elif defined ARM64_NEON_PMULL > - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL)) { > + if (sse42_pclmulqdq_init()) > + alg =3D RTE_NET_CRC_SSE42; > + if (neon_pmull_init()) > alg =3D RTE_NET_CRC_NEON; > - rte_net_crc_neon_init(); > - } > -#endif >=20 > rte_net_crc_set_alg(alg); > } > -- > 2.12.3 The change looks good to me. Reviewed-by: Ruifeng Wang