The fourth and final part of the EthSwt core series covers three runtime topics: VLAN toggling, port mirroring, and MAC learning modes. Mirroring in particular turns out to be considerably more powerful in the real SWS than a simple "source port/target port" model would suggest.
Toggling VLANs at runtime
EthSwt_EnableVlan does not enable a new VLAN — it enables or disables
an already pre-configured VLAN at a given port:
Std_ReturnType EthSwt_EnableVlan(
uint8 SwitchIdx,
uint8 SwitchPortIdx,
uint16 VlanId,
boolean Enable // TRUE = enable this VLAN at this port
// FALSE = frames with this VLAN ID get dropped
);Per the SWS, |
With Enable = FALSE, frames with the corresponding VLAN ID are dropped
at the port — practically useful e.g. for temporarily isolating a
diagnostic or workshop port from the rest of the vehicle network without
reflashing the entire ARXML configuration.
Port mirroring: more powerful than expected
The real EthSwt_PortMirrorCfgType structure (chapter 8.2.5) goes far
beyond a simple "port A mirrors to port B" model:
| Field | Meaning |
|---|---|
| Only mirror frames with a matching source/destination MAC address;
|
| Only mirror frames of a specific VLAN ID; |
| Only mirror every nth frame (e.g. |
|
|
| Bitmasks (one bit per |
| The port where the mirrored traffic is output |
| VLAN ID(s) for re-/double-tagging, unless already provided by the switch configuration |
Per the SWS, a port-mirror configuration is maintained per Ethernet switch (not per port) — but the ingress/egress bitmasks let you mirror multiple source ports simultaneously to a single capture port. |
Relevant APIs: EthSwt_WritePortMirrorConfiguration,
EthSwt_ReadPortMirrorConfiguration,
EthSwt_DeletePortMirrorConfiguration,
EthSwt_SetPortMirrorState / EthSwt_GetPortMirrorState.
|
MAC learning modes
Per the SWS, EthSwt_SetMacLearningMode / EthSwt_GetMacLearningMode
support exactly three modes:
| Mode | Meaning |
|---|---|
HW learning enabled | The switch chip learns MAC addresses autonomously in hardware |
HW learning disabled | No automatic learning — the ARL table stays static as configured (see this series' ARL table post) |
SW learning enabled | Learning happens in software, e.g. via an integration routine that evaluates unknown source addresses |
The SWS explicitly emphasizes that this feature is hardware-dependent —
not every switch chip supports all three modes. |
Diagnostics via counters
Several counter APIs are available for ongoing diagnostics:
EthSwt_GetCounterValues, EthSwt_GetRxStats, EthSwt_GetTxStats, and
EthSwt_GetTxErrorCounterValues. Combined with mirroring and MAC learning
status, these let you narrow down typical network problems without
affecting the traffic itself.
Case study: narrowing down a broadcast storm
Confirm the suspicion —
EthSwt_GetRxStatson several ports shows unusually high broadcast/multicast ratesMirror selectively — configure port mirroring with
VlanIdFilterset to the affected VLAN and a practicalMirroringPacketDivider, pointing the capture port at the diagnostic connectorCheck MAC learning — query
EthSwt_GetMacLearningModeon each involved port; a loop in the network often shows up as constantly changing ARL entries for the same source addressIsolate — temporarily disable the affected VLAN on a suspicious port via
EthSwt_EnableVlan(…, FALSE)to narrow down the source of the problem
Series (complete)
| Part | Topic | Status |
|---|---|---|
1 | Fundamentals, SWS & architecture | done |
2 | API & initialization | done |
3 | ARXML configuration | done |
4 | VLAN management, mirroring & diagnostics | this post |
The core series is now complete. The following dedicated posts dive into specialized topics: hardware architecture, TSN, MACsec in the switch, firewall interaction, global time support, the ARL table/MAC learning in detail, and diagnostics/register access.