Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp936189yba; Wed, 15 May 2019 12:34:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnrJEJ4dsCMwr+bsr67GRGlF7pNuCsl516HT0BIQyNSvCtFPpXhEfyXiBDB/zaN3kmPlw5 X-Received: by 2002:aa7:9f01:: with SMTP id g1mr36472492pfr.259.1557948854508; Wed, 15 May 2019 12:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557948854; cv=none; d=google.com; s=arc-20160816; b=r8d4d/g1Q6v1KSWJspVPzqJTyecBI8yyZthifc4ykERhknhHLe1pnR6bESSkn5V2Zy 84339LxhfqT/XD/GaMdge+CNSF9zK2tkeq0wMMccqNncArfEVOxVgoz1Z3vnNECKZjf/ 1Ih6iWrvpAWqm6Hkjyy8ZSmt5Ipo3plzsc1UGWr7tHkcNm7imdJx2+g0wsAAgSodN660 6Qhoj5CsRqiK4D5QmwIsZ2iOyXz5ZPcSzqdhRmRl8J86bfQWre6fAe7iQQMACqQ7p6cP CzOhu5vmBdL3z8hol4DI21n41xef7znK9MSfiVSzz2MuPR1Ftp/7bsSCJK/gyZCcqeUa PIDQ== 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; bh=ykyNhA02OViIpJqGvQF+ng/2AKItOfThcuRWMe61VNE=; b=hdLO1rgWHdXXhnn1erSydRqjUTPBCBTC+UKn9hDvzb+wmytle+lmmtCWlJNE1bd8We +V8sVs5nhe6kMDxO4gZyTYK/aKiZqAYWTEBwJiZ45Xe3QkltRo9bi3vfgb6letMbysjT HNDbDft7dQLzS1O8YacsWyno6o2n3InE2HFnw+oyQDVuxpriaa2SEqpbF6GUZl/hj2Ik VKbkP5bnTNJishz5xBijhSpHs3MIyQjjWcd9tDBS/h89GHepb6BsmQ9OUzMJ8kVc1sbt lsLya1YTlCH4rxtbPhE/qncePINWkyrxxRv6w6Yqooh7n3VCFKvQppDSwSSWh87A8vid shBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o15si2503801pgv.316.2019.05.15.12.33.59; Wed, 15 May 2019 12:34:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbfEOTa6 (ORCPT + 99 others); Wed, 15 May 2019 15:30:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42870 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbfEOT1d (ORCPT ); Wed, 15 May 2019 15:27:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A40F90906; Wed, 15 May 2019 19:27:33 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 257DA5D729; Wed, 15 May 2019 19:27:33 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id BE116225482; Wed, 15 May 2019 15:27:29 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-nvdimm@lists.01.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, swhiteho@redhat.com Subject: [PATCH v2 14/30] virtio: Add get_shm_region method Date: Wed, 15 May 2019 15:26:59 -0400 Message-Id: <20190515192715.18000-15-vgoyal@redhat.com> In-Reply-To: <20190515192715.18000-1-vgoyal@redhat.com> References: <20190515192715.18000-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 15 May 2019 19:27:33 +0000 (UTC) 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 --- 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.20.1