Read and write the MAC address in the config space byte by byte

This commit is contained in:
Bryan Venteicher 2014-01-25 07:13:47 +00:00
parent 8c457c885e
commit 1dbb21dcc9

View File

@ -3485,6 +3485,7 @@ static void
vtnet_set_hwaddr(struct vtnet_softc *sc)
{
device_t dev;
int i;
dev = sc->vtnet_dev;
@ -3492,9 +3493,11 @@ vtnet_set_hwaddr(struct vtnet_softc *sc)
if (vtnet_ctrl_mac_cmd(sc, sc->vtnet_hwaddr) != 0)
device_printf(dev, "unable to set MAC address\n");
} else if (sc->vtnet_flags & VTNET_FLAG_MAC) {
virtio_write_device_config(dev,
offsetof(struct virtio_net_config, mac),
sc->vtnet_hwaddr, ETHER_ADDR_LEN);
for (i = 0; i < ETHER_ADDR_LEN; i++) {
virtio_write_dev_config_1(dev,
offsetof(struct virtio_net_config, mac) + i,
sc->vtnet_hwaddr[i]);
}
}
}
@ -3502,6 +3505,7 @@ static void
vtnet_get_hwaddr(struct vtnet_softc *sc)
{
device_t dev;
int i;
dev = sc->vtnet_dev;
@ -3519,8 +3523,10 @@ vtnet_get_hwaddr(struct vtnet_softc *sc)
return;
}
virtio_read_device_config(dev, offsetof(struct virtio_net_config, mac),
sc->vtnet_hwaddr, ETHER_ADDR_LEN);
for (i = 0; i < ETHER_ADDR_LEN; i++) {
sc->vtnet_hwaddr[i] = virtio_read_dev_config_1(dev,
offsetof(struct virtio_net_config, mac) + i);
}
}
static void