All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	Rob Herring <robh@kernel.org>, Michael Walle <michael@walle.cc>,
	Gerd Hoffmann <kraxel@redhat.com>,
	stefanha@redhat.com,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [Qemu-devel] [PATCH for-2.4 05/12] etsec: Move etsec_can_receive into etsec_receive
Date: Tue, 14 Jul 2015 17:30:14 +0800	[thread overview]
Message-ID: <55A4D6A6.4000303@redhat.com> (raw)
In-Reply-To: <1436860421-4604-6-git-send-email-famz@redhat.com>



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 <famz@redhat.com>
> ---
>  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?

>      }
>  
>      if (etsec->regs[RSTAT].value & 1 << (23 - ring_nbr)) {
>          RING_DEBUG("%s: The ring is halted\n", __func__);
> -        return;
> +        return -1;
>      }
>  
>      if (etsec->regs[DMACTRL].value & DMACTRL_GRS) {
>          RING_DEBUG("%s: Graceful receive stop\n", __func__);
> -        return;
> +        return -1;
>      }
>  
>      if (!(etsec->regs[MACCFG1].value & MACCFG1_RX_EN)) {
>          RING_DEBUG("%s: MAC Receive not enabled\n", __func__);
> -        return;
> +        return -1;
>      }
>  
>      if ((etsec->regs[RCTRL].value & RCTRL_RSF) && (size < 60)) {
>          /* CRC is not in the packet yet, so short frame is below 60 bytes */
>          RING_DEBUG("%s: Drop short frame\n", __func__);
> -        return;
> +        return -1;
>      }
>  
>      rx_init_frame(etsec, buf, size);
>  
>      etsec_walk_rx_ring(etsec, ring_nbr);
> +
> +    return size;
>  }
>  
>  void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr)

  reply	other threads:[~2015-07-14  9:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14  7:53 [Qemu-devel] [PATCH for-2.4 00/12] hw/net: Fix .can_receive() for NICs Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 01/12] xgmac: Drop packets with eth_can_rx is false Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 02/12] pcnet: Drop pcnet_can_receive Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 03/12] eepro100: Drop nic_can_receive Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 04/12] usbnet: Drop usbnet_can_receive Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 05/12] etsec: Move etsec_can_receive into etsec_receive Fam Zheng
2015-07-14  9:30   ` Jason Wang [this message]
2015-07-14  9:49     ` Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 06/12] etsec: Flush queue when rx buffer is consumed Fam Zheng
2015-07-14  9:33   ` Jason Wang
2015-07-14  9:48     ` Fam Zheng
2015-07-15  5:10       ` Jason Wang
2015-07-15  6:01         ` Fam Zheng
2015-07-15  7:38           ` Jason Wang
2015-07-15  8:04             ` Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 07/12] mcf_fec: Drop mcf_fec_can_receive Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 08/12] milkymist-minimac2: Flush queued packets when link comes up Fam Zheng
2015-07-14 11:02   ` Michael Walle
2015-07-14 11:07     ` Fam Zheng
2015-07-15  7:50       ` Michael Walle
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 09/12] mipsnet: Flush queued packets when receiving is enabled Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 10/12] stellaris_enet: Flush queued packets when read done Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 11/12] dp8393x: Flush packets when link comes up Fam Zheng
2015-07-14  7:53 ` [Qemu-devel] [PATCH for-2.4 12/12] axienet: Flush queued packets when rx is done Fam Zheng
2015-07-14  8:34 ` [Qemu-devel] [PATCH for-2.4 00/12] hw/net: Fix .can_receive() for NICs Wen Congyang
2015-07-15  8:50   ` Stefan Hajnoczi
2015-07-14 14:40 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A4D6A6.4000303@redhat.com \
    --to=jasowang@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=famz@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=michael@walle.cc \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=robh@kernel.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.