summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-01-08 10:36:13 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2013-01-08 10:36:13 -0600
commitc3dd94b129e222e00a4ed00689e11afdd85c740f (patch)
treeb189ff27f0ce3ae57887515fb5b4f9d6eea1127f
parentda1a4cef9e125a866f4ef9a39b342c2913727f70 (diff)
parent83f58e570f21c3e7227e7fbef1fc0e18b5ed7ea9 (diff)
downloadfocaccia-qemu-c3dd94b129e222e00a4ed00689e11afdd85c740f.tar.gz
focaccia-qemu-c3dd94b129e222e00a4ed00689e11afdd85c740f.zip
Merge remote-tracking branch 'stefanha/net' into staging
* stefanha/net:
  rtl8139: preserve link state across device reset
  e1000: no need auto-negotiation if link was down
  net: clean up network at qemu process termination
  e1000: Discard oversized packets based on SBP|LPE

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--hw/e1000.c12
-rw-r--r--hw/rtl8139.c3
-rw-r--r--vl.c4
3 files changed, 15 insertions, 4 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 92fb00a89f..0f177ff844 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -61,6 +61,8 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
 
 /* this is the size past which hardware will drop packets when setting LPE=0 */
 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+/* this is the size past which hardware will drop packets when setting LPE=1 */
+#define MAXIMUM_ETHERNET_LPE_SIZE 16384
 
 /*
  * HW models:
@@ -164,6 +166,11 @@ static void
 set_phy_ctrl(E1000State *s, int index, uint16_t val)
 {
     if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
+        /* no need auto-negotiation if link was down */
+        if (s->nic->nc.link_down) {
+            s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
+            return;
+        }
         s->nic->nc.link_down = true;
         e1000_link_down(s);
         s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;
@@ -809,8 +816,9 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
     }
 
     /* Discard oversized packets if !LPE and !SBP. */
-    if (size > MAXIMUM_ETHERNET_VLAN_SIZE
-        && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+    if ((size > MAXIMUM_ETHERNET_LPE_SIZE ||
+        (size > MAXIMUM_ETHERNET_VLAN_SIZE
+        && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)))
         && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
         return size;
     }
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index c59ec6b6df..3e080621f6 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1258,7 +1258,8 @@ static void rtl8139_reset(DeviceState *d)
     s->BasicModeStatus  = 0x7809;
     //s->BasicModeStatus |= 0x0040; /* UTP medium */
     s->BasicModeStatus |= 0x0020; /* autonegotiation completed */
-    s->BasicModeStatus |= 0x0004; /* link is up */
+    /* preserve link state */
+    s->BasicModeStatus |= s->nic->nc.link_down ? 0 : 0x04;
 
     s->NWayAdvert    = 0x05e1; /* all modes, full duplex */
     s->NWayLPAR      = 0x05e1; /* all modes, full duplex */
diff --git a/vl.c b/vl.c
index f056c95807..79e5122393 100644
--- a/vl.c
+++ b/vl.c
@@ -3762,6 +3762,9 @@ int main(int argc, char **argv, char **envp)
     }
     configure_icount(icount_option);
 
+    /* clean up network at qemu process termination */
+    atexit(&net_cleanup);
+
     if (net_init_clients() < 0) {
         exit(1);
     }
@@ -4014,7 +4017,6 @@ int main(int argc, char **argv, char **envp)
     main_loop();
     bdrv_close_all();
     pause_all_vcpus();
-    net_cleanup();
     res_free();
 
     return 0;