From b726cfe451fbc033d94856feaec067620cc151a0 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 9 Dec 2024 11:09:08 +0100 Subject: [PATCH] hw/net: fix opencores_eth driver to consider the MAC address from CLI Part of the fix for https://github.com/espressif/qemu/issues/107 --- hw/net/opencores_eth.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c index ec35e220231b..60b0717c7c3e 100644 --- a/hw/net/opencores_eth.c +++ b/hw/net/opencores_eth.c @@ -359,6 +359,14 @@ static void open_eth_reset(void *opaque) s->regs[TX_BD_NUM] = 0x40; s->regs[MIIMODER] = 0x64; + uint8_t *mac_addr = s->conf.macaddr.a; + SET_REGFIELD(s, MAC_ADDR1, BYTE0, mac_addr[0]); + SET_REGFIELD(s, MAC_ADDR1, BYTE1, mac_addr[1]); + SET_REGFIELD(s, MAC_ADDR0, BYTE2, mac_addr[2]); + SET_REGFIELD(s, MAC_ADDR0, BYTE3, mac_addr[3]); + SET_REGFIELD(s, MAC_ADDR0, BYTE4, mac_addr[4]); + SET_REGFIELD(s, MAC_ADDR0, BYTE5, mac_addr[5]); + s->tx_desc = 0; s->rx_desc = 0x40; @@ -747,9 +755,13 @@ static void sysbus_open_eth_realize(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->irq); + qemu_macaddr_default_if_unset(&s->conf.macaddr); + s->nic = qemu_new_nic(&net_open_eth_info, &s->conf, object_get_typename(OBJECT(s)), dev->id, &dev->mem_reentrancy_guard, s); + + qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); } static void qdev_open_eth_reset(DeviceState *dev)