aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mii.h
diff options
context:
space:
mode:
authorSteve Glendinning <steve.glendinning@smsc.com>2008-12-16 05:00:48 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-16 05:00:48 -0500
commitbc02ff95fe4ebd3e5ee7455c0aa6f76ebe39ebca (patch)
tree675887b8007a53464e84b9da2f7b54a77fab035a /include/linux/mii.h
parente18ce3465477502108187c6c08b6423fb784a313 (diff)
net: Refactor full duplex flow control resolution
These 4 drivers have identical full duplex flow control resolution functions. This patch changes them all to use one common function. The function in question decides whether a device should enable TX and RX flow control in a standard way (IEEE 802.3-2005 table 28B-3), so this should also be useful for other drivers. Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/mii.h')
-rw-r--r--include/linux/mii.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 4a376e0816f..ad748588faf 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -239,5 +239,34 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
239 return 0; 239 return 0;
240} 240}
241 241
242/**
243 * mii_resolve_flowctrl_fdx
244 * @lcladv: value of MII ADVERTISE register
245 * @rmtadv: value of MII LPA register
246 *
247 * Resolve full duplex flow control as per IEEE 802.3-2005 table 28B-3
248 */
249static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
250{
251 u8 cap = 0;
252
253 if (lcladv & ADVERTISE_PAUSE_CAP) {
254 if (lcladv & ADVERTISE_PAUSE_ASYM) {
255 if (rmtadv & LPA_PAUSE_CAP)
256 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
257 else if (rmtadv & LPA_PAUSE_ASYM)
258 cap = FLOW_CTRL_RX;
259 } else {
260 if (rmtadv & LPA_PAUSE_CAP)
261 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
262 }
263 } else if (lcladv & ADVERTISE_PAUSE_ASYM) {
264 if ((rmtadv & LPA_PAUSE_CAP) && (rmtadv & LPA_PAUSE_ASYM))
265 cap = FLOW_CTRL_TX;
266 }
267
268 return cap;
269}
270
242#endif /* __KERNEL__ */ 271#endif /* __KERNEL__ */
243#endif /* __LINUX_MII_H__ */ 272#endif /* __LINUX_MII_H__ */