aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-11-01 11:13:59 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-11-01 11:13:59 -0500
commitd971919f08ca300e7b3595a4c5ddaea2ce8fc3ba (patch)
tree4bef68afad713ada32f674e232b496fc62dca073
parent5a34dbb55994ddb8e3f4cc465abbb85aa2e6dfaf (diff)
parent372254c6e5c078fb13b236bb648d2b9b2b0c70f1 (diff)
Merge remote-tracking branch 'stefanha/net' into staging
* stefanha/net: e1000: pre-initialize RAH/RAL registers net: Reject non-netdevs in qmp_netdev_del() net: use "socket" model name for UDP sockets e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--hw/e1000.c17
-rw-r--r--net.c9
-rw-r--r--net/socket.c2
3 files changed, 21 insertions, 7 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index e4f1ffef74..cb7e7e8366 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -92,7 +92,6 @@ typedef struct E1000State_st {
uint32_t rxbuf_size;
uint32_t rxbuf_min_shift;
- int check_rxov;
struct e1000_tx {
unsigned char header[256];
unsigned char vlan_header[4];
@@ -266,6 +265,8 @@ rxbufsize(uint32_t v)
static void e1000_reset(void *opaque)
{
E1000State *d = opaque;
+ uint8_t *macaddr = d->conf.macaddr.a;
+ int i;
qemu_del_timer(d->autoneg_timer);
memset(d->phy_reg, 0, sizeof d->phy_reg);
@@ -278,6 +279,14 @@ static void e1000_reset(void *opaque)
if (d->nic->nc.link_down) {
e1000_link_down(d);
}
+
+ /* Some guests expect pre-initialized RAH/RAL (AddrValid flag + MACaddr) */
+ d->mac_reg[RA] = 0;
+ d->mac_reg[RA + 1] = E1000_RAH_AV;
+ for (i = 0; i < 4; i++) {
+ d->mac_reg[RA] |= macaddr[i] << (8 * i);
+ d->mac_reg[RA + 1] |= (i < 2) ? macaddr[i + 4] << (8 * i) : 0;
+ }
}
static void
@@ -741,11 +750,11 @@ static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
int bufs;
/* Fast-path short packets */
if (total_size <= s->rxbuf_size) {
- return s->mac_reg[RDH] != s->mac_reg[RDT] || !s->check_rxov;
+ return s->mac_reg[RDH] != s->mac_reg[RDT];
}
if (s->mac_reg[RDH] < s->mac_reg[RDT]) {
bufs = s->mac_reg[RDT] - s->mac_reg[RDH];
- } else if (s->mac_reg[RDH] > s->mac_reg[RDT] || !s->check_rxov) {
+ } else if (s->mac_reg[RDH] > s->mac_reg[RDT]) {
bufs = s->mac_reg[RDLEN] / sizeof(struct e1000_rx_desc) +
s->mac_reg[RDT] - s->mac_reg[RDH];
} else {
@@ -848,7 +857,6 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
- s->check_rxov = 1;
/* see comment in start_xmit; same here */
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
@@ -925,7 +933,6 @@ mac_writereg(E1000State *s, int index, uint32_t val)
static void
set_rdt(E1000State *s, int index, uint32_t val)
{
- s->check_rxov = 0;
s->mac_reg[index] = val & 0xffff;
if (e1000_has_rxbufs(s, 1)) {
qemu_flush_queued_packets(&s->nic->nc);
diff --git a/net.c b/net.c
index ae4bc0d431..e8ae13e283 100644
--- a/net.c
+++ b/net.c
@@ -827,6 +827,7 @@ exit_err:
void qmp_netdev_del(const char *id, Error **errp)
{
NetClientState *nc;
+ QemuOpts *opts;
nc = qemu_find_netdev(id);
if (!nc) {
@@ -834,8 +835,14 @@ void qmp_netdev_del(const char *id, Error **errp)
return;
}
+ opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), id);
+ if (!opts) {
+ error_setg(errp, "Device '%s' is not a netdev", id);
+ return;
+ }
+
qemu_del_net_client(nc);
- qemu_opts_del(qemu_opts_find(qemu_find_opts_err("netdev", errp), id));
+ qemu_opts_del(opts);
}
void print_net_client(Monitor *mon, NetClientState *nc)
diff --git a/net/socket.c b/net/socket.c
index b75d567695..c01323d4b0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -747,7 +747,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name,
error_report("localaddr= is mandatory with udp=");
return -1;
}
- if (net_socket_udp_init(peer, "udp", name, sock->udp, sock->localaddr) ==
+ if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) ==
-1) {
return -1;
}