net/rds/ib_cm.c
Source file repositories/reference/linux-study-clean/net/rds/ib_cm.c
File Facts
- System
- Linux kernel
- Corpus path
net/rds/ib_cm.c- Extension
.c- Size
- 37280 bytes
- Lines
- 1304
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/in.hlinux/slab.hlinux/vmalloc.hlinux/ratelimit.hnet/addrconf.hrdma/ib_cm.hrds_single_path.hrds.hib.hib_mr.h
Detected Declarations
function Copyrightfunction rds_ib_set_flow_controlfunction rds_ib_cm_connect_completefunction rds_ib_cm_fill_conn_paramfunction rds_ib_cq_event_handlerfunction rds_recv_incomingfunction poll_scqfunction rds_ib_tasklet_fn_sendfunction poll_rcqfunction rds_ib_tasklet_fn_recvfunction rds_ib_qp_event_handlerfunction rds_ib_cq_comp_handler_sendfunction ibdev_get_unused_vectorfunction ibdev_put_vectorfunction rds_dma_hdr_freefunction rds_dma_hdrs_freefunction rds_ib_setup_qpfunction rds_ib_protocol_compatiblefunction RDS_PROTOCOLfunction __rds_find_ifindexfunction rds_ib_cm_handle_connectfunction rds_ib_cm_initiate_connectfunction rds_ib_conn_path_connectfunction rds_ib_conn_path_shutdown_check_waitfunction rds_ib_conn_path_shutdownfunction rds_ib_conn_allocfunction rds_ib_conn_freefunction __rds_ib_conn_error
Annotated Snippet
sizeof(struct rds6_ib_connect_private)) {
major = dp->ricp_v6.dp_protocol_major;
minor = dp->ricp_v6.dp_protocol_minor;
credit = dp->ricp_v6.dp_credit;
/* dp structure start is not guaranteed to be 8 bytes
* aligned. Since dp_ack_seq is 64-bit extended load
* operations can be used so go through get_unaligned
* to avoid unaligned errors.
*/
ack_seq = get_unaligned(&dp->ricp_v6.dp_ack_seq);
}
} else if (event->param.conn.private_data_len >=
sizeof(struct rds_ib_connect_private)) {
major = dp->ricp_v4.dp_protocol_major;
minor = dp->ricp_v4.dp_protocol_minor;
credit = dp->ricp_v4.dp_credit;
ack_seq = get_unaligned(&dp->ricp_v4.dp_ack_seq);
}
/* make sure it isn't empty data */
if (major) {
rds_ib_set_protocol(conn, RDS_PROTOCOL(major, minor));
rds_ib_set_flow_control(conn, be32_to_cpu(credit));
}
if (conn->c_version < RDS_PROTOCOL_VERSION) {
if (conn->c_version != RDS_PROTOCOL_COMPAT_VERSION) {
pr_notice("RDS/IB: Connection <%pI6c,%pI6c> version %u.%u no longer supported\n",
&conn->c_laddr, &conn->c_faddr,
RDS_PROTOCOL_MAJOR(conn->c_version),
RDS_PROTOCOL_MINOR(conn->c_version));
rds_conn_destroy(conn);
return;
}
}
pr_notice("RDS/IB: %s conn connected <%pI6c,%pI6c,%d> version %u.%u%s\n",
ic->i_active_side ? "Active" : "Passive",
&conn->c_laddr, &conn->c_faddr, conn->c_tos,
RDS_PROTOCOL_MAJOR(conn->c_version),
RDS_PROTOCOL_MINOR(conn->c_version),
ic->i_flowctl ? ", flow control" : "");
/* receive sl from the peer */
ic->i_sl = ic->i_cm_id->route.path_rec->sl;
atomic_set(&ic->i_cq_quiesce, 0);
/* Init rings and fill recv. this needs to wait until protocol
* negotiation is complete, since ring layout is different
* from 3.1 to 4.1.
*/
rds_ib_send_init_ring(ic);
rds_ib_recv_init_ring(ic);
/* Post receive buffers - as a side effect, this will update
* the posted credit count. */
rds_ib_recv_refill(conn, 1, GFP_KERNEL);
/* update ib_device with this local ipaddr */
err = rds_ib_update_ipaddr(ic->rds_ibdev, &conn->c_laddr);
if (err)
printk(KERN_ERR "rds_ib_update_ipaddr failed (%d)\n",
err);
/* If the peer gave us the last packet it saw, process this as if
* we had received a regular ACK. */
if (dp) {
if (ack_seq)
rds_send_drop_acked(conn, be64_to_cpu(ack_seq),
NULL);
}
conn->c_proposed_version = conn->c_version;
rds_connect_complete(conn);
}
static void rds_ib_cm_fill_conn_param(struct rds_connection *conn,
struct rdma_conn_param *conn_param,
union rds_ib_conn_priv *dp,
u32 protocol_version,
u32 max_responder_resources,
u32 max_initiator_depth,
bool isv6)
{
struct rds_ib_connection *ic = conn->c_transport_data;
struct rds_ib_device *rds_ibdev = ic->rds_ibdev;
memset(conn_param, 0, sizeof(struct rdma_conn_param));
conn_param->responder_resources =
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/in.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/ratelimit.h`, `net/addrconf.h`, `rdma/ib_cm.h`, `rds_single_path.h`.
- Detected declarations: `function Copyright`, `function rds_ib_set_flow_control`, `function rds_ib_cm_connect_complete`, `function rds_ib_cm_fill_conn_param`, `function rds_ib_cq_event_handler`, `function rds_recv_incoming`, `function poll_scq`, `function rds_ib_tasklet_fn_send`, `function poll_rcq`, `function rds_ib_tasklet_fn_recv`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.