drivers/infiniband/hw/mlx5/qp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/qp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/qp.c- Extension
.c- Size
- 166579 bytes
- Lines
- 6003
- 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/etherdevice.hrdma/ib_umem.hrdma/ib_cache.hrdma/ib_user_verbs.hrdma/rdma_counter.hlinux/mlx5/fs.hmlx5_ib.hib_rep.hcounters.hcmd.humr.hqp.hwr.hrdma/uverbs_named_ioctl.h
Detected Declarations
struct mlx5_rate_limit_ctxstruct mlx5_modify_raw_qp_paramstruct mlx5_ib_qp_event_workstruct mlx5_create_qp_paramsstruct mlx5_ib_drain_cqeenum raw_qp_set_mask_mapfunction is_qp0function is_sqpfunction mlx5_ib_read_user_wqe_commonfunction mlx5_ib_read_kernel_wqe_sqfunction mlx5_ib_read_user_wqe_sqfunction mlx5_ib_read_wqe_sqfunction mlx5_ib_read_user_wqe_rqfunction mlx5_ib_read_wqe_rqfunction mlx5_ib_read_user_wqe_srqfunction mlx5_ib_read_wqe_srqfunction mlx5_ib_qp_err_syndromefunction mlx5_ib_handle_qp_eventfunction mlx5_ib_qp_eventfunction set_rq_sizefunction sq_overheadfunction calc_send_wqefunction get_send_sgefunction calc_sq_sizefunction set_user_buf_sizefunction qp_has_rqfunction max_bfregsfunction num_med_bfregfunction first_med_bfregfunction first_hi_bfregfunction alloc_high_class_bfregfunction alloc_med_class_bfregfunction alloc_bfregfunction mlx5_ib_free_bfregfunction to_mlx5_statefunction to_mlx5_stfunction bfregn_to_uar_indexfunction destroy_user_rqfunction create_user_rqfunction adjust_bfregnfunction mlx5_qp_buf_attrfunction _create_user_qpfunction destroy_qpfunction _create_kernel_qpfunction get_rx_typefunction create_raw_packet_qp_tisfunction destroy_raw_packet_qp_tisfunction destroy_flow_rule_vport_sq
Annotated Snippet
struct mlx5_rate_limit_ctx {
struct mlx5_rate_limit rl_old;
struct mlx5_rate_limit rl_desired;
u16 rl_desired_index;
bool rl_changed;
};
struct mlx5_modify_raw_qp_param {
u16 operation;
u32 set_mask; /* raw_qp_set_mask_map */
struct mlx5_rate_limit_ctx rl_ctx;
u8 rq_q_ctr_id;
u32 port;
};
struct mlx5_ib_qp_event_work {
struct work_struct work;
struct mlx5_core_qp *qp;
int type;
};
static struct workqueue_struct *mlx5_ib_qp_event_wq;
static void get_cqs(enum ib_qp_type qp_type,
struct ib_cq *ib_send_cq, struct ib_cq *ib_recv_cq,
struct mlx5_ib_cq **send_cq, struct mlx5_ib_cq **recv_cq);
static int is_qp0(enum ib_qp_type qp_type)
{
return qp_type == IB_QPT_SMI;
}
static int is_sqp(enum ib_qp_type qp_type)
{
return is_qp0(qp_type) || is_qp1(qp_type);
}
/**
* mlx5_ib_read_user_wqe_common() - Copy a WQE (or part of) from user WQ
* to kernel buffer
*
* @umem: User space memory where the WQ is
* @buffer: buffer to copy to
* @buflen: buffer length
* @wqe_index: index of WQE to copy from
* @wq_offset: offset to start of WQ
* @wq_wqe_cnt: number of WQEs in WQ
* @wq_wqe_shift: log2 of WQE size
* @bcnt: number of bytes to copy
* @bytes_copied: number of bytes to copy (return value)
*
* Copies from start of WQE bcnt or less bytes.
* Does not gurantee to copy the entire WQE.
*
* Return: zero on success, or an error code.
*/
static int mlx5_ib_read_user_wqe_common(struct ib_umem *umem, void *buffer,
size_t buflen, int wqe_index,
int wq_offset, int wq_wqe_cnt,
int wq_wqe_shift, int bcnt,
size_t *bytes_copied)
{
size_t offset = wq_offset + ((wqe_index % wq_wqe_cnt) << wq_wqe_shift);
size_t wq_end = wq_offset + (wq_wqe_cnt << wq_wqe_shift);
size_t copy_length;
int ret;
/* don't copy more than requested, more than buffer length or
* beyond WQ end
*/
copy_length = min_t(u32, buflen, wq_end - offset);
copy_length = min_t(u32, copy_length, bcnt);
ret = ib_umem_copy_from(buffer, umem, offset, copy_length);
if (ret)
return ret;
if (!ret && bytes_copied)
*bytes_copied = copy_length;
return 0;
}
static int mlx5_ib_read_kernel_wqe_sq(struct mlx5_ib_qp *qp, int wqe_index,
void *buffer, size_t buflen, size_t *bc)
{
struct mlx5_wqe_ctrl_seg *ctrl;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `rdma/ib_umem.h`, `rdma/ib_cache.h`, `rdma/ib_user_verbs.h`, `rdma/rdma_counter.h`, `linux/mlx5/fs.h`, `mlx5_ib.h`, `ib_rep.h`.
- Detected declarations: `struct mlx5_rate_limit_ctx`, `struct mlx5_modify_raw_qp_param`, `struct mlx5_ib_qp_event_work`, `struct mlx5_create_qp_params`, `struct mlx5_ib_drain_cqe`, `enum raw_qp_set_mask_map`, `function is_qp0`, `function is_sqp`, `function mlx5_ib_read_user_wqe_common`, `function mlx5_ib_read_kernel_wqe_sq`.
- 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.