All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve.Glendinning@smsc.com
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: ian.saturley@smsc.com, netdev@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] refactor full duplex flow control resolution
Date: Mon, 29 Dec 2008 17:12:51 +0000	[thread overview]
Message-ID: <OF7B34BB2C.B6A69F84-ON8025752E.005E7485-8025752E.005EAB70@smsc.com> (raw)
In-Reply-To: <1230054335.3402.29.camel@deadeye.i.decadent.org.uk>

Thanks Ben, this looks good.

Do you want to submit a patch for this or should I?

Regards,
--
Steve Glendinning
SMSC GmbH
m: +44 777 933 9124
e: steve.glendinning@smsc.com



Ben Hutchings <bhutchings@solarflare.com> wrote on 23/12/2008 17:45:35:

> On Sun, 2008-12-14 at 12:38 +0000, Steve Glendinning wrote:
> [...]
> > +/**
> > + * mii_resolve_flowctrl_fdx
> > + * @lcladv: value of MII ADVERTISE register
> > + * @rmtadv: value of MII LPA register
> > + *
> > + * Resolve full duplex flow control as per IEEE 802.3-2005 table 
28B-3
> > + */
> > +static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
> > +{
> > +   u8 cap = 0;
> > +
> > +   if (lcladv & ADVERTISE_PAUSE_CAP) {
> > +      if (lcladv & ADVERTISE_PAUSE_ASYM) {
> > +         if (rmtadv & LPA_PAUSE_CAP)
> > +            cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
> > +         else if (rmtadv & LPA_PAUSE_ASYM)
> > +            cap = FLOW_CTRL_RX;
> > +      } else {
> > +         if (rmtadv & LPA_PAUSE_CAP)
> > +            cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
> > +      }
> > +   } else if (lcladv & ADVERTISE_PAUSE_ASYM) {
> > +      if ((rmtadv & LPA_PAUSE_CAP) && (rmtadv & LPA_PAUSE_ASYM))
> > +         cap = FLOW_CTRL_TX;
> > +   }
> > +
> > +   return cap;
> > +}
> 
> There's a rather more elegant way to write this, which is:
> 
>    if (lcladv & rmtadv & ADVERTISE_PAUSE_CAP) {
>       cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
>    } else if (lcladv & rmtadv & ADVERTISE_PAUSE_ASYM) {
>       if (lcladv & ADVERTISE_PAUSE_CAP)
>          cap = FLOW_CTRL_RX;
>       else if (rmtadv & ADVERTISE_PAUSE_CAP)
>          cap = FLOW_CTRL_TX;
>    }
> 
> Ben.
> 
> -- 
> Ben Hutchings, Senior Software Engineer, Solarflare Communications
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2008-12-29 17:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-14 12:38 [RFC PATCH 0/2] unify full duplex flow control resolution Steve Glendinning
2008-12-14 12:38 ` [RFC PATCH 1/2] move flow control definitions to mii.h Steve Glendinning
2008-12-14 12:38   ` [RFC PATCH 2/2] refactor full duplex flow control resolution Steve Glendinning
2008-12-16 10:00     ` David Miller
2008-12-23 17:45     ` Ben Hutchings
2008-12-29 17:12       ` Steve.Glendinning [this message]
2008-12-16 10:00   ` [RFC PATCH 1/2] move flow control definitions to mii.h David Miller
2008-12-18  0:17   ` Andrew Morton
2008-12-18  0:27     ` David Miller
2008-12-23 17:47   ` Ben Hutchings

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=OF7B34BB2C.B6A69F84-ON8025752E.005E7485-8025752E.005EAB70@smsc.com \
    --to=steve.glendinning@smsc.com \
    --cc=bhutchings@solarflare.com \
    --cc=ian.saturley@smsc.com \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.