net/enic: use I/O device memory read/write API
authorSantosh Shukla <santosh.shukla@caviumnetworks.com>
Wed, 18 Jan 2017 01:21:33 +0000 (06:51 +0530)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 18 Jan 2017 16:18:26 +0000 (17:18 +0100)
Replace the raw I/O device memory read/write access with eal
abstraction for I/O device memory read/write access to fix portability
issues across different architectures.

CC: John Daley <johndale@cisco.com>
CC: Nelson Escobar <neescoba@cisco.com>
Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
drivers/net/enic/enic_compat.h
drivers/net/enic/enic_rxtx.c

index 5dbd983..fc58bb4 100644 (file)
@@ -41,6 +41,7 @@
 #include <rte_atomic.h>
 #include <rte_malloc.h>
 #include <rte_log.h>
+#include <rte_io.h>
 
 #define ENIC_PAGE_ALIGN 4096UL
 #define ENIC_ALIGN      ENIC_PAGE_ALIGN
@@ -95,42 +96,52 @@ typedef         unsigned long long  dma_addr_t;
 
 static inline uint32_t ioread32(volatile void *addr)
 {
-       return *(volatile uint32_t *)addr;
+       return rte_read32(addr);
 }
 
 static inline uint16_t ioread16(volatile void *addr)
 {
-       return *(volatile uint16_t *)addr;
+       return rte_read16(addr);
 }
 
 static inline uint8_t ioread8(volatile void *addr)
 {
-       return *(volatile uint8_t *)addr;
+       return rte_read8(addr);
 }
 
 static inline void iowrite32(uint32_t val, volatile void *addr)
 {
-       *(volatile uint32_t *)addr = val;
+       rte_write32(val, addr);
+}
+
+static inline void iowrite32_relaxed(uint32_t val, volatile void *addr)
+{
+       rte_write32_relaxed(val, addr);
 }
 
 static inline void iowrite16(uint16_t val, volatile void *addr)
 {
-       *(volatile uint16_t *)addr = val;
+       rte_write16(val, addr);
 }
 
 static inline void iowrite8(uint8_t val, volatile void *addr)
 {
-       *(volatile uint8_t *)addr = val;
+       rte_write8(val, addr);
 }
 
 static inline unsigned int readl(volatile void __iomem *addr)
 {
-       return *(volatile unsigned int *)addr;
+       return rte_read32(addr);
+}
+
+static inline unsigned int readl_relaxed(volatile void __iomem *addr)
+{
+       return rte_read32_relaxed(addr);
 }
 
 static inline void writel(unsigned int val, volatile void __iomem *addr)
 {
-       *(volatile unsigned int *)addr = val;
+       rte_write32(val, addr);
 }
 
 #define min_t(type, x, y) ({                    \
index 981be3a..26b83ae 100644 (file)
@@ -446,10 +446,11 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
                rte_mb();
                if (data_rq->in_use)
-                       iowrite32(data_rq->posted_index,
-                                 &data_rq->ctrl->posted_index);
+                       iowrite32_relaxed(data_rq->posted_index,
+                                         &data_rq->ctrl->posted_index);
                rte_compiler_barrier();
-               iowrite32(sop_rq->posted_index, &sop_rq->ctrl->posted_index);
+               iowrite32_relaxed(sop_rq->posted_index,
+                                 &sop_rq->ctrl->posted_index);
        }
 
 
@@ -629,7 +630,7 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        }
  post:
        rte_wmb();
-       iowrite32(head_idx, &wq->ctrl->posted_index);
+       iowrite32_relaxed(head_idx, &wq->ctrl->posted_index);
  done:
        wq->ring.desc_avail = wq_desc_avail;
        wq->head_idx = head_idx;