drivers/infiniband/sw/siw/siw_mem.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/siw/siw_mem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/siw/siw_mem.c- Extension
.c- Size
- 9178 bytes
- Lines
- 401
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/gfp.hrdma/ib_verbs.hrdma/ib_umem.hlinux/dma-mapping.hlinux/slab.hlinux/sched/mm.hlinux/resource.hsiw.hsiw_mem.h
Detected Declarations
function siw_mem_id2objfunction siw_umem_releasefunction siw_mr_add_memfunction siw_mr_drop_memfunction siw_free_memfunction siw_check_memfunction siw_check_sgefunction siw_wqe_put_memfunction siw_invalidate_stagfunction siw_pbl_get_buffer
Annotated Snippet
if (unlikely(!new)) {
siw_dbg_pd(pd, "STag unknown: 0x%08x\n", sge->lkey);
rv = -E_STAG_INVALID;
goto fail;
}
*mem = new;
}
/* Check if user re-registered with different STag key */
if (unlikely((*mem)->stag != sge->lkey)) {
siw_dbg_mem((*mem), "STag mismatch: 0x%08x\n", sge->lkey);
rv = -E_STAG_INVALID;
goto fail;
}
rv = siw_check_mem(pd, *mem, sge->laddr + off, perms, len);
if (unlikely(rv))
goto fail;
return 0;
fail:
if (new) {
*mem = NULL;
siw_mem_put(new);
}
return rv;
}
void siw_wqe_put_mem(struct siw_wqe *wqe, enum siw_opcode op)
{
switch (op) {
case SIW_OP_SEND:
case SIW_OP_WRITE:
case SIW_OP_SEND_WITH_IMM:
case SIW_OP_SEND_REMOTE_INV:
case SIW_OP_READ:
case SIW_OP_READ_LOCAL_INV:
if (!(wqe->sqe.flags & SIW_WQE_INLINE))
siw_unref_mem_sgl(wqe->mem, wqe->sqe.num_sge);
break;
case SIW_OP_RECEIVE:
siw_unref_mem_sgl(wqe->mem, wqe->rqe.num_sge);
break;
case SIW_OP_READ_RESPONSE:
siw_unref_mem_sgl(wqe->mem, 1);
break;
default:
/*
* SIW_OP_INVAL_STAG and SIW_OP_REG_MR
* do not hold memory references
*/
break;
}
}
int siw_invalidate_stag(struct ib_pd *pd, u32 stag)
{
struct siw_device *sdev = to_siw_dev(pd->device);
struct siw_mem *mem = siw_mem_id2obj(sdev, stag >> 8);
int rv = 0;
if (unlikely(!mem)) {
siw_dbg_pd(pd, "STag 0x%08x unknown\n", stag);
return -EINVAL;
}
if (unlikely(mem->pd != pd)) {
siw_dbg_pd(pd, "PD mismatch for STag 0x%08x\n", stag);
rv = -EACCES;
goto out;
}
/*
* Per RDMA verbs definition, an STag may already be in invalid
* state if invalidation is requested. So no state check here.
*/
mem->stag_valid = 0;
siw_dbg_pd(pd, "STag 0x%08x now invalid\n", stag);
out:
siw_mem_put(mem);
return rv;
}
/*
* Gets physical address backed by PBL element. Address is referenced
* by linear byte offset into list of variably sized PB elements.
* Optionally, provides remaining len within current element, and
* current PBL index for later resume at same element.
*/
Annotation
- Immediate include surface: `linux/gfp.h`, `rdma/ib_verbs.h`, `rdma/ib_umem.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/sched/mm.h`, `linux/resource.h`, `siw.h`.
- Detected declarations: `function siw_mem_id2obj`, `function siw_umem_release`, `function siw_mr_add_mem`, `function siw_mr_drop_mem`, `function siw_free_mem`, `function siw_check_mem`, `function siw_check_sge`, `function siw_wqe_put_mem`, `function siw_invalidate_stag`, `function siw_pbl_get_buffer`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.