Commit 37f07023d30708b5da091fe6d6be9b60783c6d82

Authored by Matt Carlson
Committed by David S. Miller
1 parent b8ffdbd05f

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>

Showing 6 changed files with 75 additions and 42 deletions Side-by-side Diff

drivers/net/ethernet/broadcom/bnx2.c
... ... @@ -2054,8 +2054,8 @@
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 |
2062 2062  
2063 2063  
2064 2064  
... ... @@ -2064,18 +2064,18 @@
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 }
drivers/net/ethernet/broadcom/tg3.c
... ... @@ -3594,7 +3594,7 @@
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,7 +3604,7 @@
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,7 +3778,7 @@
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,7 +3789,7 @@
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,7 +4889,7 @@
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);
drivers/net/ethernet/sun/niu.c
... ... @@ -1151,8 +1151,8 @@
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;
... ... @@ -35,14 +35,11 @@
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 /**
49 46  
... ... @@ -93,12 +90,13 @@
93 90  
94 91 ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE);
95 92 if (mii->supports_gmii)
96   - ecmd->advertising |= mii_adv_to_ethtool_1000T(ctrl1000);
  93 + ecmd->advertising |=
  94 + mii_ctrl1000_to_ethtool_adv_t(ctrl1000);
97 95  
98 96 if (bmsr & BMSR_ANEGCOMPLETE) {
99 97 ecmd->lp_advertising = mii_get_an(mii, MII_LPA);
100 98 ecmd->lp_advertising |=
101   - mii_lpa_to_ethtool_1000T(stat1000);
  99 + mii_stat1000_to_ethtool_lpa_t(stat1000);
102 100 } else {
103 101 ecmd->lp_advertising = 0;
104 102 }
105 103  
... ... @@ -186,10 +184,11 @@
186 184 advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
187 185 tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
188 186 }
189   - tmp |= ethtool_adv_to_mii_100bt(ecmd->advertising);
  187 + tmp |= ethtool_adv_to_mii_adv_t(ecmd->advertising);
190 188  
191 189 if (mii->supports_gmii)
192   - tmp2 |= ethtool_adv_to_mii_1000T(ecmd->advertising);
  190 + tmp2 |=
  191 + ethtool_adv_to_mii_ctrl1000_t(ecmd->advertising);
193 192 if (advert != tmp) {
194 193 mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
195 194 mii->advertising = tmp;
drivers/net/phy/phy_device.c
... ... @@ -565,7 +565,7 @@
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,7 +584,7 @@
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);
... ... @@ -241,14 +241,14 @@
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  
255 255  
... ... @@ -269,13 +269,13 @@
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  
282 282  
... ... @@ -296,14 +296,14 @@
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  
310 310  
... ... @@ -316,14 +316,14 @@
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  
330 330  
331 331  
332 332  
... ... @@ -335,17 +335,33 @@
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;
339 349  
  350 + if (lpa & LPA_LPACK)
  351 + result |= ADVERTISED_Autoneg;
  352 +
  353 + return result | mii_adv_to_ethtool_adv_t(lpa);
  354 +}
  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  
352 368  
... ... @@ -358,14 +374,14 @@
358 374 }
359 375  
360 376 /**
361   - * ethtool_adv_to_mii_1000X
  377 + * ethtool_adv_to_mii_adv_x
362 378 * @ethadv: the ethtool advertisement settings
363 379 *
364 380 * A small helper function that translates ethtool advertisement
365 381 * settings to phy autonegotiation advertisements for the
366 382 * MII_CTRL1000 register when in 1000Base-X mode.
367 383 */
368   -static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv)
  384 +static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
369 385 {
370 386 u32 result = 0;
371 387  
372 388  
... ... @@ -382,14 +398,14 @@
382 398 }
383 399  
384 400 /**
385   - * mii_adv_to_ethtool_1000X
  401 + * mii_adv_to_ethtool_adv_x
386 402 * @adv: value of the MII_CTRL1000 register
387 403 *
388 404 * A small helper function that translates MII_CTRL1000
389 405 * bits, when in 1000Base-X mode, to ethtool
390 406 * advertisement settings.
391 407 */
392   -static inline u32 mii_adv_to_ethtool_1000X(u32 adv)
  408 +static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
393 409 {
394 410 u32 result = 0;
395 411  
... ... @@ -403,6 +419,24 @@
403 419 result |= ADVERTISED_Asym_Pause;
404 420  
405 421 return result;
  422 +}
  423 +
  424 +/**
  425 + * mii_lpa_to_ethtool_lpa_x
  426 + * @adv: value of the MII_LPA register
  427 + *
  428 + * A small helper function that translates MII_LPA
  429 + * bits, when in 1000Base-X mode, to ethtool
  430 + * LP advertisement settings.
  431 + */
  432 +static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
  433 +{
  434 + u32 result = 0;
  435 +
  436 + if (lpa & LPA_LPACK)
  437 + result |= ADVERTISED_Autoneg;
  438 +
  439 + return result | mii_adv_to_ethtool_adv_x(lpa);
406 440 }
407 441  
408 442 /**