diff options
author | Allan, Bruce W <bruce.w.allan@intel.com> | 2012-08-20 00:55:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-23 01:58:27 -0400 |
commit | b32607dd47d456b99f0a16f1c37bc8a0975ffb19 (patch) | |
tree | 74be66275dc26089b3a2c7b73b83d08198cff551 /include | |
parent | 9e67030af367ab524d0856af9e992de241eca3c7 (diff) |
mdio: translation of MMD EEE registers to/from ethtool settings
The helper functions which translate IEEE MDIO Manageable Device (MMD)
Energy-Efficient Ethernet (EEE) registers 3.20, 7.60 and 7.61 to and from
the comparable ethtool supported/advertised settings will be needed by
drivers other than those in PHYLIB (e.g. e1000e in a follow-on patch).
In the same fashion as similar translation functions in linux/mii.h, move
these functions from the PHYLIB core to the linux/mdio.h header file so the
code will not have to be duplicated in each driver needing MMD-to-ethtool
(and vice-versa) translations. The function and some variable names have
been renamed to be more descriptive.
Not tested on the only hardware that currently calls the related functions,
stmmac, because I don't have access to any. Has been compile tested and
the translations have been tested on a locally modified version of e1000e.
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mdio.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 7cccafe50e7b..6c406845f7e2 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h | |||
@@ -377,5 +377,88 @@ static inline void mdio45_ethtool_gset(const struct mdio_if_info *mdio, | |||
377 | extern int mdio_mii_ioctl(const struct mdio_if_info *mdio, | 377 | extern int mdio_mii_ioctl(const struct mdio_if_info *mdio, |
378 | struct mii_ioctl_data *mii_data, int cmd); | 378 | struct mii_ioctl_data *mii_data, int cmd); |
379 | 379 | ||
380 | /** | ||
381 | * mmd_eee_cap_to_ethtool_sup_t | ||
382 | * @eee_cap: value of the MMD EEE Capability register | ||
383 | * | ||
384 | * A small helper function that translates MMD EEE Capability (3.20) bits | ||
385 | * to ethtool supported settings. | ||
386 | */ | ||
387 | static inline u32 mmd_eee_cap_to_ethtool_sup_t(u16 eee_cap) | ||
388 | { | ||
389 | u32 supported = 0; | ||
390 | |||
391 | if (eee_cap & MDIO_EEE_100TX) | ||
392 | supported |= SUPPORTED_100baseT_Full; | ||
393 | if (eee_cap & MDIO_EEE_1000T) | ||
394 | supported |= SUPPORTED_1000baseT_Full; | ||
395 | if (eee_cap & MDIO_EEE_10GT) | ||
396 | supported |= SUPPORTED_10000baseT_Full; | ||
397 | if (eee_cap & MDIO_EEE_1000KX) | ||
398 | supported |= SUPPORTED_1000baseKX_Full; | ||
399 | if (eee_cap & MDIO_EEE_10GKX4) | ||
400 | supported |= SUPPORTED_10000baseKX4_Full; | ||
401 | if (eee_cap & MDIO_EEE_10GKR) | ||
402 | supported |= SUPPORTED_10000baseKR_Full; | ||
403 | |||
404 | return supported; | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * mmd_eee_adv_to_ethtool_adv_t | ||
409 | * @eee_adv: value of the MMD EEE Advertisement/Link Partner Ability registers | ||
410 | * | ||
411 | * A small helper function that translates the MMD EEE Advertisment (7.60) | ||
412 | * and MMD EEE Link Partner Ability (7.61) bits to ethtool advertisement | ||
413 | * settings. | ||
414 | */ | ||
415 | static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv) | ||
416 | { | ||
417 | u32 adv = 0; | ||
418 | |||
419 | if (eee_adv & MDIO_EEE_100TX) | ||
420 | adv |= ADVERTISED_100baseT_Full; | ||
421 | if (eee_adv & MDIO_EEE_1000T) | ||
422 | adv |= ADVERTISED_1000baseT_Full; | ||
423 | if (eee_adv & MDIO_EEE_10GT) | ||
424 | adv |= ADVERTISED_10000baseT_Full; | ||
425 | if (eee_adv & MDIO_EEE_1000KX) | ||
426 | adv |= ADVERTISED_1000baseKX_Full; | ||
427 | if (eee_adv & MDIO_EEE_10GKX4) | ||
428 | adv |= ADVERTISED_10000baseKX4_Full; | ||
429 | if (eee_adv & MDIO_EEE_10GKR) | ||
430 | adv |= ADVERTISED_10000baseKR_Full; | ||
431 | |||
432 | return adv; | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * ethtool_adv_to_mmd_eee_adv_t | ||
437 | * @adv: the ethtool advertisement settings | ||
438 | * | ||
439 | * A small helper function that translates ethtool advertisement settings | ||
440 | * to EEE advertisements for the MMD EEE Advertisement (7.60) and | ||
441 | * MMD EEE Link Partner Ability (7.61) registers. | ||
442 | */ | ||
443 | static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv) | ||
444 | { | ||
445 | u16 reg = 0; | ||
446 | |||
447 | if (adv & ADVERTISED_100baseT_Full) | ||
448 | reg |= MDIO_EEE_100TX; | ||
449 | if (adv & ADVERTISED_1000baseT_Full) | ||
450 | reg |= MDIO_EEE_1000T; | ||
451 | if (adv & ADVERTISED_10000baseT_Full) | ||
452 | reg |= MDIO_EEE_10GT; | ||
453 | if (adv & ADVERTISED_1000baseKX_Full) | ||
454 | reg |= MDIO_EEE_1000KX; | ||
455 | if (adv & ADVERTISED_10000baseKX4_Full) | ||
456 | reg |= MDIO_EEE_10GKX4; | ||
457 | if (adv & ADVERTISED_10000baseKR_Full) | ||
458 | reg |= MDIO_EEE_10GKR; | ||
459 | |||
460 | return reg; | ||
461 | } | ||
462 | |||
380 | #endif /* __KERNEL__ */ | 463 | #endif /* __KERNEL__ */ |
381 | #endif /* __LINUX_MDIO_H__ */ | 464 | #endif /* __LINUX_MDIO_H__ */ |