From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 0A0E52082 for ; Tue, 6 Nov 2018 11:18:02 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2018 02:18:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,471,1534834800"; d="scan'208";a="83684853" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by fmsmga007.fm.intel.com with ESMTP; 06 Nov 2018 02:18:00 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.144]) by IRSMSX153.ger.corp.intel.com ([169.254.9.139]) with mapi id 14.03.0415.000; Tue, 6 Nov 2018 10:17:59 +0000 From: "Ananyev, Konstantin" To: Malvika Gupta CC: "dev@dpdk.org" , "gavin.hu@arm.com" , "honnappa.nagarahalli@arm.com" , "nd@arm.com" Thread-Topic: [PATCH v2] test/bpf: use hton instead of _builtin_bswap Thread-Index: AQHUct97jaiqmnR5BUeAuLtg7iom5aVCjYtg Date: Tue, 6 Nov 2018 10:17:58 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772580103069510@irsmsx105.ger.corp.intel.com> References: <20180828204620.1862-1-Malvika.Gupta@arm.com> <20181102190808.16421-1-malvika.gupta@arm.com> In-Reply-To: <20181102190808.16421-1-malvika.gupta@arm.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzkyMjkxOTktNGU2Ni00MDYxLTlhNGEtZmZlY2NlYmEyZDQ0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRmVTQnhDQmtqQkFZSFkxT1BROEk1amdcL1RvejFrQUdiQWk1QmplXC9FQWFGOFFYNkRJVldtWHdUd2dWaW1ZMzRtIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] 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: Tue, 06 Nov 2018 10:18:03 -0000 Hi Malvika, > -----Original Message----- > From: Malvika Gupta [mailto:malvika.gupta@arm.com] > Sent: Friday, November 2, 2018 7:08 PM > To: Ananyev, Konstantin > Cc: dev@dpdk.org; gavin.hu@arm.com; honnappa.nagarahalli@arm.com; nd@arm.= com; Malvika Gupta ; > Malvika Gupta > Subject: [PATCH v2] test/bpf: use hton instead of _builtin_bswap >=20 > From: Malvika Gupta >=20 > Convert host machine endianness to networking endianness for > comparison of incoming packets with BPF filter >=20 > Suggested-by: Brian Brooks > Signed-off-by: Malvika Gupta > Reviewed-by: Gavin Hu > Reviewed-by: Konstantin Ananyev I don't remember I acked it before actually, but I am ok to do it now for v= 2. Acked-by: Konstantin Ananyev > Acked-by: Honnappa Nagarahalli > --- > v2: > * Correct compilation command in the comments for x86. > * Added compilation command for ARM. >=20 > --- > test/bpf/t1.c | 14 +++++++++----- > test/bpf/t3.c | 13 ++++++++++--- > 2 files changed, 19 insertions(+), 8 deletions(-) >=20 > diff --git a/test/bpf/t1.c b/test/bpf/t1.c > index 60f9434ab..3364b4f1e 100644 > --- a/test/bpf/t1.c > +++ b/test/bpf/t1.c > @@ -20,32 +20,36 @@ > * (011) ret #1 > * (012) ret #0 > * > - * To compile: > - * clang -O2 -target bpf -c t1.c > + * To compile on x86: > + * clang -O2 -U __GNUC__ -target bpf -c t1.c > + * > + * To compile on ARM: > + * clang -O2 -I/usr/include/aarch64-linux-gnu/ -target bpf -c t1.c > */ >=20 > #include > #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)) > 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..9ba34638a 100644 > --- a/test/bpf/t3.c > +++ b/test/bpf/t3.c > @@ -6,9 +6,15 @@ > * eBPF program sample. > * Accepts pointer to struct rte_mbuf as an input parameter. > * Dump the mbuf into stdout if it is an ARP packet (aka tcpdump 'arp'). > - * To compile: > - * clang -O2 -I${RTE_SDK}/${RTE_TARGET}/include \ > + * > + * To compile on x86: > + * clang -O2 -U __GNUC__ -I${RTE_SDK}/${RTE_TARGET}/include \ > * -target bpf -Wno-int-to-void-pointer-cast -c t3.c > + * > + * To compile on ARM: > + * clang -O2 -I/usr/include/aarch64-linux-gnu \ > + * -I${RTE_SDK}/${RTE_TARGET}/include -target bpf \ > + * -Wno-int-to-void-pointer-cast -c t3.c > */ >=20 > #include > @@ -17,6 +23,7 @@ > #include > #include > #include "mbuf.h" > +#include >=20 > extern void rte_pktmbuf_dump(FILE *, const struct rte_mbuf *, unsigned i= nt); >=20 > @@ -29,7 +36,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