[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 33/45] hw/m68k/q800: use qemu_configure_nic_device()
- To: qemu-devel@xxxxxxxxxx
- From: David Woodhouse <dwmw2@xxxxxxxxxxxxx>
- Date: Sun, 22 Oct 2023 16:51:48 +0100
- Cc: Richard Henderson <richard.henderson@xxxxxxxxxx>, Beniamino Galvani <b.galvani@xxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Strahinja Jankovic <strahinja.p.jankovic@xxxxxxxxx>, Niek Linnenbank <nieklinnenbank@xxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Andrew Jeffery <andrew@xxxxxxxx>, Joel Stanley <joel@xxxxxxxxx>, Igor Mitsyanko <i.mitsyanko@xxxxxxxxx>, Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>, Andrey Smirnov <andrew.smirnov@xxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>, Rob Herring <robh@xxxxxxxxxx>, Subbaraya Sundeep <sundeep.lkml@xxxxxxxxx>, Jan Kiszka <jan.kiszka@xxxxxx>, Tyrone Ting <kfting@xxxxxxxxxxx>, Hao Wu <wuhaotsh@xxxxxxxxxx>, Radoslaw Biernacki <rad@xxxxxxxxxxxx>, Leif Lindholm <quic_llindhol@xxxxxxxxxxx>, Marcin Juszkiewicz <marcin.juszkiewicz@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Helge Deller <deller@xxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Eduardo Habkost <eduardo@xxxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Song Gao <gaosong@xxxxxxxxxxx>, Thomas Huth <huth@xxxxxxxxxxxxx>, Laurent Vivier <laurent@xxxxxxxxx>, Huacai Chen <chenhuacai@xxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Hervé Poussineau <hpoussin@xxxxxxxxxxx>, Aleksandar Rikalo <aleksandar.rikalo@xxxxxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>, Jason Wang <jasowang@xxxxxxxxxx>, Jia Liu <proljc@xxxxxxxxx>, Stafford Horne <shorne@xxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Daniel Henrique Barboza <danielhb413@xxxxxxxxx>, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, Harsh Prateek Bora <harshpb@xxxxxxxxxxxxx>, Bin Meng <bin.meng@xxxxxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Weiwei Li <liweiwei@xxxxxxxxxxx>, Liu Zhiwei <zhiwei_liu@xxxxxxxxxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Ilya Leoshkevich <iii@xxxxxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Eric Farman <farman@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Magnus Damm <magnus.damm@xxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, qemu-arm@xxxxxxxxxx, qemu-ppc@xxxxxxxxxx, qemu-riscv@xxxxxxxxxx, qemu-s390x@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Sun, 22 Oct 2023 15:53:54 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: David Woodhouse <dwmw@xxxxxxxxxxxx>
Then fetch the MAC that was assigned, if any. And assign one if not,
ensuring that it uses the Apple OUI.
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
hw/m68k/q800.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 1d7cd5ff1c..94e7c0dd60 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -271,6 +271,7 @@ static void q800_machine_init(MachineState *machine)
BusState *adb_bus;
NubusBus *nubus;
DriveInfo *dinfo;
+ MACAddr mac;
uint8_t rng_seed[32];
linux_boot = (kernel_filename != NULL);
@@ -371,13 +372,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 +381,22 @@ 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]);
+ if (qemu_configure_nic_device(dev, TYPE_DP8393X, true, "dp83932")) {
+ gchar *macstr = object_property_get_str(OBJECT(dev));
+ if (macstr) {
+ net_parse_macaddr(mac.a, macstr);
+ g_free(macstr);
+ }
+ }
+ qemu_macaddr_default_if_unset(&mac);
+ mac.a[0] = 0x08;
+ mac.a[1] = 0x00;
+ mac.a[2] = 0x07;
+ qemu_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 +417,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.40.1
|