net/ethtool/plca.c
Source file repositories/reference/linux-study-clean/net/ethtool/plca.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/plca.c- Extension
.c- Size
- 8003 bytes
- Lines
- 272
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/phy.hlinux/ethtool_netlink.hcommon.hnetlink.h
Detected Declarations
struct plca_req_infostruct plca_reply_datafunction plca_update_sintfunction plca_get_cfg_prepare_datafunction plca_get_cfg_reply_sizefunction plca_get_cfg_fill_replyfunction ethnl_set_plcafunction plca_get_status_prepare_datafunction plca_get_status_reply_sizefunction plca_get_status_fill_reply
Annotated Snippet
struct plca_req_info {
struct ethnl_req_info base;
};
struct plca_reply_data {
struct ethnl_reply_data base;
struct phy_plca_cfg plca_cfg;
struct phy_plca_status plca_st;
};
// Helpers ------------------------------------------------------------------ //
#define PLCA_REPDATA(__reply_base) \
container_of(__reply_base, struct plca_reply_data, base)
// PLCA get configuration message ------------------------------------------- //
const struct nla_policy ethnl_plca_get_cfg_policy[] = {
[ETHTOOL_A_PLCA_HEADER] =
NLA_POLICY_NESTED(ethnl_header_policy_phy),
};
static void plca_update_sint(int *dst, struct nlattr **tb, u32 attrid,
bool *mod)
{
const struct nlattr *attr = tb[attrid];
if (!attr ||
WARN_ON_ONCE(attrid >= ARRAY_SIZE(ethnl_plca_set_cfg_policy)))
return;
switch (ethnl_plca_set_cfg_policy[attrid].type) {
case NLA_U8:
*dst = nla_get_u8(attr);
break;
case NLA_U32:
*dst = nla_get_u32(attr);
break;
default:
WARN_ON_ONCE(1);
}
*mod = true;
}
static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base,
struct ethnl_reply_data *reply_base,
const struct genl_info *info)
{
struct plca_reply_data *data = PLCA_REPDATA(reply_base);
struct net_device *dev = reply_base->dev;
const struct ethtool_phy_ops *ops;
struct nlattr **tb = info->attrs;
struct phy_device *phydev;
int ret;
phydev = ethnl_req_get_phydev(req_base, tb, ETHTOOL_A_PLCA_HEADER,
info->extack);
// check that the PHY device is available and connected
if (IS_ERR_OR_NULL(phydev)) {
ret = -EOPNOTSUPP;
goto out;
}
// note: rtnl_lock is held already by ethnl_default_doit
ops = ethtool_phy_ops;
if (!ops || !ops->get_plca_cfg) {
ret = -EOPNOTSUPP;
goto out;
}
ret = ethnl_ops_begin(dev);
if (ret < 0)
goto out;
memset(&data->plca_cfg, 0xff,
sizeof_field(struct plca_reply_data, plca_cfg));
ret = ops->get_plca_cfg(phydev, &data->plca_cfg);
ethnl_ops_complete(dev);
out:
return ret;
}
static int plca_get_cfg_reply_size(const struct ethnl_req_info *req_base,
const struct ethnl_reply_data *reply_base)
{
return nla_total_size(sizeof(u16)) + /* _VERSION */
nla_total_size(sizeof(u8)) + /* _ENABLED */
Annotation
- Immediate include surface: `linux/phy.h`, `linux/ethtool_netlink.h`, `common.h`, `netlink.h`.
- Detected declarations: `struct plca_req_info`, `struct plca_reply_data`, `function plca_update_sint`, `function plca_get_cfg_prepare_data`, `function plca_get_cfg_reply_size`, `function plca_get_cfg_fill_reply`, `function ethnl_set_plca`, `function plca_get_status_prepare_data`, `function plca_get_status_reply_size`, `function plca_get_status_fill_reply`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.