[U-Boot,v4,1/2] net: Add mii_resolve_flowctrl_fdx()

Message ID 1502469898-994-1-git-send-email-yuiko.oshino@microchip.com
State Accepted
Commit 1c1e370
Delegated to: Joe Hershberger
Headers show

Commit Message

Yuiko.Oshino@microchip.com Aug. 11, 2017, 4:44 p.m.
From: Yuiko Oshino <yuiko.oshino@microchip.com>

Add support for Microchip LAN7500, LAN7800 and LAN7850,
USB to 10/100/1000 Ethernet Controllers.

Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>

---

Changes in v4:
   - none.

Changes in v3:
   - This patch is added to a series.

Changes in v2:
   - The patch's tag is changed to net:.

 include/linux/mii.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Joe Hershberger Aug. 14, 2017, 5:49 p.m. | #1
Hi Yuiko.Oshino@microchip.com,

https://patchwork.ozlabs.org/patch/800647/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe

Patch

diff --git a/include/linux/mii.h b/include/linux/mii.h
index 66b83d8..19afb74 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__ */