drivers/infiniband/hw/erdma/erdma_cm.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/erdma/erdma_cm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/erdma/erdma_cm.c- Extension
.c- Size
- 31738 bytes
- Lines
- 1432
- 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/workqueue.htrace/events/sock.herdma.herdma_cm.herdma_verbs.h
Detected Declarations
function erdma_sk_assign_cm_upcallsfunction erdma_sk_save_upcallsfunction erdma_sk_restore_upcallsfunction erdma_socket_disassocfunction erdma_cep_socket_assocfunction erdma_disassoc_listen_cepfunction erdma_cm_free_workfunction list_for_each_safefunction erdma_cancel_mpatimerfunction erdma_put_workfunction erdma_cep_set_inusefunction erdma_cep_set_freefunction __erdma_cep_deallocfunction erdma_cm_alloc_workfunction erdma_cm_upcallfunction erdma_qp_cm_dropfunction erdma_cep_putfunction erdma_cep_getfunction erdma_send_mpareqrepfunction ksock_recvfunction __recv_mpa_hdrfunction __mpa_rr_set_revisionfunction __mpa_rr_revisionfunction __mpa_ext_set_ccfunction __mpa_ext_ccfunction erdma_recv_mpa_rrfunction erdma_proc_mpareqfunction erdma_proc_mpareplyfunction erdma_accept_newconnfunction erdma_newconn_connectedfunction erdma_cm_work_handlerfunction erdma_cm_queue_workfunction erdma_cm_llp_data_readyfunction erdma_cm_llp_error_reportfunction erdma_cm_llp_state_changefunction kernel_bindconnectfunction erdma_connectfunction erdma_acceptfunction erdma_rejectfunction erdma_create_listenfunction erdma_drop_listenersfunction erdma_destroy_listenfunction erdma_cm_initfunction erdma_cm_exit
Annotated Snippet
ret = sock_create(AF_INET, SOCK_STREAM, IPPROTO_TCP, &s);
if (ret < 0)
goto error_put_qp;
cep = erdma_cep_alloc(dev);
if (!cep) {
ret = -ENOMEM;
goto error_release_sock;
}
erdma_cep_set_inuse(cep);
/* Associate QP with CEP */
erdma_cep_get(cep);
qp->cep = cep;
cep->qp = qp;
/* Associate cm_id with CEP */
id->add_ref(id);
cep->cm_id = id;
/*
* 6: Allocate a sufficient number of work elements
* to allow concurrent handling of local + peer close
* events, MPA header processing + MPA timeout, connected event
* and connect timeout.
*/
ret = erdma_cm_alloc_work(cep, 6);
if (ret != 0) {
ret = -ENOMEM;
goto error_release_cep;
}
cep->ird = params->ird;
cep->ord = params->ord;
cep->state = ERDMA_EPSTATE_CONNECTING;
erdma_cep_socket_assoc(cep, s);
if (pd_len) {
cep->pd_len = pd_len;
cep->private_data = kmalloc(pd_len, GFP_KERNEL);
if (!cep->private_data) {
ret = -ENOMEM;
goto error_disassoc;
}
memcpy(cep->private_data, params->private_data,
params->private_data_len);
}
ret = kernel_bindconnect(s, laddr, sizeof(*laddr), raddr,
sizeof(*raddr), O_NONBLOCK);
if (ret != -EINPROGRESS && ret != 0) {
goto error_disassoc;
} else if (ret == 0) {
ret = erdma_cm_queue_work(cep, ERDMA_CM_WORK_CONNECTED);
if (ret)
goto error_disassoc;
} else {
ret = erdma_cm_queue_work(cep, ERDMA_CM_WORK_CONNECTTIMEOUT);
if (ret)
goto error_disassoc;
}
erdma_cep_set_free(cep);
return 0;
error_disassoc:
kfree(cep->private_data);
cep->private_data = NULL;
cep->pd_len = 0;
erdma_socket_disassoc(s);
error_release_cep:
/* disassoc with cm_id */
cep->cm_id = NULL;
id->rem_ref(id);
/* disassoc with qp */
qp->cep = NULL;
erdma_cep_put(cep);
cep->qp = NULL;
cep->state = ERDMA_EPSTATE_CLOSED;
erdma_cep_set_free(cep);
/* release the cep. */
Annotation
- Immediate include surface: `linux/workqueue.h`, `trace/events/sock.h`, `erdma.h`, `erdma_cm.h`, `erdma_verbs.h`.
- Detected declarations: `function erdma_sk_assign_cm_upcalls`, `function erdma_sk_save_upcalls`, `function erdma_sk_restore_upcalls`, `function erdma_socket_disassoc`, `function erdma_cep_socket_assoc`, `function erdma_disassoc_listen_cep`, `function erdma_cm_free_work`, `function list_for_each_safe`, `function erdma_cancel_mpatimer`, `function erdma_put_work`.
- 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.