drivers/infiniband/sw/siw/siw_cm.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/siw/siw_cm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/siw/siw_cm.c- Extension
.c- Size
- 48239 bytes
- Lines
- 2010
- 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/errno.hlinux/types.hlinux/net.hlinux/inetdevice.hnet/addrconf.hlinux/workqueue.hnet/sock.hnet/tcp.hlinux/inet.hlinux/tcp.htrace/events/sock.hrdma/iw_cm.hrdma/ib_verbs.hrdma/ib_user_verbs.hsiw.hsiw_cm.h
Detected Declarations
function siw_reclassify_socketfunction siw_sk_assign_cm_upcallsfunction siw_sk_restore_upcallsfunction siw_qp_socket_assocfunction siw_socket_disassocfunction siw_rtr_data_readyfunction siw_sk_assign_rtr_upcallsfunction siw_cep_socket_assocfunction siw_cm_free_workfunction list_for_each_safefunction siw_cancel_mpatimerfunction siw_put_workfunction siw_cep_set_inusefunction siw_cep_set_freefunction __siw_cep_deallocfunction siw_cm_alloc_workfunction siw_cm_upcallfunction siw_free_cm_idfunction siw_destroy_cep_sockfunction siw_qp_cm_dropfunction siw_cep_putfunction siw_cep_set_free_and_putfunction siw_cep_getfunction siw_send_mpareqrepfunction siw_recv_mpa_rrfunction siw_proc_mpareqfunction siw_proc_mpareplyfunction siw_accept_newconnfunction siw_cm_work_handlerfunction siw_cm_queue_workfunction siw_cm_llp_data_readyfunction siw_cm_llp_write_spacefunction siw_cm_llp_error_reportfunction siw_cm_llp_state_changefunction kernel_bindconnectfunction siw_connectfunction siw_acceptfunction siw_rejectfunction siw_create_listenfunction siw_drop_listenersfunction siw_destroy_listenfunction siw_cm_initfunction siw_cm_exit
Annotated Snippet
rv = sock_create(v4 ? AF_INET : AF_INET6, SOCK_STREAM, IPPROTO_TCP, &s);
if (rv < 0)
goto error;
siw_reclassify_socket(s);
/*
* NOTE: For simplification, connect() is called in blocking
* mode. Might be reconsidered for async connection setup at
* TCP level.
*/
rv = kernel_bindconnect(s, laddr, raddr, id->afonly);
if (rv != 0) {
siw_dbg_qp(qp, "kernel_bindconnect: error %d\n", rv);
goto error;
}
if (siw_tcp_nagle == false)
tcp_sock_set_nodelay(s->sk);
cep = siw_cep_alloc(sdev);
if (!cep) {
rv = -ENOMEM;
goto error;
}
siw_cep_set_inuse(cep);
/* Associate QP with CEP */
siw_cep_get(cep);
qp->cep = cep;
/* siw_qp_get(qp) already done by QP lookup */
cep->qp = qp;
id->add_ref(id);
cep->cm_id = id;
/*
* 4: Allocate a sufficient number of work elements
* to allow concurrent handling of local + peer close
* events, MPA header processing + MPA timeout.
*/
rv = siw_cm_alloc_work(cep, 4);
if (rv != 0) {
rv = -ENOMEM;
goto error;
}
cep->ird = params->ird;
cep->ord = params->ord;
if (p2p_mode && cep->ord == 0)
cep->ord = 1;
cep->state = SIW_EPSTATE_CONNECTING;
/*
* Associate CEP with socket
*/
siw_cep_socket_assoc(cep, s);
cep->state = SIW_EPSTATE_AWAIT_MPAREP;
/*
* Set MPA Request bits: CRC if required, no MPA Markers,
* MPA Rev. according to module parameter 'mpa_version', Key 'Request'.
*/
cep->mpa.hdr.params.bits = 0;
if (version > MPA_REVISION_2) {
pr_warn("Setting MPA version to %u\n", MPA_REVISION_2);
version = MPA_REVISION_2;
/* Adjust also module parameter */
mpa_version = MPA_REVISION_2;
}
__mpa_rr_set_revision(&cep->mpa.hdr.params.bits, version);
if (try_gso)
cep->mpa.hdr.params.bits |= MPA_RR_FLAG_GSO_EXP;
if (mpa_crc_required)
cep->mpa.hdr.params.bits |= MPA_RR_FLAG_CRC;
/*
* If MPA version == 2:
* o Include ORD and IRD.
* o Indicate peer-to-peer mode, if required by module
* parameter 'peer_to_peer'.
*/
if (version == MPA_REVISION_2) {
cep->enhanced_rdma_conn_est = true;
cep->mpa.hdr.params.bits |= MPA_RR_FLAG_ENHANCED;
cep->mpa.v2_ctrl.ird = htons(cep->ird);
cep->mpa.v2_ctrl.ord = htons(cep->ord);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/net.h`, `linux/inetdevice.h`, `net/addrconf.h`, `linux/workqueue.h`, `net/sock.h`, `net/tcp.h`.
- Detected declarations: `function siw_reclassify_socket`, `function siw_sk_assign_cm_upcalls`, `function siw_sk_restore_upcalls`, `function siw_qp_socket_assoc`, `function siw_socket_disassoc`, `function siw_rtr_data_ready`, `function siw_sk_assign_rtr_upcalls`, `function siw_cep_socket_assoc`, `function siw_cm_free_work`, `function list_for_each_safe`.
- 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.