diff options
Diffstat (limited to 'include/linux/mdio.h')
-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__ */ |