net/smc/smc_wr.c
Source file repositories/reference/linux-study-clean/net/smc/smc_wr.c
File Facts
- System
- Linux kernel
- Corpus path
net/smc/smc_wr.c- Extension
.c- Size
- 26331 bytes
- Lines
- 934
- 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/atomic.hlinux/hashtable.hlinux/wait.hrdma/ib_verbs.hasm/div64.hsmc.hsmc_wr.h
Detected Declarations
struct smc_wr_tx_pendfunction smc_wr_is_tx_pendfunction smc_wr_tx_wait_no_pending_sendsfunction smc_wr_tx_find_pending_indexfunction smc_wr_tx_process_cqefunction smc_wr_tx_tasklet_fnfunction smc_wr_tx_cq_handlerfunction smc_wr_tx_get_free_slot_indexfunction smc_wr_tx_get_free_slotfunction smc_wr_tx_get_v2_slotfunction smc_wr_tx_put_slotfunction smc_wr_tx_sendfunction smc_wr_tx_v2_sendfunction smc_wr_tx_send_waitfunction smc_wr_reg_sendfunction smc_wr_rx_register_handlerfunction smc_wr_rx_demultiplexfunction smc_wr_rx_process_cqesfunction smc_wr_rx_tasklet_fnfunction smc_wr_rx_cq_handlerfunction smc_wr_rx_post_initfunction smc_wr_remember_qp_attrfunction smc_wr_init_sgefunction smc_wr_free_linkfunction smc_wr_free_lgr_memfunction smc_wr_free_link_memfunction smc_wr_alloc_lgr_memfunction smc_wr_alloc_link_memfunction smc_wr_remove_devfunction smc_wr_add_devfunction smcr_wr_tx_refs_freefunction smcr_wr_reg_refs_freefunction smc_wr_create_link
Annotated Snippet
struct smc_wr_tx_pend { /* control data for a pending send request */
u64 wr_id; /* work request id sent */
smc_wr_tx_handler handler;
enum ib_wc_status wc_status; /* CQE status */
struct smc_link *link;
u32 idx;
struct smc_wr_tx_pend_priv priv;
u8 compl_requested;
};
/******************************** send queue *********************************/
/*------------------------------- completion --------------------------------*/
/* returns true if at least one tx work request is pending on the given link */
static inline bool smc_wr_is_tx_pend(struct smc_link *link)
{
return !bitmap_empty(link->wr_tx_mask, link->wr_tx_cnt);
}
/* wait till all pending tx work requests on the given link are completed */
void smc_wr_tx_wait_no_pending_sends(struct smc_link *link)
{
wait_event(link->wr_tx_wait, !smc_wr_is_tx_pend(link));
}
static inline int smc_wr_tx_find_pending_index(struct smc_link *link, u64 wr_id)
{
u32 i;
for (i = 0; i < link->wr_tx_cnt; i++) {
if (link->wr_tx_pends[i].wr_id == wr_id)
return i;
}
return link->wr_tx_cnt;
}
static inline void smc_wr_tx_process_cqe(struct ib_wc *wc)
{
struct smc_wr_tx_pend pnd_snd;
struct smc_link *link;
u32 pnd_snd_idx;
link = wc->qp->qp_context;
if (wc->opcode == IB_WC_REG_MR) {
if (wc->status)
link->wr_reg_state = FAILED;
else
link->wr_reg_state = CONFIRMED;
smc_wr_wakeup_reg_wait(link);
return;
}
pnd_snd_idx = smc_wr_tx_find_pending_index(link, wc->wr_id);
if (pnd_snd_idx == link->wr_tx_cnt) {
if (link->lgr->smc_version != SMC_V2 ||
link->wr_tx_v2_pend->wr_id != wc->wr_id)
return;
link->wr_tx_v2_pend->wc_status = wc->status;
memcpy(&pnd_snd, link->wr_tx_v2_pend, sizeof(pnd_snd));
/* clear the full struct smc_wr_tx_pend including .priv */
memset(link->wr_tx_v2_pend, 0,
sizeof(*link->wr_tx_v2_pend));
memset(link->lgr->wr_tx_buf_v2, 0,
sizeof(*link->lgr->wr_tx_buf_v2));
} else {
link->wr_tx_pends[pnd_snd_idx].wc_status = wc->status;
if (link->wr_tx_pends[pnd_snd_idx].compl_requested)
complete(&link->wr_tx_compl[pnd_snd_idx]);
memcpy(&pnd_snd, &link->wr_tx_pends[pnd_snd_idx],
sizeof(pnd_snd));
/* clear the full struct smc_wr_tx_pend including .priv */
memset(&link->wr_tx_pends[pnd_snd_idx], 0,
sizeof(link->wr_tx_pends[pnd_snd_idx]));
memset(&link->wr_tx_bufs[pnd_snd_idx], 0,
sizeof(link->wr_tx_bufs[pnd_snd_idx]));
if (!test_and_clear_bit(pnd_snd_idx, link->wr_tx_mask))
return;
}
if (wc->status) {
if (link->lgr->smc_version == SMC_V2) {
memset(link->wr_tx_v2_pend, 0,
sizeof(*link->wr_tx_v2_pend));
memset(link->lgr->wr_tx_buf_v2, 0,
sizeof(*link->lgr->wr_tx_buf_v2));
}
/* terminate link */
smcr_link_down_cond_sched(link);
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/hashtable.h`, `linux/wait.h`, `rdma/ib_verbs.h`, `asm/div64.h`, `smc.h`, `smc_wr.h`.
- Detected declarations: `struct smc_wr_tx_pend`, `function smc_wr_is_tx_pend`, `function smc_wr_tx_wait_no_pending_sends`, `function smc_wr_tx_find_pending_index`, `function smc_wr_tx_process_cqe`, `function smc_wr_tx_tasklet_fn`, `function smc_wr_tx_cq_handler`, `function smc_wr_tx_get_free_slot_index`, `function smc_wr_tx_get_free_slot`, `function smc_wr_tx_get_v2_slot`.
- 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.