From 204a7f44bc457b2c75c9eeb56468214664c830f0 Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Thu, 5 Nov 2020 22:17:11 +0100 Subject: [PATCH] bus/pci: support I/O port operations with musl Add a fallback for non-GNU libc systems like musl libc for the non-standard functions outl_p, outw_p and outb_p. It solves the following errors when building with musl libc: pci_uio.c: undefined reference to 'outw_p' pci_uio.c: undefined reference to 'outl_p' pci_uio.c: undefined reference to 'outb_p' Bugzilla ID: 35 Fixes: 756ce64b1ecd ("eal: introduce PCI ioport API") Cc: stable@dpdk.org Reported-by: Natanael Copa Signed-off-by: Thomas Monjalon Acked-by: Andrew Rybchenko Acked-by: David Marchand --- drivers/bus/pci/linux/pci_uio.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 0907051e04..39ebeac2a0 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -526,13 +526,18 @@ error: #endif #if defined(RTE_ARCH_X86) + static inline uint8_t ioread8(void *addr) { uint8_t val; val = (uint64_t)(uintptr_t)addr >= PIO_MAX ? *(volatile uint8_t *)addr : +#ifdef __GLIBC__ inb_p((unsigned long)addr); +#else + inb((unsigned long)addr); +#endif return val; } @@ -543,7 +548,11 @@ static inline uint16_t ioread16(void *addr) val = (uint64_t)(uintptr_t)addr >= PIO_MAX ? *(volatile uint16_t *)addr : +#ifdef __GLIBC__ inw_p((unsigned long)addr); +#else + inw((unsigned long)addr); +#endif return val; } @@ -554,7 +563,11 @@ static inline uint32_t ioread32(void *addr) val = (uint64_t)(uintptr_t)addr >= PIO_MAX ? *(volatile uint32_t *)addr : +#ifdef __GLIBC__ inl_p((unsigned long)addr); +#else + inl((unsigned long)addr); +#endif return val; } @@ -563,23 +576,37 @@ static inline void iowrite8(uint8_t val, void *addr) { (uint64_t)(uintptr_t)addr >= PIO_MAX ? *(volatile uint8_t *)addr = val : +#ifdef __GLIBC__ outb_p(val, (unsigned long)addr); +#else + outb(val, (unsigned long)addr); +#endif } static inline void iowrite16(uint16_t val, void *addr) { (uint64_t)(uintptr_t)addr >= PIO_MAX ? *(volatile uint16_t *)addr = val : +#ifdef __GLIBC__ outw_p(val, (unsigned long)addr); +#else + outw(val, (unsigned long)addr); +#endif } static inline void iowrite32(uint32_t val, void *addr) { (uint64_t)(uintptr_t)addr >= PIO_MAX ? *(volatile uint32_t *)addr = val : +#ifdef __GLIBC__ outl_p(val, (unsigned long)addr); -} #else + outl(val, (unsigned long)addr); +#endif +} + +#else /* !RTE_ARCH_X86 */ + static inline uint8_t ioread8(void *addr) { return *(volatile uint8_t *)addr; @@ -609,7 +636,8 @@ static inline void iowrite32(uint32_t val, void *addr) { *(volatile uint32_t *)addr = val; } -#endif + +#endif /* !RTE_ARCH_X86 */ void pci_uio_ioport_read(struct rte_pci_ioport *p, -- 2.20.1