Skip to content

Commit 4715d87

Browse files
oleremkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent abcd302 commit 4715d87

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

include/linux/ethtool_netlink.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ struct phy_device;
2323
int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd);
2424
void ethnl_cable_test_free(struct phy_device *phydev);
2525
void ethnl_cable_test_finished(struct phy_device *phydev);
26-
int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result);
27-
int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm);
26+
int ethnl_cable_test_result_with_src(struct phy_device *phydev, u8 pair,
27+
u8 result, u32 src);
28+
int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev, u8 pair,
29+
u32 cm, u32 src);
2830
int ethnl_cable_test_amplitude(struct phy_device *phydev, u8 pair, s16 mV);
2931
int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV);
3032
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)
5456
static inline void ethnl_cable_test_finished(struct phy_device *phydev)
5557
{
5658
}
57-
static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
58-
u8 result)
59+
static inline int ethnl_cable_test_result_with_src(struct phy_device *phydev,
60+
u8 pair, u8 result, u32 src)
5961
{
6062
return -EOPNOTSUPP;
6163
}
6264

63-
static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
64-
u8 pair, u32 cm)
65+
static inline int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev,
66+
u8 pair, u32 cm, u32 src)
6567
{
6668
return -EOPNOTSUPP;
6769
}
@@ -119,4 +121,19 @@ static inline bool ethtool_dev_mm_supported(struct net_device *dev)
119121
}
120122

121123
#endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */
124+
125+
static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
126+
u8 result)
127+
{
128+
return ethnl_cable_test_result_with_src(phydev, pair, result,
129+
ETHTOOL_A_CABLE_INF_SRC_TDR);
130+
}
131+
132+
static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
133+
u8 pair, u32 cm)
134+
{
135+
return ethnl_cable_test_fault_length_with_src(phydev, pair, cm,
136+
ETHTOOL_A_CABLE_INF_SRC_TDR);
137+
}
138+
122139
#endif /* _LINUX_ETHTOOL_NETLINK_H_ */

net/ethtool/cabletest.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ void ethnl_cable_test_finished(struct phy_device *phydev)
164164
}
165165
EXPORT_SYMBOL_GPL(ethnl_cable_test_finished);
166166

167-
int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result)
167+
int ethnl_cable_test_result_with_src(struct phy_device *phydev, u8 pair,
168+
u8 result, u32 src)
168169
{
169170
struct nlattr *nest;
170171
int ret = -EMSGSIZE;
@@ -177,6 +178,10 @@ int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result)
177178
goto err;
178179
if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_RESULT_CODE, result))
179180
goto err;
181+
if (src != ETHTOOL_A_CABLE_INF_SRC_UNSPEC) {
182+
if (nla_put_u32(phydev->skb, ETHTOOL_A_CABLE_RESULT_SRC, src))
183+
goto err;
184+
}
180185

181186
nla_nest_end(phydev->skb, nest);
182187
return 0;
@@ -185,9 +190,10 @@ int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result)
185190
nla_nest_cancel(phydev->skb, nest);
186191
return ret;
187192
}
188-
EXPORT_SYMBOL_GPL(ethnl_cable_test_result);
193+
EXPORT_SYMBOL_GPL(ethnl_cable_test_result_with_src);
189194

190-
int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm)
195+
int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev, u8 pair,
196+
u32 cm, u32 src)
191197
{
192198
struct nlattr *nest;
193199
int ret = -EMSGSIZE;
@@ -201,6 +207,11 @@ int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm)
201207
goto err;
202208
if (nla_put_u32(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_CM, cm))
203209
goto err;
210+
if (src != ETHTOOL_A_CABLE_INF_SRC_UNSPEC) {
211+
if (nla_put_u32(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_SRC,
212+
src))
213+
goto err;
214+
}
204215

205216
nla_nest_end(phydev->skb, nest);
206217
return 0;
@@ -209,7 +220,7 @@ int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm)
209220
nla_nest_cancel(phydev->skb, nest);
210221
return ret;
211222
}
212-
EXPORT_SYMBOL_GPL(ethnl_cable_test_fault_length);
223+
EXPORT_SYMBOL_GPL(ethnl_cable_test_fault_length_with_src);
213224

214225
static const struct nla_policy cable_test_tdr_act_cfg_policy[] = {
215226
[ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST] = { .type = NLA_U32 },

0 commit comments

Comments
 (0)