Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mdio: add clause 73 to ethtool conversion helper

Add a helper to convert a clause 73 advertisement to an ethtool bitmap.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
e9261467 41a45ea4

+63
+39
include/linux/mdio.h
··· 486 486 return result; 487 487 } 488 488 489 + /** 490 + * mii_c73_mod_linkmode - convert a Clause 73 advertisement to linkmodes 491 + * @adv: linkmode advertisement setting 492 + * @lpa: array of three u16s containing the advertisement 493 + * 494 + * Convert an IEEE 802.3 Clause 73 advertisement to ethtool link modes. 495 + */ 496 + static inline void mii_c73_mod_linkmode(unsigned long *adv, u16 *lpa) 497 + { 498 + linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, 499 + adv, lpa[0] & MDIO_AN_C73_0_PAUSE); 500 + linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, 501 + adv, lpa[0] & MDIO_AN_C73_0_ASM_DIR); 502 + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, 503 + adv, lpa[1] & MDIO_AN_C73_1_1000BASE_KX); 504 + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, 505 + adv, lpa[1] & MDIO_AN_C73_1_10GBASE_KX4); 506 + linkmode_mod_bit(ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, 507 + adv, lpa[1] & MDIO_AN_C73_1_40GBASE_KR4); 508 + linkmode_mod_bit(ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, 509 + adv, lpa[1] & MDIO_AN_C73_1_40GBASE_CR4); 510 + /* 100GBASE_CR10 and 100GBASE_KP4 not implemented */ 511 + linkmode_mod_bit(ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, 512 + adv, lpa[1] & MDIO_AN_C73_1_100GBASE_KR4); 513 + linkmode_mod_bit(ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, 514 + adv, lpa[1] & MDIO_AN_C73_1_100GBASE_CR4); 515 + /* 25GBASE_R_S not implemented */ 516 + /* The 25GBASE_R bit can be used for 25Gbase KR or CR modes */ 517 + linkmode_mod_bit(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, 518 + adv, lpa[1] & MDIO_AN_C73_1_25GBASE_R); 519 + linkmode_mod_bit(ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, 520 + adv, lpa[1] & MDIO_AN_C73_1_25GBASE_R); 521 + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, 522 + adv, lpa[1] & MDIO_AN_C73_1_10GBASE_KR); 523 + linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, 524 + adv, lpa[2] & MDIO_AN_C73_2_2500BASE_KX); 525 + /* 5GBASE_KR not implemented */ 526 + } 527 + 489 528 int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum); 490 529 int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); 491 530 int __mdiobus_modify_changed(struct mii_bus *bus, int addr, u32 regnum,
+24
include/uapi/linux/mdio.h
··· 231 231 #define MDIO_PMA_EXTABLE_BT1 0x0800 /* BASE-T1 ability */ 232 232 #define MDIO_PMA_EXTABLE_NBT 0x4000 /* 2.5/5GBASE-T ability */ 233 233 234 + /* AN Clause 73 linkword */ 235 + #define MDIO_AN_C73_0_S_MASK GENMASK(4, 0) 236 + #define MDIO_AN_C73_0_E_MASK GENMASK(9, 5) 237 + #define MDIO_AN_C73_0_PAUSE BIT(10) 238 + #define MDIO_AN_C73_0_ASM_DIR BIT(11) 239 + #define MDIO_AN_C73_0_C2 BIT(12) 240 + #define MDIO_AN_C73_0_RF BIT(13) 241 + #define MDIO_AN_C73_0_ACK BIT(14) 242 + #define MDIO_AN_C73_0_NP BIT(15) 243 + #define MDIO_AN_C73_1_T_MASK GENMASK(4, 0) 244 + #define MDIO_AN_C73_1_1000BASE_KX BIT(5) 245 + #define MDIO_AN_C73_1_10GBASE_KX4 BIT(6) 246 + #define MDIO_AN_C73_1_10GBASE_KR BIT(7) 247 + #define MDIO_AN_C73_1_40GBASE_KR4 BIT(8) 248 + #define MDIO_AN_C73_1_40GBASE_CR4 BIT(9) 249 + #define MDIO_AN_C73_1_100GBASE_CR10 BIT(10) 250 + #define MDIO_AN_C73_1_100GBASE_KP4 BIT(11) 251 + #define MDIO_AN_C73_1_100GBASE_KR4 BIT(12) 252 + #define MDIO_AN_C73_1_100GBASE_CR4 BIT(13) 253 + #define MDIO_AN_C73_1_25GBASE_R_S BIT(14) 254 + #define MDIO_AN_C73_1_25GBASE_R BIT(15) 255 + #define MDIO_AN_C73_2_2500BASE_KX BIT(0) 256 + #define MDIO_AN_C73_2_5GBASE_KR BIT(1) 257 + 234 258 /* PHY XGXS lane state register. */ 235 259 #define MDIO_PHYXS_LNSTAT_SYNC0 0x0001 236 260 #define MDIO_PHYXS_LNSTAT_SYNC1 0x0002