From nobody Tue Nov 4 22:00:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531127694145699.0968706022638; Mon, 9 Jul 2018 02:14:54 -0700 (PDT) Received: from localhost ([::1]:39991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcSFr-0006Yb-WB for importer@patchew.org; Mon, 09 Jul 2018 05:14:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcSDz-0005R9-NG for qemu-devel@nongnu.org; Mon, 09 Jul 2018 05:12:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcSDw-0007Hk-QW for qemu-devel@nongnu.org; Mon, 09 Jul 2018 05:12:51 -0400 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]:33780) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fcSDw-0007HK-JI for qemu-devel@nongnu.org; Mon, 09 Jul 2018 05:12:48 -0400 Received: by mail-ed1-x544.google.com with SMTP id x5-v6so9676238edr.0 for ; Mon, 09 Jul 2018 02:12:48 -0700 (PDT) Received: from localhost.localdomain ([194.230.159.64]) by smtp.gmail.com with ESMTPSA id c6-v6sm6865091edt.41.2018.07.09.02.12.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 02:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ynSHATwvwcgV+WoQrgaoozN6evLYGuZ6cZOWLkl+ZrI=; b=QEwaA/glPeL8pj0wMdK23tqTFYBxnCTaIN9/uy3yclr/aDqU+kx9QuaRTkTilHRtNV RBdp9AEC192fT5zdF7a0JlACSnMXWGgSDUuaL6bGqHYyEUrQZDBnxbwiPP32sEY9RcM5 WrpMOB0RdwW3CEVWODmyF+6A7Vxu+MjmfvY87qeJgjJYjKtRgFV+Ll6HMeMrMDL+jUBc t8bbeLGMvy8lr/USzm5MaReS/an0AXi3cbxniCrmsi2J1oPFnXoUdj3d7rFOza4trsko /WW/NHTwSEG3kyS+hPkCWZOmcLdZ99kq8/BCmlBEcSYT01LZZ26EUSI4rXB3lNK4zoJe GM6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ynSHATwvwcgV+WoQrgaoozN6evLYGuZ6cZOWLkl+ZrI=; b=sXVNkpV9OnJh/JYMdJVysxLbhH4giHCrzFV/O3RFqDxMkpjRsMDmrZTF8M/jJexmQj FzrOGcbaSgo7j8vWD9d8uyf/hG79+HTVWrDdouAK3klz2huUC8cfeXEKuUkQnBbDbo89 +d9WhWIbcnUadPPc/q24JJd++NK77Sd+60YuuNGyE2Xh3osL8I4bc/bPoVM96n+wBPNz CnaoBAOz83Zs7rm2jI6JX/xzLxGUDyOZsXzA1gbdkM1ENBYBKxaGsY/dUQpdrx3Z/GP+ BWQs86mIh0ofhJKqBBE8lVuQ/dVhJtl15nObslTev39gaVgrMnUye0jtengYONNrIZhz EWjw== X-Gm-Message-State: APt69E3jqvZ9zb9/ifeRnamHtL0HUEOIEdUf1nyk3dcrm/TJ2mfjOKTI ggO24XhBUx4+lkLw2UOdq+0= X-Google-Smtp-Source: AAOMgpchtVPPCSDCZpy5kbYLwhgoZWYcLGtkLRQrctTTghQRU7IQtIB8WO495i5gy0rVD4/5jvMSyQ== X-Received: by 2002:a50:fa82:: with SMTP id w2-v6mr22124797edr.256.1531127567635; Mon, 09 Jul 2018 02:12:47 -0700 (PDT) From: Emanuele Giuseppe Esposito To: Paolo Bonzini Date: Mon, 9 Jul 2018 11:11:31 +0200 Message-Id: <20180709091136.28849-3-e.emanuelegiuseppe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180709091136.28849-1-e.emanuelegiuseppe@gmail.com> References: <20180709091136.28849-1-e.emanuelegiuseppe@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::544 Subject: [Qemu-devel] [PATCH 2/7] tests/qgraph: pci-pc driver and interface nodes 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: Laurent Vivier , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add pci-bus-pc node and pci-bus interface, moved QPCIBusPC struct declaration in its header (since it will be needed by other drivers) and introduced a setter method for drivers that do not need to allocate but have to initialize QPCIBusPC. Signed-off-by: Emanuele Giuseppe Esposito --- tests/libqos/pci-pc.c | 53 ++++++++++++++++++++++++++++++++++++------- tests/libqos/pci-pc.h | 8 +++++++ tests/libqos/pci.c | 8 +++++++ 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index a7803308b7..f1c1741279 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -18,15 +18,9 @@ =20 #include "qemu-common.h" =20 - #define ACPI_PCIHP_ADDR 0xae00 #define PCI_EJ_BASE 0x0008 =20 -typedef struct QPCIBusPC -{ - QPCIBus bus; -} QPCIBusPC; - static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr) { return inb(addr); @@ -115,10 +109,33 @@ static void qpci_pc_config_writel(QPCIBus *bus, int d= evfn, uint8_t offset, uint3 outl(0xcfc, value); } =20 -QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) +static void *qpci_get_driver(void *obj, const char *interface) { - QPCIBusPC *ret =3D g_new0(QPCIBusPC, 1); + QPCIBusPC *qpci =3D obj; + if (!g_strcmp0(interface, "pci-bus")) { + return &qpci->bus; + } + printf("%s not present in pci-bus-pc", interface); + abort(); +} =20 +void qpci_device_init(QPCIDevice *dev, QPCIBus *bus, int devfn) +{ + if (!bus) { + return; + } + dev->bus =3D bus; + dev->devfn =3D devfn; + + if (qpci_config_readw(dev, PCI_VENDOR_ID) =3D=3D 0xFFFF) { + printf("PCI Device not found\n"); + abort(); + } + qpci_device_enable(dev); +} + +void qpci_set_pc(QPCIBusPC *ret, QTestState *qts, QGuestAllocator *alloc) +{ assert(qts); =20 ret->bus.pio_readb =3D qpci_pc_pio_readb; @@ -147,11 +164,23 @@ QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocato= r *alloc) ret->bus.mmio_alloc_ptr =3D 0xE0000000; ret->bus.mmio_limit =3D 0x100000000ULL; =20 + ret->obj.get_driver =3D qpci_get_driver; +} + +QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc) +{ + QPCIBusPC *ret =3D g_new0(QPCIBusPC, 1); + qpci_set_pc(ret, qts, alloc); + return &ret->bus; } =20 void qpci_free_pc(QPCIBus *bus) { + if (!bus) { + return; + } + QPCIBusPC *s =3D container_of(bus, QPCIBusPC, bus); =20 g_free(s); @@ -176,3 +205,11 @@ void qpci_unplug_acpi_device_test(const char *id, uint= 8_t slot) =20 qmp_eventwait("DEVICE_DELETED"); } + +static void qpci_pc(void) +{ + qos_node_create_driver("pci-bus-pc", NULL); + qos_node_produces("pci-bus-pc", "pci-bus"); +} + +libqos_init(qpci_pc); diff --git a/tests/libqos/pci-pc.h b/tests/libqos/pci-pc.h index 491eeac756..ee381c5667 100644 --- a/tests/libqos/pci-pc.h +++ b/tests/libqos/pci-pc.h @@ -15,7 +15,15 @@ =20 #include "libqos/pci.h" #include "libqos/malloc.h" +#include "qgraph.h" =20 +typedef struct QPCIBusPC { + QOSGraphObject obj; + QPCIBus bus; +} QPCIBusPC; + +void qpci_device_init(QPCIDevice *dev, QPCIBus *bus, int devfn); +void qpci_set_pc(QPCIBusPC *ret, QTestState *qts, QGuestAllocator *alloc); QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc); void qpci_free_pc(QPCIBus *bus); =20 diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c index 0b73cb23d0..c51c186867 100644 --- a/tests/libqos/pci.c +++ b/tests/libqos/pci.c @@ -15,6 +15,7 @@ =20 #include "hw/pci/pci_regs.h" #include "qemu/host-utils.h" +#include "qgraph.h" =20 void qpci_device_foreach(QPCIBus *bus, int vendor_id, int device_id, void (*func)(QPCIDevice *dev, int devfn, void *da= ta), @@ -402,3 +403,10 @@ void qpci_plug_device_test(const char *driver, const c= har *id, qtest_qmp_device_add(driver, id, "'addr': '%d'%s%s", slot, opts ? ", " : "", opts ? opts : ""); } + +static void qpci(void) +{ + qos_node_create_interface("pci-bus"); +} + +libqos_init(qpci); --=20 2.17.1