From patchwork Thu Oct 18 09:29:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 47033 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 139F61B107; Thu, 18 Oct 2018 11:29:43 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 6CCF61B0FC for ; Thu, 18 Oct 2018 11:29:41 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C25265996; Thu, 18 Oct 2018 09:29:40 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E62BF60BE4; Thu, 18 Oct 2018 09:29:37 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, jfreimann@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com, jasowang@redhat.com, mst@redhat.com Cc: Maxime Coquelin Date: Thu, 18 Oct 2018 11:29:23 +0200 Message-Id: <20181018092924.23402-2-maxime.coquelin@redhat.com> In-Reply-To: <20181018092924.23402-1-maxime.coquelin@redhat.com> References: <20181018092924.23402-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 18 Oct 2018 09:29:40 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 1/2] vhost: add packed ring support to vring base requests 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" For packed ring layout, we need save and restore avail and used indexes, and their wrap counter values. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 508228a3c..c712c9a40 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -696,10 +696,24 @@ vhost_user_set_vring_base(struct virtio_net **pdev, int main_fd __rte_unused) { struct virtio_net *dev = *pdev; - dev->virtqueue[msg->payload.state.index]->last_used_idx = - msg->payload.state.num; - dev->virtqueue[msg->payload.state.index]->last_avail_idx = - msg->payload.state.num; + struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index]; + uint64_t val = msg->payload.state.num; + + if (vq_is_packed(dev)) { + /* + * Bit[0:14]: avail index + * Bit[15]: avail wrap counter + * Bit[16:30]: used index + * Bit[31]: used wrap counter + */ + vq->last_avail_idx = (val & 0x1f); + vq->avail_wrap_counter = (val & (0x1 << 15) >> 15); + vq->last_used_idx = (val & (0x1f << 16)) >> 16; + vq->used_wrap_counter = (val & (0x1 << 31) >> 31); + } else { + vq->last_used_idx = msg->payload.state.num; + vq->last_avail_idx = msg->payload.state.num; + } return VH_RESULT_OK; } @@ -1208,6 +1222,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev, { struct virtio_net *dev = *pdev; struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index]; + uint64_t val; /* We have to stop the queue (virtio) if it is running. */ vhost_destroy_device_notify(dev); @@ -1215,8 +1230,22 @@ vhost_user_get_vring_base(struct virtio_net **pdev, dev->flags &= ~VIRTIO_DEV_READY; dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED; - /* Here we are safe to get the last avail index */ - msg->payload.state.num = vq->last_avail_idx; + /* Here we are safe to get the indexes */ + if (vq_is_packed(dev)) { + /* + * Bit[0:14]: avail index + * Bit[15]: avail wrap counter + * Bit[16:30]: used index + * Bit[31]: used wrap counter + */ + val = vq->last_avail_idx & 0x1f; + val |= vq->avail_wrap_counter << 15; + val |= (vq->last_used_idx & 0x1f) << 16; + val |= vq->used_wrap_counter << 31; + msg->payload.state.num = val; + } else { + msg->payload.state.num = vq->last_avail_idx; + } RTE_LOG(INFO, VHOST_CONFIG, "vring base idx:%d file:%d\n", msg->payload.state.index, From patchwork Thu Oct 18 09:29:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 47034 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E25B41B122; Thu, 18 Oct 2018 11:29:44 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 45AB91B11D for ; Thu, 18 Oct 2018 11:29:44 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F198308FB94; Thu, 18 Oct 2018 09:29:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 029F6608F6; Thu, 18 Oct 2018 09:29:40 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, jfreimann@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com, jasowang@redhat.com, mst@redhat.com Cc: Maxime Coquelin Date: Thu, 18 Oct 2018 11:29:24 +0200 Message-Id: <20181018092924.23402-3-maxime.coquelin@redhat.com> In-Reply-To: <20181018092924.23402-1-maxime.coquelin@redhat.com> References: <20181018092924.23402-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 18 Oct 2018 09:29:43 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 2/2] vhost: advertize packed ring layout support 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" Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index b4abad30c..760f42192 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -275,7 +275,8 @@ struct vring_packed_desc_event { (1ULL << VIRTIO_RING_F_EVENT_IDX) | \ (1ULL << VIRTIO_NET_F_MTU) | \ (1ULL << VIRTIO_F_IN_ORDER) | \ - (1ULL << VIRTIO_F_IOMMU_PLATFORM)) + (1ULL << VIRTIO_F_IOMMU_PLATFORM) | \ + (1ULL << VIRTIO_F_RING_PACKED)) struct guest_page {