From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2524BA04BC; Fri, 9 Oct 2020 10:21:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 53B8A1C1E0; Fri, 9 Oct 2020 10:20:40 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 3C1941C1D3 for ; Fri, 9 Oct 2020 10:20:37 +0200 (CEST) IronPort-SDR: pcxgFwBzV9nlTkCRYluJntPSL5FN7mchOTNB2Q3yXu64K48Luzeo4fQs5tJHTPstP33Msbmth1 WqDA6OjUJ+ZQ== X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="144778911" X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="144778911" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2020 01:20:35 -0700 IronPort-SDR: Qi28qAPXPAhGeQQMql8OMw2qR2mkwXdygZN1hmOYzWTnptr4agyac7+xaYO4YIskDBpeCMiJAY vX8d4WxAeBgg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="528833341" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.56]) by orsmga005.jf.intel.com with ESMTP; 09 Oct 2020 01:20:33 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org, Marvin Liu Date: Fri, 9 Oct 2020 16:14:08 +0800 Message-Id: <20201009081410.63944-4-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201009081410.63944-1-yong.liu@intel.com> References: <20200819032414.51430-2-yong.liu@intel.com> <20201009081410.63944-1-yong.liu@intel.com> Subject: [dpdk-dev] [PATCH v3 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 12b7699cf..a19fe9423 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) @@ -349,6 +351,11 @@ struct inflight_mem_info { uint64_t size; }; +struct mem_regions_range { + uint64_t regions_low_addrs[MAX_NREGIONS]; + uint64_t regions_high_addrs[MAX_NREGIONS]; +}; + /** * Device structure contains all configuration information relating * to the device. @@ -356,6 +363,7 @@ struct inflight_mem_info { struct virtio_net { /* Frontend (QEMU) memory and memory region information */ struct rte_vhost_memory *mem; + struct mem_regions_range *regions_range; 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 4deceb3e0..2d2a2a1a3 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -185,6 +185,11 @@ vhost_backend_cleanup(struct virtio_net *dev) dev->inflight_info = NULL; } + if (dev->regions_range) { + free(dev->regions_range); + dev->regions_range = NULL; + } + if (dev->slave_req_fd >= 0) { close(dev->slave_req_fd); dev->slave_req_fd = -1; @@ -1230,6 +1235,27 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg, } } + RTE_BUILD_BUG_ON(VHOST_MEMORY_MAX_NREGIONS != 8); + if (dev->vectorized) { + if (dev->regions_range == NULL) { + dev->regions_range = calloc(1, + sizeof(struct mem_regions_range)); + if (!dev->regions_range) { + VHOST_LOG_CONFIG(ERR, + "failed to alloc dev vectorized area\n"); + return RTE_VHOST_MSG_RESULT_ERR; + } + } + + for (i = 0; i < memory->nregions; i++) { + dev->regions_range->regions_low_addrs[i] = + memory->regions[i].guest_phys_addr; + dev->regions_range->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]; -- 2.17.1