5544c1b
From a71b6050a88402c3f388b8f13afed51e6ba6f41a Mon Sep 17 00:00:00 2001
5544c1b
From: Paolo Bonzini <pbonzini@redhat.com>
5544c1b
Date: Thu, 9 Aug 2012 16:45:56 +0200
5544c1b
Subject: [PATCH] e1000: flush queue whenever can_receive can go from false to
5544c1b
 true
5544c1b
5544c1b
When the guests replenish the receive ring buffer, the network device
5544c1b
should flush its queue of pending packets.  This is done with
5544c1b
qemu_flush_queued_packets.
5544c1b
5544c1b
e1000's can_receive can go from false to true when RCTL or RDT are
5544c1b
modified.
5544c1b
5544c1b
Reported-by: Luigi Rizzo <rizzo@iet.unipi.it>
5544c1b
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
5544c1b
Cc: Jan Kiszka <jan.kiszka@siemens.de>
5544c1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5544c1b
Reviewed-by: Amos Kong <akong@redhat.com>
5544c1b
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
5544c1b
(cherry picked from commit e8b4c680b41bd960ecccd9ff076b7b058e0afcd4)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 hw/e1000.c | 4 ++++
5544c1b
 1 file changed, 4 insertions(+)
5544c1b
5544c1b
diff --git a/hw/e1000.c b/hw/e1000.c
5544c1b
index ae8a6c5..ec3a7c4 100644
5544c1b
--- a/hw/e1000.c
5544c1b
+++ b/hw/e1000.c
5544c1b
@@ -295,6 +295,7 @@ set_rx_control(E1000State *s, int index, uint32_t val)
5544c1b
     s->rxbuf_min_shift = ((val / E1000_RCTL_RDMTS_QUAT) & 3) + 1;
5544c1b
     DBGOUT(RX, "RCTL: %d, mac_reg[RCTL] = 0x%x\n", s->mac_reg[RDT],
5544c1b
            s->mac_reg[RCTL]);
5544c1b
+    qemu_flush_queued_packets(&s->nic->nc);
5544c1b
 }
5544c1b
 
5544c1b
 static void
5544c1b
@@ -926,6 +927,9 @@ set_rdt(E1000State *s, int index, uint32_t val)
5544c1b
 {
5544c1b
     s->check_rxov = 0;
5544c1b
     s->mac_reg[index] = val & 0xffff;
5544c1b
+    if (e1000_has_rxbufs(s, 1)) {
5544c1b
+        qemu_flush_queued_packets(&s->nic->nc);
5544c1b
+    }
5544c1b
 }
5544c1b
 
5544c1b
 static void