From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0057.outbound.protection.outlook.com [104.47.0.57]) by dpdk.org (Postfix) with ESMTP id 749B2A491 for ; Mon, 22 Jan 2018 06:52:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=mwz+DEB8UPjPTA/YMQEnuHY110she2fL7vxkBdwXvjg=; b=loJnjj/IJmig2218vcTazA+H735KAGywjlfRGUnP8egcwZVYI3wREkXOoGV/28Cz2OZNzY8FjPcwoVjN/wdbmtefNH02TFMFi1PgLU7JcuSsx1ZOPVxX6HVgn0Fe2vDiiAI9ZDbLyDqw9ocialXhzszRQYKKAwtNcspYAR2Hlfs= Received: from HE1PR08MB2809.eurprd08.prod.outlook.com (10.170.246.148) by HE1PR08MB2811.eurprd08.prod.outlook.com (10.170.246.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Mon, 22 Jan 2018 05:52:36 +0000 Received: from HE1PR08MB2809.eurprd08.prod.outlook.com ([fe80::4b6:8770:8525:20c5]) by HE1PR08MB2809.eurprd08.prod.outlook.com ([fe80::4b6:8770:8525:20c5%13]) with mapi id 15.20.0428.019; Mon, 22 Jan 2018 05:52:36 +0000 From: Herbert Guan To: Pavan Nikhilesh , "jerin.jacob@caviumnetworks.com" , "bruce.richardson@intel.com" , "harry.van.haaren@intel.com" , "hemant.agrawal@nxp.com" CC: "dev@dpdk.org" , nd Thread-Topic: [dpdk-dev] [PATCH v4 2/2] build: add support for detecting march on ARM Thread-Index: AQHTkVLij44cJzy1VUm31W4qryRaraN/XSZA Date: Mon, 22 Jan 2018 05:52:36 +0000 Message-ID: References: <20171219105338.198727-1-bruce.richardson@intel.com> <20180119182349.21935-1-pbhagavatula@caviumnetworks.com> <20180119182349.21935-2-pbhagavatula@caviumnetworks.com> In-Reply-To: <20180119182349.21935-2-pbhagavatula@caviumnetworks.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Herbert.Guan@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR08MB2811; 7:wRfvNYwe7Zag1m63GLbT+1f7Y/XI8uQuNjB/xJF5W675EaqUbXlHSSdukTNzbA6TR4wKpU8cMhJenPaIRWQDQiW+JrJU5qGJl1mn3ZRe5MG3EQ5GYcOZ/8LUxFapJ/t4jQXHUS6/5Oj70BPojwg/iL9IgtKMow149OPabIvK6mEixPUjjyC17Z3umV6Xk6x6EwoLOZiWHV/iSpM3rn96nUbTfu0JbTLHBeHxW24ZusolFnhQp5T0rG7/Q7Qubcxt x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: a1584c52-9507-4e1b-9383-08d5615c56c8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(48565401081)(2017052603307)(7153060)(7193020); SRVR:HE1PR08MB2811; x-ms-traffictypediagnostic: HE1PR08MB2811: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR08MB2811; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR08MB2811; x-forefront-prvs: 0560A2214D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(39380400002)(366004)(39850400004)(396003)(199004)(13464003)(189003)(53546011)(6506007)(72206003)(5660300001)(2501003)(478600001)(7696005)(76176011)(102836004)(26005)(3660700001)(106356001)(3280700002)(2950100002)(5250100002)(14454004)(59450400001)(66066001)(2201001)(86362001)(305945005)(97736004)(7736002)(74316002)(575784001)(99286004)(8656006)(316002)(68736007)(110136005)(81166006)(8676002)(54906003)(3846002)(8936002)(81156014)(6116002)(9686003)(6246003)(33656002)(55016002)(25786009)(53936002)(4326008)(2900100001)(229853002)(105586002)(2906002)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR08MB2811; H:HE1PR08MB2809.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: uAU2Yb4uNDoK2/k1zQL7f4t1H9mCWDTlkLm3aF25D3ZpBixPfhEkoQ3tv28tJqmGE4ZFoHMo5e90+52mgG087w== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1584c52-9507-4e1b-9383-08d5615c56c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jan 2018 05:52:36.1632 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2811 Subject: Re: [dpdk-dev] [PATCH v4 2/2] build: add support for detecting march on ARM 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: , X-List-Received-Date: Mon, 22 Jan 2018 05:52:38 -0000 Hi, Pavan Please see my notes inline. Best regards, Herbert > -----Original Message----- > From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com] > Sent: Saturday, January 20, 2018 2:24 > To: jerin.jacob@caviumnetworks.com; bruce.richardson@intel.com; > harry.van.haaren@intel.com; Herbert Guan ; > hemant.agrawal@nxp.com > Cc: dev@dpdk.org; Pavan Nikhilesh > Subject: [dpdk-dev] [PATCH v4 2/2] build: add support for detecting march > on ARM >=20 > Added support for detecting march and mcpu by reading midr_el1 register. > The implementer, primary part number values read can be used to figure ou= t > the underlying arm cpu. >=20 > Signed-off-by: Pavan Nikhilesh > --- > app/test-pmd/meson.build | 2 +- > config/arm/armv8_machine.py | 18 +++++++++++ > config/arm/meson.build | 76 > ++++++++++++++++++++++++++++++++++++++++----- > config/meson.build | 19 ++++++------ > drivers/meson.build | 2 +- > examples/meson.build | 2 +- > lib/meson.build | 2 +- > meson.build | 2 +- > test/test/meson.build | 2 +- > 9 files changed, 102 insertions(+), 23 deletions(-) create mode 100755 > config/arm/armv8_machine.py >=20 > diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build index > e819677a5..2a3f0ba1f 100644 > --- a/app/test-pmd/meson.build > +++ b/app/test-pmd/meson.build > @@ -45,7 +45,7 @@ endif >=20 > executable('dpdk-testpmd', > sources, > - c_args: machine_arg, > + c_args: machine_args, > link_whole: link_libs, > dependencies: dep_objs, > install_rpath: join_paths(get_option('prefix'), driver_install_path), > diff --git a/config/arm/armv8_machine.py b/config/arm/armv8_machine.py > new file mode 100755 index 000000000..404866d2f > --- /dev/null > +++ b/config/arm/armv8_machine.py > @@ -0,0 +1,18 @@ > +#!/usr/bin/python > +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Cavium, Inc > + > +ident =3D [] > +fname =3D '/sys/devices/system/cpu/cpu0/regs/identification/midr_el1' > +with open(fname) as f: > + content =3D f.read() > + > +midr_el1 =3D (int(content.rstrip('\n'), 16)) > + > +ident.append(hex((midr_el1 >> 24) & 0xFF)) # Implementer > +ident.append(hex((midr_el1 >> 20) & 0xF)) # Variant > +ident.append(hex((midr_el1 >> 16) & 0XF)) # Architecture > +ident.append(hex((midr_el1 >> 4) & 0xFFF)) # Primary Part number > +ident.append(hex(midr_el1 & 0xF)) # Revision > + > +print(' '.join(ident)) > diff --git a/config/arm/meson.build b/config/arm/meson.build index > f05de4c2c..1bed82236 100644 > --- a/config/arm/meson.build > +++ b/config/arm/meson.build > @@ -5,28 +5,88 @@ > # for checking defines we need to use the correct compiler flags march_= opt > =3D '-march=3D@0@'.format(machine) >=20 > +machine_args_cavium =3D [ > + ['default', ['-march=3Darmv8-a+crc+crypto','-mcpu=3Dthunderx']], > + ['0xa1', ['-mcpu=3Dthunderxt88']], > + ['0xa2', ['-mcpu=3Dthunderxt81']], > + ['0xa3', ['-mcpu=3Dthunderxt83']]] > + > +flags_cavium =3D [ > + ['RTE_MACHINE', '"thunderx"'], > + ['RTE_CACHE_LINE_SIZE', 128], > + ['RTE_MAX_NUMA_NODES', 2], > + ['RTE_MAX_LCORE', 96], > + ['RTE_MAX_VFIO_GROUPS', 128], > + ['RTE_RING_USE_C11_MEM_MODEL', false]] > + > +impl_0x43 =3D ['Cavium', flags_cavium, machine_args_cavium] There're only Cavimu args/flags defined, so other arm/arm64 platforms will = fail at detecting. Can you add one entry for default? > + > +dpdk_conf.set_quoted('RTE_TOOLCHAIN', 'gcc') > +dpdk_conf.set('RTE_TOOLCHAIN_GCC', 1) > dpdk_conf.set('RTE_FORCE_INTRINSICS', 1) -if cc.sizeof('void *') =3D=3D = 8 > - dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128) > - dpdk_conf.set('RTE_ARCH_ARM64', 1) > - dpdk_conf.set('RTE_ARCH_64', 1) > -else > + > +if cc.sizeof('void *') !=3D 8 > dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64) > dpdk_conf.set('RTE_ARCH_ARM', 1) > dpdk_conf.set('RTE_ARCH_ARMv7', 1) > +else > + dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128) > + dpdk_conf.set('RTE_ARCH_ARM64', 1) > + dpdk_conf.set('RTE_ARCH_64', 1) > + > + if not meson.is_cross_build() > + # The script returns ['Implementor', 'Variant', 'Architecture', > + # 'Primary Part number', 'Revision'] > + detect_vendor =3D find_program(join_paths( > + meson.current_source_dir(), > 'armv8_machine.py')) > + cmd =3D run_command(detect_vendor.path()) > + if cmd.returncode() !=3D 0 > + message('Using default armv8 config') > + else > + machine_args =3D [] # Clear previous machine args > + cmd_output =3D cmd.stdout().strip().split(' ') > + machine =3D get_variable('impl_' + cmd_output[0]) Script will fail for non-cavium Arm platforms. We need to check if cmd_out= put[0] is a known value in a list, otherwise should go to default entry. > + message('Implementor : ' + machine[0]) > + > + foreach flag: machine[1] > + dpdk_conf.set(flag[0], flag[1]) > + endforeach > + > + # Primary part number based mcpu flags are > supported > + # for gcc versions > 7 > + if cc.version().version_compare('<7.0') > + foreach marg: machine[2] > + if marg[0] =3D=3D 'default' > + foreach f: marg[1] > + machine_args +=3D f > + endforeach > + endif > + endforeach > + else > + foreach marg: machine[2] > + if marg[0] =3D=3D cmd_output[3] > + foreach f: marg[1] > + machine_args +=3D f > + endforeach > + endif > + endforeach > + endif > + endif > + endif > endif > +message(machine_args) >=20 > -if cc.get_define('__ARM_NEON', args: march_opt) !=3D '' > +if cc.get_define('__ARM_NEON', args: machine_args) !=3D '' > dpdk_conf.set('RTE_MACHINE_CPUFLAG_NEON', 1) > compile_time_cpuflags +=3D ['RTE_CPUFLAG_NEON'] endif >=20 > -if cc.get_define('__ARM_FEATURE_CRC32', args: march_opt) !=3D '' > +if cc.get_define('__ARM_FEATURE_CRC32', args: machine_args) !=3D '' > dpdk_conf.set('RTE_MACHINE_CPUFLAG_CRC32', 1) > compile_time_cpuflags +=3D ['RTE_CPUFLAG_CRC32'] endif >=20 > -if cc.get_define('__ARM_FEATURE_CRYPTO', args: march_opt) !=3D '' > +if cc.get_define('__ARM_FEATURE_CRYPTO', args: machine_args) !=3D '' > dpdk_conf.set('RTE_MACHINE_CPUFLAG_AES', 1) > dpdk_conf.set('RTE_MACHINE_CPUFLAG_PMULL', 1) > dpdk_conf.set('RTE_MACHINE_CPUFLAG_SHA1', 1) diff --git > a/config/meson.build b/config/meson.build index fa55c53a5..f8c67578d > 100644 > --- a/config/meson.build > +++ b/config/meson.build > @@ -8,7 +8,8 @@ else > machine =3D get_option('machine') > endif > dpdk_conf.set('RTE_MACHINE', machine) > -machine_arg =3D '-march=3D' + machine > +machine_args =3D [] > +machine_args +=3D '-march=3D' + machine >=20 > # use pthreads > add_project_link_arguments('-pthread', language: 'c') @@ -53,6 +54,14 @@ > foreach arg: warning_flags > endif > endforeach >=20 > +# set other values pulled from the build options > +dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores')) > +dpdk_conf.set('RTE_MAX_NUMA_NODES', > get_option('max_numa_nodes')) > +dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet')) > +dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', > +get_option('allow_invalid_socket_id')) > +# values which have defaults which may be overridden > +dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64) > + > compile_time_cpuflags =3D [] > if host_machine.cpu_family().startswith('x86') > arch_subdir =3D 'x86' > @@ -65,12 +74,4 @@ dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', > ','.join(compile_time_cpuflags)) # set the install path for the drivers > dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path) >=20 > -# set other values pulled from the build options - > dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores')) - > dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes')) > -dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet')) - > dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', > get_option('allow_invalid_socket_id')) > -# values which have defaults which may be overridden - > dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64) > - > install_headers('rte_config.h', subdir: get_option('include_subdir_arch'= )) > diff --git a/drivers/meson.build b/drivers/meson.build index > 9b5039847..1d6430bfe 100644 > --- a/drivers/meson.build > +++ b/drivers/meson.build > @@ -22,7 +22,7 @@ foreach class:driver_classes > version =3D 1 > sources =3D [] > objs =3D [] > - cflags =3D [machine_arg] > + cflags =3D machine_args > includes =3D [include_directories(drv_path)] > # set up internal deps. Drivers can append/override as > necessary > deps =3D std_deps > diff --git a/examples/meson.build b/examples/meson.build index > 0abed7169..b3f997242 100644 > --- a/examples/meson.build > +++ b/examples/meson.build > @@ -9,7 +9,7 @@ endif > foreach example: get_option('examples').split(',') > name =3D example > sources =3D [] > - cflags =3D [machine_arg] > + cflags =3D machine_args > ext_deps =3D [] > includes =3D [include_directories(example)] > deps =3D ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] diff --= git > a/lib/meson.build b/lib/meson.build index 0c94d74b9..b9ea6f61b 100644 > --- a/lib/meson.build > +++ b/lib/meson.build > @@ -31,7 +31,7 @@ foreach l:libraries > sources =3D [] > headers =3D [] > includes =3D [] > - cflags =3D [machine_arg] > + cflags =3D machine_args > objs =3D [] # other object files to link against, used e.g. for > # instruction-set optimized versions of code >=20 > diff --git a/meson.build b/meson.build > index 3dce8579e..326fbc7d1 100644 > --- a/meson.build > +++ b/meson.build > @@ -66,5 +66,5 @@ pkg.generate(name: meson.project_name(), > ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, > description: 'The Data Plane Development Kit (DPDK)', > subdirs: [get_option('include_subdir_arch'), '.'], > - extra_cflags: ['-include "rte_config.h"', machine_arg] > + extra_cflags: ['-include "rte_config.h"'] + machine_args > ) > diff --git a/test/test/meson.build b/test/test/meson.build index > 1863c603c..873efbc07 100644 > --- a/test/test/meson.build > +++ b/test/test/meson.build > @@ -204,7 +204,7 @@ if get_option('tests') > test_sources, > link_whole: link_libs, > dependencies: test_dep_objs, > - c_args: machine_arg, > + c_args: machine_args, > install_rpath: driver_install_path, > install: false) >=20 > -- > 2.15.1