Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1156689pxb; Fri, 13 Nov 2020 05:49:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4wkPYvQurHIxXMQdjs5Zny6Kq8pT/c1xln0Jbkw6xfmFVY8HoUAAmZfg9HW9w3pzmThZs X-Received: by 2002:a50:f68f:: with SMTP id d15mr2605622edn.4.1605275392714; Fri, 13 Nov 2020 05:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605275392; cv=none; d=google.com; s=arc-20160816; b=gzYNlXhdrVxrV0J+JCHvtNAuWnsLZA8ZxemKYlzGRu3VuvjNcCYfSJXKcTnxD+VKdM hyhnVDC35YsWVj3q+r7wyqjNthol3q4jqPOHxT5esWzvSltThldIVSHhjRmnQKyBqCWa RhfX+kY7f/m76k+ap7h3Eubpz4zvPjHkQdHiOBItPPNbwU5iH7W5VJppduDAKZjXM45p RsmWSWmPhE61OvLqKyCCNq/o5Vzg0PdA8w8ZtXzFPTe8k0/1O8fMYtCEDBOvhTcMsSbc UoHs4tJfNogwfH0eWxRlvu+DIkjnNmSOHkhEaFdMr4Y0S8SfK3rf+SY+8OaG/O31Z/qZ 1B9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qUSCXqZfVu5qowPNJ7+Usz2GPpNw0QJvHN5TBNVtPXI=; b=CrYTi/KDkYBrh5yPTWT3x5gmTFqkAt0nOHPnlqSG7aA9xLLJlZtSzQtTlWXHEp/ZlA 1aCq+ySXvhgbIuNq6G4H/rYqfLX7wpCMnP+HA6MwPHNMnCvVDEJPMV43JsEsPUVUaf5x P3sWjrIINuobWtPzORUOobzQgs2Aru/SCSaMT5at8tyusfQkVXaFOoQml5pOX2J60ZmZ myNx4wiD4zFP5Zvw0O9Rfnqa4vNcSMTxLtIM9vvVw7cW5+eN9h/zjbGzP0vM5MNE8r5O dTpZyu41zGBa1QNkVSQvzpRSwAFzN+C2pA9AMYbkd0hZZu7URAQe5aiBJAmqVRMaEWeC AgAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZN+yGDgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc4si1909939edb.348.2020.11.13.05.49.29; Fri, 13 Nov 2020 05:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZN+yGDgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbgKMNre (ORCPT + 99 others); Fri, 13 Nov 2020 08:47:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53035 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726324AbgKMNra (ORCPT ); Fri, 13 Nov 2020 08:47:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605275247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qUSCXqZfVu5qowPNJ7+Usz2GPpNw0QJvHN5TBNVtPXI=; b=ZN+yGDgV8jI5n1dsGxqnrMVHHTdSXMiIAeA6DC5eudT5gBdrlrt6gj4oa75vx3r3oSPDig t1iK51OW5V2QxOqXYjdALctHAUuoG7h2mLEeC3Ein7amMgEvbZmFdm2imS+/Ejnuzw5JA8 r8HOm3Gq/2SXbr4X9H9/5SsHcDslJDU= 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-259--0QA5k77MY-frLRzGvAyxA-1; Fri, 13 Nov 2020 08:47:25 -0500 X-MC-Unique: -0QA5k77MY-frLRzGvAyxA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D55210066FA; Fri, 13 Nov 2020 13:47:24 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-114-21.ams2.redhat.com [10.36.114.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5310B60C84; Fri, 13 Nov 2020 13:47:22 +0000 (UTC) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: Stefan Hajnoczi , Laurent Vivier , linux-kernel@vger.kernel.org, Eli Cohen , Jason Wang , "Michael S. Tsirkin" , Max Gurtovoy Subject: [PATCH RFC 01/12] vhost-vdpa: add support for vDPA blk devices Date: Fri, 13 Nov 2020 14:47:01 +0100 Message-Id: <20201113134712.69744-2-sgarzare@redhat.com> In-Reply-To: <20201113134712.69744-1-sgarzare@redhat.com> References: <20201113134712.69744-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Max Gurtovoy Currently only net devices can act as vDPA backends. Add an infrastructure for block devices will basic feature list that will be increased in the future. Signed-off-by: Max Gurtovoy Reviewed-by: Jason Wang Signed-off-by: Stefano Garzarella --- drivers/vhost/vdpa.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 2754f3069738..fb0411594963 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "vhost.h" @@ -194,6 +195,9 @@ static int vhost_vdpa_config_validate(struct vhost_vdpa *v, case VIRTIO_ID_NET: size = sizeof(struct virtio_net_config); break; + case VIRTIO_ID_BLOCK: + size = sizeof(struct virtio_blk_config); + break; } if (c->len == 0) @@ -975,12 +979,13 @@ static void vhost_vdpa_release_dev(struct device *device) static int vhost_vdpa_probe(struct vdpa_device *vdpa) { const struct vdpa_config_ops *ops = vdpa->config; + u32 device_id = ops->get_device_id(vdpa); struct vhost_vdpa *v; int minor; int r; - /* Currently, we only accept the network devices. */ - if (ops->get_device_id(vdpa) != VIRTIO_ID_NET) + /* Currently, we only accept the network and block devices. */ + if (device_id != VIRTIO_ID_NET && device_id != VIRTIO_ID_BLOCK) return -ENOTSUPP; v = kzalloc(sizeof(*v), GFP_KERNEL | __GFP_RETRY_MAYFAIL); @@ -998,7 +1003,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) v->minor = minor; v->vdpa = vdpa; v->nvqs = vdpa->nvqs; - v->virtio_id = ops->get_device_id(vdpa); + v->virtio_id = device_id; device_initialize(&v->dev); v->dev.release = vhost_vdpa_release_dev; -- 2.26.2