[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/44] net: convert e1000 to NICState
From: |
Mark McLoughlin |
Subject: |
[Qemu-devel] [PATCH 19/44] net: convert e1000 to NICState |
Date: |
Wed, 25 Nov 2009 18:49:12 +0000 |
Signed-off-by: Mark McLoughlin <address@hidden>
---
hw/e1000.c | 47 ++++++++++++++++++++++++++---------------------
1 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/hw/e1000.c b/hw/e1000.c
index 00f6a57..683fdcc 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);
--
1.6.5.2
- [Qemu-devel] [PATCH 38/44] net: add qemu_foreach_nic(), (continued)
- [Qemu-devel] [PATCH 38/44] net: add qemu_foreach_nic(), Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 40/44] net: print correct error for '-netdev ""', Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 32/44] net: convert usb-net to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 43/44] net: initialize vnet_hdr in net_init_tap(), Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 42/44] net: check for TUNSETOFFLOAD support before trying to enable offload features, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 25/44] net: convert etrax to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 27/44] net: convert mcf_fec to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 37/44] net: remove VLANClientState members now in NetClientInfo, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 23/44] net: convert eepro100 to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 30/44] net: convert smc91c111 to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 19/44] net: convert e1000 to NICState,
Mark McLoughlin <=
- [Qemu-devel] [PATCH 20/44] net: convert rtl8139 to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 15/44] net: convert socket to NetClientInfo, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 18/44] net: convert virtio to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 08/44] net: introduce NetClientInfo, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 24/44] net: convert dp8393x to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 16/44] net: convert dump to NetClientInfo, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 29/44] net: convert musicpal to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 44/44] net: fix vnet_hdr handling in solaris tap code, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 31/44] net: convert stellaris to NICState, Mark McLoughlin, 2009/11/25