L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
Virtio_switch Class Reference

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 (Virtio_port *port)
 Add a port to the switch.
 
bool add_monitor_port (Virtio_port *port)
 Add a monitor port to the switch.
 
void check_ports ()
 Check validity of ports.
 
void handle_port_irq (Virtio_port *port)
 Handle an incoming irq on a 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 28 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_portsmaximal number of provided ports

Definition at line 12 of file switch.cc.

Member Function Documentation

◆ add_monitor_port()

bool Virtio_switch::add_monitor_port ( Virtio_port port)

Add a monitor port to the switch.

Parameters
portA pointer to an already constructed Virtio_port object.
Return values
truePort was added successfully.
falseSwitch was not able to add the port.

Definition at line 55 of file switch.cc.

Referenced by Switch_factory::op_create().

+ Here is the caller graph for this function:

◆ add_port()

bool Virtio_switch::add_port ( Virtio_port port)

Add a port to the switch.

Parameters
portA pointer to an already constructed Virtio_port object.
Return values
truePort was added successfully.
falseSwitch was not able to add the port.

Definition at line 30 of file switch.cc.

References Mac_addr::is_unknown(), and Virtio_port::mac().

Referenced by Switch_factory::op_create().

+ Here is the call graph for this function:
+ Here is the caller 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 70 of file switch.cc.

References Mac_table< Size >::flush(), and L4::Epiface_t0< RPC_IFACE, BASE >::obj_cap().

+ Here is the call graph for this function:

◆ handle_port_irq()

void Virtio_switch::handle_port_irq ( Virtio_port port)

Handle an incoming irq on a given port.

Virtio_port does not handle irq related stuff by itself. Someone else has to do this and has to handle incoming irqs. This function is supposed to be invoked after an irq related to the port came in.

Parameters
portthe Virtio_port an irq was triggered on

Definition at line 143 of file switch.cc.

References L4virtio::Svr::Device_t< DATA >::device_error(), L4virtio::Svr::Bad_descriptor::message(), Virtio_net::rx_q(), Virtio_net::tx_q(), and Virtio_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
monitorTrue if we look for a monitor slot.
Return values
>=0The next available port index.
-1No port available.

Definition at line 123 of file switch.h.

Referenced by Switch_factory::op_create().

+ Here is the caller graph for this function:

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