Skip to contentSkip to conversation

net: cadence_gem: clear RX control descriptor

PATCH Superseded Ramon Fried 3 participants 6 messages Jun 15, 2019 – Jul 16, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: cadence_gem: clear RX control descriptor

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.

---
 hw/net/cadence_gem.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/net/cadence_gem.c +7 -0
index ecee22525c..d83a82bdb0 100644
@@ -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(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
 static inline void rx_desc_set_eof(uint32_t *desc)
 {
     desc[1] |= DESC_1_RX_EOF;
@@ -994,6 +999,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
         /* Update the descriptor.  */
+        rx_desc_clear(s->rx_desc[q]);
+
         if (first_desc) {
             rx_desc_set_sof(s->rx_desc[q]);
             first_desc = false;
Signature · 1 line
2.21.0
#1 lore raw

ping

Quoted 41 lines · Ramon Fried

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.

---
 hw/net/cadence_gem.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/net/cadence_gem.c +7 -1
index ecee22525c..d83a82bdb0 100644
@@ -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(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
 static inline void rx_desc_set_eof(uint32_t *desc)
 {
     desc[1] |= DESC_1_RX_EOF;
@@ -994,6 +999,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
         /* Update the descriptor.  */
+        rx_desc_clear(s->rx_desc[q]);
+
         if (first_desc) {
             rx_desc_set_sof(s->rx_desc[q]);
             first_desc = false;
--

2.21.0

#2 lore raw
Quoted 35 lines · Ramon Fried

ping

Quoted 32 lines · Ramon Fried

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.

---
 hw/net/cadence_gem.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/net/cadence_gem.c +5 -0
index ecee22525c..d83a82bdb0 100644
@@ -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(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
 static inline void rx_desc_set_eof(uint32_t *desc)
 {
     desc[1] |= DESC_1_RX_EOF;
@@ -994,6 +999,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
Quoted 2 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 1002

Quoted 2 lines
hw/net/cadence_gem.c +1 -0
         /* Update the descriptor.  */
+        rx_desc_clear(s->rx_desc[q]);

Maybe move the call before the comment, regardless:

Quoted 7 lines
Quoted 7 lines
hw/net/cadence_gem.c +1 -1
+
         if (first_desc) {
             rx_desc_set_sof(s->rx_desc[q]);
             first_desc = false;
--

2.21.0

#4 lore raw
In reply to Ramon Fried
Quoted 17 lines · Ramon Fried

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.

---
  hw/net/cadence_gem.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/net/cadence_gem.c +0 -0
index ecee22525c..d83a82bdb0 100644

hw/net/cadence_gem.c static inline void rx_desc_set_sof(uint32_t *desc) · line 409

Quoted 4 lines
hw/net/cadence_gem.c +1 -0
@@ -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(uint32_t *desc)

Nit: is this better to name this as "rx_desc_clear_control()" ?

Thanks

Quoted 16 lines
hw/net/cadence_gem.c +6 -0
+{
+    desc[1]  = 0;
+}
+
  static inline void rx_desc_set_eof(uint32_t *desc)
  {
      desc[1] |= DESC_1_RX_EOF;
@@ -994,6 +999,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
          bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
          /* Update the descriptor.  */
+        rx_desc_clear(s->rx_desc[q]);
+
          if (first_desc) {
              rx_desc_set_sof(s->rx_desc[q]);
              first_desc = false;
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 35 lines · Ramon Fried

ping

Quoted 32 lines · Ramon Fried

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.

---
 hw/net/cadence_gem.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/net/cadence_gem.c +5 -0
index ecee22525c..d83a82bdb0 100644
@@ -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(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
 static inline void rx_desc_set_eof(uint32_t *desc)
 {
     desc[1] |= DESC_1_RX_EOF;
@@ -994,6 +999,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
Quoted 4 lines
Quoted 2 lines

hw/net/cadence_gem.c static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) · line 1002

Quoted 2 lines
hw/net/cadence_gem.c +1 -0
         /* Update the descriptor.  */
+        rx_desc_clear(s->rx_desc[q]);

Maybe move the call before the comment, regardless:

Make sense, sent v2.

Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
hw/net/cadence_gem.c +1 -1
+
         if (first_desc) {
             rx_desc_set_sof(s->rx_desc[q]);
             first_desc = false;
--

2.21.0

#5 lore raw
In reply to Jason Wang
Quoted 23 lines · Jason Wang
Quoted 20 lines · Ramon Fried

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.

---
  hw/net/cadence_gem.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/net/cadence_gem.c +0 -0
index ecee22525c..d83a82bdb0 100644
@@ -406,6 +406,11 @@ static inline void rx_desc_set_sof(uint32_t *desc)
      desc[1] |= DESC_1_RX_SOF;
  }
 
Quoted 4 lines

hw/net/cadence_gem.c static inline void rx_desc_set_sof(uint32_t *desc) · line 409

Quoted 1 line
hw/net/cadence_gem.c +1 -0
+static inline void rx_desc_clear(uint32_t *desc)

Nit: is this better to name this as "rx_desc_clear_control()" ?

I agree, sent v2.

Quoted 23 lines

Thanks

Quoted 16 lines
hw/net/cadence_gem.c +6 -0
+{
+    desc[1]  = 0;
+}
+
  static inline void rx_desc_set_eof(uint32_t *desc)
  {
      desc[1] |= DESC_1_RX_EOF;
@@ -994,6 +999,8 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
          bytes_to_copy -= MIN(bytes_to_copy, rxbufsize);
 
          /* Update the descriptor.  */
+        rx_desc_clear(s->rx_desc[q]);
+
          if (first_desc) {
              rx_desc_set_sof(s->rx_desc[q]);
              first_desc = false;