Skip to contentSkip to conversation

Net patches

GIT PULL New Stefan Hajnoczi 2 participants 6 messages Nov 1, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 286d52ebfc0d0d53c2a878e454292fea14bad41b:

target-mips: don't flush extra TLB on permissions upgrade (2012-10-31 22:20:49 +0100)

are available in the git repository at:

git://github.com/stefanha/qemu.git net

for you to fetch changes up to 372254c6e5c078fb13b236bb648d2b9b2b0c70f1:

e1000: pre-initialize RAH/RAL registers (2012-11-01 12:02:17 +0100)

----------------------------------------------------------------
Dmitry Fleytman (1):

      e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty

Gabriel L. Somlo (1):
e1000: pre-initialize RAH/RAL registers

Lei Li (1):
net: use "socket" model name for UDP sockets

Stefan Hajnoczi (1):
net: Reject non-netdevs in qmp_netdev_del()

 hw/e1000.c   | 17 ++++++++++++-----
 net.c        |  9 ++++++++-
 net/socket.c |  2 +-
 3 files changed, 21 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.12.1
#1 lore raw

PATCH 1/4 e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty

From: Dmitry Fleytman <[email protected]>

Real HW always treats RX ring with RDH == RDT as empty. Emulation is supposed to behave the same.

---
 hw/e1000.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/e1000.c +2 -5
index e4f1ffe..ec32f59 100644
@@ -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];
@@ -741,11 +740,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 +847,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 +923,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);
Signature · 1 line
1.7.12.1
#2 lore raw

PATCH 2/4 net: use "socket" model name for UDP sockets

In reply to Stefan Hajnoczi

From: Lei Li <[email protected]>

Fix the problem that can not delete the udp socket. It's caused by passing "udp" model to net_socket_udp_init, but we do not have "udp" model in our model list. Pass the right model "socket" to init function.

https://bugs.launchpad.net/qemu/+bug/1073585?comments=all

---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/socket.c +1 -1
index b75d567..c01323d 100644
@@ -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;
     }
Signature · 1 line
1.7.12.1
#3 lore raw

PATCH 3/4 net: Reject non-netdevs in qmp_netdev_del()

In reply to Stefan Hajnoczi

The netdev_del command crashes when given a -net device, because it calls qemu_opts_del(NULL).

Check that this is a -netdev before attempting to delete it and the QemuOpts.

Note the subtle change from qemu_find_opts_err("netdev", errp) to qemu_find_opts_err("netdev", NULL). Since "netdev" is a built in options group and we don't check for NULL return anyway, there's no use in passing errp here.

---
 net.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net.c +8 -1
index ae4bc0d..e8ae13e 100644
@@ -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)
Signature · 1 line
1.7.12.1
#4 lore raw

PATCH 4/4 e1000: pre-initialize RAH/RAL registers

In reply to Stefan Hajnoczi

From: "Gabriel L. Somlo" <[email protected]>

Some guest operating systems' drivers (Mac OS X in particular) fail to properly initialize the Receive Address registers (probably expecting them to be pre-initialized by an earlier component, such as a specific proprietary BIOS). This patch pre-initializes the RA registers, allowing OS X networking to function properly. Other guest operating systems are not affected, and free to (re)initialize these registers during boot.

[According to the datasheet the Address Valid bits in the RA registers are cleared on PCI or software reset. This patch adds the NIC's MAC address and sets Address Valid on reset. So we diverge from real hardware behavior here. -- Stefan]

---
 hw/e1000.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/e1000.c +10 -0
index ec32f59..cb7e7e8 100644
@@ -265,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);
@@ -277,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
Signature · 1 line
1.7.12.1
#5 lore raw
In reply to Stefan Hajnoczi
Quoted 16 lines · Stefan Hajnoczi

The following changes since commit 286d52ebfc0d0d53c2a878e454292fea14bad41b:

target-mips: don't flush extra TLB on permissions upgrade (2012-10-31 22:20:49 +0100)

are available in the git repository at:

git://github.com/stefanha/qemu.git net

for you to fetch changes up to 372254c6e5c078fb13b236bb648d2b9b2b0c70f1:

e1000: pre-initialize RAH/RAL registers (2012-11-01 12:02:17 +0100)

----------------------------------------------------------------
Dmitry Fleytman (1):

      e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty
Quoted 9 lines

Gabriel L. Somlo (1):
e1000: pre-initialize RAH/RAL registers

Lei Li (1):
net: use "socket" model name for UDP sockets

Stefan Hajnoczi (1):
net: Reject non-netdevs in qmp_netdev_del()

Pulled. Thanks.

Regards,

Anthony Liguori

Quoted 7 lines
 hw/e1000.c   | 17 ++++++++++++-----
 net.c        |  9 ++++++++-
 net/socket.c |  2 +-
 3 files changed, 21 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.12.1