Loading...
Searching...
No Matches
L4virtio::Svr::Virtqueue Class Reference

Virtqueue implementation for the device. More...

`#include <virtio>`

Inheritance diagram for L4virtio::Svr::Virtqueue:
Collaboration diagram for L4virtio::Svr::Virtqueue:

## Data Structures

class | Head_desc
| VIRTIO request, essentially a descriptor from the available ring. More...

## Public Member Functions

Request | next_avail ()
| Get the next available descriptor from the available ring.
void | rewind_avail (Head_desc const &d)
| Return unfinished descriptors to the available ring, i.e.
bool | desc_avail () const
| Test for available descriptors.
void | consumed (Head_desc const &r, l4_uint32_t len=0)
| Put the given descriptor into the used ring.
template<typename ITER>
void | consumed (ITER const &begin, ITER const &end)
| Put multiple descriptors into the used ring.
template<typename QUEUE_OBSERVER>
void | finish (Head_desc &d, QUEUE_OBSERVER *o, l4_uint32_t len=0)
| Add a descriptor to the used ring, and notify an observer.
template<typename ITER, typename QUEUE_OBSERVER>
void | finish (ITER const &begin, ITER const &end, QUEUE_OBSERVER *o)
| Add a range of descriptors to the used ring, and notify an observer once.
void | disable_notify ()
| Set the 'no notify' flag for this queue.
void | enable_notify ()
| Clear the 'no notify' flag for this queue.
Desc const * | desc (unsigned idx) const
| Get a descriptor from the descriptor list.
Public Member Functions inherited from L4virtio::Virtqueue
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).

## Additional Inherited Members

Public Types inherited from L4virtio::Virtqueue
enum |
| Fixed alignment values for different parts of a virtqueue.
Static Public Member Functions inherited from L4virtio::Virtqueue
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 inherited from L4virtio::Virtqueue
| Virtqueue ()=default
| Create a disabled virtqueue.
Protected Attributes inherited from L4virtio::Virtqueue
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.

## Detailed Description

Virtqueue implementation for the device.

This class represents a single virtqueue, with a local running available index.

Note
  The Virtqueue implementation is not thread-safe.

Definition at line 87 of file virtio.

## Member Function Documentation

## consumed() [1/2]

void L4virtio::Svr::Virtqueue::consumed | ( | Head_desc const & | r,
|  | l4_uint32_t | len = 0 )

inline

Put the given descriptor into the used ring.

Parameters

  r | Request that shall be marked as finished.
  len | The total number of bytes written.

Precondition
  queue must be in working state.
  r must be a valid request from this queue.

Definition at line 190 of file virtio.

References L4virtio::Virtqueue::_desc, L4virtio::Virtqueue::_idx_mask, and L4virtio::Virtqueue::_used.

Referenced by finish(), and finish().

Here is the caller graph for this function:

## consumed() [2/2]

template<typename ITER>

void L4virtio::Svr::Virtqueue::consumed | ( | ITER const & | begin,
|  | ITER const & | end )

inline

Put multiple descriptors into the used ring.

A range of descriptors, specified by begin and end iterators is added. Each iterator points to a struct that has a first member that is a Head_desc and a second member that is the corresponding number of bytes written.

Template Parameters

  ITER | The type of the iterator (inferred).

Parameters

  begin | Iterator pointing to first new descriptor.
  end | Iterator pointing to one past last entry.

Precondition
  queue must be in working state.

Definition at line 213 of file virtio.

References L4virtio::Virtqueue::_desc, L4virtio::Virtqueue::_idx_mask, and L4virtio::Virtqueue::_used.

## desc()

Desc const * L4virtio::Svr::Virtqueue::desc | ( | unsigned | idx | ) | const

inline

Get a descriptor from the descriptor list.

Parameters

  idx | The index of the descriptor.

Precondition
  idx < num
  queue must be in working state

Definition at line 298 of file virtio.

References L4virtio::Virtqueue::_desc.

Referenced by L4virtio::Svr::Request_processor::start().

Here is the caller graph for this function:

## desc_avail()

bool L4virtio::Svr::Virtqueue::desc_avail | ( |  | ) | const

inline

Test for available descriptors.

Returns
  true if there are descriptors available, false if not.

Precondition
  The queue must be in working state.

Definition at line 175 of file virtio.

References L4virtio::Virtqueue::_avail, and L4virtio::Virtqueue::_current_avail.

Referenced by Virtio_net_request::drop_requests(), and L4virtio_port::tx_work_pending().

