net/rds/ib_recv.c
Source file repositories/reference/linux-study-clean/net/rds/ib_recv.c
File Facts
- System
- Linux kernel
- Corpus path
net/rds/ib_recv.c- Extension
.c- Size
- 31766 bytes
- Lines
- 1096
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/sched/clock.hlinux/slab.hlinux/pci.hlinux/dma-mapping.hrdma/rdma_cm.hrds_single_path.hrds.hib.h
Detected Declarations
function rds_ib_recv_init_ringfunction list_splice_entire_tailfunction rds_ib_cache_xfer_to_readyfunction rds_ib_recv_alloc_cachefunction for_each_possible_cpufunction rds_ib_recv_alloc_cachesfunction rds_ib_cache_splice_all_listsfunction for_each_possible_cpufunction rds_ib_recv_free_cachesfunction list_for_each_entry_safefunction list_for_each_entry_safefunction rds_ib_frag_freefunction rds_ib_inc_freefunction rds_ib_recv_clear_onefunction rds_ib_recv_clear_ringfunction rds_ib_recv_refill_onefunction acquire_refillfunction release_refillfunction rds_ib_recv_refillfunction rds_ib_ring_emptyfunction list_emptyfunction rds_ib_inc_copy_to_userfunction rds_ib_recv_init_ackfunction rds_ib_set_ackfunction rds_ib_get_ackfunction rds_ib_set_ackfunction rds_ib_get_ackfunction rds_ib_send_ackfunction rds_ib_attempt_ackfunction rds_ib_ack_send_completefunction rds_ib_piggyb_ackfunction rds_ib_cong_recvfunction rds_ib_process_recvfunction rds_ib_recv_cqe_handlerfunction rds_ib_ring_freefunction rds_ib_recv_pathfunction rds_ib_recv_initfunction rds_ib_recv_exit
Annotated Snippet
if (head->first) {
list_splice_entire_tail(head->first, caller_list);
head->first = NULL;
}
}
if (cache->ready) {
list_splice_entire_tail(cache->ready, caller_list);
cache->ready = NULL;
}
}
void rds_ib_recv_free_caches(struct rds_ib_connection *ic)
{
struct rds_ib_incoming *inc;
struct rds_ib_incoming *inc_tmp;
struct rds_page_frag *frag;
struct rds_page_frag *frag_tmp;
LIST_HEAD(list);
rds_ib_cache_xfer_to_ready(&ic->i_cache_incs);
rds_ib_cache_splice_all_lists(&ic->i_cache_incs, &list);
free_percpu(ic->i_cache_incs.percpu);
list_for_each_entry_safe(inc, inc_tmp, &list, ii_cache_entry) {
list_del(&inc->ii_cache_entry);
WARN_ON(!list_empty(&inc->ii_frags));
kmem_cache_free(rds_ib_incoming_slab, inc);
atomic_dec(&rds_ib_allocation);
}
rds_ib_cache_xfer_to_ready(&ic->i_cache_frags);
rds_ib_cache_splice_all_lists(&ic->i_cache_frags, &list);
free_percpu(ic->i_cache_frags.percpu);
list_for_each_entry_safe(frag, frag_tmp, &list, f_cache_entry) {
list_del(&frag->f_cache_entry);
WARN_ON(!list_empty(&frag->f_item));
kmem_cache_free(rds_ib_frag_slab, frag);
}
}
/* fwd decl */
static void rds_ib_recv_cache_put(struct list_head *new_item,
struct rds_ib_refill_cache *cache);
static struct list_head *rds_ib_recv_cache_get(struct rds_ib_refill_cache *cache);
/* Recycle frag and attached recv buffer f_sg */
static void rds_ib_frag_free(struct rds_ib_connection *ic,
struct rds_page_frag *frag)
{
rdsdebug("frag %p page %p\n", frag, sg_page(&frag->f_sg));
rds_ib_recv_cache_put(&frag->f_cache_entry, &ic->i_cache_frags);
atomic_add(RDS_FRAG_SIZE / SZ_1K, &ic->i_cache_allocs);
rds_ib_stats_add(s_ib_recv_added_to_cache, RDS_FRAG_SIZE);
}
/* Recycle inc after freeing attached frags */
void rds_ib_inc_free(struct rds_incoming *inc)
{
struct rds_ib_incoming *ibinc;
struct rds_page_frag *frag;
struct rds_page_frag *pos;
struct rds_ib_connection *ic = inc->i_conn->c_transport_data;
ibinc = container_of(inc, struct rds_ib_incoming, ii_inc);
/* Free attached frags */
list_for_each_entry_safe(frag, pos, &ibinc->ii_frags, f_item) {
list_del_init(&frag->f_item);
rds_ib_frag_free(ic, frag);
}
BUG_ON(!list_empty(&ibinc->ii_frags));
rdsdebug("freeing ibinc %p inc %p\n", ibinc, inc);
rds_ib_recv_cache_put(&ibinc->ii_cache_entry, &ic->i_cache_incs);
}
static void rds_ib_recv_clear_one(struct rds_ib_connection *ic,
struct rds_ib_recv_work *recv)
{
if (recv->r_ibinc) {
rds_inc_put(&recv->r_ibinc->ii_inc);
recv->r_ibinc = NULL;
}
if (recv->r_frag) {
ib_dma_unmap_sg(ic->i_cm_id->device, &recv->r_frag->f_sg, 1, DMA_FROM_DEVICE);
rds_ib_frag_free(ic, recv->r_frag);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched/clock.h`, `linux/slab.h`, `linux/pci.h`, `linux/dma-mapping.h`, `rdma/rdma_cm.h`, `rds_single_path.h`, `rds.h`.
- Detected declarations: `function rds_ib_recv_init_ring`, `function list_splice_entire_tail`, `function rds_ib_cache_xfer_to_ready`, `function rds_ib_recv_alloc_cache`, `function for_each_possible_cpu`, `function rds_ib_recv_alloc_caches`, `function rds_ib_cache_splice_all_lists`, `function for_each_possible_cpu`, `function rds_ib_recv_free_caches`, `function list_for_each_entry_safe`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.