SatCat5
satcat5::router2::Offload Class Reference

Detailed Description

Offload port for gateware-accelerated IPv4 routers.

When the router2::Dispatch class is used in conjunction with the VHDL "router2_core" block, the VHDL handles bulk traffic for gateware-defined ports but offloads complex edge-cases to the software. This block acts as the gateware/software bridge for that offload function.

Definition at line 31 of file router2_offload.h.

#include <router2_offload.h>

Inheritance diagram for satcat5::router2::Offload:
[legend]
Collaboration diagram for satcat5::router2::Offload:
[legend]

Classes

struct  ctrl_reg
 

Public Member Functions

 Offload (satcat5::cfg::ConfigBusMmap *cfg, unsigned devaddr, satcat5::router2::Dispatch *router, unsigned hw_ports)
 Constructor sets the number of associated hardware ports. More...
 
void rule_allow (u32 mask)
 Set specific router policy flags.
 
void rule_block (u32 mask)
 Clear specific router policy flags.
 
void rule_zpad (bool enable)
 Enable or disable zero-padding.
 
void deliver (const satcat5::eth::PluginPacket &meta)
 Deliver a given packet to the hardware queue.
 
satcat5::cfg::Register get_log_register () const
 Get packet-logging register. More...
 
u32 reconfigure ()
 Reload router IP address and MAC address. More...
 
u32 link_shdn_hw ()
 Mask indicating hardware-defined ports in the shutdown state.
 
SATCAT5_PMASK_TYPE link_shdn_sw ()
 Mask indicating software-defined ports in the shutdown state.
 
unsigned port_index (unsigned hw_idx) const
 Convert hardware port index to a software port-index.
 
SATCAT5_PMASK_TYPE port_mask (unsigned hw_idx) const
 Convert hardware port index to a software port-mask.
 
SATCAT5_PMASK_TYPE port_mask_all () const
 Return a port-mask containing all connected ports.
 

Protected Member Functions

void irq_event () override
 Interrupt service routine. More...
 
void irq_check ()
 Check if this interrupt may need service. More...
 
void irq_enable ()
 Enable this interrupt. More...
 
void irq_disable ()
 Temporarily disable this interrupt. More...
 
void set_max_packet (unsigned max_bytes)
 Update the maximum allowed packet length. More...
 
void set_priority (u16 priority)
 Set priority of the current packet. More...
 
void set_timeout (unsigned timeout_msec)
 Update the watchdog timeout. More...
 
unsigned get_write_partial () const
 Get current write length.
 
unsigned get_write_space () const override
 How many bytes can be written without blocking? More...
 
void write_bytes (unsigned nbytes, const void *src) override
 Write 0 or more bytes from a buffer. More...
 
void write_abort () override
 If possible, abort the current partially-written packet. More...
 
bool write_finalize () override
 Mark end of frame and release temporary working data. More...
 
bool write_bypass (satcat5::io::MultiReader *dst)
 Deliver data directly to the designated MultiReader. More...
 
void timer_event () override
 Timeouts help prevent resource-hogging.
 
void write_next (u8 data) override
 Write the next byte to the underlying buffer or device. More...
 
void write_overflow () override
 Optional error handling for write overflow. More...
 
unsigned write_prep ()
 Open a new packet or allocate additional buffers. More...
 
satcat5::io::MultiPacketprepare_pkt ()
 Prepare packet for delivery and reset internal state.
 
void write_u8 (u8 data)
 One of many functions for writing integer/floating point values, see details. More...
 
void write_str (const char *str)
 Write the contents of a null-terminated string. More...
 
template<class T >
void write_obj (const T &obj)
 Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr) const;
 
void timer_once (unsigned msec)
 Configure a one-time notification after X milliseconds.
 
void timer_every (unsigned msec)
 Configure a repeating notification every X milliseconds.
 
void timer_stop ()
 Stop all future notifications.
 
unsigned timer_interval () const
 Accessor for recurring timer interval, if one is set.
 
