SatCat5
satcat5::eth::SwitchCoreStatic< BSIZE > Class Template Reference

Detailed Description

template<unsigned BSIZE = 65536>
class satcat5::eth::SwitchCoreStatic< BSIZE >

Wrapper for SwitchCore with a statically-allocated working buffer.

Definition at line 203 of file eth_switch.h.

#include <eth_switch.h>

Inheritance diagram for satcat5::eth::SwitchCoreStatic< BSIZE >:
[legend]
Collaboration diagram for satcat5::eth::SwitchCoreStatic< BSIZE >:
[legend]

Public Member Functions

satcat5::eth::SwitchPortget_port (unsigned idx)
 Fetch a SwitchPort object by port-index. More...
 
SATCAT5_PMASK_TYPE next_port_mask ()
 Get next available bit-mask for new SwitchPort objects. More...
 
u32 port_count () const
 Get the number of attached ports.
 
void set_debug (satcat5::io::Writeable *debug)
 Optional debug interface gets a carbon copy of each packet.
 
void add_log (satcat5::eth::SwitchLogHandler *log)
 Optional logging interface records a summary of every packet. More...
 
void remove_log (satcat5::eth::SwitchLogHandler *log)
 
void set_promiscuous (unsigned port_idx, bool enable)
 Enable or disable "promiscuous" flag on the specified port index. More...
 
void set_promiscuous_mask (SATCAT5_PMASK_TYPE mask)
 Enable or disable "promiscuous" flag for all ports at once.
 
SATCAT5_PMASK_TYPE get_promiscuous_mask () const
 Return a bit-mask identifying all "promiscuous" ports.
 
void set_traffic_filter (u16 etype=0)
 Configure EtherType filter for traffic reporting. (0 = Any type)
 
u16 get_traffic_filter () const
 Return the current filter configuration. (0 = Any type)
 
u32 get_traffic_count ()
 Query traffic statistics Count received frames that match the current traffic filter, starting from the previous call to get_traffic_count(). More...
 
void debug_if (const satcat5::eth::PluginPacket &pkt, unsigned mask) const
 Carbon-copy a packet to the debug port, if it is enabled. More...
 
void debug_log (const satcat5::io::MultiPacket *pkt, u8 reason, SATCAT5_PMASK_TYPE dst=0) const
 If logging is enabled, record the outcome for this packet.
 
bool consistency () const
 Internal consistency self-test (Optional).
 
unsigned get_free_bytes () const
 Query remaining buffer capacity.
 
u16 get_pcount ()
 Current value of the packet counter.
 
bool enqueue (satcat5::io::MultiPacket *packet)
 Queue an incoming packet for deferred processing. More...
 
void free_packet (satcat5::io::MultiPacket *packet)
 Immediately free memory associated with this packet. More...
 

Protected Member Functions

unsigned deliver (satcat5::io::MultiPacket *packet) override
 Override the MultiBuffer::deliver() method.
 
satcat5::io::MultiPacketdequeue ()
 Event handler for deferred packet delivery.
 
void poll_demand () override
 Deferred event handler, called after request(). More...
 
void request_poll ()
 Call this method to request polling at a later time. More...
 
void request_cancel ()
 Call this method to cancel a previous request_poll().
 
void process_stats (const satcat5::eth::PluginPacket &pkt)
 Internal event-handlers called from deliver(...).
 
satcat5::util::optional< unsigned > process_plugins (satcat5::eth::PluginPacket &pkt)
 Internal event-handlers called from deliver(...).
 
satcat5::util::optional< unsigned > pkt_has_dropped (satcat5::eth::PluginPacket &pkt, unsigned mask)
 Internal event-handlers called from deliver(...).
 
unsigned deliver_switch (const satcat5::eth::PluginPacket &pkt)
 Internal event-handlers called from deliver(...).
 
void plugin_add (satcat5::eth::PluginCore *plugin)
 
void plugin_remove (satcat5::eth::PluginCore *plugin)
 
void port_add (satcat5::eth::SwitchPort *port)
 
void port_remove (satcat5::eth::SwitchPort *port)
 
void port_remove (const SATCAT5_PMASK_TYPE &mask)
 
satcat5::io::MultiChunknew_chunk ()
 Memory allocation.
 
