qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] net: cadence_gem: clear RX control descriptor
@ 2019-07-16 10:59 Ramon Fried
  2019-07-16 11:58 ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Ramon Fried @ 2019-07-16 10:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, jasowang, alistair, open list:Xilinx Zynq,
	Ramon Fried, edgar.iglesias, Philippe Mathieu-Daudé

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 ecee22525c..cca3ce7f56 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -406,6 +406,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;
@@ -993,6 +998,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.22.0



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

* Re: [Qemu-devel] [PATCH v2] net: cadence_gem: clear RX control descriptor
  2019-07-16 10:59 [Qemu-devel] [PATCH v2] net: cadence_gem: clear RX control descriptor Ramon Fried
@ 2019-07-16 11:58 ` Jason Wang
  2020-04-13 17:55   ` Ramon Fried
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2019-07-16 11:58 UTC (permalink / raw)
  To: Ramon Fried, qemu-devel
  Cc: edgar.iglesias, alistair, Philippe Mathieu-Daudé,
	open list:Xilinx Zynq, peter.maydell


On 2019/7/16 下午6:59, 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>
>
> ---
> 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 ecee22525c..cca3ce7f56 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -406,6 +406,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;
> @@ -993,6 +998,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]);


Applied.

Thanks



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

* Re: [PATCH v2] net: cadence_gem: clear RX control descriptor
  2019-07-16 11:58 ` Jason Wang
@ 2020-04-13 17:55   ` Ramon Fried
  0 siblings, 0 replies; 3+ messages in thread
From: Ramon Fried @ 2020-04-13 17:55 UTC (permalink / raw)
  To: Jason Wang
  Cc: Peter Maydell, Alistair Francis, qemu-devel,
	open list:Xilinx Zynq, Edgar E. Iglesias,
	Philippe Mathieu-Daudé

Hi.
Just noticed that this patch didn't hit master.
Got lost ?

Thanks,
Ramon.

On Tue, Jul 16, 2019 at 2:58 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2019/7/16 下午6:59, 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>
> >
> > ---
> > 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 ecee22525c..cca3ce7f56 100644
> > --- a/hw/net/cadence_gem.c
> > +++ b/hw/net/cadence_gem.c
> > @@ -406,6 +406,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;
> > @@ -993,6 +998,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]);
>
>
> Applied.
>
> Thanks
>


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

end of thread, other threads:[~2020-04-13 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-16 10:59 [Qemu-devel] [PATCH v2] net: cadence_gem: clear RX control descriptor Ramon Fried
2019-07-16 11:58 ` Jason Wang
2020-04-13 17:55   ` Ramon Fried

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).