diff options
author | Roy Franz <roy.franz@linaro.org> | 2014-01-07 20:19:51 -0800 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-01-27 15:44:06 +0100 |
commit | 2ad657e3f3af66def47554186a58f1748787a527 (patch) | |
tree | 48997dd395fdc4be65dcc6b21caa03977c25ba67 /hw/net | |
parent | 4bf2c138ddefc6ff17f6c4b947320c60aa0c38a0 (diff) |
Fix lan9118 TX "CMD A" handling
The 9118 ethernet controller supports transmission of multi-buffer packets
with arbitrary byte alignment of the start and end bytes. All writes to
the packet fifo are 32 bits, so the controller discards bytes at the beginning
and end of each buffer based on the 'Data start offset' and 'Buffer size'
of the TX command 'A' format.
This patch changes the buffer size and offset internal state variables to be
updated on every "TX command A" write. Previously they were only updated for
the first segment, which resulted incorrect behavior for packets with more
than one segment. Each segment of the packet has its own CMD A command, with
its own buffer size and start offset.
Also update extraction of fields from the CMD A word to use extract32().
Signed-off-by: Roy Franz <roy.franz@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r-- | hw/net/lan9118.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 2315f996d4..bb0c503a1b 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -727,14 +727,14 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) s->txp->cmd_a = val & 0x831f37ff; s->txp->fifo_used++; s->txp->state = TX_B; + s->txp->buffer_size = extract32(s->txp->cmd_a, 0, 11); + s->txp->offset = extract32(s->txp->cmd_a, 16, 5); break; case TX_B: if (s->txp->cmd_a & 0x2000) { /* First segment */ s->txp->cmd_b = val; s->txp->fifo_used++; - s->txp->buffer_size = s->txp->cmd_a & 0x7ff; - s->txp->offset = (s->txp->cmd_a >> 16) & 0x1f; /* End alignment does not include command words. */ n = (s->txp->buffer_size + s->txp->offset + 3) >> 2; switch ((n >> 24) & 3) { |