qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend v2] net: cadence_gem: clear RX control descriptor
@ 2020-04-18  8:51 Ramon Fried
  2020-04-18  9:10 ` Edgar E. Iglesias
  2020-04-20  9:05 ` Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Ramon Fried @ 2020-04-18  8:51 UTC (permalink / raw)
  To: edgar.iglesias, alistair, peter.maydell, jasowang, qemu-arm
  Cc: Philippe Mathieu-Daudé, Ramon Fried, qemu-devel

The RX ring descriptors control field is used for setting
SOF and EOF (start of frame and end of frame).
The SOF and EOF weren't cleared from the previous descriptors,
causing inconsistencies in ring buffer.
Fix that by clearing the control field of every descriptors we're
processing.

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

---
v2:
  * change function name to rx_desc_clear_control as proposed by
      Jason Wang
  * Move the function call above the comment, as proposed by
    Philippe Mathieu-Daudé

 hw/net/cadence_gem.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index b7b7985bf2..22a0b1b1f9 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -411,6 +411,11 @@ static inline void rx_desc_set_sof(uint32_t *desc)
     desc[1] |= DESC_1_RX_SOF;
 }
 
+static inline void rx_desc_clear_control(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
 static inline void rx_desc_set_eof(uint32_t *desc)
 {
     desc[1] |= DESC_1_RX_EOF;
@@ -999,6 +1004,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         rxbuf_ptr += MIN(bytes_to_copy, rxbufsize);
         bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
+        rx_desc_clear_control(s->rx_desc[q]);
+
         /* Update the descriptor.  */
         if (first_desc) {
             rx_desc_set_sof(s->rx_desc[q]);
-- 
2.26.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH resend v2] net: cadence_gem: clear RX control descriptor
  2020-04-18  8:51 [PATCH resend v2] net: cadence_gem: clear RX control descriptor Ramon Fried
@ 2020-04-18  9:10 ` Edgar E. Iglesias
  2020-04-20  9:05 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Edgar E. Iglesias @ 2020-04-18  9:10 UTC (permalink / raw)
  To: Ramon Fried
  Cc: peter.maydell, jasowang, alistair, qemu-devel, qemu-arm,
	Philippe Mathieu-Daudé

On Sat, Apr 18, 2020 at 11:51:45AM +0300, Ramon Fried wrote:
> The RX ring descriptors control field is used for setting
> SOF and EOF (start of frame and end of frame).
> The SOF and EOF weren't cleared from the previous descriptors,
> causing inconsistencies in ring buffer.
> Fix that by clearing the control field of every descriptors we're
> processing.
> 
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> ---
> v2:
>   * change function name to rx_desc_clear_control as proposed by
>       Jason Wang
>   * Move the function call above the comment, as proposed by
>     Philippe Mathieu-Daudé
> 
>  hw/net/cadence_gem.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index b7b7985bf2..22a0b1b1f9 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -411,6 +411,11 @@ static inline void rx_desc_set_sof(uint32_t *desc)
>      desc[1] |= DESC_1_RX_SOF;
>  }
>  
> +static inline void rx_desc_clear_control(uint32_t *desc)
> +{
> +    desc[1]  = 0;
> +}
> +
>  static inline void rx_desc_set_eof(uint32_t *desc)
>  {
>      desc[1] |= DESC_1_RX_EOF;
> @@ -999,6 +1004,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
>          rxbuf_ptr += MIN(bytes_to_copy, rxbufsize);
>          bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
>  
> +        rx_desc_clear_control(s->rx_desc[q]);
> +
>          /* Update the descriptor.  */
>          if (first_desc) {
>              rx_desc_set_sof(s->rx_desc[q]);
> -- 
> 2.26.0
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH resend v2] net: cadence_gem: clear RX control descriptor
  2020-04-18  8:51 [PATCH resend v2] net: cadence_gem: clear RX control descriptor Ramon Fried
  2020-04-18  9:10 ` Edgar E. Iglesias
@ 2020-04-20  9:05 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2020-04-20  9:05 UTC (permalink / raw)
  To: Ramon Fried
  Cc: Jason Wang, Alistair Francis, QEMU Developers, qemu-arm,
	Edgar E. Iglesias, Philippe Mathieu-Daudé

On Sat, 18 Apr 2020 at 09:52, Ramon Fried <rfried.dev@gmail.com> wrote:
>
> The RX ring descriptors control field is used for setting
> SOF and EOF (start of frame and end of frame).
> The SOF and EOF weren't cleared from the previous descriptors,
> causing inconsistencies in ring buffer.
> Fix that by clearing the control field of every descriptors we're
> processing.
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



Applied to target-arm.next for 5.1, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-20  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-18  8:51 [PATCH resend v2] net: cadence_gem: clear RX control descriptor Ramon Fried
2020-04-18  9:10 ` Edgar E. Iglesias
2020-04-20  9:05 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).