#include <stdbool.h>#include <stdint.h>#include <openamp/virtio_ring.h>#include <metal/alloc.h>#include <metal/io.h>#include <metal/cache.h>Go to the source code of this file.
Data Structures | |
| struct | virtqueue_buf |
| Buffer descriptor. More... | |
| struct | vq_desc_extra |
| Vring descriptor extra information for buffer list management. More... | |
| struct | virtqueue |
| Local virtio queue to manage a virtio ring for sending or receiving. More... | |
| struct | vring_alloc_info |
| Virtio ring specific information. More... | |
Macros | |
| #define | VQ_ERROR_BASE -3000 |
| #define | ERROR_VRING_FULL (VQ_ERROR_BASE - 1) |
| #define | ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2) |
| #define | ERROR_EMPTY_RING (VQ_ERROR_BASE - 3) |
| #define | ERROR_NO_MEM (VQ_ERROR_BASE - 4) |
| #define | ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5) |
| #define | ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6) |
| #define | ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7) |
| #define | ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8) |
| #define | VQUEUE_SUCCESS 0 |
| #define | VQ_RING_DESC_CHAIN_END 32768 |
| #define | VIRTIO_RING_F_INDIRECT_DESC (1 << 28) |
| #define | VIRTIO_RING_F_EVENT_IDX (1 << 29) |
| #define | VRING_FLUSH(x, s) |
| #define | VRING_INVALIDATE(x, s) |
| #define | VQASSERT(_vq, _exp, _msg) |
| #define | VQ_RING_ASSERT_VALID_IDX(_vq, _idx) |
| #define | VQ_RING_ASSERT_CHAIN_TERM(_vq) |
| #define | VQ_PARAM_CHK(condition, status_var, status_err) |
| #define | VQUEUE_BUSY(vq) |
| #define | VQUEUE_IDLE(vq) |
Typedefs | |
| typedef void(* | vq_callback) (struct virtqueue *) |
| typedef void(* | vq_notify) (struct virtqueue *) |
Functions | |
| int | virtqueue_create (struct virtio_device *device, unsigned short id, const char *name, struct vring_alloc_info *ring, void(*callback)(struct virtqueue *vq), void(*notify)(struct virtqueue *vq), struct virtqueue *vq) |
| static void | virtqueue_set_shmem_io (struct virtqueue *vq, struct metal_io_region *io) |
| int | virtqueue_add_buffer (struct virtqueue *vq, struct virtqueue_buf *buf_list, int readable, int writable, void *cookie) |
| void * | virtqueue_get_buffer (struct virtqueue *vq, uint32_t *len, uint16_t *idx) |
| void * | virtqueue_get_first_avail_buffer (struct virtqueue *vq, uint16_t *avail_idx, uint32_t *len) |
| void * | virtqueue_get_next_avail_buffer (struct virtqueue *vq, uint16_t idx, uint16_t *next_idx, uint32_t *next_len) |
| int | virtqueue_add_consumed_buffer (struct virtqueue *vq, uint16_t head_idx, uint32_t len) |
| void | virtqueue_disable_cb (struct virtqueue *vq) |
| int | virtqueue_enable_cb (struct virtqueue *vq) |
| void | virtqueue_kick (struct virtqueue *vq) |
| static struct virtqueue * | virtqueue_allocate (unsigned int num_desc_extra) |
| void | virtqueue_free (struct virtqueue *vq) |
| void | virtqueue_dump (struct virtqueue *vq) |
| void | virtqueue_notification (struct virtqueue *vq) |
| uint32_t | virtqueue_get_desc_size (struct virtqueue *vq) |
| uint32_t | virtqueue_get_buffer_length (struct virtqueue *vq, uint16_t idx) |
| void * | virtqueue_get_buffer_addr (struct virtqueue *vq, uint16_t idx) |
| bool | virtqueue_is_buffer_device_writable (struct virtqueue *vq, uint16_t idx) |
| Test if buffer is marked as device-writable. | |
| static int | virtqueue_empty (struct virtqueue *vq) |
| Test if virtqueue is empty. | |
| static int | virtqueue_full (struct virtqueue *vq) |
| Test if virtqueue is full. | |
| #define ERROR_EMPTY_RING (VQ_ERROR_BASE - 3) |
| #define ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2) |
| #define ERROR_NO_MEM (VQ_ERROR_BASE - 4) |
| #define ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8) |
| #define ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6) |
| #define ERROR_VRING_FULL (VQ_ERROR_BASE - 1) |
| #define ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5) |
| #define ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7) |
| #define VIRTIO_RING_F_EVENT_IDX (1 << 29) |
| #define VIRTIO_RING_F_INDIRECT_DESC (1 << 28) |
| #define VQ_ERROR_BASE -3000 |
| #define VQ_PARAM_CHK | ( | condition, | |
| status_var, | |||
| status_err ) |
| #define VQ_RING_ASSERT_CHAIN_TERM | ( | _vq | ) |
| #define VQ_RING_ASSERT_VALID_IDX | ( | _vq, | |
| _idx ) |
| #define VQ_RING_DESC_CHAIN_END 32768 |
| #define VQASSERT | ( | _vq, | |
| _exp, | |||
| _msg ) |
| #define VQUEUE_BUSY | ( | vq | ) |
| #define VQUEUE_IDLE | ( | vq | ) |
| #define VQUEUE_SUCCESS 0 |
| #define VRING_FLUSH | ( | x, | |
| s ) |
| #define VRING_INVALIDATE | ( | x, | |
| s ) |
| typedef void(* vq_callback) (struct virtqueue *) |
| typedef void(* vq_notify) (struct virtqueue *) |
| int virtqueue_add_buffer | ( | struct virtqueue * | vq, |
| struct virtqueue_buf * | buf_list, | ||
| int | readable, | ||
| int | writable, | ||
| void * | cookie ) |
| int virtqueue_add_consumed_buffer | ( | struct virtqueue * | vq, |
| uint16_t | head_idx, | ||
| uint32_t | len ) |
|
inlinestatic |
| int virtqueue_create | ( | struct virtio_device * | device, |
| unsigned short | id, | ||
| const char * | name, | ||
| struct vring_alloc_info * | ring, | ||
| void(* | callback )(struct virtqueue *vq), | ||
| void(* | notify )(struct virtqueue *vq), | ||
| struct virtqueue * | vq ) |
| void virtqueue_disable_cb | ( | struct virtqueue * | vq | ) |
| void virtqueue_dump | ( | struct virtqueue * | vq | ) |
|
inlinestatic |
Test if virtqueue is empty.
| vq | Pointer to VirtIO queue control block |
| int virtqueue_enable_cb | ( | struct virtqueue * | vq | ) |
| void virtqueue_free | ( | struct virtqueue * | vq | ) |
|
inlinestatic |
Test if virtqueue is full.
| vq | Pointer to VirtIO queue control block |
| void * virtqueue_get_buffer | ( | struct virtqueue * | vq, |
| uint32_t * | len, | ||
| uint16_t * | idx ) |
| void * virtqueue_get_buffer_addr | ( | struct virtqueue * | vq, |
| uint16_t | idx ) |
| uint32_t virtqueue_get_buffer_length | ( | struct virtqueue * | vq, |
| uint16_t | idx ) |
| uint32_t virtqueue_get_desc_size | ( | struct virtqueue * | vq | ) |
| void * virtqueue_get_first_avail_buffer | ( | struct virtqueue * | vq, |
| uint16_t * | avail_idx, | ||
| uint32_t * | len ) |
| void * virtqueue_get_next_avail_buffer | ( | struct virtqueue * | vq, |
| uint16_t | idx, | ||
| uint16_t * | next_idx, | ||
| uint32_t * | next_len ) |
| bool virtqueue_is_buffer_device_writable | ( | struct virtqueue * | vq, |
| uint16_t | idx ) |
Test if buffer is marked as device-writable.
| vq | Pointer to VirtIO queue control block |
| idx | Index used in vring desc table |
| void virtqueue_kick | ( | struct virtqueue * | vq | ) |
| void virtqueue_notification | ( | struct virtqueue * | vq | ) |
|
inlinestatic |