net/ethtool/mm.c
Source file repositories/reference/linux-study-clean/net/ethtool/mm.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/mm.c- Extension
.c- Size
- 16806 bytes
- Lines
- 563
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
common.hnetlink.h
Detected Declarations
struct mm_req_infostruct mm_reply_datafunction mm_prepare_datafunction mm_reply_sizefunction mm_put_statfunction mm_put_statsfunction mm_fill_replyfunction mm_state_to_cfgfunction ethnl_set_mm_validatefunction ethnl_set_mmfunction netdev_assert_locked_ops_compatfunction ethtool_dev_mm_supportedfunction ethtool_mmsv_configure_txfunction ethtool_mmsv_configure_pmacfunction ethtool_mmsv_send_mpacketfunction ethtool_mmsv_verify_timerfunction ethtool_mmsv_verify_timer_armfunction ethtool_mmsv_applyfunction ethtool_mmsv_stopfunction ethtool_mmsv_link_state_handlefunction ethtool_mmsv_event_handlefunction ethtool_mmsv_is_tx_activefunction ethtool_mmsv_get_mmfunction ethtool_mmsv_set_mmfunction ethtool_mmsv_initexport ethtool_dev_mm_supportedexport ethtool_mmsv_stopexport ethtool_mmsv_link_state_handleexport ethtool_mmsv_event_handleexport ethtool_mmsv_get_mmexport ethtool_mmsv_set_mmexport ethtool_mmsv_init
Annotated Snippet
struct mm_req_info {
struct ethnl_req_info base;
};
struct mm_reply_data {
struct ethnl_reply_data base;
struct ethtool_mm_state state;
struct ethtool_mm_stats stats;
};
#define MM_REPDATA(__reply_base) \
container_of(__reply_base, struct mm_reply_data, base)
#define ETHTOOL_MM_STAT_CNT \
(__ETHTOOL_A_MM_STAT_CNT - (ETHTOOL_A_MM_STAT_PAD + 1))
const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1] = {
[ETHTOOL_A_MM_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy_stats),
};
static int mm_prepare_data(const struct ethnl_req_info *req_base,
struct ethnl_reply_data *reply_base,
const struct genl_info *info)
{
struct mm_reply_data *data = MM_REPDATA(reply_base);
struct net_device *dev = reply_base->dev;
const struct ethtool_ops *ops;
int ret;
ops = dev->ethtool_ops;
if (!ops->get_mm)
return -EOPNOTSUPP;
ethtool_stats_init((u64 *)&data->stats,
sizeof(data->stats) / sizeof(u64));
ret = ethnl_ops_begin(dev);
if (ret < 0)
return ret;
ret = ops->get_mm(dev, &data->state);
if (ret)
goto out_complete;
if (ops->get_mm_stats && (req_base->flags & ETHTOOL_FLAG_STATS))
ops->get_mm_stats(dev, &data->stats);
out_complete:
ethnl_ops_complete(dev);
return ret;
}
static int mm_reply_size(const struct ethnl_req_info *req_base,
const struct ethnl_reply_data *reply_base)
{
int len = 0;
len += nla_total_size(sizeof(u8)); /* _MM_PMAC_ENABLED */
len += nla_total_size(sizeof(u8)); /* _MM_TX_ENABLED */
len += nla_total_size(sizeof(u8)); /* _MM_TX_ACTIVE */
len += nla_total_size(sizeof(u8)); /* _MM_VERIFY_ENABLED */
len += nla_total_size(sizeof(u8)); /* _MM_VERIFY_STATUS */
len += nla_total_size(sizeof(u32)); /* _MM_VERIFY_TIME */
len += nla_total_size(sizeof(u32)); /* _MM_MAX_VERIFY_TIME */
len += nla_total_size(sizeof(u32)); /* _MM_TX_MIN_FRAG_SIZE */
len += nla_total_size(sizeof(u32)); /* _MM_RX_MIN_FRAG_SIZE */
if (req_base->flags & ETHTOOL_FLAG_STATS)
len += nla_total_size(0) + /* _MM_STATS */
nla_total_size_64bit(sizeof(u64)) * ETHTOOL_MM_STAT_CNT;
return len;
}
static int mm_put_stat(struct sk_buff *skb, u64 val, u16 attrtype)
{
if (val == ETHTOOL_STAT_NOT_SET)
return 0;
if (nla_put_u64_64bit(skb, attrtype, val, ETHTOOL_A_MM_STAT_PAD))
return -EMSGSIZE;
return 0;
}
static int mm_put_stats(struct sk_buff *skb,
const struct ethtool_mm_stats *stats)
{
struct nlattr *nest;
Annotation
- Immediate include surface: `common.h`, `netlink.h`.
- Detected declarations: `struct mm_req_info`, `struct mm_reply_data`, `function mm_prepare_data`, `function mm_reply_size`, `function mm_put_stat`, `function mm_put_stats`, `function mm_fill_reply`, `function mm_state_to_cfg`, `function ethnl_set_mm_validate`, `function ethnl_set_mm`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.