From patchwork Wed Aug 19 03:24:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Liu X-Patchwork-Id: 75698 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A2896A04AF; Wed, 19 Aug 2020 05:25:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 17F781C0B6; Wed, 19 Aug 2020 05:24:59 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id AEA191C0AD for ; Wed, 19 Aug 2020 05:24:56 +0200 (CEST) IronPort-SDR: +KMt5mXY9qQDcYX5IaEBHryOm6DRNcXHtwpl3vtn65D3Ji6PBrLBJiDYJOG+nwr1oGHMDFvEXZ LSlspt8al/aQ== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="156113178" X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="156113178" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 20:24:56 -0700 IronPort-SDR: 4GpTiJS9EqU3HPppayL6LzL0DgrquDxZxn2JbH8a9R0O+gIpWrfxBEeuxDEBesU8tncj62nNFm aGc8p4V2oJMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="441452729" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.56]) by orsmga004.jf.intel.com with ESMTP; 18 Aug 2020 20:24:55 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org, Marvin Liu Date: Wed, 19 Aug 2020 11:24:12 +0800 Message-Id: <20200819032414.51430-4-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819032414.51430-1-yong.liu@intel.com> References: <20200819032414.51430-1-yong.liu@intel.com> Subject: [dpdk-dev] [PATCH v1 3/5] vhost: prepare memory regions addresses 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Prepare memory regions guest physical addresses for vectorized data path. These information will be utilized by SIMD instructions to find matched region index. Signed-off-by: Marvin Liu diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 5a5c945551..4a81f18f01 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -52,6 +52,8 @@ #define ASYNC_MAX_POLL_SEG 255 +#define MAX_NREGIONS 8 + #define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST * 2) #define VHOST_MAX_ASYNC_VEC (BUF_VECTOR_MAX * 2) @@ -375,6 +377,8 @@ struct inflight_mem_info { struct virtio_net { /* Frontend (QEMU) memory and memory region information */ struct rte_vhost_memory *mem; + uint64_t regions_low_addrs[MAX_NREGIONS]; + uint64_t regions_high_addrs[MAX_NREGIONS]; uint64_t features; uint64_t protocol_features; int vid; diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index c3c924faec..89e75e9e71 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1291,6 +1291,17 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg, } } + RTE_BUILD_BUG_ON(VHOST_MEMORY_MAX_NREGIONS != 8); + if (dev->vectorized) { + for (i = 0; i < memory->nregions; i++) { + dev->regions_low_addrs[i] = + memory->regions[i].guest_phys_addr; + dev->regions_high_addrs[i] = + memory->regions[i].guest_phys_addr + + memory->regions[i].memory_size; + } + } + for (i = 0; i < dev->nr_vring; i++) { struct vhost_virtqueue *vq = dev->virtqueue[i];