xref: /qemu/tests/qtest/es1370-test.c (revision 7f4090a56d455881f261817be47c96f6d278da81)
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*7f4090a5SEmanuele Giuseppe Esposito #include "libqos/qgraph.h"
13*7f4090a5SEmanuele Giuseppe Esposito #include "libqos/pci.h"
148fa74c94SAndreas Färber 
15*7f4090a5SEmanuele Giuseppe Esposito typedef struct QES1370 QES1370;
16*7f4090a5SEmanuele Giuseppe Esposito 
17*7f4090a5SEmanuele Giuseppe Esposito struct QES1370 {
18*7f4090a5SEmanuele Giuseppe Esposito     QOSGraphObject obj;
19*7f4090a5SEmanuele Giuseppe Esposito     QPCIDevice dev;
20*7f4090a5SEmanuele Giuseppe Esposito };
21*7f4090a5SEmanuele Giuseppe Esposito 
22*7f4090a5SEmanuele Giuseppe Esposito static void *es1370_get_driver(void *obj, const char *interface)
238fa74c94SAndreas Färber {
24*7f4090a5SEmanuele Giuseppe Esposito     QES1370 *es1370 = obj;
25*7f4090a5SEmanuele Giuseppe Esposito 
26*7f4090a5SEmanuele Giuseppe Esposito     if (!g_strcmp0(interface, "pci-device")) {
27*7f4090a5SEmanuele Giuseppe Esposito         return &es1370->dev;
288fa74c94SAndreas Färber     }
298fa74c94SAndreas Färber 
30*7f4090a5SEmanuele Giuseppe Esposito     fprintf(stderr, "%s not present in e1000e\n", interface);
31*7f4090a5SEmanuele Giuseppe Esposito     g_assert_not_reached();
328fa74c94SAndreas Färber }
33*7f4090a5SEmanuele Giuseppe Esposito 
34*7f4090a5SEmanuele Giuseppe Esposito static void *es1370_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
35*7f4090a5SEmanuele Giuseppe Esposito {
36*7f4090a5SEmanuele Giuseppe Esposito     QES1370 *es1370 = g_new0(QES1370, 1);
37*7f4090a5SEmanuele Giuseppe Esposito     QPCIBus *bus = pci_bus;
38*7f4090a5SEmanuele Giuseppe Esposito 
39*7f4090a5SEmanuele Giuseppe Esposito     qpci_device_init(&es1370->dev, bus, addr);
40*7f4090a5SEmanuele Giuseppe Esposito     es1370->obj.get_driver = es1370_get_driver;
41*7f4090a5SEmanuele Giuseppe Esposito 
42*7f4090a5SEmanuele Giuseppe Esposito     return &es1370->obj;
43*7f4090a5SEmanuele Giuseppe Esposito }
44*7f4090a5SEmanuele Giuseppe Esposito 
45*7f4090a5SEmanuele Giuseppe Esposito static void es1370_register_nodes(void)
46*7f4090a5SEmanuele Giuseppe Esposito {
47*7f4090a5SEmanuele Giuseppe Esposito     QOSGraphEdgeOptions opts = {
48*7f4090a5SEmanuele Giuseppe Esposito         .extra_device_opts = "addr=04.0",
49*7f4090a5SEmanuele Giuseppe Esposito     };
50*7f4090a5SEmanuele Giuseppe Esposito     add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
51*7f4090a5SEmanuele Giuseppe Esposito 
52*7f4090a5SEmanuele Giuseppe Esposito     qos_node_create_driver("ES1370", es1370_create);
53*7f4090a5SEmanuele Giuseppe Esposito     qos_node_consumes("ES1370", "pci-bus", &opts);
54*7f4090a5SEmanuele Giuseppe Esposito     qos_node_produces("ES1370", "pci-device");
55*7f4090a5SEmanuele Giuseppe Esposito }
56*7f4090a5SEmanuele Giuseppe Esposito 
57*7f4090a5SEmanuele Giuseppe Esposito libqos_init(es1370_register_nodes);
58