From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH 2/5] vhost: refactor virtio_dev_rx Date: Mon, 14 Dec 2015 09:47:16 +0800 Message-ID: <20151214014716.GY29571@yliu-dev.sh.intel.com> References: <1449122773-25510-1-git-send-email-yuanhan.liu@linux.intel.com> <1449122773-25510-3-git-send-email-yuanhan.liu@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org, Victor Kaplansky , "Michael S. Tsirkin" To: Rich Lane Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 516438D39 for ; Mon, 14 Dec 2015 02:46:58 +0100 (CET) Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Dec 11, 2015 at 12:42:33PM -0800, Rich Lane wrote: > On Wed, Dec 2, 2015 at 10:06 PM, Yuanhan Liu > wrote: >=20 > +static inline int __attribute__((always_inline)) > +copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *= vq, > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct rte_mbuf *m, uint16_t de= sc_idx, uint32_t *copied) > +{ > ... > +=A0 =A0 =A0 =A0while (1) { > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* done with current mbuf, fetch ne= xt */ > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (mbuf_avail =3D=3D 0) { > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m =3D m->next; > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (m =3D=3D NULL) > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bre= ak; > + > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mbuf_offset =3D 0; > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mbuf_avail=A0 =3D r= te_pktmbuf_data_len(m); > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > + > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* done with current desc buf, fetc= h next */ > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (desc_avail =3D=3D 0) { > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if ((desc->flags & = VRING_DESC_F_NEXT) =3D=3D 0) { > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* = Room in vring buffer is not enough */ > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret= urn -1; > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > + > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0desc =3D &vq->desc[= desc->next]; > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0desc_addr=A0 =A0=3D= gpa_to_vva(dev, desc->addr); > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0desc_offset =3D 0; > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0desc_avail=A0 =3D d= esc->len; > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > + > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0COPY(desc_addr + desc_offset, > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rte_pktmbuf_mtod_of= fset(m, uint64_t, mbuf_offset)); > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PRINT_PACKET(dev, (uintptr_t)(desc_= addr + desc_offset), > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cpy_len, 0= ); > +=A0 =A0 =A0 =A0} > +=A0 =A0 =A0 =A0*copied =3D rte_pktmbuf_pkt_len(m); >=20 >=20 > AFAICT m will always be NULL at this point so the call to rte_pktmbuf_l= en will > segfault. Right, I should move it in the beginning of this function. --yliu