diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-11-25 18:49:26 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 09:41:34 -0600 |
commit | d7539ab4bf78809202a8fcce292bf2b51594a0e9 (patch) | |
tree | 9b63f03585490e409f1ed1e08debfcbfa143d7b2 /hw | |
parent | e0394b8b5056c429bc9a753845acf7d56d936d6d (diff) |
net: convert xilinx_ethlite to NICState
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xilinx_ethlite.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c index b7129d5dd7..37e33ec011 100644 --- a/hw/xilinx_ethlite.c +++ b/hw/xilinx_ethlite.c @@ -51,7 +51,7 @@ struct xlx_ethlite { SysBusDevice busdev; qemu_irq irq; - VLANClientState *vc; + NICState *nic; NICConf conf; uint32_t c_tx_pingpong; @@ -118,7 +118,7 @@ eth_writel (void *opaque, target_phys_addr_t addr, uint32_t value) D(qemu_log("%s addr=%x val=%x\n", __func__, addr * 4, value)); if ((value & (CTRL_P | CTRL_S)) == CTRL_S) { - qemu_send_packet(s->vc, + qemu_send_packet(&s->nic->nc, (void *) &s->regs[base], s->regs[base + R_TX_LEN0]); D(qemu_log("eth_tx %d\n", s->regs[base + R_TX_LEN0])); @@ -160,17 +160,17 @@ static CPUWriteMemoryFunc * const eth_write[] = { NULL, NULL, ð_writel, }; -static int eth_can_rx(VLANClientState *vc) +static int eth_can_rx(VLANClientState *nc) { - struct xlx_ethlite *s = vc->opaque; + struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque; int r; r = !(s->regs[R_RX_CTRL0] & CTRL_S); return r; } -static ssize_t eth_rx(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t eth_rx(VLANClientState *nc, const uint8_t *buf, size_t size) { - struct xlx_ethlite *s = vc->opaque; + struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque; unsigned int rxbase = s->rxbuf * (0x800 / 4); int i; @@ -201,13 +201,21 @@ static ssize_t eth_rx(VLANClientState *vc, const uint8_t *buf, size_t size) return size; } -static void eth_cleanup(VLANClientState *vc) +static void eth_cleanup(VLANClientState *nc) { - struct xlx_ethlite *s = vc->opaque; + struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque; - s->vc = NULL; + s->nic = NULL; } +static NetClientInfo net_xilinx_ethlite_info = { + .type = NET_CLIENT_TYPE_NIC, + .size = sizeof(NICState), + .can_receive = eth_can_rx, + .receive = eth_rx, + .cleanup = eth_cleanup, +}; + static int xilinx_ethlite_init(SysBusDevice *dev) { struct xlx_ethlite *s = FROM_SYSBUS(typeof (*s), dev); @@ -220,12 +228,9 @@ static int xilinx_ethlite_init(SysBusDevice *dev) sysbus_init_mmio(dev, R_MAX * 4, regs); qemu_macaddr_default_if_unset(&s->conf.macaddr); - 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_rx, eth_rx, NULL, - NULL, eth_cleanup, s); - qemu_format_nic_info_str(s->vc, s->conf.macaddr.a); + s->nic = qemu_new_nic(&net_xilinx_ethlite_info, &s->conf, + dev->qdev.info->name, dev->qdev.id, s); + qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); return 0; } |