drivers/net/ethernet/mellanox/mlx5/core/wc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/wc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/wc.c- Extension
.c- Size
- 11108 bytes
- Lines
- 461
- 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/io.hlinux/iopoll.hlinux/mlx5/transobj.hlib/clock.hmlx5_core.hwq.hasm/neon.hasm/simd.h
Detected Declarations
struct mlx5_wc_cqstruct mlx5_wc_sqfunction mlx5_wc_create_cqwqfunction create_wc_cqfunction mlx5_wc_create_cqfunction mlx5_wc_destroy_cqfunction create_wc_sqfunction mlx5_wc_create_sqfunction mlx5_wc_destroy_sqfunction mlx5_iowrite64_copyfunction mlx5_wc_post_nopfunction mlx5_wc_poll_cqfunction mlx5_core_test_wcfunction mlx5_wc_support_getexport mlx5_wc_support_get
Annotated Snippet
struct mlx5_wc_cq {
/* data path - accessed per cqe */
struct mlx5_cqwq wq;
/* data path - accessed per napi poll */
struct mlx5_core_cq mcq;
/* control */
struct mlx5_core_dev *mdev;
struct mlx5_wq_ctrl wq_ctrl;
};
struct mlx5_wc_sq {
/* data path */
u16 cc;
u16 pc;
/* read only */
struct mlx5_wq_cyc wq;
u32 sqn;
/* control path */
struct mlx5_wq_ctrl wq_ctrl;
struct mlx5_wc_cq cq;
struct mlx5_sq_bfreg bfreg;
};
static int mlx5_wc_create_cqwq(struct mlx5_core_dev *mdev, void *cqc,
struct mlx5_wc_cq *cq)
{
struct mlx5_core_cq *mcq = &cq->mcq;
struct mlx5_wq_param param = {};
int err;
u32 i;
err = mlx5_cqwq_create(mdev, ¶m, cqc, &cq->wq, &cq->wq_ctrl);
if (err)
return err;
mcq->cqe_sz = 64;
mcq->set_ci_db = cq->wq_ctrl.db.db;
mcq->arm_db = cq->wq_ctrl.db.db + 1;
for (i = 0; i < mlx5_cqwq_get_size(&cq->wq); i++) {
struct mlx5_cqe64 *cqe = mlx5_cqwq_get_wqe(&cq->wq, i);
cqe->op_own = 0xf1;
}
cq->mdev = mdev;
return 0;
}
static int create_wc_cq(struct mlx5_wc_cq *cq, void *cqc_data)
{
u32 out[MLX5_ST_SZ_DW(create_cq_out)];
struct mlx5_core_dev *mdev = cq->mdev;
struct mlx5_core_cq *mcq = &cq->mcq;
int err, inlen, eqn;
void *in, *cqc;
err = mlx5_comp_eqn_get(mdev, 0, &eqn);
if (err)
return err;
inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
sizeof(u64) * cq->wq_ctrl.buf.npages;
in = kvzalloc(inlen, GFP_KERNEL);
if (!in)
return -ENOMEM;
cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context);
memcpy(cqc, cqc_data, MLX5_ST_SZ_BYTES(cqc));
mlx5_fill_page_frag_array(&cq->wq_ctrl.buf,
(__be64 *)MLX5_ADDR_OF(create_cq_in, in, pas));
MLX5_SET(cqc, cqc, cq_period_mode, MLX5_CQ_PERIOD_MODE_START_FROM_EQE);
MLX5_SET(cqc, cqc, c_eqn_or_apu_element, eqn);
MLX5_SET(cqc, cqc, uar_page, mdev->priv.bfreg.up->index);
MLX5_SET(cqc, cqc, log_page_size, cq->wq_ctrl.buf.page_shift -
MLX5_ADAPTER_PAGE_SHIFT);
MLX5_SET64(cqc, cqc, dbr_addr, cq->wq_ctrl.db.dma);
err = mlx5_core_create_cq(mdev, mcq, in, inlen, out, sizeof(out));
kvfree(in);
Annotation
- Immediate include surface: `linux/io.h`, `linux/iopoll.h`, `linux/mlx5/transobj.h`, `lib/clock.h`, `mlx5_core.h`, `wq.h`, `asm/neon.h`, `asm/simd.h`.
- Detected declarations: `struct mlx5_wc_cq`, `struct mlx5_wc_sq`, `function mlx5_wc_create_cqwq`, `function create_wc_cq`, `function mlx5_wc_create_cq`, `function mlx5_wc_destroy_cq`, `function create_wc_sq`, `function mlx5_wc_create_sq`, `function mlx5_wc_destroy_sq`, `function mlx5_iowrite64_copy`.
- 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.