From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60060.outbound.protection.outlook.com [40.107.6.60]) by dpdk.org (Postfix) with ESMTP id BA9891559 for ; Wed, 5 Sep 2018 23:43:30 +0200 (CEST) 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:X-MS-Exchange-SenderADCheck; bh=hW/Sxi5RgSXdTqdjxjRSWvnqVdNthOHJFawp80vLCpM=; b=WiiJw0wpMdx2FIdqULl3rrhNrfx25oFvweAh3tyqrcsoQajZ5Cnc67IARB8gfTEtXCYoPmDafwO/IfrJPi8f+g5ru+ZQjfk5SGWqen42pjg0QsmCrSmzO/NAtWJPNXMLCUl+FCuYQo7IgwABIYv930hN/XkrdcdPZXx12i8nZdU= Received: from AM5PR0801MB1859.eurprd08.prod.outlook.com (10.168.157.16) by AM5PR0801MB1970.eurprd08.prod.outlook.com (10.168.158.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.17; Wed, 5 Sep 2018 21:43:29 +0000 Received: from AM5PR0801MB1859.eurprd08.prod.outlook.com ([fe80::f847:f383:a483:3d4a]) by AM5PR0801MB1859.eurprd08.prod.outlook.com ([fe80::f847:f383:a483:3d4a%5]) with mapi id 15.20.1101.016; Wed, 5 Sep 2018 21:43:29 +0000 From: Malvika Gupta To: "Ananyev, Konstantin" CC: "dev@dpdk.org" , "Gavin Hu (Arm Technology China)" , Honnappa Nagarahalli , Brian Brooks , nd Thread-Topic: [PATCH] test/bpf: use hton instead of __builtin_bswap Thread-Index: AQHUPxBK9GM4qmAjxku+s3XgHfeEQqTgMAWAgAIP03A= Date: Wed, 5 Sep 2018 21:43:28 +0000 Message-ID: References: <20180828204620.1862-1-Malvika.Gupta@arm.com> <2601191342CEEE43887BDE71AB977258EA9511E7@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB977258EA9511E7@irsmsx105.ger.corp.intel.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=Malvika.Gupta@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM5PR0801MB1970; 6:BooKUheUMxlBaPc2axOoeYtjO9yx4Y2L4D0eakDqT5GVh8fjOrBRM9f5z9wvu1AbkYVu6qJ9vhz26Z0yOxl8rz517mYZ6rDP910T/irdVeklNsJs7BUz5+FLeQPwjN3cNaD5Mt9hnkg7CTg+zMFtZfIFHIrFF0aQSgq91h8hUJa816eNCPEH/eB9MSC7GBA9IMe/naHWNevo77Mbv8woUFLTb9hQqI2NyEEd4/kdhuDJeNpo460BEYr9t15h22szAOTTWe7C9l4OJao2ojgjO862XDiA9q9hlJYPbEcKXk7UX2Y+9nb69Ae8oU8M1Ta1uc10oHy/7kcaLDtKaFXjaw5IVZp77NPjXafqdqWFUA6dUPl68+DE9+F5agykBCTF5GrFYPdhz63jSliBYNzIPoUElNeyAF5bMR9rfSjrXUKP/xj6xuK/23Oll/lwAvUA+NaxGouj/FWCcfUXW5C/jA==; 5:dne1RhvsAJdst6rc9w5UQ59Iz+U1Utk9qE4b2KdeKYv/FbsFUP7Wt21UArLwxC2q4t+CuLHJEg+lXMlljWBkXNrLaynxhwMynU2Rp8ePFBzST5OZWnxZUWqVZsa/ctmjOTL1vuFWAXtj3Jj/rcvkNouojQg8Ur3y/bxevb7SrWQ=; 7:5jYsd5SEZoaQcuUoKq98mDNJHpSczk3knH51iIN3CM4Rqb4fUGbFNMnmbTv+VHq+8EbM2OWh+e9Z6FyVgUPU3yQSVq0J084I7Xd8Aay3yfuN5O81Xx1hJr5HS/AAP9w+QJjJZIQQ55XwAsZ9PGpXp3c+QP/+/OWcSyEBCqEmTSBpaNE5NyqkC8h1Ty+s+CVlmV9hmRDqqcJ4Y1B+HJwy/yJAHOmSbB3+rM2w9ICd/2TuYeNC+YEH4AfC5Itwgyn8 x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 8392c46e-0bc0-4858-3979-08d613789e32 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB1970; x-ms-traffictypediagnostic: AM5PR0801MB1970: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(201708071742011)(7699016); SRVR:AM5PR0801MB1970; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1970; x-forefront-prvs: 078693968A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(396003)(136003)(376002)(346002)(199004)(189003)(13464003)(229853002)(54906003)(74316002)(4326008)(476003)(478600001)(256004)(6506007)(53546011)(2906002)(97736004)(7736002)(2900100001)(72206003)(25786009)(53936002)(86362001)(316002)(102836004)(5250100002)(305945005)(9686003)(6436002)(5660300001)(8676002)(26005)(81156014)(6916009)(105586002)(81166006)(68736007)(106356001)(99286004)(8936002)(55016002)(186003)(486006)(6116002)(3846002)(446003)(6246003)(7696005)(11346002)(76176011)(14454004)(33656002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0801MB1970; H:AM5PR0801MB1859.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8R29IsTwy7T0VVpM3T9Bn/6ld0vLESF9dbVVrntjO0mv4hwgkcUfnMQiSkMFUui/fDWD3hgyckBf/RTHRUSUS/3O/yirOcY4MHMkJnzct/p+dSZyvQksHov/mBeKvPfsuKo6z73fwyu9Gg60F1MlCa3Rr0zXHgV0dOupGR+d+WJ2MmbtMpJoGiyDPR2V+AO8WbocZXlEoSwrxr3bM+egskybqDqd0Sgq2pf15pkO/miiBSzCIpkgKvMXF6DCi2Z4kXiWtplYo5bsoYrAIh2zL7yr1oTOVNG8dSxpKNCxG/RfTYB3P67FhNG1/4POnwSs2+ID8sR12iMJQ0W3+cPTLD1ajBvn8MYg9diRcqZRHdM= 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: 8392c46e-0bc0-4858-3979-08d613789e32 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Sep 2018 21:43:28.8957 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1970 Subject: Re: [dpdk-dev] [PATCH] test/bpf: use hton instead of __builtin_bswap 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: Wed, 05 Sep 2018 21:43:31 -0000 Hi Ananyev, I used clang version 6.0.0. Please see the following output for your refere= nce.=20 $ clang -v=20 clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/6 Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/6.4= .0 Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/7 Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/7.3= .0 Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/8 Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/8.0= .1 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6.4.0 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7.3.0 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/8.0.1 Selected GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/7.3.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 Also, the code compiles with both -O2 and -O0 for me.=20 I hope this was helpful Best, Malvika -----Original Message----- From: Ananyev, Konstantin =20 Sent: Tuesday, September 4, 2018 8:56 AM To: Malvika Gupta Cc: dev@dpdk.org; Gavin Hu (Arm Technology China) ; Honna= ppa Nagarahalli ; Brian Brooks ; nd Subject: RE: [PATCH] test/bpf: use hton instead of __builtin_bswap Hi, >=20 > Convert host machine endianness to networking endianness for=20 > comparison of incoming packets with BPF filter >=20 >=20 > Signed-off-by: Malvika Gupta > Reviewed-by: Gavin Hu > Reviewed-by: Brian Brooks > Suggested-by: Brian Brooks > --- > test/bpf/t1.c | 7 ++++--- > test/bpf/t3.c | 3 ++- > 2 files changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/test/bpf/t1.c b/test/bpf/t1.c index 60f9434ab..7943fcf34=20 > 100644 > --- a/test/bpf/t1.c > +++ b/test/bpf/t1.c > @@ -28,24 +28,25 @@ > #include > #include > #include > +#include >=20 > uint64_t > entry(void *pkt) > { > struct ether_header *ether_header =3D (void *)pkt; >=20 > - if (ether_header->ether_type !=3D __builtin_bswap16(0x0800)) > + if (ether_header->ether_type !=3D htons(0x0800)) Which version of clang do you use? With my one I get: $ clang -O2 -target bpf -c t1.c t1.c:37:34: error: couldn't allocate output register for constraint 'r' if (ether_header->ether_type !=3D ntohs(0x0800)) ^ /usr/include/netinet/in.h:402:21: note: expanded from macro 'ntohs' # define ntohs(x) __bswap_16 (x) ^ /usr/include/bits/byteswap-16.h:31:14: note: expanded from macro '__bswap_1= 6' __asm__ ("rorw $8, %w0" =20 With '-O0' it compiles ok. $ clang -v clang version 4.0.1 (tags/RELEASE_401/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/7 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/7 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Selected multilib: .;@m64 Konstantin > return 0; >=20 > struct iphdr *iphdr =3D (void *)(ether_header + 1); > if (iphdr->protocol !=3D 17 || (iphdr->frag_off & 0x1ffff) !=3D 0 || > - iphdr->daddr !=3D __builtin_bswap32(0x1020304)) > + iphdr->daddr !=3D htonl(0x1020304)) > return 0; >=20 > int hlen =3D iphdr->ihl * 4; > struct udphdr *udphdr =3D (void *)iphdr + hlen; >=20 > - if (udphdr->dest !=3D __builtin_bswap16(5000)) > + if (udphdr->dest !=3D htons(5000)) > return 0; >=20 > return 1; > diff --git a/test/bpf/t3.c b/test/bpf/t3.c index 531b9cb8c..24298b7c7=20 > 100644 > --- a/test/bpf/t3.c > +++ b/test/bpf/t3.c > @@ -17,6 +17,7 @@ > #include > #include > #include "mbuf.h" > +#include >=20 > extern void rte_pktmbuf_dump(FILE *, const struct rte_mbuf *,=20 > unsigned int); >=20 > @@ -29,7 +30,7 @@ entry(const void *pkt) > mb =3D pkt; > eth =3D rte_pktmbuf_mtod(mb, const struct ether_header *); >=20 > - if (eth->ether_type =3D=3D __builtin_bswap16(ETHERTYPE_ARP)) > + if (eth->ether_type =3D=3D htons(ETHERTYPE_ARP)) > rte_pktmbuf_dump(stdout, mb, 64); >=20 > return 1; > -- > 2.17.1