Loading...
Searching...
No Matches
Virtio_switch Class Reference
Virtio Net Switch

The Virtio switch contains all ports and processes network requests. More...

`#include <switch.h>`

Collaboration diagram for Virtio_switch:

## Public Member Functions

| Virtio_switch (unsigned max_ports)
| Create a switch with n ports.
bool | add_port (Port_iface *port)
| Add a port to the switch.
bool | add_monitor_port (Port_iface *port)
| Add a monitor port to the switch.
void | check_ports ()
| Check validity of ports.
bool | handle_l4virtio_port_tx (L4virtio_port *port)
| Handle TX queue of the given port.
int | port_available (bool monitor)
| Is there still a free port on this switch available?

## Detailed Description

The Virtio switch contains all ports and processes network requests.

A Port on its own is not capable to process an incoming network request because it has no knowledge about other ports. The processing of an incoming request therefore gets delegated to the switch.

The Virtio_switch is constructed at the start of the Virtio Net Switch application. The factory saves a reference to it to pass it to the Kick_irq on port creation.

Definition at line 33 of file switch.h.

## Constructor & Destructor Documentation

## Virtio_switch()

Virtio_switch::Virtio_switch | ( | unsigned | max_ports | ) |

explicit

Create a switch with n ports.

Parameters

  max_ports | maximal number of provided ports

Definition at line 12 of file switch.cc.

## Member Function Documentation

## add_monitor_port()

bool Virtio_switch::add_monitor_port | ( | Port_iface * | port | ) |

Add a monitor port to the switch.

Parameters

  port | A pointer to an already constructed Port_iface object.

Return values

  true | Port was added successfully.
  false | Switch was not able to add the port.

Definition at line 54 of file switch.cc.

## add_port()

bool Virtio_switch::add_port | ( | Port_iface * | port | ) |

Add a port to the switch.

Parameters

  port | A pointer to an already constructed Port_iface object.

Return values

  true | Port was added successfully.
  false | Switch was not able to add the port.

Definition at line 29 of file switch.cc.

References Mac_addr::is_unknown().

Here is the call graph for this function:

## check_ports()

void Virtio_switch::check_ports | ( |  | ) |

Check validity of ports.

Check whether all ports are still used and remove any unused (unreferenced) ports. Shall be invoked after an incoming cap deletion irq to remove ports without clients.

Definition at line 69 of file switch.cc.

## handle_l4virtio_port_tx()

bool Virtio_switch::handle_l4virtio_port_tx | ( | L4virtio_port * | port | ) |

Handle TX queue of the given port.

Parameters

  port | L4virtio_port to handle pending TX work for.

Return values

  false | Port hit its TX burst limit, and thus a TX pending reschedule notification was queued.
  true | Port's entire TX queue was processed.

Definition at line 194 of file switch.cc.

References L4virtio::Svr::Device_t< DATA >::device_error(), L4virtio::Svr::Virtqueue::disable_notify(), L4virtio::Svr::Virtqueue::enable_notify(), L4virtio::Svr::Bad_descriptor::message(), Virtio_net::rx_q(), Virtio_net::tx_q(), and L4virtio_port::tx_work_pending().

Here is the call graph for this function:

## port_available()

int Virtio_switch::port_available | ( | bool | monitor | ) |

inline

Is there still a free port on this switch available?

Parameters

  monitor | True if we look for a monitor slot.

Return values

  >=0 | The next available port index.
  -1 | No port available.

Definition at line 148 of file switch.h.

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

- pkg/virtio-net-switch/server/switch/switch.h
- pkg/virtio-net-switch/server/switch/switch.cc