]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
net: Add mii_resolve_flowctrl_fdx()
authorYuiko Oshino <yuiko.oshino@microchip.com>
Fri, 11 Aug 2017 16:44:57 +0000 (12:44 -0400)
committerJoe Hershberger <joe.hershberger@ni.com>
Mon, 14 Aug 2017 17:47:32 +0000 (12:47 -0500)
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>
include/linux/mii.h

index 66b83d83deb4fc5d285e8ad89ca27f0cab3acad4..19afb746cd00b14f39fd9346164508f25e6343cc 100644 (file)
@@ -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__ */