Skip to content

Commit

Permalink
net: cadence_gem: clear RX control descriptor
Browse files Browse the repository at this point in the history
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>
Message-id: 20200418085145.489726-1-rfried.dev@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
mellowcandle authored and pm215 committed Apr 30, 2020
1 parent f1e7cb1 commit 59ab136
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hw/net/cadence_gem.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 59ab136

Please sign in to comment.