drivers/infiniband/hw/mlx4/qp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx4/qp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx4/qp.c- Extension
.c- Size
- 125838 bytes
- Lines
- 4482
- 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.
- 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
linux/log2.hlinux/etherdevice.hnet/ip.hlinux/slab.hlinux/netdevice.hrdma/ib_cache.hrdma/ib_pack.hrdma/ib_addr.hrdma/ib_mad.hrdma/uverbs_ioctl.hlinux/mlx4/driver.hlinux/mlx4/qp.hmlx4_ib.hrdma/mlx4-abi.h
Detected Declarations
struct mlx4_ib_qp_event_workstruct mlx4_ib_drain_cqeenum mlx4_ib_source_typefunction is_tunnel_qpfunction is_sqpfunction is_qp0function stamp_send_wqefunction mlx4_ib_handle_qp_eventfunction mlx4_ib_qp_eventfunction mlx4_ib_wq_eventfunction send_wqe_overheadfunction set_rq_sizefunction set_kernel_sq_sizefunction set_user_sq_sizefunction alloc_proxy_bufsfunction free_proxy_bufsfunction qp_has_rqfunction qp0_enabled_vffunction mlx4_ib_free_qp_counterfunction set_qp_rssfunction create_qp_rssfunction _mlx4_ib_create_qp_rssfunction mlx4_ib_alloc_wqnfunction mlx4_ib_release_wqnfunction create_rqfunction create_qp_commonfunction to_mlx4_statefunction mlx4_ib_lock_cqsfunction mlx4_ib_unlock_cqsfunction del_gid_entriesfunction list_for_each_entry_safefunction get_cqsfunction destroy_qp_rssfunction destroy_qp_commonfunction get_sqp_numfunction _mlx4_ib_create_qpfunction mlx4_ib_create_qpfunction _mlx4_ib_destroy_qpfunction mlx4_ib_destroy_qpfunction to_mlx4_stfunction to_mlx4_access_flagsfunction store_sqp_attrsfunction mlx4_set_schedfunction _mlx4_set_pathfunction mlx4_set_pathfunction mlx4_set_alt_pathfunction update_mcg_macsfunction list_for_each_entry_safe
Annotated Snippet
struct mlx4_ib_qp_event_work {
struct work_struct work;
struct mlx4_qp *qp;
enum mlx4_event type;
};
static struct workqueue_struct *mlx4_ib_qp_event_wq;
static int is_tunnel_qp(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
{
if (!mlx4_is_master(dev->dev))
return 0;
return qp->mqp.qpn >= dev->dev->phys_caps.base_tunnel_sqpn &&
qp->mqp.qpn < dev->dev->phys_caps.base_tunnel_sqpn +
8 * MLX4_MFUNC_MAX;
}
static int is_sqp(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
{
int proxy_sqp = 0;
int real_sqp = 0;
int i;
/* PPF or Native -- real SQP */
real_sqp = ((mlx4_is_master(dev->dev) || !mlx4_is_mfunc(dev->dev)) &&
qp->mqp.qpn >= dev->dev->phys_caps.base_sqpn &&
qp->mqp.qpn <= dev->dev->phys_caps.base_sqpn + 3);
if (real_sqp)
return 1;
/* VF or PF -- proxy SQP */
if (mlx4_is_mfunc(dev->dev)) {
for (i = 0; i < dev->dev->caps.num_ports; i++) {
if (qp->mqp.qpn == dev->dev->caps.spec_qps[i].qp0_proxy ||
qp->mqp.qpn == dev->dev->caps.spec_qps[i].qp1_proxy) {
proxy_sqp = 1;
break;
}
}
}
if (proxy_sqp)
return 1;
return !!(qp->flags & MLX4_IB_ROCE_V2_GSI_QP);
}
/* used for INIT/CLOSE port logic */
static int is_qp0(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
{
int proxy_qp0 = 0;
int real_qp0 = 0;
int i;
/* PPF or Native -- real QP0 */
real_qp0 = ((mlx4_is_master(dev->dev) || !mlx4_is_mfunc(dev->dev)) &&
qp->mqp.qpn >= dev->dev->phys_caps.base_sqpn &&
qp->mqp.qpn <= dev->dev->phys_caps.base_sqpn + 1);
if (real_qp0)
return 1;
/* VF or PF -- proxy QP0 */
if (mlx4_is_mfunc(dev->dev)) {
for (i = 0; i < dev->dev->caps.num_ports; i++) {
if (qp->mqp.qpn == dev->dev->caps.spec_qps[i].qp0_proxy) {
proxy_qp0 = 1;
break;
}
}
}
return proxy_qp0;
}
static void *get_wqe(struct mlx4_ib_qp *qp, int offset)
{
return mlx4_buf_offset(&qp->buf, offset);
}
static void *get_recv_wqe(struct mlx4_ib_qp *qp, int n)
{
return get_wqe(qp, qp->rq.offset + (n << qp->rq.wqe_shift));
}
static void *get_send_wqe(struct mlx4_ib_qp *qp, int n)
{
return get_wqe(qp, qp->sq.offset + (n << qp->sq.wqe_shift));
}
/*
* Stamp a SQ WQE so that it is invalid if prefetched by marking the
* first four bytes of every 64 byte chunk with 0xffffffff, except for
* the very first chunk of the WQE.
*/
static void stamp_send_wqe(struct mlx4_ib_qp *qp, int n)
Annotation
- Immediate include surface: `linux/log2.h`, `linux/etherdevice.h`, `net/ip.h`, `linux/slab.h`, `linux/netdevice.h`, `rdma/ib_cache.h`, `rdma/ib_pack.h`, `rdma/ib_addr.h`.
- Detected declarations: `struct mlx4_ib_qp_event_work`, `struct mlx4_ib_drain_cqe`, `enum mlx4_ib_source_type`, `function is_tunnel_qp`, `function is_sqp`, `function is_qp0`, `function stamp_send_wqe`, `function mlx4_ib_handle_qp_event`, `function mlx4_ib_qp_event`, `function mlx4_ib_wq_event`.
- 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.
- 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.