#include <zlib.h>
#include "hw.h"
-#include "pci.h"
-#include "dma.h"
-#include "qemu-timer.h"
-#include "net.h"
+#include "pci/pci.h"
+#include "sysemu/dma.h"
+#include "qemu/timer.h"
+#include "net/net.h"
#include "loader.h"
-#include "sysemu.h"
-#include "iov.h"
+#include "sysemu/sysemu.h"
+#include "qemu/iov.h"
/* debug RTL8139 card */
//#define DEBUG_RTL8139 1
static int rtl8139_can_receive(NetClientState *nc)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
int avail;
/* Receive (drop) packets if card is disabled. */
static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
/* size is the length of the buffer passed to the driver */
int size = size_;
const uint8_t *dot1q_buf = NULL;
s->BasicModeStatus = 0x7809;
//s->BasicModeStatus |= 0x0040; /* UTP medium */
s->BasicModeStatus |= 0x0020; /* autonegotiation completed */
- s->BasicModeStatus |= 0x0004; /* link is up */
+ /* preserve link state */
+ s->BasicModeStatus |= qemu_get_queue(s->nic)->link_down ? 0 : 0x04;
s->NWayAdvert = 0x05e1; /* all modes, full duplex */
s->NWayLPAR = 0x05e1; /* all modes, full duplex */
}
DPRINTF("+++ transmit loopback mode\n");
- rtl8139_do_receive(&s->nic->nc, buf, size, do_interrupt);
+ rtl8139_do_receive(qemu_get_queue(s->nic), buf, size, do_interrupt);
if (iov) {
g_free(buf2);
else
{
if (iov) {
- qemu_sendv_packet(&s->nic->nc, iov, 3);
+ qemu_sendv_packet(qemu_get_queue(s->nic), iov, 3);
} else {
- qemu_send_packet(&s->nic->nc, buf, size);
+ qemu_send_packet(qemu_get_queue(s->nic), buf, size);
}
}
}
/* nc.link_down can't be migrated, so infer link_down according
* to link status bit in BasicModeStatus */
- s->nic->nc.link_down = (s->BasicModeStatus & 0x04) == 0;
+ qemu_get_queue(s->nic)->link_down = (s->BasicModeStatus & 0x04) == 0;
return 0;
}
static void rtl8139_cleanup(NetClientState *nc)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
}
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
- qemu_del_net_client(&s->nic->nc);
+ qemu_del_nic(s->nic);
}
static void rtl8139_set_link_status(NetClientState *nc)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
if (nc->link_down) {
s->BasicModeStatus &= ~0x04;
s->nic = qemu_new_nic(&net_rtl8139_info, &s->conf,
object_get_typename(OBJECT(dev)), dev->qdev.id, s);
- qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
+ qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
s->cplus_txbuffer = NULL;
s->cplus_txbuffer_len = 0;
dc->props = rtl8139_properties;
}
-static TypeInfo rtl8139_info = {
+static const TypeInfo rtl8139_info = {
.name = "rtl8139",
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(RTL8139State),