Skip to contentSkip to conversation

qemu:e1000: Fix RX descriptor low threshold interrupt logic

PATCH RESEND Applied Alex Williamson 2 participants 2 messages Mar 19, 2009 – Mar 20, 2009

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 qemu:e1000: Fix RX descriptor low threshold interrupt logic

The RXDMT0 interrupt is supposed to fire when the number of free RX descriptors drops to some fraction of the total descriptors. However in practice, it seems like we're adding this interrupt cause on every RX. Fix the logic to treat (tail - head) as the number of free entries rather than the number of used entries.

---

 hw/e1000.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/e1000.c +2 -2
index e6155d6..1644201 100644
@@ -666,8 +666,8 @@ e1000_receive(void *opaque, const uint8_t *buf, int size)
     n = E1000_ICS_RXT0;
     if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
         rdt += s->mac_reg[RDLEN] / sizeof(desc);
-    if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) << s->rxbuf_min_shift >=
-        s->mac_reg[RDLEN])
+    if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
+        s->rxbuf_min_shift)
         n |= E1000_ICS_RXDMT0;
 
     set_ics(s, 0, n);
#1 lore raw
Quoted 8 lines · Alex Williamson

The RXDMT0 interrupt is supposed to fire when the number of free RX descriptors drops to some fraction of the total descriptors. However in practice, it seems like we're adding this interrupt cause on every RX. Fix the logic to treat (tail - head) as the number of free entries rather than the number of used entries.

Applied to trunk and stable, thanks.

Regards,

Anthony Liguori

Quoted 25 lines

---

 hw/e1000.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/e1000.c +2 -2
index e6155d6..1644201 100644
@@ -666,8 +666,8 @@ e1000_receive(void *opaque, const uint8_t *buf, int size)
     n = E1000_ICS_RXT0;
     if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
         rdt += s->mac_reg[RDLEN] / sizeof(desc);
-    if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) << s->rxbuf_min_shift >=
-        s->mac_reg[RDLEN])
+    if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
+        s->rxbuf_min_shift)
         n |= E1000_ICS_RXDMT0;
 
     set_ics(s, 0, n);