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 93E107EB8 for ; Tue, 14 Oct 2014 18:20:37 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 14 Oct 2014 09:27:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,718,1406617200"; d="scan'208";a="614352095" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga002.fm.intel.com with ESMTP; 14 Oct 2014 09:26:27 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 14 Oct 2014 09:26:27 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 14 Oct 2014 09:26:27 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.203]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.190]) with mapi id 14.03.0195.001; Wed, 15 Oct 2014 00:26:25 +0800 From: "Xie, Huawei" To: "Ouyang, Changchun" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4] virtio: Fix vring entry number issue Thread-Index: AQHP58mV2d8fl47fYUGu5xxp2btvAZwvx1kw Date: Tue, 14 Oct 2014 16:26:25 +0000 Message-ID: References: <1413299561-31263-1-git-send-email-changchun.ouyang@intel.com> <1413302634-848-1-git-send-email-changchun.ouyang@intel.com> In-Reply-To: <1413302634-848-1-git-send-email-changchun.ouyang@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 Subject: Re: [dpdk-dev] [PATCH v4] virtio: Fix vring entry number issue 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: Tue, 14 Oct 2014 16:20:38 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ouyang Changchun > Sent: Tuesday, October 14, 2014 9:04 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v4] virtio: Fix vring entry number issue >=20 > Fix one issue in virtio TX: it needs one more vring descriptor to hold = the virtio > header when transmitting packets, it is used later to determine whether= to free > more entries from used vring. > It fixes failing to transmit any packet with 1 segment in the circumsta= nce of > only > 1 descriptor in the vring free list. >=20 > Signed-off-by: Changchun Ouyang > Reviewed-by: Olivier Matz > --- > -V4 change: > Relocate those changelog and annotation here. >=20 > -V3 change: > Resolve compilation issue due to mbuf re-structure. >=20 > -V2 change: > Refine description, 'vring descriptor' is more accurate than 'vring ent= ry'; > Accordingly update test condition (it needs one more descriptor for vir= tio > header) to > put packets to transmit queue. >=20 > -V1 change: > Fix the vring descriptor issue in virtio TX, it needs one more vring de= scriptor to > hold the > virtio header. >=20 > lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c > b/lib/librte_pmd_virtio/virtio_rxtx.c > index 0b10108..ac44c65 100644 > --- a/lib/librte_pmd_virtio/virtio_rxtx.c > +++ b/lib/librte_pmd_virtio/virtio_rxtx.c > @@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf > **tx_pkts, uint16_t nb_pkts) > num =3D (uint16_t)(likely(nb_used < VIRTIO_MBUF_BURST_SZ) ? nb_used : > VIRTIO_MBUF_BURST_SZ); >=20 > while (nb_tx < nb_pkts) { > - int need =3D tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; > + /* Need one more descriptor for virtio header. */ > + int need =3D tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt + 1; > int deq_cnt =3D RTE_MIN(need, (int)num); >=20 > num -=3D (deq_cnt > 0) ? deq_cnt : 0; > @@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf > **tx_pkts, uint16_t nb_pkts) > deq_cnt--; > } >=20 > - if (tx_pkts[nb_tx]->pkt.nb_segs <=3D txvq->vq_free_cnt) { > + need =3D (int)tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt + 1; > + /* > + * Zero or negative value indicates it has enough free > + * decriptors to transmit. > + */ > + if (need <=3D 0) { Could we put a branch hint to favor the fast path? > txm =3D tx_pkts[nb_tx]; > /* Enqueue Packet buffers */ > error =3D virtqueue_enqueue_xmit(txvq, txm); > -- > 1.8.4.2