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, EthSwt_EnableVlan explicitly requires a pre-configured VLAN assignment ("VLAN-ID to a preconfigured configuration"). The VLAN itself — which ports may belong to it, what the default VLAN ID is — comes from the ARXML configuration (Part 3). At runtime you can only switch it on or off, not redefine it.

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:

FieldMeaning

srcMacAddrFilter / dstMacAddrFilter

Only mirror frames with a matching source/destination MAC address; 00:00:00:00:00:00 = no filter

VlanIdFilter

Only mirror frames of a specific VLAN ID; 65535 = no filter

MirroringPacketDivider

Only mirror every nth frame (e.g. 2 = every second frame) — reduces bandwidth load on the capture port

MirroringMode

0x00 no retagging, 0x01 VLAN retagging, 0x02 VLAN double tagging

TrafficDirectionIngressBitMask / …​EgressBitMask

Bitmasks (one bit per EthSwtPortIdx) that separately control whether a port’s ingress or egress traffic is mirrored

CapturePortIdx

The port where the mirrored traffic is output

ReTaggingVlanId / DoubleTaggingVlanId

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.

MirroringPacketDivider is worth its weight in gold in practice: a full 1000BASE-T1 uplink often can’t be mirrored 1:1 to a single diagnostic port without overloading it. A divider of, say, 10 cuts the mirrored load to a tenth — enough for many statistical analyses without flooding the capture port.

MAC learning modes

Per the SWS, EthSwt_SetMacLearningMode / EthSwt_GetMacLearningMode support exactly three modes:

ModeMeaning

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. SetMacLearningMode can therefore return E_NOT_OK if a requested mode isn’t supported by the specific hardware.

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

  1. Confirm the suspicionEthSwt_GetRxStats on several ports shows unusually high broadcast/multicast rates

  2. Mirror selectively — configure port mirroring with VlanIdFilter set to the affected VLAN and a practical MirroringPacketDivider, pointing the capture port at the diagnostic connector

  3. Check MAC learning — query EthSwt_GetMacLearningMode on each involved port; a loop in the network often shows up as constantly changing ARL entries for the same source address

  4. Isolate — temporarily disable the affected VLAN on a suspicious port via EthSwt_EnableVlan(…​, FALSE) to narrow down the source of the problem

Series (complete)

PartTopicStatus

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.