From patchwork Mon Sep 21 06:48:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Liu X-Patchwork-Id: 78147 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 664FCA04B7; Mon, 21 Sep 2020 08:53:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 143C11D975; Mon, 21 Sep 2020 08:53:03 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id F00B41D94B for ; Mon, 21 Sep 2020 08:52:58 +0200 (CEST) IronPort-SDR: qt8VbfCP9fLxyQPd2od/KOBBVBX55rPsGDjejUoDLVw/BAhVuePeUkU/hBP0CtfwxnhxeyGxA5 M1oREEOygI5A== X-IronPort-AV: E=McAfee;i="6000,8403,9750"; a="148073434" X-IronPort-AV: E=Sophos;i="5.77,285,1596524400"; d="scan'208";a="148073434" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 23:52:58 -0700 IronPort-SDR: NQmADq6KgTkR70u7uVftooYttFtdd6/cZzsZq+qkmICU/uIXvPICx8C22hSS9SMEwvD61q8dgD dMtOlAV4NyWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,285,1596524400"; d="scan'208";a="412078413" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.56]) by fmsmga001.fm.intel.com with ESMTP; 20 Sep 2020 23:52:57 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org, Marvin Liu Date: Mon, 21 Sep 2020 14:48:35 +0800 Message-Id: <20200921064837.15957-4-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921064837.15957-1-yong.liu@intel.com> References: <20200819032414.51430-2-yong.liu@intel.com> <20200921064837.15957-1-yong.liu@intel.com> Subject: [dpdk-dev] [PATCH v2 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];