1 From bdb6cfe7512f7a214815a3092f0be50963dcacbc Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Sat, 18 Jun 2022 11:28:32 +0100
4 Subject: [PATCH] net: mii: add mii_bmcr_encode_fixed()
6 Add a function to encode a fixed speed/duplex to a BMCR value.
8 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
9 Signed-off-by: David S. Miller <davem@davemloft.net>
11 include/linux/mii.h | 35 +++++++++++++++++++++++++++++++++++
12 1 file changed, 35 insertions(+)
14 --- a/include/linux/mii.h
15 +++ b/include/linux/mii.h
16 @@ -595,4 +595,39 @@ static inline u8 mii_resolve_flowctrl_fd
21 + * mii_bmcr_encode_fixed - encode fixed speed/duplex settings to a BMCR value
22 + * @speed: a SPEED_* value
23 + * @duplex: a DUPLEX_* value
25 + * Encode the speed and duplex to a BMCR value. 2500, 1000, 100 and 10 Mbps are
26 + * supported. 2500Mbps is encoded to 1000Mbps. Other speeds are encoded as 10
27 + * Mbps. Unknown duplex values are encoded to half-duplex.
29 +static inline u16 mii_bmcr_encode_fixed(int speed, int duplex)
36 + bmcr = BMCR_SPEED1000;
40 + bmcr = BMCR_SPEED100;
45 + bmcr = BMCR_SPEED10;
49 + if (duplex == DUPLEX_FULL)
50 + bmcr |= BMCR_FULLDPLX;
55 #endif /* __LINUX_MII_H__ */