]>
Commit | Line | Data |
---|---|---|
4a053e7f AF |
1 | /* |
2 | * QTest testcase for vmxnet3 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" |
4a053e7f | 11 | #include "libqtest.h" |
0b8fa32f | 12 | #include "qemu/module.h" |
53bfb429 EGE |
13 | #include "libqos/qgraph.h" |
14 | #include "libqos/pci.h" | |
4a053e7f | 15 | |
53bfb429 EGE |
16 | typedef struct QVmxnet3 QVmxnet3; |
17 | ||
18 | struct QVmxnet3 { | |
19 | QOSGraphObject obj; | |
20 | QPCIDevice dev; | |
21 | }; | |
22 | ||
23 | static void *vmxnet3_get_driver(void *obj, const char *interface) | |
4a053e7f | 24 | { |
53bfb429 EGE |
25 | QVmxnet3 *vmxnet3 = obj; |
26 | ||
27 | if (!g_strcmp0(interface, "pci-device")) { | |
28 | return &vmxnet3->dev; | |
29 | } | |
30 | ||
31 | fprintf(stderr, "%s not present in vmxnet3\n", interface); | |
32 | g_assert_not_reached(); | |
4a053e7f AF |
33 | } |
34 | ||
53bfb429 | 35 | static void *vmxnet3_create(void *pci_bus, QGuestAllocator *alloc, void *addr) |
4a053e7f | 36 | { |
53bfb429 EGE |
37 | QVmxnet3 *vmxnet3 = g_new0(QVmxnet3, 1); |
38 | QPCIBus *bus = pci_bus; | |
4a053e7f | 39 | |
53bfb429 EGE |
40 | qpci_device_init(&vmxnet3->dev, bus, addr); |
41 | vmxnet3->obj.get_driver = vmxnet3_get_driver; | |
4a053e7f | 42 | |
53bfb429 EGE |
43 | return &vmxnet3->obj; |
44 | } | |
4a053e7f | 45 | |
53bfb429 EGE |
46 | static void vmxnet3_register_nodes(void) |
47 | { | |
48 | QOSGraphEdgeOptions opts = { | |
49 | .extra_device_opts = "addr=04.0", | |
50 | }; | |
51 | add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); | |
4a053e7f | 52 | |
53bfb429 EGE |
53 | qos_node_create_driver("vmxnet3", vmxnet3_create); |
54 | qos_node_consumes("vmxnet3", "pci-bus", &opts); | |
55 | qos_node_produces("vmxnet3", "pci-device"); | |
4a053e7f | 56 | } |
53bfb429 EGE |
57 | |
58 | libqos_init(vmxnet3_register_nodes); |