diff mbox

[2/2] e1000: decrement RDT if equal to RDH

Message ID 1398460630-31557-3-git-send-email-rich.tollerton@ni.com
State New
Headers show

Commit Message

Richard Tollerton April 25, 2014, 9:17 p.m. UTC
Some drivers set RDT=RDH. Oddly, this works on real hardware. To work
around this, autodecrement RDT when this happens.

Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
---
 hw/net/e1000.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index c3c612c..11148db 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1116,6 +1116,12 @@  mac_writereg(E1000State *s, int index, uint32_t val)
 static void
 set_rdt(E1000State *s, int index, uint32_t val)
 {
+    if (val == s->mac_reg[RDH]) {     /* Decrement RDT if it's too big */
+        if (val == 0) {
+            val = s->mac_reg[RDLEN] / sizeof(struct e1000_rx_desc);
+        }
+        val--;
+    }
     s->mac_reg[index] = val & 0xffff;
     if (e1000_has_rxbufs(s, 1)) {
         qemu_flush_queued_packets(qemu_get_queue(s->nic));