From patchwork Fri Jun 29 22:19:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venu Busireddy X-Patchwork-Id: 10497691 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 2C228601C7 for ; Fri, 29 Jun 2018 22:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19D53297B4 for ; Fri, 29 Jun 2018 22:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DFBD297BE; Fri, 29 Jun 2018 22:20:40 +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 71957297B4 for ; Fri, 29 Jun 2018 22:20:39 +0000 (UTC) Received: from localhost ([::1]:44710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ1ks-0002W7-Kj for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jun 2018 18:20:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ1jo-0001JB-LA for qemu-devel@nongnu.org; Fri, 29 Jun 2018 18:19:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZ1jk-0007EJ-LN for qemu-devel@nongnu.org; Fri, 29 Jun 2018 18:19:32 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:40466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fZ1jk-0007DT-DS for qemu-devel@nongnu.org; Fri, 29 Jun 2018 18:19:28 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5TMJPWd089521; Fri, 29 Jun 2018 22:19:26 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=bRcSCrR0eMb0pEtzuGydein6jsC4IZY5rQn6f1vJMK0=; b=LqXCgzkFjzmIg//7imV5IjP6h0rzXSiXLkFlkOQSzSOnClkdbQBS4wa+xOsCw8upvn0Q M49RlzzyGXl7ADlTGNx6ZP0WJy4JQzHoZP+eG+GPcBYX0coC9p3+zqq87xi/bvNzGnes 09JNRCC+behptpmKIfHntXLQbJ9EYUmRpNrlsgMQCH6jMj4I50eTDFwdVKnhOo9GEVo7 KTEohez5mnUPJvkkGo1PI0UD1TEZF6vowT/MTdmQo1uF7yOL8S3d8TLrJcaaq9Mwq2FT LUv9C0jNu7uLWprmbRyDicmwXVdsT6MlzIEC7C4Lw4bESs8NYWoJ84PH5Mcv55A8Usca rg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2jukhsr6x1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 22:19:26 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5TMJQs3009873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 22:19:26 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5TMJPcx015800; Fri, 29 Jun 2018 22:19:25 GMT Received: from troi.attlocal.net (/10.154.170.104) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 29 Jun 2018 15:19:25 -0700 From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S . Tsirkin" , Marcel Apfelbaum Date: Fri, 29 Jun 2018 17:19:04 -0500 Message-Id: <20180629221907.3662-2-venu.busireddy@oracle.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180629221907.3662-1-venu.busireddy@oracle.com> References: <20180629221907.3662-1-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8939 signatures=668703 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-1806210000 definitions=main-1806290237 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH v3 1/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" specified via the command line option "failover-group-id" for the virtio device. The capability will be present in the virtio device's configuration space iff the "failover-group-id" 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/hw/pci/pci.h | 1 + include/hw/pci/pcie.h | 1 + include/standard-headers/linux/virtio_pci.h | 8 ++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 3a01fe90f0..cdf907e9c5 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1638,6 +1638,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 +1651,11 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) virtio_pci_modern_regions_init(proxy); + if (proxy->pci_dev.failover_group_id != ULLONG_MAX) { + group.failover_group_id = proxy->pci_dev.failover_group_id; + 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 +1772,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 +1911,8 @@ 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_UINT64(COMPAT_PROP_FAILOVER_GROUP_ID, + PCIDevice, failover_group_id, ULLONG_MAX), 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/hw/pci/pci.h b/include/hw/pci/pci.h index 990d6fcbde..b59c3e7e38 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -343,6 +343,7 @@ struct PCIDevice { bool has_rom; MemoryRegion rom; uint32_t rom_bar; + uint64_t failover_group_id; /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index b71e369703..71cd143ee4 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -82,6 +82,7 @@ struct PCIExpressDevice { }; #define COMPAT_PROP_PCP "power_controller_present" +#define COMPAT_PROP_FAILOVER_GROUP_ID "failover-group-id" /* PCI express capability helper functions */ int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type, diff --git a/include/standard-headers/linux/virtio_pci.h b/include/standard-headers/linux/virtio_pci.h index 9262acd130..e46df63e52 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; + uint64_t failover_group_id; +}; + /* Macro versions of offsets for the Old Timers! */ #define VIRTIO_PCI_CAP_VNDR 0 #define VIRTIO_PCI_CAP_NEXT 1