L4Re Operating System Framework
Interface and Usage Documentation
|
#include <virtqueue>
Data Structures | |
class | Avail |
Type of available ring, this is read-only for the host. More... | |
class | Desc |
Descriptor in the descriptor table. More... | |
class | Used |
Used ring. More... | |
struct | Used_elem |
Type of an element of the used ring. More... | |
Public Types | |
enum | |
Fixed alignment values for different parts of a virtqueue. | |
Public Member Functions | |
void | disable () |
Completely disable the queue. | |
unsigned long | total_size () const |
Calculate the total size of this virtqueue. | |
unsigned long | avail_offset () const |
Get the offset of the available ring from the descriptor table. | |
unsigned long | used_offset () const |
Get the offset of the used ring from the descriptor table. | |
void | setup (unsigned num, void *desc, void *avail, void *used) |
Enable this queue. | |
void | setup_simple (unsigned num, void *ring) |
Enable this queue. | |
void | dump (Desc const *d) const |
Dump descriptors for this queue. | |
bool | ready () const |
Test if this queue is in working state. | |
unsigned | num () const |
bool | no_notify_guest () const |
Get the no IRQ flag of this queue. | |
bool | no_notify_host () const |
Get the no notify flag of this queue. | |
void | no_notify_host (bool value) |
Set the no-notify flag for this queue. | |
l4_uint16_t | get_avail_idx () const |
Get available index from available ring (for debugging). | |
l4_uint16_t | get_tail_avail_idx () const |
Get tail-available index stored in local state (for debugging). | |
Static Public Member Functions | |
static unsigned long | total_size (unsigned num) |
Calculate the total size for a virtqueue of the given dimensions. | |
static unsigned long | desc_size (unsigned num) |
Calculate the size of the descriptor table for num entries. | |
static unsigned long | desc_align () |
Get the alignment in zero LSBs needed for the descriptor table. | |
static unsigned long | avail_size (unsigned num) |
Calculate the size of the available ring for num entries. | |
static unsigned long | avail_align () |
Get the alignment in zero LSBs needed for the available ring. | |
static unsigned long | used_size (unsigned num) |
Calculate the size of the used ring for num entries. | |
static unsigned long | used_align () |
Get the alignment in zero LSBs needed for the used ring. | |
Protected Member Functions | |
Virtqueue ()=default | |
Create a disabled virtqueue. | |
Protected Attributes | |
Desc * | _desc = nullptr |
pointer to descriptor table, NULL if queue is off. | |
Avail * | _avail = nullptr |
pointer to available ring. | |
Used * | _used = nullptr |
pointer to used ring. | |
l4_uint16_t | _current_avail = 0 |
The life counter for the queue. | |
l4_uint16_t | _idx_mask = 0 |
mask used for indexing into the descriptor table and the rings. | |
Low-level Virtqueue.
This class represents a single virtqueue, with a local running available index.
|
inlinestatic |
|
inlinestatic |
Calculate the size of the available ring for num
entries.
num | The number of entries in the available ring. |
num
entries. Definition at line 285 of file virtqueue.
References num().
Referenced by L4virtio::Svr::Device_t< DATA >::setup_queue(), setup_simple(), and total_size().
|
inlinestatic |
|
inlinestatic |
Calculate the size of the descriptor table for num
entries.
num | The number of entries in the descriptor table. |
num
entries. Definition at line 267 of file virtqueue.
References num().
Referenced by L4virtio::Svr::Device_t< DATA >::setup_queue(), setup_simple(), and total_size().
|
inline |
Completely disable the queue.
setup() must be used to enable the queue again.
Definition at line 230 of file virtqueue.
References _desc.
Referenced by L4virtio::Svr::Block_dev_base< Ds_data >::reset(), and L4virtio::Svr::Device_t< DATA >::setup_queue().
|
inline |
Dump descriptors for this queue.
Definition at line 398 of file virtqueue.
References _desc, and L4virtio::Virtqueue::Desc::dump().
|
inline |
Get available index from available ring (for debugging).
Definition at line 455 of file virtqueue.
References _avail, and L4virtio::Virtqueue::Avail::idx.
|
inline |
Get tail-available index stored in local state (for debugging).
Definition at line 462 of file virtqueue.
References _current_avail.
|
inline |
Get the no IRQ flag of this queue.
Definition at line 420 of file virtqueue.
References _avail, L4virtio::Virtqueue::Avail::flags, and L4virtio::Virtqueue::Avail::Flags::no_irq().
Referenced by L4virtio::Svr::Block_dev_base< Ds_data >::finalize_request(), and L4virtio::Svr::Console::Device::notify_queue().
|
inline |
Get the no notify flag of this queue.
Definition at line 432 of file virtqueue.
References _used, L4virtio::Virtqueue::Used::flags, and L4virtio::Virtqueue::Used::Flags::no_notify().
|
inline |
Set the no-notify flag for this queue.
Definition at line 442 of file virtqueue.
References _used, L4virtio::Virtqueue::Used::flags, and L4virtio::Virtqueue::Used::Flags::no_notify().
|
inline |
Definition at line 410 of file virtqueue.
References _idx_mask.
Referenced by avail_size(), desc_size(), L4virtio::Driver::Virtqueue::init_queue(), L4virtio::Driver::Virtqueue::init_queue(), L4virtio::Driver::Virtqueue::initialize_rings(), L4virtio::Driver::Block_device::process_used_queue(), L4virtio::Driver::Virtio_net_device::rx_pkt(), setup(), setup_simple(), L4virtio::Svr::Request_processor::start(), total_size(), total_size(), and used_size().
|
inline |
Test if this queue is in working state.
Definition at line 406 of file virtqueue.
References _desc, and L4_LIKELY.
Referenced by L4virtio::Svr::Virtqueue::disable_notify(), L4virtio::Svr::Virtqueue::enable_notify(), L4virtio::Svr::Block_dev_base< Ds_data >::finalize_request(), L4virtio::Svr::Block_dev_base< Ds_data >::get_request(), L4virtio::Svr::Console::Virtio_con::handle_control_message(), L4virtio::Svr::Console::Port::queues_ready(), L4virtio::Svr::Console::Port::rx_ready(), L4virtio::Svr::Console::Virtio_con::send_control_message(), and L4virtio::Svr::Console::Port::tx_ready().
|
inline |
Enable this queue.
num | The number of entries in the descriptor table, the available ring, and the used ring (must be a power of 2). |
desc | The address of the descriptor table. (Must be Desc_align aligned and at least desc_size(num) bytes in size.) |
avail | The address of the available ring. (Must be Avail_align aligned and at least avail_size(num) bytes in size.) |
used | The address of the used ring. (Must be Used_align aligned and at least used_size(num) bytes in size.) |
Due to the data type of the descriptors, the queue can have a maximum size of 2^16.
Definition at line 355 of file virtqueue.
References _avail, _current_avail, _desc, _idx_mask, _used, L4_EINVAL, and num().
Referenced by L4virtio::Driver::Virtqueue::init_queue(), L4virtio::Svr::Device_t< DATA >::setup_queue(), and setup_simple().
|
inline |
Enable this queue.
num | The number of entries in the descriptor table, the available ring, and the used ring (must be a power of 2). |
ring | The base address for the queue data structure. The memory block at ring must be at least total_size(num) bytes in size and have an alignment of Desc_align (desc_align()) bits. |
Due to the data type of the descriptors, the queue can have a maximum size of 2^16.
Definition at line 384 of file virtqueue.
References avail_size(), desc_size(), l4_round_size(), num(), and setup().
Referenced by L4virtio::Driver::Virtqueue::init_queue().
|
inline |
|
inlinestatic |
Calculate the total size for a virtqueue of the given dimensions.
num | The number of entries in the descriptor table, the available ring, and the used ring (must be a power of 2). |
Definition at line 251 of file virtqueue.
References avail_size(), desc_size(), l4_round_size(), num(), and used_size().
Referenced by L4virtio::Driver::Virtio_net_device::setup_device(), and L4virtio::Driver::Block_device::setup_device().
|
inlinestatic |
|
inlinestatic |
Calculate the size of the used ring for num
entries.
num | The number of entries in the used ring. |
num
entries. Definition at line 304 of file virtqueue.
References num().
Referenced by L4virtio::Svr::Device_t< DATA >::setup_queue(), total_size(), and total_size().