ethtool: Add support for specifying information source in cable test results

Enhance the ethtool cable test interface by introducing the ability to
specify the source of the diagnostic information for cable test results.
This is particularly useful for PHYs that offer multiple diagnostic
methods, such as Time Domain Reflectometry (TDR) and Active Link Cable
Diagnostic (ALCD).

Key changes:
- Added `ethnl_cable_test_result_with_src` and
  `ethnl_cable_test_fault_length_with_src` functions to allow specifying
  the information source when reporting cable test results.
- Updated existing `ethnl_cable_test_result` and
  `ethnl_cable_test_fault_length` functions to use TDR as the default
  source, ensuring backward compatibility.
- Modified the UAPI to support these new attributes, enabling drivers to
  provide more detailed diagnostic information.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240822120703.1393130-3-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Oleksij Rempel 2024-08-22 14:07:02 +02:00 committed by Jakub Kicinski
parent abcd3026dd
commit 4715d87e11
2 changed files with 38 additions and 10 deletions

View File

@ -23,8 +23,10 @@ struct phy_device;
int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd);
void ethnl_cable_test_free(struct phy_device *phydev);
void ethnl_cable_test_finished(struct phy_device *phydev);
int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result);
int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm);
int ethnl_cable_test_result_with_src(struct phy_device *phydev, u8 pair,
u8 result, u32 src);
int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev, u8 pair,
u32 cm, u32 src);
int ethnl_cable_test_amplitude(struct phy_device *phydev, u8 pair, s16 mV);
int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV);
int ethnl_cable_test_step(struct phy_device *phydev, u32 first, u32 last,
@ -54,14 +56,14 @@ static inline void ethnl_cable_test_free(struct phy_device *phydev)
static inline void ethnl_cable_test_finished(struct phy_device *phydev)
{
}
static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
u8 result)
static inline int ethnl_cable_test_result_with_src(struct phy_device *phydev,
u8 pair, u8 result, u32 src)
{
return -EOPNOTSUPP;
}
static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
u8 pair, u32 cm)
static inline int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev,
u8 pair, u32 cm, u32 src)
{
return -EOPNOTSUPP;
}
@ -119,4 +121,19 @@ static inline bool ethtool_dev_mm_supported(struct net_device *dev)
}
#endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */
static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
u8 result)
{
return ethnl_cable_test_result_with_src(phydev, pair, result,
ETHTOOL_A_CABLE_INF_SRC_TDR);
}
static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
u8 pair, u32 cm)
{
return ethnl_cable_test_fault_length_with_src(phydev, pair, cm,
ETHTOOL_A_CABLE_INF_SRC_TDR);
}
#endif /* _LINUX_ETHTOOL_NETLINK_H_ */

View File

@ -164,7 +164,8 @@ void ethnl_cable_test_finished(struct phy_device *phydev)
}
EXPORT_SYMBOL_GPL(ethnl_cable_test_finished);
int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result)
int ethnl_cable_test_result_with_src(struct phy_device *phydev, u8 pair,
u8 result, u32 src)
{
struct nlattr *nest;
int ret = -EMSGSIZE;
@ -177,6 +178,10 @@ int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result)
goto err;
if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_RESULT_CODE, result))
goto err;
if (src != ETHTOOL_A_CABLE_INF_SRC_UNSPEC) {
if (nla_put_u32(phydev->skb, ETHTOOL_A_CABLE_RESULT_SRC, src))
goto err;
}
nla_nest_end(phydev->skb, nest);
return 0;
@ -185,9 +190,10 @@ err:
nla_nest_cancel(phydev->skb, nest);
return ret;
}
EXPORT_SYMBOL_GPL(ethnl_cable_test_result);
EXPORT_SYMBOL_GPL(ethnl_cable_test_result_with_src);
int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm)
int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev, u8 pair,
u32 cm, u32 src)
{
struct nlattr *nest;
int ret = -EMSGSIZE;
@ -201,6 +207,11 @@ int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm)
goto err;
if (nla_put_u32(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_CM, cm))
goto err;
if (src != ETHTOOL_A_CABLE_INF_SRC_UNSPEC) {
if (nla_put_u32(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_SRC,
src))
goto err;
}
nla_nest_end(phydev->skb, nest);
return 0;
@ -209,7 +220,7 @@ err:
nla_nest_cancel(phydev->skb, nest);
return ret;
}
EXPORT_SYMBOL_GPL(ethnl_cable_test_fault_length);
EXPORT_SYMBOL_GPL(ethnl_cable_test_fault_length_with_src);
static const struct nla_policy cable_test_tdr_act_cfg_policy[] = {
[ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .type = NLA_U32 },