drivers/infiniband/hw/mlx5/counters.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/counters.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/counters.c- Extension
.c- Size
- 35514 bytes
- Lines
- 1276
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
mlx5_ib.hlinux/mlx5/eswitch.hlinux/mlx5/vport.hcounters.hib_rep.hqp.h
Detected Declarations
struct mlx5_ib_counterstruct mlx5_rdma_counterfunction mlx5_ib_read_countersfunction mlx5_ib_destroy_countersfunction mlx5_ib_create_countersfunction vport_qcounters_supportedfunction mlx5_ib_get_counters_idfunction mlx5_ib_alloc_hw_device_statsfunction mlx5_ib_alloc_hw_port_statsfunction mlx5_ib_query_q_countersfunction mlx5_ib_query_ext_ppcnt_countersfunction mlx5_ib_query_q_counters_vportfunction do_get_hw_statsfunction is_rdma_bytes_counterfunction do_per_qp_get_op_statfunction do_get_op_statfunction do_get_op_statsfunction mlx5_ib_get_hw_statsfunction mlx5_ib_counter_alloc_statsfunction mlx5_ib_counter_update_statsfunction mlx5_ib_counter_deallocfunction mlx5_ib_counter_bind_qpfunction mlx5_ib_counter_unbind_qpfunction mlx5_ib_fill_countersfunction __mlx5_ib_alloc_countersfunction mlx5r_is_opfc_shared_and_in_usefunction mlx5_ib_dealloc_countersfunction mlx5_ib_alloc_countersfunction read_flow_countersfunction counters_set_descriptionfunction mlx5_ib_flow_counters_set_datafunction mlx5_ib_counters_clear_descriptionfunction mlx5_ib_modify_statfunction mlx5_ib_counter_initfunction mlx5_ib_counters_initfunction mlx5_ib_counters_cleanup
Annotated Snippet
struct mlx5_ib_counter {
const char *name;
size_t offset;
u32 type;
};
struct mlx5_rdma_counter {
struct rdma_counter rdma_counter;
struct mlx5_fc *fc[MLX5_IB_OPCOUNTER_MAX];
struct xarray qpn_opfc_xa;
};
static struct mlx5_rdma_counter *to_mcounter(struct rdma_counter *counter)
{
return container_of(counter, struct mlx5_rdma_counter, rdma_counter);
}
#define INIT_Q_COUNTER(_name) \
{ .name = #_name, .offset = MLX5_BYTE_OFF(query_q_counter_out, _name)}
#define INIT_VPORT_Q_COUNTER(_name) \
{ .name = "vport_" #_name, .offset = \
MLX5_BYTE_OFF(query_q_counter_out, _name)}
static const struct mlx5_ib_counter basic_q_cnts[] = {
INIT_Q_COUNTER(rx_write_requests),
INIT_Q_COUNTER(rx_read_requests),
INIT_Q_COUNTER(rx_atomic_requests),
INIT_Q_COUNTER(rx_dct_connect),
INIT_Q_COUNTER(out_of_buffer),
};
static const struct mlx5_ib_counter out_of_seq_q_cnts[] = {
INIT_Q_COUNTER(out_of_sequence),
};
static const struct mlx5_ib_counter retrans_q_cnts[] = {
INIT_Q_COUNTER(duplicate_request),
INIT_Q_COUNTER(rnr_nak_retry_err),
INIT_Q_COUNTER(packet_seq_err),
INIT_Q_COUNTER(implied_nak_seq_err),
INIT_Q_COUNTER(local_ack_timeout_err),
};
static const struct mlx5_ib_counter vport_basic_q_cnts[] = {
INIT_VPORT_Q_COUNTER(rx_write_requests),
INIT_VPORT_Q_COUNTER(rx_read_requests),
INIT_VPORT_Q_COUNTER(rx_atomic_requests),
INIT_VPORT_Q_COUNTER(rx_dct_connect),
INIT_VPORT_Q_COUNTER(out_of_buffer),
};
static const struct mlx5_ib_counter vport_out_of_seq_q_cnts[] = {
INIT_VPORT_Q_COUNTER(out_of_sequence),
};
static const struct mlx5_ib_counter vport_retrans_q_cnts[] = {
INIT_VPORT_Q_COUNTER(duplicate_request),
INIT_VPORT_Q_COUNTER(rnr_nak_retry_err),
INIT_VPORT_Q_COUNTER(packet_seq_err),
INIT_VPORT_Q_COUNTER(implied_nak_seq_err),
INIT_VPORT_Q_COUNTER(local_ack_timeout_err),
};
#define INIT_CONG_COUNTER(_name) \
{ .name = #_name, .offset = \
MLX5_BYTE_OFF(query_cong_statistics_out, _name ## _high)}
static const struct mlx5_ib_counter cong_cnts[] = {
INIT_CONG_COUNTER(rp_cnp_ignored),
INIT_CONG_COUNTER(rp_cnp_handled),
INIT_CONG_COUNTER(np_ecn_marked_roce_packets),
INIT_CONG_COUNTER(np_cnp_sent),
};
static const struct mlx5_ib_counter extended_err_cnts[] = {
INIT_Q_COUNTER(resp_local_length_error),
INIT_Q_COUNTER(resp_cqe_error),
INIT_Q_COUNTER(req_cqe_error),
INIT_Q_COUNTER(req_remote_invalid_request),
INIT_Q_COUNTER(req_remote_access_errors),
INIT_Q_COUNTER(resp_remote_access_errors),
INIT_Q_COUNTER(resp_cqe_flush_error),
INIT_Q_COUNTER(req_cqe_flush_error),
INIT_Q_COUNTER(req_transport_retries_exceeded),
INIT_Q_COUNTER(req_rnr_retries_exceeded),
};
static const struct mlx5_ib_counter roce_accl_cnts[] = {
Annotation
- Immediate include surface: `mlx5_ib.h`, `linux/mlx5/eswitch.h`, `linux/mlx5/vport.h`, `counters.h`, `ib_rep.h`, `qp.h`.
- Detected declarations: `struct mlx5_ib_counter`, `struct mlx5_rdma_counter`, `function mlx5_ib_read_counters`, `function mlx5_ib_destroy_counters`, `function mlx5_ib_create_counters`, `function vport_qcounters_supported`, `function mlx5_ib_get_counters_id`, `function mlx5_ib_alloc_hw_device_stats`, `function mlx5_ib_alloc_hw_port_stats`, `function mlx5_ib_query_q_counters`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.