From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2CBF62BC7 for ; Wed, 19 Dec 2018 12:20:23 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2018 03:20:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,372,1539673200"; d="scan'208";a="119527832" Received: from dpdk-tbie.sh.intel.com ([10.67.104.173]) by orsmga002.jf.intel.com with ESMTP; 19 Dec 2018 03:20:21 -0800 Date: Wed, 19 Dec 2018 19:18:18 +0800 From: Tiwei Bie To: Maxime Coquelin Cc: dev@dpdk.org, jfreimann@redhat.com, zhihong.wang@intel.com Message-ID: <20181219111818.GA3443@dpdk-tbie.sh.intel.com> References: <20181211134804.10318-1-maxime.coquelin@redhat.com> <20181211134804.10318-4-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181211134804.10318-4-maxime.coquelin@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/virtio: improve batching in mergeable path 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, 19 Dec 2018 11:20:24 -0000 On Tue, Dec 11, 2018 at 02:48:04PM +0100, Maxime Coquelin wrote: > This patch improves both descriptors dequeue and refill, > by using the same bathing strategy as done in in-order path. > > Signed-off-by: Maxime Coquelin > --- > drivers/net/virtio/virtio_rxtx.c | 237 ++++++++++++++++--------------- > 1 file changed, 126 insertions(+), 111 deletions(-) > > diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c > index ebe5c74b5..59bcac2f7 100644 > --- a/drivers/net/virtio/virtio_rxtx.c > +++ b/drivers/net/virtio/virtio_rxtx.c > @@ -267,41 +267,42 @@ virtqueue_enqueue_refill_inorder(struct virtqueue *vq, > } > > static inline int > -virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie) > +virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf **cookie, > + uint16_t num) > { > struct vq_desc_extra *dxp; > struct virtio_hw *hw = vq->hw; > - struct vring_desc *start_dp; > - uint16_t needed = 1; > - uint16_t head_idx, idx; > + struct vring_desc *start_dp = vq->vq_ring.desc; > + uint16_t idx, i; > > if (unlikely(vq->vq_free_cnt == 0)) > return -ENOSPC; > - if (unlikely(vq->vq_free_cnt < needed)) > + if (unlikely(vq->vq_free_cnt < num)) > return -EMSGSIZE; > > - head_idx = vq->vq_desc_head_idx; > - if (unlikely(head_idx >= vq->vq_nentries)) > + if (unlikely(vq->vq_desc_head_idx >= vq->vq_nentries)) > return -EFAULT; > > - idx = head_idx; > - dxp = &vq->vq_descx[idx]; > - dxp->cookie = (void *)cookie; > - dxp->ndescs = needed; > + for (i = 0; i < num; i++) { > + idx = vq->vq_desc_head_idx; > + dxp = &vq->vq_descx[idx]; > + dxp->cookie = (void *)cookie[i]; > + dxp->ndescs = 1; > > - start_dp = vq->vq_ring.desc; > - start_dp[idx].addr = > - VIRTIO_MBUF_ADDR(cookie, vq) + > - RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; > - start_dp[idx].len = > - cookie->buf_len - RTE_PKTMBUF_HEADROOM + hw->vtnet_hdr_size; > - start_dp[idx].flags = VRING_DESC_F_WRITE; > - idx = start_dp[idx].next; > - vq->vq_desc_head_idx = idx; > - if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END) > - vq->vq_desc_tail_idx = idx; > - vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - needed); > - vq_update_avail_ring(vq, head_idx); > + start_dp[idx].addr = > + VIRTIO_MBUF_ADDR(cookie[i], vq) + > + RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; > + start_dp[idx].len = > + cookie[i]->buf_len - RTE_PKTMBUF_HEADROOM + > + hw->vtnet_hdr_size; > + start_dp[idx].flags = VRING_DESC_F_WRITE; > + vq->vq_desc_head_idx = start_dp[idx].next; > + if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END) > + vq->vq_desc_tail_idx = vq->vq_desc_head_idx; It's better to break the loop here. Or maybe move this check out of the loop. > + vq_update_avail_ring(vq, idx); > + } > + > + vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num); > > return 0; > } [...]