SatCat5
satcat5::eth::SwitchCacheInner Class Reference

Detailed Description

MAC-address cache plugin for the software-defined Ethernet switch.

All Ethernet switches maintain a cache of recently used MAC addresses, noting the port associated with each address so that packets can be directed accordingly. The switch cannot operate without this function, using this plugin or a near-equivalent.

This class defines a SwitchCore plugin with a simple implementation of such a cache, with an LRU replacement policy. Configuration methods mimic eth::SwitchConfig.

See also
eth::SwitchCache, eth::SwitchCore.

Definition at line 25 of file eth_sw_cache.h.

#include <eth_sw_cache.h>

Inheritance diagram for satcat5::eth::SwitchCacheInner:
[legend]
Collaboration diagram for satcat5::eth::SwitchCacheInner:
[legend]

Classes

struct  CacheEntry
 Data structure for the internal cache. More...
 

Public Member Functions

void query (satcat5::eth::PluginPacket &pkt) override
 Implement the required SwitchPlugin API.
 
void set_miss_bcast (unsigned port_idx, bool enable)
 Enable or disable "miss-as-broadcast" flag for a specific port. More...
 
void set_miss_mask (SATCAT5_PMASK_TYPE mask)
 Enable or disable "miss-as-broadcast" flag for all ports. More...
 
SATCAT5_PMASK_TYPE get_miss_mask () const
 Identify which ports are currently in "miss-as-broadcast" mode. More...
 
unsigned mactbl_size () const
 Read or manipulate the contents of the MAC-address table. More...
 
bool mactbl_read (unsigned tbl_idx, unsigned &port_idx, satcat5::eth::MacAddr &mac_addr)
 Read or manipulate the contents of the MAC-address table. More...
 
bool mactbl_write (unsigned port_idx, const satcat5::eth::MacAddr &mac_addr)
 Read or manipulate the contents of the MAC-address table. More...
 
bool mactbl_clear ()
 Read or manipulate the contents of the MAC-address table. More...
 
bool mactbl_learn (bool enable)
 Read or manipulate the contents of the MAC-address table. More...
 
bool mactbl_learn () const
 Read or manipulate the contents of the MAC-address table. More...
 

Protected Member Functions

 SwitchCacheInner (satcat5::eth::SwitchCore *sw, CacheEntry *array, unsigned size)
 Constructor accepts a child-allocated array for the cache.
 
SATCAT5_PMASK_TYPE destination_mask (const PluginPacket &pkt)
 Destination MAC-address lookup.
 

Protected Attributes

bool m_learn
 
SATCAT5_PMASK_TYPE m_miss_mask
 
CacheEntry *const m_array
 
const unsigned m_size
 
satcat5::util::LruCache< CacheEntrym_cache
 

Private Attributes

satcat5::eth::SwitchCore *const m_switch
 Pointer to the associated SwitchCore object.
 
satcat5::eth::PluginCorem_next
 

Member Function Documentation

◆ get_miss_mask()

SATCAT5_PMASK_TYPE satcat5::eth::SwitchCacheInner::get_miss_mask ( ) const
inline

Identify which ports are currently in "miss-as-broadcast" mode.

For format description,

See also
set_miss_mask.

Definition at line 45 of file eth_sw_cache.h.

◆ mactbl_clear()

bool satcat5::eth::SwitchCacheInner::mactbl_clear ( )
inline

Read or manipulate the contents of the MAC-address table.

All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)

Definition at line 61 of file eth_sw_cache.h.

◆ mactbl_learn() [1/2]

bool satcat5::eth::SwitchCacheInner::mactbl_learn ( ) const
inline

Read or manipulate the contents of the MAC-address table.

All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)

Definition at line 65 of file eth_sw_cache.h.

◆ mactbl_learn() [2/2]

bool satcat5::eth::SwitchCacheInner::mactbl_learn ( bool  enable)
inline

Read or manipulate the contents of the MAC-address table.

All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)

Definition at line 63 of file eth_sw_cache.h.

◆ mactbl_read()

bool SwitchCacheInner::mactbl_read ( unsigned  tbl_idx,
unsigned &  port_idx,
satcat5::eth::MacAddr mac_addr 
)

Read or manipulate the contents of the MAC-address table.

All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)

Definition at line 60 of file eth_sw_cache.cc.

◆ mactbl_size()

unsigned satcat5::eth::SwitchCacheInner::mactbl_size ( ) const
inline

Read or manipulate the contents of the MAC-address table.

All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)

Definition at line 52 of file eth_sw_cache.h.

◆ mactbl_write()

bool SwitchCacheInner::mactbl_write ( unsigned  port_idx,
const satcat5::eth::MacAddr mac_addr 
)

Read or manipulate the contents of the MAC-address table.

All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)

Definition at line 67 of file eth_sw_cache.cc.

◆ set_miss_bcast()

void SwitchCacheInner::set_miss_bcast ( unsigned  port_idx,
bool  enable 
)

Enable or disable "miss-as-broadcast" flag for a specific port.

Frames with an unknown destination (i.e., destination MAC not found in cache) are sent to every port with this flag. This method sets the configuration for the specified port index.

Definition at line 55 of file eth_sw_cache.cc.

◆ set_miss_mask()

void satcat5::eth::SwitchCacheInner::set_miss_mask ( SATCAT5_PMASK_TYPE  mask)
inline

Enable or disable "miss-as-broadcast" flag for all ports.

Frames with an unknown destination (i.e., destination MAC not found in cache) are sent to every port with this flag. This method sets all ports in a single call.

See also
set_miss_bcast.

Definition at line 40 of file eth_sw_cache.h.


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