[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <OF7B34BB2C.B6A69F84-ON8025752E.005E7485-8025752E.005EAB70@smsc.com>
Date:	Mon, 29 Dec 2008 17:12:51 +0000
From:	Steve.Glendinning@...c.com
To:	Ben Hutchings <bhutchings@...arflare.com>
Cc:	ian.saturley@...c.com, netdev@...r.kernel.org
Subject: Re: [RFC PATCH 2/2] refactor full duplex flow control resolution
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@...c.com
Ben Hutchings <bhutchings@...arflare.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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists
 
