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.

Dependency Surface

Detected Declarations

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

Implementation Notes