[dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead of asm volatile

Olivier Matz olivier.matz at 6wind.com
Fri Jan 24 16:59:17 CET 2014


Use the DPDK specific function rte_mb() instead of
the GCC statement asm volatile ("" ::: "memory").

Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
 common/memnic.h  | 2 --
 pmd/pmd_memnic.c | 6 +++---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/common/memnic.h b/common/memnic.h
index 6ff38a0..fdc9fa3 100644
--- a/common/memnic.h
+++ b/common/memnic.h
@@ -123,8 +123,6 @@ struct memnic_area {
 /* for userspace */
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
-#define barrier() do { asm volatile("": : :"memory"); } while (0)
-
 static inline uint32_t cmpxchg(uint32_t *dst, uint32_t old, uint32_t new)
 {
 	volatile uint32_t *ptr = (volatile uint32_t *)dst;
diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c
index bc01746..1586222 100644
--- a/pmd/pmd_memnic.c
+++ b/pmd/pmd_memnic.c
@@ -100,7 +100,7 @@ static int memnic_dev_start(struct rte_eth_dev *dev)
 
 	/* invalidate */
 	adapter->nic->hdr.valid = 0;
-	barrier();
+	rte_mb();
 	/* reset */
 	adapter->nic->hdr.reset = 1;
 	/* no need to wait here */
@@ -242,7 +242,7 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
 		mb->pkt.data_len = p->len;
 		rx_pkts[nr] = mb;
 
-		barrier();
+		rte_mb();
 		p->status = MEMNIC_PKT_ST_FREE;
 
 		if (++idx >= MEMNIC_NR_PACKET)
@@ -290,7 +290,7 @@ retry:
 
 		rte_memcpy(p->data, rte_pktmbuf_mtod(tx_pkts[nr], void *), len);
 
-		barrier();
+		rte_mb();
 		p->status = MEMNIC_PKT_ST_FILLED;
 
 		rte_pktmbuf_free(tx_pkts[nr]);
-- 
1.8.4.rc3



More information about the dev mailing list