From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 21CE72BEB for ; Wed, 4 Jul 2018 07:56:37 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 22:56:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="64001119" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.228]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2018 22:56:29 -0700 Date: Wed, 4 Jul 2018 13:56:30 +0800 From: Tiwei Bie To: Maxime Coquelin Cc: zhihong.wang@intel.com, jfreimann@redhat.com, dev@dpdk.org, mst@redhat.com, jasowang@redhat.com, wexu@redhat.com Message-ID: <20180704055630.GE28826@debian> References: <20180702081629.29258-1-maxime.coquelin@redhat.com> <20180702081629.29258-11-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180702081629.29258-11-maxime.coquelin@redhat.com> User-Agent: Mutt/1.9.5 (2018-04-13) Subject: Re: [dpdk-dev] [PATCH v6 10/15] vhost: create descriptor mapping 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: , X-List-Received-Date: Wed, 04 Jul 2018 05:56:38 -0000 On Mon, Jul 02, 2018 at 10:16:24AM +0200, Maxime Coquelin wrote: > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/virtio_net.c | 61 ++++++++++++++++++++++++++----------------- > 1 file changed, 37 insertions(+), 24 deletions(-) > > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c > index f0e2e6a1f..64664b7de 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -292,6 +292,37 @@ virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr) > } > } > > +static __rte_always_inline int > +map_one_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, > + struct buf_vector *buf_vec, uint16_t *vec_idx, > + uint64_t desc_iova, uint64_t desc_len, uint8_t perm) > +{ > + uint16_t vec_id = *vec_idx; > + > + while (desc_len) { > + uint64_t desc_addr; > + uint64_t desc_chunck_len = desc_len; > + > + desc_addr = vhost_iova_to_vva(dev, vq, > + desc_iova, > + &desc_chunck_len, > + perm); > + if (unlikely(!desc_addr)) > + return -1; > + > + buf_vec[vec_id].buf_iova = desc_iova; > + buf_vec[vec_id].buf_addr = desc_addr; > + buf_vec[vec_id].buf_len = desc_chunck_len; > + > + desc_len -= desc_chunck_len; > + desc_iova += desc_chunck_len; > + vec_id++; FYI, a rebase on top of the latest "vhost: generalize buffer vectors" series is needed to make sure that access buf_vec[vec_id] won't cause overflow. > + } > + *vec_idx = vec_id; > + > + return 0; > +} > + [...]