qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Patch Tracking <patches@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/5] hw/net/stellaris_enet: Rewrite tx fifo handling code
Date: Tue, 1 Apr 2014 18:45:56 +0100	[thread overview]
Message-ID: <20140401174555.GV2411@work-vm> (raw)
In-Reply-To: <CAFEAcA-MS9wCX-5QZfjmx4K2V9wco5ALg2RuzbgZXTnG5uhxxw@mail.gmail.com>

(resend reply - the mail gru got some of the 1st one)

* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 1 April 2014 18:26, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> > * Peter Maydell (peter.maydell@linaro.org) wrote:
> >> The datasheet is clear that the frame length written to the DATA
> >> register is actually stored in the TX FIFO; this means we don't
> >> need to keep both tx_frame_len and tx_fifo_len state separately.
> >>
> >> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> >> ---
> >>  hw/net/stellaris_enet.c | 119 +++++++++++++++++++++++++++++++-----------------
> >>  1 file changed, 77 insertions(+), 42 deletions(-)
> >>
> >> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
> >> index d0da819..b99f93e 100644
> >> --- a/hw/net/stellaris_enet.c
> >> +++ b/hw/net/stellaris_enet.c
> >> @@ -59,7 +59,6 @@ typedef struct {
> >>      uint32_t mtxd;
> >>      uint32_t mrxd;
> >>      uint32_t np;
> >> -    int tx_frame_len;
> >>      int tx_fifo_len;
> >>      uint8_t tx_fifo[2048];
> >>      /* Real hardware has a 2k fifo, which works out to be at most 31 packets.
> >> @@ -82,6 +81,62 @@ static void stellaris_enet_update(stellaris_enet_state *s)
> >>      qemu_set_irq(s->irq, (s->ris & s->im) != 0);
> >>  }
> >>
> >> +/* Return the data length of the packet currently being assembled
> >> + * in the TX fifo.
> >> + */
> >> +static inline int stellaris_txpacket_datalen(stellaris_enet_state *s)
> >> +{
> >> +    return s->tx_fifo[0] | (s->tx_fifo[1] << 8);
> >> +}
> >> +
> >> +/* Return true if the packet currently in the TX FIFO is complete,
> >> +* ie the FIFO holds enough bytes for the data length, ethernet header,
> >> +* payload and optionally CRC.
> >> +*/
> >> +static inline bool stellaris_txpacket_complete(stellaris_enet_state *s)
> >> +{
> >> +    int framelen = stellaris_txpacket_datalen(s);
> >> +    framelen += 16;
> >
> > What's the magical 16? (It doesn't jump out from the data sheet).
> 
> See table 15-3: 2 bytes of data length, 6 bytes dest addr,
> 6 bytes source addr, 2 bytes len/type.

Ah yes or the text in 15.3.1.2 para 4 'referes to the Etehernet frame data
payload, as shown in the 5th to nth FIFO positions' (1,2,3,4 each 4 bytes).

> > You should probably increment the migration state version number to 2.
>
> Oops, yes.

Fix if you need to reroll, but not too important since i doubt people are
migrating it.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  parent reply	other threads:[~2014-04-01 17:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01 16:53 [Qemu-devel] [PATCH 0/5] stellaris_enet: overhaul TX handling Peter Maydell
2014-04-01 16:53 ` [Qemu-devel] [PATCH 1/5] hw/net/stellaris_enet: Restructure tx_fifo code to avoid buffer overrun Peter Maydell
2014-04-01 17:00   ` Dr. David Alan Gilbert
2014-04-01 16:53 ` [Qemu-devel] [PATCH 2/5] hw/net/stellaris_enet: Correct handling of packet padding Peter Maydell
2014-04-01 17:01   ` Dr. David Alan Gilbert
2014-04-01 16:53 ` [Qemu-devel] [PATCH 3/5] hw/net/stellaris_enet: Rewrite tx fifo handling code Peter Maydell
2014-04-01 17:26   ` Dr. David Alan Gilbert
2014-04-01 17:29     ` Peter Maydell
2014-04-01 17:35       ` Dr. David Alan Gilbert
2014-04-01 17:45       ` Dr. David Alan Gilbert [this message]
2014-04-01 17:48         ` Peter Maydell
2014-04-01 17:51           ` Dr. David Alan Gilbert
2014-04-01 16:53 ` [Qemu-devel] [PATCH 4/5] hw/net/stellaris_enet: Correctly implement the TR and THR registers Peter Maydell
2014-04-01 17:44   ` Dr. David Alan Gilbert
2014-04-01 18:08     ` Peter Maydell
2014-04-01 16:53 ` [Qemu-devel] [PATCH 5/5] hw/net/stellaris_enet: Fix debug format strings Peter Maydell
2014-04-01 17:47   ` Dr. David Alan Gilbert
2014-04-01 17:04 ` [Qemu-devel] [PATCH 0/5] stellaris_enet: overhaul TX handling Peter Maydell

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=20140401174555.GV2411@work-vm \
    --to=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).