From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC0fN-0006LH-0v for qemu-devel@nongnu.org; Mon, 06 Jul 2015 03:18:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC0fH-0008Mw-JJ for qemu-devel@nongnu.org; Mon, 06 Jul 2015 03:18:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC0fH-0008Mr-Dj for qemu-devel@nongnu.org; Mon, 06 Jul 2015 03:18:07 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id AAF228EA48 for ; Mon, 6 Jul 2015 07:18:06 +0000 (UTC) From: Fam Zheng Date: Mon, 6 Jul 2015 15:18:02 +0800 Message-Id: <1436167082-6957-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] dp8393x: Flush packets when link comes up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, Stefan Hajnoczi .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. Signed-off-by: Fam Zheng --- hw/net/dp8393x.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index cd889bc..451ff72 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -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: -- 2.4.3