diff options
author | Yuiko Oshino <yuiko.oshino@microchip.com> | 2017-08-11 12:44:57 -0400 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2017-08-14 12:47:32 -0500 |
commit | 1c1e370033f9aa0e2aed8ef64764a924e6248609 (patch) | |
tree | dd215d8444af694dac81ee4e1e9968a269be2a39 | |
parent | 3f8f1410b5d5d1fcbc28ea06700a9b601d736575 (diff) |
net: Add mii_resolve_flowctrl_fdx()
Add an mii helper function to resolve flow control status per
IEEE 802.3-2005 table 28B-3.
This function was taken from the Linux source tree.
Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
-rw-r--r-- | include/linux/mii.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/mii.h b/include/linux/mii.h index 66b83d83deb..19afb746cd0 100644 --- a/include/linux/mii.h +++ b/include/linux/mii.h @@ -190,4 +190,27 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock, return 0; } +/** + * 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 & 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; + } + + return cap; +} + #endif /* __LINUX_MII_H__ */ |