net/ethtool/pause.c
Source file repositories/reference/linux-study-clean/net/ethtool/pause.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/pause.c- Extension
.c- Size
- 6357 bytes
- Lines
- 223
- 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
common.hnetlink.h
Detected Declarations
struct pause_req_infostruct pause_reply_datafunction pause_parse_requestfunction pause_prepare_datafunction pause_reply_sizefunction ethtool_put_statfunction pause_put_statsfunction pause_fill_replyfunction ethnl_set_pause_validatefunction ethnl_set_pause
Annotated Snippet
struct pause_req_info {
struct ethnl_req_info base;
enum ethtool_mac_stats_src src;
};
#define PAUSE_REQINFO(__req_base) \
container_of(__req_base, struct pause_req_info, base)
struct pause_reply_data {
struct ethnl_reply_data base;
struct ethtool_pauseparam pauseparam;
struct ethtool_pause_stats pausestat;
};
#define PAUSE_REPDATA(__reply_base) \
container_of(__reply_base, struct pause_reply_data, base)
const struct nla_policy ethnl_pause_get_policy[] = {
[ETHTOOL_A_PAUSE_HEADER] =
NLA_POLICY_NESTED(ethnl_header_policy_stats),
[ETHTOOL_A_PAUSE_STATS_SRC] =
NLA_POLICY_MAX(NLA_U32, ETHTOOL_MAC_STATS_SRC_PMAC),
};
static int pause_parse_request(struct ethnl_req_info *req_base,
const struct genl_info *info,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
enum ethtool_mac_stats_src src = ETHTOOL_MAC_STATS_SRC_AGGREGATE;
struct pause_req_info *req_info = PAUSE_REQINFO(req_base);
if (tb[ETHTOOL_A_PAUSE_STATS_SRC]) {
if (!(req_base->flags & ETHTOOL_FLAG_STATS)) {
NL_SET_ERR_MSG_MOD(extack,
"ETHTOOL_FLAG_STATS must be set when requesting a source of stats");
return -EINVAL;
}
src = nla_get_u32(tb[ETHTOOL_A_PAUSE_STATS_SRC]);
}
req_info->src = src;
return 0;
}
static int pause_prepare_data(const struct ethnl_req_info *req_base,
struct ethnl_reply_data *reply_base,
const struct genl_info *info)
{
const struct pause_req_info *req_info = PAUSE_REQINFO(req_base);
struct pause_reply_data *data = PAUSE_REPDATA(reply_base);
enum ethtool_mac_stats_src src = req_info->src;
struct net_device *dev = reply_base->dev;
int ret;
if (!dev->ethtool_ops->get_pauseparam)
return -EOPNOTSUPP;
ethtool_stats_init((u64 *)&data->pausestat,
sizeof(data->pausestat) / 8);
data->pausestat.src = src;
ret = ethnl_ops_begin(dev);
if (ret < 0)
return ret;
if ((src == ETHTOOL_MAC_STATS_SRC_EMAC ||
src == ETHTOOL_MAC_STATS_SRC_PMAC) &&
!__ethtool_dev_mm_supported(dev)) {
NL_SET_ERR_MSG_MOD(info->extack,
"Device does not support MAC merge layer");
ethnl_ops_complete(dev);
return -EOPNOTSUPP;
}
dev->ethtool_ops->get_pauseparam(dev, &data->pauseparam);
if (req_base->flags & ETHTOOL_FLAG_STATS &&
dev->ethtool_ops->get_pause_stats)
dev->ethtool_ops->get_pause_stats(dev, &data->pausestat);
ethnl_ops_complete(dev);
return 0;
}
static int pause_reply_size(const struct ethnl_req_info *req_base,
const struct ethnl_reply_data *reply_base)
{
Annotation
- Immediate include surface: `common.h`, `netlink.h`.
- Detected declarations: `struct pause_req_info`, `struct pause_reply_data`, `function pause_parse_request`, `function pause_prepare_data`, `function pause_reply_size`, `function ethtool_put_stat`, `function pause_put_stats`, `function pause_fill_reply`, `function ethnl_set_pause_validate`, `function ethnl_set_pause`.
- 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.