[PATCH 2/5] sandbox: Add a DSA sandbox driver and unit test

Simon Glass sjg at chromium.org
Thu Jan 14 16:42:25 CET 2021


On Wed, 13 Jan 2021 at 11:05, Claudiu Manoil <claudiu.manoil at nxp.com> wrote:
>
> The DSA sandbox driver is used for unit testing the DSA class code.
> It implements a simple 2 port switch plus 1 CPU port, and uses a very
> simple tag to identify the ports.
> The DSA sandbox device is connected via CPU port to a regular Ethernet
> sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox
> driver.  The 'dsa-test-eth' is not intended for testing the eth class
> code however, but it is used to emulate traffic through the 'lan0' and
> 'lan1' front pannel switch ports.  To achieve this the dsa sandbox driver
> registers a tx handler for the 'dsa-test-eth' device.  The switch ports,
> labeled as 'lan0' and 'lan1', are also registered as eth devices by the
> dsa class code this time.  So pinging through these switch ports is as
> easy as:
> => setenv ethact lan0
> => ping 1.2.3.5
>
> Unit tests for the dsa class code were also added.  The 'dsa_probe'
> test exercises most API functions from dsa.h.  The 'dsa' unit test
> simply exercises ARP/ICMP traffic through the two switch ports,
> including tag injection and extraction, with the help of the dsa
> sandbox driver.
> I took care to minimize the impact on the existing eth unit tests,
> though some adjustments needed to be made with the addition of
> extra eth interfaces used by the dsa unit tests. The additional eth
> interfaces also require MAC addresses, these have been added to the
> sandbox default environment.
>
> Signed-off-by: Alex Marginean <alexandru.marginean at nxp.com>
> Signed-off-by: Claudiu Manoil <claudiu.manoil at nxp.com>
> ---
>  arch/Kconfig              |   1 +
>  arch/sandbox/dts/test.dts |  40 +++++++++
>  drivers/net/Kconfig       |   9 ++
>  drivers/net/Makefile      |   1 +
>  drivers/net/dsa_sandbox.c | 181 ++++++++++++++++++++++++++++++++++++++
>  include/configs/sandbox.h |   2 +
>  test/dm/Makefile          |   1 +
>  test/dm/dsa.c             |  91 +++++++++++++++++++
>  test/dm/eth.c             |  10 +--
>  9 files changed, 331 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/net/dsa_sandbox.c
>  create mode 100644 test/dm/dsa.c
>

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list