e1000: flush packets when link comes up
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 25 Jun 2015 09:18:05 +0000 (10:18 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 7 Jul 2015 12:10:26 +0000 (13:10 +0100)
e1000_can_receive() checks the link up status register bit.  If the bit
is clear, packets will be queued and the peer may disable receive to
avoid wasting CPU reading packets that cannot be delivered.  The queue
must be flushed once the link comes back up again.

This patch fixes broken e1000 receive with Mac OS X Snow Leopard guests
and tap networking.  Flushing the queue invokes the async send callback,
which re-enables tap fd read.

Reported-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 1435223885-12745-1-git-send-email-stefanha@redhat.com

hw/net/e1000.c

index bab8e2abfb361f6a226aee1cc3d78aa6e96db96e..5c6bcd001491f6a50ebe09394e66b37026af5fc3 100644 (file)
@@ -185,6 +185,9 @@ e1000_link_up(E1000State *s)
 {
     s->mac_reg[STATUS] |= E1000_STATUS_LU;
     s->phy_reg[PHY_STATUS] |= MII_SR_LINK_STATUS;
+
+    /* E1000_STATUS_LU is tested by e1000_can_receive() */
+    qemu_flush_queued_packets(qemu_get_queue(s->nic));
 }
 
 static bool