[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 46/51] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract paren
From: |
Jason Wang |
Subject: |
[PULL 46/51] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent |
Date: |
Tue, 7 Mar 2023 15:08:11 +0800 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Have all the EEPRO100-based devices share a common (abstract)
QOM parent.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/eepro100.c | 60 ++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index dce7503..4b5d455 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -235,8 +235,20 @@ typedef enum {
ru_ready = 4
} ru_state_t;
-typedef struct {
+#define TYPE_EEPRO100 "eepro100"
+OBJECT_DECLARE_TYPE(EEPRO100State, EEPRO100Class, EEPRO100)
+
+struct EEPRO100Class {
+ /*< private >*/
+ PCIDeviceClass parent_class;
+ /*< public >*/
+};
+
+struct EEPRO100State {
+ /*< private >*/
PCIDevice dev;
+ /*< public >*/
+
/* Hash register (multicast mask array, multiple individual addresses). */
uint8_t mult[8];
MemoryRegion mmio_bar;
@@ -279,7 +291,7 @@ typedef struct {
/* Quasi static device properties (no need to save them). */
uint16_t stats_size;
bool has_extended_tcb_support;
-} EEPRO100State;
+};
/* Word indices in EEPROM. */
typedef enum {
@@ -2055,43 +2067,55 @@ static Property e100_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
-static void eepro100_class_init(ObjectClass *klass, void *data)
+static void eepro100_base_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
E100PCIDeviceInfo *info;
- info = eepro100_get_class_by_name(object_class_get_name(klass));
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
device_class_set_props(dc, e100_properties);
- dc->desc = info->desc;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->class_id = PCI_CLASS_NETWORK_ETHERNET;
k->romfile = "pxe-eepro100.rom";
k->realize = e100_nic_realize;
k->exit = pci_nic_uninit;
+
+ info = eepro100_get_class_by_name(object_class_get_name(klass));
+ if (!info) {
+ /* base class */
+ return;
+ }
+ dc->desc = info->desc;
k->device_id = info->device_id;
k->revision = info->revision;
k->subsystem_vendor_id = info->subsystem_vendor_id;
k->subsystem_id = info->subsystem_id;
}
+static const TypeInfo eepro100_base_info = {
+ .name = TYPE_EEPRO100,
+ .parent = TYPE_PCI_DEVICE,
+ .abstract = true,
+ .class_init = eepro100_base_class_init,
+ .class_size = sizeof(EEPRO100Class),
+ .instance_size = sizeof(EEPRO100State),
+ .instance_init = eepro100_instance_init,
+ .interfaces = (InterfaceInfo[]) {
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+ { },
+ },
+};
+
static void eepro100_register_types(void)
{
- size_t i;
- for (i = 0; i < ARRAY_SIZE(e100_devices); i++) {
- TypeInfo type_info = {};
- E100PCIDeviceInfo *info = &e100_devices[i];
-
- type_info.name = info->name;
- type_info.parent = TYPE_PCI_DEVICE;
- type_info.class_init = eepro100_class_init;
- type_info.instance_size = sizeof(EEPRO100State);
- type_info.instance_init = eepro100_instance_init;
- type_info.interfaces = (InterfaceInfo[]) {
- { INTERFACE_CONVENTIONAL_PCI_DEVICE },
- { },
+ type_register_static(&eepro100_base_info);
+
+ for (size_t i = 0; i < ARRAY_SIZE(e100_devices); i++) {
+ TypeInfo type_info = {
+ .name = e100_devices[i].name,
+ .parent = TYPE_EEPRO100,
};
type_register(&type_info);
--
2.7.4
- [PULL 42/51] tests/avocado: Add igb test, (continued)
- [PULL 42/51] tests/avocado: Add igb test, Jason Wang, 2023/03/07
- [PULL 45/51] hw/net/eepro100: Abort if pci_add_capability() ever fail, Jason Wang, 2023/03/07
- [PULL 44/51] ebpf: fix compatibility with libbpf 1.0+, Jason Wang, 2023/03/07
- [PULL 48/51] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data, Jason Wang, 2023/03/07
- [PULL 47/51] hw/net/eepro100: Convert reset handler to DeviceReset, Jason Wang, 2023/03/07
- [PULL 43/51] docs/system/devices/igb: Add igb documentation, Jason Wang, 2023/03/07
- [PULL 40/51] tests/qtest/libqos/e1000e: Export macreg functions, Jason Wang, 2023/03/07
- [PULL 50/51] hw/net/eepro100: Remove instance's EEPRO100State::device, Jason Wang, 2023/03/07
- [PULL 49/51] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support, Jason Wang, 2023/03/07
- [PULL 41/51] igb: Introduce qtest for igb device, Jason Wang, 2023/03/07
- [PULL 46/51] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent,
Jason Wang <=
- [PULL 51/51] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100(), Jason Wang, 2023/03/07
- Re: [PULL 00/51] Net patches, Peter Maydell, 2023/03/07
- Re: [PULL 00/51] Net patches, Philippe Mathieu-Daudé, 2023/03/07
- Re: [PULL 00/51] Net patches, Jason Wang, 2023/03/08
- Re: [PULL 00/51] Net patches, Philippe Mathieu-Daudé, 2023/03/08
- Re: [PULL 00/51] Net patches, Michael S. Tsirkin, 2023/03/08
- Re: [PULL 00/51] Net patches, Philippe Mathieu-Daudé, 2023/03/08
- Re: [PULL 00/51] Net patches, Michael S. Tsirkin, 2023/03/08
- Re: [PULL 00/51] Net patches, Jason Wang, 2023/03/08
Re: [PULL 00/51] Net patches, Jason Wang, 2023/03/08