From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 377D97E99 for ; Tue, 14 Oct 2014 17:21:12 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 14 Oct 2014 08:21:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,717,1406617200"; d="scan'208";a="618466173" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 14 Oct 2014 08:28:11 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 14 Oct 2014 08:28:11 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 14 Oct 2014 08:28:10 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.192]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.204]) with mapi id 14.03.0195.001; Tue, 14 Oct 2014 23:28:02 +0800 From: "Ouyang, Changchun" To: 'Olivier MATZ' Thread-Topic: [PATCH v3] virtio: Fix vring entry number issue Thread-Index: AQHP58FesLVJYPXg3UeXQsuoXSXADZwvtnhQ Date: Tue, 14 Oct 2014 15:28:02 +0000 Message-ID: References: <1413014735-24693-1-git-send-email-changchun.ouyang@intel.com> <1413299561-31263-1-git-send-email-changchun.ouyang@intel.com> In-Reply-To: <1413299561-31263-1-git-send-email-changchun.ouyang@intel.com> Accept-Language: zh-CN, 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 v3] 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 15:21:12 -0000 Hi Olivier, Any other comments for this v3 patch? Thanks and regards, Changchun > -----Original Message----- > From: Ouyang, Changchun > Sent: Tuesday, October 14, 2014 11:13 PM > To: dev@dpdk.org > Cc: Cao, Waterman; Ouyang, Changchun > Subject: [PATCH v3] virtio: Fix vring entry number issue >=20 > -- V1 change: > 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. >=20 > It fixes failing to transmit any packet with 1 segment in the circumsta= nce of > only > 1 descriptor in the vring free list. >=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 > -- V3 change: > Resolve compilation issue due to mbuf re-structure. >=20 > Signed-off-by: Changchun Ouyang > --- > 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) { > txm =3D tx_pkts[nb_tx]; > /* Enqueue Packet buffers */ > error =3D virtqueue_enqueue_xmit(txvq, txm); > -- > 1.8.4.2