Message ID | 1438583517-19035-2-git-send-email-chaozhu@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B2CFAC410; Mon, 3 Aug 2015 08:31:17 +0200 (CEST) Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by dpdk.org (Postfix) with ESMTP id 6286B5FEB for <dev@dpdk.org>; Mon, 3 Aug 2015 08:31:15 +0200 (CEST) Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for <dev@dpdk.org> from <chaozhu@linux.vnet.ibm.com>; Mon, 3 Aug 2015 16:31:13 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 3 Aug 2015 16:31:11 +1000 X-Helo: d23dlp01.au.ibm.com X-MailFrom: chaozhu@linux.vnet.ibm.com X-RcptTo: dev@dpdk.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 302F72CE8055 for <dev@dpdk.org>; Mon, 3 Aug 2015 16:31:11 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t736V2gQ42729584 for <dev@dpdk.org>; Mon, 3 Aug 2015 16:31:10 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t736UcBN015581 for <dev@dpdk.org>; Mon, 3 Aug 2015 16:30:38 +1000 Received: from os_controller.crl.ibm.com ([9.186.57.26]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t736UDkF014006 for <dev@dpdk.org>; Mon, 3 Aug 2015 16:30:37 +1000 From: Chao Zhu <chaozhu@linux.vnet.ibm.com> To: dev@dpdk.org Date: Mon, 3 Aug 2015 14:31:57 +0800 Message-Id: <1438583517-19035-2-git-send-email-chaozhu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1438583517-19035-1-git-send-email-chaozhu@linux.vnet.ibm.com> References: <1438583517-19035-1-git-send-email-chaozhu@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15080306-1618-0000-0000-0000028BA311 Subject: [dpdk-dev] [PATCH] fm10k: fix the compilation on big endian platforms X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Chao Zhu
Aug. 3, 2015, 6:31 a.m. UTC
The rte_cpu_to_le_32 function can't be used to define const variables
because it has different implementation on big endian platforms. If
doing so, it will cause 'initializer element is not constant' compiling
error. This patch fixes this problem.
Signed-off-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>
---
drivers/net/fm10k/base/fm10k_tlv.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
Comments
2015-08-03 14:31, Chao Zhu: > The rte_cpu_to_le_32 function can't be used to define const variables > because it has different implementation on big endian platforms. If > doing so, it will cause 'initializer element is not constant' compiling > error. This patch fixes this problem. > --- a/drivers/net/fm10k/base/fm10k_tlv.c > +++ b/drivers/net/fm10k/base/fm10k_tlv.c You cannot change a base driver file except the osdep header where FM10K_CPU_TO_LE32 is defined. I don't understand why it doesn't give you a constant, given this definition: #define rte_bswap32(x) ((uint32_t)(__builtin_constant_p(x) ? \ rte_constant_bswap32(x) : \ rte_arch_bswap32(x))) Have you tried CONFIG_RTE_FORCE_INTRINSICS=y ? It should trigger this definition: #define rte_bswap32(x) __builtin_bswap32(x) > -STATIC const __le32 test_le[2] = { FM10K_CPU_TO_LE32(0x12345678), > - FM10K_CPU_TO_LE32(0x9abcdef0)}; > +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN > +STATIC const __le32 test_le[2] = {0x78563412,0xf0debc9a}; > +#else > +STATIC const __le32 test_le[2] = {0x12345678,0x9abcdef0}; > +#endif
On 2015/8/3 17:06, Thomas Monjalon wrote: > 2015-08-03 14:31, Chao Zhu: >> The rte_cpu_to_le_32 function can't be used to define const variables >> because it has different implementation on big endian platforms. If >> doing so, it will cause 'initializer element is not constant' compiling >> error. This patch fixes this problem. >> --- a/drivers/net/fm10k/base/fm10k_tlv.c >> +++ b/drivers/net/fm10k/base/fm10k_tlv.c > You cannot change a base driver file except the osdep header where > FM10K_CPU_TO_LE32 is defined. > > I don't understand why it doesn't give you a constant, given this definition: > > #define rte_bswap32(x) ((uint32_t)(__builtin_constant_p(x) ? \ > rte_constant_bswap32(x) : \ > rte_arch_bswap32(x))) > > Have you tried CONFIG_RTE_FORCE_INTRINSICS=y ? > It should trigger this definition: > > #define rte_bswap32(x) __builtin_bswap32(x) Yes. CONFIG_RTE_FORCE_INTRINSICS=y works on Power Big endian. But if I turn off this, the error happens. Seems rte_constant_bswap32 doesn't work on Power8? I'll try to check it. > >> -STATIC const __le32 test_le[2] = { FM10K_CPU_TO_LE32(0x12345678), >> - FM10K_CPU_TO_LE32(0x9abcdef0)}; >> +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN >> +STATIC const __le32 test_le[2] = {0x78563412,0xf0debc9a}; >> +#else >> +STATIC const __le32 test_le[2] = {0x12345678,0x9abcdef0}; >> +#endif
2015-08-03 19:32, Chao Zhu: > On 2015/8/3 17:06, Thomas Monjalon wrote: > > 2015-08-03 14:31, Chao Zhu: > >> The rte_cpu_to_le_32 function can't be used to define const variables > >> because it has different implementation on big endian platforms. If > >> doing so, it will cause 'initializer element is not constant' compiling > >> error. This patch fixes this problem. > >> --- a/drivers/net/fm10k/base/fm10k_tlv.c > >> +++ b/drivers/net/fm10k/base/fm10k_tlv.c > > > > You cannot change a base driver file except the osdep header where > > FM10K_CPU_TO_LE32 is defined. > > > > I don't understand why it doesn't give you a constant, given this definition: > > > > #define rte_bswap32(x) ((uint32_t)(__builtin_constant_p(x) ? \ > > rte_constant_bswap32(x) : \ > > rte_arch_bswap32(x))) > > > > Have you tried CONFIG_RTE_FORCE_INTRINSICS=y ? > > It should trigger this definition: > > > > #define rte_bswap32(x) __builtin_bswap32(x) > > Yes. CONFIG_RTE_FORCE_INTRINSICS=y works on Power Big endian. But if I > turn off this, the error happens. Seems rte_constant_bswap32 doesn't > work on Power8? I'll try to check it. The tile arch force intrinsics: http://dpdk.org/browse/dpdk/tree/config/defconfig_tile-tilegx-linuxapp-gcc#n39 http://dpdk.org/browse/dpdk/tree/lib/librte_eal/common/include/arch/tile/rte_byteorder.h#n36 I don't know wether it was for the same reason.
>-----Original Message----- >From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] >Sent: Monday, August 03, 2015 7:39 PM >To: Chao Zhu >Cc: dev@dpdk.org; Zhigang Lu >Subject: Re: [dpdk-dev] [PATCH] fm10k: fix the compilation on big endian >platforms > >2015-08-03 19:32, Chao Zhu: >> On 2015/8/3 17:06, Thomas Monjalon wrote: >> > 2015-08-03 14:31, Chao Zhu: >> >> The rte_cpu_to_le_32 function can't be used to define const >> >> variables because it has different implementation on big endian >> >> platforms. If doing so, it will cause 'initializer element is not >> >> constant' compiling error. This patch fixes this problem. >> >> --- a/drivers/net/fm10k/base/fm10k_tlv.c >> >> +++ b/drivers/net/fm10k/base/fm10k_tlv.c >> > >> > You cannot change a base driver file except the osdep header where >> > FM10K_CPU_TO_LE32 is defined. >> > >> > I don't understand why it doesn't give you a constant, given this definition: >> > >> > #define rte_bswap32(x) ((uint32_t)(__builtin_constant_p(x) ? \ >> > rte_constant_bswap32(x) : \ >> > rte_arch_bswap32(x))) >> > >> > Have you tried CONFIG_RTE_FORCE_INTRINSICS=y ? >> > It should trigger this definition: >> > >> > #define rte_bswap32(x) __builtin_bswap32(x) >> >> Yes. CONFIG_RTE_FORCE_INTRINSICS=y works on Power Big endian. But if >> I turn off this, the error happens. Seems rte_constant_bswap32 >> doesn't work on Power8? I'll try to check it. > >The tile arch force intrinsics: > http://dpdk.org/browse/dpdk/tree/config/defconfig_tile-tilegx-linuxapp-gcc >#n39 > http://dpdk.org/browse/dpdk/tree/lib/librte_eal/common/include/arch/tile >/rte_byteorder.h#n36 >I don't know wether it was for the same reason. Not really, the reason Tile arch force intrinsics is to reuse some generic functions in lib/librte_eal/common/include/generic/, such as rte_atomic16_cmpset() rte_atomic16_inc() rte_spinlock_lock() .... Thanks -Zhigang
diff --git a/drivers/net/fm10k/base/fm10k_tlv.c b/drivers/net/fm10k/base/fm10k_tlv.c index 1d9d7d8..5b2937d 100644 --- a/drivers/net/fm10k/base/fm10k_tlv.c +++ b/drivers/net/fm10k/base/fm10k_tlv.c @@ -664,8 +664,11 @@ STATIC const s64 test_s64 = -0x123456789abcdef0ll; STATIC const s32 test_s32 = -0x1235678; STATIC const s16 test_s16 = -0x1234; STATIC const s8 test_s8 = -0x12; -STATIC const __le32 test_le[2] = { FM10K_CPU_TO_LE32(0x12345678), - FM10K_CPU_TO_LE32(0x9abcdef0)}; +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN +STATIC const __le32 test_le[2] = {0x78563412,0xf0debc9a}; +#else +STATIC const __le32 test_le[2] = {0x12345678,0x9abcdef0}; +#endif /* The message below is meant to be used as a test message to demonstrate * how to use the TLV interface and to test the types. Normally this code