SatCat5
satcat5::eth::SwitchConfig Class Reference

Detailed Description

Management functions for a SatCat5 Ethernet switch.

Definition at line 166 of file switch_cfg.h.

#include <switch_cfg.h>

Collaboration diagram for satcat5::eth::SwitchConfig:
[legend]

Public Member Functions

 SwitchConfig (satcat5::cfg::ConfigBus *cfg, unsigned devaddr)
 Attach to the designated ConfigBus address.
 
void log_info (const char *label)
 Log some basic info about this switch.
 
u32 port_count ()
 Number of ports on this switch.
 
void priority_reset ()
 Clear all EtherType-based priority settings.
 
bool priority_set (u16 etype, unsigned plen=16)
 Designate specific EtherType range(s) as high-priority. More...
 
void set_miss_bcast (unsigned port_idx, bool enable)
 Enable or disable "miss-as-broadcast" flag on the specified port. More...
 
void set_miss_mask (u32 mask)
 Enable or disable all "miss-as-broadcast" flags at once.
 
u32 get_miss_mask ()
 Identify which ports are currently in "miss-as-broadcast" mode.
 
void set_promiscuous (unsigned port_idx, bool enable)
 Enable or disable "promiscuous" flag on the specified port index. More...
 
void set_promiscuous_mask (u32 mask)
 Set the "promiscuous" flag for all ports at once.
 
u32 get_promiscuous_mask ()
 Identify which ports are currently promiscuous.
 
void set_traffic_filter (u16 etype=0)
 Set EtherType filter for traffic reporting. (0 = Any type)
 
u16 get_traffic_filter () const
 Query the current traffic filter setting.
 
u32 get_traffic_count ()
 Report matching frames since last call to get_traffic_count().
 
u16 get_frame_min ()
 Get the minimum allowed frame size, in bytes.
 
u16 get_frame_max ()
 Get the maximum allowed frame size, in bytes.
 
satcat5::cfg::Register get_log_register ()
 Get packet-logging register. More...
 
void vlan_reset (bool lockdown=false)
 Revert all VLAN settings to default.
 
u32 vlan_get_mask (u16 vid)
 Get connected port-mask for the designated VLAN.
 
void vlan_set_mask (u16 vid, u32 mask)
 Set connected port-mask for the designated VLAN.
 
void vlan_set_port (const VtagPolicy &cfg)
 Set tag policy and other per-port settings.
 
void vlan_join (u16 vid, unsigned port)
 Join a given port to the designated VLAN.
 
void vlan_leave (u16 vid, unsigned port)
 Remote a given port from the designated VLAN.
 
void vlan_set_rate (u16 vid, const satcat5::eth::VlanRate &cfg)
 Set the maximum aggregated throughput for a given VID.
 
unsigned mactbl_size ()
 Read the maximum size of the MAC-address table.
 
bool mactbl_read (unsigned tbl_idx, unsigned &port_idx, satcat5::eth::MacAddr &mac_addr)
 Read the Nth entry from the MAC-address table. More...
 
bool mactbl_write (unsigned port_idx, const satcat5::eth::MacAddr &mac_addr)
 Write a new entry to the MAC-address table. More...
 
bool mactbl_clear ()
 Clear MAC-address table contents.
 
bool mactbl_learn (bool enable)
 Enable automatic learning of new MAC addresses?
 
void mactbl_log (const char *label)
 Log the contents of the MAC-address table.
 
s32 ptp_get_offset_rx (unsigned port_idx)
 PTP configuration for each port. More...
 
s32 ptp_get_offset_tx (unsigned port_idx)
 PTP configuration for each port. More...
 
u32 ptp_get_2step_mask ()
 PTP configuration for each port. More...
 
void ptp_set_offset_rx (unsigned port_idx, s32 subns)
 PTP configuration for each port. More...
 
void ptp_set_offset_tx (unsigned port_idx, s32 subns)
 PTP configuration for each port. More...
 
void ptp_set_2step (unsigned port_idx, bool enable)
 PTP configuration for each port. More...
 

Static Public Member Functions

static constexpr unsigned REG_PORT (unsigned idx)
 Base address for per-port registers.
 
static constexpr unsigned REG_PTP_RX (unsigned idx)
 Rx timestamp offset for Nth port.
 
static constexpr unsigned REG_PTP_TX (unsigned idx)
 Tx timestamp offset for Nth port.
 

Static Public Attributes

static constexpr unsigned REG_PORTCOUNT = 0
 Number of ports (read-only)
 
static constexpr unsigned REG_DATAPATH = 1
 Datapath width, in bits (read-only)
 
static constexpr unsigned REG_CORECLOCK = 2
 Core clock frequency, in Hz (read-only)
 
static constexpr unsigned REG_MACCOUNT = 3
 MAC-address table size (read-only)
 
static constexpr unsigned REG_PROMISC = 4
 Promisicuous port mask (read-write)
 
static constexpr unsigned REG_PRIORITY = 5
 Packet prioritization (read-write, optional)
 
