From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id D30FB81A9 for ; Sat, 11 Oct 2014 09:58:12 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 11 Oct 2014 00:55:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,697,1406617200"; d="scan'208";a="603788300" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 11 Oct 2014 01:05:41 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9B85d6U029416; Sat, 11 Oct 2014 16:05:39 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9B85bGE024726; Sat, 11 Oct 2014 16:05:39 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9B85bVB024722; Sat, 11 Oct 2014 16:05:37 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Sat, 11 Oct 2014 16:05:35 +0800 Message-Id: <1413014735-24693-1-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH v2] 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: Sat, 11 Oct 2014 07:58:13 -0000 -- 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. It fixes failing to transmit any packet with 1 segment in the circumstance of only 1 descriptor in the vring free list. -- V2 change: Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtio header) to put packets to transmit queue. Signed-off-by: Changchun Ouyang --- lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c index 0b10108..c736362 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 = (uint16_t)(likely(nb_used < VIRTIO_MBUF_BURST_SZ) ? nb_used : VIRTIO_MBUF_BURST_SZ); while (nb_tx < nb_pkts) { - int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; + /* Need one more descriptor for virtio header. */ + int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt + 1; int deq_cnt = RTE_MIN(need, (int)num); num -= (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--; } - if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int)tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt + 1; + /* + * Zero or negative value indicates it has enough free + * decriptors to transmit. + */ + if (need <= 0) { txm = tx_pkts[nb_tx]; /* Enqueue Packet buffers */ error = virtqueue_enqueue_xmit(txvq, txm); -- 1.8.4.2