From: Stefan Hajnoczi <stefanha@redhat.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Beniamino Galvani <b.galvani@gmail.com>,
Peter Maydell <peter.maydell@linaro.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Li Guang <lig.fnst@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] hw/net: add support for Allwinner EMAC Fast Ethernet controller
Date: Tue, 14 Jan 2014 13:19:38 +0800 [thread overview]
Message-ID: <20140114051938.GC4803@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAEgOgz5c1i9X8DHXvnOXYF+1N6k77wYOAYf5CaqRAbYnY5zPXw@mail.gmail.com>
On Mon, Jan 13, 2014 at 11:16:37PM +1000, Peter Crosthwaite wrote:
> On Mon, Jan 13, 2014 at 11:15 PM, Peter Crosthwaite
> <peter.crosthwaite@xilinx.com> wrote:
> > On Sat, Jan 11, 2014 at 8:13 PM, Beniamino Galvani <b.galvani@gmail.com> wrote:
> >> + } else {
> >> + mii->bmsr &= ~MII_BMSR_LINK_ST;
> >> + mii->anlpar = MII_ANAR_TX;
> >> + }
> >> + mii->link_ok = link_ok;
> >> +}
> >> +
> >> +static void mii_reset(AwEmacMii *mii)
> >> +{
> >> + mii->bmcr = MII_BMCR_FD | MII_BMCR_AUTOEN | MII_BMCR_SPEED;
> >> + mii->bmsr = MII_BMSR_100TX_FD | MII_BMSR_100TX_HD | MII_BMSR_10T_FD |
> >> + MII_BMSR_10T_HD | MII_BMSR_MFPS | MII_BMSR_AUTONEG;
> >> + mii->anar = MII_ANAR_TXFD | MII_ANAR_TX | MII_ANAR_10FD | MII_ANAR_10 |
> >> + MII_ANAR_CSMACD;
> >> + mii->anlpar = MII_ANAR_TX;
> >> + mii_set_link(mii, mii->link_ok);
> >
> > If this is actually needed, it smells like a bug in the net layer. Is
> > the net layer not doing it's resets properly? It's quite odd that you
> > are preserving old state across a reset.
The net layer doesn't have a reset point for the link status. The net
client must explicitly transition states itself.
> >> +static ssize_t aw_emac_receive(NetClientState *nc, const uint8_t *buf,
> >> + size_t size)
> >> +{
> >> + AwEmacState *s = qemu_get_nic_opaque(nc);
> >> + AwEmacFifo *fifo;
> >> + uint32_t crc, *word;
> >> + uint8_t *dest;
> >> +
> >> + if (s->num_rx >= NUM_RX_FIFOS) {
> >
> > Seems inconsistent that you check for fifo vacancy but you dont check
> > for s->ctl & EMAC_CTL_RX_EN (as above in can_recieve). Then again,
> > both conditions should be guarded by can_recieve, so I wonder whether
> > you can just drop this.
> >
> > Stefan, if you are reading, can the recieve function rely on
> > can_recieve success and drop such checks?
It is safer to perform full checks in .receive() since
qemu_net_queue_flush() calls .receive() repeatedly without
.can_receive(). This means especially if the state can change between
calls, you need to do a full check.
> >> +static const VMStateDescription vmstate_mii = {
> >> + .name = "allwinner_emac_mii",
> >> + .version_id = 1,
> >> + .minimum_version_id = 1,
> >> + .fields = (VMStateField[]) {
> >> + VMSTATE_UINT16(bmcr, AwEmacMii),
> >> + VMSTATE_UINT16(bmsr, AwEmacMii),
> >> + VMSTATE_UINT16(anar, AwEmacMii),
> >> + VMSTATE_UINT16(anlpar, AwEmacMii),
> >> + VMSTATE_BOOL(link_ok, AwEmacMii),
> >
> > The net layer should probably properly set link_ok on realize, so I
> > doubt it's migratable state.
The net layer is not part of live migration. It's up to the emulated
device to migrate link state and restore it after migration. In other
words, link state should be migrated as part of PHY vmstate.
next prev parent reply other threads:[~2014-01-14 5:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-11 10:13 [Qemu-devel] [PATCH v2 0/2] hw/arm: add ethernet support to Allwinner A10 Beniamino Galvani
2014-01-11 10:13 ` [Qemu-devel] [PATCH v2 1/2] hw/net: add support for Allwinner EMAC Fast Ethernet controller Beniamino Galvani
2014-01-13 5:20 ` Stefan Hajnoczi
2014-01-13 13:15 ` Peter Crosthwaite
2014-01-13 13:16 ` Peter Crosthwaite
2014-01-14 5:19 ` Stefan Hajnoczi [this message]
2014-01-15 8:24 ` Peter Crosthwaite
2014-01-15 10:25 ` Juan Quintela
2014-01-15 12:15 ` Peter Crosthwaite
2014-01-16 2:45 ` Stefan Hajnoczi
2014-01-16 12:52 ` Peter Crosthwaite
2014-01-17 3:25 ` Stefan Hajnoczi
2014-01-15 12:40 ` Peter Crosthwaite
2014-01-15 21:42 ` Beniamino Galvani
2014-01-15 23:29 ` Peter Crosthwaite
2014-01-11 10:13 ` [Qemu-devel] [PATCH v2 2/2] hw/arm/allwinner-a10: initialize EMAC Beniamino Galvani
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=20140114051938.GC4803@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=b.galvani@gmail.com \
--cc=lig.fnst@cn.fujitsu.com \
--cc=peter.crosthwaite@xilinx.com \
--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).