unsigned timer_remaining () const
 Accessor for time to next event, if one is set.
 

Static Protected Member Functions

static unsigned count_timer ()
 Count all objects of this type, including idle timers.
 

Protected Attributes

ctrl_reg *const m_ctrl
 
satcat5::router2::Dispatch *const m_router
 
satcat5::cfg::Register m_pktlog
 
const unsigned m_port_index
 
bool m_zero_pad
 
SATCAT5_PMASK_TYPE m_port_mask
 
u32 m_policy
 
satcat5::io::MultiBuffer *const m_dst
 Pointer to the destination buffer.
 
friend LimitedWrite
 
friend WriteableBroadcast
 
friend WriteableRedirect
 
satcat5::io::MultiPacketm_write_pkt
 Current write state.
 
satcat5::io::MultiChunkm_write_tail
 Current write state.
 
unsigned m_write_pos
 Current write state.
 
unsigned m_write_len
 Current write state.
 
unsigned m_write_maxlen
 Current write state.
 
unsigned m_write_timeout
 Current write state.
 

Private Member Functions

void query (unsigned elapsed_msec)
 

Private Attributes

satcat5::cfg::ConfigBus *const m_cfg
 
satcat5::cfg::Interruptm_next
 
unsigned m_trem
 
unsigned m_tnext
 

Constructor & Destructor Documentation

◆ Offload()

Offload::Offload ( satcat5::cfg::ConfigBusMmap cfg,
unsigned  devaddr,
satcat5::router2::Dispatch router,
unsigned  hw_ports 
)

Constructor sets the number of associated hardware ports.

Always create this object BEFORE registering software ports.

Definition at line 21 of file router2_offload.cc.

Member Function Documentation

◆ get_log_register()

satcat5::cfg::Register satcat5::router2::Offload::get_log_register ( ) const
inline

Get packet-logging register.

See also
eth_sw_log.h. Do not call this method unless LOG_CFGBUS is enabled.

Definition at line 56 of file router2_offload.h.

◆ get_write_space()

unsigned MultiWriter::get_write_space ( ) const
overridevirtualinherited

How many bytes can be written without blocking?

Child objects of io::Writeable MUST override this method.

Implements satcat5::io::Writeable.

Definition at line 465 of file multi_buffer.cc.

◆ irq_check()

void Interrupt::irq_check ( )
inherited

Check if this interrupt may need service.

If the interrupt needs service, this calls irq_event.

Definition at line 46 of file cfgbus_interrupt.cc.

◆ irq_disable()

void Interrupt::irq_disable ( )
inherited

Temporarily disable this interrupt.

Interrupts are enabled by default, but some peripherals may wish to temporary toggle this setting. For use with standard "cfgbus_interrupt" only.

Definition at line 63 of file cfgbus_interrupt.cc.

◆ irq_enable()

void Interrupt::irq_enable ( )
inherited

Enable this interrupt.

Interrupts are enabled by default, but some peripherals may wish to temporary toggle this setting. For use with standard "cfgbus_interrupt" only.

Definition at line 58 of file cfgbus_interrupt.cc.

◆ irq_event()

void Offload::irq_event ( )
overrideprotectedvirtual

Interrupt service routine.

(Child class must override this method.)

Implements satcat5::cfg::Interrupt.

Definition at line 103 of file router2_offload.cc.

◆ reconfigure()

u32 Offload::reconfigure ( )

Reload router IP address and MAC address.

The router2::Dispatch class calls this after any address change. Return value is for internal use only and should be ignored.

Definition at line 132 of file router2_offload.cc.

◆ set_max_packet()

void satcat5::io::MultiWriter::set_max_packet ( unsigned  max_bytes)
inlineinherited

Update the maximum allowed packet length.

(Longer packets are terminated to avoid resource hogging.)

Definition at line 413 of file multi_buffer.h.

◆ set_priority()

