5#include <l4/virtio-net-switch/stats.h>
11 Virtio_net_switch::Statistics *_stats;
12 bool _initialized =
false;
14 Switch_statistics() {}
25 Virtio_net_switch::Statistics *stats()
33 static Switch_statistics& get_instance()
35 static Switch_statistics instance;
42 +
sizeof(Virtio_net_switch::Port_statistics) * num_max_ports);
43 void *addr = malloc(_size);
46 "Could not allocate statistics memory.");
48 memset(addr, 0, _size);
49 _stats =
reinterpret_cast<Virtio_net_switch::Statistics *
>(addr);
51 _stats->max_ports = num_max_ports;
54 Virtio_net_switch::Port_statistics *
55 allocate_port_statistics(
char const* name)
57 for (
unsigned i = 0; i < _stats->max_ports; ++i)
59 if (!_stats->port_stats[i].in_use)
61 memset(
reinterpret_cast<void*
>(&_stats->port_stats[i]), 0,
62 sizeof(Virtio_net_switch::Port_statistics));
63 _stats->port_stats[i].in_use = 1;
64 size_t len = std::min(strlen(name),
sizeof(_stats->port_stats[i].name) - 1);
65 memcpy(_stats->port_stats[i].name, name, len);
66 _stats->port_stats[i].name[len] =
'\0';
68 return &_stats->port_stats[i];
77 Switch_statistics(Switch_statistics
const&) =
delete;
78 void operator=(Switch_statistics
const &) =
delete;
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.
Exception for an abstract runtime error.
unsigned int l4_size_t
Unsigned size type.
unsigned long l4_addr_t
Address type.
unsigned long long l4_uint64_t
Unsigned 64bit value.
l4_addr_t l4_round_page(l4_addr_t address) L4_NOTHROW
Round address up to the next page.