Here is the caller graph for this function:

## disable_notify()

void L4virtio::Svr::Virtqueue::disable_notify | ( |  | ) |

inline

Set the 'no notify' flag for this queue.

This function may be called on a disabled queue.

Definition at line 273 of file virtio.

References L4virtio::Virtqueue::_used, L4_LIKELY, and L4virtio::Virtqueue::ready().

Referenced by Virtio_switch::handle_l4virtio_port_tx().

Here is the call graph for this function:
Here is the caller graph for this function:

## enable_notify()

void L4virtio::Svr::Virtqueue::enable_notify | ( |  | ) |

inline

Clear the 'no notify' flag for this queue.

This function may be called on a disabled queue.

Definition at line 284 of file virtio.

References L4virtio::Virtqueue::_used, L4_LIKELY, and L4virtio::Virtqueue::ready().

Referenced by Virtio_switch::handle_l4virtio_port_tx().

Here is the call graph for this function:
Here is the caller graph for this function:

## finish() [1/2]

template<typename QUEUE_OBSERVER>

void L4virtio::Svr::Virtqueue::finish | ( | Head_desc & | d,
|  | QUEUE_OBSERVER * | o,
|  | l4_uint32_t | len = 0 )

inline

Add a descriptor to the used ring, and notify an observer.

Template Parameters

  QUEUE_OBSERVER | The type of the observer (inferred).

Parameters

  d | descriptor of the request that is to be marked as finished.
  o | Pointer to the observer that is notified.
  len | Number of bytes written for this request.

Precondition
  queue must be in working state.
  d must be a valid request from this queue.

Definition at line 240 of file virtio.

References consumed().

Referenced by Virtio_net_request::drop_requests(), L4virtio::Svr::Console::Virtio_con::handle_control_message(), L4virtio::Svr::Console::Device::port_read(), L4virtio::Svr::Console::Device::port_write(), and L4virtio::Svr::Console::Virtio_con::send_control_message().

Here is the call graph for this function:
Here is the caller graph for this function:

## finish() [2/2]

template<typename ITER, typename QUEUE_OBSERVER>

void L4virtio::Svr::Virtqueue::finish | ( | ITER const & | begin,
|  | ITER const & | end,
|  | QUEUE_OBSERVER * | o )

inline

Add a range of descriptors to the used ring, and notify an observer once.

The iterators are passed to consumed<ITER>(ITER const &, ITER const &), and the requirements detailed there apply.

Template Parameters

  ITER | type of the iterator (inferred)
  QUEUE_OBSERVER | the type of the observer (inferred).

Parameters

  begin | iterator pointing to first element.
  end | iterator pointing to one past last element.
  o | pointer to the observer that is notified.

Precondition
  queue must be in working state.

Definition at line 262 of file virtio.

References consumed().

Here is the call graph for this function:

## next_avail()

Request L4virtio::Svr::Virtqueue::next_avail | ( |  | ) |

inline

Get the next available descriptor from the available ring.

Precondition
  The queue must be in working state.

Returns
  A Request for the next available descriptor, the Request is invalid if there are no descriptors in the available ring.

Note
  The return value must be checked even when a previous desc_avail() returned true.

Definition at line 136 of file virtio.

References L4virtio::Virtqueue::_avail, L4virtio::Virtqueue::_current_avail, L4virtio::Virtqueue::_idx_mask, and L4_LIKELY.

Referenced by Virtio_net_request::drop_requests(), Virtio_net_request::get_request(), L4virtio::Svr::Console::Virtio_con::handle_control_message(), L4virtio::Svr::Console::Device::port_read(), L4virtio::Svr::Console::Device::port_write(), and L4virtio::Svr::Console::Virtio_con::send_control_message().

Here is the caller graph for this function:

## rewind_avail()

void L4virtio::Svr::Virtqueue::rewind_avail | ( | Head_desc const & | d | ) |

inline

Return unfinished descriptors to the available ring, i.e.

reset the local next index of the available ring to the given descriptor.

Parameters

  d | descriptor of the request that is to be marked as finished.

Precondition
  queue must be in working state.
  d must be a valid request from this queue, obtained via next_avail(), that has not yet been finished, and in addition, no descriptors following it have been finished.

Definition at line 160 of file virtio.

References L4virtio::Virtqueue::_current_avail, L4virtio::Virtqueue::_desc, and L4virtio::Virtqueue::_idx_mask.

The documentation for this class was generated from the following file:

- l4/l4virtio/server/virtio