L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
switch.h
1/*
2 * Copyright (C) 2016-2017, 2020, 2022-2024 Kernkonzept GmbH.
3 * Author(s): Jean Wolter <jean.wolter@kernkonzept.com>
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 *
6 * License: see LICENSE.spdx (in this directory or the directories above)
7 */
8#pragma once
9
10#include "port.h"
11#include "mac_table.h"
12
29{
30private:
31 Virtio_port **_ports;
32 Virtio_port *_monitor;
34 unsigned _max_ports;
35 unsigned _max_used;
36 Mac_table<> _mac_table;
37
38 int lookup_free_slot();
39
49 void handle_tx_queue(Virtio_port *port);
50
51
52 void all_kick_emit_enable()
53 {
54 for (unsigned idx = 0; idx < _max_ports; ++idx)
55 if (_ports[idx])
56 _ports[idx]->kick_emit_and_enable();
57 }
58
59 void all_kick_disable_remember()
60 {
61 for (unsigned idx = 0; idx < _max_ports; ++idx)
62 if (_ports[idx])
63 _ports[idx]->kick_disable_and_remember();
64 }
65
66public:
72 explicit Virtio_switch(unsigned max_ports);
73
82 bool add_port(Virtio_port *port);
83
92 bool add_monitor_port(Virtio_port *port);
93
101 void check_ports();
102
113 void handle_port_irq(Virtio_port *port);
114
123 int port_available(bool monitor)
124 {
125 if (monitor)
126 return !_monitor ? 0 : -1;
127
128 return lookup_free_slot();
129 }
130};
Mac_table manages a 1:n association between ports and MAC addresses.
Definition mac_table.h:40
A Port on the Virtio Net Switch.
Definition port.h:36
The Virtio switch contains all ports and processes network requests.
Definition switch.h:29
bool add_monitor_port(Virtio_port *port)
Add a monitor port to the switch.
Definition switch.cc:55
void check_ports()
Check validity of ports.
Definition switch.cc:70
bool add_port(Virtio_port *port)
Add a port to the switch.
Definition switch.cc:30
void handle_port_irq(Virtio_port *port)
Handle an incoming irq on a given port.
Definition switch.cc:143
int port_available(bool monitor)
Is there still a free port on this switch available?
Definition switch.h:123