From: Roy Franz <roy.franz@linaro.org>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Patch Tracking <patches@linaro.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] net: Fix lan9118 buffer length handling
Date: Wed, 1 Jan 2014 12:09:34 -0800 [thread overview]
Message-ID: <CAFECyb-V7Yb0Jbn3-fFmmW9dANa=v0VcXPSsrPHP42H45p_o+w@mail.gmail.com> (raw)
In-Reply-To: <CAEgOgz4FAUUFJ9n1FBURONh27LFc9D8_OUQf1EYZ7qhR3V0_=Q@mail.gmail.com>
On Fri, Dec 27, 2013 at 5:25 PM, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> On Sat, Dec 21, 2013 at 4:26 AM, Roy Franz <roy.franz@linaro.org> wrote:
>> 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 uses the provided buffer length to limit the bytes transmitted.
>> Previously all the bytes of the last 32-bit word written to the TX fifo
>> were added to the internal transmit buffer structure resulting in more bytes
>> being transmitted than were submitted to the hardware in the command. This
>> resulted in extra bytes being inserted into the middle of multi-buffer
>> packets when the non-final buffers had non-32bit aligned ending addresses.
>>
>> Signed-off-by: Roy Franz <roy.franz@linaro.org>
>> ---
>> hw/net/lan9118.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
>> index c5d6f14..712bb41 100644
>> --- a/hw/net/lan9118.c
>> +++ b/hw/net/lan9118.c
>> @@ -773,11 +773,10 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val)
>> in FIFO words. Empirical results show it to be little-endian.
>> */
>> /* TODO: FIFO overflow checking. */
>> - while (n--) {
>> + while (n-- && s->txp->buffer_size--) {
>
> can you just get n right in the first place (line 766):
>
> n = MIN(4, s->txp_buffer_size);
>
> rather than doing min calculation on two parallel iteration variables?
>
> Regards,
> Peter
>
>> s->txp->data[s->txp->len] = val & 0xff;
>> s->txp->len++;
>> val >>= 8;
>> - s->txp->buffer_size--;
>> }
>> s->txp->fifo_used++;
>> }
>> --
>> 1.7.10.4
>>
>>
Hi Peter,
I'll take a look at this (and your other comments on the extract32)
when I am back at work next week.
Thanks,
Roy
prev parent reply other threads:[~2014-01-01 20:09 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 ` [Qemu-devel] [PATCH 1/2] net: Fix lan9118 TX "CMD A" handling Roy Franz
2013-12-28 1:25 ` 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 [this message]
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='CAFECyb-V7Yb0Jbn3-fFmmW9dANa=v0VcXPSsrPHP42H45p_o+w@mail.gmail.com' \
--to=roy.franz@linaro.org \
--cc=aliguori@amazon.com \
--cc=patches@linaro.org \
--cc=peter.crosthwaite@xilinx.com \
--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).