#include "osdep.h"
#include "virtio_pci.h"
#include "VirtIO.h"
#include "kdebugprint.h"
#include "virtio_ring.h"
#include "windows/virtio_ring_allocation.h"
#include <pshpack1.h>
#include <poppack.h>
Go to the source code of this file.
|
static void | vring_init (struct vring *vr, unsigned int num, void *p, unsigned long align) |
|
static unsigned | vring_size_split (unsigned int num, unsigned long align) |
|
static int | vring_need_event (__u16 event_idx, __u16 new_idx, __u16 old) |
|
static u16 | get_unused_desc (struct virtqueue_split *vq) |
|
static void | put_unused_desc_chain (struct virtqueue_split *vq, u16 idx) |
|
static int | virtqueue_add_buf_split (struct virtqueue *_vq, struct scatterlist sg[], unsigned int out, unsigned int in, void *opaque, void *va_indirect, ULONGLONG phys_indirect) |
|
static void * | virtqueue_get_buf_split (struct virtqueue *_vq, unsigned int *len) |
|
static BOOLEAN | virtqueue_has_buf_split (struct virtqueue *_vq) |
|
static bool | virtqueue_kick_prepare_split (struct virtqueue *_vq) |
|
static void | virtqueue_kick_always_split (struct virtqueue *_vq) |
|
static bool | virtqueue_enable_cb_split (struct virtqueue *_vq) |
|
static bool | virtqueue_enable_cb_delayed_split (struct virtqueue *_vq) |
|
static void | virtqueue_disable_cb_split (struct virtqueue *_vq) |
|
static BOOLEAN | virtqueue_is_interrupt_enabled_split (struct virtqueue *_vq) |
|
static void | virtqueue_shutdown_split (struct virtqueue *_vq) |
|
static void * | virtqueue_detach_unused_buf_split (struct virtqueue *_vq) |
|
unsigned int | vring_control_block_size (u16 qsize, bool packed) |
|
struct virtqueue * | vring_new_virtqueue_split (unsigned int index, unsigned int num, unsigned int vring_align, VirtIODevice *vdev, void *pages, void(*notify)(struct virtqueue *), void *control) |
|
void | vring_transport_features (VirtIODevice *vdev, u64 *features) |
|
u32 | virtio_get_indirect_page_capacity () |
|
unsigned long | vring_size (unsigned int num, unsigned long align, bool packed) |
|
◆ DESC_INDEX
◆ splitvq
◆ VIRTQ_AVAIL_F_NO_INTERRUPT
#define VIRTQ_AVAIL_F_NO_INTERRUPT 1 |
◆ VIRTQ_DESC_F_INDIRECT
#define VIRTQ_DESC_F_INDIRECT 4 |
◆ VIRTQ_DESC_F_NEXT
◆ VIRTQ_DESC_F_WRITE
◆ VIRTQ_USED_F_NO_NOTIFY
#define VIRTQ_USED_F_NO_NOTIFY 1 |
◆ VRING_AVAIL_ALIGN_SIZE
#define VRING_AVAIL_ALIGN_SIZE 2 |
◆ vring_avail_event
◆ VRING_DESC_ALIGN_SIZE
#define VRING_DESC_ALIGN_SIZE 16 |
◆ VRING_USED_ALIGN_SIZE
#define VRING_USED_ALIGN_SIZE 4 |
◆ vring_used_event
◆ get_unused_desc()
◆ put_unused_desc_chain()
◆ virtio_get_indirect_page_capacity()
u32 virtio_get_indirect_page_capacity |
( |
| ) |
|
◆ virtqueue_add_buf_split()
Definition at line 225 of file VirtIORing.c.
233{
238
240
242
246 desc[
i].addr = sg[
i].physAddr.QuadPart;
247 desc[
i].len = sg[
i].length;
249 }
250 desc[
i - 1].flags &= ~VIRTQ_DESC_F_NEXT;
251
254 vq->
vring.desc[
idx].addr = phys_indirect;
256
258 } else {
260
261
264 }
265
266
269
275 }
277
278
281
282 vring->
desc[last_idx].addr = sg[
i].physAddr.QuadPart;
287 }
289 }
290 vring->
desc[last_idx].flags &= ~VIRTQ_DESC_F_NEXT;
291 }
292
293
298
299 return 0;
300}
#define VIRTQ_DESC_F_WRITE
#define DESC_INDEX(num, i)
#define VIRTQ_DESC_F_INDIRECT
static u16 get_unused_desc(struct virtqueue_split *vq)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static const WCHAR desc[]
FORCEINLINE VOID KeMemoryBarrier(VOID)
struct virtqueue_split::@4339 master_vring_avail
unsigned int num_added_since_kick
struct vring_avail * avail
Referenced by vring_new_virtqueue_split().
◆ virtqueue_detach_unused_buf_split()
Definition at line 455 of file VirtIORing.c.
456{
460
465 vq->vring.avail->idx = --
vq->master_vring_avail.idx;
466 break;
467 }
468 }
470}
static void put_unused_desc_chain(struct virtqueue_split *vq, u16 idx)
Referenced by vring_new_virtqueue_split().
◆ virtqueue_disable_cb_split()
Definition at line 415 of file VirtIORing.c.
416{
421 {
422 vq->vring.avail->flags =
vq->master_vring_avail.flags;
423 }
424 }
425}
#define VIRTQ_AVAIL_F_NO_INTERRUPT
static BOOLEAN virtqueue_is_interrupt_enabled(struct virtqueue *vq)
bool event_suppression_enabled
Referenced by vring_new_virtqueue_split().
◆ virtqueue_enable_cb_delayed_split()
Definition at line 394 of file VirtIORing.c.
395{
398
400 vq->master_vring_avail.flags &= ~VIRTQ_AVAIL_F_NO_INTERRUPT;
402 {
403 vq->vring.avail->flags =
vq->master_vring_avail.flags;
404 }
405 }
406
407
408 bufs = (
u16)(
vq->master_vring_avail.idx -
vq->last_used) * 3 / 4;
411 return ((
vq->vring.used->idx -
vq->last_used) <=
bufs);
412}
#define vring_used_event(vr)
Referenced by vring_new_virtqueue_split().
◆ virtqueue_enable_cb_split()
Definition at line 376 of file VirtIORing.c.
377{
380 vq->master_vring_avail.flags &= ~VIRTQ_AVAIL_F_NO_INTERRUPT;
382 {
383 vq->vring.avail->flags =
vq->master_vring_avail.flags;
384 }
385 }
386
389 return (
vq->last_used ==
vq->vring.used->idx);
390}
Referenced by vring_new_virtqueue_split().
◆ virtqueue_get_buf_split()
◆ virtqueue_has_buf_split()
◆ virtqueue_is_interrupt_enabled_split()
◆ virtqueue_kick_always_split()
◆ virtqueue_kick_prepare_split()
Definition at line 345 of file VirtIORing.c.
346{
348 bool wrap_around;
351
352 wrap_around = (
vq->num_added_since_kick >= (1 << 16));
353
354 old = (
u16)(
vq->master_vring_avail.idx -
vq->num_added_since_kick);
355 new =
vq->master_vring_avail.idx;
356 vq->num_added_since_kick = 0;
357
360 } else {
362 }
363}
static int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
#define vring_avail_event(vr)
#define VIRTQ_USED_F_NO_NOTIFY
Referenced by vring_new_virtqueue_split().
◆ virtqueue_shutdown_split()
Definition at line 435 of file VirtIORing.c.
436{
438 unsigned int num =
vq->vring.num;
439 void *pages =
vq->vring.desc;
441
446 vring_align,
448 pages,
451}
struct virtqueue * vring_new_virtqueue_split(unsigned int index, unsigned int num, unsigned int vring_align, VirtIODevice *vdev, void *pages, void(*notify)(struct virtqueue *), void *control)
static unsigned vring_size_split(unsigned int num, unsigned long align)
void(* notification_cb)(struct virtqueue *vq)
#define RtlZeroMemory(Destination, Length)
Referenced by vring_new_virtqueue_split().
◆ vring_control_block_size()
◆ vring_init()
◆ vring_need_event()
◆ vring_new_virtqueue_split()
Definition at line 486 of file VirtIORing.c.
494{
497
499 DPrintf(0,
"Virtqueue length %u is not a power of 2\n",
num);
501 }
502
504
509
510
511 vq->num_unused =
num;
512 vq->first_unused = 0;
513 for (
i = 0;
i <
num - 1;
i++) {
515 vq->vring.desc[
i].next =
i + 1;
516 }
517 vq->vq.avail_va =
vq->vring.avail;
518 vq->vq.used_va =
vq->vring.used;
531}
static bool virtqueue_enable_cb_delayed_split(struct virtqueue *_vq)
static BOOLEAN virtqueue_is_interrupt_enabled_split(struct virtqueue *_vq)
static void virtqueue_shutdown_split(struct virtqueue *_vq)
static void virtqueue_kick_always_split(struct virtqueue *_vq)
static void virtqueue_disable_cb_split(struct virtqueue *_vq)
static bool virtqueue_kick_prepare_split(struct virtqueue *_vq)
static BOOLEAN virtqueue_has_buf_split(struct virtqueue *_vq)
static void * virtqueue_get_buf_split(struct virtqueue *_vq, unsigned int *len)
static void * virtqueue_detach_unused_buf_split(struct virtqueue *_vq)
static int virtqueue_add_buf_split(struct virtqueue *_vq, struct scatterlist sg[], unsigned int out, unsigned int in, void *opaque, void *va_indirect, ULONGLONG phys_indirect)
static void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align)
static bool virtqueue_enable_cb_split(struct virtqueue *_vq)
#define DPrintf(Level, Fmt)
Referenced by vio_legacy_setup_vq(), vio_modern_setup_vq(), and virtqueue_shutdown_split().
◆ vring_size()
◆ vring_size_split()
◆ vring_transport_features()
Definition at line 534 of file VirtIORing.c.
537{
539
545 }
546 }
547}
#define VIRTIO_TRANSPORT_F_START
#define VIRTIO_TRANSPORT_F_END
#define VIRTIO_F_VERSION_1
#define virtio_feature_disable(FeaturesList, Feature)
#define VIRTIO_RING_F_INDIRECT_DESC
#define VIRTIO_RING_F_EVENT_IDX
Referenced by vio_legacy_set_features(), and vio_modern_set_features().