From patchwork Tue Jun 19 16:32:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venu Busireddy X-Patchwork-Id: 10475171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65F04601D7 for ; Tue, 19 Jun 2018 17:36:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5356828A43 for ; Tue, 19 Jun 2018 17:36:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4809328AA4; Tue, 19 Jun 2018 17:36:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BA40828A43 for ; Tue, 19 Jun 2018 17:36:35 +0000 (UTC) Received: from localhost ([::1]:44091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVKYV-00074K-2j for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Jun 2018 13:36:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVJZ7-0004Um-QO for qemu-devel@nongnu.org; Tue, 19 Jun 2018 12:33:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVJZ2-0002gr-Tj for qemu-devel@nongnu.org; Tue, 19 Jun 2018 12:33:09 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:41514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVJZ2-0002gH-JT for qemu-devel@nongnu.org; Tue, 19 Jun 2018 12:33:04 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5JGT4ud015414; Tue, 19 Jun 2018 16:33:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=ofQYAVL8BoDib3C14vEyzjng1qP6CeUfIFOS6WRP23o=; b=Ue+kyn7eDw3jhiM1O7DLkVGeI0/CVgX/5hPSGMwa28/MVe5LFgbNaftMLDrNCP0AOhYw sfC4mpp9ZLDGFfKryeX9cWfRYxlZKlk90SwsAEAVM4cFGbcL6WCN8LWJ7T8cnVloArDC 7yyn9DSq9dLCenxpgBfTHMb8kMRzEDhfil+6wFfmgxFun+j8i9+Lir82ZEXuihQsZUz+ BpPhMycTUYu0mNCyEGbh7UntFFNPLYnYB2w3LtWUPPVR1DxevVaKs9rUtvfq1f9WC3bB t8Y+k0eAZt3Pc8ojpjHlmFHIYgHs+uYPFShkmzdVaKNolAeIh1xpFdI9dh1biYNRBEKH jw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2jmt01h1ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jun 2018 16:33:02 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5JGX1n9028036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jun 2018 16:33:01 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5JGX1Rs013110; Tue, 19 Jun 2018 16:33:01 GMT Received: from localhost.localdomain (/10.159.242.141) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Jun 2018 09:33:00 -0700 From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S . Tsirkin" , Marcel Apfelbaum Date: Tue, 19 Jun 2018 11:32:27 -0500 Message-Id: <20180619163228.13790-4-venu.busireddy@oracle.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180619163228.13790-1-venu.busireddy@oracle.com> References: <20180619163228.13790-1-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8929 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806190182 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 X-Mailman-Approved-At: Tue, 19 Jun 2018 13:31:57 -0400 Subject: [Qemu-devel] [PATCH 3/3] Add "Group Identifier" support to virtio devices. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the virtio PCI capability "VIRTIO_PCI_CAP_GROUP_ID_CFG" to store the "Group Identifier" (UUID) specified via the command line option "uuid" for the virtio device. The capability will be present in the virtio device's configuration space iff the "uuid" option is specified. Group Identifier is used to pair a virtio device with a passthrough device. Signed-off-by: Venu Busireddy --- hw/virtio/virtio-pci.c | 15 +++++++++++++++ hw/virtio/virtio-pci.h | 3 ++- include/standard-headers/linux/virtio_pci.h | 8 ++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 3a01fe90f0..9c2ef16773 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -36,6 +36,7 @@ #include "qemu/range.h" #include "hw/virtio/virtio-bus.h" #include "qapi/visitor.h" +#include "qemu/uuid.h" #define VIRTIO_PCI_REGION_SIZE(dev) VIRTIO_PCI_CONFIG_OFF(msix_present(dev)) @@ -1638,6 +1639,10 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) .cap.cap_len = sizeof cfg, .cap.cfg_type = VIRTIO_PCI_CAP_PCI_CFG, }; + struct virtio_pci_group_id_cap group = { + .cap.cap_len = sizeof group, + .cap.cfg_type = VIRTIO_PCI_CAP_GROUP_ID_CFG, + }; struct virtio_pci_notify_cap notify_pio = { .cap.cap_len = sizeof notify, .notify_off_multiplier = cpu_to_le32(0x0), @@ -1647,6 +1652,11 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) virtio_pci_modern_regions_init(proxy); + if (!qemu_uuid_is_null(&proxy->pci_dev.uuid)) { + memcpy(group.group_id, &proxy->pci_dev.uuid, sizeof(QemuUUID)); + virtio_pci_modern_mem_region_map(proxy, &proxy->group, &group.cap); + } + virtio_pci_modern_mem_region_map(proxy, &proxy->common, &cap); virtio_pci_modern_mem_region_map(proxy, &proxy->isr, &cap); virtio_pci_modern_mem_region_map(proxy, &proxy->device, &cap); @@ -1763,6 +1773,10 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) proxy->device.size = 0x1000; proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; + proxy->group.offset = 0; + proxy->group.size = 0; + proxy->group.type = VIRTIO_PCI_CAP_GROUP_ID_CFG; + proxy->notify.offset = 0x3000; proxy->notify.size = virtio_pci_queue_mem_mult(proxy) * VIRTIO_QUEUE_MAX; proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; @@ -1898,6 +1912,7 @@ static Property virtio_pci_properties[] = { VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true), DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_INIT_PM_BIT, true), + DEFINE_PROP_UUID("uuid", PCIDevice, uuid, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 813082b0d7..e4592e90bf 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -164,10 +164,11 @@ struct VirtIOPCIProxy { VirtIOPCIRegion common; VirtIOPCIRegion isr; VirtIOPCIRegion device; + VirtIOPCIRegion group; VirtIOPCIRegion notify; VirtIOPCIRegion notify_pio; }; - VirtIOPCIRegion regs[5]; + VirtIOPCIRegion regs[6]; }; MemoryRegion modern_bar; MemoryRegion io_bar; diff --git a/include/standard-headers/linux/virtio_pci.h b/include/standard-headers/linux/virtio_pci.h index 9262acd130..e5b6c6f3a6 100644 --- a/include/standard-headers/linux/virtio_pci.h +++ b/include/standard-headers/linux/virtio_pci.h @@ -113,6 +113,8 @@ #define VIRTIO_PCI_CAP_DEVICE_CFG 4 /* PCI configuration access */ #define VIRTIO_PCI_CAP_PCI_CFG 5 +/* Group Identifier */ +#define VIRTIO_PCI_CAP_GROUP_ID_CFG 6 /* This is the PCI capability header: */ struct virtio_pci_cap { @@ -163,6 +165,12 @@ struct virtio_pci_cfg_cap { uint8_t pci_cfg_data[4]; /* Data for BAR access. */ }; +/* Fields in VIRTIO_PCI_CAP_GROUP_ID_CFG: */ +struct virtio_pci_group_id_cap { + struct virtio_pci_cap cap; + uint8_t group_id[16]; +}; + /* Macro versions of offsets for the Old Timers! */ #define VIRTIO_PCI_CAP_VNDR 0 #define VIRTIO_PCI_CAP_NEXT 1