From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEy3r-0007Cu-Cf for qemu-devel@nongnu.org; Tue, 14 Jul 2015 07:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEy3n-0006jv-7b for qemu-devel@nongnu.org; Tue, 14 Jul 2015 07:07:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEy3n-0006jh-2n for qemu-devel@nongnu.org; Tue, 14 Jul 2015 07:07:39 -0400 Date: Tue, 14 Jul 2015 19:07:34 +0800 From: Fam Zheng Message-ID: <20150714110734.GA22250@ad.nay.redhat.com> References: <1436860421-4604-1-git-send-email-famz@redhat.com> <1436860421-4604-9-git-send-email-famz@redhat.com> <0e59f1d9503695e4d32cb4eb3110b724@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e59f1d9503695e4d32cb4eb3110b724@walle.cc> Subject: Re: [Qemu-devel] [PATCH for-2.4 08/12] milkymist-minimac2: Flush queued packets when link comes up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Walle Cc: Peter Maydell , Peter Crosthwaite , Rob Herring , jasowang@redhat.com, qemu-devel@nongnu.org, Gerd Hoffmann , stefanha@redhat.com, "Edgar E. Iglesias" On Tue, 07/14 13:02, Michael Walle wrote: > Am 2015-07-14 09:53, schrieb Fam Zheng: > >Drop .can_receive and move the semantics into minimac2_rx, by returning > >0. > > > >That is once minimac2_rx returns 0, incoming packets will be queued > >until the queue is explicitly flushed. We do this when s->regs[R_STATE0] > >or s->regs[R_STATE1] is changed in minimac2_write. > > > >Signed-off-by: Fam Zheng > >--- > > hw/net/milkymist-minimac2.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > >diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c > >index f06afaa..cd38a06 100644 > >--- a/hw/net/milkymist-minimac2.c > >+++ b/hw/net/milkymist-minimac2.c > >@@ -303,8 +303,7 @@ static ssize_t minimac2_rx(NetClientState *nc, > >const uint8_t *buf, size_t size) > > r_state = R_STATE1; > > rx_buf = s->rx1_buf; > > } else { > >- trace_milkymist_minimac2_drop_rx_frame(buf); > >- return size; > >+ return 0; > > trace removed? Because the frame is no longer dropped as we return 0 - it is queued and will be sent again when we do qemu_flush_queued_packets later. Should I rename the trace point? Fam > > > } > > > > /* assemble frame */ > >@@ -354,6 +353,7 @@ minimac2_read(void *opaque, hwaddr addr, unsigned > >size) > > return r; > > } > > > >+static int minimac2_can_rx(MilkymistMinimac2State *s); > > static void > > minimac2_write(void *opaque, hwaddr addr, uint64_t value, > > unsigned size) > >@@ -387,6 +387,9 @@ minimac2_write(void *opaque, hwaddr addr, uint64_t > >value, > > case R_STATE1: > > s->regs[addr] = value; > > update_rx_interrupt(s); > >+ if (minimac2_can_rx(s)) { > >+ qemu_flush_queued_packets(qemu_get_queue(s->nic)); > >+ } > > break; > > case R_SETUP: > > case R_COUNT0: > >@@ -411,10 +414,8 @@ static const MemoryRegionOps minimac2_ops = { > > .endianness = DEVICE_NATIVE_ENDIAN, > > }; > > > >-static int minimac2_can_rx(NetClientState *nc) > >+static int minimac2_can_rx(MilkymistMinimac2State *s) > > { > >- MilkymistMinimac2State *s = qemu_get_nic_opaque(nc); > >- > > if (s->regs[R_STATE0] == STATE_LOADED) { > > return 1; > > } > > please move this above the minimac2_write call, so the forward declaration > isn't necessary anymore. > > > > -michael >