drivers/infiniband/core/cma.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/cma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/cma.c- Extension
.c- Size
- 151564 bytes
- Lines
- 5676
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/completion.hlinux/in.hlinux/in6.hlinux/mutex.hlinux/random.hlinux/rbtree.hlinux/igmp.hlinux/xarray.hlinux/inetdevice.hlinux/slab.hlinux/module.hnet/route.hnet/net_namespace.hnet/netns/generic.hnet/netevent.hnet/tcp.hnet/ipv6.hnet/ip_fib.hnet/ip6_route.hrdma/rdma_cm.hrdma/rdma_cm_ib.hrdma/rdma_netlink.hrdma/ib.hrdma/ib_cache.hrdma/ib_cm.hrdma/ib_sa.hrdma/iw_cm.hcore_priv.hcma_priv.hcma_trace.h
Detected Declarations
struct cma_pernetstruct id_table_entrystruct cma_devicestruct rdma_bind_liststruct cma_multicaststruct cma_workstruct cma_hdrstruct cma_req_infostruct iboe_prio_tc_mapfunction rdma_event_msgfunction rdma_reject_msgfunction rdma_is_consumer_rejectfunction rdma_iw_cm_idfunction cma_ps_allocfunction cma_ps_removefunction cma_dev_getfunction cma_dev_putfunction list_for_each_entryfunction cma_get_default_gid_typefunction cma_set_default_gid_typefunction cma_get_default_roce_tosfunction cma_set_default_roce_tosfunction cma_comp_exchfunction cma_get_ip_verfunction cma_set_ip_verfunction cma_igmp_sendfunction compare_netdev_and_ipfunction cma_add_id_to_treefunction node_from_ndev_ipfunction cma_remove_id_from_treefunction _cma_attach_to_devfunction cma_attach_to_devfunction cma_release_devfunction cma_familyfunction cma_set_default_qkeyfunction cma_set_qkeyfunction cma_translate_ibfunction cma_translate_addrfunction cma_validate_portfunction cma_bind_sgid_attrfunction cma_acquire_dev_by_src_ipfunction rdma_for_each_portfunction cma_ib_acquire_devfunction cma_iw_acquire_devfunction list_for_each_entryfunction cma_resolve_ib_devfunction rdma_for_each_portfunction cma_id_get
Annotated Snippet
module_init(cma_init);
module_exit(cma_cleanup);
static void cma_query_ib_service_handler(int status,
struct sa_service_rec *recs,
unsigned int num_recs, void *context)
{
struct cma_work *work = context;
struct rdma_id_private *id_priv = work->id;
struct sockaddr_ib *addr;
if (status)
goto fail;
if (!num_recs) {
status = -ENOENT;
goto fail;
}
if (id_priv->id.route.service_recs) {
status = -EALREADY;
goto fail;
}
id_priv->id.route.service_recs =
kmalloc_objs(*recs, num_recs);
if (!id_priv->id.route.service_recs) {
status = -ENOMEM;
goto fail;
}
id_priv->id.route.num_service_recs = num_recs;
memcpy(id_priv->id.route.service_recs, recs, sizeof(*recs) * num_recs);
addr = (struct sockaddr_ib *)&id_priv->id.route.addr.dst_addr;
addr->sib_family = AF_IB;
addr->sib_addr = *(struct ib_addr *)&recs->gid;
addr->sib_pkey = recs->pkey;
addr->sib_sid = recs->id;
rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr,
(union ib_gid *)&addr->sib_addr);
ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr,
ntohs(addr->sib_pkey));
queue_work(cma_wq, &work->work);
return;
fail:
work->old_state = RDMA_CM_ADDRINFO_QUERY;
work->new_state = RDMA_CM_ADDR_BOUND;
work->event.event = RDMA_CM_EVENT_ADDRINFO_ERROR;
work->event.status = status;
pr_debug_ratelimited(
"RDMA CM: SERVICE_ERROR: failed to query service record. status %d\n",
status);
queue_work(cma_wq, &work->work);
}
static int cma_resolve_ib_service(struct rdma_id_private *id_priv,
struct rdma_ucm_ib_service *ibs)
{
struct sa_service_rec sr = {};
ib_sa_comp_mask mask = 0;
struct cma_work *work;
work = kzalloc_obj(*work);
if (!work)
return -ENOMEM;
cma_id_get(id_priv);
work->id = id_priv;
INIT_WORK(&work->work, cma_work_handler);
work->old_state = RDMA_CM_ADDRINFO_QUERY;
work->new_state = RDMA_CM_ADDRINFO_RESOLVED;
work->event.event = RDMA_CM_EVENT_ADDRINFO_RESOLVED;
if (ibs->flags & RDMA_USER_CM_IB_SERVICE_FLAG_ID) {
sr.id = cpu_to_be64(ibs->service_id);
mask |= IB_SA_SERVICE_REC_SERVICE_ID;
}
if (ibs->flags & RDMA_USER_CM_IB_SERVICE_FLAG_NAME) {
strscpy(sr.name, ibs->service_name, sizeof(sr.name));
mask |= IB_SA_SERVICE_REC_SERVICE_NAME;
}
id_priv->query_id = ib_sa_service_rec_get(&sa_client,
id_priv->id.device,
id_priv->id.port_num,
&sr, mask,
Annotation
- Immediate include surface: `linux/completion.h`, `linux/in.h`, `linux/in6.h`, `linux/mutex.h`, `linux/random.h`, `linux/rbtree.h`, `linux/igmp.h`, `linux/xarray.h`.
- Detected declarations: `struct cma_pernet`, `struct id_table_entry`, `struct cma_device`, `struct rdma_bind_list`, `struct cma_multicast`, `struct cma_work`, `struct cma_hdr`, `struct cma_req_info`, `struct iboe_prio_tc_map`, `function rdma_event_msg`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: integration 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.