Skip to contentSkip to conversation

dp8393x: Flush packets when link comes up

PATCH New Fam Zheng 1 participant 1 message Jul 6, 2015

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 dp8393x: Flush packets when link comes up

.can_receive callback changes semantics that once return 0, backend will try sending again until explicitly flushed, change the device to meet that.

dp8393x_can_receive checks SONIC_CR_RXEN bit in SONIC_CR register and SONIC_ISR_RBE bit in SONIC_ISR register, try flushing the queue when either bit is being updated.

---
 hw/net/dp8393x.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/net/dp8393x.c +8 -0
index cd889bc..451ff72 100644
@@ -327,9 +327,14 @@ static void dp8393x_do_stop_timer(dp8393xState *s)
     dp8393x_update_wt_regs(s);
 }
 
+static int dp8393x_can_receive(NetClientState *nc);
+
 static void dp8393x_do_receiver_enable(dp8393xState *s)
 {
     s->regs[SONIC_CR] &= ~SONIC_CR_RXDIS;
+    if (dp8393x_can_receive(s->nic->ncs)) {
+        qemu_flush_queued_packets(qemu_get_queue(s->nic));
+    }
 }
 
 static void dp8393x_do_receiver_disable(dp8393xState *s)
@@ -569,6 +574,9 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data,
                 dp8393x_do_read_rra(s);
             }
             dp8393x_update_irq(s);
+            if (dp8393x_can_receive(s->nic->ncs)) {
+                qemu_flush_queued_packets(qemu_get_queue(s->nic));
+            }
             break;
         /* Ignore least significant bit */
         case SONIC_RSA:
Signature · 1 line
2.4.3