From patchwork Wed Jun 27 03:49:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venu Busireddy X-Patchwork-Id: 10490463 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 7F3E460230 for ; Wed, 27 Jun 2018 03:52:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D6C01FFB2 for ; Wed, 27 Jun 2018 03:52:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EC7426242; Wed, 27 Jun 2018 03:52:10 +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 E34CA1FFB2 for ; Wed, 27 Jun 2018 03:52:09 +0000 (UTC) Received: from localhost ([::1]:56323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY1V3-0008IL-3F for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jun 2018 23:52:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY1Sw-0006eg-36 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 23:49:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fY1Sv-00069M-00 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 23:49:58 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:59464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fY1Su-00067q-QK for qemu-devel@nongnu.org; Tue, 26 Jun 2018 23:49:56 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5R3nKO9075160; Wed, 27 Jun 2018 03:49:55 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=C2tx10Sln0qnMBQrSH5Ft6DHhN+xGhhMzgBrZVD3K2M=; b=YbTQUpP5A7+P2fPyTeYq3FVFCaUIX7CgqL7aVxE3h6jbheZXJN9euz7VPoCa3Ce741Yq TKr0luc5vdnmbLgHuUNpO9QdIq0tdc2LyO0c+Jgu/TOFpSN7a/XtS0o4f60Il9TQF5/3 Xxbem7lkdv8/T0j5Qa6Ztc5j9r5+MlKcybwXyNcFgXikWlpKrsvZxm9MjbLWxxyg7Pi/ dHpm8YzkTZueojt2jiw0Yl+PFb229HVGDfL/k5XhkcvQSpUMswzKlFgPe5yzwH0s38kB RMbVs6TET32APDGisp42rSPMbo9xcD4TQrxgyUOJCuAsMyQuD+Zgbl90U8BO1QUHEnEP bg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2jukmtu4rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Jun 2018 03:49:55 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5R3nshO011959 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Jun 2018 03:49:54 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5R3nsfY007722; Wed, 27 Jun 2018 03:49:54 GMT Received: from troi.attlocal.net (/10.154.103.180) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Jun 2018 20:49:54 -0700 From: Venu Busireddy To: venu.busireddy@oracle.com, "Michael S . Tsirkin" , Marcel Apfelbaum Date: Tue, 26 Jun 2018 22:49:33 -0500 Message-Id: <20180627034935.20276-4-venu.busireddy@oracle.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180627034935.20276-1-venu.busireddy@oracle.com> References: <20180627034935.20276-1-venu.busireddy@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8936 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-1806270042 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v2 3/4] Add "Group Identifier" support to Red Hat PCI bridge. 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 Add the "Vendor-Specific" capability to the Red Hat PCI bridge device "pci-bridge", to contain the "Group Identifier" (UUID) that will be used to pair a virtio device with the passthrough device attached to that bridge. This capability is added to the bridge iff the "uuid" option is specified for the bridge. Signed-off-by: Venu Busireddy --- hw/pci-bridge/pci_bridge_dev.c | 8 ++++++++ hw/pci/pci_bridge.c | 26 ++++++++++++++++++++++++++ include/hw/pci/pcie.h | 1 + 3 files changed, 35 insertions(+) diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c index b2d861d216..bbbc6fa1c6 100644 --- a/hw/pci-bridge/pci_bridge_dev.c +++ b/hw/pci-bridge/pci_bridge_dev.c @@ -71,6 +71,12 @@ static void pci_bridge_dev_realize(PCIDevice *dev, Error **errp) bridge_dev->msi = ON_OFF_AUTO_OFF; } + err = pci_bridge_vendor_init(dev, 0, errp); + if (err < 0) { + error_append_hint(errp, "Can't init group ID, error %d\n", err); + goto vendor_cap_err; + } + err = slotid_cap_init(dev, 0, bridge_dev->chassis_nr, 0, errp); if (err) { goto slotid_error; @@ -109,6 +115,7 @@ slotid_error: if (shpc_present(dev)) { shpc_cleanup(dev, &bridge_dev->bar); } +vendor_cap_err: shpc_error: pci_bridge_exitfn(dev); } @@ -162,6 +169,7 @@ static Property pci_bridge_dev_properties[] = { ON_OFF_AUTO_AUTO), DEFINE_PROP_BIT(PCI_BRIDGE_DEV_PROP_SHPC, PCIBridgeDev, flags, PCI_BRIDGE_DEV_F_SHPC_REQ, true), + DEFINE_PROP_UUID(COMPAT_PROP_UUID, PCIDevice, uuid, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 40a39f57cb..cb8b3dad2a 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -34,12 +34,17 @@ #include "hw/pci/pci_bus.h" #include "qemu/range.h" #include "qapi/error.h" +#include "qemu/uuid.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8 #define PCI_SSVID_SVID 4 #define PCI_SSVID_SSID 6 +#define PCI_VENDOR_SIZEOF 20 +#define PCI_VENDOR_CAP_LEN_OFFSET 2 +#define PCI_VENDOR_GROUP_ID_OFFSET 4 + int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset, uint16_t svid, uint16_t ssid, Error **errp) @@ -57,6 +62,27 @@ int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset, return pos; } +int pci_bridge_vendor_init(PCIDevice *d, uint8_t offset, Error **errp) +{ + int pos; + + if (qemu_uuid_is_null(&d->uuid)) { + return 0; + } + + pos = pci_add_capability(d, PCI_CAP_ID_VNDR, offset, PCI_VENDOR_SIZEOF, + errp); + if (pos < 0) { + return pos; + } + + pci_set_word(d->config + pos + PCI_VENDOR_CAP_LEN_OFFSET, + PCI_VENDOR_SIZEOF); + memcpy(d->config + pos + PCI_VENDOR_GROUP_ID_OFFSET, &d->uuid, + sizeof(QemuUUID)); + return pos; +} + /* Accessor function to get parent bridge device from pci bus. */ PCIDevice *pci_bridge_get_device(PCIBus *bus) { diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index b71e369703..b4189d0ce3 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_UUID "uuid" /* PCI express capability helper functions */ int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type,