From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu4mm-0001U6-VU for qemu-devel@nongnu.org; Fri, 20 Dec 2013 13:27:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vu4mg-0000eb-W0 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 13:26:56 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:61773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu4mg-0000eA-PR for qemu-devel@nongnu.org; Fri, 20 Dec 2013 13:26:50 -0500 Received: by mail-pb0-f53.google.com with SMTP id ma3so2929379pbc.12 for ; Fri, 20 Dec 2013 10:26:50 -0800 (PST) From: Roy Franz Date: Fri, 20 Dec 2013 10:26:36 -0800 Message-Id: <1387563997-1845-2-git-send-email-roy.franz@linaro.org> In-Reply-To: <1387563997-1845-1-git-send-email-roy.franz@linaro.org> References: <1387563997-1845-1-git-send-email-roy.franz@linaro.org> Subject: [Qemu-devel] [PATCH 1/2] net: Fix lan9118 TX "CMD A" handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, stefanha@redhat.com, aliguori@amazon.com Cc: Roy Franz , peter.maydell@linaro.org, patches@linaro.org 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. Signed-off-by: Roy Franz --- hw/net/lan9118.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 2315f99..c5d6f14 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 = s->txp->cmd_a & 0x7ff; + s->txp->offset = (s->txp->cmd_a >> 16) & 0x1f; 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) { -- 1.7.10.4