net/ethtool/cabletest.c
Source file repositories/reference/linux-study-clean/net/ethtool/cabletest.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/cabletest.c- Extension
.c- Size
- 10514 bytes
- Lines
- 451
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/phy.hlinux/ethtool_netlink.hnet/netdev_lock.hcommon.hnetlink.h
Detected Declarations
function ethnl_cable_test_startedfunction ethnl_act_cable_testfunction ethnl_cable_test_allocfunction ethnl_cable_test_freefunction ethnl_cable_test_finishedfunction ethnl_cable_test_result_with_srcfunction ethnl_cable_test_fault_length_with_srcfunction ethnl_act_cable_test_tdr_cfgfunction ethnl_act_cable_test_tdrfunction ethnl_cable_test_amplitudefunction ethnl_cable_test_pulsefunction ethnl_cable_test_stepexport ethnl_cable_test_allocexport ethnl_cable_test_freeexport ethnl_cable_test_finishedexport ethnl_cable_test_result_with_srcexport ethnl_cable_test_fault_length_with_srcexport ethnl_cable_test_amplitudeexport ethnl_cable_test_pulseexport ethnl_cable_test_step
Annotated Snippet
if (cfg->pair > ETHTOOL_A_CABLE_PAIR_D) {
NL_SET_ERR_MSG_ATTR(
info->extack,
tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR],
"invalid pair parameter");
return -EINVAL;
}
}
if (cfg->first > MAX_CABLE_LENGTH_CM) {
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST],
"invalid first parameter");
return -EINVAL;
}
if (cfg->last > MAX_CABLE_LENGTH_CM) {
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST],
"invalid last parameter");
return -EINVAL;
}
if (cfg->first > cfg->last) {
NL_SET_ERR_MSG(info->extack, "invalid first/last parameter");
return -EINVAL;
}
if (!cfg->step) {
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP],
"invalid step parameter");
return -EINVAL;
}
if (cfg->step > (cfg->last - cfg->first)) {
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP],
"step parameter too big");
return -EINVAL;
}
return 0;
}
int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info)
{
struct ethnl_req_info req_info = {};
const struct ethtool_phy_ops *ops;
struct nlattr **tb = info->attrs;
struct phy_device *phydev;
struct phy_tdr_config cfg;
struct net_device *dev;
int ret;
ret = ethnl_parse_header_dev_get(&req_info,
tb[ETHTOOL_A_CABLE_TEST_TDR_HEADER],
genl_info_net(info), info->extack,
true);
if (ret < 0)
return ret;
dev = req_info.dev;
ret = ethnl_act_cable_test_tdr_cfg(tb[ETHTOOL_A_CABLE_TEST_TDR_CFG],
info, &cfg);
if (ret)
goto out_dev_put;
netdev_lock_ops_compat(dev);
phydev = ethnl_req_get_phydev(&req_info, tb,
ETHTOOL_A_CABLE_TEST_TDR_HEADER,
info->extack);
if (IS_ERR_OR_NULL(phydev)) {
ret = -EOPNOTSUPP;
goto out_unlock;
}
ops = ethtool_phy_ops;
if (!ops || !ops->start_cable_test_tdr) {
ret = -EOPNOTSUPP;
goto out_unlock;
}
ret = ethnl_ops_begin(dev);
if (ret < 0)
goto out_unlock;
ret = ops->start_cable_test_tdr(phydev, info->extack, &cfg);
Annotation
- Immediate include surface: `linux/phy.h`, `linux/ethtool_netlink.h`, `net/netdev_lock.h`, `common.h`, `netlink.h`.
- Detected declarations: `function ethnl_cable_test_started`, `function ethnl_act_cable_test`, `function ethnl_cable_test_alloc`, `function ethnl_cable_test_free`, `function ethnl_cable_test_finished`, `function ethnl_cable_test_result_with_src`, `function ethnl_cable_test_fault_length_with_src`, `function ethnl_act_cable_test_tdr_cfg`, `function ethnl_act_cable_test_tdr`, `function ethnl_cable_test_amplitude`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.