From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2239BA00C3; Tue, 19 Apr 2022 05:45:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4754341611; Tue, 19 Apr 2022 05:45:00 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 7FC3A40150 for ; Tue, 19 Apr 2022 05:44:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650339898; x=1681875898; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=P51t1JH9TdZMrevfhvGJM2vHia8B+7/9JAkwRRBYwqI=; b=YP3WZ4a9sgVK0f4Yc0V5n4HvsXdAdxnPAc8LcHV5HX0sW3QA9n5we1hT Om5yl46YBOsgtKFrfMMgyiv/RZL9jLPvszTPgFe71toLFKMEuluCCYT7J jvJ19nbSyeMGA8P1FEfVMtltFpCKxsh/YyHyi4gPxk9Wcy0aDnNez5+A/ 8u23dQ6Fg8dgaOldleg0qbGNAGDRpXKRTqtGnNN2E24oV+JjWdJr887ne +cQmpyIVKO71sOcNo1cQn6TtM8gRoFIOEBS3JXlnC7nYSArWLm4h6zKtl 9sHZkZtru03h+FSeZrJtplEkkHgVHTETXpiyyMpXjWa8jbrv5Gklwlh9l w==; X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="263425287" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="263425287" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 20:44:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="529134004" Received: from npg-dpdk-xuan-cbdma.sh.intel.com ([10.67.110.228]) by orsmga006.jf.intel.com with ESMTP; 18 Apr 2022 20:44:54 -0700 From: xuan.ding@intel.com To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, jiayu.hu@intel.com, cheng1.jiang@intel.com, sunil.pai.g@intel.com, liangma@liangbit.com, Xuan Ding Subject: [PATCH v3 2/5] vhost: prepare async for descriptor to mbuf refactoring Date: Tue, 19 Apr 2022 03:43:20 +0000 Message-Id: <20220419034323.92820-3-xuan.ding@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220419034323.92820-1-xuan.ding@intel.com> References: <20220407152546.38167-1-xuan.ding@intel.com> <20220419034323.92820-1-xuan.ding@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Xuan Ding This patch refactors vhost async enqueue path and dequeue path to use the same function async_fill_seg() for preparing batch elements, which simplifies the code without performance degradation. Signed-off-by: Xuan Ding --- lib/vhost/virtio_net.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 6d53016c75..391fb82f0e 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -997,13 +997,14 @@ async_iter_reset(struct vhost_async *async) } static __rte_always_inline int -async_mbuf_to_desc_seg(struct virtio_net *dev, struct vhost_virtqueue *vq, +async_fill_seg(struct virtio_net *dev, struct vhost_virtqueue *vq, struct rte_mbuf *m, uint32_t mbuf_offset, - uint64_t buf_iova, uint32_t cpy_len) + uint64_t buf_iova, uint32_t cpy_len, bool to_desc) { struct vhost_async *async = vq->async; uint64_t mapped_len; uint32_t buf_offset = 0; + void *src, *dst; void *host_iova; while (cpy_len) { @@ -1015,10 +1016,16 @@ async_mbuf_to_desc_seg(struct virtio_net *dev, struct vhost_virtqueue *vq, return -1; } - if (unlikely(async_iter_add_iovec(dev, async, - (void *)(uintptr_t)rte_pktmbuf_iova_offset(m, - mbuf_offset), - host_iova, (size_t)mapped_len))) + if (to_desc) { + src = (void *)(uintptr_t)rte_pktmbuf_iova_offset(m, mbuf_offset); + dst = host_iova; + } else { + src = host_iova; + dst = (void *)(uintptr_t)rte_pktmbuf_iova_offset(m, mbuf_offset); + } + + if (unlikely(async_iter_add_iovec(dev, async, src, dst, + (size_t)mapped_len))) return -1; cpy_len -= (uint32_t)mapped_len; @@ -1167,8 +1174,8 @@ mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, cpy_len = RTE_MIN(buf_avail, mbuf_avail); if (is_async) { - if (async_mbuf_to_desc_seg(dev, vq, m, mbuf_offset, - buf_iova + buf_offset, cpy_len) < 0) + if (async_fill_seg(dev, vq, m, mbuf_offset, + buf_iova + buf_offset, cpy_len, true) < 0) goto error; } else { sync_fill_seg(dev, vq, m, mbuf_offset, -- 2.17.1