From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp [202.32.8.193]) by dpdk.org (Postfix) with ESMTP id 21F8368F7 for ; Thu, 30 Jan 2014 12:41:56 +0100 (CET) Received: from mailgate3.nec.co.jp ([10.7.69.192]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id s0UBhE2h026075; Thu, 30 Jan 2014 20:43:14 +0900 (JST) Received: from mailsv4.nec.co.jp (imss63.nec.co.jp [10.7.69.158]) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) with ESMTP id s0UBhDh02084; Thu, 30 Jan 2014 20:43:13 +0900 (JST) Received: from mail01b.kamome.nec.co.jp (mail01b.kamome.nec.co.jp [10.25.43.2]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id s0UBhDpG006139; Thu, 30 Jan 2014 20:43:13 +0900 (JST) Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.142] [10.38.151.142]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-667816; Thu, 30 Jan 2014 20:43:01 +0900 Received: from BPXM14GP.gisp.nec.co.jp ([169.254.1.238]) by BPXC14GP.gisp.nec.co.jp ([10.38.151.142]) with mapi id 14.02.0328.011; Thu, 30 Jan 2014 20:43:00 +0900 From: Hiroshi Shimamoto To: Olivier Matz , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead of asm volatile Thread-Index: AQHPHZx+GnkMrafuWE28CMkS68q0tZqdJHeQ Date: Thu, 30 Jan 2014 11:42:59 +0000 Message-ID: <7F861DC0615E0C47A872E6F3C5FCDDBD0102D11D@BPXM14GP.gisp.nec.co.jp> References: <1390579157-23890-1-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1390579157-23890-1-git-send-email-olivier.matz@6wind.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.205.5.123] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead of asm volatile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jan 2014 11:41:57 -0000 > Subject: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function inste= ad of asm volatile >=20 > 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 >=20 > Signed-off-by: Olivier Matz > --- > common/memnic.h | 2 -- > pmd/pmd_memnic.c | 6 +++--- > 2 files changed, 3 insertions(+), 5 deletions(-) >=20 > 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)) >=20 > -#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 =3D (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) >=20 > /* invalidate */ > adapter->nic->hdr.valid =3D 0; > - barrier(); > + rte_mb(); > /* reset */ > adapter->nic->hdr.reset =3D 1; > /* no need to wait here */ > @@ -242,7 +242,7 @@ static uint16_t memnic_recv_pkts(void *rx_queue, > mb->pkt.data_len =3D p->len; > rx_pkts[nr] =3D mb; >=20 > - barrier(); > + rte_mb(); > p->status =3D MEMNIC_PKT_ST_FREE; >=20 > if (++idx >=3D MEMNIC_NR_PACKET) > @@ -290,7 +290,7 @@ retry: >=20 > rte_memcpy(p->data, rte_pktmbuf_mtod(tx_pkts[nr], void *), len); >=20 > - barrier(); > + rte_mb(); > p->status =3D MEMNIC_PKT_ST_FILLED; >=20 > rte_pktmbuf_free(tx_pkts[nr]); > -- > 1.8.4.rc3