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 BA0B0A04BA; Wed, 7 Oct 2020 16:59:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2684F1BC86; Wed, 7 Oct 2020 16:59:34 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 9C6A81BC84 for ; Wed, 7 Oct 2020 16:59:32 +0200 (CEST) IronPort-SDR: 2cIBGC3YRUpXF5XRErbnEghytp707WEoqWYtTwQZA5aYyNv4Ov6r6tyOxUlpuokt9LP7LtP0Nj cLI/X9DQmtSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9767"; a="152737493" X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="152737493" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 07:59:30 -0700 IronPort-SDR: ZJ5uamVyQww65paSxyY6imXsvoOUT8CCbqMzNrIO1Zr8yM7n6sNTBJhaWOC3gzDrRlWWS8iaPB RBk/ciPy9+cQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="517836460" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga006.fm.intel.com with ESMTP; 07 Oct 2020 07:59:29 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 7 Oct 2020 07:59:29 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 7 Oct 2020 07:59:28 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 7 Oct 2020 07:59:28 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.49) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 7 Oct 2020 07:59:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PcThw88TBhgcnNf7Eu/Q++hssYZW5LBZTfxwT/ZwRNsLmbwcOx9legulFtXLUN1myNDEwef1pEcgbf/gf9I2k02tg5I7/vGhUquXpnQQO86tBLQlnGpQOfAlN4JRmrjevJ3h5MmbesWhZONhlubxByxt5loN5byEe09FMdv9mc285cYAHN6tgIUYhGvpsEttcFFg/vVuY+yMiGwhvyQBydQSV/e6ZpV+Vbhgs5DFaSJ+B+1ayNeCq+Sf6XvCzlncHDP6id5pZWj/1nWZtefp7C5+IulH6tG+rGSNOg4OOGG6JVnI6Y3m7h9zgroVIVIh/+F1rYMgzacKVdW6vhDyQA== 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=EML+yBdNM3rWvP4o479Hx531WZ3Mf6/WadEogGoIXy8=; b=XIJOkCVLeOjl+Qs1EAvPPYB9506XecDNAsJTTZ1nX0ElZzfKxFOErbDUGuQnpIoCbaTTD2c7iFF3/jB0RL2KzMmQLJOIC4htUDELrmy1AYTzf8QbNOsjgPrn7bP1iQlIKFsVTHxjy6PCVwntcbSdpl0sq9UIVukcN7ihgNM1Ex1EOOcgzSRrNdy55lOR70dZxenIOKSs/SXbfAKz2O0mJPSybf3aUo4LPdjT1V7B6Y8uwJ+VuKFnIn92K5BkNqVSboADT4DJjTekkSQLC3vwzYg+vdWYzo7U4HySV6tpBQ/DoFMeNreIDegOgx6Ed+mBy82m66piLg34MVW+lP01RA== 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=EML+yBdNM3rWvP4o479Hx531WZ3Mf6/WadEogGoIXy8=; b=nrCow9ycAvoGrKJrIR9xrGaasFRR+fAq0FLbljCCJtu1WJ+SkaGoz3ltrdMP1hbBVSqreNyL6Q031Pr+n9hf7pebpDYr8JoqGgOuUXpTO0T1Uhyj8xye8cs4V2uAxR1pHUXWI4l0Ehz1cAMf1nlNhpdfwBamOrcbgGL/nm9C0Yk= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3621.namprd11.prod.outlook.com (2603:10b6:a03:fc::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32; Wed, 7 Oct 2020 14:59:24 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f5a4:3f6b:ade3:296b]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f5a4:3f6b:ade3:296b%3]) with mapi id 15.20.3455.023; Wed, 7 Oct 2020 14:59:24 +0000 From: "Ananyev, Konstantin" To: "O'loingsigh, Mairtin" , "Singh, Jasvinder" , "Richardson, Bruce" , "De Lara Guarch, Pablo" CC: "dev@dpdk.org" , "Ryan, Brendan" , "O'loingsigh, Mairtin" , "Coyle, David" Thread-Topic: [dpdk-dev] [PATCH v4 1/2] net: add run-time architecture specific CRC selection Thread-Index: AQHWm/1wHYj+FT4p1UG9Gswdu4W1mKmMOZ+Q Date: Wed, 7 Oct 2020 14:59:23 +0000 Message-ID: References: <1601393761-11588-1-git-send-email-mairtin.oloingsigh@intel.com> <20201006162319.7981-1-mairtin.oloingsigh@intel.com> <20201006162319.7981-2-mairtin.oloingsigh@intel.com> In-Reply-To: <20201006162319.7981-2-mairtin.oloingsigh@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [46.7.39.127] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3725faa4-715b-4b87-d099-08d86ad1944e x-ms-traffictypediagnostic: BYAPR11MB3621: 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:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: J9exKpGVABlUhmJfslfU6gCzdzzWAl2sGYQxw/QzsGWwXRb81azlT3QQnWyIk2kvDmQZbDfJZw/hqZjH+bKjGvQtscykto8hRTzULPyvB6kglqPt64u/b+0oPRcCEkjBiZgi4YZffhBCFhm/7LfryxkPUyjUEh1R2b0JxPgaz2irDnMyfCh+dN8RjCvvuMcYsDIP1GfFbUDOvFvVII8/mEL9cAY2iPmyeRLJOvZO7AvbohxAMNUfFn8/o2TGVu/Cbt+NMkH7qf9WzTyg+hZefM9M+FuyKISUpkeLk5Xd7MvXvTMlhOzFrW+GcajgwOXcqMINBeNax03CowTVhmgStQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(366004)(396003)(4326008)(26005)(8936002)(6506007)(83380400001)(478600001)(7696005)(66476007)(55016002)(5660300002)(316002)(66946007)(30864003)(186003)(52536014)(71200400001)(86362001)(54906003)(76116006)(6636002)(33656002)(110136005)(107886003)(66556008)(64756008)(2906002)(66446008)(9686003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: q9I4xudbw+ETKAQKdHFYagSsm+YJxzMSGBvEoJha4TDuAysB2iQFSRCDsH9RRIMX6xQVoT+PtYv4m5+B5jm3isoIMoDz9kcoh6eDeCsDKcT5F6POvw6tbw/Hxkebz6IdFVk2jxoeaK++DljyN1EzpKdLcpqSqdeMmO3aNnF5AvQ6h5Ovpn2AAigCsdgpzkpr2BhUpER9J7n7HXe96u4IWRovFntycEYZVU/h4lMyDPF65cmjRL+3jYIBIGjj0MZKb3IDQaRx5umko2JVkvoa+mv9Ush99YcFtmVX/FxqIJQbW2IJG2Cf4hJgKh1lcvwlMNAoP6H0+Txa267lspD8lSPIgYUtMfKMyQmJYzIdPW/CjY2MpxEIzMX/KDlwRzdwlLWKfRjyIbIhCDM8elU4uLY6hAKp6J/uA3jo85n9R5+6xZZPud7DKIUPV1O63yYp4t3Q8XD9X1xngNvw+o/yf9kVmYam26yC1HylVUQbEvD8oSLuu2tm4UMYALLQpBv6wQyEntWsXd3T1qsaflhBOZscXE3kh3GSfVlr+9uUl1cMBmBJMi+crYOhu0yKJ9dcLixtgUFZJ8LU7L69iDwGd68qsRnoRTqV7T038EfCUXRsM5YX1cfQm1bm5P3At8zOp76UkldkDTPPTCkSN+HqOw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3301.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3725faa4-715b-4b87-d099-08d86ad1944e X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2020 14:59:23.9721 (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: sDer0xqgMJgw/rCPyi0pd5w5eu/DP55FeRWarv8u3j3roKYBWwCJjOS/RYbgff5VmYyEYLuDEVaKt0RnILO5JWtgRlFgwDPAn6rIUJFiS1U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3621 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4 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" >=20 > This patch adds support for run-time selection of the optimal > architecture-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 the CPU supports, with the most optimal supported CRC path > ultimately selected. >=20 > Signed-off-by: Mairtin o Loingsigh > Signed-off-by: David Coyle LGTM, just one nit see below. With that: Series 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 | 67 ++++++++++++++---= ------ > 6 files changed, 131 insertions(+), 68 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_note= s/release_20_11.rst > index ca5ec7391..0f14e087d 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, i= ncluding: > diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build > index 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..83dccbfba 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 > @@ -47,13 +37,13 @@ static 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 > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT > static 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 > +#endif > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > static 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, > @@ -142,22 +132,44 @@ rte_crc32_eth_handler(const uint8_t *data, uint32_t= data_len) > crc32_eth_lut); > } >=20 > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT > +static uint8_t > +sse42_pclmulqdq_cpu_supported(void) > +{ > + return rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ); > +} As a nit, I think it would be better to hide #fidef inside the function, and return an 0 when define is not set. Something like: static int sse42_pclmulqdq_cpu_supported(void) { #ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT return rte_cpu_get_flag_enabled(RTE_CPUFLAG_PCLMULQDQ); #else return 0; } Same for other cpu_supported functions. And then you can remove these ifdefs in set_alg and other palces, i.e.: void rte_net_crc_set_alg(enum rte_net_crc_alg alg) { switch (alg) { #ifdef RTE_ARCH_X86_64 case RTE_NET_CRC_AVX512: if (avx512_vpclmulqdq_cpu_supported()) { handlers =3D handlers_avx512; break; } /* fall-through */ case RTE_NET_CRC_SSE42: if (sse42_pclmulqdq_cpu_supported()) { handlers =3D handlers_sse42; break; } #endif ... Same for rte_net_crc_init() > +#endif > + > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > +static uint8_t > +neon_pmull_cpu_supported(void) > +{ > + return rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL); > +} > +#endif > + > void > rte_net_crc_set_alg(enum rte_net_crc_alg alg) > { > switch (alg) { > -#ifdef X86_64_SSE42_PCLMULQDQ > +#ifdef RTE_ARCH_X86_64 > case RTE_NET_CRC_SSE42: > - handlers =3D handlers_sse42; > - break; > -#elif defined ARM64_NEON_PMULL > - /* fall-through */ > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT > + if (sse42_pclmulqdq_cpu_supported()) { > + handlers =3D handlers_sse42; > + break; > + } > +#endif > +#endif /* RTE_ARCH_X86_64 */ > +#ifdef RTE_ARCH_ARM64 > case RTE_NET_CRC_NEON: > - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_PMULL)) { > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > + if (neon_pmull_cpu_supported()) { > handlers =3D handlers_neon; > break; > } > #endif > +#endif /* RTE_ARCH_ARM64 */ > /* fall-through */ > case RTE_NET_CRC_SCALAR: > /* fall-through */ > @@ -188,11 +200,14 @@ 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)) { > +#ifdef CC_X86_64_SSE42_PCLMULQDQ_SUPPORT > + if (sse42_pclmulqdq_cpu_supported()) { > + alg =3D RTE_NET_CRC_SSE42; > + rte_net_crc_sse42_init(); > + } > +#endif > +#ifdef CC_ARM64_NEON_PMULL_SUPPORT > + if (neon_pmull_cpu_supported()) { > alg =3D RTE_NET_CRC_NEON; > rte_net_crc_neon_init(); > } > -- > 2.12.3