static constexpr unsigned REG_PKTCOUNT = 6
 Packet-counting w/ filter (read-write)
 
static constexpr unsigned REG_FRAMESIZE = 7
 Frame size limits (read-only)
 
static constexpr unsigned REG_VLAN_PORT = 8
 VLAN port configuration (write-only)
 
static constexpr unsigned REG_VLAN_VID = 9
 VLAN connections: set VID (read-write)
 
static constexpr unsigned REG_VLAN_MASK = 10
 VLAN connections: set mask (read-write)
 
static constexpr unsigned REG_MACTBL_LSB = 11
 MAC-table control (read-write)
 
static constexpr unsigned REG_MACTBL_MSB = 12
 MAC-table control (read-write)
 
static constexpr unsigned REG_MACTBL_CTRL = 13
 MAC-table control (read-write)
 
static constexpr unsigned REG_MISS_BCAST = 14
 Miss-as-broadcast port mask (read-write)
 
static constexpr unsigned REG_PTP_2STEP = 15
 PTP "twoStep" mode flag (read-write)
 
static constexpr unsigned REG_VLAN_RATE = 16
 VLAN rate-control configuration (write-only)
 
static constexpr unsigned REG_LOGGING = 17
 Packet logging diagnostics (read-only)
 

Protected Member Functions

bool mactbl_wait_idle ()
 Wait for MAC-table access.
 

Protected Attributes

satcat5::cfg::Register m_reg
 ConfigBus register space.
 
u32 m_pri_wridx
 Next index in priority table.
 
u16 m_stats_filter
 Filter stats by EtherType.
 

Member Function Documentation

◆ get_log_register()

satcat5::cfg::Register SwitchConfig::get_log_register ( )

Get packet-logging register.

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

Definition at line 134 of file switch_cfg.cc.

◆ mactbl_read()

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

Read the Nth entry from the MAC-address table.

  • tbl_idx Table index to be read
  • port_idx Resulting port index (output)
  • mac_addr Resulting MAC address (output)
    Returns
    True if successful, false otherwise.

Definition at line 232 of file switch_cfg.cc.

◆ mactbl_write()

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

Write a new entry to the MAC-address table.

Note: When writing, FPGA logic chooses the next available table index; this parameter is not under software control.

  • port_idx Port index for the new MAC address
  • mac_addr New MAC address
    Returns
    True if write successful, false otherwise.

Definition at line 257 of file switch_cfg.cc.

◆ priority_set()

bool SwitchConfig::priority_set ( u16  etype,
unsigned  plen = 16 
)

Designate specific EtherType range(s) as high-priority.

Each range is specified with a CIDR-style prefix-length:

  • 0x1234/16 = EtherType 0x1234 only
  • 0x1230/12 = EtherType 0x1230 through 0x123F

Definition at line 59 of file switch_cfg.cc.

◆ ptp_get_2step_mask()

u32 SwitchConfig::ptp_get_2step_mask ( )

PTP configuration for each port.

Time units are in sub-nanoseconds (see ptp_time.h)

Definition at line 146 of file switch_cfg.cc.

◆ ptp_get_offset_rx()

s32 SwitchConfig::ptp_get_offset_rx ( unsigned  port_idx)

PTP configuration for each port.

Time units are in sub-nanoseconds (see ptp_time.h)

Definition at line 138 of file switch_cfg.cc.

◆ ptp_get_offset_tx()

s32 SwitchConfig::ptp_get_offset_tx ( unsigned  port_idx)

PTP configuration for each port.

Time units are in sub-nanoseconds (see ptp_time.h)

Definition at line 142 of file switch_cfg.cc.

◆ ptp_set_2step()

void SwitchConfig::ptp_set_2step ( unsigned  port_idx,
bool  enable 
)

PTP configuration for each port.

Time units are in sub-nanoseconds (see ptp_time.h)

Definition at line 158 of file switch_cfg.cc.

◆ ptp_set_offset_rx()

void SwitchConfig::ptp_set_offset_rx ( unsigned  port_idx,
s32  subns 
)

PTP configuration for each port.

Time units are in sub-nanoseconds (see ptp_time.h)

Definition at line 150 of file switch_cfg.cc.

◆ ptp_set_offset_tx()

void SwitchConfig::ptp_set_offset_tx ( unsigned  port_idx,
s32  subns 
)

PTP configuration for each port.

Time units are in sub-nanoseconds (see ptp_time.h)

Definition at line 154 of file switch_cfg.cc.

◆ set_miss_bcast()

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

Enable or disable "miss-as-broadcast" flag on the specified port.

Frames with an unknown destination (i.e., destination MAC not found in cache) are sent to every port with this flag.

Definition at line 80 of file switch_cfg.cc.

◆ set_promiscuous()

void SwitchConfig::set_promiscuous ( unsigned  port_idx,
bool  enable 
)

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 desitnation address.

Definition at line 95 of file switch_cfg.cc.


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