From patchwork Thu May 14 08:02:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70209 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 4E780A00C3; Thu, 14 May 2020 10:02:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 380AE1D6A9; Thu, 14 May 2020 10:02:44 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 06A3B1D6A6 for ; Thu, 14 May 2020 10:02:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QM7NkTdmUfadt9y4RbM4DxyLCkkemp2dlmsstKvAgHk=; b=dpAoJ40wA/ZFgCln+C8+qZoTvOq90VfXJ3l2w2qcw27AONCiYmMTHaSubeW3iY4TF1+zRy k+xwOXVRXYnCSY/y+qOdMeycbes5EQ4JfsQJHqlysqbwSzwQqorutCO1DFTzJHoG5B2jqe hdWTSsOASVTL9z8sMemsdCPr+2sJfaM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-cY6IjMHtP1KBSXntIMbDAQ-1; Thu, 14 May 2020 04:02:40 -0400 X-MC-Unique: cY6IjMHtP1KBSXntIMbDAQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E854D107ACF2; Thu, 14 May 2020 08:02:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 750A861F50; Thu, 14 May 2020 08:02:36 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin , stable@dpdk.org Date: Thu, 14 May 2020 10:02:10 +0200 Message-Id: <20200514080218.1435344-2-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 1/9] vhost: fix virtio ready flag check 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" Before checking whether the device is ready is done a check on whether the RUNNING flag is set. Then the READY flag is set if virtio_is_ready() returns true. While it seems to not cause any issue, it makes more sense to check whether the READY flag is set and not the RUNNING one. Fixes: c0674b1bc898 ("vhost: move the device ready check at proper place") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 9c891d4c01..106b6d7609 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2784,7 +2784,7 @@ vhost_user_msg_handler(int vid, int fd) return -1; } - if (!(dev->flags & VIRTIO_DEV_RUNNING) && virtio_is_ready(dev)) { + if (!(dev->flags & VIRTIO_DEV_READY) && virtio_is_ready(dev)) { dev->flags |= VIRTIO_DEV_READY; if (!(dev->flags & VIRTIO_DEV_RUNNING)) { From patchwork Thu May 14 08:02:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70211 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 8D250A00C3; Thu, 14 May 2020 10:03:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 83E181D6C2; Thu, 14 May 2020 10:02:51 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 4A3401D674 for ; Thu, 14 May 2020 10:02:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L23EYYDQnt1kpmDXqzogWQoltBCFMyLVefIJOcVZvTg=; b=b3PC5ycQ9T1n3KgIAAZeJq18GQNT9wCvaNzClqIpVzRtjUIrt3oeihzxMlJiAiKrafVzeS cYrvqyZTotkl+J9wtos6VWP5lZwSoL8phplQb6rMJ4dDEitUzGIVkq5Dri6RJ030dHFbbF hy1svnDEJzWj7gEvlYVHQbLIhkaMpxo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-53-0bvbFdHhPnOZv2WL3eQmfg-1; Thu, 14 May 2020 04:02:43 -0400 X-MC-Unique: 0bvbFdHhPnOZv2WL3eQmfg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A286EC1A0; Thu, 14 May 2020 08:02:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C9E36E9E0; Thu, 14 May 2020 08:02:39 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:11 +0200 Message-Id: <20200514080218.1435344-3-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 2/9] vhost: refactor Virtio ready check 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" This patch is a small refactoring, as preliminary work for adding support to Virtio status support. No functionnal change here. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost.c | 1 + lib/librte_vhost/vhost_user.c | 40 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 0266318440..fd8ba1be2d 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -716,6 +716,7 @@ vhost_enable_dequeue_zero_copy(int vid) return; dev->dequeue_zero_copy = 1; + VHOST_LOG_CONFIG(INFO, "dequeue zero copy is enabled\n"); } void diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 106b6d7609..f5800bd9c1 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1315,6 +1315,9 @@ virtio_is_ready(struct virtio_net *dev) struct vhost_virtqueue *vq; uint32_t i; + if (dev->flags & VIRTIO_DEV_READY) + return 1; + if (dev->nr_vring == 0) return 0; @@ -1325,8 +1328,11 @@ virtio_is_ready(struct virtio_net *dev) return 0; } + dev->flags |= VIRTIO_DEV_READY; + VHOST_LOG_CONFIG(INFO, "virtio is now ready for processing.\n"); + return 1; } @@ -2606,7 +2612,6 @@ vhost_user_msg_handler(int vid, int fd) struct virtio_net *dev; struct VhostUserMsg msg; struct rte_vdpa_device *vdpa_dev; - int did = -1; int ret; int unlock_required = 0; bool handled; @@ -2784,30 +2789,33 @@ vhost_user_msg_handler(int vid, int fd) return -1; } - if (!(dev->flags & VIRTIO_DEV_READY) && virtio_is_ready(dev)) { - dev->flags |= VIRTIO_DEV_READY; + if (!virtio_is_ready(dev)) + goto out; - if (!(dev->flags & VIRTIO_DEV_RUNNING)) { - if (dev->dequeue_zero_copy) { - VHOST_LOG_CONFIG(INFO, - "dequeue zero copy is enabled\n"); - } + /* + * Virtio is now ready. If not done already, it is time + * to notify the application it can process the rings and + * configure the vDPA device if present. + */ - if (dev->notify_ops->new_device(dev->vid) == 0) - dev->flags |= VIRTIO_DEV_RUNNING; - } + if (!(dev->flags & VIRTIO_DEV_RUNNING)) { + if (dev->notify_ops->new_device(dev->vid) == 0) + dev->flags |= VIRTIO_DEV_RUNNING; } - did = dev->vdpa_dev_id; - vdpa_dev = rte_vdpa_get_device(did); - if (vdpa_dev && virtio_is_ready(dev) && - !(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) && - msg.request.master == VHOST_USER_SET_VRING_CALL) { + vdpa_dev = rte_vdpa_get_device(dev->vdpa_dev_id); + if (!vdpa_dev) + goto out; + + if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) && + request == VHOST_USER_SET_VRING_CALL) { if (vdpa_dev->ops->dev_conf) vdpa_dev->ops->dev_conf(dev->vid); + dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED; } +out: return 0; } From patchwork Thu May 14 08:02:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70212 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 38F2EA00C3; Thu, 14 May 2020 10:03:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 094751D6BB; Thu, 14 May 2020 10:02:53 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 51E8C1D6B6 for ; Thu, 14 May 2020 10:02:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hbqmmtxQ7RfGpinEDbuwHG/hbZUEf+JW+zZ9BQ0qDnk=; b=cf7OZLc0xRuNER/6P1jOQmU/c4Gfu50V5HBjGJrIov7crYjJKpkrbSQMo601F/Uos1wfDb /19HoNZlcygXwj3GFIef3NdAg17owN4QHM0zipU+g5Cu4k6761SjmeagWD4EevO3nGCVHk FnT8WlLyilsTuJy5CK31nPQkXSn7nKQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-HFP5jqd8ObSQUOMFwDvHHg-1; Thu, 14 May 2020 04:02:46 -0400 X-MC-Unique: HFP5jqd8ObSQUOMFwDvHHg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27E4C100CCC0; Thu, 14 May 2020 08:02:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FEBE61538; Thu, 14 May 2020 08:02:42 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:12 +0200 Message-Id: <20200514080218.1435344-4-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 3/9] vdpa/ifc: add support to vDPA queue enable 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" This patch adds support to enabling and disabling vrings on a per-vring granularity. Signed-off-by: Maxime Coquelin --- drivers/vdpa/ifc/base/ifcvf.c | 9 +++++++++ drivers/vdpa/ifc/base/ifcvf.h | 4 ++++ drivers/vdpa/ifc/ifcvf_vdpa.c | 23 ++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c index 3c0b2dff66..dd4e7468ae 100644 --- a/drivers/vdpa/ifc/base/ifcvf.c +++ b/drivers/vdpa/ifc/base/ifcvf.c @@ -327,3 +327,12 @@ ifcvf_get_queue_notify_off(struct ifcvf_hw *hw, int qid) return (u8 *)hw->notify_addr[qid] - (u8 *)hw->mem_resource[hw->notify_region].addr; } + +void +ifcvf_queue_enable(struct ifcvf_hw *hw, u16 qid, u16 enable) +{ + struct ifcvf_pci_common_cfg *cfg = hw->common_cfg; + + IFCVF_WRITE_REG16(qid, &cfg->queue_select); + IFCVF_WRITE_REG16(enable, &cfg->queue_enable); +} diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h index eb04a94067..bd85010eff 100644 --- a/drivers/vdpa/ifc/base/ifcvf.h +++ b/drivers/vdpa/ifc/base/ifcvf.h @@ -159,4 +159,8 @@ ifcvf_get_notify_region(struct ifcvf_hw *hw); u64 ifcvf_get_queue_notify_off(struct ifcvf_hw *hw, int qid); +void +ifcvf_queue_enable(struct ifcvf_hw *hw, u16 qid, u16 enable); + + #endif /* _IFCVF_H_ */ diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index ec97178dcb..55ce0cf13d 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -937,6 +937,27 @@ ifcvf_dev_close(int vid) return 0; } +static int +ifcvf_set_vring_state(int vid, int vring, int state) +{ + int did; + struct internal_list *list; + struct ifcvf_internal *internal; + + did = rte_vhost_get_vdpa_device_id(vid); + list = find_internal_resource_by_did(did); + if (list == NULL) { + DRV_LOG(ERR, "Invalid device id: %d", did); + return -1; + } + + internal = list->internal; + + ifcvf_queue_enable(&internal->hw, (uint16_t)vring, (uint16_t) state); + + return 0; +} + static int ifcvf_set_features(int vid) { @@ -1086,7 +1107,7 @@ static struct rte_vdpa_dev_ops ifcvf_ops = { .get_protocol_features = ifcvf_get_protocol_features, .dev_conf = ifcvf_dev_config, .dev_close = ifcvf_dev_close, - .set_vring_state = NULL, + .set_vring_state = ifcvf_set_vring_state, .set_features = ifcvf_set_features, .migration_done = NULL, .get_vfio_group_fd = ifcvf_get_vfio_group_fd, From patchwork Thu May 14 08:02:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70213 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 30063A00C3; Thu, 14 May 2020 10:03:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 715C01D6C8; Thu, 14 May 2020 10:02:55 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 72D1A1D6C9 for ; Thu, 14 May 2020 10:02:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uy9TjvAJ14wqsJkkwW/+la6q7yIoIFQXKBW9vxgtO/Y=; b=Lo9iXCGyuRRrWQzNyOVt4M8SJZMHwisbC+x/f3kj2q7HSRxKH8EpRaHVeTyzc4yn17rriN hyTs+Rsl6PXOkOdvEUO+u7YK0CauU+j8zAmVPvnQEKOR2vn+4LX99eF3RQaCmnV/f9CxD3 uxI1Uby1YRZHoVgXAXd3UgvvSzqvgZM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-nLCkAVjtOVKSVAwr5PDLdA-1; Thu, 14 May 2020 04:02:49 -0400 X-MC-Unique: nLCkAVjtOVKSVAwr5PDLdA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A7E8801503; Thu, 14 May 2020 08:02:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B9576E6F4; Thu, 14 May 2020 08:02:45 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:13 +0200 Message-Id: <20200514080218.1435344-5-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 4/9] vhost: make some vDPA callbacks mandatory 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" Some of the vDPA callbacks have to be implemented for vDPA to work properly. This patch marks them as mandatory in the API doc and simplify code calling these ops with removing unnecessary checks that are now done at registration time. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/rte_vdpa.h | 14 ++++++++------ lib/librte_vhost/socket.c | 6 +++--- lib/librte_vhost/vdpa.c | 10 ++++++++++ lib/librte_vhost/vhost.c | 2 +- lib/librte_vhost/vhost_user.c | 7 +++---- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h index 3c400ee79b..a4f74211db 100644 --- a/lib/librte_vhost/rte_vdpa.h +++ b/lib/librte_vhost/rte_vdpa.h @@ -41,23 +41,25 @@ struct rte_vdpa_dev_addr { * vdpa device operations */ struct rte_vdpa_dev_ops { - /** Get capabilities of this device */ + /** Get capabilities of this device (Mandatory) */ int (*get_queue_num)(int did, uint32_t *queue_num); - /** Get supported features of this device */ + /** Get supported features of this device (Mandatory) */ int (*get_features)(int did, uint64_t *features); - /** Get supported protocol features of this device */ + /** Get supported protocol features of this device (Mandatory) */ int (*get_protocol_features)(int did, uint64_t *protocol_features); - /** Driver configure/close the device */ + /** Driver configure the device (Mandatory) */ int (*dev_conf)(int vid); + + /** Driver close the device (Mandatory) */ int (*dev_close)(int vid); - /** Enable/disable this vring */ + /** Enable/disable this vring (Mandatory) */ int (*set_vring_state)(int vid, int vring, int state); - /** Set features when changed */ + /** Set features when changed (Mandatory) */ int (*set_features)(int vid); /** Destination operations when migration done */ diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index bb8d0d7801..23f3448d2c 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -707,7 +707,7 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features) did = vsocket->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); - if (!vdpa_dev || !vdpa_dev->ops->get_features) { + if (!vdpa_dev) { *features = vsocket->features; goto unlock_exit; } @@ -762,7 +762,7 @@ rte_vhost_driver_get_protocol_features(const char *path, did = vsocket->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); - if (!vdpa_dev || !vdpa_dev->ops->get_protocol_features) { + if (!vdpa_dev) { *protocol_features = vsocket->protocol_features; goto unlock_exit; } @@ -804,7 +804,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num) did = vsocket->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); - if (!vdpa_dev || !vdpa_dev->ops->get_queue_num) { + if (!vdpa_dev) { *queue_num = VHOST_MAX_QUEUE_PAIRS; goto unlock_exit; } diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c index b2b2a105f1..e5e949f6d3 100644 --- a/lib/librte_vhost/vdpa.c +++ b/lib/librte_vhost/vdpa.c @@ -66,6 +66,16 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr, if (i == MAX_VHOST_DEVICE) return -1; + /* Check mandatory ops are implemented */ + if (!ops->get_queue_num || !ops->get_features || + !ops->get_protocol_features || !ops->dev_conf || + !ops->dev_close || !ops->set_vring_state || + !ops->set_features) { + VHOST_LOG_CONFIG(ERR, + "Some mandatory vDPA ops aren't implemented\n"); + return -1; + } + snprintf(device_name, sizeof(device_name), "vdpa-dev-%d", i); dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device), RTE_CACHE_LINE_SIZE); diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index fd8ba1be2d..7b5c9b3537 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -649,7 +649,7 @@ vhost_destroy_device_notify(struct virtio_net *dev) if (dev->flags & VIRTIO_DEV_RUNNING) { did = dev->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); - if (vdpa_dev && vdpa_dev->ops->dev_close) + if (vdpa_dev) vdpa_dev->ops->dev_close(dev->vid); dev->flags &= ~VIRTIO_DEV_RUNNING; dev->notify_ops->destroy_device(dev->vid); diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index f5800bd9c1..7a43c2fae7 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -386,7 +386,7 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg, did = dev->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); - if (vdpa_dev && vdpa_dev->ops->set_features) + if (vdpa_dev) vdpa_dev->ops->set_features(dev->vid); return RTE_VHOST_MSG_RESULT_OK; @@ -1972,7 +1972,7 @@ vhost_user_set_vring_enable(struct virtio_net **pdev, did = dev->vdpa_dev_id; vdpa_dev = rte_vdpa_get_device(did); - if (vdpa_dev && vdpa_dev->ops->set_vring_state) + if (vdpa_dev) vdpa_dev->ops->set_vring_state(dev->vid, index, enable); if (dev->notify_ops->vring_state_changed) @@ -2809,8 +2809,7 @@ vhost_user_msg_handler(int vid, int fd) if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) && request == VHOST_USER_SET_VRING_CALL) { - if (vdpa_dev->ops->dev_conf) - vdpa_dev->ops->dev_conf(dev->vid); + vdpa_dev->ops->dev_conf(dev->vid); dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED; } From patchwork Thu May 14 08:02:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70214 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 B78CCA00C3; Thu, 14 May 2020 10:03:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBEA61D6D6; Thu, 14 May 2020 10:02:56 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 232381D6CC for ; Thu, 14 May 2020 10:02:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MtGynsRnuQQT2fYWzpW2QMq35U9zie/ih98HvPBKCsw=; b=AItLDuhk+7h6uW4tfP1iBlJbzXHhwo8ZJs2mkDW7I1JOt1YjV6SjjsprkMPuLOz9gQE+DQ ojdwBOW3t+lNgKZDiqoSbtQ+16QdI0Rmz8ch71XOVK2yXa3RfUXOQyN3Y114V/vuf9BdmT DAMX7YjOogogKs9aTlOxGqhxhG3DCNY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-348-vB2MSGfuMI6xIwJORN2Vyw-1; Thu, 14 May 2020 04:02:52 -0400 X-MC-Unique: vB2MSGfuMI6xIwJORN2Vyw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5A43107ACCA; Thu, 14 May 2020 08:02:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7483361538; Thu, 14 May 2020 08:02:48 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:14 +0200 Message-Id: <20200514080218.1435344-6-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 5/9] vhost: check vDPA configuration succeed 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" This patch checks whether vDPA device configuration succeed and does not set the CONFIGURED flag if it didn't. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 7a43c2fae7..4a847f368c 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2809,9 +2809,11 @@ vhost_user_msg_handler(int vid, int fd) if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) && request == VHOST_USER_SET_VRING_CALL) { - vdpa_dev->ops->dev_conf(dev->vid); - - dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED; + if (vdpa_dev->ops->dev_conf(dev->vid)) + VHOST_LOG_CONFIG(ERR, + "Failed to configure vDPA device\n"); + else + dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED; } out: From patchwork Thu May 14 08:02:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70215 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 434DAA00C3; Thu, 14 May 2020 10:04:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E42D21D69F; Thu, 14 May 2020 10:03:02 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id CFC6C1D69F for ; Thu, 14 May 2020 10:03:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CTMij03Q34lnX0i1J7D0o4e+IdRflCVwty3xKTqgJE4=; b=CxkSBm0Xe5PuRspJfs0AyKro76jE3lMDFeiO3agW1ttbUaNLLX7ESCJCnolpx9SFsDbHec 5aB+EjH0Ko2rHSOz/1wz49VJ+y/RRWDbD5fsm24JeXagTo8JALapzvQIFezriyj8YimSmf islSJ132sRZgTSzFvL0+Ig5zk27ahmg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-inNRDrcnPae8kHDLMlSFMQ-1; Thu, 14 May 2020 04:02:57 -0400 X-MC-Unique: inNRDrcnPae8kHDLMlSFMQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6195F805721; Thu, 14 May 2020 08:02:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34E7861F50; Thu, 14 May 2020 08:02:50 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:15 +0200 Message-Id: <20200514080218.1435344-7-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 6/9] vhost: add support for virtio status 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" This patch adds support to the new Virtio device status Vhost-user protocol feature. Getting such information in the backend helps to know when the driver is done with the device configuration and so makes the initialization phase more robust. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/rte_vhost.h | 4 ++++ lib/librte_vhost/vhost.h | 9 ++++++++ lib/librte_vhost/vhost_user.c | 40 +++++++++++++++++++++++++++++++++++ lib/librte_vhost/vhost_user.h | 6 ++++-- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 5c72fba797..b4b7aa1928 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -85,6 +85,10 @@ extern "C" { #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 #endif +#ifndef VHOST_USER_PROTOCOL_F_STATUS +#define VHOST_USER_PROTOCOL_F_STATUS 15 +#endif + /** Indicate whether protocol features negotiation is supported. */ #ifndef VHOST_USER_F_PROTOCOL_FEATURES #define VHOST_USER_F_PROTOCOL_FEATURES 30 diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index df98d15de6..9a9c0a98f5 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -202,6 +202,14 @@ struct vhost_virtqueue { TAILQ_HEAD(, vhost_iotlb_entry) iotlb_pending_list; } __rte_cache_aligned; +/* Virtio device status as per Virtio specification */ +#define VIRTIO_DEVICE_STATUS_ACK 0x01 +#define VIRTIO_DEVICE_STATUS_DRIVER 0x02 +#define VIRTIO_DEVICE_STATUS_DRIVER_OK 0x04 +#define VIRTIO_DEVICE_STATUS_FEATURES_OK 0x08 +#define VIRTIO_DEVICE_STATUS_DEV_NEED_RESET 0x40 +#define VIRTIO_DEVICE_STATUS_FAILED 0x80 + /* Old kernels have no such macros defined */ #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 @@ -364,6 +372,7 @@ struct virtio_net { uint64_t log_addr; struct rte_ether_addr mac; uint16_t mtu; + uint8_t status; struct vhost_device_ops const *notify_ops; diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 4a847f368c..e5a44be58d 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -87,6 +87,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] = { [VHOST_USER_POSTCOPY_END] = "VHOST_USER_POSTCOPY_END", [VHOST_USER_GET_INFLIGHT_FD] = "VHOST_USER_GET_INFLIGHT_FD", [VHOST_USER_SET_INFLIGHT_FD] = "VHOST_USER_SET_INFLIGHT_FD", + [VHOST_USER_SET_STATUS] = "VHOST_USER_SET_STATUS", }; static int send_vhost_reply(int sockfd, struct VhostUserMsg *msg); @@ -1328,6 +1329,11 @@ virtio_is_ready(struct virtio_net *dev) return 0; } + /* If supported, ensure the frontend is really done with config */ + if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)) + if (!(dev->status & VIRTIO_DEVICE_STATUS_DRIVER_OK)) + return 0; + dev->flags |= VIRTIO_DEV_READY; VHOST_LOG_CONFIG(INFO, @@ -2425,6 +2431,39 @@ vhost_user_postcopy_end(struct virtio_net **pdev, struct VhostUserMsg *msg, return RTE_VHOST_MSG_RESULT_REPLY; } +static int +vhost_user_set_status(struct virtio_net **pdev, struct VhostUserMsg *msg, + int main_fd __rte_unused) +{ + struct virtio_net *dev = *pdev; + + /* As per Virtio specification, the device status is 8bits long */ + if (msg->payload.u64 > UINT8_MAX) { + VHOST_LOG_CONFIG(ERR, "Invalid VHOST_USER_SET_STATUS payload 0x%" PRIx64 "\n", + msg->payload.u64); + return RTE_VHOST_MSG_RESULT_ERR; + } + + dev->status = msg->payload.u64; + + VHOST_LOG_CONFIG(INFO, "New device status(0x%08x):\n" + "\t-ACKNOWLEDGE: %u\n" + "\t-DRIVER: %u\n" + "\t-FEATURES_OK: %u\n" + "\t-DRIVER_OK: %u\n" + "\t-DEVICE_NEED_RESET: %u\n" + "\t-FAILED: %u\n", + dev->status, + !!(dev->status & VIRTIO_DEVICE_STATUS_ACK), + !!(dev->status & VIRTIO_DEVICE_STATUS_DRIVER), + !!(dev->status & VIRTIO_DEVICE_STATUS_FEATURES_OK), + !!(dev->status & VIRTIO_DEVICE_STATUS_DRIVER_OK), + !!(dev->status & VIRTIO_DEVICE_STATUS_DEV_NEED_RESET), + !!(dev->status & VIRTIO_DEVICE_STATUS_FAILED)); + + return RTE_VHOST_MSG_RESULT_OK; +} + typedef int (*vhost_message_handler_t)(struct virtio_net **pdev, struct VhostUserMsg *msg, int main_fd); @@ -2457,6 +2496,7 @@ static vhost_message_handler_t vhost_message_handlers[VHOST_USER_MAX] = { [VHOST_USER_POSTCOPY_END] = vhost_user_postcopy_end, [VHOST_USER_GET_INFLIGHT_FD] = vhost_user_get_inflight_fd, [VHOST_USER_SET_INFLIGHT_FD] = vhost_user_set_inflight_fd, + [VHOST_USER_SET_STATUS] = vhost_user_set_status, }; /* return bytes# of read on success or negative val on failure. */ diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h index 1f65efa4a9..74fd361e3a 100644 --- a/lib/librte_vhost/vhost_user.h +++ b/lib/librte_vhost/vhost_user.h @@ -23,7 +23,8 @@ (1ULL << VHOST_USER_PROTOCOL_F_CRYPTO_SESSION) | \ (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \ (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \ - (1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT)) + (1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT) | \ + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)) typedef enum VhostUserRequest { VHOST_USER_NONE = 0, @@ -56,7 +57,8 @@ typedef enum VhostUserRequest { VHOST_USER_POSTCOPY_END = 30, VHOST_USER_GET_INFLIGHT_FD = 31, VHOST_USER_SET_INFLIGHT_FD = 32, - VHOST_USER_MAX = 33 + VHOST_USER_SET_STATUS = 36, + VHOST_USER_MAX = 37 } VhostUserRequest; typedef enum VhostUserSlaveRequest { From patchwork Thu May 14 08:02:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70216 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 7CA8BA00C3; Thu, 14 May 2020 10:04:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 35EF31D6E0; Thu, 14 May 2020 10:03:04 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 039E91D6A5 for ; Thu, 14 May 2020 10:03:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m/2xrXkWefCfEbYkeY7XMEMjWuei1VH1O8tRR4ERQIo=; b=B6pVScwOlb8PeaGoYfqFxGW3njIHGiqFQ30L5240Kk5tgRzOiel7/SP/dGziwu3oWUtuBu hkxzgpPhoCaPsqfujIpkYNvEVFeDXZTuO77p3fabQTj/PJqF/Lc44MaedpXnsc/qkey+P1 iqTplXDBFepZAQJ+DTuj+WywndvtFtU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-cVTJbdolPMqsFYyb6koSOg-1; Thu, 14 May 2020 04:03:01 -0400 X-MC-Unique: cVTJbdolPMqsFYyb6koSOg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AFD2019200CB; Thu, 14 May 2020 08:02:59 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC3ED6E6F4; Thu, 14 May 2020 08:02:56 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:16 +0200 Message-Id: <20200514080218.1435344-8-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 7/9] vdpa/ifc: enable status protocol feature 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" This patch advertises VHOST_USER_PROTOCOL_F_STATUS support in the IFC driver so that that the protocol feature is negotiated. Signed-off-by: Maxime Coquelin --- drivers/vdpa/ifc/ifcvf_vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index 55ce0cf13d..d398766c83 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -1093,7 +1093,8 @@ ifcvf_get_vdpa_features(int did, uint64_t *features) 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ | \ 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD | \ 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | \ - 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) + 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | \ + 1ULL << VHOST_USER_PROTOCOL_F_STATUS) static int ifcvf_get_protocol_features(int did __rte_unused, uint64_t *features) { From patchwork Thu May 14 08:02:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70217 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 F3D44A00C3; Thu, 14 May 2020 10:04:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A34931D6F0; Thu, 14 May 2020 10:03:07 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 2A8EF1D6F3 for ; Thu, 14 May 2020 10:03:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=igow5Cq4V2gyX7JVraPRRd+0KwpdLZaWBMpAILBFr8U=; b=erfqxioA3pXDFUEnvs3ClCpvquYwoZtxmuTLpxpZV5EnKGWj5kXUcF/FtNlLTOOkMxj0pl wEn2/p4RrQArTnQ/gsS7raG1qvGsPYiltNB9Bz92R0ohvBp4HltXK1APiFyBuyJQiuC7Su dUcVzGnG3RdQdQV0WYjRvtV70ex4PyY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-448-IGxBvVOzOKiw-t34LL-59A-1; Thu, 14 May 2020 04:03:03 -0400 X-MC-Unique: IGxBvVOzOKiw-t34LL-59A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A379119200C1; Thu, 14 May 2020 08:03:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 133AD61F50; Thu, 14 May 2020 08:02:59 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:17 +0200 Message-Id: <20200514080218.1435344-9-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 8/9] vdpa/mlx5: enable status protocol feature 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" This patch advertises VHOST_USER_PROTOCOL_F_STATUS support in the MLX5 driver so that that the protocol feature is negotiated. Signed-off-by: Maxime Coquelin --- drivers/vdpa/mlx5/mlx5_vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 1113d6cef0..7021e476cf 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -31,7 +31,9 @@ (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \ (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \ (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \ - (1ULL << VHOST_USER_PROTOCOL_F_MQ)) + (1ULL << VHOST_USER_PROTOCOL_F_MQ) | \ + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)) + TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list = TAILQ_HEAD_INITIALIZER(priv_list); From patchwork Thu May 14 08:02:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70218 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 4A4ACA00C3; Thu, 14 May 2020 10:04:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D76191D6E7; Thu, 14 May 2020 10:03:13 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 1EA661D6E7 for ; Thu, 14 May 2020 10:03:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fm8Fi3mUwy4WGydUR/47N3fIo/yZ1B4zqMJN0MUDkgo=; b=aN4CMfxLEGkfbUi0qkrf0UaBGOrhBt+Am/c7sOXvfJgRHQ2TdpREG/j8pHm9JBxGBxsQzx wXpM27y7+J1xWzocdlkd++NFLcuEpnHejas9zkcgedoiCMu15RoCm0bOe4pbQFOi2aCB6j OOIsC+gVC1Cb5FeyRFQ+wXnZE5S6YMI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-rGmQxCgvM_i-04YDkEx_1w-1; Thu, 14 May 2020 04:03:08 -0400 X-MC-Unique: rGmQxCgvM_i-04YDkEx_1w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0693835B40; Thu, 14 May 2020 08:03:06 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17E2B61F50; Thu, 14 May 2020 08:03:02 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:18 +0200 Message-Id: <20200514080218.1435344-10-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 9/9] vhost: only use vDPA config workaround if needed 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" Now that we have Virtio device status support, let's only use the vDPA workaround if it is not supported. This patch also document why Virtio device status protocol feature support is strongly advised. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index e5a44be58d..67e96a872a 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2847,8 +2847,20 @@ vhost_user_msg_handler(int vid, int fd) if (!vdpa_dev) goto out; - if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) && - request == VHOST_USER_SET_VRING_CALL) { + if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { + /* + * Workaround when Virtio device status protocol + * feature is not supported, wait for SET_VRING_CALL + * request. This is not ideal as some frontends like + * Virtio-user may not send this request, so vDPA device + * may never be configured. Virtio device status support + * on frontend side is strongly advised. + */ + if (!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)) && + (request != VHOST_USER_SET_VRING_CALL)) + goto out; + if (vdpa_dev->ops->dev_conf(dev->vid)) VHOST_LOG_CONFIG(ERR, "Failed to configure vDPA device\n");