diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-11-25 18:49:12 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 09:41:31 -0600 |
commit | a03e2aec9643981a9fc10206262b170e005d0b31 (patch) | |
tree | a0872832fabc1af456a2565a942838e8b3a24f46 | |
parent | eb6b6c121add5f708a920a68361099a8fa1ac45c (diff) |
net: convert e1000 to NICState
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/e1000.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/hw/e1000.c b/hw/e1000.c index 00f6a57da1..683fdccae3 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -75,7 +75,7 @@ enum { typedef struct E1000State_st { PCIDevice dev; - VLANClientState *vc; + NICState *nic; NICConf conf; int mmio_index; @@ -385,9 +385,9 @@ xmit_seg(E1000State *s) if (tp->vlan_needed) { memmove(tp->vlan, tp->data, 12); memcpy(tp->data + 8, tp->vlan_header, 4); - qemu_send_packet(s->vc, tp->vlan, tp->size + 4); + qemu_send_packet(&s->nic->nc, tp->vlan, tp->size + 4); } else - qemu_send_packet(s->vc, tp->data, tp->size); + qemu_send_packet(&s->nic->nc, tp->data, tp->size); s->mac_reg[TPT]++; s->mac_reg[GPTC]++; n = s->mac_reg[TOTL]; @@ -590,12 +590,12 @@ receive_filter(E1000State *s, const uint8_t *buf, int size) } static void -e1000_set_link_status(VLANClientState *vc) +e1000_set_link_status(VLANClientState *nc) { - E1000State *s = vc->opaque; + E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; uint32_t old_status = s->mac_reg[STATUS]; - if (vc->link_down) + if (nc->link_down) s->mac_reg[STATUS] &= ~E1000_STATUS_LU; else s->mac_reg[STATUS] |= E1000_STATUS_LU; @@ -605,17 +605,17 @@ e1000_set_link_status(VLANClientState *vc) } static int -e1000_can_receive(VLANClientState *vc) +e1000_can_receive(VLANClientState *nc) { - E1000State *s = vc->opaque; + E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; return (s->mac_reg[RCTL] & E1000_RCTL_EN); } static ssize_t -e1000_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { - E1000State *s = vc->opaque; + E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; struct e1000_rx_desc desc; target_phys_addr_t base; unsigned int n, rdt; @@ -1037,11 +1037,11 @@ e1000_mmio_map(PCIDevice *pci_dev, int region_num, } static void -e1000_cleanup(VLANClientState *vc) +e1000_cleanup(VLANClientState *nc) { - E1000State *d = vc->opaque; + E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; - d->vc = NULL; + s->nic = NULL; } static int @@ -1050,7 +1050,7 @@ pci_e1000_uninit(PCIDevice *dev) E1000State *d = DO_UPCAST(E1000State, dev, dev); cpu_unregister_io_memory(d->mmio_index); - qemu_del_vlan_client(d->vc); + qemu_del_vlan_client(&d->nic->nc); vmstate_unregister(&vmstate_e1000, d); return 0; } @@ -1067,6 +1067,15 @@ static void e1000_reset(void *opaque) memset(&d->tx, 0, sizeof d->tx); } +static NetClientInfo net_e1000_info = { + .type = NET_CLIENT_TYPE_NIC, + .size = sizeof(NICState), + .can_receive = e1000_can_receive, + .receive = e1000_receive, + .cleanup = e1000_cleanup, + .link_status_changed = e1000_set_link_status, +}; + static int pci_e1000_init(PCIDevice *pci_dev) { E1000State *d = DO_UPCAST(E1000State, dev, pci_dev); @@ -1107,14 +1116,10 @@ static int pci_e1000_init(PCIDevice *pci_dev) checksum = (uint16_t) EEPROM_SUM - checksum; d->eeprom_data[EEPROM_CHECKSUM_REG] = checksum; - d->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, - d->conf.vlan, d->conf.peer, - d->dev.qdev.info->name, d->dev.qdev.id, - e1000_can_receive, e1000_receive, NULL, - NULL, e1000_cleanup, d); - d->vc->link_status_changed = e1000_set_link_status; + d->nic = qemu_new_nic(&net_e1000_info, &d->conf, + d->dev.qdev.info->name, d->dev.qdev.id, d); - qemu_format_nic_info_str(d->vc, macaddr); + qemu_format_nic_info_str(&d->nic->nc, macaddr); vmstate_register(-1, &vmstate_e1000, d); |