From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id DEB082BD2 for ; Wed, 1 Jun 2016 10:01:12 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 01 Jun 2016 01:01:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,400,1459839600"; d="scan'208";a="988676582" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by orsmga002.jf.intel.com with ESMTP; 01 Jun 2016 01:00:49 -0700 Date: Wed, 1 Jun 2016 16:03:41 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, Huawei Xie , rich.lane@bigswitch.com, mst@redhat.com, nakajima.yoshihiro@lab.ntt.co.jp, p.fedin@samsung.com, ann.zhuangyanying@huawei.com, mukawa@igel.co.jp, nhorman@tuxdriver.com Message-ID: <20160601080341.GE10038@yliu-dev.sh.intel.com> References: <1446748276-132087-1-git-send-email-jianfeng.tan@intel.com> <1464605739-140761-1-git-send-email-jianfeng.tan@intel.com> <1464605739-140761-4-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464605739-140761-4-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v5 3/8] virtio: enable use virtual address to fill desc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2016 08:01:13 -0000 On Mon, May 30, 2016 at 10:55:34AM +0000, Jianfeng Tan wrote: > This patch is related to how to calculate relative address for vhost > backend. > > The principle is that: based on one or multiple shared memory regions, > vhost maintains a reference system with the frontend start address, > backend start address, and length for each segment, so that each > frontend address (GPA, Guest Physical Address) can be translated into > vhost-recognizable backend address. To make the address translation > efficient, we need to maintain as few regions as possible. In the case > of VM, GPA is always locally continuous. But for some other case, like > virtio-user, we use virtual address here. > > It basically means: > a. when set_base_addr, VA address is used; > b. when preparing RX's descriptors, VA address is used; > c. when transmitting packets, VA is filled in TX's descriptors; > d. in TX and CQ's header, VA is used. > > Signed-off-by: Huawei Xie > Signed-off-by: Jianfeng Tan > Acked-by: Neil Horman > --- > drivers/net/virtio/virtio_ethdev.c | 21 ++++++++++++++++----- > drivers/net/virtio/virtio_rxtx.c | 5 ++--- > drivers/net/virtio/virtio_rxtx_simple.c | 13 +++++++------ > drivers/net/virtio/virtqueue.h | 13 ++++++++++++- > 4 files changed, 37 insertions(+), 15 deletions(-) > > @@ -419,8 +419,6 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, > vq->virtio_net_hdr_mem = hdr_mz->phys_addr; > > memset(hdr_mz->addr, 0, hdr_mz_sz); > - vring_hdr_desc_init(vq); > - > } else if (queue_type == VTNET_CQ) { > /* Allocate a page for control vq command, data and status */ > snprintf(vq_name, sizeof(vq_name), "port%d_cvq_hdrzone", > @@ -441,6 +439,19 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, > memset(vq->virtio_net_hdr_mz->addr, 0, PAGE_SIZE); > } > > + if (dev->pci_dev) > + vq->offset = offsetof(struct rte_mbuf, buf_physaddr); > + else { > + vq->vq_ring_mem = (phys_addr_t)vq->mz->addr; > + vq->offset = offsetof(struct rte_mbuf, buf_addr); > + if (vq->virtio_net_hdr_mz) > + vq->virtio_net_hdr_mem = > + (phys_addr_t)vq->virtio_net_hdr_mz->addr; > + } I guess this piece of code deserves some comments. Say, for virtio-user case (that is when dev->pci_dev is NULL), we use virtual address, because, bala, bala ... > @@ -165,6 +173,7 @@ struct virtqueue { > void *vq_ring_virt_mem; /**< linear address of vring*/ > unsigned int vq_ring_size; > phys_addr_t vq_ring_mem; /**< physical address of vring */ > + /**< use virtual address for vdev. */ Replace vdev with "virtio-user" is better here? --yliu