From patchwork Tue Dec 3 14:56:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Marginean X-Patchwork-Id: 1203768 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 47S6bR5N2vz9s4Y for ; Wed, 4 Dec 2019 03:18:11 +1100 (AEDT) Received: by phobos.denx.de (Postfix, from userid 109) id B70D781AB5; Tue, 3 Dec 2019 17:05:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 450F080658; Tue, 3 Dec 2019 16:53:32 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 9140681686; Tue, 3 Dec 2019 16:53:27 +0100 (CET) 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 55EFF8067D for ; Tue, 3 Dec 2019 15:58:26 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=alexandru.marginean@nxp.com Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 238071A13A3; Tue, 3 Dec 2019 15:57:28 +0100 (CET) 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 161751A13A1; Tue, 3 Dec 2019 15:57:28 +0100 (CET) Received: from fsr-ub1864-115.ea.freescale.net (fsr-ub1864-115.ea.freescale.net [10.171.82.26]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id CC4AE205C6; Tue, 3 Dec 2019 15:57:27 +0100 (CET) From: Alex Marginean To: u-boot@lists.denx.de Subject: [PATCH v3 0/6] Introduce DSA Ethernet switch class and Felix driver Date: Tue, 3 Dec 2019 16:56:39 +0200 Message-Id: <20191203145645.13361-1-alexandru.marginean@nxp.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joe Hershberger , Claudiu Manoil , Vladimir Oltean Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at mail.denx.de X-Virus-Status: Clean DSA stands for Distributed Switch Architecture and it is a subsystem introduced in the Linux kernel to support switches that: - have an Ethernet link up to the CPU - use some form of tagging to identify the source/destination port for Rx/Tx - may be cascaded in tree-like structures. DSA is described in depth here: https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt From the doc: Summarized, this is basically how DSA looks like from a network device perspective: |--------------------------- | CPU network device (eth0)| ---------------------------- | | |--------------------------------------------| | Switch driver | |--------------------------------------------| || || || |-------| |-------| |-------| | sw0p0 | | sw0p1 | | sw0p2 | |-------| |-------| |-------| This patch set introduces a DSA class in U-Boot to support drivers of such switches. DSA drivers have to implement the following ops: - enable/disable of switch ports, - insert a tag in frames being transmitted, used by the switch to select the egress port, - parse a tag in frames being received, used for Rx traffic. DSA class code deals with presentation of switch ports as Ethernet interfaces, deals with the master Ethernet device for I/O and helps with parsing of the DT assuming the structure follows the DSA kernel binding. Support for switch cascading is not included yet. This patch set also introduces a driver for the Ethernet switch integrated into NXP LS1028A, called Felix. The switch has 4 front panel ports, I/O to/fom it is done though an ENETC Ethernet interface and meta-data is carried between the switch and the driver though an additional header pre-pended to the original frame. Network commands like tftp can be used on these front panel ports. The ports are disabled unless used so they do not cause issues on network topologies that include loops. Felix as seen on LS1028A RDB: => dm tree Class Index Probed Driver Name ----------------------------------------------------------- ...... dsa 0 [ + ] felix-switch | |-- felix-switch eth 4 [ + ] dsa-port | | |-- swp0 eth 5 [ + ] dsa-port | | |-- swp1 eth 6 [ + ] dsa-port | | |-- swp2 eth 7 [ + ] dsa-port | | `-- swp3 => mdio list ...... 10 - Vitesse VSC8514 <--> swp0 11 - Vitesse VSC8514 <--> swp1 12 - Vitesse VSC8514 <--> swp2 13 - Vitesse VSC8514 <--> swp3 => tftp 80000000 test Using swp2 device TFTP from server 192.168.100.1; our IP address is 192.168.100.100 Filename 'test'. Load address: 0x80000000 Loading: ################################################################# ################################################################# ######################################################## 6.8 MiB/s done Bytes transferred = 949880 (e7e78 hex) Changes in v3: - fix Felix platdata size - move include/dsa.h to include/net/dsa.h - updated TODO in dsa.h - other minor fixes Changes in v2: - Don't use NULL PHY in Felix driver - guard dsa.h with #ifndef __DSA__H__, somehow I missed that in v1 - added a TODO for setting master Eth in promiscuous mode - Minor fixes in patch descriptions, API comments - Added address/size-cells to LS1028A DT ports node This patch set replaces v2: https://patchwork.ozlabs.org/project/uboot/list/?series=144912 and depends on: https://patchwork.ozlabs.org/project/uboot/list/?series=144907 https://patchwork.ozlabs.org/project/uboot/list/?series=142879 Alex Marginean (6): net: introduce DSA class for Ethernet switches drivers: net: add a DSA sandbox driver test: dm: add a simple unit test for DSA class drivers: net: add Felix DSA switch driver arm: dts: ls1028a: adds Ethernet switch node and its dependencies configs: ls1028a: enable the Ethernet switch driver in defconfig arch/Kconfig | 1 + arch/arm/dts/fsl-ls1028a-rdb.dts | 36 ++ arch/arm/dts/fsl-ls1028a.dtsi | 44 +- arch/sandbox/dts/test.dts | 49 ++ configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 3 +- configs/ls1028aqds_tfa_defconfig | 3 +- configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 3 +- configs/ls1028ardb_tfa_defconfig | 3 +- drivers/net/Kconfig | 21 + drivers/net/Makefile | 1 + drivers/net/dsa_sandbox.c | 272 +++++++++++ drivers/net/fsl_enetc.h | 5 + drivers/net/mscc_eswitch/Kconfig | 8 + drivers/net/mscc_eswitch/Makefile | 1 + drivers/net/mscc_eswitch/felix_switch.c | 454 +++++++++++++++++++ include/configs/sandbox.h | 4 + include/dm/uclass-id.h | 1 + include/dsa.h | 140 ++++++ net/Makefile | 1 + net/dsa-uclass.c | 369 +++++++++++++++ test/dm/Makefile | 1 + test/dm/dsa.c | 58 +++ test/dm/test-fdt.c | 2 +- 23 files changed, 1474 insertions(+), 6 deletions(-) create mode 100644 drivers/net/dsa_sandbox.c create mode 100644 drivers/net/mscc_eswitch/felix_switch.c create mode 100644 include/dsa.h create mode 100644 net/dsa-uclass.c create mode 100644 test/dm/dsa.c Tested-by: Vladimir Oltean