include/linux/vringh.h
Source file repositories/reference/linux-study-clean/include/linux/vringh.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/vringh.h- Extension
.h- Size
- 9030 bytes
- Lines
- 322
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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
uapi/linux/virtio_ring.hlinux/virtio_byteorder.hlinux/uio.hlinux/slab.hlinux/spinlock.hlinux/dma-direction.hlinux/vhost_iotlb.hasm/barrier.h
Detected Declarations
struct vringhstruct virtio_devicestruct vringh_config_opsstruct vringh_rangestruct vringh_iovstruct vringh_kiovfunction vringh_iov_initfunction vringh_iov_resetfunction vringh_iov_cleanupfunction vringh_kiov_initfunction vringh_kiov_resetfunction vringh_kiov_cleanupfunction vringh_kiov_lengthfunction vringh_notifyfunction vringh_is_little_endianfunction vringh16_to_cpufunction cpu_to_vringh16function vringh32_to_cpufunction cpu_to_vringh32function vringh64_to_cpufunction cpu_to_vringh64
Annotated Snippet
struct vringh {
/* Everything is little endian */
bool little_endian;
/* Guest publishes used event idx (note: we always do). */
bool event_indices;
/* Can we get away with weak barriers? */
bool weak_barriers;
/* Use user's VA */
bool use_va;
/* Last available index we saw (ie. where we're up to). */
u16 last_avail_idx;
/* Last index we used. */
u16 last_used_idx;
/* How many descriptors we've completed since last need_notify(). */
u32 completed;
/* The vring (note: it may contain user pointers!) */
struct vring vring;
/* IOTLB for this vring */
struct vhost_iotlb *iotlb;
/* spinlock to synchronize IOTLB accesses */
spinlock_t *iotlb_lock;
/* The function to call to notify the guest about added buffers */
void (*notify)(struct vringh *);
};
struct virtio_device;
typedef void vrh_callback_t(struct virtio_device *, struct vringh *);
/**
* struct vringh_config_ops - ops for creating a host vring from a virtio driver
* @find_vrhs: find the host vrings and instantiate them
* vdev: the virtio_device
* nhvrs: the number of host vrings to find
* hvrs: on success, includes new host vrings
* callbacks: array of driver callbacks, for each host vring
* include a NULL entry for vqs that do not need a callback
* Returns 0 on success or error status
* @del_vrhs: free the host vrings found by find_vrhs().
*/
struct vringh_config_ops {
int (*find_vrhs)(struct virtio_device *vdev, unsigned nhvrs,
struct vringh *vrhs[], vrh_callback_t *callbacks[]);
void (*del_vrhs)(struct virtio_device *vdev);
};
/* The memory the vring can access, and what offset to apply. */
struct vringh_range {
u64 start, end_incl;
u64 offset;
};
/**
* struct vringh_iov - iovec mangler.
* @iov: array of iovecs to operate on
* @consumed: number of bytes consumed within iov[i]
* @i: index of current iovec
* @used: number of iovecs present in @iov
* @max_num: maximum number of iovecs.
* corresponds to allocated memory of @iov
*
* Mangles iovec in place, and restores it.
* Remaining data is iov + i, of used - i elements.
*/
struct vringh_iov {
struct iovec *iov;
size_t consumed; /* Within iov[i] */
unsigned i, used, max_num;
};
/**
* struct vringh_kiov - kvec mangler.
* @iov: array of iovecs to operate on
* @consumed: number of bytes consumed within iov[i]
* @i: index of current iovec
* @used: number of iovecs present in @iov
* @max_num: maximum number of iovecs.
* corresponds to allocated memory of @iov
*
* Mangles kvec in place, and restores it.
* Remaining data is iov + i, of used - i elements.
Annotation
- Immediate include surface: `uapi/linux/virtio_ring.h`, `linux/virtio_byteorder.h`, `linux/uio.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/dma-direction.h`, `linux/vhost_iotlb.h`, `asm/barrier.h`.
- Detected declarations: `struct vringh`, `struct virtio_device`, `struct vringh_config_ops`, `struct vringh_range`, `struct vringh_iov`, `struct vringh_kiov`, `function vringh_iov_init`, `function vringh_iov_reset`, `function vringh_iov_cleanup`, `function vringh_kiov_init`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
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.