Zephyr Project API 4.1.99
A Scalable Open Source RTOS
|
Virtqueue Interface. More...
Data Structures | |
struct | virtq_desc |
virtqueue descriptor More... | |
struct | virtq_avail |
virtqueue available ring More... | |
struct | virtq_used_elem |
used descriptor chain More... | |
struct | virtq_used |
virtqueue used ring More... | |
struct | virtq_receive_callback_entry |
callback descriptor More... | |
struct | virtq |
virtqueue More... | |
struct | virtq_buf |
single buffer passed to virtq_add_buffer_chain More... | |
Macros | |
#define | VIRTQ_DESC_F_NEXT 1 |
used in virtq_desc::flags, enables chaining descriptor via virtq_desc::next | |
#define | VIRTQ_DESC_F_WRITE 2 |
used in virtq_desc::flags, makes descriptor device writeable | |
Typedefs | |
typedef void(* | virtq_receive_callback) (void *opaque, uint32_t used_len) |
receive callback function type | |
Functions | |
int | virtq_create (struct virtq *v, size_t size) |
creates virtqueue | |
void | virtq_free (struct virtq *v) |
frees virtqueue | |
int | virtq_add_buffer_chain (struct virtq *v, struct virtq_buf *bufs, uint16_t bufs_size, uint16_t device_readable_count, virtq_receive_callback cb, void *cb_opaque, k_timeout_t timeout) |
adds chain of buffers to the virtqueue | |
void | virtq_add_free_desc (struct virtq *v, uint16_t desc_idx) |
adds free descriptor back | |
int | virtq_get_free_desc (struct virtq *v, uint16_t *desc_idx, k_timeout_t timeout) |
gets next free descriptor | |
Virtqueue Interface.
#define VIRTQ_DESC_F_NEXT 1 |
#include <include/zephyr/virtio/virtqueue.h>
used in virtq_desc::flags, enables chaining descriptor via virtq_desc::next
#define VIRTQ_DESC_F_WRITE 2 |
#include <include/zephyr/virtio/virtqueue.h>
used in virtq_desc::flags, makes descriptor device writeable
typedef void(* virtq_receive_callback) (void *opaque, uint32_t used_len) |
#include <include/zephyr/virtio/virtqueue.h>
receive callback function type
opaque | argument passed to the callback |
used_len | total amount of bytes written to the descriptor chain by the virtio device |
int virtq_add_buffer_chain | ( | struct virtq * | v, |
struct virtq_buf * | bufs, | ||
uint16_t | bufs_size, | ||
uint16_t | device_readable_count, | ||
virtq_receive_callback | cb, | ||
void * | cb_opaque, | ||
k_timeout_t | timeout | ||
) |
#include <include/zephyr/virtio/virtqueue.h>
adds chain of buffers to the virtqueue
Note that according to spec 2.7.13.3 the device may access the buffers as soon as the avail->idx is increased, which is done at the end of this function, so the device may access the buffers without notifying it with virtio_notify_virtqueue
v | virtqueue it operates on |
bufs | array of buffers to be added to the virtqueue |
bufs_size | amount of buffers |
device_readable_count | amount of bufferes readable by the device, the first device_readable_count buffers will be set as device readable |
cb | callback to be invoked after device returns the buffer chain, can be NULL |
cb_opaque | opaque value that will be passed to the cb |
timeout | amount of time it will wait for free descriptors, with K_NO_WAIT it can be called from isr |
#include <include/zephyr/virtio/virtqueue.h>
adds free descriptor back
v | virtqueue it operates on |
desc_idx | index of returned descriptor |
#include <include/zephyr/virtio/virtqueue.h>
creates virtqueue
v | virtqueue to be created |
size | size of the virtqueue |
void virtq_free | ( | struct virtq * | v | ) |
int virtq_get_free_desc | ( | struct virtq * | v, |
uint16_t * | desc_idx, | ||
k_timeout_t | timeout | ||
) |
#include <include/zephyr/virtio/virtqueue.h>
gets next free descriptor
v | virtqueue it operates on |
desc_idx | address where index of descriptor will be stored |
timeout | amount of time it will wait for free descriptor, with K_NO_WAIT it can be called from isr |