Revision e00e365e
b/hw/eepro100.c | ||
---|---|---|
195 | 195 |
PCIDevice dev; |
196 | 196 |
uint8_t mult[8]; /* multicast mask array */ |
197 | 197 |
int mmio_index; |
198 |
VLANClientState *vc;
|
|
198 |
NICState *nic;
|
|
199 | 199 |
NICConf conf; |
200 | 200 |
uint8_t scb_stat; /* SCB stat/ack byte */ |
201 | 201 |
uint8_t int_stat; /* PCI interrupt status */ |
... | ... | |
868 | 868 |
} |
869 | 869 |
} |
870 | 870 |
TRACE(RXTX, logout("%p sending frame, len=%d,%s\n", s, size, nic_dump(buf, size))); |
871 |
qemu_send_packet(s->vc, buf, size);
|
|
871 |
qemu_send_packet(&s->nic->nc, buf, size);
|
|
872 | 872 |
s->statistics.tx_good_frames++; |
873 | 873 |
/* Transmit with bad status would raise an CX/TNO interrupt. |
874 | 874 |
* (82557 only). Emulation never has bad status. */ |
... | ... | |
1599 | 1599 |
} |
1600 | 1600 |
} |
1601 | 1601 |
|
1602 |
static int nic_can_receive(VLANClientState *vc)
|
|
1602 |
static int nic_can_receive(VLANClientState *nc)
|
|
1603 | 1603 |
{ |
1604 |
EEPRO100State *s = vc->opaque;
|
|
1604 |
EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
|
1605 | 1605 |
TRACE(RXTX, logout("%p\n", s)); |
1606 | 1606 |
return get_ru_state(s) == ru_ready; |
1607 | 1607 |
//~ return !eepro100_buffer_full(s); |
1608 | 1608 |
} |
1609 | 1609 |
|
1610 |
static ssize_t nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
|
|
1610 |
static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size)
|
|
1611 | 1611 |
{ |
1612 | 1612 |
/* TODO: |
1613 | 1613 |
* - Magic packets should set bit 30 in power management driver register. |
1614 | 1614 |
* - Interesting packets should set bit 29 in power management driver register. |
1615 | 1615 |
*/ |
1616 |
EEPRO100State *s = vc->opaque;
|
|
1616 |
EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
|
1617 | 1617 |
uint16_t rfd_status = 0xa000; |
1618 | 1618 |
static const uint8_t broadcast_macaddr[6] = |
1619 | 1619 |
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
... | ... | |
1779 | 1779 |
} |
1780 | 1780 |
}; |
1781 | 1781 |
|
1782 |
static void nic_cleanup(VLANClientState *vc)
|
|
1782 |
static void nic_cleanup(VLANClientState *nc)
|
|
1783 | 1783 |
{ |
1784 |
EEPRO100State *s = vc->opaque;
|
|
1784 |
EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
|
1785 | 1785 |
|
1786 |
s->vc = NULL;
|
|
1786 |
s->nic = NULL;
|
|
1787 | 1787 |
} |
1788 | 1788 |
|
1789 | 1789 |
static int pci_nic_uninit(PCIDevice *pci_dev) |
... | ... | |
1793 | 1793 |
cpu_unregister_io_memory(s->mmio_index); |
1794 | 1794 |
vmstate_unregister(s->vmstate, s); |
1795 | 1795 |
eeprom93xx_free(s->eeprom); |
1796 |
qemu_del_vlan_client(s->vc);
|
|
1796 |
qemu_del_vlan_client(&s->nic->nc);
|
|
1797 | 1797 |
return 0; |
1798 | 1798 |
} |
1799 | 1799 |
|
1800 |
static NetClientInfo net_eepro100_info = { |
|
1801 |
.type = NET_CLIENT_TYPE_NIC, |
|
1802 |
.size = sizeof(NICState), |
|
1803 |
.can_receive = nic_can_receive, |
|
1804 |
.receive = nic_receive, |
|
1805 |
.cleanup = nic_cleanup, |
|
1806 |
}; |
|
1807 |
|
|
1800 | 1808 |
static int nic_init(PCIDevice *pci_dev, uint32_t device) |
1801 | 1809 |
{ |
1802 | 1810 |
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); |
... | ... | |
1829 | 1837 |
|
1830 | 1838 |
nic_reset(s); |
1831 | 1839 |
|
1832 |
s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, |
|
1833 |
s->conf.vlan, s->conf.peer, |
|
1834 |
pci_dev->qdev.info->name, pci_dev->qdev.id, |
|
1835 |
nic_can_receive, nic_receive, NULL, NULL, |
|
1836 |
nic_cleanup, s); |
|
1840 |
s->nic = qemu_new_nic(&net_eepro100_info, &s->conf, |
|
1841 |
pci_dev->qdev.info->name, pci_dev->qdev.id, s); |
|
1837 | 1842 |
|
1838 |
qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
|
|
1839 |
TRACE(OTHER, logout("%s\n", s->vc->info_str));
|
|
1843 |
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
|
|
1844 |
TRACE(OTHER, logout("%s\n", s->nic->nc.info_str));
|
|
1840 | 1845 |
|
1841 | 1846 |
qemu_register_reset(nic_reset, s); |
1842 | 1847 |
|
1843 | 1848 |
s->vmstate = qemu_malloc(sizeof(vmstate_eepro100)); |
1844 | 1849 |
memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100)); |
1845 |
s->vmstate->name = s->vc->model;
|
|
1850 |
s->vmstate->name = s->nic->nc.model;
|
|
1846 | 1851 |
vmstate_register(-1, s->vmstate, s); |
1847 | 1852 |
|
1848 | 1853 |
if (!pci_dev->qdev.hotplugged) { |
1849 | 1854 |
static int loaded = 0; |
1850 | 1855 |
if (!loaded) { |
1851 | 1856 |
char fname[32]; |
1852 |
snprintf(fname, sizeof(fname), "pxe-%s.bin", s->vc->model);
|
|
1857 |
snprintf(fname, sizeof(fname), "pxe-%s.bin", s->nic->nc.model);
|
|
1853 | 1858 |
rom_add_option(fname); |
1854 | 1859 |
loaded = 1; |
1855 | 1860 |
} |
Also available in: Unified diff