SatCat5
eth_sw_log.cc
1 // Copyright 2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
6 #include <satcat5/cfgbus_stats.h>
7 #include <satcat5/datetime.h>
8 #include <satcat5/eth_sw_log.h>
9 #include <satcat5/log.h>
10 #include <satcat5/udp_dispatch.h>
11 
21 using satcat5::net::Type;
22 
23 // Explicit re-declaration of class-local constants.
24 // (Workaround for linker errors in some versions of GCC.)
25 constexpr u8 SwitchLogMessage::REASON_KEEP;
26 constexpr u8 SwitchLogMessage::DROP_OVERFLOW;
27 constexpr u8 SwitchLogMessage::DROP_BADFCS;
28 constexpr u8 SwitchLogMessage::DROP_BADFRM;
29 constexpr u8 SwitchLogMessage::DROP_MCTRL;
30 constexpr u8 SwitchLogMessage::DROP_VLAN;
31 constexpr u8 SwitchLogMessage::DROP_VRATE;
32 constexpr u8 SwitchLogMessage::DROP_PTPERR;
33 constexpr u8 SwitchLogMessage::DROP_NO_ROUTE;
34 constexpr u8 SwitchLogMessage::DROP_DISABLED;
35 constexpr u8 SwitchLogMessage::DROP_UNKNOWN;
36 
37 u8 SwitchLogMessage::reason() const {
38  switch (type()) {
39  case TYPE_KEEP: return REASON_KEEP;
40  case TYPE_DROP: return u8(meta & 0xFF);
41  default: return DROP_UNKNOWN;
42  }
43 }
44 
45 const char* SwitchLogMessage::reason_str() const {
46  switch (reason()) {
47  case REASON_KEEP: return "N/A";
48  case DROP_OVERFLOW: return "Overflow";
49  case DROP_BADFCS: return "Bad CRC";
50  case DROP_BADFRM: return "Bad header";
51  case DROP_MCTRL: return "Link-local";
52  case DROP_VLAN: return "VLAN policy";
53  case DROP_VRATE: return "Rate-limit";
54  case DROP_PTPERR: return "PTP error";
55  case DROP_NO_ROUTE: return "No route";
56  case DROP_DISABLED: return "Port off";
57  default: return "Unknown";
58  }
59 }
60 
62  if (type() == TYPE_KEEP) return 0; // KEEP message
63  if (type() == TYPE_DROP) return 1; // DROP message
64  return u16(meta >> 16); // SKIP message
65 }
66 
68  if (type() == TYPE_KEEP) return 1; // KEEP message
69  if (type() == TYPE_DROP) return 0; // DROP message
70  return u16(meta & 0xFFFF); // SKIP message
71 }
72 
73 void SwitchLogMessage::init_keep(const Header& _hdr, u8 _src, u32 _dst) {
74  tstamp = satcat5::datetime::clock.uptime_usec();
75  type_src = TYPE_KEEP | (SRC_MASK & _src);
76  hdr = _hdr;
77  meta = _dst;
78 }
79 
80 void SwitchLogMessage::init_drop(const Header& _hdr, u8 _src, u8 _why) {
81  tstamp = satcat5::datetime::clock.uptime_usec();
82  type_src = TYPE_DROP | (SRC_MASK & _src);
83  hdr = _hdr;
84  meta = u32(_why);
85 }
86 
87 void SwitchLogMessage::init_skip(u16 _drop, u16 _keep) {
88  tstamp = satcat5::datetime::clock.uptime_usec();
90  hdr = HEADER_NULL;
91  meta = (u32(_drop) << 16) | u32(_keep);
92 }
93 
95  if (type() == TYPE_KEEP) {
96  wr.wr_str("\r\n Delivered to: 0x");
97  wr.wr_h32(meta);
98  hdr.log_to(wr);
99  } else if (type() == TYPE_DROP) {
100  wr.wr_str("\r\n Dropped: ");
101  wr.wr_str(reason_str());
102  hdr.log_to(wr);
103  } else if (type() == TYPE_SKIP) {
104  wr.wr_str("\r\n Summary: ");
105  wr.wr_d32(count_keep());
106  wr.wr_str(" delivered, ");
107  wr.wr_d32(count_drop());
108  wr.wr_str(" dropped.");
109  }
110 }
111 
113  wr->write_u24(tstamp);
114  wr->write_u8(type_src);
115  hdr.dst.write_to(wr); // Write full header even if no VTAG.
116  hdr.src.write_to(wr);
117  hdr.type.write_to(wr);
118  hdr.vtag.write_to(wr);
119  wr->write_u32(meta);
120 }
121 
123  if (rd->get_read_ready() < LEN_BYTES) return false;
124  tstamp = rd->read_u24();
125  type_src = rd->read_u8();
126  hdr.dst.read_from(rd); // Read full header even if no VTAG.
127  hdr.src.read_from(rd);
128  hdr.type.read_from(rd);
129  hdr.vtag.read_from(rd);
130  meta = rd->read_u32();
131  return true;
132 }
133 
136  : m_dst(dst)
137  , m_src(src)
138 {
139  // No interrupts, just poll at regular intervals.
140  if (m_dst) timer_every(25);
141 }
142 
144  static constexpr u32 DATA_VALID = (1u << 31);
145  static constexpr u32 DATA_FINAL = (1u << 30);
146 
147  // Poll the ConfigBus register...
148  u32 reg = *m_src;
149  while (reg & DATA_VALID) {
150  // Each data word is copied to the working buffer.
151  m_buff.write_u24(reg);
152  if (reg & DATA_FINAL) {
153  // Final word attempts to parse the message descriptor.
154  m_buff.write_finalize();
155  satcat5::io::ArrayRead rd(m_buff.buffer(), m_buff.written_len());
156  SwitchLogMessage pkt;
157  if (pkt.read_from(&rd)) m_dst->log_packet(pkt);
158  }
159  // Keep reading until FIFO is empty.
160  reg = *m_src;
161  }
162 }
163 
165  // Is there room in the output buffer?
166  bool can_write = (m_dst->get_write_space() >= SwitchLogMessage::LEN_BYTES);
167 
168  // Have we already entered skip/summary mode?
169  bool skip_mode = m_skip_drop || m_skip_keep;
170 
171  // Are we able to write an individual packet?
172  if (can_write && !skip_mode) {
173  // Forward the message descriptor as-is.
174  msg.write_to(m_dst);
175  m_dst->write_finalize();
176  } else {
177  // Increment applicable summary counter(s).
178  m_skip_drop += msg.count_drop();
179  m_skip_keep += msg.count_keep();
180  // Write the summary now or later?
181  if (can_write) timer_event();
182  else timer_every(50);
183  }
184 }
185 
187  // If the destination is full, try again later.
188  if (m_dst->get_write_space() < SwitchLogMessage::LEN_BYTES) return;
189  // Format the SKIP message.
190  SwitchLogMessage msg;
191  msg.init_skip(m_skip_drop, m_skip_keep);
192  msg.write_to(m_dst);
193  // Reset state once it's sent successfully.
194  if (m_dst->write_finalize()) {
195  m_skip_drop = 0;
196  m_skip_keep = 0;
197  timer_stop();
198  }
199 }
200 
201 static constexpr SwitchLogStats::TrafficStats STATS_ZERO = {};
202 
204  : m_stats(buff)
205  , m_size(size)
206 {
207  for (unsigned a = 0 ; a < m_size ; ++a)
208  m_stats[a] = STATS_ZERO;
209 }
210 
212  if (idx >= m_size) return STATS_ZERO;
213  TrafficStats tmp = m_stats[idx];
214  m_stats[idx] = STATS_ZERO;
215  return tmp;
216 }
217 
219  // Sanity check for a valid source port.
220  unsigned src = msg.srcport();
221  if (src >= m_size) return;
222 
223  if (msg.reason() == SwitchLogMessage::REASON_KEEP) {
224  // Increment packet counters for the source port.
225  ++m_stats[src].rcvd_frames;
226  if (msg.hdr.dst.is_broadcast())
227  ++m_stats[src].bcast_frames;
228  // Increment packet counters for the destination port(s).
229  for (unsigned dst = 0 ; dst < m_size ; ++dst) {
230  if ((msg.dstmask() >> dst) & 1)
231  ++m_stats[dst].sent_frames;
232  }
233  } else {
234  // Increment error counters for the source port only.
235  ++m_stats[src].errct_total;
237  ++m_stats[src].errct_ovr;
240  ++m_stats[src].errct_pkt;
241  }
242 }
243 
245  : Protocol(satcat5::net::TYPE_NONE)
246  , m_src(src)
247  , m_iface(nullptr)
248 {
249  if (m_src) m_src->set_callback(this);
250 }
251 
253  : Protocol(filter)
254  , m_src(nullptr)
255  , m_iface(iface)
256 {
257  if (m_iface) m_iface->add(this);
258 }
259 
260 #if SATCAT5_ALLOW_DELETION
261 SwitchLogReader::~SwitchLogReader() {
262  if (m_iface) m_iface->remove(this);
263  if (m_src) m_src->set_callback(nullptr);
264 }
265 #endif
266 
268  if (!m_src) return;
269  if (msec) {
270  m_src->set_callback(nullptr);
271  timer_every(msec);
272  } else {
273  m_src->set_callback(this);
274  timer_stop();
275  }
276 }
277 
279  SwitchLogMessage msg;
280  while (msg.read_from(src)) {
281  this->log_event(msg); // Call child's event-handler.
282  if (src->get_read_ready() == 0) src->read_finalize();
283  }
284 }
285 
286 void SwitchLogReader::data_unlink(Readable* src) {m_src = 0;} // GCOVR_EXCL_LINE
287 
289  data_rcvd(&src);
290 }
291 
293  if (m_src) data_rcvd(m_src);
294 }
295 
297  : SwitchLogReader(src), m_label(lbl)
298 {
299  // Nothing else to initialize.
300 }
301 
303  satcat5::eth::Dispatch* iface, satcat5::eth::MacType etype, const char* lbl)
304  : SwitchLogReader(iface, Type(etype.value)), m_label(lbl)
305 {
306  // Nothing else to initialize.
307 }
308 
310  satcat5::udp::Dispatch* iface, satcat5::udp::Port port, const char* lbl)
311  : SwitchLogReader(iface, Type(port.value)), m_label(lbl)
312 {
313  // Nothing else to initialize.
314 }
315 
317  satcat5::log::Log(satcat5::log::DEBUG, m_label).write_obj(msg);
318 }
319 
323  satcat5::udp::Dispatch* iface)
324  : SwitchLogReader(src)
325  , m_dst_port(dst->get_switch(), dst->get_egress())
326  , m_dst_raw(&m_dst_port)
327  , m_eth(iface->eth())
328  , m_udp(iface)
329  , m_first(true)
330 {
331  // Nothing else to initialize.
332 }
333 
337  satcat5::udp::Dispatch* iface)
338  : SwitchLogReader(src)
339  , m_dst_port(nullptr, nullptr)
340  , m_dst_raw(dst)
341  , m_eth(iface->eth())
342  , m_udp(iface)
343  , m_first(true)
344 {
345  // Nothing else to initialize.
346 }
347 
349  const satcat5::eth::MacAddr& addr,
350  const satcat5::eth::MacType& type,
351  const satcat5::eth::VlanTag& vtag)
352 {
353  m_udp.close();
354  m_eth.connect(addr, type, vtag);
355 }
356 
358  const satcat5::udp::Addr& addr,
359  const satcat5::udp::Port& port,
360  const satcat5::eth::VlanTag& vtag)
361 {
362  m_eth.close();
363  m_udp.connect(addr, port, satcat5::udp::PORT_NONE, vtag);
364 }
365 
367  // If there's no valid connection, abort immediately.
368  // (This includes UDP connections waiting for an ARP handshake.)
369  if (!ready()) return;
370 
371  // Are additional packets waiting in the read queue?
372  // Use this information to consolidate outgoing log packets.
373  const unsigned BYTES_PER_MSG = SwitchLogMessage::LEN_BYTES;
374  unsigned more_pkt = m_src->get_read_ready() / BYTES_PER_MSG;
375 
376  // If this starts a new packet, write Eth/IP/UDP headers.
377  if (m_first) {
378  m_first = false;
379  if (m_eth.ready()) { // Raw-Ethernet mode
380  m_dst_raw->write_obj(m_eth.header());
381  } else { // UDP mode
382  unsigned total_bytes = (1 + more_pkt) * BYTES_PER_MSG;
383  m_dst_raw->write_obj(m_udp.eth_header());
384  m_dst_raw->write_obj(m_udp.ip_header(total_bytes));
385  m_dst_raw->write_obj(m_udp.udp_header(total_bytes));
386  }
387  }
388 
389  // Write the next log descriptor.
390  m_dst_raw->write_obj(msg);
391 
392  // Final descriptor in this packet?
393  if (!more_pkt) {
394  m_dst_raw->write_finalize();
395  m_first = true;
396  }
397 }
Pointer-like wrapper for one or more ConfigBus registers.
Definition: cfgbus_core.h:76
u32 uptime_usec() const
Get elapsed time since startup, in microseconds.
Definition: datetime.cc:44
bool ready() const override
Is this address object ready for use? Child MUST override this method.
Definition: eth_address.cc:43
void close() override
Close any open connections and revert to idle.
Definition: eth_address.cc:37
void connect(const satcat5::eth::MacAddr &addr, const satcat5::eth::MacType &type, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Connect to the designated address.
Definition: eth_address.cc:19
Implemention of "net::Dispatch" for Ethernet frames.
Definition: eth_dispatch.h:21
Accept incoming Ethernet packets by EtherType.
Definition: eth_protocol.h:24
Read binary packet logs to produce human-readable log messages.
Definition: eth_sw_log.h:303
SwitchLogFormatter(satcat5::io::Readable *src, const char *lbl="PktLog")
Bind this object to a stream of packet-logging data.
Definition: eth_sw_log.cc:296
void log_event(const satcat5::eth::SwitchLogMessage &msg) override
Implement the SwitchLogReader callback.
Definition: eth_sw_log.cc:316
Define the API for packet-logging callbacks from eth::SwitchCore.
Definition: eth_switch.h:64
virtual void log_packet(const satcat5::eth::SwitchLogMessage &msg)=0
This method is called exactly once for each incoming packet.
Poll a hardware switch or router for log data.
Definition: eth_sw_log.h:152
void timer_event() override
Child class MUST override this method.
Definition: eth_sw_log.cc:143
SwitchLogHardware(satcat5::eth::SwitchLogHandler *dst, satcat5::cfg::Register src)
Link this object to a log-writer and a data source.
Definition: eth_sw_log.cc:134
Read packet-logs from an input stream or network interface.
Definition: eth_sw_log.h:267
virtual void log_event(const satcat5::eth::SwitchLogMessage &msg)=0
The child class MUST override this method.
void set_polling_interval(unsigned msec)
Set polling interval, in milliseconds.
Definition: eth_sw_log.cc:267
void frame_rcvd(satcat5::io::LimitedRead &src) override
Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value.
Definition: eth_sw_log.cc:288
void data_unlink(satcat5::io::Readable *src) override
Unlink this EventListener from the designated source, because the designated Readable object is being...
Definition: eth_sw_log.cc:286
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
Definition: eth_sw_log.cc:278
void timer_event() override
Child class MUST override this method.
Definition: eth_sw_log.cc:292
SwitchLogReader(satcat5::io::Readable *src)
Constructor for buffered mode.
Definition: eth_sw_log.cc:244
Record packet statistics based on switch log events.
Definition: eth_sw_log.h:173
TrafficStats get_port(unsigned idx)
Read most recent statistics for the Nth port.
Definition: eth_sw_log.cc:211
const unsigned m_size
Buffer size.
Definition: eth_sw_log.h:198
TrafficStats *const m_stats
Working counters.
Definition: eth_sw_log.h:197
SwitchLogStats(TrafficStats *buff, unsigned size)
Constructor accepts a pointer to the working buffer.
Definition: eth_sw_log.cc:203
void log_packet(const satcat5::eth::SwitchLogMessage &msg) override
Process each packet event.
Definition: eth_sw_log.cc:218
Forward binary packet logs to a network interface.
Definition: eth_sw_log.h:342
SwitchLogToPort(satcat5::io::Readable *src, satcat5::eth::SwitchPort *dst, satcat5::udp::Dispatch *iface)
Bind this object to a software egress port.
Definition: eth_sw_log.cc:320
bool ready() const
Is this connection currently active?
Definition: eth_sw_log.h:377
void log_event(const satcat5::eth::SwitchLogMessage &msg) override
Implement the SwitchLogReader callback.
Definition: eth_sw_log.cc:366
void connect(const satcat5::eth::MacAddr &addr, const satcat5::eth::MacType &type=satcat5::eth::ETYPE_SWITCH_LOG, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Connect to a designated raw-Ethernet address.
Definition: eth_sw_log.cc:348
Record rate-limited packet-logs for a switch or router.
Definition: eth_sw_log.h:216
void timer_event() override
Child class MUST override this method.
Definition: eth_sw_log.cc:186
void log_packet(const satcat5::eth::SwitchLogMessage &msg) override
Process each packet event.
Definition: eth_sw_log.cc:164
Generic packetized I/O interface for use with SwitchCore.
Definition: eth_switch.h:245
Ephemeral Readable interface for a simple array.
Definition: io_readable.h:206
unsigned written_len() const
Report total length after write_finalize() is called.
Definition: io_writeable.h:151
bool write_finalize() override
Mark end of frame and release temporary working data.
const u8 * buffer() const
Read-only access to the working buffer.
Definition: io_writeable.h:147
Limited read of next N bytes.
Definition: io_readable.h:255
Abstract API for reading byte-streams and packets.
Definition: io_readable.h:68
u8 read_u8()
One of many functions for reading integer/floating point values, see details.
Definition: io_readable.cc:44
virtual void read_finalize()
Consume any remaining bytes in this frame, if applicable.
Definition: io_readable.cc:270
virtual void set_callback(satcat5::io::EventListener *callback)
Update registered callback for data_rcvd() events.
Definition: io_readable.cc:39
virtual unsigned get_read_ready() const =0
How many bytes can be read without blocking?
Abstract API for writing byte-streams and packets.
Definition: io_writeable.h:24
virtual unsigned get_write_space() const =0
How many bytes can be written without blocking?
void write_u8(u8 data)
One of many functions for writing integer/floating point values, see details.
Definition: io_writeable.cc:20
virtual bool write_finalize()
Mark end of frame and release temporary working data.
void write_obj(const T &obj)
Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr)...
Definition: io_writeable.h:104
Internal buffer used by the Log class.
Definition: log.h:134
void wr_h32(u32 val, unsigned nhex=8)
Write an integer (u32) in hexadecimal format.
Definition: log.cc:303
void wr_str(const char *str)
Write a null-terminated UTF-8 string.
Definition: log.cc:297
void wr_d32(u32 val, unsigned zpad=0)
Write an unsigned integer (u32) in decimal format.
Definition: log.cc:317
The Log class creates and formats one log message.
Definition: log.h:195
Log & write_obj(const T &obj)
Templated wrapper for custom output formatting.
Definition: log.h:251
The "Dispatch" is a generic interface that knows how to read a designated protocol layer and sort inc...
Definition: net_dispatch.h:36
void add(satcat5::net::Protocol *proto)
Register a Protocol object.
Definition: net_dispatch.h:55
void remove(satcat5::net::Protocol *proto)
Unregister a Protocol object.
Definition: net_dispatch.h:59
void timer_stop()
Stop all future notifications.
Definition: polling.cc:326
void timer_every(unsigned msec)
Configure a repeating notification every X milliseconds.
Definition: polling.cc:321
void connect(const satcat5::udp::Addr &dstaddr, const satcat5::eth::MacAddr &dstmac, const satcat5::udp::Port &dstport, const satcat5::udp::Port &srcport=satcat5::udp::PORT_NONE, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Manual address resolution (user supplies IP + MAC).
Definition: udp_core.cc:30
void close() override
Close any open connections and revert to idle.
Definition: udp_core.h:102
Dispatcher sorts incoming UDP messages by port index.
Definition: udp_dispatch.h:20
Real-time clock conversion functions.
Diagnostic logging system for the Ethernet switch.
Diagnostic logging to UART and/or Ethernet ports.
An Ethernet frame header.
Definition: eth_header.h:167
satcat5::eth::MacType type
Ethernet header fields.
Definition: eth_header.h:172
satcat5::eth::VlanTag vtag
Ethernet header fields.
Definition: eth_header.h:173
satcat5::eth::MacAddr src
Ethernet header fields.
Definition: eth_header.h:171
satcat5::eth::MacAddr dst
Ethernet header fields.
Definition: eth_header.h:170
void log_to(satcat5::log::LogBuffer &wr) const
Human-readable report of all fields.
Definition: eth_header.cc:109
An Ethernet MAC address (with serializable interface).
Definition: eth_header.h:29
void write_to(satcat5::io::Writeable *wr) const
Write this field to a byte-stream.
Definition: eth_header.h:86
bool read_from(satcat5::io::Readable *rd)
Read this field from a byte-stream.
Definition: eth_header.h:89
bool is_broadcast() const
Broadcast (FF:FF:FF:FF:FF:FF)
Definition: eth_header.cc:33
EtherType field (uint16) is used a protocol-ID [1536..65535].
Definition: eth_header.h:96
void write_to(satcat5::io::Writeable *wr) const
Write this field to a byte-stream.
Definition: eth_header.h:115
bool read_from(satcat5::io::Readable *rd)
Read this field from a byte-stream.
Definition: eth_header.h:118
A single 24-byte packet-log message.
Definition: eth_sw_log.h:74
void init_keep(const satcat5::eth::Header &hdr, u8 src, u32 dst)
Initialize a KEEP message.
Definition: eth_sw_log.cc:73
static constexpr u8 DROP_UNKNOWN
Other unspecified error.
Definition: eth_sw_log.h:88
satcat5::eth::Header hdr
Ethernet packet header.
Definition: eth_sw_log.h:105
static constexpr u8 DROP_VLAN
Virtual-LAN policy.
Definition: eth_sw_log.h:83
static constexpr u8 DROP_MCTRL
Link-local control packet.
Definition: eth_sw_log.h:82
bool read_from(satcat5::io::Readable *rd)
Read descriptor from the designated stream.
Definition: eth_sw_log.cc:122
static constexpr unsigned LEN_BYTES
Message length, in bytes.
Definition: eth_sw_log.h:100
static constexpr u8 DROP_BADFRM
Frame length, source MAC, etc.
Definition: eth_sw_log.h:81
void init_drop(const satcat5::eth::Header &hdr, u8 src, u8 why)
Initialize a DROP message.
Definition: eth_sw_log.cc:80
u16 count_keep() const
Count delivered packets.
Definition: eth_sw_log.cc:67
static constexpr u8 DROP_PTPERR
PTP error (no timestamp)
Definition: eth_sw_log.h:85
static constexpr u8 DROP_BADFCS
Invalid frame check sequence.
Definition: eth_sw_log.h:80
static constexpr u8 TYPE_SKIP
Message type: SKIP (summary)
Definition: eth_sw_log.h:96
u16 count_drop() const
Count dropped packets.
Definition: eth_sw_log.cc:61
static constexpr u8 DROP_DISABLED
Ingress or egress port disabled.
Definition: eth_sw_log.h:87
u8 type_src
Type and source port.
Definition: eth_sw_log.h:104
void init_skip(u16 drop, u16 keep)
Initialize a SKIP message.
Definition: eth_sw_log.cc:87
const char * reason_str() const
Human-readable reason for a dropped packet, if applicable.
Definition: eth_sw_log.cc:45
static constexpr u8 DROP_NO_ROUTE
No destination or null route.
Definition: eth_sw_log.h:86
static constexpr u8 REASON_KEEP
Packet accepted / not dropped.
Definition: eth_sw_log.h:78
static constexpr u8 DROP_VRATE
Virtual-LAN rate limits.
Definition: eth_sw_log.h:84
u8 reason() const
Coded reason for a dropped packet, if applicable.
Definition: eth_sw_log.cc:37
u32 meta
Additional metadata.
Definition: eth_sw_log.h:106
void log_to(satcat5::log::LogBuffer &wr) const
Format this field as a human-readable string.
Definition: eth_sw_log.cc:94
u8 type() const
< Message type.
Definition: eth_sw_log.h:130
static constexpr u8 TYPE_DROP
Message type: DROP (dropped)
Definition: eth_sw_log.h:95
static constexpr u8 DROP_OVERFLOW
FIFO overflow (Rx or Tx)
Definition: eth_sw_log.h:79
u32 tstamp
Timestamp in microseconds.
Definition: eth_sw_log.h:103
static constexpr u8 TYPE_KEEP
Message type: KEEP (delivered)
Definition: eth_sw_log.h:94
static constexpr u8 SRC_MASK
Mask for source index.
Definition: eth_sw_log.h:92
void write_to(satcat5::io::Writeable *wr) const
Write descriptor to the designated stream.
Definition: eth_sw_log.cc:112
SATCAT5_PMASK_TYPE dstmask() const
Destination mask (KEEP messages only).
Definition: eth_sw_log.h:122
u8 srcport() const
< Source port index.
Definition: eth_sw_log.h:128
Data structure for reporting per-port traffic statistics.
Definition: eth_sw_log.h:176
u32 bcast_frames
Broadcast frames received from device.
Definition: eth_sw_log.h:177
u32 errct_total
Total packet errors, all types.
Definition: eth_sw_log.h:182
u32 errct_ovr
Frames dropped due to FIFO overflow.
Definition: eth_sw_log.h:180
u32 sent_frames
Total frames sent from switch to device.
Definition: eth_sw_log.h:179
u32 rcvd_frames
Total frames received from device.
Definition: eth_sw_log.h:178
u32 errct_pkt
Invalid packets (bad checksum, etc.)
Definition: eth_sw_log.h:181
Header contents for an 802.1Q Virtual-LAN tag.
Definition: eth_header.h:124
bool read_from(satcat5::io::Readable *rd)
Read this field from a byte-stream.
Definition: eth_header.h:159
void write_to(satcat5::io::Writeable *wr) const
Write this field to a byte-stream.
Definition: eth_header.h:156
IPv4 address is a 32-bit unsigned integer.
Definition: ip_core.h:15
UDP and TCP ports are both 16-bit unsigned integers.
Definition: ip_core.h:119
Multipurpose filter for matching fields in network packets.
Definition: net_type.h:38