qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: romain@dolbeau.org, agraf@suse.de, qemu-devel@nongnu.org,
	stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH] e1000: factor out checking for auto-negotiation availability
Date: Fri, 20 Jun 2014 00:58:54 +0300	[thread overview]
Message-ID: <20140619215854.GA24468@redhat.com> (raw)
In-Reply-To: <20140619194051.GI1695@ERROL.INI.CMU.EDU>

On Thu, Jun 19, 2014 at 03:40:51PM -0400, Gabriel L. Somlo wrote:
> Also fix minor indentation issues in the surrounding code.
> 
> Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Gabriel Somlo <somlo@cmu.edu>

Applied, thanks!

> ---
>  hw/net/e1000.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index 8ee5225..0fc29a0 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -848,6 +848,14 @@ receive_filter(E1000State *s, const uint8_t *buf, int size)
>      return 0;
>  }
>  
> +static bool
> +have_autoneg(E1000State *s)
> +{
> +    return (s->compat_flags & E1000_FLAG_AUTONEG) &&
> +           (s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN) &&
> +           (s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG);
> +}
> +
>  static void
>  e1000_set_link_status(NetClientState *nc)
>  {
> @@ -857,9 +865,7 @@ e1000_set_link_status(NetClientState *nc)
>      if (nc->link_down) {
>          e1000_link_down(s);
>      } else {
> -        if (s->compat_flags & E1000_FLAG_AUTONEG &&
> -            s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
> -            s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG &&
> +        if (have_autoneg(s) &&
>              !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) {
>              /* emulate auto-negotiation if supported */
>              timer_mod(s->autoneg_timer,
> @@ -1297,11 +1303,8 @@ static void e1000_pre_save(void *opaque)
>       * complete auto-negotiation immediately. This allows us to look
>       * at MII_SR_AUTONEG_COMPLETE to infer link status on load.
>       */
> -    if (nc->link_down &&
> -        s->compat_flags & E1000_FLAG_AUTONEG &&
> -        s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
> -        s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG) {
> -         s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
> +    if (nc->link_down && have_autoneg(s)) {
> +        s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
>      }
>  }
>  
> @@ -1323,12 +1326,11 @@ static int e1000_post_load(void *opaque, int version_id)
>       * Alternatively, restart link negotiation if it was in progress. */
>      nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0;
>  
> -    if (s->compat_flags & E1000_FLAG_AUTONEG &&
> -        s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
> -        s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG &&
> +    if (have_autoneg(s) &&
>          !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) {
>          nc->link_down = false;
> -        timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
> +        timer_mod(s->autoneg_timer,
> +                  qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
>      }
>  
>      return 0;
> -- 
> 1.9.3

      reply	other threads:[~2014-06-19 21:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 19:40 [Qemu-devel] [PATCH] e1000: factor out checking for auto-negotiation availability Gabriel L. Somlo
2014-06-19 21:58 ` Michael S. Tsirkin [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=20140619215854.GA24468@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=gsomlo@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=romain@dolbeau.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).