DPDK patches and discussions
 help / color / mirror / Atom feed
From: Natanael Copa <ncopa@alpinelinux.org>
To: dev@dpdk.org
Cc: Natanael Copa <ncopa@alpinelinux.org>
Subject: [dpdk-dev] [PATCH 04/15] bus/pci: factor out various ifdefs in pci_uio_ioport_{read, write}
Date: Mon, 11 Mar 2019 18:36:51 +0100	[thread overview]
Message-ID: <20190311173702.24471-5-ncopa@alpinelinux.org> (raw)
In-Reply-To: <20190311173702.24471-1-ncopa@alpinelinux.org>

define the macros so we can remove various #if defined(RTE_ARCH_X86)

Ref: https://bugs.dpdk.org/show_bug.cgi?id=35#c6

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---

Please note that this is only compile tested with musl libc on x86_64.

 drivers/bus/pci/linux/pci_uio.c | 54 +++++++++++++++------------------
 1 file changed, 24 insertions(+), 30 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 6058cd9f8..dfa42c565 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -14,11 +14,18 @@
 
 #if defined(RTE_ARCH_X86)
 #include <sys/io.h>
+
+#define pci_uio_inl(reg) inl(reg)
+#define pci_uio_inw(reg) inw(reg)
+#define pci_uio_inb(reg) inb(reg)
+
 #if defined(__GLIBC__)
+
 #define pci_uio_outl_p outl_p
 #define pci_uio_outw_p outw_p
 #define pci_uio_outb_p outb_p
-#else
+
+#else /* defined(__GLIBC__) */
 static inline void
 pci_uio_outl_p(unsigned int value, unsigned short int port)
 {
@@ -39,8 +46,19 @@ pci_uio_outb_p(unsigned char value, unsigned short int port)
   __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value),
 			"Nd" (port));
 }
-#endif
-#endif
+#endif /* defined(__GLIBC__) */
+
+#else /* RTE_ARCH_X86 */
+
+#define pci_uio_inl(reg) *(volatile uint32_t *)(reg)
+#define pci_uio_inw(reg) *(volatile uint16_t *)(reg)
+#define pci_uio_inb(reg) *(volatile uint8_t *)(reg)
+
+#define pci_uio_outl_p(value, reg) *(volatile uint32_t *)(reg) = (value)
+#define pci_uio_outw_p(value, reg) *(volatile uint16_t *)(reg) = (value)
+#define pci_uio_outb_p(value, reg) *(volatile uint8_t *)(reg) = (value)
+
+#endif /* RTE_ARCH_X86 */
 
 #include <rte_log.h>
 #include <rte_pci.h>
@@ -518,25 +536,13 @@ pci_uio_ioport_read(struct rte_pci_ioport *p,
 	for (d = data; len > 0; d += size, reg += size, len -= size) {
 		if (len >= 4) {
 			size = 4;
-#if defined(RTE_ARCH_X86)
-			*(uint32_t *)d = inl(reg);
-#else
-			*(uint32_t *)d = *(volatile uint32_t *)reg;
-#endif
+			*(uint32_t *)d = pci_uio_inl(reg);
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
-			*(uint16_t *)d = inw(reg);
-#else
-			*(uint16_t *)d = *(volatile uint16_t *)reg;
-#endif
+			*(uint16_t *)d = pci_uio_inw(reg);
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
-			*d = inb(reg);
-#else
-			*d = *(volatile uint8_t *)reg;
-#endif
+			*d = pci_uio_inb(reg);
 		}
 	}
 }
@@ -552,25 +558,13 @@ pci_uio_ioport_write(struct rte_pci_ioport *p,
 	for (s = data; len > 0; s += size, reg += size, len -= size) {
 		if (len >= 4) {
 			size = 4;
-#if defined(RTE_ARCH_X86)
 			pci_uio_outl_p(*(const uint32_t *)s, reg);
-#else
-			*(volatile uint32_t *)reg = *(const uint32_t *)s;
-#endif
 		} else if (len >= 2) {
 			size = 2;
-#if defined(RTE_ARCH_X86)
 			pci_uio_outw_p(*(const uint16_t *)s, reg);
-#else
-			*(volatile uint16_t *)reg = *(const uint16_t *)s;
-#endif
 		} else {
 			size = 1;
-#if defined(RTE_ARCH_X86)
 			pci_uio_outb_p(*s, reg);
-#else
-			*(volatile uint8_t *)reg = *s;
-#endif
 		}
 	}
 }
-- 
2.21.0

  parent reply	other threads:[~2019-03-11 17:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 17:36 [dpdk-dev] [PATCH 00/15] Build fixes for musl libc Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 01/15] app/testpmd: replace uint with unsigned int Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 02/15] net/cxgbe: " Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc Natanael Copa
2019-03-12 10:16   ` [dpdk-dev] [PATCH v2 " Natanael Copa
2019-03-13 11:13     ` Ferruh Yigit
2019-03-13 17:08       ` Natanael Copa
2019-03-11 17:36 ` Natanael Copa [this message]
2019-03-12 10:18   ` [dpdk-dev] [PATCH v2 04/15] bus/pci: factor out various ifdefs in pci_uio_ioport_{read, write} Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 05/15] bus/fslmc: fix compile error with musl libc Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 06/15] bus/fslmc: remove unused include of error.h Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 07/15] net/nfp: build fix for musl libc Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 08/15] app/test: include fcntl.h due to use of O_RDONLY Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 09/15] app/test: fix setting of -D_GNU_SOURCE with meson Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 11/15] bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 12/15] crypto/dpaa2_sec: build fix for musl libc Natanael Copa
2019-03-12 10:20   ` [dpdk-dev] [PATCH v2 " Natanael Copa
2019-03-11 17:37 ` [dpdk-dev] [PATCH 13/15] crypto/dpaa2_sec: simplify pr_{debug, err, warn} macros Natanael Copa
2019-03-11 17:37 ` [dpdk-dev] [PATCH 14/15] net/netvsc: fix compile warning for fcntl.h include Natanael Copa
2019-03-11 18:17   ` Stephen Hemminger
2019-03-11 17:37 ` [dpdk-dev] [PATCH 15/15] eal/linux: use gettid(2) for debug message in sigbus_handler Natanael Copa
2019-03-11 18:21   ` Stephen Hemminger
2019-03-12 10:22     ` [dpdk-dev] [PATCH v2 15/15] eal/linux: simplify " Natanael Copa
2019-03-13 11:45 ` [dpdk-dev] [PATCH 00/15] Build fixes for musl libc Sirvys, Andrius
2019-03-13 16:53   ` Natanael Copa

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=20190311173702.24471-5-ncopa@alpinelinux.org \
    --to=ncopa@alpinelinux.org \
    --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).