drivers/infiniband/hw/mlx5/qpc.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/qpc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/qpc.c- Extension
.c- Size
- 18473 bytes
- Lines
- 705
- 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/gfp.hlinux/mlx5/qp.hlinux/mlx5/driver.hmlx5_ib.hqp.h
Detected Declarations
struct mbox_infofunction mlx5_get_rscfunction mlx5_core_put_rscfunction qp_allowed_event_typesfunction rq_allowed_event_typesfunction sq_allowed_event_typesfunction dct_allowed_event_typesfunction is_event_type_allowedfunction dct_event_notifierfunction rsc_event_notifierfunction create_resource_commonfunction modify_resource_common_statefunction destroy_resource_commonfunction _mlx5_core_destroy_dctfunction mlx5_core_create_dctfunction mlx5_qpc_create_qpfunction mlx5_core_drain_dctfunction mlx5_core_destroy_dctfunction mlx5_core_destroy_qpfunction mlx5_core_set_delay_dropfunction mbox_allocfunction mbox_freefunction get_ece_from_mboxfunction modify_qp_mbox_allocfunction mlx5_core_qp_modifyfunction mlx5_init_qp_tablefunction mlx5_cleanup_qp_tablefunction mlx5_core_qp_queryfunction mlx5_core_dct_queryfunction mlx5_core_xrcd_allocfunction mlx5_core_xrcd_deallocfunction destroy_rq_trackedfunction mlx5_core_create_rq_trackedfunction mlx5_core_destroy_rq_trackedfunction destroy_sq_trackedfunction mlx5_core_create_sq_trackedfunction mlx5_core_destroy_sq_trackedfunction mlx5_core_res_put
Annotated Snippet
struct mbox_info {
u32 *in;
u32 *out;
int inlen;
int outlen;
};
static int mbox_alloc(struct mbox_info *mbox, int inlen, int outlen)
{
mbox->inlen = inlen;
mbox->outlen = outlen;
mbox->in = kzalloc(mbox->inlen, GFP_KERNEL);
mbox->out = kzalloc(mbox->outlen, GFP_KERNEL);
if (!mbox->in || !mbox->out) {
kfree(mbox->in);
kfree(mbox->out);
return -ENOMEM;
}
return 0;
}
static void mbox_free(struct mbox_info *mbox)
{
kfree(mbox->in);
kfree(mbox->out);
}
static int get_ece_from_mbox(void *out, u16 opcode)
{
int ece = 0;
switch (opcode) {
case MLX5_CMD_OP_INIT2INIT_QP:
ece = MLX5_GET(init2init_qp_out, out, ece);
break;
case MLX5_CMD_OP_INIT2RTR_QP:
ece = MLX5_GET(init2rtr_qp_out, out, ece);
break;
case MLX5_CMD_OP_RTR2RTS_QP:
ece = MLX5_GET(rtr2rts_qp_out, out, ece);
break;
case MLX5_CMD_OP_RTS2RTS_QP:
ece = MLX5_GET(rts2rts_qp_out, out, ece);
break;
case MLX5_CMD_OP_RST2INIT_QP:
ece = MLX5_GET(rst2init_qp_out, out, ece);
break;
default:
break;
}
return ece;
}
static int modify_qp_mbox_alloc(struct mlx5_core_dev *dev, u16 opcode, int qpn,
u32 opt_param_mask, void *qpc,
struct mbox_info *mbox, u16 uid, u32 ece)
{
mbox->out = NULL;
mbox->in = NULL;
#define MBOX_ALLOC(mbox, typ) \
mbox_alloc(mbox, MLX5_ST_SZ_BYTES(typ##_in), MLX5_ST_SZ_BYTES(typ##_out))
#define MOD_QP_IN_SET(typ, in, _opcode, _qpn, _uid) \
do { \
MLX5_SET(typ##_in, in, opcode, _opcode); \
MLX5_SET(typ##_in, in, qpn, _qpn); \
MLX5_SET(typ##_in, in, uid, _uid); \
} while (0)
#define MOD_QP_IN_SET_QPC(typ, in, _opcode, _qpn, _opt_p, _qpc, _uid) \
do { \
MOD_QP_IN_SET(typ, in, _opcode, _qpn, _uid); \
MLX5_SET(typ##_in, in, opt_param_mask, _opt_p); \
memcpy(MLX5_ADDR_OF(typ##_in, in, qpc), _qpc, \
MLX5_ST_SZ_BYTES(qpc)); \
} while (0)
switch (opcode) {
/* 2RST & 2ERR */
case MLX5_CMD_OP_2RST_QP:
if (MBOX_ALLOC(mbox, qp_2rst))
return -ENOMEM;
MOD_QP_IN_SET(qp_2rst, mbox->in, opcode, qpn, uid);
break;
case MLX5_CMD_OP_2ERR_QP:
if (MBOX_ALLOC(mbox, qp_2err))
return -ENOMEM;
Annotation
- Immediate include surface: `linux/gfp.h`, `linux/mlx5/qp.h`, `linux/mlx5/driver.h`, `mlx5_ib.h`, `qp.h`.
- Detected declarations: `struct mbox_info`, `function mlx5_get_rsc`, `function mlx5_core_put_rsc`, `function qp_allowed_event_types`, `function rq_allowed_event_types`, `function sq_allowed_event_types`, `function dct_allowed_event_types`, `function is_event_type_allowed`, `function dct_event_notifier`, `function rsc_event_notifier`.
- 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.