This post was revised after fact-checking it against the real SWS EthSwt
(see correction issue #145): SPI access in EthSwt isn’t a plain vendor
mechanism outside of AUTOSAR — it’s standardized through dedicated ARXML
containers ( |
When SPI instead of MII as the host interface?
Per chapter 1 of the SWS, access for switch-specific configuration or
functions happens via an SPI or MII/MDIO interface — mediated
through the Eth driver (MII/MDIO) or directly through the Spi driver
(SPI). SPI is used in particular when the host has no dedicated Ethernet
MAC port to the switch, or when configuration has to happen before an
Ethernet link to the switch even exists.
The real ARXML configuration: EthSwtSpi / EthSwtSpiSequence
EthSwtConfig
└── EthSwtSpi (0..1 — only present if SPI is used)
└── EthSwtSpiSequence (1..* — one or more SPI sequences)
├── EthSwtSpiAccessSynchronous (optional, boolean)
└── reference to a real SpiSequence
of the Spi driver (SpiSequenceId, symbolic name)The SWS is unusually explicit here: an |
If the switch chip has no SPI interface at all, there simply is no
instance of EthSwtSpi in the configuration — the container is optional
(0..1) exactly for that reason.
Generic register APIs — MII and SPI behind the same interface
The key point: EthSwt exposes one generic API for register access
upstream, regardless of whether MII or SPI sits underneath:
| API | Description per the SWS |
|---|---|
| "Generic API for reading the content of a switch register" — per
|
| The write counterpart; likewise generic over MII/SPI |
| Transceiver registers "through the MII or SPI of the indexed switch port" — for registers pertaining to a specific port |
For the caller of any of these APIs, it’s transparent whether an SPI
transaction over the configured |
Synchronous vs. asynchronous
The optional EthSwtSpiAccessSynchronous parameter controls whether the
SPI access is blocking (synchronous) or non-blocking. For time-critical
accesses during initialization (see EthSwt_BackgroundTask in Part 2 of
this series), this is a relevant knob for avoiding unnecessary delays in
register configuration.
Typical use cases
Initial configuration at boot — before an Ethernet link to the switch even exists
Statistics readout without extra Ethernet traffic — querying MIB counters (Part 4) over SPI without loading the actual data path
Diagnostics on a broken Ethernet link — if MII/MDIO is unavailable for some reason, SPI remains an independent access path
Failure pattern: register access fails
As described in this series' bring-up post, a failing register access —
whether via MII or SPI — results in the extended production error
ETHSWT_E_ACCESS. In SPI setups, it’s additionally worth checking
CPOL/CPHA settings and the timing of the configured EthSwtSpiSequence
with a logic analyzer.
Summary
| Aspect | Key takeaway |
|---|---|
ARXML container |
|
API abstraction |
|
Synchronicity | Configurable via |
Failure case |
|