From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id D93E65A98 for ; Wed, 21 Jun 2017 04:59:46 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 20 Jun 2017 19:59:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,367,1493708400"; d="scan'208";a="101830352" Received: from dpdk25.sh.intel.com ([10.67.111.75]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2017 19:59:46 -0700 From: Tiwei Bie To: dev@dpdk.org Date: Wed, 21 Jun 2017 10:58:03 +0800 Message-Id: <1498013885-102779-28-git-send-email-tiwei.bie@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498013885-102779-1-git-send-email-tiwei.bie@intel.com> References: <1498013885-102779-1-git-send-email-tiwei.bie@intel.com> Subject: [dpdk-dev] [RFC 27/29] vhost: various optimizations for Tx 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, 21 Jun 2017 02:59:47 -0000 Signed-off-by: Tiwei Bie --- lib/librte_vhost/virtio_net.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 049b400..2d111a3 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -604,6 +604,8 @@ enqueue_pkt(struct virtio_net *dev, struct vring_desc_1_1 *descs, if (unlikely(desc->len < dev->vhost_hlen) || !desc_addr) return -1; + desc->len = m->pkt_len + dev->vhost_hlen; + rte_prefetch0((void *)(uintptr_t)desc_addr); hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr; @@ -632,6 +634,7 @@ enqueue_pkt(struct virtio_net *dev, struct vring_desc_1_1 *descs, return -1; } + rte_panic("Shouldn't reach here\n"); /** NOTE: we should not come here with current virtio-user implementation **/ desc_idx = (desc_idx + 1); // & (vq->size - 1); @@ -680,6 +683,8 @@ vhost_enqueue_burst_1_1(struct virtio_net *dev, uint16_t queue_id, head_idx = vq->last_used_idx; desc = vq->desc_1_1; + count = RTE_MIN(count, (uint32_t)MAX_PKT_BURST); + for (i = 0; i < count; i++) { /* XXX: there is an assumption that no desc will be chained */ idx = vq->last_used_idx & (vq->size - 1); @@ -693,11 +698,12 @@ vhost_enqueue_burst_1_1(struct virtio_net *dev, uint16_t queue_id, } count = i; - rte_smp_wmb(); - for (i = 0; i < count; i++) { - idx = (head_idx + i) & (vq->size - 1); - desc[idx].flags &= ~DESC_HW; - desc[idx].len = pkts[i]->pkt_len + dev->vhost_hlen; + if (count) { + rte_smp_wmb(); + for (i = 0; i < count; i++) { + idx = (head_idx + i) & (vq->size - 1); + desc[idx].flags &= ~DESC_HW; + } } return count; -- 2.7.4