net: cadence_gem: clear RX control descriptor
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
@@ -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
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.Signed-off-by Ramon Fried <[email protected]>--- hw/net/cadence_gem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/net/cadence_gem.c +7
-1@@ -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
Philippe Mathieu-Daudé
Reviewed-byQuoted 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.Signed-off-by Ramon Fried <[email protected]>--- hw/net/cadence_gem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/net/cadence_gem.c +5
-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) +{ + 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
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.Signed-off-by Ramon Fried <[email protected]>--- hw/net/cadence_gem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/net/cadence_gem.c +0
-0
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;
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.Signed-off-by Ramon Fried <[email protected]>--- hw/net/cadence_gem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/net/cadence_gem.c +5
-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) +{ + 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
Reviewed-by Philippe Mathieu-Daudé <[email protected]>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
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.Signed-off-by Ramon Fried <[email protected]>--- hw/net/cadence_gem.c | 7 +++++++ 1 file changed, 7 insertions(+)hw/net/cadence_gem.c +0
-0@@ -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;