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

net: Change mii to ethtool advertisement function names

This patch implements advice by Ben Hutchings to change the mii side of
the function names to look more like the register whose values they
convert. New LPA translation functions have been added as well.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Matt Carlson and committed by
David S. Miller
37f07023 b8ffdbd0

+75 -42
+10 -10
drivers/net/ethernet/broadcom/bnx2.c
··· 2054 2054 2055 2055 if (bp->autoneg & AUTONEG_SPEED) { 2056 2056 u32 adv_reg, adv1000_reg; 2057 - u32 new_adv_reg = 0; 2058 - u32 new_adv1000_reg = 0; 2057 + u32 new_adv = 0; 2058 + u32 new_adv1000 = 0; 2059 2059 2060 2060 bnx2_read_phy(bp, bp->mii_adv, &adv_reg); 2061 2061 adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP | ··· 2064 2064 bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg); 2065 2065 adv1000_reg &= PHY_ALL_1000_SPEED; 2066 2066 2067 - new_adv_reg = ethtool_adv_to_mii_100bt(bp->advertising); 2068 - new_adv_reg |= ADVERTISE_CSMA; 2069 - new_adv_reg |= bnx2_phy_get_pause_adv(bp); 2067 + new_adv = ethtool_adv_to_mii_adv_t(bp->advertising); 2068 + new_adv |= ADVERTISE_CSMA; 2069 + new_adv |= bnx2_phy_get_pause_adv(bp); 2070 2070 2071 - new_adv1000_reg |= ethtool_adv_to_mii_1000T(bp->advertising); 2071 + new_adv1000 |= ethtool_adv_to_mii_ctrl1000_t(bp->advertising); 2072 2072 2073 - if ((adv1000_reg != new_adv1000_reg) || 2074 - (adv_reg != new_adv_reg) || 2073 + if ((adv1000_reg != new_adv1000) || 2074 + (adv_reg != new_adv) || 2075 2075 ((bmcr & BMCR_ANENABLE) == 0)) { 2076 2076 2077 - bnx2_write_phy(bp, bp->mii_adv, new_adv_reg); 2078 - bnx2_write_phy(bp, MII_CTRL1000, new_adv1000_reg); 2077 + bnx2_write_phy(bp, bp->mii_adv, new_adv); 2078 + bnx2_write_phy(bp, MII_CTRL1000, new_adv1000); 2079 2079 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_ANRESTART | 2080 2080 BMCR_ANENABLE); 2081 2081 }
+5 -5
drivers/net/ethernet/broadcom/tg3.c
··· 3594 3594 u32 val, new_adv; 3595 3595 3596 3596 new_adv = ADVERTISE_CSMA; 3597 - new_adv |= ethtool_adv_to_mii_100bt(advertise); 3597 + new_adv |= ethtool_adv_to_mii_adv_t(advertise); 3598 3598 new_adv |= tg3_advert_flowctrl_1000T(flowctrl); 3599 3599 3600 3600 err = tg3_writephy(tp, MII_ADVERTISE, new_adv); ··· 3604 3604 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) 3605 3605 goto done; 3606 3606 3607 - new_adv = ethtool_adv_to_mii_1000T(advertise); 3607 + new_adv = ethtool_adv_to_mii_ctrl1000_t(advertise); 3608 3608 3609 3609 if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 || 3610 3610 tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) ··· 3778 3778 { 3779 3779 u32 adv_reg, all_mask = 0; 3780 3780 3781 - all_mask = ethtool_adv_to_mii_100bt(mask); 3781 + all_mask = ethtool_adv_to_mii_adv_t(mask); 3782 3782 3783 3783 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg)) 3784 3784 return 0; ··· 3789 3789 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { 3790 3790 u32 tg3_ctrl; 3791 3791 3792 - all_mask = ethtool_adv_to_mii_1000T(mask); 3792 + all_mask = ethtool_adv_to_mii_ctrl1000_t(mask); 3793 3793 3794 3794 if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl)) 3795 3795 return 0; ··· 4889 4889 ADVERTISE_SLCT); 4890 4890 4891 4891 newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); 4892 - newadv |= ethtool_adv_to_mii_1000X(tp->link_config.advertising); 4892 + newadv |= ethtool_adv_to_mii_adv_x(tp->link_config.advertising); 4893 4893 4894 4894 if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) { 4895 4895 tg3_writephy(tp, MII_ADVERTISE, newadv);
+2 -2
drivers/net/ethernet/sun/niu.c
··· 1151 1151 supported |= SUPPORTED_1000baseT_Full; 1152 1152 lp->supported = supported; 1153 1153 1154 - advertising = mii_adv_to_ethtool_100bt(advert); 1155 - advertising |= mii_adv_to_ethtool_1000T(ctrl1000); 1154 + advertising = mii_adv_to_ethtool_adv_t(advert); 1155 + advertising |= mii_ctrl1000_to_ethtool_adv_t(ctrl1000); 1156 1156 1157 1157 if (bmcr & BMCR_ANENABLE) { 1158 1158 int neg, neg1000;
+7 -8
drivers/net/mii.c
··· 35 35 36 36 static u32 mii_get_an(struct mii_if_info *mii, u16 addr) 37 37 { 38 - u32 result = 0; 39 38 int advert; 40 39 41 40 advert = mii->mdio_read(mii->dev, mii->phy_id, addr); 42 - if (advert & LPA_LPACK) 43 - result |= ADVERTISED_Autoneg; 44 41 45 - return result | mii_adv_to_ethtool_100bt(advert); 42 + return mii_lpa_to_ethtool_lpa_t(advert); 46 43 } 47 44 48 45 /** ··· 90 93 91 94 ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE); 92 95 if (mii->supports_gmii) 93 - ecmd->advertising |= mii_adv_to_ethtool_1000T(ctrl1000); 96 + ecmd->advertising |= 97 + mii_ctrl1000_to_ethtool_adv_t(ctrl1000); 94 98 95 99 if (bmsr & BMSR_ANEGCOMPLETE) { 96 100 ecmd->lp_advertising = mii_get_an(mii, MII_LPA); 97 101 ecmd->lp_advertising |= 98 - mii_lpa_to_ethtool_1000T(stat1000); 102 + mii_stat1000_to_ethtool_lpa_t(stat1000); 99 103 } else { 100 104 ecmd->lp_advertising = 0; 101 105 } ··· 184 186 advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000); 185 187 tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL); 186 188 } 187 - tmp |= ethtool_adv_to_mii_100bt(ecmd->advertising); 189 + tmp |= ethtool_adv_to_mii_adv_t(ecmd->advertising); 188 190 189 191 if (mii->supports_gmii) 190 - tmp2 |= ethtool_adv_to_mii_1000T(ecmd->advertising); 192 + tmp2 |= 193 + ethtool_adv_to_mii_ctrl1000_t(ecmd->advertising); 191 194 if (advert != tmp) { 192 195 mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp); 193 196 mii->advertising = tmp;
+2 -2
drivers/net/phy/phy_device.c
··· 565 565 566 566 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | 567 567 ADVERTISE_PAUSE_ASYM); 568 - adv |= ethtool_adv_to_mii_100bt(advertise); 568 + adv |= ethtool_adv_to_mii_adv_t(advertise); 569 569 570 570 if (adv != oldadv) { 571 571 err = phy_write(phydev, MII_ADVERTISE, adv); ··· 584 584 return adv; 585 585 586 586 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); 587 - adv |= ethtool_adv_to_mii_1000T(advertise); 587 + adv |= ethtool_adv_to_mii_ctrl1000_t(advertise); 588 588 589 589 if (adv != oldadv) { 590 590 err = phy_write(phydev, MII_CTRL1000, adv);
+49 -15
include/linux/mii.h
··· 241 241 } 242 242 243 243 /** 244 - * ethtool_adv_to_mii_100bt 244 + * ethtool_adv_to_mii_adv_t 245 245 * @ethadv: the ethtool advertisement settings 246 246 * 247 247 * A small helper function that translates ethtool advertisement 248 248 * settings to phy autonegotiation advertisements for the 249 249 * MII_ADVERTISE register. 250 250 */ 251 - static inline u32 ethtool_adv_to_mii_100bt(u32 ethadv) 251 + static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv) 252 252 { 253 253 u32 result = 0; 254 254 ··· 269 269 } 270 270 271 271 /** 272 - * mii_adv_to_ethtool_100bt 272 + * mii_adv_to_ethtool_adv_t 273 273 * @adv: value of the MII_ADVERTISE register 274 274 * 275 275 * A small helper function that translates MII_ADVERTISE bits 276 276 * to ethtool advertisement settings. 277 277 */ 278 - static inline u32 mii_adv_to_ethtool_100bt(u32 adv) 278 + static inline u32 mii_adv_to_ethtool_adv_t(u32 adv) 279 279 { 280 280 u32 result = 0; 281 281 ··· 296 296 } 297 297 298 298 /** 299 - * ethtool_adv_to_mii_1000T 299 + * ethtool_adv_to_mii_ctrl1000_t 300 300 * @ethadv: the ethtool advertisement settings 301 301 * 302 302 * A small helper function that translates ethtool advertisement 303 303 * settings to phy autonegotiation advertisements for the 304 304 * MII_CTRL1000 register when in 1000T mode. 305 305 */ 306 - static inline u32 ethtool_adv_to_mii_1000T(u32 ethadv) 306 + static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv) 307 307 { 308 308 u32 result = 0; 309 309 ··· 316 316 } 317 317 318 318 /** 319 - * mii_adv_to_ethtool_1000T 319 + * mii_ctrl1000_to_ethtool_adv_t 320 320 * @adv: value of the MII_CTRL1000 register 321 321 * 322 322 * A small helper function that translates MII_CTRL1000 323 323 * bits, when in 1000Base-T mode, to ethtool 324 324 * advertisement settings. 325 325 */ 326 - static inline u32 mii_adv_to_ethtool_1000T(u32 adv) 326 + static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv) 327 327 { 328 328 u32 result = 0; 329 329 ··· 335 335 return result; 336 336 } 337 337 338 - #define mii_lpa_to_ethtool_100bt(lpa) mii_adv_to_ethtool_100bt(lpa) 338 + /** 339 + * mii_lpa_to_ethtool_lpa_t 340 + * @adv: value of the MII_LPA register 341 + * 342 + * A small helper function that translates MII_LPA 343 + * bits, when in 1000Base-T mode, to ethtool 344 + * LP advertisement settings. 345 + */ 346 + static inline u32 mii_lpa_to_ethtool_lpa_t(u32 lpa) 347 + { 348 + u32 result = 0; 349 + 350 + if (lpa & LPA_LPACK) 351 + result |= ADVERTISED_Autoneg; 352 + 353 + return result | mii_adv_to_ethtool_adv_t(lpa); 354 + } 339 355 340 356 /** 341 - * mii_lpa_to_ethtool_1000T 357 + * mii_stat1000_to_ethtool_lpa_t 342 358 * @adv: value of the MII_STAT1000 register 343 359 * 344 360 * A small helper function that translates MII_STAT1000 345 361 * bits, when in 1000Base-T mode, to ethtool 346 362 * advertisement settings. 347 363 */ 348 - static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa) 364 + static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa) 349 365 { 350 366 u32 result = 0; 351 367 ··· 374 358 } 375 359 376 360 /** 377 - * ethtool_adv_to_mii_1000X 361 + * ethtool_adv_to_mii_adv_x 378 362 * @ethadv: the ethtool advertisement settings 379 363 * 380 364 * A small helper function that translates ethtool advertisement 381 365 * settings to phy autonegotiation advertisements for the 382 366 * MII_CTRL1000 register when in 1000Base-X mode. 383 367 */ 384 - static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv) 368 + static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv) 385 369 { 386 370 u32 result = 0; 387 371 ··· 398 382 } 399 383 400 384 /** 401 - * mii_adv_to_ethtool_1000X 385 + * mii_adv_to_ethtool_adv_x 402 386 * @adv: value of the MII_CTRL1000 register 403 387 * 404 388 * A small helper function that translates MII_CTRL1000 405 389 * bits, when in 1000Base-X mode, to ethtool 406 390 * advertisement settings. 407 391 */ 408 - static inline u32 mii_adv_to_ethtool_1000X(u32 adv) 392 + static inline u32 mii_adv_to_ethtool_adv_x(u32 adv) 409 393 { 410 394 u32 result = 0; 411 395 ··· 419 403 result |= ADVERTISED_Asym_Pause; 420 404 421 405 return result; 406 + } 407 + 408 + /** 409 + * mii_lpa_to_ethtool_lpa_x 410 + * @adv: value of the MII_LPA register 411 + * 412 + * A small helper function that translates MII_LPA 413 + * bits, when in 1000Base-X mode, to ethtool 414 + * LP advertisement settings. 415 + */ 416 + static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa) 417 + { 418 + u32 result = 0; 419 + 420 + if (lpa & LPA_LPACK) 421 + result |= ADVERTISED_Autoneg; 422 + 423 + return result | mii_adv_to_ethtool_adv_x(lpa); 422 424 } 423 425 424 426 /**