From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D8C0AA0613 for ; Mon, 23 Sep 2019 11:15:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0AD5A37B4; Mon, 23 Sep 2019 11:15:14 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 7419C343C for ; Mon, 23 Sep 2019 11:15:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 02:15:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="190606559" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 23 Sep 2019 02:15:10 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Sep 2019 02:15:09 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.140]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0439.000; Mon, 23 Sep 2019 17:15:08 +0800 From: "Liu, Yong" To: "Gavin Hu (Arm Technology China)" , "maxime.coquelin@redhat.com" , "Bie, Tiwei" , "Wang, Zhihong" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue function Thread-Index: AQHVce6fwSDV/rFOr0+3m3CnoXFzYqc4+YNQ Date: Mon, 23 Sep 2019 09:15:07 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E633A9CD0@SHSMSX103.ccr.corp.intel.com> References: <20190905161421.55981-2-yong.liu@intel.com> <20190919163643.24130-1-yong.liu@intel.com> <20190919163643.24130-2-yong.liu@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzVmZjkyOTYtM2E2ZC00NzJmLWI3ZWMtYzNlMjAwMWJjZTE1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoickdhcHdPdmg2MDQrS0NqajdqYlVhYThvZDlUN2ptTTQwT1pQY0tlSDVrRDJHN2w2M1ZWR1Q3VVNZQUhcL2duRU8ifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Gavin Hu (Arm Technology China) [mailto:Gavin.Hu@arm.com] > Sent: Monday, September 23, 2019 5:09 PM > To: Liu, Yong ; maxime.coquelin@redhat.com; Bie, Tiwe= i > ; Wang, Zhihong > Cc: dev@dpdk.org > Subject: RE: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue > function >=20 > Hi Marvin, >=20 > > -----Original Message----- > > From: dev On Behalf Of Marvin Liu > > Sent: Friday, September 20, 2019 12:36 AM > > To: maxime.coquelin@redhat.com; tiwei.bie@intel.com; > > zhihong.wang@intel.com > > Cc: dev@dpdk.org; Marvin Liu > > Subject: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue > > function > > > > Add vhost enqueue function for single packet and meanwhile left space > > for flush used ring function. > > > > Signed-off-by: Marvin Liu > > > > diff --git a/lib/librte_vhost/virtio_net.c > b/lib/librte_vhost/virtio_net.c > > index 5b85b832d..2b5c47145 100644 > > --- a/lib/librte_vhost/virtio_net.c > > +++ b/lib/librte_vhost/virtio_net.c > > @@ -774,6 +774,70 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct > > vhost_virtqueue *vq, > > return error; > > } > > > > +/* > > + * Returns -1 on fail, 0 on success > > + */ > > +static __rte_always_inline int > > +vhost_enqueue_single_packed(struct virtio_net *dev, struct > > vhost_virtqueue *vq, > > + struct rte_mbuf *pkt, struct buf_vector *buf_vec, uint16_t > > *nr_descs) > > +{ > > + uint16_t nr_vec =3D 0; > > + > > + uint16_t avail_idx; > > + uint16_t max_tries, tries =3D 0; > > + > > + uint16_t buf_id =3D 0; > > + uint32_t len =3D 0; > > + uint16_t desc_count; > > + > > + uint32_t size =3D pkt->pkt_len + dev->vhost_hlen; > > + avail_idx =3D vq->last_avail_idx; > > + > > + if (rxvq_is_mergeable(dev)) > > + max_tries =3D vq->size - 1; > > + else > > + max_tries =3D 1; > > + > > + uint16_t num_buffers =3D 0; > > + > > + while (size > 0) { > > + /* > > + * if we tried all available ring items, and still > > + * can't get enough buf, it means something abnormal > > + * happened. > > + */ > > + if (unlikely(++tries > max_tries)) > > + return -1; > > + > > + if (unlikely(fill_vec_buf_packed(dev, vq, > > + avail_idx, &desc_count, > > + buf_vec, &nr_vec, > > + &buf_id, &len, > > + VHOST_ACCESS_RW) < 0)) { > > + return -1; > > + } > > + > > + len =3D RTE_MIN(len, size); > > + > > + size -=3D len; > > + > > + avail_idx +=3D desc_count; > > + if (avail_idx >=3D vq->size) > > + avail_idx -=3D vq->size; > > + > > + *nr_descs +=3D desc_count; > > + num_buffers +=3D 1; > > + } > > + > > + if (copy_mbuf_to_desc(dev, vq, pkt, > > + buf_vec, nr_vec, > > + num_buffers) < 0) { > > + return 0; > Why return 0, which means success, while "copy_mbuf_to_desc" encounters > some problems and failed? > /Gavin Gavin, Thanks for notice this typo issue. Here should return negative value -1. Regards, Marvin > > + } > > + > > + return 0; > > +} > > + > > static __rte_noinline uint32_t > > virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq= , > > struct rte_mbuf **pkts, uint32_t count) > > @@ -831,6 +895,35 @@ virtio_dev_rx_split(struct virtio_net *dev, struct > > vhost_virtqueue *vq, > > return pkt_idx; > > } > > > > +static __rte_unused int16_t > > +virtio_dev_rx_single_packed(struct virtio_net *dev, struct > vhost_virtqueue > > *vq, > > + struct rte_mbuf *pkt) > > +{ > > + struct buf_vector buf_vec[BUF_VECTOR_MAX]; > > + uint16_t nr_descs =3D 0; > > + > > + rte_smp_rmb(); > > + if (unlikely(vhost_enqueue_single_packed(dev, vq, pkt, buf_vec, > > + &nr_descs) < 0)) { > > + VHOST_LOG_DEBUG(VHOST_DATA, > > + "(%d) failed to get enough desc from > > vring\n", > > + dev->vid); > > + return -1; > > + } > > + > > + VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end > > index %d\n", > > + dev->vid, vq->last_avail_idx, > > + vq->last_avail_idx + nr_descs); > > + > > + vq->last_avail_idx +=3D nr_descs; > > + if (vq->last_avail_idx >=3D vq->size) { > > + vq->last_avail_idx -=3D vq->size; > > + vq->avail_wrap_counter ^=3D 1; > > + } > > + > > + return 0; > > +} > > + > > static __rte_noinline uint32_t > > virtio_dev_rx_packed(struct virtio_net *dev, struct vhost_virtqueue *v= q, > > struct rte_mbuf **pkts, uint32_t count) > > -- > > 2.17.1 >=20 > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy th= e > information in any medium. Thank you.