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

A Port on the Virtio Net Switch. More...

#include <port.h>

+ Inheritance diagram for Virtio_port:
+ Collaboration diagram for Virtio_port:

Public Member Functions

void set_vlan_access (l4_uint16_t id)
 Set port as access port for a certain VLAN.
 
void set_vlan_trunk (const std::vector< l4_uint16_t > &ids)
 Set port as trunk port.
 
void set_monitor ()
 Set this port as monitor port.
 
bool match_vlan (uint16_t id)
 Match VLAN id.
 
Mac_addr mac () const
 Get MAC address.
 
 Virtio_port (unsigned vq_max, unsigned num_ds, char const *name, l4_uint8_t const *mac)
 Create a Virtio net port object.
 
bool tx_work_pending () const
 Check whether there is any work pending on the transmission queue.
 
std::optional< Virtio_net_requestget_tx_request ()
 Get one request from the transmission queue.
 
void drop_requests ()
 Drop all requests pending in the transmission queue.
 
void handle_request (Virtio_port *src_port, Virtio_net_request const &request)
 Handle a request - send it to the guest associated with this port.
 
- Public Member Functions inherited from Virtio_net
void reset () override
 reset callback, called for doing a device reset
 
int reconfig_queue (unsigned index) override
 callback for client queue-config request
 
bool check_queues () override
 Check whether both virtqueues are ready.
 
void register_single_driver_irq () override
 Save the _kick_guest_irq that the client sent via device_notification_irq().
 
void trigger_driver_config_irq () override
 callback for triggering configuration change notification IRQ
 
void notify_queue (L4virtio::Svr::Virtqueue *queue)
 Trigger the _kick_guest_irq IRQ.
 
Virtqueue * tx_q ()
 Getter for the transmission queue.
 
Virtqueue * rx_q ()
 Getter for the receive queue.
 
Virtqueue const * tx_q () const
 Getter for the transmission queue.
 
Virtqueue const * rx_q () const
 Getter for the receive queue.
 
- Public Member Functions inherited from L4virtio::Svr::Device_t< DATA >
virtual bool check_features ()
 callback for checking the subset of accepted features
 
virtual void cfg_changed (unsigned)
 callback for client device configuration changes
 
virtual L4::Cap< L4::Irqdevice_notify_irq () const
 callback to gather the device notification IRQ (old-style)
 
virtual void register_driver_irq (unsigned idx)
 Callback for registering an notification IRQ (multi IRQ).
 
virtual L4::Cap< L4::Irqdevice_notify_irq (unsigned idx)
 Callback to gather the device notification IRQ (multi IRQ).
 
virtual unsigned num_events_supported () const
 Return the highest notification index supported.
 
 Device_t (Dev_config *dev_config)
 Make a device for the given config.
 
Mem_list const * mem_info () const
 Get the memory region list used for this device.
 
void reset_queue_config (unsigned idx, unsigned num_max, bool inc_generation=false)
 Trigger reset for the configuration space for queue idx.
 
void init_mem_info (unsigned num)
 Initialize the memory region list to the given maximum.
 
void device_error ()
 Transition device into DEVICE_NEEDS_RESET state.
 
bool setup_queue (Virtqueue *q, unsigned qn, unsigned num_max)
 Enable/disable the specified queue.
 
bool handle_mem_cmd_write ()
 Check for a value in the cmd register and handle a write.
 
void enable_trusted_ds_validation ()
 Enable trusted dataspace validation.
 
void add_trusted_dataspaces (std::shared_ptr< Ds_vector const > ds)
 Provide a list of trusted dataspaces that can be used for validation.
 
- Public Member Functions inherited from L4::Epiface_t0< RPC_IFACE, BASE >
Type_info::Demand get_buffer_demand () const
 Get the server-side buffer demand based in IFACE.
 
Cap< RPC_IFACE > obj_cap () const
 Get the (typed) capability to this object.
 
- Public Member Functions inherited from L4::Epiface
 Epiface ()
 Make a server object.
 
virtual ~Epiface ()=0
 Destroy the object.
 
