Revision 1673ad51
b/hw/rtl8139.c | ||
---|---|---|
459 | 459 |
uint16_t CpCmd; |
460 | 460 |
uint8_t TxThresh; |
461 | 461 |
|
462 |
VLANClientState *vc;
|
|
462 |
NICState *nic;
|
|
463 | 463 |
NICConf conf; |
464 | 464 |
int rtl8139_mmio_io_addr; |
465 | 465 |
|
... | ... | |
785 | 785 |
#endif |
786 | 786 |
} |
787 | 787 |
|
788 |
static int rtl8139_can_receive(VLANClientState *vc)
|
|
788 |
static int rtl8139_can_receive(VLANClientState *nc)
|
|
789 | 789 |
{ |
790 |
RTL8139State *s = vc->opaque;
|
|
790 |
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
|
791 | 791 |
int avail; |
792 | 792 |
|
793 | 793 |
/* Receive (drop) packets if card is disabled. */ |
... | ... | |
807 | 807 |
} |
808 | 808 |
} |
809 | 809 |
|
810 |
static ssize_t rtl8139_do_receive(VLANClientState *vc, const uint8_t *buf, size_t size_, int do_interrupt)
|
|
810 |
static ssize_t rtl8139_do_receive(VLANClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
|
|
811 | 811 |
{ |
812 |
RTL8139State *s = vc->opaque;
|
|
812 |
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
|
813 | 813 |
int size = size_; |
814 | 814 |
|
815 | 815 |
uint32_t packet_header = 0; |
... | ... | |
1156 | 1156 |
return size_; |
1157 | 1157 |
} |
1158 | 1158 |
|
1159 |
static ssize_t rtl8139_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
|
1159 |
static ssize_t rtl8139_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
|
|
1160 | 1160 |
{ |
1161 |
return rtl8139_do_receive(vc, buf, size, 1);
|
|
1161 |
return rtl8139_do_receive(nc, buf, size, 1);
|
|
1162 | 1162 |
} |
1163 | 1163 |
|
1164 | 1164 |
static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize) |
... | ... | |
1744 | 1744 |
if (TxLoopBack == (s->TxConfig & TxLoopBack)) |
1745 | 1745 |
{ |
1746 | 1746 |
DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n")); |
1747 |
rtl8139_do_receive(s->vc, buf, size, do_interrupt);
|
|
1747 |
rtl8139_do_receive(&s->nic->nc, buf, size, do_interrupt);
|
|
1748 | 1748 |
} |
1749 | 1749 |
else |
1750 | 1750 |
{ |
1751 |
qemu_send_packet(s->vc, buf, size);
|
|
1751 |
qemu_send_packet(&s->nic->nc, buf, size);
|
|
1752 | 1752 |
} |
1753 | 1753 |
} |
1754 | 1754 |
|
... | ... | |
3280 | 3280 |
} |
3281 | 3281 |
#endif /* RTL8139_ONBOARD_TIMER */ |
3282 | 3282 |
|
3283 |
static void rtl8139_cleanup(VLANClientState *vc)
|
|
3283 |
static void rtl8139_cleanup(VLANClientState *nc)
|
|
3284 | 3284 |
{ |
3285 |
RTL8139State *s = vc->opaque;
|
|
3285 |
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
|
3286 | 3286 |
|
3287 |
s->vc = NULL;
|
|
3287 |
s->nic = NULL;
|
|
3288 | 3288 |
} |
3289 | 3289 |
|
3290 | 3290 |
static int pci_rtl8139_uninit(PCIDevice *dev) |
... | ... | |
3301 | 3301 |
qemu_free_timer(s->timer); |
3302 | 3302 |
#endif |
3303 | 3303 |
vmstate_unregister(&vmstate_rtl8139, s); |
3304 |
qemu_del_vlan_client(s->vc);
|
|
3304 |
qemu_del_vlan_client(&s->nic->nc);
|
|
3305 | 3305 |
return 0; |
3306 | 3306 |
} |
3307 | 3307 |
|
3308 |
static NetClientInfo net_rtl8139_info = { |
|
3309 |
.type = NET_CLIENT_TYPE_NIC, |
|
3310 |
.size = sizeof(NICState), |
|
3311 |
.can_receive = rtl8139_can_receive, |
|
3312 |
.receive = rtl8139_receive, |
|
3313 |
.cleanup = rtl8139_cleanup, |
|
3314 |
}; |
|
3315 |
|
|
3308 | 3316 |
static int pci_rtl8139_init(PCIDevice *dev) |
3309 | 3317 |
{ |
3310 | 3318 |
RTL8139State * s = DO_UPCAST(RTL8139State, dev, dev); |
... | ... | |
3332 | 3340 |
|
3333 | 3341 |
qemu_macaddr_default_if_unset(&s->conf.macaddr); |
3334 | 3342 |
|
3335 |
s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, |
|
3336 |
s->conf.vlan, s->conf.peer, |
|
3337 |
dev->qdev.info->name, dev->qdev.id, |
|
3338 |
rtl8139_can_receive, rtl8139_receive, NULL, |
|
3339 |
NULL, rtl8139_cleanup, s); |
|
3340 |
qemu_format_nic_info_str(s->vc, s->conf.macaddr.a); |
|
3343 |
s->nic = qemu_new_nic(&net_rtl8139_info, &s->conf, |
|
3344 |
dev->qdev.info->name, dev->qdev.id, s); |
|
3345 |
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); |
|
3341 | 3346 |
|
3342 | 3347 |
s->cplus_txbuffer = NULL; |
3343 | 3348 |
s->cplus_txbuffer_len = 0; |
Also available in: Unified diff