diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2016-02-01 11:18:03 +0530 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-02-08 16:40:39 +1100 |
commit | aa9566d2ed5c4fdcaa385759475c75bb0d0801d4 (patch) | |
tree | daa8fa79c2720690ed98fc8b2ca7281729ffde61 /lib | |
parent | 31312dcf4430c372318ed56ba5a9006fc6546d8d (diff) | |
download | SLOF-aa9566d2ed5c4fdcaa385759475c75bb0d0801d4.zip SLOF-aa9566d2ed5c4fdcaa385759475c75bb0d0801d4.tar.gz SLOF-aa9566d2ed5c4fdcaa385759475c75bb0d0801d4.tar.bz2 |
virtio-net: move setup-mac to the open routine
MAC reading should be done after the initialization of the device after
the features negotiation.
Adjust the open routine accordingly. There is no point in sending the
mac address to the virtionet_open. Change the signature. Also read the
mac address directly from the config space to remove the dependency of
getting the mac address from the open routine.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libvirtio/virtio-net.c | 7 | ||||
-rw-r--r-- | lib/libvirtio/virtio-net.h | 2 | ||||
-rw-r--r-- | lib/libvirtio/virtio.code | 8 |
3 files changed, 8 insertions, 9 deletions
diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c index 83a99db..f8b8cec 100644 --- a/lib/libvirtio/virtio-net.c +++ b/lib/libvirtio/virtio-net.c @@ -157,7 +157,9 @@ static int virtionet_init(net_driver_t *driver) virtio_queue_notify(&virtiodev, VQ_RX); driver->running = 1; - + for(i = 0; i < (int)sizeof(driver->mac_addr); i++) { + driver->mac_addr[i] = virtio_get_config(&virtiodev, i, 1); + } return 0; dev_error: @@ -284,7 +286,7 @@ static int virtionet_receive(char *buf, int maxlen) return len; } -net_driver_t *virtionet_open(char *mac_addr, int len, struct virtio_device *dev) +net_driver_t *virtionet_open(struct virtio_device *dev) { net_driver_t *driver; @@ -294,7 +296,6 @@ net_driver_t *virtionet_open(char *mac_addr, int len, struct virtio_device *dev) return NULL; } - memcpy(driver->mac_addr, mac_addr, 6); driver->running = 0; if (virtionet_init_pci(dev)) diff --git a/lib/libvirtio/virtio-net.h b/lib/libvirtio/virtio-net.h index 2196f87..195afd4 100644 --- a/lib/libvirtio/virtio-net.h +++ b/lib/libvirtio/virtio-net.h @@ -23,7 +23,7 @@ enum { VQ_TX = 1, /* Transmit Queue */ }; -extern net_driver_t *virtionet_open(char *mac_addr, int len, struct virtio_device *dev); +extern net_driver_t *virtionet_open(struct virtio_device *dev); extern void virtionet_close(net_driver_t *driver); extern int virtionet_read(char *buf, int len); extern int virtionet_write(char *buf, int len); diff --git a/lib/libvirtio/virtio.code b/lib/libvirtio/virtio.code index 9e6c475..0c22ecc 100644 --- a/lib/libvirtio/virtio.code +++ b/lib/libvirtio/virtio.code @@ -122,14 +122,12 @@ MIRP /******** virtio-net ********/ -// : virtio-net-open ( mac-addr-str len dev -- false | [ driver true ] ) +// : virtio-net-open ( dev -- false | [ driver true ] ) PRIM(virtio_X2d_net_X2d_open) { - void *dev = TOS.a; POP; - int len = TOS.u; POP; - char *mac_addr = TOS.a; + void *dev = TOS.a; - net_driver_t *net_driver = virtionet_open(mac_addr, len, dev); + net_driver_t *net_driver = virtionet_open(dev); if (net_driver) { TOS.u = (unsigned long)net_driver; PUSH; |