From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00085.outbound.protection.outlook.com [40.107.0.85]) by dpdk.org (Postfix) with ESMTP id 512F94CA2 for ; Wed, 12 Sep 2018 20:46:28 +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=zlhs4Od98+hJLRoOsI/okQGEElZA2h48UDVExjB6vyA=; b=de3Byj3Y9j30zSuWyaZhrca1PRLxecDBkoVolpoHcdCpKkUXAMJf55Q5k3BcpY1iSi/xsgX3KFNNd7Ub+gGT3NNDTJsHdkOnJVgG3F4FxkAe7dF7oYSJtPKzfq72/VDl0T4XqcT0WpW2hALnAzH/IbIhTLUn7CqKCxPWbEB6n1w= Received: from DB6PR0801MB1864.eurprd08.prod.outlook.com (10.168.85.10) by DB6PR0801MB1334.eurprd08.prod.outlook.com (10.168.11.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Wed, 12 Sep 2018 18:46:27 +0000 Received: from DB6PR0801MB1864.eurprd08.prod.outlook.com ([fe80::bda4:f874:718:70b6]) by DB6PR0801MB1864.eurprd08.prod.outlook.com ([fe80::bda4:f874:718:70b6%10]) with mapi id 15.20.1122.018; Wed, 12 Sep 2018 18:46:26 +0000 From: Malvika Gupta To: "Ananyev, Konstantin" CC: "dev@dpdk.org" , "Gavin Hu (Arm Technology China)" , Honnappa Nagarahalli , nd Thread-Topic: [PATCH] test/bpf: use hton instead of __builtin_bswap Thread-Index: AQHUPxBK9GM4qmAjxku+s3XgHfeEQqTgMAWAgAIP03CACssPIA== Date: Wed, 12 Sep 2018 18:46:26 +0000 Message-ID: References: <20180828204620.1862-1-Malvika.Gupta@arm.com> <2601191342CEEE43887BDE71AB977258EA9511E7@irsmsx105.ger.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB1334; 6:ViwVufAw069iUeNOQd1X0Uvtn7WGGk/8F/ROnGu9Wa2cnzyAX7YYiBkP82GVvrYH/ibwm6YXVIorrVZJQqEp0EcFdRrvRTh7kG8dPkMmZOBherNlMLQW3QEelRPKCeFc5f8yL+evs0bAJriblBpj7x0zgJskXCIqEN9ZwQ3DzvRloAazuIEGWlJAQcPJE2v4EWZO65S2asEmjOHgA1XFmteajKDD5kfHHgUCHf1dkjqAXvTB5ETaRP60Z2XgTFEC5B3AKXsE0j1XMXMdD7Drba4JkaFBD2o1iCp2x+YDcVxl5M7T1+kG//Az7QTfUHIg5G0hAyeoU+2GKT+Kp1OBYklUXMKYsv3F1dEPr++8JxI8/EBQ2UiXQs47TeH7D5JGduZTgT2ZuM185uaSEjamhdbH9r1vYQtolfoW1Urz6T8ModbTv/FjQZGdrU5ApIn0NP4gkLLtMFtd+d3ZXRGLCw==; 5:o3A75B+SZ05xOzeYOiRZQcVDL1Kgn0LHOg4RGqWf7dvXynAWwoYDOeh6IMiBkbt7Gn9YxiOWifUMrSs0duYN+ojliGtXfkCHZHSGb2jS6vwvMnLmKBA3ZinY6CUgaJFQvNk1i3b5wkbT1T4LC8ALyCfgFDIBeNiVlIESFV9fEvE=; 7:lHKrD5bdOa4xpp9llu+/QAgpYiLHVqagSkvttyR1GKEQoVDOd7NdDX2J3t3h0hsOGIeaXSj4Qj1StUXnkwiKGwBmZKXsfp4mdSWOV4L7+lVGyUSuYLQfJwcWE06ksAq0VCi/Asn6NovVFmXG6xq+RC7XTfX87RirtZ5a8z0TO/4yaSJt0GPjo3v+RzM7f4LBWIfsmfP43en3O3gF01g44AjxvdVkKGudMh8mlRBYpIl16hg6xv//yxVivZxlRoap x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: ee4818bb-d54a-4a6b-5803-08d618e00bce 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:DB6PR0801MB1334; x-ms-traffictypediagnostic: DB6PR0801MB1334: 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)(8121501046)(5005006)(823301075)(10201501046)(93006095)(93001095)(3231344)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050)(76991041); SRVR:DB6PR0801MB1334; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1334; x-forefront-prvs: 07935ACF08 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(39860400002)(346002)(396003)(376002)(13464003)(189003)(199004)(106356001)(229853002)(2900100001)(7736002)(74316002)(305945005)(105586002)(66066001)(8676002)(11346002)(86362001)(26005)(6346003)(68736007)(53936002)(102836004)(55016002)(476003)(6436002)(486006)(8936002)(25786009)(81156014)(81166006)(446003)(2906002)(4326008)(53546011)(6246003)(6506007)(186003)(9686003)(76176011)(99286004)(6916009)(33656002)(5660300001)(7696005)(54906003)(316002)(478600001)(97736004)(3846002)(6116002)(72206003)(256004)(14454004)(5250100002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB1334; H:DB6PR0801MB1864.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Malvika.Gupta@arm.com; x-microsoft-antispam-message-info: I3NDgGgh+J306Wlhr8vFJ7VM+vfcW0CfLBKQh10iAHsCOd+RTcXKab0cBEIyePyczWrxXDPOrM+qjPQHTfRnlEy4FLnWW8lsIGqdWc9OPKulWlXFECksCqMnDMGzeCBgD9HJiMhmr5eujcIcd3OQPs6y/RguJ9wldSeBIcvKUhbbP/XHKA4abRFTpLSXxMgvvDzNt/npSaOeNsTwipSumD0RxNnhNZNJS8bDYPEir/7s8q81YQEg6FiK5plOK7sFmKRDXsG9ZUQlYQmr05QkU9sSfBKZS0g/KiM6rn9qCfoA0+0ftIaFBY4IWfwiWG4GUS2FcX4DkzgCT1UiNOAXygDT1hJstNyf/sY23jRAZb8= 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: ee4818bb-d54a-4a6b-5803-08d618e00bce X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Sep 2018 18:46:26.7515 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1334 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, 12 Sep 2018 18:46:28 -0000 Hi Konstantin, I installed the clang version 4.0.1 to check for the issue you were facing = with -O2 compilation. I was able to compile with -O2 and -O0 optimization w= ithout any errors. Please see the exact command I used and the following ou= tput for your reference: $ clang -O2 -target bpf -I /usr/include/aarch64-linux-gnu/ -c t1.c=20 $ clang -O0 -target bpf -I /usr/include/aarch64-linux-gnu/ -c t1.c $ clang -v clang version 4.0.1-10 (tags/RELEASE_401/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 I hope this was helpful to you. Best Regards, Malvika Gupta -----Original Message----- From: Malvika Gupta=20 Sent: Wednesday, September 5, 2018 4:43 PM To: Ananyev, Konstantin 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 Ananyev, I used clang version 6.0.0. Please see the following output for your refere= nce.=20 $ clang -v 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 ca= ndidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6.4.0 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7 Found ca= ndidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7.3.0 Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/8 Found ca= ndidate 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 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 > 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 > 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