[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 25/44] net: convert etrax to NICState
From: |
Mark McLoughlin |
Subject: |
[Qemu-devel] [PATCH 25/44] net: convert etrax to NICState |
Date: |
Wed, 25 Nov 2009 18:49:18 +0000 |
Signed-off-by: Mark McLoughlin <address@hidden>
---
hw/etraxfs_eth.c | 45 +++++++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 2cc2332..dedd107 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -319,7 +319,8 @@ static void mdio_cycle(struct qemu_mdio *bus)
struct fs_eth
{
- VLANClientState *vc;
+ NICState *nic;
+ NICConf conf;
int ethregs;
/* Two addrs in the filter. */
@@ -495,15 +496,15 @@ static int eth_match_groupaddr(struct fs_eth *eth, const
unsigned char *sa)
return match;
}
-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)
{
unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
- struct fs_eth *eth = vc->opaque;
+ struct fs_eth *eth = DO_UPCAST(NICState, nc, nc)->opaque;
int use_ma0 = eth->regs[RW_REC_CTRL] & 1;
int use_ma1 = eth->regs[RW_REC_CTRL] & 2;
int r_bcast = eth->regs[RW_REC_CTRL] & 8;
@@ -533,15 +534,15 @@ static int eth_tx_push(void *opaque, unsigned char *buf,
int len)
struct fs_eth *eth = opaque;
D(printf("%s buf=%p len=%d\n", __func__, buf, len));
- qemu_send_packet(eth->vc, buf, len);
+ qemu_send_packet(ð->nic->nc, buf, len);
return len;
}
-static void eth_set_link(VLANClientState *vc)
+static void eth_set_link(VLANClientState *nc)
{
- struct fs_eth *eth = vc->opaque;
- D(printf("%s %d\n", __func__, vc->link_down));
- eth->phy.link = !vc->link_down;
+ struct fs_eth *eth = DO_UPCAST(NICState, nc, nc)->opaque;
+ D(printf("%s %d\n", __func__, nc->link_down));
+ eth->phy.link = !nc->link_down;
}
static CPUReadMemoryFunc * const eth_read[] = {
@@ -554,9 +555,9 @@ static CPUWriteMemoryFunc * const eth_write[] = {
ð_writel,
};
-static void eth_cleanup(VLANClientState *vc)
+static void eth_cleanup(VLANClientState *nc)
{
- struct fs_eth *eth = vc->opaque;
+ struct fs_eth *eth = DO_UPCAST(NICState, nc, nc)->opaque;
cpu_unregister_io_memory(eth->ethregs);
@@ -564,6 +565,15 @@ static void eth_cleanup(VLANClientState *vc)
qemu_free(eth);
}
+static NetClientInfo net_etraxfs_info = {
+ .type = NET_CLIENT_TYPE_NIC,
+ .size = sizeof(NICState),
+ .can_receive = eth_can_receive,
+ .receive = eth_receive,
+ .cleanup = eth_cleanup,
+ .link_status_changed = eth_set_link,
+};
+
void *etraxfs_eth_init(NICInfo *nd, target_phys_addr_t base, int phyaddr)
{
struct etraxfs_dma_client *dma = NULL;
@@ -590,13 +600,12 @@ void *etraxfs_eth_init(NICInfo *nd, target_phys_addr_t
base, int phyaddr)
eth->ethregs = cpu_register_io_memory(eth_read, eth_write, eth);
cpu_register_physical_memory (base, 0x5c, eth->ethregs);
- eth->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC,
- nd->vlan, nd->netdev,
- nd->model, nd->name,
- eth_can_receive, eth_receive,
- NULL, NULL, eth_cleanup, eth);
- eth->vc->opaque = eth;
- eth->vc->link_status_changed = eth_set_link;
+ memcpy(eth->conf.macaddr.a, nd->macaddr, sizeof(nd->macaddr));
+ eth->conf.vlan = nd->vlan;
+ eth->conf.peer = nd->netdev;
+
+ eth->nic = qemu_new_nic(&net_etraxfs_info, ð->conf,
+ nd->model, nd->name, eth);
return dma;
}
--
1.6.5.2
- [Qemu-devel] [PATCH 39/44] net: fix qemu_announce_self(), (continued)
- [Qemu-devel] [PATCH 39/44] net: fix qemu_announce_self(), Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 41/44] net: fix TAP networking on host kernels without IFF_VNET_HDR support, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 14/44] net: convert vde to NetClientInfo, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 33/44] net: convert xilinx_ethlite to NICState, Mark McLoughlin, 2009/11/25
- [Qemu-devel] [PATCH 36/44] net: remove qemu_new_vlan_client(), Mark McLoughlin, 2009/11/25
- [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 <=
- [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, 2009/11/25
- [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