aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-11-17 09:30:55 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-21 15:27:19 -0500
commit37f07023d30708b5da091fe6d6be9b60783c6d82 (patch)
treee4f576abd841cdeddc6cbdc9da6b083277784295
parentb8ffdbd05f8692cdadccd04464271e48b1e8d439 (diff)
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>
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c20
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c10
-rw-r--r--drivers/net/ethernet/sun/niu.c4
-rw-r--r--drivers/net/mii.c15
-rw-r--r--drivers/net/phy/phy_device.c4
-rw-r--r--include/linux/mii.h64
6 files changed, 75 insertions, 42 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 66f6e7f654c..83d8cefba8c 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -2054,8 +2054,8 @@ __acquires(&bp->phy_lock)
2054 2054
2055 if (bp->autoneg & AUTONEG_SPEED) { 2055 if (bp->autoneg & AUTONEG_SPEED) {
2056 u32 adv_reg, adv1000_reg; 2056 u32 adv_reg, adv1000_reg;
2057 u32 new_adv_reg = 0; 2057 u32 new_adv = 0;
2058 u32 new_adv1000_reg = 0; 2058 u32 new_adv1000 = 0;
2059 2059
2060 bnx2_read_phy(bp, bp->mii_adv, &adv_reg); 2060 bnx2_read_phy(bp, bp->mii_adv, &adv_reg);
2061 adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP | 2061 adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP |
@@ -2064,18 +2064,18 @@ __acquires(&bp->phy_lock)
2064 bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg); 2064 bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
2065 adv1000_reg &= PHY_ALL_1000_SPEED; 2065 adv1000_reg &= PHY_ALL_1000_SPEED;
2066 2066
2067 new_adv_reg = ethtool_adv_to_mii_100bt(bp->advertising); 2067 new_adv = ethtool_adv_to_mii_adv_t(bp->advertising);
2068 new_adv_reg |= ADVERTISE_CSMA; 2068 new_adv |= ADVERTISE_CSMA;
2069 new_adv_reg |= bnx2_phy_get_pause_adv(bp); 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) || 2073 if ((adv1000_reg != new_adv1000) ||
2074 (adv_reg != new_adv_reg) || 2074 (adv_reg != new_adv) ||
2075 ((bmcr & BMCR_ANENABLE) == 0)) { 2075 ((bmcr & BMCR_ANENABLE) == 0)) {
2076 2076
2077 bnx2_write_phy(bp, bp->mii_adv, new_adv_reg); 2077 bnx2_write_phy(bp, bp->mii_adv, new_adv);
2078 bnx2_write_phy(bp, MII_CTRL1000, new_adv1000_reg); 2078 bnx2_write_phy(bp, MII_CTRL1000, new_adv1000);
2079 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_ANRESTART | 2079 bnx2_write_phy(bp, bp->mii_bmcr, BMCR_ANRESTART |
2080 BMCR_ANENABLE); 2080 BMCR_ANENABLE);
2081 } 2081 }
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 024ca1d4d02..47c0e3a1f58 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -3594,7 +3594,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
3594 u32 val, new_adv; 3594 u32 val, new_adv;
3595 3595
3596 new_adv = ADVERTISE_CSMA; 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 new_adv |= tg3_advert_flowctrl_1000T(flowctrl); 3598 new_adv |= tg3_advert_flowctrl_1000T(flowctrl);
3599 3599
3600 err = tg3_writephy(tp, MII_ADVERTISE, new_adv); 3600 err = tg3_writephy(tp, MII_ADVERTISE, new_adv);
@@ -3604,7 +3604,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
3604 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) 3604 if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
3605 goto done; 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 if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 || 3609 if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
3610 tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) 3610 tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)
@@ -3778,7 +3778,7 @@ static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
3778{ 3778{
3779 u32 adv_reg, all_mask = 0; 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 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg)) 3783 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
3784 return 0; 3784 return 0;
@@ -3789,7 +3789,7 @@ static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
3789 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) { 3789 if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) {
3790 u32 tg3_ctrl; 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 if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl)) 3794 if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl))
3795 return 0; 3795 return 0;
@@ -4889,7 +4889,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
4889 ADVERTISE_SLCT); 4889 ADVERTISE_SLCT);
4890 4890
4891 newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl); 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 if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) { 4894 if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) {
4895 tg3_writephy(tp, MII_ADVERTISE, newadv); 4895 tg3_writephy(tp, MII_ADVERTISE, newadv);
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 9997be52508..680b107fdab 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1151,8 +1151,8 @@ static int link_status_mii(struct niu *np, int *link_up_p)
1151 supported |= SUPPORTED_1000baseT_Full; 1151 supported |= SUPPORTED_1000baseT_Full;
1152 lp->supported = supported; 1152 lp->supported = supported;
1153 1153
1154 advertising = mii_adv_to_ethtool_100bt(advert); 1154 advertising = mii_adv_to_ethtool_adv_t(advert);
1155 advertising |= mii_adv_to_ethtool_1000T(ctrl1000); 1155 advertising |= mii_ctrl1000_to_ethtool_adv_t(ctrl1000);
1156 1156
1157 if (bmcr & BMCR_ANENABLE) { 1157 if (bmcr & BMCR_ANENABLE) {
1158 int neg, neg1000; 1158 int neg, neg1000;
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index d0a29627271..c70c2332d15 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -35,14 +35,11 @@
35 35
36static u32 mii_get_an(struct mii_if_info *mii, u16 addr) 36static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
37{ 37{
38 u32 result = 0;
39 int advert; 38 int advert;
40 39
41 advert = mii->mdio_read(mii->dev, mii->phy_id, addr); 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/**
@@ -93,12 +90,13 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
93 90
94 ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE); 91 ecmd->advertising |= mii_get_an(mii, MII_ADVERTISE);
95 if (mii->supports_gmii) 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 if (bmsr & BMSR_ANEGCOMPLETE) { 96 if (bmsr & BMSR_ANEGCOMPLETE) {
99 ecmd->lp_advertising = mii_get_an(mii, MII_LPA); 97 ecmd->lp_advertising = mii_get_an(mii, MII_LPA);
100 ecmd->lp_advertising |= 98 ecmd->lp_advertising |=
101 mii_lpa_to_ethtool_1000T(stat1000); 99 mii_stat1000_to_ethtool_lpa_t(stat1000);
102 } else { 100 } else {
103 ecmd->lp_advertising = 0; 101 ecmd->lp_advertising = 0;
104 } 102 }
@@ -186,10 +184,11 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
186 advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000); 184 advert2 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
187 tmp2 = advert2 & ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL); 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 if (mii->supports_gmii) 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 if (advert != tmp) { 192 if (advert != tmp) {
194 mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp); 193 mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
195 mii->advertising = tmp; 194 mii->advertising = tmp;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index edb905f8011..f320f466f03 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -565,7 +565,7 @@ static int genphy_config_advert(struct phy_device *phydev)
565 565
566 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | 566 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP |
567 ADVERTISE_PAUSE_ASYM); 567 ADVERTISE_PAUSE_ASYM);
568 adv |= ethtool_adv_to_mii_100bt(advertise); 568 adv |= ethtool_adv_to_mii_adv_t(advertise);
569 569
570 if (adv != oldadv) { 570 if (adv != oldadv) {
571 err = phy_write(phydev, MII_ADVERTISE, adv); 571 err = phy_write(phydev, MII_ADVERTISE, adv);
@@ -584,7 +584,7 @@ static int genphy_config_advert(struct phy_device *phydev)
584 return adv; 584 return adv;
585 585
586 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); 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 if (adv != oldadv) { 589 if (adv != oldadv) {
590 err = phy_write(phydev, MII_CTRL1000, adv); 590 err = phy_write(phydev, MII_CTRL1000, adv);
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 6697b911201..2783eca629a 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -241,14 +241,14 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
241} 241}
242 242
243/** 243/**
244 * ethtool_adv_to_mii_100bt 244 * ethtool_adv_to_mii_adv_t
245 * @ethadv: the ethtool advertisement settings 245 * @ethadv: the ethtool advertisement settings
246 * 246 *
247 * A small helper function that translates ethtool advertisement 247 * A small helper function that translates ethtool advertisement
248 * settings to phy autonegotiation advertisements for the 248 * settings to phy autonegotiation advertisements for the
249 * MII_ADVERTISE register. 249 * MII_ADVERTISE register.
250 */ 250 */
251static inline u32 ethtool_adv_to_mii_100bt(u32 ethadv) 251static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
252{ 252{
253 u32 result = 0; 253 u32 result = 0;
254 254
@@ -269,13 +269,13 @@ static inline u32 ethtool_adv_to_mii_100bt(u32 ethadv)
269} 269}
270 270
271/** 271/**
272 * mii_adv_to_ethtool_100bt 272 * mii_adv_to_ethtool_adv_t
273 * @adv: value of the MII_ADVERTISE register 273 * @adv: value of the MII_ADVERTISE register
274 * 274 *
275 * A small helper function that translates MII_ADVERTISE bits 275 * A small helper function that translates MII_ADVERTISE bits
276 * to ethtool advertisement settings. 276 * to ethtool advertisement settings.
277 */ 277 */
278static inline u32 mii_adv_to_ethtool_100bt(u32 adv) 278static inline u32 mii_adv_to_ethtool_adv_t(u32 adv)
279{ 279{
280 u32 result = 0; 280 u32 result = 0;
281 281
@@ -296,14 +296,14 @@ static inline u32 mii_adv_to_ethtool_100bt(u32 adv)
296} 296}
297 297
298/** 298/**
299 * ethtool_adv_to_mii_1000T 299 * ethtool_adv_to_mii_ctrl1000_t
300 * @ethadv: the ethtool advertisement settings 300 * @ethadv: the ethtool advertisement settings
301 * 301 *
302 * A small helper function that translates ethtool advertisement 302 * A small helper function that translates ethtool advertisement
303 * settings to phy autonegotiation advertisements for the 303 * settings to phy autonegotiation advertisements for the
304 * MII_CTRL1000 register when in 1000T mode. 304 * MII_CTRL1000 register when in 1000T mode.
305 */ 305 */
306static inline u32 ethtool_adv_to_mii_1000T(u32 ethadv) 306static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
307{ 307{
308 u32 result = 0; 308 u32 result = 0;
309 309
@@ -316,14 +316,14 @@ static inline u32 ethtool_adv_to_mii_1000T(u32 ethadv)
316} 316}
317 317
318/** 318/**
319 * mii_adv_to_ethtool_1000T 319 * mii_ctrl1000_to_ethtool_adv_t
320 * @adv: value of the MII_CTRL1000 register 320 * @adv: value of the MII_CTRL1000 register
321 * 321 *
322 * A small helper function that translates MII_CTRL1000 322 * A small helper function that translates MII_CTRL1000
323 * bits, when in 1000Base-T mode, to ethtool 323 * bits, when in 1000Base-T mode, to ethtool
324 * advertisement settings. 324 * advertisement settings.
325 */ 325 */
326static inline u32 mii_adv_to_ethtool_1000T(u32 adv) 326static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv)
327{ 327{
328 u32 result = 0; 328 u32 result = 0;
329 329
@@ -335,17 +335,33 @@ static inline u32 mii_adv_to_ethtool_1000T(u32 adv)
335 return result; 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 */
346static 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 * @adv: value of the MII_STAT1000 register 358 * @adv: value of the MII_STAT1000 register
343 * 359 *
344 * A small helper function that translates MII_STAT1000 360 * A small helper function that translates MII_STAT1000
345 * bits, when in 1000Base-T mode, to ethtool 361 * bits, when in 1000Base-T mode, to ethtool
346 * advertisement settings. 362 * advertisement settings.
347 */ 363 */
348static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa) 364static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa)
349{ 365{
350 u32 result = 0; 366 u32 result = 0;
351 367
@@ -358,14 +374,14 @@ static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa)
358} 374}
359 375
360/** 376/**
361 * ethtool_adv_to_mii_1000X 377 * ethtool_adv_to_mii_adv_x
362 * @ethadv: the ethtool advertisement settings 378 * @ethadv: the ethtool advertisement settings
363 * 379 *
364 * A small helper function that translates ethtool advertisement 380 * A small helper function that translates ethtool advertisement
365 * settings to phy autonegotiation advertisements for the 381 * settings to phy autonegotiation advertisements for the
366 * MII_CTRL1000 register when in 1000Base-X mode. 382 * MII_CTRL1000 register when in 1000Base-X mode.
367 */ 383 */
368static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv) 384static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
369{ 385{
370 u32 result = 0; 386 u32 result = 0;
371 387
@@ -382,14 +398,14 @@ static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv)
382} 398}
383 399
384/** 400/**
385 * mii_adv_to_ethtool_1000X 401 * mii_adv_to_ethtool_adv_x
386 * @adv: value of the MII_CTRL1000 register 402 * @adv: value of the MII_CTRL1000 register
387 * 403 *
388 * A small helper function that translates MII_CTRL1000 404 * A small helper function that translates MII_CTRL1000
389 * bits, when in 1000Base-X mode, to ethtool 405 * bits, when in 1000Base-X mode, to ethtool
390 * advertisement settings. 406 * advertisement settings.
391 */ 407 */
392static inline u32 mii_adv_to_ethtool_1000X(u32 adv) 408static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
393{ 409{
394 u32 result = 0; 410 u32 result = 0;
395 411
@@ -406,6 +422,24 @@ static inline u32 mii_adv_to_ethtool_1000X(u32 adv)
406} 422}
407 423
408/** 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 */
432static 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);
440}
441
442/**
409 * mii_advertise_flowctrl - get flow control advertisement flags 443 * mii_advertise_flowctrl - get flow control advertisement flags
410 * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both) 444 * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
411 */ 445 */