net/sunrpc/xprtrdma/verbs.c
Source file repositories/reference/linux-study-clean/net/sunrpc/xprtrdma/verbs.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/xprtrdma/verbs.c- Extension
.c- Size
- 37547 bytes
- Lines
- 1427
- 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/bitops.hlinux/interrupt.hlinux/slab.hlinux/sunrpc/addr.hlinux/sunrpc/svc_rdma.hlinux/log2.hasm/barrier.hrdma/ib_cm.hxprt_rdma.htrace/events/rpcrdma.h
Detected Declarations
function rpcrdma_xprt_drainfunction rpcrdma_force_disconnectfunction rpcrdma_flush_disconnectfunction rpcrdma_wc_sendfunction rpcrdma_wc_receivefunction rpcrdma_update_cm_privatefunction rpcrdma_cm_event_handlerfunction rpcrdma_ep_removal_donefunction rpcrdma_ep_destroyfunction rpcrdma_ep_getfunction rpcrdma_ep_putfunction rpcrdma_ep_createfunction rpcrdma_xprt_connectfunction rpcrdma_xprt_disconnectfunction ib_poll_cqfunction rpcrdma_sendctxs_createfunction modulusfunction functionfunction functionfunction rpcrdma_mrs_createfunction rpcrdma_mr_refresh_workerfunction rpcrdma_mrs_refreshfunction rpcrdma_req_setupfunction rpcrdma_reqs_setupfunction list_for_each_entryfunction rpcrdma_req_resetfunction rpcrdma_reqs_resetfunction rpcrdma_rep_freefunction rpcrdma_rep_putfunction rpcrdma_reps_unmapfunction rpcrdma_reps_destroyfunction rpcrdma_buffer_createfunction rpcrdma_req_destroyfunction rpcrdma_mrs_destroyfunction rpcrdma_buffer_destroyfunction rpcrdma_mr_getfunction rpcrdma_reply_putfunction rpcrdma_buffer_getfunction rpcrdma_buffer_putfunction rpcrdma_regbuf_alloc_nodefunction rpcrdma_regbuf_allocfunction rpcrdma_regbuf_reallocfunction __rpcrdma_regbuf_dma_mapfunction rpcrdma_regbuf_dma_unmapfunction rpcrdma_regbuf_freefunction rpcrdma_post_recvs
Annotated Snippet
if (rc) {
kfree(mr);
break;
}
spin_lock(&buf->rb_lock);
rpcrdma_mr_push(mr, &buf->rb_mrs);
list_add(&mr->mr_all, &buf->rb_all_mrs);
spin_unlock(&buf->rb_lock);
}
r_xprt->rx_stats.mrs_allocated += count;
trace_xprtrdma_createmrs(r_xprt, count);
}
static void
rpcrdma_mr_refresh_worker(struct work_struct *work)
{
struct rpcrdma_buffer *buf = container_of(work, struct rpcrdma_buffer,
rb_refresh_worker);
struct rpcrdma_xprt *r_xprt = container_of(buf, struct rpcrdma_xprt,
rx_buf);
rpcrdma_mrs_create(r_xprt);
xprt_write_space(&r_xprt->rx_xprt);
}
/**
* rpcrdma_mrs_refresh - Wake the MR refresh worker
* @r_xprt: controlling transport instance
*
*/
void rpcrdma_mrs_refresh(struct rpcrdma_xprt *r_xprt)
{
struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
struct rpcrdma_ep *ep = r_xprt->rx_ep;
/* If there is no underlying connection, it's no use
* to wake the refresh worker.
*/
if (ep->re_connect_status != 1)
return;
queue_work(system_highpri_wq, &buf->rb_refresh_worker);
}
/**
* rpcrdma_req_create - Allocate an rpcrdma_req object
* @r_xprt: controlling r_xprt
* @size: initial size, in bytes, of send and receive buffers
*
* Returns an allocated and fully initialized rpcrdma_req or NULL.
*/
struct rpcrdma_req *rpcrdma_req_create(struct rpcrdma_xprt *r_xprt,
size_t size)
{
struct rpcrdma_buffer *buffer = &r_xprt->rx_buf;
struct rpcrdma_req *req;
req = kzalloc_obj(*req, XPRTRDMA_GFP_FLAGS);
if (req == NULL)
goto out1;
req->rl_sendbuf = rpcrdma_regbuf_alloc(size, DMA_TO_DEVICE);
if (!req->rl_sendbuf)
goto out2;
req->rl_recvbuf = rpcrdma_regbuf_alloc(size, DMA_NONE);
if (!req->rl_recvbuf)
goto out3;
INIT_LIST_HEAD(&req->rl_free_mrs);
INIT_LIST_HEAD(&req->rl_registered);
spin_lock(&buffer->rb_lock);
list_add(&req->rl_all, &buffer->rb_allreqs);
spin_unlock(&buffer->rb_lock);
return req;
out3:
rpcrdma_regbuf_free(req->rl_sendbuf);
out2:
kfree(req);
out1:
return NULL;
}
/**
* rpcrdma_req_setup - Per-connection instance setup of an rpcrdma_req object
* @r_xprt: controlling transport instance
* @req: rpcrdma_req object to set up
*
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/sunrpc/addr.h`, `linux/sunrpc/svc_rdma.h`, `linux/log2.h`, `asm/barrier.h`, `rdma/ib_cm.h`.
- Detected declarations: `function rpcrdma_xprt_drain`, `function rpcrdma_force_disconnect`, `function rpcrdma_flush_disconnect`, `function rpcrdma_wc_send`, `function rpcrdma_wc_receive`, `function rpcrdma_update_cm_private`, `function rpcrdma_cm_event_handler`, `function rpcrdma_ep_removal_done`, `function rpcrdma_ep_destroy`, `function rpcrdma_ep_get`.
- 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.