* [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion
@ 2023-02-13 10:10 Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 1/7] hw/net/eepro100: Abort if pci_add_capability() ever fail Philippe Mathieu-Daudé
` (7 more replies)
0 siblings, 8 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
Convert EEPRO100 to use the latest QDev conventions / style.
v1:
https://lore.kernel.org/qemu-devel/20230213070820.76881-9-philmd@linaro.org/
Based-on: <20230213070423.76428-1-philmd@linaro.org>
hw/qdev: Housekeeping around qdev_get_parent_bus()
Philippe Mathieu-Daudé (7):
hw/net/eepro100: Abort if pci_add_capability() ever fail
hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent
hw/net/eepro100: Convert reset handler to DeviceReset
hw/net/eepro100: Pass E100PCIDeviceInfo as class init data
hw/net/eepro100: Remove instance
EEPRO100State::has_extended_tcb_support
hw/net/eepro100: Remove instance's EEPRO100State::device
hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100()
hw/net/eepro100.c | 147 ++++++++++++++++++++++------------------------
1 file changed, 69 insertions(+), 78 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/7] hw/net/eepro100: Abort if pci_add_capability() ever fail
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 2/7] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent Philippe Mathieu-Daudé
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
If pci_add_capability() ever fail, the EEPRO100 device is broken,
which is a bug. No need to report that to the user, abort instead.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index dc07984ae9..dce75039ec 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -549,13 +549,8 @@ static void e100_pci_reset(EEPRO100State *s, Error **errp)
if (info->power_management) {
/* Power Management Capabilities */
int cfg_offset = 0xdc;
- int r = pci_add_capability(&s->dev, PCI_CAP_ID_PM,
- cfg_offset, PCI_PM_SIZEOF,
- errp);
- if (r < 0) {
- return;
- }
-
+ pci_add_capability(&s->dev, PCI_CAP_ID_PM, cfg_offset, PCI_PM_SIZEOF,
+ &error_abort);
pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21);
#if 0 /* TODO: replace dummy code for power management emulation. */
/* TODO: Power Management Control / Status. */
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/7] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 1/7] hw/net/eepro100: Abort if pci_add_capability() ever fail Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 3/7] hw/net/eepro100: Convert reset handler to DeviceReset Philippe Mathieu-Daudé
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
Have all the EEPRO100-based devices share a common (abstract)
QOM parent.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 58 +++++++++++++++++++++++++++++++++--------------
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index dce75039ec..4b5d45576b 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_register_static(&eepro100_base_info);
- 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 },
- { },
+ 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.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 3/7] hw/net/eepro100: Convert reset handler to DeviceReset
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 1/7] hw/net/eepro100: Abort if pci_add_capability() ever fail Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 2/7] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 4/7] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data Philippe Mathieu-Daudé
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 4b5d45576b..722fb55e4a 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -486,8 +486,9 @@ static void eepro100_fcp_interrupt(EEPRO100State * s)
}
#endif
-static void e100_pci_reset(EEPRO100State *s, Error **errp)
+static void e100_pci_reset(DeviceState *dev)
{
+ EEPRO100State *s = EEPRO100(dev);
E100PCIDeviceInfo *info = eepro100_get_class(s);
uint32_t device = s->device;
uint8_t *pci_conf = s->dev.config;
@@ -1847,18 +1848,11 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
{
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
E100PCIDeviceInfo *info = eepro100_get_class(s);
- Error *local_err = NULL;
TRACE(OTHER, logout("\n"));
s->device = info->device;
- e100_pci_reset(s, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
-
/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
* i82559 and later support 64 or 256 word EEPROM. */
s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE);
@@ -2076,6 +2070,7 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
device_class_set_props(dc, e100_properties);
+ dc->reset = e100_pci_reset;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->class_id = PCI_CLASS_NETWORK_ETHERNET;
k->romfile = "pxe-eepro100.rom";
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 4/7] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-02-13 10:10 ` [PATCH v2 3/7] hw/net/eepro100: Convert reset handler to DeviceReset Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 5/7] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support Philippe Mathieu-Daudé
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
QOM already provides the TypeInfo::class_data to set
class-specific data. Use it instead of reinventing the
wheel with eepro100_get_class_by_name(). This finishes
the QDev conversion started 12 years ago in commit
40021f0888 ("pci: convert to QEMU Object Model").
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 63 +++++++++++++++--------------------------------
1 file changed, 20 insertions(+), 43 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 722fb55e4a..ab20558a18 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -242,6 +242,8 @@ struct EEPRO100Class {
/*< private >*/
PCIDeviceClass parent_class;
/*< public >*/
+
+ const E100PCIDeviceInfo *info;
};
struct EEPRO100State {
@@ -338,8 +340,6 @@ static const uint16_t eepro100_mdi_mask[] = {
0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s);
-
/* Read a 16 bit control/status (CSR) register. */
static uint16_t e100_read_reg2(EEPRO100State *s, E100RegisterOffset addr)
{
@@ -489,8 +489,9 @@ static void eepro100_fcp_interrupt(EEPRO100State * s)
static void e100_pci_reset(DeviceState *dev)
{
EEPRO100State *s = EEPRO100(dev);
- E100PCIDeviceInfo *info = eepro100_get_class(s);
- uint32_t device = s->device;
+ EEPRO100Class *ek = EEPRO100_GET_CLASS(s);
+ const E100PCIDeviceInfo *info = ek->info;
+ uint32_t device = info->device;
uint8_t *pci_conf = s->dev.config;
TRACE(OTHER, logout("%p\n", s));
@@ -1847,11 +1848,11 @@ static NetClientInfo net_eepro100_info = {
static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
{
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
- E100PCIDeviceInfo *info = eepro100_get_class(s);
+ EEPRO100Class *ek = EEPRO100_GET_CLASS(s);
TRACE(OTHER, logout("\n"));
- s->device = info->device;
+ s->device = ek->info->device;
/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
* i82559 and later support 64 or 256 word EEPROM. */
@@ -2028,32 +2029,19 @@ static E100PCIDeviceInfo e100_devices[] = {
}
};
-static E100PCIDeviceInfo *eepro100_get_class_by_name(const char *typename)
+static void eepro100_class_init(ObjectClass *klass, void *data)
{
- E100PCIDeviceInfo *info = NULL;
- int i;
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+ EEPRO100Class *ek = EEPRO100_CLASS(klass);
+ const E100PCIDeviceInfo *info = data;
- /* This is admittedly awkward but also temporary. QOM allows for
- * parameterized typing and for subclassing both of which would suitable
- * handle what's going on here. But class_data is already being used as
- * a stop-gap hack to allow incremental qdev conversion so we cannot use it
- * right now. Once we merge the final QOM series, we can come back here and
- * do this in a much more elegant fashion.
- */
- for (i = 0; i < ARRAY_SIZE(e100_devices); i++) {
- if (strcmp(e100_devices[i].name, typename) == 0) {
- info = &e100_devices[i];
- break;
- }
- }
- assert(info != NULL);
-
- return info;
-}
-
-static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s)
-{
- return eepro100_get_class_by_name(object_get_typename(OBJECT(s)));
+ 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;
+ ek->info = info;
}
static Property e100_properties[] = {
@@ -2065,8 +2053,6 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- E100PCIDeviceInfo *info;
-
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
device_class_set_props(dc, e100_properties);
@@ -2076,17 +2062,6 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data)
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 = {
@@ -2111,6 +2086,8 @@ static void eepro100_register_types(void)
TypeInfo type_info = {
.name = e100_devices[i].name,
.parent = TYPE_EEPRO100,
+ .class_init = eepro100_class_init,
+ .class_data = (void *)&e100_devices[i],
};
type_register(&type_info);
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 5/7] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-02-13 10:10 ` [PATCH v2 4/7] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 6/7] hw/net/eepro100: Remove instance's EEPRO100State::device Philippe Mathieu-Daudé
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
'has_extended_tcb_support' is accessed read-only and is present
in the class definition. No need to duplicate it in the instance
state. Directly access the class field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index ab20558a18..d7757907c3 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -292,7 +292,6 @@ struct EEPRO100State {
/* Quasi static device properties (no need to save them). */
uint16_t stats_size;
- bool has_extended_tcb_support;
};
/* Word indices in EEPROM. */
@@ -511,7 +510,6 @@ static void e100_pci_reset(DeviceState *dev)
pci_set_byte(pci_conf + PCI_MAX_LAT, 0x18);
s->stats_size = info->stats_size;
- s->has_extended_tcb_support = info->has_extended_tcb_support;
switch (device) {
case i82550:
@@ -746,6 +744,8 @@ static void read_cb(EEPRO100State *s)
static void tx_command(EEPRO100State *s)
{
+ EEPRO100Class *ek = EEPRO100_GET_CLASS(s);
+ const E100PCIDeviceInfo *info = ek->info;
const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
uint32_t tbd_array = s->tx.tbd_array_addr;
uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff;
@@ -782,7 +782,7 @@ static void tx_command(EEPRO100State *s)
uint16_t tx_buffer_size;
uint16_t tx_buffer_el;
- if (s->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) {
+ if (info->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) {
/* Extended Flexible TCB. */
for (; tbd_count < 2; tbd_count++) {
ldl_le_pci_dma(&s->dev, tbd_address, &tx_buffer_address, attrs);
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 6/7] hw/net/eepro100: Remove instance's EEPRO100State::device
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2023-02-13 10:10 ` [PATCH v2 5/7] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 7/7] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100() Philippe Mathieu-Daudé
2023-02-23 15:16 ` [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
'device' is accessed read-only and is present in the class
definition. No need to duplicate it in the instance state.
Directly access the class field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index d7757907c3..bce377688e 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -263,7 +263,6 @@ struct EEPRO100State {
/* region must not be saved by nic_save. */
uint16_t mdimem[32];
eeprom_t *eeprom;
- uint32_t device; /* device variant */
/* (cu_base + cu_offset) address the next command block in the command block list. */
uint32_t cu_base; /* CU base address */
uint32_t cu_offset; /* CU address offset */
@@ -591,6 +590,9 @@ static void e100_pci_reset(DeviceState *dev)
static void nic_selective_reset(EEPRO100State * s)
{
+ EEPRO100Class *ek = EEPRO100_GET_CLASS(s);
+ const E100PCIDeviceInfo *info = ek->info;
+
size_t i;
uint16_t *eeprom_contents = eeprom93xx_data(s->eeprom);
#if 0
@@ -598,8 +600,9 @@ static void nic_selective_reset(EEPRO100State * s)
#endif
memcpy(eeprom_contents, s->conf.macaddr.a, 6);
eeprom_contents[EEPROM_ID] = EEPROM_ID_VALID;
- if (s->device == i82557B || s->device == i82557C)
+ if (info->device == i82557B || info->device == i82557C) {
eeprom_contents[5] = 0x0100;
+ }
eeprom_contents[EEPROM_PHY_ID] = 1;
uint16_t sum = 0;
for (i = 0; i < EEPROM_SIZE - 1; i++) {
@@ -1794,7 +1797,7 @@ static const VMStateDescription vmstate_eepro100 = {
VMSTATE_UNUSED(19*4),
VMSTATE_UINT16_ARRAY(mdimem, EEPRO100State, 32),
/* The eeprom should be saved and restored by its own routines. */
- VMSTATE_UINT32(device, EEPRO100State),
+ VMSTATE_UNUSED(sizeof(uint32_t)), /* was device variant */
/* TODO check device. */
VMSTATE_UINT32(cu_base, EEPRO100State),
VMSTATE_UINT32(cu_offset, EEPRO100State),
@@ -1848,12 +1851,9 @@ static NetClientInfo net_eepro100_info = {
static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
{
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
- EEPRO100Class *ek = EEPRO100_GET_CLASS(s);
TRACE(OTHER, logout("\n"));
- s->device = ek->info->device;
-
/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
* i82559 and later support 64 or 256 word EEPROM. */
s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE);
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 7/7] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100()
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2023-02-13 10:10 ` [PATCH v2 6/7] hw/net/eepro100: Remove instance's EEPRO100State::device Philippe Mathieu-Daudé
@ 2023-02-13 10:10 ` Philippe Mathieu-Daudé
2023-02-23 15:16 ` [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
7 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-13 10:10 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil,
Philippe Mathieu-Daudé
Use the EEPRO100() QOM type-checking macro to avoid DO_UPCAST().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/eepro100.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index bce377688e..6db15f1ba2 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1834,7 +1834,7 @@ static const VMStateDescription vmstate_eepro100 = {
static void pci_nic_uninit(PCIDevice *pci_dev)
{
- EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
+ EEPRO100State *s = EEPRO100(pci_dev);
vmstate_unregister(VMSTATE_IF(&pci_dev->qdev), s->vmstate, s);
g_free(s->vmstate);
@@ -1850,7 +1850,7 @@ static NetClientInfo net_eepro100_info = {
static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
{
- EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
+ EEPRO100State *s = EEPRO100(pci_dev);
TRACE(OTHER, logout("\n"));
@@ -1891,7 +1891,7 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
static void eepro100_instance_init(Object *obj)
{
- EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, PCI_DEVICE(obj));
+ EEPRO100State *s = EEPRO100(obj);
device_add_bootindex_property(obj, &s->conf.bootindex,
"bootindex", "/ethernet-phy@0",
DEVICE(s));
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2023-02-13 10:10 ` [PATCH v2 7/7] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100() Philippe Mathieu-Daudé
@ 2023-02-23 15:16 ` Philippe Mathieu-Daudé
2023-02-28 13:40 ` Philippe Mathieu-Daudé
7 siblings, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-23 15:16 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil
ping
On 13/2/23 11:10, Philippe Mathieu-Daudé wrote:
> Convert EEPRO100 to use the latest QDev conventions / style.
>
> v1:
> https://lore.kernel.org/qemu-devel/20230213070820.76881-9-philmd@linaro.org/
>
> Based-on: <20230213070423.76428-1-philmd@linaro.org>
> hw/qdev: Housekeeping around qdev_get_parent_bus()
>
> Philippe Mathieu-Daudé (7):
> hw/net/eepro100: Abort if pci_add_capability() ever fail
> hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent
> hw/net/eepro100: Convert reset handler to DeviceReset
> hw/net/eepro100: Pass E100PCIDeviceInfo as class init data
> hw/net/eepro100: Remove instance
> EEPRO100State::has_extended_tcb_support
> hw/net/eepro100: Remove instance's EEPRO100State::device
> hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100()
>
> hw/net/eepro100.c | 147 ++++++++++++++++++++++------------------------
> 1 file changed, 69 insertions(+), 78 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion
2023-02-23 15:16 ` [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
@ 2023-02-28 13:40 ` Philippe Mathieu-Daudé
2023-03-03 8:01 ` Jason Wang
0 siblings, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-28 13:40 UTC (permalink / raw)
To: qemu-devel, Eduardo Habkost
Cc: Jason Wang, Thomas Huth, Igor Mammedov, Stefan Weil
Hi Jason, do you Ack this series?
On 23/2/23 16:16, Philippe Mathieu-Daudé wrote:
> ping
>
> On 13/2/23 11:10, Philippe Mathieu-Daudé wrote:
>> Convert EEPRO100 to use the latest QDev conventions / style.
>>
>> v1:
>> https://lore.kernel.org/qemu-devel/20230213070820.76881-9-philmd@linaro.org/
>>
>> Based-on: <20230213070423.76428-1-philmd@linaro.org>
>> hw/qdev: Housekeeping around qdev_get_parent_bus()
>>
>> Philippe Mathieu-Daudé (7):
>> hw/net/eepro100: Abort if pci_add_capability() ever fail
>> hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent
>> hw/net/eepro100: Convert reset handler to DeviceReset
>> hw/net/eepro100: Pass E100PCIDeviceInfo as class init data
>> hw/net/eepro100: Remove instance
>> EEPRO100State::has_extended_tcb_support
>> hw/net/eepro100: Remove instance's EEPRO100State::device
>> hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100()
>>
>> hw/net/eepro100.c | 147 ++++++++++++++++++++++------------------------
>> 1 file changed, 69 insertions(+), 78 deletions(-)
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion
2023-02-28 13:40 ` Philippe Mathieu-Daudé
@ 2023-03-03 8:01 ` Jason Wang
2023-03-03 10:32 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 12+ messages in thread
From: Jason Wang @ 2023-03-03 8:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Eduardo Habkost, Thomas Huth, Igor Mammedov, Stefan Weil
On Tue, Feb 28, 2023 at 9:40 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Hi Jason, do you Ack this series?
Sorry for the late reply.
I've queued this series.
Thanks
>
> On 23/2/23 16:16, Philippe Mathieu-Daudé wrote:
> > ping
> >
> > On 13/2/23 11:10, Philippe Mathieu-Daudé wrote:
> >> Convert EEPRO100 to use the latest QDev conventions / style.
> >>
> >> v1:
> >> https://lore.kernel.org/qemu-devel/20230213070820.76881-9-philmd@linaro.org/
> >>
> >> Based-on: <20230213070423.76428-1-philmd@linaro.org>
> >> hw/qdev: Housekeeping around qdev_get_parent_bus()
> >>
> >> Philippe Mathieu-Daudé (7):
> >> hw/net/eepro100: Abort if pci_add_capability() ever fail
> >> hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent
> >> hw/net/eepro100: Convert reset handler to DeviceReset
> >> hw/net/eepro100: Pass E100PCIDeviceInfo as class init data
> >> hw/net/eepro100: Remove instance
> >> EEPRO100State::has_extended_tcb_support
> >> hw/net/eepro100: Remove instance's EEPRO100State::device
> >> hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100()
> >>
> >> hw/net/eepro100.c | 147 ++++++++++++++++++++++------------------------
> >> 1 file changed, 69 insertions(+), 78 deletions(-)
> >>
> >
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion
2023-03-03 8:01 ` Jason Wang
@ 2023-03-03 10:32 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-03-03 10:32 UTC (permalink / raw)
To: Jason Wang
Cc: qemu-devel, Eduardo Habkost, Thomas Huth, Igor Mammedov, Stefan Weil
On 3/3/23 09:01, Jason Wang wrote:
> On Tue, Feb 28, 2023 at 9:40 PM Philippe Mathieu-Daudé
> <philmd@linaro.org> wrote:
>>
>> Hi Jason, do you Ack this series?
>
> Sorry for the late reply.
>
> I've queued this series.
Thank you!
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-03-03 10:32 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 10:10 [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 1/7] hw/net/eepro100: Abort if pci_add_capability() ever fail Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 2/7] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 3/7] hw/net/eepro100: Convert reset handler to DeviceReset Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 4/7] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 5/7] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 6/7] hw/net/eepro100: Remove instance's EEPRO100State::device Philippe Mathieu-Daudé
2023-02-13 10:10 ` [PATCH v2 7/7] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100() Philippe Mathieu-Daudé
2023-02-23 15:16 ` [PATCH v2 0/7] hw/net/eepro100: Finish QDev conversion Philippe Mathieu-Daudé
2023-02-28 13:40 ` Philippe Mathieu-Daudé
2023-03-03 8:01 ` Jason Wang
2023-03-03 10:32 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.