void MultiWriter::set_priority ( u16  priority)
inherited

Set priority of the current packet.

Call this method after writing data, but before calling write_finalize or write_bypass. Priority affects readout order for recipient(s) using the MultiReaderPriority class.

Definition at line 461 of file multi_buffer.cc.

◆ set_timeout()

void satcat5::io::MultiWriter::set_timeout ( unsigned  timeout_msec)
inlineinherited

Update the watchdog timeout.

The watchdog is reset each time a byte is written; if a partial packet is not finalized or aborted within the time limit, then it is dicarded.

Definition at line 425 of file multi_buffer.h.

◆ write_abort()

void MultiWriter::write_abort ( )
overridevirtualinherited

If possible, abort the current partially-written packet.

Child objects of io::Writeable SHOULD override this method if it is practical to prevent in-progress data from being relayed downstream.

Reimplemented from satcat5::io::Writeable.

Definition at line 504 of file multi_buffer.cc.

◆ write_bypass()

bool MultiWriter::write_bypass ( satcat5::io::MultiReader dst)
inherited

Deliver data directly to the designated MultiReader.

The write_finalize method delivers the current packet to the MultiBuffer, which then decides which port(s) should receive that packet.

See also
MultiBuffer::deliver

This alternative method delivers the packet directly to the designated MultiReader, bypassing MultiBuffer delivery logic.

Definition at line 521 of file multi_buffer.cc.

◆ write_bytes()

void MultiWriter::write_bytes ( unsigned  nbytes,
const void *  src 
)
overridevirtualinherited

Write 0 or more bytes from a buffer.

Child objects of io::Writeable MAY override write_bytes as needed for performance.

Reimplemented from satcat5::io::Writeable.

Definition at line 474 of file multi_buffer.cc.

◆ write_finalize()

bool MultiWriter::write_finalize ( )
overridevirtualinherited

Mark end of frame and release temporary working data.

Child objects of io::Writeable SHOULD override this method to mark frame bounds.

Returns
True if successful, false on error.

Reimplemented from satcat5::io::Writeable.

Reimplemented in satcat5::io::MultiWriterBypass.

Definition at line 514 of file multi_buffer.cc.

◆ write_next()

void MultiWriter::write_next ( u8  data)
overrideprotectedvirtualinherited

Write the next byte to the underlying buffer or device.

Child objects of io::Writeable MUST override this method.

Implements satcat5::io::Writeable.

Definition at line 531 of file multi_buffer.cc.

◆ write_overflow()

void MultiWriter::write_overflow ( )
overrideprotectedvirtualinherited

Optional error handling for write overflow.

Child objects of io::Writeable MAY override this method for error handling.

Reimplemented from satcat5::io::Writeable.

Definition at line 547 of file multi_buffer.cc.

◆ write_prep()

unsigned MultiWriter::write_prep ( )
protectedinherited

Open a new packet or allocate additional buffers.

Returns
The number of bytes that can be written.

Definition at line 558 of file multi_buffer.cc.

◆ write_str()

void Writeable::write_str ( const char *  str)
inherited

Write the contents of a null-terminated string.

Note: Null-termination is not copied to the output.

Definition at line 180 of file io_writeable.cc.

◆ write_u8()

void Writeable::write_u8 ( u8  data)
inherited

One of many functions for writing integer/floating point values, see details.

Several functions are provided for reading and writing scalar types to/from io::Readable and io::Writeable instances. Since there are many of these that are frequently inherited, they are hidden from documentation. These functions follow a shared template:

  • read_ or write_ prefix.
  • u for unsigned, s for signed, f for floating-point.
  • Data-type width in bits.
    • Available widths for ints: 8/16/24/32/48/64.
    • Available widths for floats: 32/64.
  • l suffix if little-endian, no suffix if big-endian.

Example: write_s48l is "Write 48 bits (6 bytes) to this io::Writeable as a signed value in little-endian order".

Definition at line 20 of file io_writeable.cc.


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