Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2509811pxa; Fri, 7 Aug 2020 12:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ1EvOW23vF5/8BvKzadc82CDXCvExMtU8URCO0TIYdfcr1zJnrtBTttiJ5qCOr7TWovX+ X-Received: by 2002:a17:906:37d2:: with SMTP id o18mr10662030ejc.162.1596830338398; Fri, 07 Aug 2020 12:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596830338; cv=none; d=google.com; s=arc-20160816; b=cUj50bwIfVuYKbhYlzSBzrATwEbv9Ry/fYEnzaG9QCIDBw1gTL1yEsG1RNlcxhePr7 REvDtrzr2Z7JOTn19qqkCxGY1l6q9nMEexOQu3EOC8HrYo1D6DU79tYEENW1QNhoCt5e ZUTguRokVl4mUXFLhfvV2SFsH3CIRmSlt4Ffp6Uyrib6nFGftnIBXfB1xFE0H8SwSLnI oAdIxTkJDffOdw0MoARp+iNC0VBi2uHMM2OLhoUA7S+mxH3oFZbHUzjQDItZgJCdmX8+ Yf9npJpYVoacpkDX8iPWJldfAs5TWVFQwVnw4y5tesgTsd3FeDBAlUpKJSCxaST7ymFw y/kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jtqR2toNUH2Oj21nmtYHpQK7dk5daGIfHgim40Hd9n0=; b=QR77r5G2jv31NowjoxpaauFptfCzc5ZA5tX6KaCAEF2vluyTqZ7QWCp7EYMA6mQVXV l7DQ1kxRgu3yDY0NqCZo1VT/IIM0pvh0L/0kfbECVUDgrgXfbVs4b24zCaCduarXTcYO fPl6Qa5Nfscw6yRPdkyACO01Gd8cy3IWRLVmZVcXx1eYIyZerfa84KAinHIZbPyhdwQT 2hpORkp4Y21ph7nuhfdw0Xq0wUK5muYqrnEd6G5KdmKwY4JzMoM4ssGR/hYjYBSSFPV0 auz63iNL3b962uOmVmVpgsZFrIv0UjYe40bbZvo0I44aOMN7pD0IZm60+XYOvNWZWNAI 75Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CUDN28Yo; 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 p10si5794503edy.86.2020.08.07.12.58.35; Fri, 07 Aug 2020 12:58:58 -0700 (PDT) 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=CUDN28Yo; 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 S1727912AbgHGT5D (ORCPT + 99 others); Fri, 7 Aug 2020 15:57:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37982 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726804AbgHGTzx (ORCPT ); Fri, 7 Aug 2020 15:55:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596830151; 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=jtqR2toNUH2Oj21nmtYHpQK7dk5daGIfHgim40Hd9n0=; b=CUDN28Yo5KP6BXDiqiNH6Z9WBLPo5cvxV4ilVQPrMcLzSPfQq31JU9HuwTtxV9POXg8nLU rFAoXEehR8FSxT8xnaWfWWcNrKWqYxTGi2BNuZhoKxGmsTevsBzqomivwdDgvuH8ccSLRZ ViHns5S+5A/HE8A/JN3zcMt+zLB5MfM= 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-281-P-RKb71IPeOz8SfGDnbULQ-1; Fri, 07 Aug 2020 15:55:49 -0400 X-MC-Unique: P-RKb71IPeOz8SfGDnbULQ-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 06EEC1005510; Fri, 7 Aug 2020 19:55:48 +0000 (UTC) Received: from horse.redhat.com (ovpn-113-142.rdu2.redhat.com [10.10.113.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 226C260BE2; Fri, 7 Aug 2020 19:55:39 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id B171C222E45; Fri, 7 Aug 2020 15:55:38 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs@redhat.com Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, Sebastien Boeuf , kvm@vger.kernel.org, "Michael S. Tsirkin" Subject: [PATCH v2 03/20] virtio: Add get_shm_region method Date: Fri, 7 Aug 2020 15:55:09 -0400 Message-Id: <20200807195526.426056-4-vgoyal@redhat.com> In-Reply-To: <20200807195526.426056-1-vgoyal@redhat.com> References: <20200807195526.426056-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastien Boeuf Virtio defines 'shared memory regions' that provide a continuously shared region between the host and guest. Provide a method to find a particular region on a device. Signed-off-by: Sebastien Boeuf Signed-off-by: Dr. David Alan Gilbert Cc: kvm@vger.kernel.org Cc: "Michael S. Tsirkin" --- include/linux/virtio_config.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index bb4cc4910750..c859f000a751 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -10,6 +10,11 @@ struct irq_affinity; +struct virtio_shm_region { + u64 addr; + u64 len; +}; + /** * virtio_config_ops - operations for configuring a virtio device * Note: Do not assume that a transport implements all of the operations @@ -65,6 +70,7 @@ struct irq_affinity; * the caller can then copy. * @set_vq_affinity: set the affinity for a virtqueue (optional). * @get_vq_affinity: get the affinity for a virtqueue (optional). + * @get_shm_region: get a shared memory region based on the index. */ typedef void vq_callback_t(struct virtqueue *); struct virtio_config_ops { @@ -88,6 +94,8 @@ struct virtio_config_ops { const struct cpumask *cpu_mask); const struct cpumask *(*get_vq_affinity)(struct virtio_device *vdev, int index); + bool (*get_shm_region)(struct virtio_device *vdev, + struct virtio_shm_region *region, u8 id); }; /* If driver didn't advertise the feature, it will never appear. */ @@ -250,6 +258,15 @@ int virtqueue_set_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask) return 0; } +static inline +bool virtio_get_shm_region(struct virtio_device *vdev, + struct virtio_shm_region *region, u8 id) +{ + if (!vdev->config->get_shm_region) + return false; + return vdev->config->get_shm_region(vdev, region, id); +} + static inline bool virtio_is_little_endian(struct virtio_device *vdev) { return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) || -- 2.25.4