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

2014-02-04 Thread Thomas Monjalon
30/01/2014 12:42, Hiroshi Shimamoto:
> > Use the DPDK specific function rte_mb() instead of
> > the GCC statement asm volatile ("" ::: "memory").
> >
> > Signed-off-by: Olivier Matz 
> 
> Yes, that's preferred for DPDK, I think.
> Looks okay to me.

Applied, thanks.

-- 
Thomas


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

2014-01-31 Thread Olivier MATZ
Hi Hiroshi-san,

On 01/30/2014 12:42 PM, Hiroshi Shimamoto wrote:
>> Subject: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead 
>> of asm volatile
>
> By the way, I was also asked to use rte atomic function
> instead of cmpxchg asm statement.
> My re-submitted version in dpdk-ovs has such a change.
> What do you think?

Yes I agree about this change.

Regards,
Olivier



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

2014-01-30 Thread Hiroshi Shimamoto
> Subject: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead 
> of asm volatile
> 
> Use the DPDK specific function rte_mb() instead of
> the GCC statement asm volatile ("" ::: "memory").

Yes, that's preferred for DPDK, I think.
Looks okay to me.

By the way, I was also asked to use rte atomic function
instead of cmpxchg asm statement.
My re-submitted version in dpdk-ovs has such a change.
What do you think?

thanks,
Hiroshi

> 
> Signed-off-by: Olivier Matz 
> ---
>  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



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

2014-01-24 Thread Olivier Matz
Use the DPDK specific function rte_mb() instead of
the GCC statement asm volatile ("" ::: "memory").

Signed-off-by: Olivier Matz 
---
 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