drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h- Extension
.h- Size
- 3965 bytes
- Lines
- 115
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.h
Detected Declarations
struct pvrdma_ringstruct pvrdma_ring_statefunction pvrdma_idx_validfunction pvrdma_idxfunction pvrdma_idx_ring_incfunction pvrdma_idx_ring_has_spacefunction pvrdma_idx_ring_has_data
Annotated Snippet
struct pvrdma_ring {
atomic_t prod_tail; /* Producer tail. */
atomic_t cons_head; /* Consumer head. */
};
struct pvrdma_ring_state {
struct pvrdma_ring tx; /* Tx ring. */
struct pvrdma_ring rx; /* Rx ring. */
};
static inline int pvrdma_idx_valid(__u32 idx, __u32 max_elems)
{
/* Generates fewer instructions than a less-than. */
return (idx & ~((max_elems << 1) - 1)) == 0;
}
static inline __s32 pvrdma_idx(atomic_t *var, __u32 max_elems)
{
const unsigned int idx = atomic_read(var);
if (pvrdma_idx_valid(idx, max_elems))
return idx & (max_elems - 1);
return PVRDMA_INVALID_IDX;
}
static inline void pvrdma_idx_ring_inc(atomic_t *var, __u32 max_elems)
{
__u32 idx = atomic_read(var) + 1; /* Increment. */
idx &= (max_elems << 1) - 1; /* Modulo size, flip gen. */
atomic_set(var, idx);
}
static inline __s32 pvrdma_idx_ring_has_space(const struct pvrdma_ring *r,
__u32 max_elems, __u32 *out_tail)
{
const __u32 tail = atomic_read(&r->prod_tail);
const __u32 head = atomic_read(&r->cons_head);
if (pvrdma_idx_valid(tail, max_elems) &&
pvrdma_idx_valid(head, max_elems)) {
*out_tail = tail & (max_elems - 1);
return tail != (head ^ max_elems);
}
return PVRDMA_INVALID_IDX;
}
static inline __s32 pvrdma_idx_ring_has_data(const struct pvrdma_ring *r,
__u32 max_elems, __u32 *out_head)
{
const __u32 tail = atomic_read(&r->prod_tail);
const __u32 head = atomic_read(&r->cons_head);
if (pvrdma_idx_valid(tail, max_elems) &&
pvrdma_idx_valid(head, max_elems)) {
*out_head = head & (max_elems - 1);
return tail != head;
}
return PVRDMA_INVALID_IDX;
}
#endif /* __PVRDMA_RING_H__ */
Annotation
- Immediate include surface: `linux/types.h`.
- Detected declarations: `struct pvrdma_ring`, `struct pvrdma_ring_state`, `function pvrdma_idx_valid`, `function pvrdma_idx`, `function pvrdma_idx_ring_inc`, `function pvrdma_idx_ring_has_space`, `function pvrdma_idx_ring_has_data`.
- 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.