drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c- Extension
.c- Size
- 99291 bytes
- Lines
- 2768
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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
lib/events.hen.hen_accel/ktls.hen_accel/en_accel.hen/ptp.hen/port.hnet/page_pool/helpers.h
Detected Declarations
function Copyrightfunction stats_grps_numfunction mlx5e_stats_total_numfunction mlx5e_stats_update_ndo_statsfunction mlx5e_stats_updatefunction mlx5e_stats_fillfunction mlx5e_stats_fill_stringsfunction MLX5E_DECLARE_STATS_GRP_OP_NUM_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction mlx5e_stats_grp_sw_update_stats_xdp_redfunction mlx5e_stats_grp_sw_update_stats_xdpsqfunction mlx5e_stats_grp_sw_update_stats_xsksqfunction mlx5e_stats_grp_sw_update_stats_xskrqfunction mlx5e_stats_grp_sw_update_stats_rq_statsfunction mlx5e_stats_grp_sw_update_stats_ch_statsfunction mlx5e_stats_grp_sw_update_stats_sqfunction mlx5e_stats_grp_sw_update_stats_ptpfunction mlx5e_stats_grp_sw_update_stats_qosfunction mlx5e_stats_update_stats_rq_page_poolfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction q_counter_anyfunction MLX5E_DECLARE_STATS_GRP_OP_NUM_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction mlx5_sd_for_each_devfunction ARRAY_SIZEfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction ARRAY_SIZEfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_NUM_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction MLX5_BYTE_OFFfunction mlx5e_stats_get_per_priofunction mlx5e_stats_pause_getfunction mlx5e_stats_eth_phy_getfunction mlx5e_stats_eth_mac_getfunction mlx5e_stats_eth_ctrl_getfunction MLX5E_DECLARE_STATS_GRP_OP_NUM_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS
Annotated Snippet
if (priv->q_counter[i]) {
MLX5_SET(query_q_counter_in, in, counter_set_id,
priv->q_counter[i]);
ret = mlx5_cmd_exec_inout(pos, query_q_counter, in, out);
if (!ret)
rx_out_of_buffer += MLX5_GET(query_q_counter_out,
out, out_of_buffer);
}
}
qcnt->rx_out_of_buffer = rx_out_of_buffer;
if (priv->drop_rq_q_counter) {
MLX5_SET(query_q_counter_in, in, counter_set_id,
priv->drop_rq_q_counter);
ret = mlx5_cmd_exec_inout(priv->mdev, query_q_counter, in, out);
if (!ret)
qcnt->rx_if_down_packets = MLX5_GET(query_q_counter_out,
out, out_of_buffer);
}
}
#define VNIC_ENV_OFF(c) MLX5_BYTE_OFF(query_vnic_env_out, c)
static const struct counter_desc vnic_env_stats_steer_desc[] = {
{ "rx_steer_missed_packets",
VNIC_ENV_OFF(vport_env.nic_receive_steering_discard) },
};
static const struct counter_desc vnic_env_stats_dev_oob_desc[] = {
{ "dev_internal_queue_oob",
VNIC_ENV_OFF(vport_env.internal_rq_out_of_buffer) },
};
static const struct counter_desc vnic_env_stats_drop_desc[] = {
{ "rx_oversize_pkts_buffer",
VNIC_ENV_OFF(vport_env.eth_wqe_too_small) },
};
#define NUM_VNIC_ENV_STEER_COUNTERS(dev) \
(MLX5_CAP_GEN(dev, nic_receive_steering_discard) ? \
ARRAY_SIZE(vnic_env_stats_steer_desc) : 0)
#define NUM_VNIC_ENV_DEV_OOB_COUNTERS(dev) \
(MLX5_CAP_GEN(dev, vnic_env_int_rq_oob) ? \
ARRAY_SIZE(vnic_env_stats_dev_oob_desc) : 0)
#define NUM_VNIC_ENV_DROP_COUNTERS(dev) \
(MLX5_CAP_GEN(dev, eth_wqe_too_small) ? \
ARRAY_SIZE(vnic_env_stats_drop_desc) : 0)
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vnic_env)
{
return NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev) +
NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev) +
NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev);
}
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vnic_env)
{
int i;
for (i = 0; i < NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev); i++)
ethtool_puts(data, vnic_env_stats_steer_desc[i].format);
for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++)
ethtool_puts(data, vnic_env_stats_dev_oob_desc[i].format);
for (i = 0; i < NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev); i++)
ethtool_puts(data, vnic_env_stats_drop_desc[i].format);
}
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vnic_env)
{
int i;
for (i = 0; i < NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev); i++)
mlx5e_ethtool_put_stat(
data,
MLX5E_READ_CTR64_BE(priv->stats.vnic.query_vnic_env_out,
vnic_env_stats_steer_desc, i));
for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++)
mlx5e_ethtool_put_stat(
data,
MLX5E_READ_CTR32_BE(priv->stats.vnic.query_vnic_env_out,
vnic_env_stats_dev_oob_desc, i));
for (i = 0; i < NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev); i++)
mlx5e_ethtool_put_stat(
data,
MLX5E_READ_CTR32_BE(priv->stats.vnic.query_vnic_env_out,
vnic_env_stats_drop_desc, i));
}
Annotation
- Immediate include surface: `lib/events.h`, `en.h`, `en_accel/ktls.h`, `en_accel/en_accel.h`, `en/ptp.h`, `en/port.h`, `net/page_pool/helpers.h`.
- Detected declarations: `function Copyright`, `function stats_grps_num`, `function mlx5e_stats_total_num`, `function mlx5e_stats_update_ndo_stats`, `function mlx5e_stats_update`, `function mlx5e_stats_fill`, `function mlx5e_stats_fill_strings`, `function MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS`, `function MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS`, `function MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS`.
- Atlas domain: Driver Families / drivers/net.
- 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.