18fa74c94SAndreas Färber /* 28fa74c94SAndreas Färber * QTest testcase for ES1370 38fa74c94SAndreas Färber * 48fa74c94SAndreas Färber * Copyright (c) 2014 SUSE LINUX Products GmbH 58fa74c94SAndreas Färber * 68fa74c94SAndreas Färber * This work is licensed under the terms of the GNU GPL, version 2 or later. 78fa74c94SAndreas Färber * See the COPYING file in the top-level directory. 88fa74c94SAndreas Färber */ 98fa74c94SAndreas Färber 108fa74c94SAndreas Färber #include "qemu/osdep.h" 11681c28a3SPeter Maydell #include "libqtest.h" 12*0b8fa32fSMarkus Armbruster #include "qemu/module.h" 137f4090a5SEmanuele Giuseppe Esposito #include "libqos/qgraph.h" 147f4090a5SEmanuele Giuseppe Esposito #include "libqos/pci.h" 158fa74c94SAndreas Färber 167f4090a5SEmanuele Giuseppe Esposito typedef struct QES1370 QES1370; 177f4090a5SEmanuele Giuseppe Esposito 187f4090a5SEmanuele Giuseppe Esposito struct QES1370 { 197f4090a5SEmanuele Giuseppe Esposito QOSGraphObject obj; 207f4090a5SEmanuele Giuseppe Esposito QPCIDevice dev; 217f4090a5SEmanuele Giuseppe Esposito }; 227f4090a5SEmanuele Giuseppe Esposito 237f4090a5SEmanuele Giuseppe Esposito static void *es1370_get_driver(void *obj, const char *interface) 248fa74c94SAndreas Färber { 257f4090a5SEmanuele Giuseppe Esposito QES1370 *es1370 = obj; 267f4090a5SEmanuele Giuseppe Esposito 277f4090a5SEmanuele Giuseppe Esposito if (!g_strcmp0(interface, "pci-device")) { 287f4090a5SEmanuele Giuseppe Esposito return &es1370->dev; 298fa74c94SAndreas Färber } 308fa74c94SAndreas Färber 317f4090a5SEmanuele Giuseppe Esposito fprintf(stderr, "%s not present in e1000e\n", interface); 327f4090a5SEmanuele Giuseppe Esposito g_assert_not_reached(); 338fa74c94SAndreas Färber } 347f4090a5SEmanuele Giuseppe Esposito 357f4090a5SEmanuele Giuseppe Esposito static void *es1370_create(void *pci_bus, QGuestAllocator *alloc, void *addr) 367f4090a5SEmanuele Giuseppe Esposito { 377f4090a5SEmanuele Giuseppe Esposito QES1370 *es1370 = g_new0(QES1370, 1); 387f4090a5SEmanuele Giuseppe Esposito QPCIBus *bus = pci_bus; 397f4090a5SEmanuele Giuseppe Esposito 407f4090a5SEmanuele Giuseppe Esposito qpci_device_init(&es1370->dev, bus, addr); 417f4090a5SEmanuele Giuseppe Esposito es1370->obj.get_driver = es1370_get_driver; 427f4090a5SEmanuele Giuseppe Esposito 437f4090a5SEmanuele Giuseppe Esposito return &es1370->obj; 447f4090a5SEmanuele Giuseppe Esposito } 457f4090a5SEmanuele Giuseppe Esposito 467f4090a5SEmanuele Giuseppe Esposito static void es1370_register_nodes(void) 477f4090a5SEmanuele Giuseppe Esposito { 487f4090a5SEmanuele Giuseppe Esposito QOSGraphEdgeOptions opts = { 497f4090a5SEmanuele Giuseppe Esposito .extra_device_opts = "addr=04.0", 507f4090a5SEmanuele Giuseppe Esposito }; 517f4090a5SEmanuele Giuseppe Esposito add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); 527f4090a5SEmanuele Giuseppe Esposito 537f4090a5SEmanuele Giuseppe Esposito qos_node_create_driver("ES1370", es1370_create); 547f4090a5SEmanuele Giuseppe Esposito qos_node_consumes("ES1370", "pci-bus", &opts); 557f4090a5SEmanuele Giuseppe Esposito qos_node_produces("ES1370", "pci-device"); 567f4090a5SEmanuele Giuseppe Esposito } 577f4090a5SEmanuele Giuseppe Esposito 587f4090a5SEmanuele Giuseppe Esposito libqos_init(es1370_register_nodes); 59