net/sunrpc/xprtrdma/frwr_ops.c
Source file repositories/reference/linux-study-clean/net/sunrpc/xprtrdma/frwr_ops.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/xprtrdma/frwr_ops.c- Extension
.c- Size
- 22660 bytes
- Lines
- 811
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sunrpc/svc_rdma.hxprt_rdma.htrace/events/rpcrdma.h
Detected Declarations
function Copyrightfunction frwr_mr_unmapfunction frwr_mr_releasefunction frwr_mr_putfunction frwr_resetfunction frwr_mr_initfunction frwr_query_devicefunction successfunction frwr_wc_fastregfunction frwr_sendfunction frwr_reminvfunction list_for_each_entryfunction frwr_mr_donefunction frwr_wc_localinvfunction frwr_wc_localinv_wakefunction frwr_unmap_syncfunction frwr_wc_localinv_donefunction frwr_unmap_asyncfunction frwr_wp_create
Annotated Snippet
while (remaining > 0 && i < max_depth) {
unsigned int len;
len = min_t(unsigned int,
PAGE_SIZE - page_base, remaining);
sg_set_page(&mr->mr_sg[i], *ppages,
len, page_base);
cur->xc_page_offset += len;
i++;
ppages++;
remaining -= len;
if (!sg_gaps && remaining > 0 &&
offset_in_page(page_base + len))
goto finish;
page_base = 0;
}
if (remaining == 0)
cur->xc_flags |= XC_PAGES_DONE;
} else if (!(cur->xc_flags & XC_PAGES_DONE)) {
cur->xc_flags |= XC_PAGES_DONE;
}
/* Tail kvec */
if (!(cur->xc_flags & XC_TAIL_DONE) && xdrbuf->tail[0].iov_len &&
i < max_depth) {
const struct kvec *tail = &xdrbuf->tail[0];
if (!sg_gaps && i > 0) {
struct scatterlist *prev = &mr->mr_sg[i - 1];
if (offset_in_page(prev->offset + prev->length) ||
offset_in_page(tail->iov_base))
goto finish;
}
sg_set_page(&mr->mr_sg[i],
virt_to_page(tail->iov_base),
tail->iov_len,
offset_in_page(tail->iov_base));
cur->xc_flags |= XC_TAIL_DONE;
i++;
} else if (!(cur->xc_flags & XC_TAIL_DONE) &&
!xdrbuf->tail[0].iov_len) {
cur->xc_flags |= XC_TAIL_DONE;
}
finish:
mr->mr_dir = rpcrdma_data_dir(writing);
mr->mr_nents = i;
dma_nents = ib_dma_map_sg(ep->re_id->device, mr->mr_sg, mr->mr_nents,
mr->mr_dir);
if (!dma_nents)
goto out_dmamap_err;
mr->mr_device = ep->re_id->device;
ibmr = mr->mr_ibmr;
n = ib_map_mr_sg(ibmr, mr->mr_sg, dma_nents, NULL, PAGE_SIZE);
if (n != dma_nents)
goto out_mapmr_err;
ibmr->iova &= 0x00000000ffffffff;
ibmr->iova |= ((u64)be32_to_cpu(xid)) << 32;
key = (u8)(ibmr->rkey & 0x000000FF);
ib_update_fast_reg_key(ibmr, ++key);
reg_wr = &mr->mr_regwr;
reg_wr->mr = ibmr;
reg_wr->key = ibmr->rkey;
reg_wr->access = writing ?
IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :
IB_ACCESS_REMOTE_READ;
mr->mr_handle = ibmr->rkey;
mr->mr_length = ibmr->length;
mr->mr_offset = ibmr->iova;
trace_xprtrdma_mr_map(mr);
return 0;
out_dmamap_err:
trace_xprtrdma_frwr_sgerr(mr, i);
return -EIO;
out_mapmr_err:
trace_xprtrdma_frwr_maperr(mr, n);
return -EIO;
}
/**
Annotation
- Immediate include surface: `linux/sunrpc/svc_rdma.h`, `xprt_rdma.h`, `trace/events/rpcrdma.h`.
- Detected declarations: `function Copyright`, `function frwr_mr_unmap`, `function frwr_mr_release`, `function frwr_mr_put`, `function frwr_reset`, `function frwr_mr_init`, `function frwr_query_device`, `function success`, `function frwr_wc_fastreg`, `function frwr_send`.
- 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.