net/ethtool/rss.c
Source file repositories/reference/linux-study-clean/net/ethtool/rss.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/rss.c- Extension
.c- Size
- 32329 bytes
- Lines
- 1211
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/netdev_lock.h../core/dev.hcommon.hnetlink.h
Detected Declarations
struct rss_req_infostruct rss_reply_datastruct rss_nl_dump_ctxfunction rss_parse_requestfunction rss_prepare_flow_hashfunction rss_get_data_allocfunction rss_get_data_freefunction rss_prepare_getfunction __rss_prepare_ctxfunction rss_prepare_ctxfunction rss_preparefunction rss_prepare_datafunction rss_reply_sizefunction rss_fill_replyfunction rss_cleanup_datafunction ethnl_rss_dump_startfunction rss_dump_one_ctxfunction rss_dump_one_devfunction ethnl_rss_dumpitfunction for_each_netdev_lock_ops_compat_scopedfunction ethnl_rss_delete_notifyfunction ethtool_rss_notifyfunction ethnl_rss_set_validatefunction rss_set_prep_indirfunction rss_set_prep_hkeyfunction rss_check_rxfh_fields_symfunction ethnl_set_rss_fieldsfunction rss_set_ctx_updatefunction ethnl_rss_setfunction ethnl_rss_create_validatefunction ethnl_rss_create_send_ntffunction ethnl_rss_create_doitfunction ethnl_rss_delete_doit
Annotated Snippet
struct rss_req_info {
struct ethnl_req_info base;
u32 rss_context;
};
struct rss_reply_data {
struct ethnl_reply_data base;
bool has_flow_hash;
bool no_key_fields;
u32 indir_size;
u32 hkey_size;
u32 hfunc;
u32 input_xfrm;
u32 *indir_table;
u8 *hkey;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] = GTPU_DL_V4_FLOW,
[ETHTOOL_A_FLOW_GTPU_DL6] = GTPU_DL_V6_FLOW,
};
#define RSS_REQINFO(__req_base) \
container_of(__req_base, struct rss_req_info, base)
#define RSS_REPDATA(__reply_base) \
container_of(__reply_base, struct rss_reply_data, base)
const struct nla_policy ethnl_rss_get_policy[] = {
[ETHTOOL_A_RSS_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy),
[ETHTOOL_A_RSS_CONTEXT] = { .type = NLA_U32 },
[ETHTOOL_A_RSS_START_CONTEXT] = { .type = NLA_U32 },
};
static int
rss_parse_request(struct ethnl_req_info *req_info,
const struct genl_info *info,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
struct rss_req_info *request = RSS_REQINFO(req_info);
if (tb[ETHTOOL_A_RSS_CONTEXT])
request->rss_context = nla_get_u32(tb[ETHTOOL_A_RSS_CONTEXT]);
if (tb[ETHTOOL_A_RSS_START_CONTEXT]) {
NL_SET_BAD_ATTR(extack, tb[ETHTOOL_A_RSS_START_CONTEXT]);
return -EINVAL;
}
return 0;
}
static void
rss_prepare_flow_hash(const struct rss_req_info *req, struct net_device *dev,
struct rss_reply_data *data, const struct genl_info *info)
{
int i;
data->has_flow_hash = false;
if (!dev->ethtool_ops->get_rxfh_fields)
return;
if (req->rss_context && !dev->ethtool_ops->rxfh_per_ctx_fields)
return;
Annotation
- Immediate include surface: `net/netdev_lock.h`, `../core/dev.h`, `common.h`, `netlink.h`.
- Detected declarations: `struct rss_req_info`, `struct rss_reply_data`, `struct rss_nl_dump_ctx`, `function rss_parse_request`, `function rss_prepare_flow_hash`, `function rss_get_data_alloc`, `function rss_get_data_free`, `function rss_prepare_get`, `function __rss_prepare_ctx`, `function rss_prepare_ctx`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.