Skip to content

Commit

Permalink
hw/net: fix opencores_eth driver to consider the MAC address from CLI
Browse files Browse the repository at this point in the history
Part of the fix for #107
  • Loading branch information
igrr committed Dec 9, 2024
1 parent 1311d7b commit b726cfe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hw/net/opencores_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b726cfe

Please sign in to comment.