diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-11-25 18:49:22 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 09:41:33 -0600 |
commit | 3a94dd18ff2d01296ebdfe7c781bea9724bab209 (patch) | |
tree | d8a265d9e477aae40dcb81805293b2bc5c3f303a /hw/musicpal.c | |
parent | 1f30d10a46697fd329eb6ad2d80a3366f120ddf9 (diff) | |
download | qemu-3a94dd18ff2d01296ebdfe7c781bea9724bab209.zip qemu-3a94dd18ff2d01296ebdfe7c781bea9724bab209.tar.gz qemu-3a94dd18ff2d01296ebdfe7c781bea9724bab209.tar.bz2 |
net: convert musicpal to NICState
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/musicpal.c')
-rw-r--r-- | hw/musicpal.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/hw/musicpal.c b/hw/musicpal.c index 264669f..4a33e28 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -151,7 +151,7 @@ typedef struct mv88w8618_eth_state { uint32_t rx_queue[4]; uint32_t frx_queue[4]; uint32_t cur_rx[4]; - VLANClientState *vc; + NICState *nic; NICConf conf; } mv88w8618_eth_state; @@ -175,14 +175,14 @@ static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc) le32_to_cpus(&desc->next); } -static int eth_can_receive(VLANClientState *vc) +static int eth_can_receive(VLANClientState *nc) { return 1; } -static ssize_t eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t eth_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { - mv88w8618_eth_state *s = vc->opaque; + mv88w8618_eth_state *s = DO_UPCAST(NICState, nc, nc)->opaque; uint32_t desc_addr; mv88w8618_rx_desc desc; int i; @@ -250,7 +250,7 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index) len = desc.bytes; if (len < 2048) { cpu_physical_memory_read(desc.buffer, buf, len); - qemu_send_packet(s->vc, buf, len); + qemu_send_packet(&s->nic->nc, buf, len); } desc.cmdstat &= ~MP_ETH_TX_OWN; s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index); @@ -365,23 +365,28 @@ static CPUWriteMemoryFunc * const mv88w8618_eth_writefn[] = { mv88w8618_eth_write }; -static void eth_cleanup(VLANClientState *vc) +static void eth_cleanup(VLANClientState *nc) { - mv88w8618_eth_state *s = vc->opaque; + mv88w8618_eth_state *s = DO_UPCAST(NICState, nc, nc)->opaque; - s->vc = NULL; + s->nic = NULL; } +static NetClientInfo net_mv88w8618_info = { + .type = NET_CLIENT_TYPE_NIC, + .size = sizeof(NICState), + .can_receive = eth_can_receive, + .receive = eth_receive, + .cleanup = eth_cleanup, +}; + static int mv88w8618_eth_init(SysBusDevice *dev) { mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev); sysbus_init_irq(dev, &s->irq); - s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, - s->conf.vlan, s->conf.peer, - dev->qdev.info->name, dev->qdev.id, - eth_can_receive, eth_receive, NULL, - NULL, eth_cleanup, s); + s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf, + dev->qdev.info->name, dev->qdev.id, s); s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); sysbus_init_mmio(dev, MP_ETH_SIZE, s->mmio_index); |