ReactOS 0.4.15-dev-8417-gb6b82fe
virtio_ring_allocation.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct virtqueuevring_new_virtqueue_split (unsigned int index, unsigned int num, unsigned int vring_align, VirtIODevice *vdev, void *pages, void(*notify)(struct virtqueue *), void *control)
 
struct virtqueuevring_new_virtqueue_packed (unsigned int index, unsigned int num, unsigned int vring_align, VirtIODevice *vdev, void *pages, void(*notify)(struct virtqueue *), void *control)
 
unsigned int vring_control_block_size (u16 qsize, bool packed)
 
unsigned int vring_control_block_size_packed (u16 qsize)
 
unsigned long vring_size_packed (unsigned int num, unsigned long align)
 

Function Documentation

◆ vring_control_block_size()

unsigned int vring_control_block_size ( u16  qsize,
bool  packed 
)

Definition at line 474 of file VirtIORing.c.

475{
476 unsigned int res;
477 if (packed) {
479 }
480 res = sizeof(struct virtqueue_split);
481 res += sizeof(void *) * qsize;
482 return res;
483}
unsigned int vring_control_block_size_packed(u16 qsize)
GLuint res
Definition: glext.h:9613
GLuint GLenum GLsizei GLsizei GLint GLint GLboolean packed
Definition: glext.h:9271

Referenced by vio_legacy_query_vq_alloc(), and vio_modern_query_vq_alloc().

◆ vring_control_block_size_packed()

unsigned int vring_control_block_size_packed ( u16  qsize)

Definition at line 157 of file VirtIORing-Packed.c.

158{
159 return sizeof(struct virtqueue_packed) + sizeof(struct vring_desc_state_packed) * qsize;
160}
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by vring_control_block_size().

◆ vring_new_virtqueue_packed()

struct virtqueue * vring_new_virtqueue_packed ( unsigned int  index,
unsigned int  num,
unsigned int  vring_align,
VirtIODevice vdev,
void pages,
void(*)(struct virtqueue *)  notify,
void control 
)

Definition at line 598 of file VirtIORing-Packed.c.

606{
607 struct virtqueue_packed *vq = packedvq(control);
608 unsigned int i;
609
610 vq->vq.vdev = vdev;
611 vq->vq.notification_cb = notify;
612 vq->vq.index = index;
613
614 vq->vq.avail_va = (u8 *)pages + num * sizeof(struct vring_packed_desc);
615 vq->vq.used_va = (u8 *)vq->vq.avail_va + sizeof(struct vring_packed_desc_event);
616
617 /* initialize the ring */
618 vq->packed.vring.num = num;
619 vq->packed.vring.desc = pages;
620 vq->packed.vring.driver = vq->vq.avail_va;
621 vq->packed.vring.device = vq->vq.used_va;
622
623 vq->num_free = num;
624 vq->free_head = 0;
625 vq->num_added = 0;
626 vq->packed.avail_wrap_counter = 1;
627 vq->packed.used_wrap_counter = 1;
628 vq->last_used_idx = 0;
629 vq->avail_used_flags = 1 << VRING_PACKED_DESC_F_AVAIL;
630 vq->packed.next_avail_idx = 0;
631 vq->packed.event_flags_shadow = 0;
632 vq->packed.desc_state = vq->desc_states;
633
634 RtlZeroMemory(vq->packed.desc_state, num * sizeof(*vq->packed.desc_state));
635 for (i = 0; i < num - 1; i++) {
636 vq->packed.desc_state[i].next = i + 1;
637 }
638
639 vq->vq.add_buf = virtqueue_add_buf_packed;
640 vq->vq.detach_unused_buf = virtqueue_detach_unused_buf_packed;
641 vq->vq.disable_cb = virtqueue_disable_cb_packed;
642 vq->vq.enable_cb = virtqueue_enable_cb_packed;
643 vq->vq.enable_cb_delayed = virtqueue_enable_cb_delayed_packed;
644 vq->vq.get_buf = virtqueue_get_buf_packed;
645 vq->vq.has_buf = virtqueue_has_buf_packed;
646 vq->vq.is_interrupt_enabled = virtqueue_is_interrupt_enabled_packed;
647 vq->vq.kick_always = virtqueue_kick_always_packed;
648 vq->vq.kick_prepare = virtqueue_kick_prepare_packed;
649 vq->vq.shutdown = virtqueue_shutdown_packed;
650 return &vq->vq;
651}
#define packedvq(vq)
static void virtqueue_kick_always_packed(struct virtqueue *_vq)
static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq)
static bool virtqueue_kick_prepare_packed(struct virtqueue *_vq)
static BOOLEAN virtqueue_is_interrupt_enabled_packed(struct virtqueue *_vq)
static void * virtqueue_get_buf_packed(struct virtqueue *_vq, unsigned int *len)
static int virtqueue_add_buf_packed(struct virtqueue *_vq, struct scatterlist sg[], unsigned int out, unsigned int in, void *opaque, void *va_indirect, ULONGLONG phys_indirect)
static BOOLEAN virtqueue_has_buf_packed(struct virtqueue *_vq)
static bool virtqueue_enable_cb_packed(struct virtqueue *_vq)
static void * virtqueue_detach_unused_buf_packed(struct virtqueue *_vq)
static void virtqueue_disable_cb_packed(struct virtqueue *_vq)
static void virtqueue_shutdown_packed(struct virtqueue *_vq)
#define VRING_PACKED_DESC_F_AVAIL
#define index(s, c)
Definition: various.h:29
UCHAR u8
Definition: btrfs.h:12
GLuint GLuint num
Definition: glext.h:9618
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
Definition: glfuncs.h:248
int notify
Definition: msacm.c:1366
struct virtqueue vq
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by vio_modern_setup_vq(), and virtqueue_shutdown_packed().

