diff options
author | David S. Miller <davem@davemloft.net> | 2020-05-21 17:18:00 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-21 17:18:00 -0700 |
commit | 2a330b533462bea0967e723ff12787daa5a608f8 (patch) | |
tree | ff7397ca188b6e6ffd74a1c272aaffcc3d09fa51 /drivers | |
parent | b0301a5a288d804374b194e755180967ff7a295b (diff) | |
parent | 68ff5e14759e7ac1aac7bc75ac5b935e390fa2b3 (diff) | |
download | linux-2a330b533462bea0967e723ff12787daa5a608f8.tar.gz linux-2a330b533462bea0967e723ff12787daa5a608f8.tar.bz2 linux-2a330b533462bea0967e723ff12787daa5a608f8.zip |
Merge branch 'provide-KAPI-for-SQI'
Oleksij Rempel says:
====================
provide KAPI for SQI
This patches are extending ethtool netlink interface to export Signal
Quality Index (SQI). SQI provided by 100Base-T1 PHYs and can be used for
cable diagnostic. Compared to a typical cable tests, this value can be
only used after link is established.
changes v3:
- rename __ethtool_get_sqi* to linkstate_get_sqi*. And move this
functions to the net/ethtool/linkstate.c
- protect linkstate_get_sqi* with locking
changes v2:
- use u32 instead of u8 for SQI
- add SQI_MAX field and callbacks
- some style fixes in the rst.
- do not convert index to shifted index.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/phy/nxp-tja11xx.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index 0d4f9067ca71..1e79c30ca81a 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -53,6 +53,8 @@ #define MII_COMMSTAT 23 #define MII_COMMSTAT_LINK_UP BIT(15) +#define MII_COMMSTAT_SQI_STATE GENMASK(7, 5) +#define MII_COMMSTAT_SQI_MAX 7 #define MII_GENSTAT 24 #define MII_GENSTAT_PLL_LOCKED BIT(14) @@ -329,6 +331,22 @@ static int tja11xx_read_status(struct phy_device *phydev) return 0; } +static int tja11xx_get_sqi(struct phy_device *phydev) +{ + int ret; + + ret = phy_read(phydev, MII_COMMSTAT); + if (ret < 0) + return ret; + + return FIELD_GET(MII_COMMSTAT_SQI_STATE, ret); +} + +static int tja11xx_get_sqi_max(struct phy_device *phydev) +{ + return MII_COMMSTAT_SQI_MAX; +} + static int tja11xx_get_sset_count(struct phy_device *phydev) { return ARRAY_SIZE(tja11xx_hw_stats); @@ -683,6 +701,8 @@ static struct phy_driver tja11xx_driver[] = { .config_aneg = tja11xx_config_aneg, .config_init = tja11xx_config_init, .read_status = tja11xx_read_status, + .get_sqi = tja11xx_get_sqi, + .get_sqi_max = tja11xx_get_sqi_max, .suspend = genphy_suspend, .resume = genphy_resume, .set_loopback = genphy_loopback, @@ -699,6 +719,8 @@ static struct phy_driver tja11xx_driver[] = { .config_aneg = tja11xx_config_aneg, .config_init = tja11xx_config_init, .read_status = tja11xx_read_status, + .get_sqi = tja11xx_get_sqi, + .get_sqi_max = tja11xx_get_sqi_max, .suspend = genphy_suspend, .resume = genphy_resume, .set_loopback = genphy_loopback, @@ -715,6 +737,8 @@ static struct phy_driver tja11xx_driver[] = { .config_aneg = tja11xx_config_aneg, .config_init = tja11xx_config_init, .read_status = tja11xx_read_status, + .get_sqi = tja11xx_get_sqi, + .get_sqi_max = tja11xx_get_sqi_max, .match_phy_device = tja1102_p0_match_phy_device, .suspend = genphy_suspend, .resume = genphy_resume, @@ -736,6 +760,8 @@ static struct phy_driver tja11xx_driver[] = { .config_aneg = tja11xx_config_aneg, .config_init = tja11xx_config_init, .read_status = tja11xx_read_status, + .get_sqi = tja11xx_get_sqi, + .get_sqi_max = tja11xx_get_sqi_max, .match_phy_device = tja1102_p1_match_phy_device, .suspend = genphy_suspend, .resume = genphy_resume, |