[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 33/46] hw/m68k/q800: use qemu_find_nic_info()
From: |
David Woodhouse |
Subject: |
[PATCH v3 33/46] hw/m68k/q800: use qemu_find_nic_info() |
Date: |
Mon, 8 Jan 2024 20:27:02 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
If a corresponding NIC configuration was found, it will have a MAC address
already assigned, so use that. Else, generate and assign a default one.
Using qemu_find_nic_info() is simpler than the alternative of using
qemu_configure_nic_device() and then having to fetch the "mac" property
as a string and convert it.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/m68k/q800.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 83d1571d02..c9e7bdf197 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -48,6 +48,7 @@
#include "hw/display/macfb.h"
#include "hw/block/swim.h"
#include "net/net.h"
+#include "net/util.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "sysemu/qtest.h"
@@ -271,6 +272,8 @@ static void q800_machine_init(MachineState *machine)
BusState *adb_bus;
NubusBus *nubus;
DriveInfo *dinfo;
+ NICInfo *nd;
+ MACAddr mac;
uint8_t rng_seed[32];
linux_boot = (kernel_filename != NULL);
@@ -371,13 +374,6 @@ static void q800_machine_init(MachineState *machine)
/* MACSONIC */
- if (nb_nics > 1) {
- error_report("q800 can only have one ethernet interface");
- exit(1);
- }
-
- qemu_check_nic_model(&nd_table[0], "dp83932");
-
/*
* MacSonic driver needs an Apple MAC address
* Valid prefix are:
@@ -387,14 +383,21 @@ static void q800_machine_init(MachineState *machine)
* 08:00:07 Apple
* (Q800 use the last one)
*/
- nd_table[0].macaddr.a[0] = 0x08;
- nd_table[0].macaddr.a[1] = 0x00;
- nd_table[0].macaddr.a[2] = 0x07;
-
object_initialize_child(OBJECT(machine), "dp8393x", &m->dp8393x,
TYPE_DP8393X);
dev = DEVICE(&m->dp8393x);
- qdev_set_nic_properties(dev, &nd_table[0]);
+ nd = qemu_find_nic_info(TYPE_DP8393X, true, "dp83932");
+ if (nd) {
+ qdev_set_nic_properties(dev, nd);
+ memcpy(mac.a, nd->macaddr.a, sizeof(mac.a));
+ } else {
+ qemu_macaddr_default_if_unset(&mac);
+ }
+ mac.a[0] = 0x08;
+ mac.a[1] = 0x00;
+ mac.a[2] = 0x07;
+ qdev_prop_set_macaddr(dev, "mac", mac.a);
+
qdev_prop_set_uint8(dev, "it_shift", 2);
qdev_prop_set_bit(dev, "big_endian", true);
object_property_set_link(OBJECT(dev), "dma_mr",
@@ -415,7 +418,7 @@ static void q800_machine_init(MachineState *machine)
prom = memory_region_get_ram_ptr(dp8393x_prom);
checksum = 0;
for (i = 0; i < 6; i++) {
- prom[i] = revbit8(nd_table[0].macaddr.a[i]);
+ prom[i] = revbit8(mac.a[i]);
checksum ^= prom[i];
}
prom[7] = 0xff - checksum;
--
2.41.0
- Re: [PATCH v3 40/46] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device(), (continued)
- [PATCH v3 37/46] hw/net/lasi_i82596: use qemu_configure_nic_device(), David Woodhouse, 2024/01/08
- [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/08
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), Thomas Huth, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), Thomas Huth, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), Thomas Huth, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
[PATCH v3 33/46] hw/m68k/q800: use qemu_find_nic_info(),
David Woodhouse <=
[PATCH v3 46/46] net: make nb_nics and nd_table[] static in net/net.c, David Woodhouse, 2024/01/08
[PATCH v3 44/46] hw/pci: remove pci_nic_init_nofail(), David Woodhouse, 2024/01/08
[PATCH v3 26/46] hw/net/lan9118: use qemu_configure_nic_device(), David Woodhouse, 2024/01/08
[PATCH v3 25/46] hw/net/smc91c111: use qemu_configure_nic_device(), David Woodhouse, 2024/01/08
[PATCH v3 08/46] hw/arm/sbsa-ref: use pci_init_nic_devices(), David Woodhouse, 2024/01/08
[PATCH v3 41/46] hw/sparc/sun4m: use qemu_find_nic_info(), David Woodhouse, 2024/01/08
[PATCH v3 28/46] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases, David Woodhouse, 2024/01/08
[PATCH v3 19/46] hw/sparc64/sun4u: use pci_init_nic_devices(), David Woodhouse, 2024/01/08