satcat5::io::MultiPacketnew_packet ()
 Memory allocation.
 

Static Protected Member Functions

static unsigned count_ondemand ()
 Count queued objects of this type (i.e., non-idle).
 

Protected Attributes

u8 m_buff [BSIZE]
 
satcat5::util::List< satcat5::eth::PluginCorem_plugins
 Linked list of attached plugins.
 
satcat5::util::List< satcat5::eth::SwitchPortm_ports
 Linked list of attached Ethernet ports.
 
satcat5::io::Writeablem_debug
 
satcat5::util::List< satcat5::eth::SwitchLogHandlerm_pktlogs
 
SATCAT5_PMASK_TYPE m_free_pmask
 
SATCAT5_PMASK_TYPE m_prom_mask
 
u16 m_stats_filter
 
u32 m_stats_count
 
unsigned m_free_bytes
 
u16 m_pcount
 
satcat5::util::List< satcat5::io::MultiChunkm_free_chunks
 
satcat5::util::List< satcat5::io::MultiReaderm_read_ports
 
satcat5::util::List< satcat5::io::MultiPacketm_rcvd_packets
 

Private Attributes

satcat5::poll::OnDemandm_next
 
bool m_idle
 

Member Function Documentation

◆ add_log()

void satcat5::eth::SwitchCore::add_log ( satcat5::eth::SwitchLogHandler log)
inlineinherited

Optional logging interface records a summary of every packet.

Function and formatting are the same as "mac_log_core.vhd".

Definition at line 119 of file eth_switch.h.

◆ debug_if()

void SwitchCore::debug_if ( const satcat5::eth::PluginPacket pkt,
unsigned  mask 
) const
inherited

Carbon-copy a packet to the debug port, if it is enabled.

Reserved for use by SwitchCore, SwitchPort, or their children.

Definition at line 135 of file eth_switch.cc.

◆ enqueue()

bool MultiBuffer::enqueue ( satcat5::io::MultiPacket packet)
inherited

Queue an incoming packet for deferred processing.

Note: This method SHOULD only be called from MultiWriter or its children. This method is public only for to allow flexibility in mutual "friend" inheritance rules.

Definition at line 176 of file multi_buffer.cc.

◆ free_packet()

void MultiBuffer::free_packet ( satcat5::io::MultiPacket packet)
inherited

Immediately free memory associated with this packet.

This is usually called by MultiReader::read_finalize().

Definition at line 243 of file multi_buffer.cc.

◆ get_port()

satcat5::eth::SwitchPort* satcat5::eth::SwitchCore::get_port ( unsigned  idx)
inlineinherited

Fetch a SwitchPort object by port-index.

Ports are numbered in the order they are created.

See also
port_add. The maximum number of ports is given by eth::PMASK_SIZE.

Definition at line 101 of file eth_switch.h.

◆ get_traffic_count()

u32 SwitchCore::get_traffic_count ( )
inherited

Query traffic statistics Count received frames that match the current traffic filter, starting from the previous call to get_traffic_count().

Returns
the number of matching frames.

Definition at line 104 of file eth_switch.cc.

◆ next_port_mask()

SATCAT5_PMASK_TYPE SwitchCore::next_port_mask ( )
inherited

Get next available bit-mask for new SwitchPort objects.

Most SwitchPort objects are one-to-one, but some represent multiple; call "next_port_mask()" once for each logical port.

Definition at line 66 of file eth_switch.cc.

◆ poll_demand()

void MultiBuffer::poll_demand ( )
overrideprotectedvirtualinherited

Deferred event handler, called after request().

Child class MUST override this method. (Call "request_poll" to enqueue a callback to this method.)

Implements satcat5::poll::OnDemand.

Definition at line 195 of file multi_buffer.cc.

◆ request_poll()

void satcat5::poll::OnDemand::request_poll ( )
inherited

Call this method to request polling at a later time.

Safe to stack requests, but only one call to poll().

Definition at line 208 of file polling.cc.

◆ set_promiscuous()

void SwitchCore::set_promiscuous ( unsigned  port_idx,
bool  enable 
)
inherited

Enable or disable "promiscuous" flag on the specified port index.

For as long as the flag is set, those port(s) will receive ALL switch traffic regardless of the destination address, etc.

Definition at line 94 of file eth_switch.cc.


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