From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerin Jacob Subject: [PATCH 11/28] eal: generic implementation for I/O device read/write access Date: Wed, 14 Dec 2016 07:25:41 +0530 Message-ID: <1481680558-4003-12-git-send-email-jerin.jacob@caviumnetworks.com> References: <1481680558-4003-1-git-send-email-jerin.jacob@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , , Jerin Jacob To: Return-path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0064.outbound.protection.outlook.com [104.47.41.64]) by dpdk.org (Postfix) with ESMTP id 436A4475D for ; Wed, 14 Dec 2016 02:58:46 +0100 (CET) In-Reply-To: <1481680558-4003-1-git-send-email-jerin.jacob@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 + /** * @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