net/ethtool/stats.c
Source file repositories/reference/linux-study-clean/net/ethtool/stats.c
File Facts
- System
- Linux kernel
- Corpus path
net/ethtool/stats.c- Extension
.c- Size
- 20852 bytes
- Lines
- 625
- 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/phy.hlinux/phylib_stubs.hbitset.hcommon.hnetlink.h
Detected Declarations
struct stats_req_infostruct stats_reply_datafunction stats_parse_requestfunction stats_prepare_datafunction stats_reply_sizefunction stat_putfunction stats_put_phy_statsfunction stats_put_phydev_statsfunction stats_put_mac_statsfunction stats_put_ctrl_statsfunction stats_put_rmon_histfunction stats_put_rmon_statsfunction stats_put_statsfunction stats_fill_replyfunction ethtool_stats_sumfunction ethtool_aggregate_statsfunction ethtool_aggregate_mac_statsfunction ethtool_aggregate_phy_statsfunction ethtool_aggregate_ctrl_statsfunction ethtool_aggregate_pause_statsfunction ethtool_aggregate_rmon_statsexport ethtool_aggregate_mac_statsexport ethtool_aggregate_phy_statsexport ethtool_aggregate_ctrl_statsexport ethtool_aggregate_pause_statsexport ethtool_aggregate_rmon_stats
Annotated Snippet
struct stats_req_info {
struct ethnl_req_info base;
DECLARE_BITMAP(stat_mask, __ETHTOOL_STATS_CNT);
enum ethtool_mac_stats_src src;
};
#define STATS_REQINFO(__req_base) \
container_of(__req_base, struct stats_req_info, base)
struct stats_reply_data {
struct ethnl_reply_data base;
struct_group(stats,
struct ethtool_eth_phy_stats phy_stats;
struct ethtool_eth_mac_stats mac_stats;
struct ethtool_eth_ctrl_stats ctrl_stats;
struct ethtool_rmon_stats rmon_stats;
struct ethtool_phy_stats phydev_stats;
);
const struct ethtool_rmon_hist_range *rmon_ranges;
};
#define STATS_REPDATA(__reply_base) \
container_of(__reply_base, struct stats_reply_data, base)
const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_STATS_ETH_PHY] = "eth-phy",
[ETHTOOL_STATS_ETH_MAC] = "eth-mac",
[ETHTOOL_STATS_ETH_CTRL] = "eth-ctrl",
[ETHTOOL_STATS_RMON] = "rmon",
[ETHTOOL_STATS_PHY] = "phydev",
};
const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_A_STATS_ETH_PHY_5_SYM_ERR] = "SymbolErrorDuringCarrier",
};
const char stats_eth_mac_names[__ETHTOOL_A_STATS_ETH_MAC_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_A_STATS_ETH_MAC_2_TX_PKT] = "FramesTransmittedOK",
[ETHTOOL_A_STATS_ETH_MAC_3_SINGLE_COL] = "SingleCollisionFrames",
[ETHTOOL_A_STATS_ETH_MAC_4_MULTI_COL] = "MultipleCollisionFrames",
[ETHTOOL_A_STATS_ETH_MAC_5_RX_PKT] = "FramesReceivedOK",
[ETHTOOL_A_STATS_ETH_MAC_6_FCS_ERR] = "FrameCheckSequenceErrors",
[ETHTOOL_A_STATS_ETH_MAC_7_ALIGN_ERR] = "AlignmentErrors",
[ETHTOOL_A_STATS_ETH_MAC_8_TX_BYTES] = "OctetsTransmittedOK",
[ETHTOOL_A_STATS_ETH_MAC_9_TX_DEFER] = "FramesWithDeferredXmissions",
[ETHTOOL_A_STATS_ETH_MAC_10_LATE_COL] = "LateCollisions",
[ETHTOOL_A_STATS_ETH_MAC_11_XS_COL] = "FramesAbortedDueToXSColls",
[ETHTOOL_A_STATS_ETH_MAC_12_TX_INT_ERR] = "FramesLostDueToIntMACXmitError",
[ETHTOOL_A_STATS_ETH_MAC_13_CS_ERR] = "CarrierSenseErrors",
[ETHTOOL_A_STATS_ETH_MAC_14_RX_BYTES] = "OctetsReceivedOK",
[ETHTOOL_A_STATS_ETH_MAC_15_RX_INT_ERR] = "FramesLostDueToIntMACRcvError",
[ETHTOOL_A_STATS_ETH_MAC_18_TX_MCAST] = "MulticastFramesXmittedOK",
[ETHTOOL_A_STATS_ETH_MAC_19_TX_BCAST] = "BroadcastFramesXmittedOK",
[ETHTOOL_A_STATS_ETH_MAC_20_XS_DEFER] = "FramesWithExcessiveDeferral",
[ETHTOOL_A_STATS_ETH_MAC_21_RX_MCAST] = "MulticastFramesReceivedOK",
[ETHTOOL_A_STATS_ETH_MAC_22_RX_BCAST] = "BroadcastFramesReceivedOK",
[ETHTOOL_A_STATS_ETH_MAC_23_IR_LEN_ERR] = "InRangeLengthErrors",
[ETHTOOL_A_STATS_ETH_MAC_24_OOR_LEN] = "OutOfRangeLengthField",
[ETHTOOL_A_STATS_ETH_MAC_25_TOO_LONG_ERR] = "FrameTooLongErrors",
};
const char stats_eth_ctrl_names[__ETHTOOL_A_STATS_ETH_CTRL_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_A_STATS_ETH_CTRL_3_TX] = "MACControlFramesTransmitted",
[ETHTOOL_A_STATS_ETH_CTRL_4_RX] = "MACControlFramesReceived",
[ETHTOOL_A_STATS_ETH_CTRL_5_RX_UNSUP] = "UnsupportedOpcodesReceived",
};
const char stats_rmon_names[__ETHTOOL_A_STATS_RMON_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_A_STATS_RMON_UNDERSIZE] = "etherStatsUndersizePkts",
[ETHTOOL_A_STATS_RMON_OVERSIZE] = "etherStatsOversizePkts",
[ETHTOOL_A_STATS_RMON_FRAG] = "etherStatsFragments",
[ETHTOOL_A_STATS_RMON_JABBER] = "etherStatsJabbers",
};
const char stats_phy_names[__ETHTOOL_A_STATS_PHY_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_A_STATS_PHY_RX_PKTS] = "RxFrames",
[ETHTOOL_A_STATS_PHY_RX_BYTES] = "RxOctets",
[ETHTOOL_A_STATS_PHY_RX_ERRORS] = "RxErrors",
[ETHTOOL_A_STATS_PHY_TX_PKTS] = "TxFrames",
[ETHTOOL_A_STATS_PHY_TX_BYTES] = "TxOctets",
[ETHTOOL_A_STATS_PHY_TX_ERRORS] = "TxErrors",
};
const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1] = {
[ETHTOOL_A_STATS_HEADER] =
NLA_POLICY_NESTED(ethnl_header_policy),
[ETHTOOL_A_STATS_GROUPS] = { .type = NLA_NESTED },
[ETHTOOL_A_STATS_SRC] =
NLA_POLICY_MAX(NLA_U32, ETHTOOL_MAC_STATS_SRC_PMAC),
};
Annotation
- Immediate include surface: `linux/phy.h`, `linux/phylib_stubs.h`, `bitset.h`, `common.h`, `netlink.h`.
- Detected declarations: `struct stats_req_info`, `struct stats_reply_data`, `function stats_parse_request`, `function stats_prepare_data`, `function stats_reply_size`, `function stat_put`, `function stats_put_phy_stats`, `function stats_put_phydev_stats`, `function stats_put_mac_stats`, `function stats_put_ctrl_stats`.
- 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.