]>
Commit | Line | Data |
---|---|---|
a21baf79 AF |
1 | /* |
2 | * QTest testcase for e1000 NIC | |
3 | * | |
4 | * Copyright (c) 2013-2014 SUSE LINUX Products GmbH | |
5 | * | |
6 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
7 | * See the COPYING file in the top-level directory. | |
8 | */ | |
9 | ||
681c28a3 | 10 | #include "qemu/osdep.h" |
a21baf79 | 11 | #include "libqtest.h" |
0b8fa32f | 12 | #include "qemu/module.h" |
a138f266 EGE |
13 | #include "libqos/qgraph.h" |
14 | #include "libqos/pci.h" | |
a21baf79 | 15 | |
a138f266 | 16 | typedef struct QE1000 QE1000; |
b167383f | 17 | |
a138f266 EGE |
18 | struct QE1000 { |
19 | QOSGraphObject obj; | |
20 | QPCIDevice dev; | |
21 | }; | |
a21baf79 | 22 | |
b167383f GS |
23 | static const char *models[] = { |
24 | "e1000", | |
25 | "e1000-82540em", | |
26 | "e1000-82544gc", | |
27 | "e1000-82545em", | |
b167383f GS |
28 | }; |
29 | ||
a138f266 | 30 | static void *e1000_get_driver(void *obj, const char *interface) |
a21baf79 | 31 | { |
a138f266 | 32 | QE1000 *e1000 = obj; |
a21baf79 | 33 | |
a138f266 EGE |
34 | if (!g_strcmp0(interface, "pci-device")) { |
35 | return &e1000->dev; | |
36 | } | |
a21baf79 | 37 | |
a138f266 EGE |
38 | fprintf(stderr, "%s not present in e1000e\n", interface); |
39 | g_assert_not_reached(); | |
40 | } | |
a21baf79 | 41 | |
a138f266 EGE |
42 | static void *e1000_create(void *pci_bus, QGuestAllocator *alloc, void *addr) |
43 | { | |
44 | QE1000 *e1000 = g_new0(QE1000, 1); | |
45 | QPCIBus *bus = pci_bus; | |
46 | ||
47 | qpci_device_init(&e1000->dev, bus, addr); | |
48 | e1000->obj.get_driver = e1000_get_driver; | |
49 | ||
50 | return &e1000->obj; | |
51 | } | |
52 | ||
53 | static void e1000_register_nodes(void) | |
54 | { | |
55 | int i; | |
56 | QOSGraphEdgeOptions opts = { | |
57 | .extra_device_opts = "addr=04.0", | |
58 | }; | |
59 | add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); | |
a21baf79 | 60 | |
a138f266 EGE |
61 | for (i = 0; i < ARRAY_SIZE(models); i++) { |
62 | qos_node_create_driver(models[i], e1000_create); | |
63 | qos_node_consumes(models[i], "pci-bus", &opts); | |
64 | qos_node_produces(models[i], "pci-device"); | |
65 | } | |
a21baf79 | 66 | } |
a138f266 EGE |
67 | |
68 | libqos_init(e1000_register_nodes); |