drivers/net/ethernet/mellanox/mlx5/core/eq.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/eq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/eq.c- Extension
.c- Size
- 31475 bytes
- Lines
- 1249
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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.
- 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
linux/interrupt.hlinux/notifier.hlinux/mlx5/driver.hlinux/mlx5/vport.hlinux/mlx5/eq.hlinux/cpu_rmap.hmlx5_core.hlib/eq.hfpga/core.heswitch.hlib/clock.hdiag/fw_tracer.hmlx5_irq.hpci_irq.hdevlink.hen_accel/ipsec.h
Detected Declarations
struct mlx5_eq_tableenum async_eq_nb_actionfunction mlx5_cmd_destroy_eqfunction mlx5_eq_comp_intfunction mlx5_eq_poll_irq_disabledfunction mlx5_eq_async_int_lockfunction mlx5_eq_async_int_unlockfunction mlx5_eq_async_intfunction mlx5_cmd_eq_recoverfunction init_eq_buffunction create_map_eqfunction mlx5_eq_enablefunction mlx5_eq_disablefunction destroy_unmap_eqfunction mlx5_eq_add_cqfunction mlx5_eq_del_cqfunction mlx5_eq_table_initfunction mlx5_eq_table_cleanupfunction create_async_eqfunction destroy_async_eqfunction cq_err_event_notifierfunction gather_user_async_eventsfunction gather_async_events_maskfunction setup_async_eqfunction cleanup_async_eqfunction async_eq_depth_devlink_param_getfunction create_async_eqsfunction destroy_async_eqsfunction mlx5_eq_synchronize_async_irqfunction mlx5_eq_synchronize_cmd_irqfunction mlx5_eq_create_genericfunction mlx5_eq_destroy_genericfunction mlx5_eq_update_cifunction comp_irq_release_pcifunction mlx5_cpumask_default_spreadfunction comp_irq_request_pcifunction comp_irq_release_sffunction comp_irq_request_sffunction comp_irq_releasefunction comp_irq_requestfunction alloc_rmapfunction free_rmapfunction alloc_rmapfunction free_rmapfunction comp_eq_depth_devlink_param_getfunction create_comp_eqfunction mlx5_comp_eqn_getfunction mlx5_comp_irqn_get
Annotated Snippet
struct mlx5_eq_table {
struct xarray comp_eqs;
struct mlx5_eq_async pages_eq;
struct mlx5_eq_async cmd_eq;
struct mlx5_eq_async async_eq;
struct atomic_notifier_head nh[MLX5_EVENT_TYPE_MAX];
/* Since CQ DB is stored in async_eq */
struct mlx5_nb cq_err_nb;
struct mutex lock; /* sync async eqs creations */
struct mutex comp_lock; /* sync comp eqs creations */
int curr_comp_eqs;
int max_comp_eqs;
struct mlx5_irq_table *irq_table;
struct xarray comp_irqs;
struct mlx5_irq *ctrl_irq;
struct cpu_rmap *rmap;
struct cpumask used_cpus;
};
#define MLX5_ASYNC_EVENT_MASK ((1ull << MLX5_EVENT_TYPE_PATH_MIG) | \
(1ull << MLX5_EVENT_TYPE_COMM_EST) | \
(1ull << MLX5_EVENT_TYPE_SQ_DRAINED) | \
(1ull << MLX5_EVENT_TYPE_CQ_ERROR) | \
(1ull << MLX5_EVENT_TYPE_WQ_CATAS_ERROR) | \
(1ull << MLX5_EVENT_TYPE_PATH_MIG_FAILED) | \
(1ull << MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \
(1ull << MLX5_EVENT_TYPE_WQ_ACCESS_ERROR) | \
(1ull << MLX5_EVENT_TYPE_PORT_CHANGE) | \
(1ull << MLX5_EVENT_TYPE_SRQ_CATAS_ERROR) | \
(1ull << MLX5_EVENT_TYPE_SRQ_LAST_WQE) | \
(1ull << MLX5_EVENT_TYPE_SRQ_RQ_LIMIT))
static int mlx5_cmd_destroy_eq(struct mlx5_core_dev *dev, u8 eqn)
{
u32 in[MLX5_ST_SZ_DW(destroy_eq_in)] = {};
MLX5_SET(destroy_eq_in, in, opcode, MLX5_CMD_OP_DESTROY_EQ);
MLX5_SET(destroy_eq_in, in, eq_number, eqn);
return mlx5_cmd_exec_in(dev, destroy_eq, in);
}
/* caller must eventually call mlx5_cq_put on the returned cq */
static struct mlx5_core_cq *mlx5_eq_cq_get(struct mlx5_eq *eq, u32 cqn)
{
struct mlx5_cq_table *table = &eq->cq_table;
struct mlx5_core_cq *cq = NULL;
rcu_read_lock();
cq = radix_tree_lookup(&table->tree, cqn);
if (likely(cq))
mlx5_cq_hold(cq);
rcu_read_unlock();
return cq;
}
static int mlx5_eq_comp_int(struct notifier_block *nb,
__always_unused unsigned long action,
__always_unused void *data)
{
struct mlx5_eq_comp *eq_comp =
container_of(nb, struct mlx5_eq_comp, irq_nb);
struct mlx5_eq *eq = &eq_comp->core;
struct mlx5_eqe *eqe;
int num_eqes = 0;
while ((eqe = next_eqe_sw(eq))) {
struct mlx5_core_cq *cq;
u32 cqn;
/* Make sure we read EQ entry contents after we've
* checked the ownership bit.
*/
dma_rmb();
/* Assume (eqe->type) is always MLX5_EVENT_TYPE_COMP */
cqn = be32_to_cpu(eqe->data.comp.cqn) & 0xffffff;
cq = mlx5_eq_cq_get(eq, cqn);
if (likely(cq)) {
++cq->arm_sn;
cq->comp(cq, eqe);
mlx5_cq_put(cq);
} else {
dev_dbg_ratelimited(eq->dev->device,
"Completion event for bogus CQ 0x%x\n", cqn);
}
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/notifier.h`, `linux/mlx5/driver.h`, `linux/mlx5/vport.h`, `linux/mlx5/eq.h`, `linux/cpu_rmap.h`, `mlx5_core.h`, `lib/eq.h`.
- Detected declarations: `struct mlx5_eq_table`, `enum async_eq_nb_action`, `function mlx5_cmd_destroy_eq`, `function mlx5_eq_comp_int`, `function mlx5_eq_poll_irq_disabled`, `function mlx5_eq_async_int_lock`, `function mlx5_eq_async_int_unlock`, `function mlx5_eq_async_int`, `function mlx5_cmd_eq_recover`, `function init_eq_buf`.
- Atlas domain: Driver Families / drivers/net.
- 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.