net: convert musicpal to NICState
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
1f30d10a46
commit
3a94dd18ff
@ -151,7 +151,7 @@ typedef struct mv88w8618_eth_state {
|
|||||||
uint32_t rx_queue[4];
|
uint32_t rx_queue[4];
|
||||||
uint32_t frx_queue[4];
|
uint32_t frx_queue[4];
|
||||||
uint32_t cur_rx[4];
|
uint32_t cur_rx[4];
|
||||||
VLANClientState *vc;
|
NICState *nic;
|
||||||
NICConf conf;
|
NICConf conf;
|
||||||
} mv88w8618_eth_state;
|
} mv88w8618_eth_state;
|
||||||
|
|
||||||
@ -175,14 +175,14 @@ static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc)
|
|||||||
le32_to_cpus(&desc->next);
|
le32_to_cpus(&desc->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eth_can_receive(VLANClientState *vc)
|
static int eth_can_receive(VLANClientState *nc)
|
||||||
{
|
{
|
||||||
return 1;
|
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)
|
||||||
{
|
{
|
||||||
mv88w8618_eth_state *s = vc->opaque;
|
mv88w8618_eth_state *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
||||||
uint32_t desc_addr;
|
uint32_t desc_addr;
|
||||||
mv88w8618_rx_desc desc;
|
mv88w8618_rx_desc desc;
|
||||||
int i;
|
int i;
|
||||||
@ -250,7 +250,7 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
|
|||||||
len = desc.bytes;
|
len = desc.bytes;
|
||||||
if (len < 2048) {
|
if (len < 2048) {
|
||||||
cpu_physical_memory_read(desc.buffer, buf, len);
|
cpu_physical_memory_read(desc.buffer, buf, len);
|
||||||
qemu_send_packet(s->vc, buf, len);
|
qemu_send_packet(&s->nic->nc, buf, len);
|
||||||
}
|
}
|
||||||
desc.cmdstat &= ~MP_ETH_TX_OWN;
|
desc.cmdstat &= ~MP_ETH_TX_OWN;
|
||||||
s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
|
s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
|
||||||
@ -365,23 +365,28 @@ static CPUWriteMemoryFunc * const mv88w8618_eth_writefn[] = {
|
|||||||
mv88w8618_eth_write
|
mv88w8618_eth_write
|
||||||
};
|
};
|
||||||
|
|
||||||
static void eth_cleanup(VLANClientState *vc)
|
static void eth_cleanup(VLANClientState *nc)
|
||||||
{
|
{
|
||||||
mv88w8618_eth_state *s = vc->opaque;
|
mv88w8618_eth_state *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
||||||
|
|
||||||
s->vc = NULL;
|
s->nic = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NetClientInfo net_mv88w8618_info = {
|
||||||
|
.type = NET_CLIENT_TYPE_NIC,
|
||||||
|
.size = sizeof(NICState),
|
||||||
|
.can_receive = eth_can_receive,
|
||||||
|
.receive = eth_receive,
|
||||||
|
.cleanup = eth_cleanup,
|
||||||
|
};
|
||||||
|
|
||||||
static int mv88w8618_eth_init(SysBusDevice *dev)
|
static int mv88w8618_eth_init(SysBusDevice *dev)
|
||||||
{
|
{
|
||||||
mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev);
|
mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev);
|
||||||
|
|
||||||
sysbus_init_irq(dev, &s->irq);
|
sysbus_init_irq(dev, &s->irq);
|
||||||
s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC,
|
s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
|
||||||
s->conf.vlan, s->conf.peer,
|
dev->qdev.info->name, dev->qdev.id, s);
|
||||||
dev->qdev.info->name, dev->qdev.id,
|
|
||||||
eth_can_receive, eth_receive, NULL,
|
|
||||||
NULL, eth_cleanup, s);
|
|
||||||
s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn,
|
s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn,
|
||||||
mv88w8618_eth_writefn, s);
|
mv88w8618_eth_writefn, s);
|
||||||
sysbus_init_mmio(dev, MP_ETH_SIZE, s->mmio_index);
|
sysbus_init_mmio(dev, MP_ETH_SIZE, s->mmio_index);
|
||||||
|
Loading…
Reference in New Issue
Block a user