24namespace Virtio_net_switch {
95 : _cap(std::move(cap))
99 "Could not get stats dataspace from switch.");
104 "Could not attach stats dataspace.");
122 for(
size_t i = 0; i < _stats->max_ports; ++i)
124 if (_stats->port_stats[i].in_use
125 && !strncmp (_stats->port_stats[i].name, name,
126 sizeof(_stats->port_stats[i].name)))
127 return &_stats->port_stats[i];
141 for (
l4_uint64_t i = 0; i < _stats->max_ports; ++i)
143 if (_stats->port_stats[i].in_use
144 && !strncmp (_stats->port_stats[i].name, name, 20))
146 std::memcpy(mac, _stats->port_stats[i].mac, 6);
159 "Synchronizing statistics information failed.\n");
163 {
return _stats->
age; }
174 std::shared_ptr<Monitor> _m;
177 Port_statistics *_stats;
183 Port_monitor(std::shared_ptr<Monitor> m,
char const *name)
186 strncpy(_name, name,
sizeof(_name) - 1);
187 _name[
sizeof(_name) - 1] =
'\0';
189 _stats = _m->get_port_stats(_name);
206 if (_age != _m->age())
208 _stats = _m->get_port_stats(_name);
215 tx_num = tx_dropped = tx_bytes = rx_num = rx_dropped = rx_bytes = 0;
219 *tx_num = _stats->tx_num;
220 *tx_dropped = _stats->tx_dropped;
221 *tx_bytes = _stats->tx_bytes;
222 *rx_num = _stats->rx_num;
223 *rx_dropped = _stats->rx_dropped;
224 *rx_bytes = _stats->rx_bytes;
L4::Cap related definitions.
static Env const * env() noexcept
Returns the initial environment for the current task.
L4::Cap< Rm > rm() const noexcept
Object-capability to the region map.
C++ interface for capabilities.
Helper class to create an L4Re interface class that is derived from a single base class.
bool get_port_mac(char const *name, unsigned char *mac) const
Retrieve the MAC address of a port.
void sync() const
Instruct the network switch to update the statistics information.
Port_statistics * get_port_stats(char const *name) const
Retrieve pointer to Port_statistics structure.
IPC interface for the statistics interface.
long sync()
Instruct the switch to update the statistics information in the shared memory buffer.
long get_buffer(L4::Ipc::Out< L4::Cap< L4Re::Dataspace > > ds)
Get shared memory buffer containing port statistics.
unsigned long l4_addr_t
Address type.
unsigned long long l4_uint64_t
Unsigned 64bit value.
@ L4_CAP_FPAGE_RO
Read right for capability flexpages.
Interface Definition Language.
#define L4_INLINE_RPC(res, name, args, attr...)
Define an inline RPC call (type and callable).
Unique_cap< T > make_unique_cap()
Allocate a capability slot and wrap it in an Unique_cap.
L4::Detail::Unique_cap_impl< T, L4Re::Util::Smart_cap_auto< L4_FP_DELETE_OBJ > > Unique_del_cap
Unique capability that implements automatic free and unmap+delete of the capability slot.
L4::Detail::Unique_cap_impl< T, L4Re::Util::Smart_cap_auto< L4_FP_ALL_SPACES > > Unique_cap
Unique capability that implements automatic free and unmap of the capability slot.
l4_ret_t chksys(l4_ret_t err, char const *extra="", l4_ret_t ret=0)
Generate C++ exception on error.
Cap< T > make_cap(L4::Cap< T > cap, unsigned rights) noexcept
Make an L4::Ipc::Cap<T> for the given capability and rights.
@ Search_addr
Search for a suitable address range.
Mark an argument as a output value in an RPC signature.
Standard list of RPCs of an interface.
unsigned char mac[6]
MAC address of a port.
l4_uint64_t rx_bytes
bytes successfully received
l4_uint64_t tx_bytes
bytes successfully sent
char name[20]
name of a port
unsigned char in_use
1 iff the data structure is currently in use, 0 otherwise
l4_uint64_t rx_num
number of successful receive requests
l4_uint64_t rx_dropped
number of dropped receive requests
l4_uint64_t tx_dropped
number of dropped send request
l4_uint64_t tx_num
number of successful send requests
Base statistics data structure, resides at the beginning of shared memory.
l4_uint64_t max_ports
The maximum number of ports that the switch supports.
struct Port_statistics port_stats[]
Array of Port_statistics.
l4_uint64_t age
This value increases on any change in the data structure.
Unique_cap / Unique_del_cap.