◆ vring_new_virtqueue_split()

struct virtqueue * vring_new_virtqueue_split ( unsigned int  index,
unsigned int  num,
unsigned int  vring_align,
VirtIODevice vdev,
void pages,
void(*)(struct virtqueue *)  notify,
void control 
)

Definition at line 486 of file VirtIORing.c.

494{
495 struct virtqueue_split *vq = splitvq(control);
496 u16 i;
497
498 if (DESC_INDEX(num, num) != 0) {
499 DPrintf(0, "Virtqueue length %u is not a power of 2\n", num);
500 return NULL;
501 }
502
503 RtlZeroMemory(vq, sizeof(*vq) + num * sizeof(void *));
504
505 vring_init(&vq->vring, num, pages, vring_align);
506 vq->vq.vdev = vdev;
507 vq->vq.notification_cb = notify;
508 vq->vq.index = index;
509
510 /* Build a linked list of unused descriptors */
511 vq->num_unused = num;
512 vq->first_unused = 0;
513 for (i = 0; i < num - 1; i++) {
514 vq->vring.desc[i].flags = VIRTQ_DESC_F_NEXT;
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;
519 vq->vq.add_buf = virtqueue_add_buf_split;
520 vq->vq.detach_unused_buf = virtqueue_detach_unused_buf_split;
521 vq->vq.disable_cb = virtqueue_disable_cb_split;
522 vq->vq.enable_cb = virtqueue_enable_cb_split;
523 vq->vq.enable_cb_delayed = virtqueue_enable_cb_delayed_split;
524 vq->vq.get_buf = virtqueue_get_buf_split;
525 vq->vq.has_buf = virtqueue_has_buf_split;
526 vq->vq.is_interrupt_enabled = virtqueue_is_interrupt_enabled_split;
527 vq->vq.kick_always = virtqueue_kick_always_split;
528 vq->vq.kick_prepare = virtqueue_kick_prepare_split;
529 vq->vq.shutdown = virtqueue_shutdown_split;
530 return &vq->vq;
531}
#define splitvq(vq)
Definition: VirtIORing.c:191
static bool virtqueue_enable_cb_delayed_split(struct virtqueue *_vq)
Definition: VirtIORing.c:394
#define VIRTQ_DESC_F_NEXT
Definition: VirtIORing.c:42
static BOOLEAN virtqueue_is_interrupt_enabled_split(struct virtqueue *_vq)
Definition: VirtIORing.c:428
#define DESC_INDEX(num, i)
Definition: VirtIORing.c:39
static void virtqueue_shutdown_split(struct virtqueue *_vq)
Definition: VirtIORing.c:435
static void virtqueue_kick_always_split(struct virtqueue *_vq)
Definition: VirtIORing.c:366
static void virtqueue_disable_cb_split(struct virtqueue *_vq)
Definition: VirtIORing.c:415
static bool virtqueue_kick_prepare_split(struct virtqueue *_vq)
Definition: VirtIORing.c:345
static BOOLEAN virtqueue_has_buf_split(struct virtqueue *_vq)
Definition: VirtIORing.c:338
static void * virtqueue_get_buf_split(struct virtqueue *_vq, unsigned int *len)
Definition: VirtIORing.c:303
static void * virtqueue_detach_unused_buf_split(struct virtqueue *_vq)
Definition: VirtIORing.c:455
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)
Definition: VirtIORing.c:225
static void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align)
Definition: VirtIORing.c:143
static bool virtqueue_enable_cb_split(struct virtqueue *_vq)
Definition: VirtIORing.c:376
USHORT u16
Definition: btrfs.h:13
#define NULL
Definition: types.h:112
#define DPrintf(Level, Fmt)
Definition: kdebugprint.h:61
struct virtqueue vq
Definition: VirtIORing.c:178

Referenced by vio_legacy_setup_vq(), vio_modern_setup_vq(), and virtqueue_shutdown_split().

◆ vring_size_packed()

unsigned long vring_size_packed ( unsigned int  num,
unsigned long  align 
)

Definition at line 162 of file VirtIORing-Packed.c.

163{
164 /* array of descriptors */
165 unsigned long res = num * sizeof(struct vring_packed_desc);
166 /* driver and device event */
167 res += 2 * sizeof(struct vring_packed_desc_event);
168 return res;
169}

Referenced by virtqueue_shutdown_packed(), and vring_size().