diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-11-25 18:49:21 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 09:41:33 -0600 |
commit | 1f30d10a46697fd329eb6ad2d80a3366f120ddf9 (patch) | |
tree | 9f30e291602abba22b6001080f960580528b5191 /hw/mipsnet.c | |
parent | 1cc49d95a1b74382ad425c76c9e14b84e18ba881 (diff) | |
download | qemu-1f30d10a46697fd329eb6ad2d80a3366f120ddf9.zip qemu-1f30d10a46697fd329eb6ad2d80a3366f120ddf9.tar.gz qemu-1f30d10a46697fd329eb6ad2d80a3366f120ddf9.tar.bz2 |
net: convert mipsnet to NICState
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/mipsnet.c')
-rw-r--r-- | hw/mipsnet.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/hw/mipsnet.c b/hw/mipsnet.c index 67160a4..a066f63 100644 --- a/hw/mipsnet.c +++ b/hw/mipsnet.c @@ -35,7 +35,8 @@ typedef struct MIPSnetState { uint8_t tx_buffer[MAX_ETH_FRAME_SIZE]; int io_base; qemu_irq irq; - VLANClientState *vc; + NICState *nic; + NICConf conf; } MIPSnetState; static void mipsnet_reset(MIPSnetState *s) @@ -66,23 +67,23 @@ static int mipsnet_buffer_full(MIPSnetState *s) return 0; } -static int mipsnet_can_receive(VLANClientState *vc) +static int mipsnet_can_receive(VLANClientState *nc) { - MIPSnetState *s = vc->opaque; + MIPSnetState *s = DO_UPCAST(NICState, nc, nc)->opaque; if (s->busy) return 0; return !mipsnet_buffer_full(s); } -static ssize_t mipsnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t mipsnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { - MIPSnetState *s = vc->opaque; + MIPSnetState *s = DO_UPCAST(NICState, nc, nc)->opaque; #ifdef DEBUG_MIPSNET_RECEIVE printf("mipsnet: receiving len=%d\n", size); #endif - if (!mipsnet_can_receive(vc)) + if (!mipsnet_can_receive(nc)) return -1; s->busy = 1; @@ -183,7 +184,7 @@ static void mipsnet_ioport_write(void *opaque, uint32_t addr, uint32_t val) #ifdef DEBUG_MIPSNET_SEND printf("mipsnet: sending len=%d\n", s->tx_count); #endif - qemu_send_packet(s->vc, s->tx_buffer, s->tx_count); + qemu_send_packet(&s->nic->nc, s->tx_buffer, s->tx_count); s->tx_count = s->tx_written = 0; s->intctl |= MIPSNET_INTCTL_TXDONE; s->busy = 1; @@ -234,9 +235,9 @@ static int mipsnet_load(QEMUFile *f, void *opaque, int version_id) return 0; } -static void mipsnet_cleanup(VLANClientState *vc) +static void mipsnet_cleanup(VLANClientState *nc) { - MIPSnetState *s = vc->opaque; + MIPSnetState *s = DO_UPCAST(NICState, nc, nc)->opaque; unregister_savevm("mipsnet", s); @@ -245,6 +246,14 @@ static void mipsnet_cleanup(VLANClientState *vc) qemu_free(s); } +static NetClientInfo net_mipsnet_info = { + .type = NET_CLIENT_TYPE_NIC, + .size = sizeof(NICState), + .can_receive = mipsnet_can_receive, + .receive = mipsnet_receive, + .cleanup = mipsnet_cleanup, +}; + void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) { MIPSnetState *s; @@ -262,17 +271,17 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) s->io_base = base; s->irq = irq; + if (nd) { - s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, - nd->vlan, nd->netdev, - nd->model, nd->name, - mipsnet_can_receive, mipsnet_receive, - NULL, NULL, mipsnet_cleanup, s); - } else { - s->vc = NULL; - } + memcpy(s->conf.macaddr.a, nd->macaddr, sizeof(nd->macaddr)); + s->conf.vlan = nd->vlan; + s->conf.peer = nd->netdev; - qemu_format_nic_info_str(s->vc, nd->macaddr); + s->nic = qemu_new_nic(&net_mipsnet_info, &s->conf, + nd->model, nd->name, s); + + qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); + } mipsnet_reset(s); register_savevm("mipsnet", 0, 0, mipsnet_save, mipsnet_load, s); |