From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] app/testpmd: fix endianness detection
Date: Wed, 3 Dec 2014 21:47:48 +0100 [thread overview]
Message-ID: <1417639668-23500-3-git-send-email-thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1417639668-23500-1-git-send-email-thomas.monjalon@6wind.com>
Use endianness detection factorized in EAL.
The comment about arpa/inet.h is not valid anymore since
commit d07180f211c08 ("net: fix conflict with libc").
The macro _htons could also be moved in rte_byteorder.h
by providing some constant byte swapping.
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
app/test-pmd/config.c | 2 +-
app/test-pmd/csumonly.c | 5 ++---
app/test-pmd/testpmd.h | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index f0b770e..69a83c2 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -628,7 +628,7 @@ ring_dma_zone_lookup(const char *ring_name, uint8_t port_id, uint16_t q_id)
union igb_ring_dword {
uint64_t dword;
struct {
-#ifdef RTE_ARCH_BIG_ENDIAN
+#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
uint32_t lo;
uint32_t hi;
#else
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 6f43761..da4bca4 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -79,9 +79,8 @@
#define IP_HDRLEN 0x05 /* default IP header length == five 32-bits words. */
#define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
-/* we cannot use htons() from arpa/inet.h due to name conflicts, and we
- * cannot use rte_cpu_to_be_16() on a constant in a switch/case */
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+/* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
#define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8)))
#else
#define _htons(x) (x)
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c925910..f8b0740 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -567,7 +567,7 @@ int tx_queue_id_is_invalid(queueid_t txq_id);
#define RTE_BE_TO_CPU_16(be_16_v) rte_be_to_cpu_16((be_16_v))
#define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v))
#else
-#ifdef __big_endian__
+#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
#define RTE_BE_TO_CPU_16(be_16_v) (be_16_v)
#define RTE_CPU_TO_BE_16(cpu_16_v) (cpu_16_v)
#else
--
2.1.3
next prev parent reply other threads:[~2014-12-03 20:49 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1417606044-3432-1-git-send-email-michael.qiu@intel.com>
[not found] ` <1417606099-3489-1-git-send-email-michael.qiu@intel.com>
2014-12-03 11:42 ` [dpdk-dev] [PATCH] test-pmd: Fix pointer aliasing error Bruce Richardson
2014-12-03 13:59 ` Qiu, Michael
2014-12-03 14:51 ` Bruce Richardson
2014-12-03 15:19 ` Qiu, Michael
2014-12-03 15:36 ` Bruce Richardson
2014-12-04 2:38 ` Qiu, Michael
2014-12-04 3:28 ` [dpdk-dev] [PATCH v2] " Michael Qiu
2014-12-04 4:16 ` [dpdk-dev] [PATCH v3] " Michael Qiu
2014-12-05 5:34 ` Qiu, Michael
2014-12-05 9:24 ` Thomas Monjalon
2014-12-08 1:28 ` Qiu, Michael
2014-12-08 1:30 ` Qiu, Michael
2014-12-10 3:44 ` Qiu, Michael
2014-12-11 0:54 ` Thomas Monjalon
2014-12-11 17:51 ` r k
2014-12-12 6:49 ` Qiu, Michael
2014-12-04 12:54 ` [dpdk-dev] [PATCH v2] " Ananyev, Konstantin
2014-12-03 15:24 ` [dpdk-dev] [PATCH] " Olivier MATZ
2014-12-03 16:03 ` Dayu Qiu
2014-12-03 15:57 ` Dayu Qiu
2014-12-03 16:26 ` [dpdk-dev] [PATCH] test-pmd: Fix "__BYTE_ORDER__" not defined error Qiu, Michael
2014-12-03 19:59 ` Thomas Monjalon
2014-12-03 20:47 ` [dpdk-dev] [PATCH 0/2] fix endianness in EAL Thomas Monjalon
2014-12-03 20:47 ` [dpdk-dev] [PATCH 1/2] eal: detect endianness Thomas Monjalon
2014-12-04 2:28 ` Qiu, Michael
2014-12-04 9:00 ` Thomas Monjalon
2014-12-04 10:28 ` Qiu, Michael
2014-12-04 12:19 ` Thomas Monjalon
2014-12-04 12:50 ` Qiu, Michael
2014-12-03 20:47 ` Thomas Monjalon [this message]
2014-12-04 9:28 ` [dpdk-dev] [PATCH 0/2] fix endianness in EAL Chao Zhu
2014-12-05 16:01 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417639668-23500-3-git-send-email-thomas.monjalon@6wind.com \
--to=thomas.monjalon@6wind.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).