qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Roy Franz <roy.franz@linaro.org>
To: qemu-devel@nongnu.org, stefanha@redhat.com, aliguori@amazon.com
Cc: Roy Franz <roy.franz@linaro.org>,
	peter.maydell@linaro.org, patches@linaro.org
Subject: [Qemu-devel] [PATCH 1/2] net: Fix lan9118 TX "CMD A" handling
Date: Fri, 20 Dec 2013 10:26:36 -0800	[thread overview]
Message-ID: <1387563997-1845-2-git-send-email-roy.franz@linaro.org> (raw)
In-Reply-To: <1387563997-1845-1-git-send-email-roy.franz@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 <roy.franz@linaro.org>
---
 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

  reply	other threads:[~2013-12-20 18:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 18:26 [Qemu-devel] [PATCH 0/2] net: Fix lan9118 multi-buffer transmit Roy Franz
2013-12-20 18:26 ` Roy Franz [this message]
2013-12-28  1:25   ` [Qemu-devel] [PATCH 1/2] net: Fix lan9118 TX "CMD A" handling Peter Crosthwaite
2013-12-20 18:26 ` [Qemu-devel] [PATCH 2/2] net: Fix lan9118 buffer length handling Roy Franz
2013-12-28  1:25   ` Peter Crosthwaite
2014-01-01 20:09     ` Roy Franz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387563997-1845-2-git-send-email-roy.franz@linaro.org \
    --to=roy.franz@linaro.org \
    --cc=aliguori@amazon.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).