drivers/infiniband/hw/mlx4/cm.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx4/cm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx4/cm.c- Extension
.c- Size
- 16759 bytes
- Lines
- 605
- 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
rdma/ib_mad.hlinux/mlx4/cmd.hlinux/rbtree.hlinux/idr.hrdma/ib_cm.hmlx4_ib.h
Detected Declarations
struct id_map_entrystruct rej_tmout_entrystruct cm_generic_msgstruct cm_sidr_generic_msgstruct cm_req_msgfunction set_local_comm_idfunction get_local_comm_idfunction set_remote_comm_idfunction get_remote_comm_idfunction gid_from_req_msgfunction id_map_find_by_sl_idfunction id_map_ent_timeoutfunction sl_id_map_addfunction id_map_allocfunction id_map_getfunction schedule_delayedfunction mlx4_ib_multiplex_cm_handlerfunction rej_tmout_timeoutfunction alloc_rej_tmoutfunction lookup_rej_tmout_slavefunction mlx4_ib_demux_cm_handlerfunction mlx4_ib_cm_paravirt_initfunction rej_tmout_xa_cleanupfunction mlx4_ib_cm_paravirt_cleanfunction list_for_each_entry_safefunction list_for_each_entry_safefunction mlx4_ib_cm_initfunction mlx4_ib_cm_destroy
Annotated Snippet
struct id_map_entry {
struct rb_node node;
u32 sl_cm_id;
u32 pv_cm_id;
int slave_id;
int scheduled_delete;
struct mlx4_ib_dev *dev;
struct list_head list;
struct delayed_work timeout;
};
struct rej_tmout_entry {
int slave;
u32 rem_pv_cm_id;
struct delayed_work timeout;
struct xarray *xa_rej_tmout;
};
struct cm_generic_msg {
struct ib_mad_hdr hdr;
__be32 local_comm_id;
__be32 remote_comm_id;
unsigned char unused[2];
__be16 rej_reason;
};
struct cm_sidr_generic_msg {
struct ib_mad_hdr hdr;
__be32 request_id;
};
struct cm_req_msg {
unsigned char unused[0x60];
union ib_gid primary_path_sgid;
};
static struct workqueue_struct *cm_wq;
static void set_local_comm_id(struct ib_mad *mad, u32 cm_id)
{
if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) {
struct cm_sidr_generic_msg *msg =
(struct cm_sidr_generic_msg *)mad;
msg->request_id = cpu_to_be32(cm_id);
} else if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) {
pr_err("trying to set local_comm_id in SIDR_REP\n");
return;
} else {
struct cm_generic_msg *msg = (struct cm_generic_msg *)mad;
msg->local_comm_id = cpu_to_be32(cm_id);
}
}
static u32 get_local_comm_id(struct ib_mad *mad)
{
if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) {
struct cm_sidr_generic_msg *msg =
(struct cm_sidr_generic_msg *)mad;
return be32_to_cpu(msg->request_id);
} else if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) {
pr_err("trying to set local_comm_id in SIDR_REP\n");
return -1;
} else {
struct cm_generic_msg *msg = (struct cm_generic_msg *)mad;
return be32_to_cpu(msg->local_comm_id);
}
}
static void set_remote_comm_id(struct ib_mad *mad, u32 cm_id)
{
if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) {
struct cm_sidr_generic_msg *msg =
(struct cm_sidr_generic_msg *)mad;
msg->request_id = cpu_to_be32(cm_id);
} else if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) {
pr_err("trying to set remote_comm_id in SIDR_REQ\n");
return;
} else {
struct cm_generic_msg *msg = (struct cm_generic_msg *)mad;
msg->remote_comm_id = cpu_to_be32(cm_id);
}
}
static u32 get_remote_comm_id(struct ib_mad *mad)
{
if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) {
struct cm_sidr_generic_msg *msg =
Annotation
- Immediate include surface: `rdma/ib_mad.h`, `linux/mlx4/cmd.h`, `linux/rbtree.h`, `linux/idr.h`, `rdma/ib_cm.h`, `mlx4_ib.h`.
- Detected declarations: `struct id_map_entry`, `struct rej_tmout_entry`, `struct cm_generic_msg`, `struct cm_sidr_generic_msg`, `struct cm_req_msg`, `function set_local_comm_id`, `function get_local_comm_id`, `function set_remote_comm_id`, `function get_remote_comm_id`, `function gid_from_req_msg`.
- 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.