drivers/infiniband/hw/mlx5/cq.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/cq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/cq.c- Extension
.c- Size
- 39017 bytes
- Lines
- 1534
- 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.
- 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/kref.hrdma/ib_umem.hrdma/ib_user_verbs.hrdma/ib_cache.hmlx5_ib.hsrq.hqp.hrdma/uverbs_named_ioctl.h
Detected Declarations
function Copyrightfunction mlx5_ib_cq_eventfunction sw_ownership_bitfunction get_umr_compfunction handle_good_reqfunction handle_responderfunction dump_cqefunction mlx5_handle_error_cqefunction handle_atomicsfunction free_cq_buffunction get_sig_err_itemfunction sw_compfunction mlx5_ib_poll_sw_compfunction list_for_each_entryfunction mlx5_poll_onefunction poll_soft_wcfunction list_for_each_entry_safefunction mlx5_ib_poll_cqfunction mlx5_ib_arm_cqfunction alloc_cq_frag_buffunction mini_cqe_res_format_to_hwfunction create_cq_userfunction destroy_cq_userfunction init_cq_frag_buffunction create_cq_kernelfunction destroy_cq_kernelfunction notify_soft_wc_handlerfunction mlx5_ib_create_user_cqfunction mlx5_ib_create_cqfunction mlx5_ib_pre_destroy_cqfunction mlx5_ib_post_destroy_cqfunction mlx5_ib_destroy_cqfunction is_equal_rsnfunction __mlx5_ib_cq_cleanfunction mlx5_ib_cq_cleanfunction mlx5_ib_modify_cqfunction resize_userfunction resize_kernelfunction copy_resize_cqesfunction mlx5_ib_resize_cqfunction mlx5_ib_get_cqe_sizefunction mlx5_ib_generate_wc
Annotated Snippet
if (qp->ibqp.xrcd) {
msrq = mlx5_cmd_get_srq(dev, be32_to_cpu(cqe->srqn));
if (msrq)
srq = to_mibsrq(msrq);
} else {
srq = to_msrq(qp->ibqp.srq);
}
if (srq) {
wqe_ctr = be16_to_cpu(cqe->wqe_counter);
wc->wr_id = srq->wrid[wqe_ctr];
mlx5_ib_free_srq_wqe(srq, wqe_ctr);
if (msrq)
mlx5_core_res_put(&msrq->common);
}
} else {
wq = &qp->rq;
wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
++wq->tail;
}
wc->byte_len = be32_to_cpu(cqe->byte_cnt);
switch (get_cqe_opcode(cqe)) {
case MLX5_CQE_RESP_WR_IMM:
wc->opcode = IB_WC_RECV_RDMA_WITH_IMM;
wc->wc_flags = IB_WC_WITH_IMM;
wc->ex.imm_data = cqe->immediate;
break;
case MLX5_CQE_RESP_SEND:
wc->opcode = IB_WC_RECV;
wc->wc_flags = IB_WC_IP_CSUM_OK;
if (unlikely(!((cqe->hds_ip_ext & CQE_L3_OK) &&
(cqe->hds_ip_ext & CQE_L4_OK))))
wc->wc_flags = 0;
break;
case MLX5_CQE_RESP_SEND_IMM:
wc->opcode = IB_WC_RECV;
wc->wc_flags = IB_WC_WITH_IMM;
wc->ex.imm_data = cqe->immediate;
break;
case MLX5_CQE_RESP_SEND_INV:
wc->opcode = IB_WC_RECV;
wc->wc_flags = IB_WC_WITH_INVALIDATE;
wc->ex.invalidate_rkey = be32_to_cpu(cqe->inval_rkey);
break;
}
wc->src_qp = be32_to_cpu(cqe->flags_rqpn) & 0xffffff;
wc->dlid_path_bits = cqe->ml_path;
g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3;
wc->wc_flags |= g ? IB_WC_GRH : 0;
if (is_qp1(qp->type)) {
u16 pkey = be32_to_cpu(cqe->pkey) & 0xffff;
ib_find_cached_pkey(&dev->ib_dev, qp->port, pkey,
&wc->pkey_index);
} else {
wc->pkey_index = 0;
}
if (ll != IB_LINK_LAYER_ETHERNET) {
wc->slid = be16_to_cpu(cqe->slid);
wc->sl = (be32_to_cpu(cqe->flags_rqpn) >> 24) & 0xf;
return;
}
wc->slid = 0;
vlan_present = cqe->l4_l3_hdr_type & 0x1;
roce_packet_type = (be32_to_cpu(cqe->flags_rqpn) >> 24) & 0x3;
if (vlan_present) {
wc->vlan_id = (be16_to_cpu(cqe->vlan_info)) & 0xfff;
wc->sl = (be16_to_cpu(cqe->vlan_info) >> 13) & 0x7;
wc->wc_flags |= IB_WC_WITH_VLAN;
} else {
wc->sl = 0;
}
switch (roce_packet_type) {
case MLX5_CQE_ROCE_L3_HEADER_TYPE_GRH:
wc->network_hdr_type = RDMA_NETWORK_ROCE_V1;
break;
case MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV6:
wc->network_hdr_type = RDMA_NETWORK_IPV6;
break;
case MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV4:
wc->network_hdr_type = RDMA_NETWORK_IPV4;
break;
}
wc->wc_flags |= IB_WC_WITH_NETWORK_HDR_TYPE;
}
static void dump_cqe(struct mlx5_ib_dev *dev, struct mlx5_err_cqe *cqe,
Annotation
- Immediate include surface: `linux/kref.h`, `rdma/ib_umem.h`, `rdma/ib_user_verbs.h`, `rdma/ib_cache.h`, `mlx5_ib.h`, `srq.h`, `qp.h`, `rdma/uverbs_named_ioctl.h`.
- Detected declarations: `function Copyright`, `function mlx5_ib_cq_event`, `function sw_ownership_bit`, `function get_umr_comp`, `function handle_good_req`, `function handle_responder`, `function dump_cqe`, `function mlx5_handle_error_cqe`, `function handle_atomics`, `function free_cq_buf`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.