net/ethtool/rings.c
Source file repositories/reference/linux-study-clean/net/ethtool/rings.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/rings.c- Extension
.c- Size
- 11443 bytes
- Lines
- 323
- 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
net/netdev_queues.hcommon.hnetlink.h
Detected Declarations
struct rings_req_infostruct rings_reply_datafunction rings_prepare_datafunction rings_reply_sizefunction rings_fill_replyfunction ethnl_set_rings_validatefunction ethnl_set_rings
Annotated Snippet
struct rings_req_info {
struct ethnl_req_info base;
};
struct rings_reply_data {
struct ethnl_reply_data base;
struct ethtool_ringparam ringparam;
struct kernel_ethtool_ringparam kernel_ringparam;
u32 supported_ring_params;
};
#define RINGS_REPDATA(__reply_base) \
container_of(__reply_base, struct rings_reply_data, base)
const struct nla_policy ethnl_rings_get_policy[] = {
[ETHTOOL_A_RINGS_HEADER] =
NLA_POLICY_NESTED(ethnl_header_policy),
};
static int rings_prepare_data(const struct ethnl_req_info *req_base,
struct ethnl_reply_data *reply_base,
const struct genl_info *info)
{
struct rings_reply_data *data = RINGS_REPDATA(reply_base);
struct net_device *dev = reply_base->dev;
int ret;
if (!dev->ethtool_ops->get_ringparam)
return -EOPNOTSUPP;
data->supported_ring_params = dev->ethtool_ops->supported_ring_params;
ret = ethnl_ops_begin(dev);
if (ret < 0)
return ret;
data->kernel_ringparam.tcp_data_split = dev->cfg->hds_config;
data->kernel_ringparam.hds_thresh = dev->cfg->hds_thresh;
dev->ethtool_ops->get_ringparam(dev, &data->ringparam,
&data->kernel_ringparam, info->extack);
ethnl_ops_complete(dev);
return 0;
}
static int rings_reply_size(const struct ethnl_req_info *req_base,
const struct ethnl_reply_data *reply_base)
{
return nla_total_size(sizeof(u32)) + /* _RINGS_RX_MAX */
nla_total_size(sizeof(u32)) + /* _RINGS_RX_MINI_MAX */
nla_total_size(sizeof(u32)) + /* _RINGS_RX_JUMBO_MAX */
nla_total_size(sizeof(u32)) + /* _RINGS_TX_MAX */
nla_total_size(sizeof(u32)) + /* _RINGS_RX */
nla_total_size(sizeof(u32)) + /* _RINGS_RX_MINI */
nla_total_size(sizeof(u32)) + /* _RINGS_RX_JUMBO */
nla_total_size(sizeof(u32)) + /* _RINGS_TX */
nla_total_size(sizeof(u32)) + /* _RINGS_RX_BUF_LEN */
nla_total_size(sizeof(u8)) + /* _RINGS_TCP_DATA_SPLIT */
nla_total_size(sizeof(u32)) + /* _RINGS_CQE_SIZE */
nla_total_size(sizeof(u8)) + /* _RINGS_TX_PUSH */
nla_total_size(sizeof(u8)) + /* _RINGS_RX_PUSH */
nla_total_size(sizeof(u32)) + /* _RINGS_TX_PUSH_BUF_LEN */
nla_total_size(sizeof(u32)) + /* _RINGS_TX_PUSH_BUF_LEN_MAX */
nla_total_size(sizeof(u32)) + /* _RINGS_HDS_THRESH */
nla_total_size(sizeof(u32)); /* _RINGS_HDS_THRESH_MAX*/
}
static int rings_fill_reply(struct sk_buff *skb,
const struct ethnl_req_info *req_base,
const struct ethnl_reply_data *reply_base)
{
const struct rings_reply_data *data = RINGS_REPDATA(reply_base);
const struct kernel_ethtool_ringparam *kr = &data->kernel_ringparam;
const struct ethtool_ringparam *ringparam = &data->ringparam;
u32 supported_ring_params = data->supported_ring_params;
WARN_ON(kr->tcp_data_split > ETHTOOL_TCP_DATA_SPLIT_ENABLED);
if ((ringparam->rx_max_pending &&
(nla_put_u32(skb, ETHTOOL_A_RINGS_RX_MAX,
ringparam->rx_max_pending) ||
nla_put_u32(skb, ETHTOOL_A_RINGS_RX,
ringparam->rx_pending))) ||
(ringparam->rx_mini_max_pending &&
(nla_put_u32(skb, ETHTOOL_A_RINGS_RX_MINI_MAX,
ringparam->rx_mini_max_pending) ||
nla_put_u32(skb, ETHTOOL_A_RINGS_RX_MINI,
ringparam->rx_mini_pending))) ||
(ringparam->rx_jumbo_max_pending &&
(nla_put_u32(skb, ETHTOOL_A_RINGS_RX_JUMBO_MAX,
Annotation
- Immediate include surface: `net/netdev_queues.h`, `common.h`, `netlink.h`.
- Detected declarations: `struct rings_req_info`, `struct rings_reply_data`, `function rings_prepare_data`, `function rings_reply_size`, `function rings_fill_reply`, `function ethnl_set_rings_validate`, `function ethnl_set_rings`.
- 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.