From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 913E929CD for ; Fri, 4 Mar 2016 07:36:44 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 03 Mar 2016 22:36:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,535,1449561600"; d="scan'208";a="663639921" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 03 Mar 2016 22:36:43 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Mar 2016 22:36:42 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.136]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.18]) with mapi id 14.03.0248.002; Fri, 4 Mar 2016 14:36:41 +0800 From: "Qiu, Michael" To: Yuanhan Liu Thread-Topic: [dpdk-dev] [PATCH v1] virtio: Use cpuflag for vector api Thread-Index: AQHRcHMbS07T/1MCB0imsZVttktoXg== Date: Fri, 4 Mar 2016 06:36:40 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028622F5D307@SHSMSX101.ccr.corp.intel.com> References: <1456476662-23081-1-git-send-email-sshukla@mvista.com> <533710CFB86FA344BFBF2D6802E6028622F5A41C@SHSMSX101.ccr.corp.intel.com> <533710CFB86FA344BFBF2D6802E6028622F5AC3E@SHSMSX101.ccr.corp.intel.com> <20160302024918.GQ14300@yliu-dev.sh.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v1] virtio: Use cpuflag for vector api 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: Fri, 04 Mar 2016 06:36:45 -0000 On 3/2/2016 10:48 AM, Yuanhan Liu wrote:=0A= > On Wed, Mar 02, 2016 at 02:10:14AM +0000, Qiu, Michael wrote:=0A= >> On 3/1/2016 5:46 PM, Santosh Shukla wrote:=0A= >>> On Tue, Mar 1, 2016 at 2:41 PM, Qiu, Michael wr= ote:=0A= >>>> On 2/26/2016 4:53 PM, Santosh Shukla wrote:=0A= >>>>> Check cpuflag macro before using vectored api.=0A= >>>>> -virtio_recv_pkts_vec() uses _sse3__ simd instruction for now so adde= d cpuflag.=0A= >>>>> - Also wrap other vectored freind api ie..=0A= >>>>> 1) virtqueue_enqueue_recv_refill_simple=0A= >>>>> 2) virtio_rxq_vec_setup=0A= >>>>>=0A= >>>>> todo:=0A= >>>>> 1) Move virtio_recv_pkts_vec() implementation to=0A= >>>>> drivers/virtio/virtio_vec_.h file.=0A= >>>>> 2) Remove use_simple_rxtx flag, so that virtio/virtio_vec_.h=0A= >>>>> files to provide vectored/non-vectored rx/tx apis.=0A= >>>>>=0A= >>>>> Signed-off-by: Santosh Shukla =0A= >>>>> ---=0A= >>>>> - v1: This is a rework of patch [1].=0A= >>>>> Note: This patch will let non-x86 arch to use virtio pmd.=0A= >>>>>=0A= >>>>> [1] http://dpdk.org/dev/patchwork/patch/10429/=0A= >>>>>=0A= >>>>> drivers/net/virtio/virtio_rxtx.c | 16 +++++++++++++++-=0A= >>>>> drivers/net/virtio/virtio_rxtx.h | 2 ++=0A= >>>>> drivers/net/virtio/virtio_rxtx_simple.c | 11 ++++++++++-=0A= >>>>> 3 files changed, 27 insertions(+), 2 deletions(-)=0A= >>>>>=0A= >>>>> diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/vi= rtio_rxtx.c=0A= >>>>> index 41a1366..ec0b8de 100644=0A= >>>>> --- a/drivers/net/virtio/virtio_rxtx.c=0A= >>>>> +++ b/drivers/net/virtio/virtio_rxtx.c=0A= >>>>> @@ -67,7 +67,9 @@=0A= >>>>> #define VIRTIO_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \= =0A= >>>>> ETH_TXQ_FLAGS_NOOFFLOADS)=0A= >>>>>=0A= >>>>> +#ifdef RTE_MACHINE_CPUFLAG_SSSE3=0A= >>>>> static int use_simple_rxtx;=0A= >>>>> +#endif=0A= >>>>>=0A= >>>>>=0A= >>>> I don't think so much #ifdef ... #endif in *.c file is a good choice.= =0A= >>>> Would you consider let it only in header file like:=0A= >>>>=0A= >>>> in drivers/net/virtio/virtio_rxtx.h=0A= >>>>=0A= >>>> [...]=0A= >>>>=0A= >>>> #ifdef RTE_MACHINE_CPUFLAG_SSSE3=0A= >>>> int virtio_rxq_vec_setup(struct virtqueue *rxq);=0A= >>>>=0A= >>>> int virtqueue_enqueue_recv_refill_simple(struct virtqueue *vq,=0A= >>>> struct rte_mbuf *m);=0A= >>>> #else=0A= >>>> int virtio_rxq_vec_setup(__rte_unused struct virtqueue *rxq) {return -= 1;}=0A= >>>> int virtqueue_enqueue_recv_refill_simple(__rte_unused struct virtqueue= *vq,=0A= >>>> __rte_unused struct rte_mbuf = *m) {=0A= >>>> return -1;=0A= >>>> }=0A= >>>> #endif=0A= >>>>=0A= >>>> and remove most #ifdef ... #endif in *.c file.=0A= >>>>=0A= >>> I guess, above approach wont work for non-x86 arch, ad those func are= =0A= >>> dummy, right? also code wont build for arm/non-86 arch because=0A= >>> tx/rx_pkt_burst callback will be using x86 specific virtio vec rx/tx=0A= >>> api.=0A= >> You may right, but you really need to reduce the #ifdef in *.c files.=0A= > In general, yes. But for this case, no: those vec stuff are for=0A= > platforms that support it. For other platforms, we should not=0A= > invoke a dummy function like virtio_rxq_vec_setup() at all.=0A= >=0A= > The right way to go is to add another wrapper beyond the vector=0A= > stuff, something like:=0A= >=0A= > virtio_rxq_setup()=0A= > {=0A= >=0A= > if (has_vec_support)=0A= > virtio_rxq_vec_setup();=0A= > else=0A= > virtio_rxq_generic_setup();=0A= > }=0A= =0A= Actually, we could call vec first and if set up failed, fall back to=0A= simple mode. Thus we could use dummy func, and it could make lift simple.= =0A= =0A= Thanks,=0A= Michael=0A= > Where virtio_rxq_vec_setup() could have a per-arch implementation,=0A= > say for X86, or ARM.=0A= >=0A= > It touchs more code, but for now, I'd like to make it simple first.=0A= > With the virtio_rxtx_simple.c isolated from Makefile, there aren't=0A= > many #ifdef after all.=0A= >=0A= > --yliu=0A= >=0A= =0A=