net/ethtool/pse-pd.c
Source file repositories/reference/linux-study-clean/net/ethtool/pse-pd.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/pse-pd.c- Extension
.c- Size
- 10310 bytes
- Lines
- 384
- 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/ethtool_netlink.hlinux/ethtool.hlinux/export.hlinux/phy.hcommon.hlinux/pse-pd/pse.hnetlink.h
Detected Declarations
struct pse_req_infostruct pse_reply_datafunction pse_get_pse_attributesfunction pse_prepare_datafunction pse_reply_sizefunction pse_put_pw_limit_rangesfunction pse_fill_replyfunction pse_cleanup_datafunction ethnl_set_pse_validatefunction ethnl_set_psefunction ethnl_pse_send_ntfexport ethnl_pse_send_ntf
Annotated Snippet
struct pse_req_info {
struct ethnl_req_info base;
};
struct pse_reply_data {
struct ethnl_reply_data base;
struct ethtool_pse_control_status status;
};
#define PSE_REPDATA(__reply_base) \
container_of(__reply_base, struct pse_reply_data, base)
/* PSE_GET */
const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER + 1] = {
[ETHTOOL_A_PSE_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy_phy),
};
static int pse_get_pse_attributes(struct phy_device *phydev,
struct netlink_ext_ack *extack,
struct pse_reply_data *data)
{
if (!phydev) {
NL_SET_ERR_MSG(extack, "No PHY found");
return -EOPNOTSUPP;
}
if (!phydev->psec) {
NL_SET_ERR_MSG(extack, "No PSE is attached");
return -EOPNOTSUPP;
}
memset(&data->status, 0, sizeof(data->status));
return pse_ethtool_get_status(phydev->psec, extack, &data->status);
}
static int pse_prepare_data(const struct ethnl_req_info *req_base,
struct ethnl_reply_data *reply_base,
const struct genl_info *info)
{
struct pse_reply_data *data = PSE_REPDATA(reply_base);
struct net_device *dev = reply_base->dev;
struct nlattr **tb = info->attrs;
struct phy_device *phydev;
int ret;
phydev = ethnl_req_get_phydev(req_base, tb, ETHTOOL_A_PSE_HEADER,
info->extack);
if (IS_ERR(phydev))
return PTR_ERR(phydev);
ret = ethnl_ops_begin(dev);
if (ret < 0)
return ret;
ret = pse_get_pse_attributes(phydev, info->extack, data);
ethnl_ops_complete(dev);
return ret;
}
static int pse_reply_size(const struct ethnl_req_info *req_base,
const struct ethnl_reply_data *reply_base)
{
const struct pse_reply_data *data = PSE_REPDATA(reply_base);
const struct ethtool_pse_control_status *st = &data->status;
int len = 0;
if (st->pw_d_id)
len += nla_total_size(sizeof(u32)); /* _PSE_PW_D_ID */
if (st->podl_admin_state > 0)
len += nla_total_size(sizeof(u32)); /* _PODL_PSE_ADMIN_STATE */
if (st->podl_pw_status > 0)
len += nla_total_size(sizeof(u32)); /* _PODL_PSE_PW_D_STATUS */
if (st->c33_admin_state > 0)
len += nla_total_size(sizeof(u32)); /* _C33_PSE_ADMIN_STATE */
if (st->c33_pw_status > 0)
len += nla_total_size(sizeof(u32)); /* _C33_PSE_PW_D_STATUS */
if (st->c33_pw_class > 0)
len += nla_total_size(sizeof(u32)); /* _C33_PSE_PW_CLASS */
if (st->c33_actual_pw > 0)
len += nla_total_size(sizeof(u32)); /* _C33_PSE_ACTUAL_PW */
if (st->c33_ext_state_info.c33_pse_ext_state > 0) {
len += nla_total_size(sizeof(u32)); /* _C33_PSE_EXT_STATE */
if (st->c33_ext_state_info.__c33_pse_ext_substate > 0)
/* _C33_PSE_EXT_SUBSTATE */
len += nla_total_size(sizeof(u32));
}
Annotation
- Immediate include surface: `linux/ethtool_netlink.h`, `linux/ethtool.h`, `linux/export.h`, `linux/phy.h`, `common.h`, `linux/pse-pd/pse.h`, `netlink.h`.
- Detected declarations: `struct pse_req_info`, `struct pse_reply_data`, `function pse_get_pse_attributes`, `function pse_prepare_data`, `function pse_reply_size`, `function pse_put_pw_limit_ranges`, `function pse_fill_reply`, `function pse_cleanup_data`, `function ethnl_set_pse_validate`, `function ethnl_set_pse`.
- 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.