net/smc/smc_rx.c
Source file repositories/reference/linux-study-clean/net/smc/smc_rx.c
File Facts
- System
- Linux kernel
- Corpus path
net/smc/smc_rx.c- Extension
.c- Size
- 14284 bytes
- Lines
- 528
- 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.
- 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/net.hlinux/rcupdate.hlinux/sched/signal.hlinux/splice.hnet/sock.htrace/events/sock.hsmc.hsmc_core.hsmc_cdc.hsmc_tx.hsmc_rx.hsmc_stats.hsmc_tracepoint.h
Detected Declarations
struct smc_spd_privfunction RDMAfunction smc_rx_update_consumerfunction smc_rx_update_consfunction smc_rx_pipe_buf_releasefunction smc_rx_pipe_buf_getfunction smc_rx_spd_releasefunction smc_rx_splicefunction smc_rx_data_available_and_no_splice_pendfunction otherwisefunction smc_rx_recv_urgfunction smc_rx_recvmsg_data_availablefunction smc_rx_recvmsgfunction smc_rx_init
Annotated Snippet
struct smc_spd_priv {
struct smc_sock *smc;
size_t len;
};
static void smc_rx_pipe_buf_release(struct pipe_inode_info *pipe,
struct pipe_buffer *buf)
{
struct smc_spd_priv *priv = (struct smc_spd_priv *)buf->private;
struct smc_sock *smc = priv->smc;
struct smc_connection *conn;
struct sock *sk = &smc->sk;
if (sk->sk_state == SMC_CLOSED ||
sk->sk_state == SMC_PEERFINCLOSEWAIT ||
sk->sk_state == SMC_APPFINCLOSEWAIT)
goto out;
conn = &smc->conn;
lock_sock(sk);
smc_rx_update_cons(smc, priv->len);
release_sock(sk);
if (atomic_sub_and_test(priv->len, &conn->splice_pending))
smc_rx_wake_up(sk);
out:
kfree(priv);
put_page(buf->page);
sock_put(sk);
}
static bool smc_rx_pipe_buf_get(struct pipe_inode_info *pipe,
struct pipe_buffer *buf)
{
/* smc_spd_priv in buf->private is not shareable; disallow cloning. */
return false;
}
static const struct pipe_buf_operations smc_pipe_ops = {
.release = smc_rx_pipe_buf_release,
.get = smc_rx_pipe_buf_get,
};
static void smc_rx_spd_release(struct splice_pipe_desc *spd,
unsigned int i)
{
put_page(spd->pages[i]);
}
static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len,
struct smc_sock *smc)
{
struct smc_link_group *lgr = smc->conn.lgr;
int offset = offset_in_page(src);
struct partial_page *partial;
struct splice_pipe_desc spd;
struct smc_spd_priv **priv;
struct page **pages;
int bytes, nr_pages;
int i;
nr_pages = !lgr->is_smcd && smc->conn.rmb_desc->is_vm ?
PAGE_ALIGN(len + offset) / PAGE_SIZE : 1;
pages = kzalloc_objs(*pages, nr_pages);
if (!pages)
goto out;
partial = kzalloc_objs(*partial, nr_pages);
if (!partial)
goto out_page;
priv = kzalloc_objs(*priv, nr_pages);
if (!priv)
goto out_part;
for (i = 0; i < nr_pages; i++) {
priv[i] = kzalloc_obj(**priv);
if (!priv[i])
goto out_priv;
}
if (lgr->is_smcd ||
(!lgr->is_smcd && !smc->conn.rmb_desc->is_vm)) {
/* smcd or smcr that uses physically contiguous RMBs */
priv[0]->len = len;
priv[0]->smc = smc;
partial[0].offset = src - (char *)smc->conn.rmb_desc->cpu_addr;
partial[0].len = len;
partial[0].private = (unsigned long)priv[0];
pages[0] = smc->conn.rmb_desc->pages;
} else {
int size, left = len;
void *buf = src;
/* smcr that uses virtually contiguous RMBs*/
Annotation
- Immediate include surface: `linux/net.h`, `linux/rcupdate.h`, `linux/sched/signal.h`, `linux/splice.h`, `net/sock.h`, `trace/events/sock.h`, `smc.h`, `smc_core.h`.
- Detected declarations: `struct smc_spd_priv`, `function RDMA`, `function smc_rx_update_consumer`, `function smc_rx_update_cons`, `function smc_rx_pipe_buf_release`, `function smc_rx_pipe_buf_get`, `function smc_rx_spd_release`, `function smc_rx_splice`, `function smc_rx_data_available_and_no_splice_pend`, `function otherwise`.
- 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.
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.