Stored_cap obj_cap () const
 Get the capability to the kernel object belonging to this object.
 
Server_ifaceserver_iface () const
 Get pointer to server interface at which the object is currently registered.
 
int set_server (Server_iface *srv, Cap< void > cap, bool managed=false)
 Set server registration info for the object.
 
void set_obj_cap (Cap< void > const &cap)
 Deprecated server registration function.
 

Additional Inherited Members

- Public Types inherited from L4::Epiface_t0< RPC_IFACE, BASE >
typedef RPC_IFACE Interface
 Data type of the IPC interface definition.
 
- Public Types inherited from L4::Epiface
typedef Ipc_svr::Server_iface Server_iface
 Type for abstract server interface.
 
typedef Ipc_svr::Server_iface::Demand Demand
 Type for server-side receive buffer demand.
 
- Protected Attributes inherited from L4virtio::Svr::Device_t< DATA >
Mem_list _mem_info
 Memory region list.
 

Detailed Description

A Port on the Virtio Net Switch.

A Port object gets created by Virtio_factory::op_create(). This function actually only instantiates objects of the types Switch_port and Monitor_port. The created Port registers itself at the switch's server. Usually, the IPC call for port creation comes from ned. To finalize the setup, the client has to initialize the port during the virtio initialization phase. To do this, the client registers a dataspace for queues and buffers and provides an IRQ to notify the client on incoming network requests.

Definition at line 35 of file port.h.

Member Function Documentation

◆ drop_requests()

void Virtio_port::drop_requests ( )
inline

Drop all requests pending in the transmission queue.

This is used for monitor ports, which are not allowed to send packets.

Definition at line 225 of file port.h.

References Virtio_net_request::drop_requests(), and Virtio_net::tx_q().

+ Here is the call graph for this function:

◆ handle_request()

void Virtio_port::handle_request ( Virtio_port src_port,
Virtio_net_request const &  request 
)
inline

Handle a request - send it to the guest associated with this port.

We try to send a packet to the guest associated with this port. To do that, we create a Virtio_net_transfer object to keep any state related to this transaction. If the transfer is successful, we delete the transfer object.

Definition at line 236 of file port.h.

References Virtio_vlan_mangle::add(), Virtio_vlan_mangle::remove(), Virtio_net::rx_q(), and Virtio_net_transfer::transfer().

+ Here is the call graph for this function:

◆ mac()

Mac_addr Virtio_port::mac ( ) const
inline

Get MAC address.

Might be Mac_addr::Addr_unknown if this port has no explicit MAC address set.

Definition at line 156 of file port.h.

Referenced by Virtio_switch::add_port(), and Virtio_port().

+ Here is the caller graph for this function:

◆ match_vlan()

bool Virtio_port::match_vlan ( uint16_t  id)
inline

Match VLAN id.

Parameters
idThe VLAN id of the packet or VLAN_ID_NATIVE.

Check whether VLAN id is switched on this port. Packets of native ports have the special VLAN_ID_NATIVE id.

Definition at line 137 of file port.h.

◆ set_monitor()

void Virtio_port::set_monitor ( )
inline

Set this port as monitor port.

Ensures that outgoing traffic will have a VLAN tag if the packet belongs to a VLAN. Packets coming from native ports will remain untagged.

Definition at line 123 of file port.h.

◆ set_vlan_access()

void Virtio_port::set_vlan_access ( l4_uint16_t  id)
inline

Set port as access port for a certain VLAN.

Parameters
idThe VLAN id for traffic on this port (0 < id < 0xfff)

The port does not see VLAN tags but belongs to the given VLAN.

Definition at line 83 of file port.h.

◆ set_vlan_trunk()

void Virtio_port::set_vlan_trunk ( const std::vector< l4_uint16_t > &  ids)
inline

Set port as trunk port.

Parameters
idsList of VLAN ids that are switched on this port

Incoming traffic on this port is expected to have a VLAN tag that matches one in ids. Outgoing traffic will be tagged it if there is no tag in the Ethernet header yet.

Definition at line 100 of file port.h.


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