Skip to content

Commit 1c1e370

Browse files
microchip1jhershbe
authored andcommitted
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>
1 parent 3f8f141 commit 1c1e370

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

include/linux/mii.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,27 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
190190
return 0;
191191
}
192192

193+
/**
194+
* mii_resolve_flowctrl_fdx
195+
* @lcladv: value of MII ADVERTISE register
196+
* @rmtadv: value of MII LPA register
197+
*
198+
* Resolve full duplex flow control as per IEEE 802.3-2005 table 28B-3
199+
*/
200+
static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
201+
{
202+
u8 cap = 0;
203+
204+
if (lcladv & rmtadv & ADVERTISE_PAUSE_CAP) {
205+
cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
206+
} else if (lcladv & rmtadv & ADVERTISE_PAUSE_ASYM) {
207+
if (lcladv & ADVERTISE_PAUSE_CAP)
208+
cap = FLOW_CTRL_RX;
209+
else if (rmtadv & ADVERTISE_PAUSE_CAP)
210+
cap = FLOW_CTRL_TX;
211+
}
212+
213+
return cap;
214+
}
215+
193216
#endif /* __LINUX_MII_H__ */

0 commit comments

Comments
 (0)