6 #include <satcat5/router2_table.h>
13 static constexpr
unsigned REG_CTRL = 509;
14 static constexpr
unsigned REG_DATA = 508;
17 static constexpr u32 MASK_BUSY = (1u << 31);
18 static constexpr u32 MASK_SIZE = 0xFFFF;
19 static constexpr u32 OPCODE_WRITE = (1u << 28);
20 static constexpr u32 OPCODE_DROUTE = (2u << 28);
21 static constexpr u32 OPCODE_CLEAR = (3u << 28);
24 : m_cfg(cfg->get_register(devaddr))
26 m_cfg[REG_CTRL] = OPCODE_CLEAR;
30 return unsigned(m_cfg[REG_CTRL] & MASK_SIZE);
36 && route_load(OPCODE_DROUTE, route);
42 && route_load(OPCODE_WRITE + idx, route);
46 bool Table::route_load(u32 opcode,
const Route& route) {
50 u32 port = route.
port;
54 while (m_cfg[REG_CTRL] & MASK_BUSY) {}
57 m_cfg[REG_DATA] = u32((pfix << 24) | (port << 16) | (dmac >> 32));
58 m_cfg[REG_DATA] = u32(dmac & 0xFFFFFFFFu);
60 m_cfg[REG_CTRL] = opcode;
virtual bool route_wrdef(const satcat5::ip::Route &route)
Internal methods used to access "m_route_default".
virtual bool route_write(unsigned idx, const satcat5::ip::Route &route)
Internal methods used to access "m_route_table".
IPv4 forwarding table with hardware mirroring.
unsigned table_size()
Read the size of the hardware table.
bool route_wrdef(const satcat5::ip::Route &route) override
Internal methods used to access "m_route_default".
bool route_write(unsigned idx, const satcat5::ip::Route &route) override
Internal methods used to access "m_route_table".
constexpr u64 to_u64() const
Convert from MacAddr to u64.
u32 value
Raw access to the underlying representation.
A single entry in the static routing table.
satcat5::eth::MacAddr dstmac
Next-hop MAC address.
satcat5::ip::Subnet subnet
Subnet address + mask.
u8 port
Next-hop port number.
unsigned prefix() const
Get the CIDR prefix length for this subnet.
satcat5::ip::Addr addr
Base address.