From: Scott Wood <scottwood@freescale.com>
To: Fabien Chouteau <chouteau@adacore.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 2/2] Add Enhanced Three-Speed Ethernet Controller (eTSEC)
Date: Thu, 18 Jul 2013 15:37:05 -0500 [thread overview]
Message-ID: <1374179825.5357.13@snotra> (raw)
In-Reply-To: <51E7B516.9060709@adacore.com> (from chouteau@adacore.com on Thu Jul 18 04:27:50 2013)
On 07/18/2013 04:27:50 AM, Fabien Chouteau wrote:
> On 07/17/2013 11:02 PM, Scott Wood wrote:
> > On 07/17/2013 05:17:06 AM, Fabien Chouteau wrote:
> >> On 07/16/2013 07:50 PM, Scott Wood wrote:
> >> > On 07/16/2013 10:28:28 AM, Fabien Chouteau wrote:
> >> >> On 07/16/2013 04:06 AM, Scott Wood wrote:
> >> >> > On 07/10/2013 12:10:02 PM, Fabien Chouteau wrote:
> >> >> >> + if (*size == etsec->rx_padding) {
> >> >> >> + /* The remaining bytes are for padding which is not
> actually allocated
> >> >> >> + in the buffer */
> >> >> >> +
> >> >> >> + rem = MIN(etsec->regs[MRBLR].value - bd->length,
> etsec->rx_padding);
> >> >> >> +
> >> >> >> + if (rem > 0) {
> >> >> >> + memset(padd, 0x0, sizeof(padd));
> >> >> >> + etsec->rx_padding -= rem;
> >> >> >> + *size -= rem;
> >> >> >> + bd->length += rem;
> >> >> >> + cpu_physical_memory_write(bufptr, padd, rem);
> >> >> >> + }
> >> >> >> + }
> >> >> >
> >> >> > What if *size > 0 && *size < etsec->rx_padding?
> >> >>
> >> >> I don't think it's possible...
> >> >
> >> > Maybe throw in an assertion, then?
> >> >
> >> > I can see how it might not be possible if rx_padding is being
> used for padding a short frame, since MRBLR must be a multiple of 64,
> but what if it's 4 bytes for CRC?
> >> >
> >>
> >> Can you explain a possible error scenario?
> >
> > 126 byte packet, no fcb. rx_padding is 4 for CRC. Suppose MRBLR
> is 128. Wouldn't *size be 2 here?
> >
>
> Yes, at the end of the function, but then rx_padding is 2 as well.
How is rx_padding 2? rx_init_frame() will set it to 4 (since the
packet size is not less than 60). The only other place I see that
modifies rx_padding is "etsec->rx_padding -= rem", but that doesn't
happen because the "*size == etsec->rx_padding" check happens first.
> value of "to_write" will be 126:
>
> *size = etsec->rx_remaining_data + etsec->rx_padding;
> = 126 + 4;
> = 130;
>
> to_write = MIN(etsec->rx_fcb_size + *size - etsec->rx_padding,
> etsec->regs[MRBLR].value);
> = MIN(0 + 130 - 4, 128);
> = MIN(126, 128);
> = 126;
>
> So we write the packet in the first part of the BD, and there's 2
> bytes
> left in the BD.
>
> *size -= to_write;
> = 4;
> bd->length = to_write;
> = 126;
>
> So *size == etsec->rx_padding (This is expected as the first write
> operation can only write data and no padding, I will comment this
> fact)
>
> rem = MIN(etsec->regs[MRBLR].value - bd->length, etsec->rx_padding);
> = MIN(128 - 126, 4);
> = MIN(2, 4);
> = 2;
>
> We write 2 bytes of padding.
>
> etsec->rx_padding -= rem;
> = 2;
> *size -= rem;
> = 2;
> bd->length += rem;
> = 128;
>
> The BD is full, we will have to put the rest of padding in the next
> one.
What rest of padding? I thought you said rx_padding was 2 somehow? If
that were true, then it would be zero at the end.
> >> > Could you at least have a way to diagnose when the guest OS
> tries to
> >> > use some functionality that you don't support, rather than
> silently
> >> > doing the wrong thing?
> >> >
> >>
> >> This device is so complex, detecting unsupported features would
> take too
> >> much work.
> >
> > I was thinking along the lines of marking registers and bits within
> registers as supported (or which are properly no-ops in QEMU) -- and
> warning the first time you see a non-default-value write to an
> unsupported field or register. It could save a lot of debugging.
> >
>
> I think we'll spend more time implementing this than debugging.
> Another
> solution is to enable debug output and see which registers are read or
> write.
I don't think it'd be that hard -- you already have an array of
registers. The information could easily go in there, and be checked by
common infrastructure.
-Scott
next prev parent reply other threads:[~2013-07-18 20:37 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 17:10 [Qemu-devel] [PATCH 0/2] Enhanced Three Speed Ethernet Controller (eTSEC) Fabien Chouteau
2013-07-10 17:10 ` [Qemu-devel] [PATCH 1/2] Add be16_to_cpupu function Fabien Chouteau
2013-07-10 17:25 ` Peter Maydell
2013-07-12 9:57 ` Fabien Chouteau
2013-07-10 17:10 ` [Qemu-devel] [PATCH 2/2] Add Enhanced Three-Speed Ethernet Controller (eTSEC) Fabien Chouteau
[not found] ` <201307110955092430409@cn.fujitsu.com>
2013-07-15 1:25 ` [Qemu-devel] Fw: [PATCH 2/2] Add Enhanced Three-Speed EthernetController (eTSEC) Yao Xingtao
2013-07-15 10:19 ` Fabien Chouteau
2013-07-15 2:00 ` [Qemu-devel] [PATCH 2/2] Add Enhanced Three-Speed Ethernet Controller (eTSEC) Peter Crosthwaite
2013-07-15 14:23 ` Fabien Chouteau
2013-07-16 1:06 ` Peter Crosthwaite
2013-07-16 8:35 ` Fabien Chouteau
2013-07-16 2:06 ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2013-07-16 15:28 ` Fabien Chouteau
2013-07-16 15:37 ` Alexander Graf
2013-07-16 16:15 ` Fabien Chouteau
2013-07-16 16:54 ` Scott Wood
2013-07-17 8:24 ` Fabien Chouteau
2013-07-17 8:29 ` Alexander Graf
2013-07-17 10:27 ` Fabien Chouteau
2013-07-16 17:50 ` Scott Wood
2013-07-17 10:17 ` Fabien Chouteau
2013-07-17 10:22 ` Alexander Graf
2013-07-17 10:43 ` Fabien Chouteau
2013-07-17 21:02 ` Scott Wood
2013-07-18 9:27 ` Fabien Chouteau
2013-07-18 20:37 ` Scott Wood [this message]
2013-07-19 9:22 ` Fabien Chouteau
2013-07-19 17:19 ` Scott Wood
2013-07-22 9:00 ` Fabien Chouteau
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=1374179825.5357.13@snotra \
--to=scottwood@freescale.com \
--cc=chouteau@adacore.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).