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

net: phy: Add limkmode equivalents to some of the MII ethtool helpers

Add helpers which take a linkmode rather than a u32 ethtool for
advertising settings.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andrew Lunn and committed by
David S. Miller
f954a04e 5f991f7b

+50
+50
include/linux/mii.h
··· 133 133 } 134 134 135 135 /** 136 + * linkmode_adv_to_mii_adv_t 137 + * @advertising: the linkmode advertisement settings 138 + * 139 + * A small helper function that translates linkmode advertisement 140 + * settings to phy autonegotiation advertisements for the 141 + * MII_ADVERTISE register. 142 + */ 143 + static inline u32 linkmode_adv_to_mii_adv_t(unsigned long *advertising) 144 + { 145 + u32 result = 0; 146 + 147 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, advertising)) 148 + result |= ADVERTISE_10HALF; 149 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, advertising)) 150 + result |= ADVERTISE_10FULL; 151 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, advertising)) 152 + result |= ADVERTISE_100HALF; 153 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, advertising)) 154 + result |= ADVERTISE_100FULL; 155 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertising)) 156 + result |= ADVERTISE_PAUSE_CAP; 157 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising)) 158 + result |= ADVERTISE_PAUSE_ASYM; 159 + 160 + return result; 161 + } 162 + 163 + /** 136 164 * mii_adv_to_ethtool_adv_t 137 165 * @adv: value of the MII_ADVERTISE register 138 166 * ··· 202 174 if (ethadv & ADVERTISED_1000baseT_Half) 203 175 result |= ADVERTISE_1000HALF; 204 176 if (ethadv & ADVERTISED_1000baseT_Full) 177 + result |= ADVERTISE_1000FULL; 178 + 179 + return result; 180 + } 181 + 182 + /** 183 + * linkmode_adv_to_mii_ctrl1000_t 184 + * advertising: the linkmode advertisement settings 185 + * 186 + * A small helper function that translates linkmode advertisement 187 + * settings to phy autonegotiation advertisements for the 188 + * MII_CTRL1000 register when in 1000T mode. 189 + */ 190 + static inline u32 linkmode_adv_to_mii_ctrl1000_t(unsigned long *advertising) 191 + { 192 + u32 result = 0; 193 + 194 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, 195 + advertising)) 196 + result |= ADVERTISE_1000HALF; 197 + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, 198 + advertising)) 205 199 result |= ADVERTISE_1000FULL; 206 200 207 201 return result;