This patch implements the generic version of rte_read[b/w/l/q]_[relaxed] and rte_write[b/w/l/q]_[relaxed] using rte_io_wmb() and rte_io_rmb()
Signed-off-by: Jerin Jacob <jerin.ja...@caviumnetworks.com> --- lib/librte_eal/common/include/generic/rte_io.h | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lib/librte_eal/common/include/generic/rte_io.h b/lib/librte_eal/common/include/generic/rte_io.h index d7ffbcd..f34c131 100644 --- a/lib/librte_eal/common/include/generic/rte_io.h +++ b/lib/librte_eal/common/include/generic/rte_io.h @@ -34,6 +34,8 @@ #ifndef _RTE_IO_H_ #define _RTE_IO_H_ +#include <rte_atomic.h> + /** * @file * I/O device memory operations @@ -260,4 +262,56 @@ rte_writeq(uint64_t value, volatile void *addr); #endif /* __DOXYGEN__ */ +#ifndef RTE_OVERRIDE_IO_H + +#define rte_readb_relaxed(addr) \ + ({ uint8_t __v = *(const volatile uint8_t *)addr; __v; }) + +#define rte_readw_relaxed(addr) \ + ({ uint16_t __v = *(const volatile uint16_t *)addr; __v; }) + +#define rte_readl_relaxed(addr) \ + ({ uint32_t __v = *(const volatile uint32_t *)addr; __v; }) + +#define rte_readq_relaxed(addr) \ + ({ uint64_t __v = *(const volatile uint64_t *)addr; __v; }) + +#define rte_writeb_relaxed(value, addr) \ + ({ *(volatile uint8_t *)addr = value; }) + +#define rte_writew_relaxed(value, addr) \ + ({ *(volatile uint16_t *)addr = value; }) + +#define rte_writel_relaxed(value, addr) \ + ({ *(volatile uint32_t *)addr = value; }) + +#define rte_writeq_relaxed(value, addr) \ + ({ *(volatile uint64_t *)addr = value; }) + +#define rte_readb(addr) \ + ({ uint8_t __v = *(const volatile uint8_t *)addr; rte_io_rmb(); __v; }) + +#define rte_readw(addr) \ + ({uint16_t __v = *(const volatile uint16_t *)addr; rte_io_rmb(); __v; }) + +#define rte_readl(addr) \ + ({uint32_t __v = *(const volatile uint32_t *)addr; rte_io_rmb(); __v; }) + +#define rte_readq(addr) \ + ({uint64_t __v = *(const volatile uint64_t *)addr; rte_io_rmb(); __v; }) + +#define rte_writeb(value, addr) \ + ({ rte_io_wmb(); *(volatile uint8_t *)addr = value; }) + +#define rte_writew(value, addr) \ + ({ rte_io_wmb(); *(volatile uint16_t *)addr = value; }) + +#define rte_writel(value, addr) \ + ({ rte_io_wmb(); *(volatile uint32_t *)addr = value; }) + +#define rte_writeq(value, addr) \ + ({ rte_io_wmb(); *(volatile uint64_t *)addr = value; }) + +#endif /* RTE_OVERRIDE_IO_H */ + #endif /* _RTE_IO_H_ */ -- 2.5.5