Skip to contentSkip to conversation

net: cadence_gem: clear RX control descriptor

PATCH Applied Ramon Fried 2 participants 3 messages Jul 16, 2019 – Apr 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
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(+)
hw/net/cadence_gem.c +7 -0
index ecee22525c..cca3ce7f56 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_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]);
Signature · 1 line
2.22.0
Applied
#1 lore raw
Quoted 37 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.

---
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(+)
hw/net/cadence_gem.c +5 -0
index ecee22525c..cca3ce7f56 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_control(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
  static inline void rx_desc_set_eof(uint32_t *desc)
  {
      desc[1] |= DESC_1_RX_EOF;

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

Quoted 8 lines
hw/net/cadence_gem.c +2 -0
@@ -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

#2 lore raw

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

Thanks,
Ramon.

Quoted 54 lines · Jason Wang
Quoted 37 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.

---
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(+)
hw/net/cadence_gem.c +5 -0
index ecee22525c..cca3ce7f56 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_control(uint32_t *desc)
+{
+    desc[1]  = 0;
+}
+
  static inline void rx_desc_set_eof(uint32_t *desc)
  {
      desc[1] |= DESC_1_RX_EOF;

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

Quoted 8 lines
hw/net/cadence_gem.c +2 -0
@@ -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