From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEwq3-0007rL-CP for qemu-devel@nongnu.org; Tue, 14 Jul 2015 05:49:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEwq2-0006bA-Ar for qemu-devel@nongnu.org; Tue, 14 Jul 2015 05:49:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEwq2-0006av-35 for qemu-devel@nongnu.org; Tue, 14 Jul 2015 05:49:22 -0400 Date: Tue, 14 Jul 2015 17:49:19 +0800 From: Fam Zheng Message-ID: <20150714094919.GE27873@ad.nay.redhat.com> References: <1436860421-4604-1-git-send-email-famz@redhat.com> <1436860421-4604-6-git-send-email-famz@redhat.com> <55A4D6A6.4000303@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55A4D6A6.4000303@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.4 05/12] etsec: Move etsec_can_receive into etsec_receive List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: Peter Maydell , Peter Crosthwaite , Rob Herring , qemu-devel@nongnu.org, Michael Walle , Gerd Hoffmann , stefanha@redhat.com, "Edgar E. Iglesias" On Tue, 07/14 17:30, Jason Wang wrote: > > > On 07/14/2015 03:53 PM, Fam Zheng wrote: > > When etsec_reset returns 0, peer would queue the packet as if > > .can_receive returns false. Drop etsec_can_receive and let etsec_receive > > carry the semantics. > > > > Signed-off-by: Fam Zheng > > --- > > hw/net/fsl_etsec/etsec.c | 11 +---------- > > hw/net/fsl_etsec/etsec.h | 2 +- > > hw/net/fsl_etsec/rings.c | 14 ++++++++------ > > 3 files changed, 10 insertions(+), 17 deletions(-) > > > > diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c > > index c57365f..f5170ae 100644 > > --- a/hw/net/fsl_etsec/etsec.c > > +++ b/hw/net/fsl_etsec/etsec.c > > @@ -338,13 +338,6 @@ static void etsec_reset(DeviceState *d) > > MII_SR_100X_FD_CAPS | MII_SR_100T4_CAPS; > > } > > > > -static int etsec_can_receive(NetClientState *nc) > > -{ > > - eTSEC *etsec = qemu_get_nic_opaque(nc); > > - > > - return etsec->rx_buffer_len == 0; > > -} > > - > > static ssize_t etsec_receive(NetClientState *nc, > > const uint8_t *buf, > > size_t size) > > @@ -355,8 +348,7 @@ static ssize_t etsec_receive(NetClientState *nc, > > fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size); > > qemu_hexdump(buf, stderr, "", size); > > #endif > > - etsec_rx_ring_write(etsec, buf, size); > > - return size; > > + return etsec_rx_ring_write(etsec, buf, size); > > } > > > > > > @@ -370,7 +362,6 @@ static void etsec_set_link_status(NetClientState *nc) > > static NetClientInfo net_etsec_info = { > > .type = NET_CLIENT_OPTIONS_KIND_NIC, > > .size = sizeof(NICState), > > - .can_receive = etsec_can_receive, > > .receive = etsec_receive, > > .link_status_changed = etsec_set_link_status, > > }; > > diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h > > index 78d2c57..fc41773 100644 > > --- a/hw/net/fsl_etsec/etsec.h > > +++ b/hw/net/fsl_etsec/etsec.h > > @@ -162,7 +162,7 @@ DeviceState *etsec_create(hwaddr base, > > > > void etsec_walk_tx_ring(eTSEC *etsec, int ring_nbr); > > void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr); > > -void etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size); > > +ssize_t etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size); > > > > void etsec_write_miim(eTSEC *etsec, > > eTSEC_Register *reg, > > diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c > > index d4a494f..a11280b 100644 > > --- a/hw/net/fsl_etsec/rings.c > > +++ b/hw/net/fsl_etsec/rings.c > > @@ -481,40 +481,42 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t *buf, size_t size) > > etsec->rx_buffer_len, etsec->rx_padding); > > } > > > > -void etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size) > > +ssize_t etsec_rx_ring_write(eTSEC *etsec, const uint8_t *buf, size_t size) > > { > > int ring_nbr = 0; /* Always use ring0 (no filer) */ > > > > if (etsec->rx_buffer_len != 0) { > > RING_DEBUG("%s: We can't receive now," > > " a buffer is already in the pipe\n", __func__); > > - return; > > + return 0; > > Is queue be flushed when rx buffer is available again? Previously not, and it's fixed in patch 6. Fam