From patchwork Tue May 5 17:43:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Manoil X-Patchwork-Id: 1283882 X-Patchwork-Delegate: priyanka.jain@nxp.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Gqsz0lRlz9sRf for ; Wed, 6 May 2020 05:44:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA4CB81D52; Tue, 5 May 2020 21:43:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 5317A8209D; Tue, 5 May 2020 19:43:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6B1DB82072 for ; Tue, 5 May 2020 19:43:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=claudiu.manoil@nxp.com Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 25ADC1A088E; Tue, 5 May 2020 19:43:10 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 1670B1A0868; Tue, 5 May 2020 19:43:10 +0200 (CEST) Received: from fsr-ub1664-016.ea.freescale.net (fsr-ub1664-016.ea.freescale.net [10.171.71.216]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id D4EAA205C7; Tue, 5 May 2020 19:43:09 +0200 (CEST) From: Claudiu Manoil To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, alexandru.marginean@nxp.com, vladimir.oltean@nxp.com Subject: [PATCH v4 3/6] test: dm: add a simple unit test for DSA class Date: Tue, 5 May 2020 20:43:05 +0300 Message-Id: <1588700588-8587-4-git-send-email-claudiu.manoil@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588700588-8587-1-git-send-email-claudiu.manoil@nxp.com> References: <1588700588-8587-1-git-send-email-claudiu.manoil@nxp.com> X-Mailman-Approved-At: Tue, 05 May 2020 21:43:54 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean From: Alex Marginean The test pings the local IP address though different ports of a sandbox DSA device. Port traffic is filtered and the test verifies that ping works only on enabled ports. The additional interfaces require MAC addresses, these have been added to sandbox default environment. Signed-off-by: Alex Marginean Signed-off-by: Claudiu Manoil --- arch/Kconfig | 1 + arch/sandbox/dts/test.dts | 49 +++++++++++++++++++++++++++++++++ include/configs/sandbox.h | 4 +++ test/dm/Makefile | 1 + test/dm/dsa.c | 58 +++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 2 +- 6 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 test/dm/dsa.c diff --git a/arch/Kconfig b/arch/Kconfig index ae9c93ed7b..d13a53a548 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -136,6 +136,7 @@ config SANDBOX imply ACPI_PMC imply ACPI_PMC_SANDBOX imply CMD_PMC + imply DM_DSA config SH bool "SuperH architecture" diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 4a277934a7..7c54200e71 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -40,6 +40,10 @@ usb2 = &usb_2; axi0 = &axi; osd0 = "/osd"; + eth8 = &swp_0; + eth9 = &swp_1; + eth10 = &swp_2; + eth11 = &dsa_eth0; }; audio: audio-codec { @@ -934,6 +938,51 @@ mdio: mdio-test { compatible = "sandbox,mdio"; }; + + dsa_eth0: dsa-test-eth { + compatible = "sandbox,dsa-eth"; + }; + + dsa-test { + compatible = "sandbox,dsa"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + swp_0: port@0 { + reg = <0>; + label = "lan0"; + }; + + swp_1: port@1 { + reg = <1>; + label = "lan1"; + phy-mode = "rgmii-txid"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + swp_2: port@2 { + reg = <2>; + label = "lan2"; + fixed-link { + speed = <100>; + full-duplex; + }; + }; + + port@3 { + reg = <3>; + ethernet = <&dsa_eth0>; + fixed-link { + speed = <100>; + full-duplex; + }; + }; + }; + }; }; #include "sandbox_pmic.dtsi" diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 1c13055cdc..35a5676eb9 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -100,6 +100,10 @@ "eth1addr=00:00:11:22:33:45\0" \ "eth3addr=00:00:11:22:33:46\0" \ "eth5addr=00:00:11:22:33:47\0" \ + "eth8addr=00:00:11:22:33:48\0" \ + "eth9addr=00:00:11:22:33:49\0" \ + "eth10addr=00:00:11:22:33:4a\0" \ + "eth11addr=00:00:11:22:33:4b\0" \ "ipaddr=1.2.3.4\0" #define MEM_LAYOUT_ENV_SETTINGS \ diff --git a/test/dm/Makefile b/test/dm/Makefile index dd1ceff86c..1807795bec 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -70,4 +70,5 @@ obj-$(CONFIG_DMA) += dma.o obj-$(CONFIG_DM_MDIO) += mdio.o obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o obj-$(CONFIG_DM_RNG) += rng.o +obj-$(CONFIG_DM_DSA) += dsa.o endif diff --git a/test/dm/dsa.c b/test/dm/dsa.c new file mode 100644 index 0000000000..8a55554a0c --- /dev/null +++ b/test/dm/dsa.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019-2020 NXP + */ + +#include +#include +#include + +extern int dsa_sandbox_port_mask; + +/* this test sends ping requests with the local address through each DSA port + * via the dummy DSA master Eth. + * The dummy Eth filters traffic based on DSA port used to Tx and the port + * mask set here, so we can check that port information gets trough correctly. + */ +static int dm_test_dsa(struct unit_test_state *uts) +{ + dsa_sandbox_port_mask = 0x5; + + env_set("ethrotate", "no"); + net_ping_ip = string_to_ip("1.2.3.4"); + + env_set("ethact", "dsa-test-eth"); + ut_assertok(net_loop(PING)); + + dsa_sandbox_port_mask = 0x7; + env_set("ethact", "lan0"); + ut_assertok(net_loop(PING)); + env_set("ethact", "lan1"); + ut_assertok(net_loop(PING)); + env_set("ethact", "lan2"); + ut_assertok(net_loop(PING)); + + dsa_sandbox_port_mask = 0x1; + env_set("ethact", "lan0"); + ut_assertok(net_loop(PING)); + env_set("ethact", "lan1"); + ut_assert(net_loop(PING) != 0); + env_set("ethact", "lan2"); + ut_assert(net_loop(PING) != 0); + + dsa_sandbox_port_mask = 0x6; + env_set("ethact", "lan0"); + ut_assert(net_loop(PING) != 0); + env_set("ethact", "lan1"); + ut_assertok(net_loop(PING)); + env_set("ethact", "lan2"); + ut_assertok(net_loop(PING)); + + dsa_sandbox_port_mask = 0; + env_set("ethact", ""); + env_set("ethrotate", "yes"); + + return 0; +} + +DM_TEST(dm_test_dsa, DM_TESTF_SCAN_FDT); diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 75ae08081c..992c040b2c 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -283,7 +283,7 @@ static int dm_test_alias_highest_id(struct unit_test_state *uts) int ret; ret = dev_read_alias_highest_id("eth"); - ut_asserteq(5, ret); + ut_asserteq(11, ret); ret = dev_read_alias_highest_id("gpio"); ut_asserteq(2, ret);