Commit bdb6cfe7 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by David S. Miller

net: mii: add mii_bmcr_encode_fixed()

Add a function to encode a fixed speed/duplex to a BMCR value.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5d1d527c
......@@ -545,4 +545,39 @@ static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
return cap;
}
/**
* mii_bmcr_encode_fixed - encode fixed speed/duplex settings to a BMCR value
* @speed: a SPEED_* value
* @duplex: a DUPLEX_* value
*
* Encode the speed and duplex to a BMCR value. 2500, 1000, 100 and 10 Mbps are
* supported. 2500Mbps is encoded to 1000Mbps. Other speeds are encoded as 10
* Mbps. Unknown duplex values are encoded to half-duplex.
*/
static inline u16 mii_bmcr_encode_fixed(int speed, int duplex)
{
u16 bmcr;
switch (speed) {
case SPEED_2500:
case SPEED_1000:
bmcr = BMCR_SPEED1000;
break;
case SPEED_100:
bmcr = BMCR_SPEED100;
break;
case SPEED_10:
default:
bmcr = BMCR_SPEED10;
break;
}
if (duplex == DUPLEX_FULL)
bmcr |= BMCR_FULLDPLX;
return bmcr;
}
#endif /* __LINUX_MII_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment