lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 23 Dec 2008 17:45:35 +0000 From: Ben Hutchings <bhutchings@...arflare.com> To: Steve Glendinning <steve.glendinning@...c.com> Cc: netdev@...r.kernel.org, Ian Saturley <ian.saturley@...c.com> Subject: Re: [RFC PATCH 2/2] refactor full duplex flow control resolution 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