From patchwork Wed Apr 24 22:24:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 162815 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1198431jan; Wed, 24 Apr 2019 15:24:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFrV9SXRTyuBd2+jnJGyHNXD5TO4XmnIuO64SAICIkL44Si3OrGxPeu3E2RnaYZDAG61AM X-Received: by 2002:a63:e042:: with SMTP id n2mr32812548pgj.45.1556144695344; Wed, 24 Apr 2019 15:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556144695; cv=none; d=google.com; s=arc-20160816; b=B1BDNKd7twIdfAbJLeWB/nqStgHcFXy9yQpUFFoSjMoNlhKpSyu812ip8qfVge/PfK FWAm7jEPIGkCkj9Z32jCW5Cbqww1IQWLHjtFpuL+FUBO5OcVcjaoMTjK437RMqUXVSoC uDBMB4zFKJjhTPd8q5xq0eb4HAK3F1aQiiwGHexuNahq/kgJxiIaYZyn9yP9c9WUzMgn twjni/TYwPiJ+ws6S0PWM3wvVJznM9saRQ1XFacnz6++ol1L4e58Cn1xQwQNKJqt9pZK b2vaSJelS40W2FoCGH7odoI64gJ5TtTfxES8cLbe2SkxYq05ocWJcgjOFpTGFqOkiz+m qt4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=P6vZmZAFETt4Q0b+EePKmb0qxtoqnt3HQMJIynOtemo=; b=FtH6eBFkssvRrPGKWF+MiUFbMypu0flNn2LxyoTDpmPpam4jkqNs657hZ7LEHbstX7 3dPvx64aie6hKJixVyHuCXLi+t6wZxGCiaDVSzhNToU2zIBL9yNe323ACF3JiCM2vRvI iY6yEoE6lNUuKGhHgQH0JID8uagVKCRFcsd/XuPW0yf5axOP+lbQe9typBkaiGKlvjfB ZdIdGK93nJJy/0RQnoN6fJpHpbBphVI7BZQWdbk2X6l4G6AEKCut7qrSJDYvrUCAJusd BuCIhtY+TtgVL8w8z1shAcdWTPrMGcc+LSHKRRBuItBFg1+ma+5u3JdNi7PMSEcF/qdy o5PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w+25MVGM; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d37si20296836pla.97.2019.04.24.15.24.55; Wed, 24 Apr 2019 15:24:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w+25MVGM; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387736AbfDXWYr (ORCPT + 9 others); Wed, 24 Apr 2019 18:24:47 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:41104 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbfDXWYk (ORCPT ); Wed, 24 Apr 2019 18:24:40 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x3OMOVsC020818; Wed, 24 Apr 2019 17:24:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1556144671; bh=P6vZmZAFETt4Q0b+EePKmb0qxtoqnt3HQMJIynOtemo=; h=From:To:CC:Subject:Date; b=w+25MVGMLx+UjE5iJe+dId9jpc/sRRJ79ttmvWvqJCMDBY58UIvvqzXmx18lsV1WT hQMqUBsBimNIyh2Lopa/qaSk5++pZf+m2I9uQZcsmdqoTuCvbVOelZZPeN+t9a59/o hzPprP4Ang4ZQkqoG73qJ4Evr+xXJLcQngfEn8Hs= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x3OMOVPv110532 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Apr 2019 17:24:31 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 24 Apr 2019 17:24:31 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 24 Apr 2019 17:24:31 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x3OMOUTs060129; Wed, 24 Apr 2019 17:24:30 -0500 From: Grygorii Strashko To: , Ilias Apalodimas , Andrew Lunn , "David S . Miller" , Ivan Khoronzhuk , Jiri Pirko CC: Florian Fainelli , Sekhar Nori , , , Murali Karicheri , Ivan Vecera , Grygorii Strashko Subject: [RFC PATCH v3 net-next 00/11] net: ethernet: ti: introduce new cpsw switchdev based driver Date: Thu, 25 Apr 2019 01:24:16 +0300 Message-ID: <1556144667-27997-1-git-send-email-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi All, This series based on work [1][2] done by Ilias Apalodimas . This the RFC v3 which introduces new CPSW switchdev based driver which is operating in dual-emac mode by default, thus working as 2 individual network interfaces. When both interfaces joined the bridge - CPSW driver will enter a switch mode and discard dual_mac configuration. The CPSW will be switched back to dual_mac mode if any port leaves the bridge. All configuration is going to be implemented via switchdev API. patches #1 - 2: preparation patcces which also moves common code to cpsw_priv.c patch #3: Adds functions to ALE for modifying VLANs/MDBs. patch #4: Adds support of force untagged VLAN traffic to Host P0 port which required for proper support of default VLANs. patch #5: Prepares cpsw driver for switchdev mode, without changing any of the funtionality. patches #6-9: Introduce TI CPSW switch driver based on switchdev and new DT bindings, resolve build dependencies patch #10: CPSW switchdev driver documentation (tbd) patch #11: DT nodes for new CPSW switchdev driver added for DRA7/am571x-idk as and example. Most of the contents of the previous cover-letter have been added in new driver documentation, so please refer to that for configuration, testing and future work. These patches can be found at: git@git.ti.com:~gragst/ti-linux-kernel/gragsts-ti-linux-kernel.git branch: lkml-5.1-switch-tbd [1] Dependencies: This series depends on prerequisite series https://lkml.org/lkml/2019/4/23/476 [1] https://patchwork.ozlabs.org/cover/929367/ [2] https://patches.linaro.org/cover/136709/ Changes in v3: - alot of work done to split properly common code between legacy and switchdev CPSW drivers and clean up code - CPSW switchdev interface updated to the current LKML switchdev interface - actually new CPSW switchdev based driver introduced - optimized dual_mac mode in new driver. Main change is that in promiscuous mode P0_UNI_FLOOD (both ports) is enabled in addition to ALLMULTI (current port) instead of ALE_BYPASS. So, port in non promiscuous mode will keep possibility of mcast and vlan filtering. - changed bridge join sequnce: now switch mode will be enabled only when both ports joined the bridge. CPSW will be switched to dual_mac mode if any port leave bridge. ALE table is completly cleared and then refiled while switching to switch mode - this simplidies code a lot, but introduces some limitation to bridge setup sequence: ip link add name br0 type bridge ip link set dev br0 type bridge ageing_time 1000 ip link set dev br0 type bridge vlan_filtering 0 <- disable echo 0 > /sys/class/net/br0/bridge/default_vlan ip link set dev sw0p1 up <- add ports ip link set dev sw0p2 up ip link set dev sw0p1 master br0 ip link set dev sw0p2 master br0 echo 1 > /sys/class/net/br0/bridge/default_vlan <- enable ip link set dev br0 type bridge vlan_filtering 1 bridge vlan add dev br0 vid 1 pvid untagged self - STP tested with vlan_filtering 1/0. To make STP work I've had to set NO_SA_UPDATE for all slave ports (see comment in code). It also required to statically register STP mcast address {0x01, 0x80, 0xc2, 0x0, 0x0, 0x0}; - allowed build both TI_CPSW and TI_CPSW_SWITCHDEV drivers - PTP can be enabled on both ports in dual_mac mode - Future work: 1. port QDISC_CBS and QDISC_MQPRIO support 2. Add support for more Bridge flags and SWITCHDEV_ATTR 3. Add support for ageing configuration 4. More testing and documentation updates Issues: 1. I've not found that configuring VLANs on Bridge port itself bridge vlan add dev br0 vid 100 pvid untagged self does not allow to set PVID on Host P0 port. The only way to set it is to change default_vlan, introduces some mess in ALE table (also causes overwrite of already configfured PVID). bridge vlan add dev sw0p1 vid 100 pvid untagged master ip link set dev br0 type bridge vlan_filtering 0 echo 2 > /sys/class/net/br0/bridge/default_vlan ip link set dev br0 type bridge vlan_filtering 1 (but it could be our mess also:() 2. Are there any way to identify Bridge default_vlan while processing SWITCHDEV_OBJ_ID_PORT_VLAN?? Grygorii Strashko (7): net: ethernet: ti: cpts: use devm_get_clk_from_child net: ethernet: ti: cpsw: move set of common functions in cpsw_priv net: ethernet: ti: cpsw: allow untagged traffic on host port dt-bindings: net: ti: add new cpsw switch driver bindings net: ethernet: ti: cpsw: fix build of cpsw drivers phy: ti: phy-gmii-sel: dependency from ti cpsw-switchdev driver ARM: dts: am57xx-idk: add dt nodes for new cpsw switch dev driver Ilias Apalodimas (4): net: ethernet: ti: cpsw: ale: add functions to modify VLANs/MDBs net: ethernet: ti: cpsw: add switchdev API for cpsw driver net: ethernet: ti: cpsw: introduce cpsw switch driver based on switchdev Documentation: networking: add cpsw switchdev based driver documentation .../bindings/net/ti,cpsw-switch.txt | 117 + .../device_drivers/ti/cpsw_switchdev.txt | 159 ++ arch/arm/boot/dts/am571x-idk.dts | 28 + arch/arm/boot/dts/am57xx-idk-common.dtsi | 2 +- arch/arm/boot/dts/dra7-l4.dtsi | 53 + drivers/net/ethernet/ti/Kconfig | 20 +- drivers/net/ethernet/ti/Makefile | 2 + drivers/net/ethernet/ti/cpsw.c | 596 +----- drivers/net/ethernet/ti/cpsw_ale.c | 199 +- drivers/net/ethernet/ti/cpsw_ale.h | 15 + drivers/net/ethernet/ti/cpsw_new.c | 1891 +++++++++++++++++ drivers/net/ethernet/ti/cpsw_priv.c | 562 ++++- drivers/net/ethernet/ti/cpsw_priv.h | 51 +- drivers/net/ethernet/ti/cpsw_switchdev.c | 394 ++++ drivers/net/ethernet/ti/cpsw_switchdev.h | 22 + drivers/net/ethernet/ti/cpts.c | 2 +- drivers/phy/ti/Kconfig | 4 +- 17 files changed, 3521 insertions(+), 596 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/ti,cpsw-switch.txt create mode 100644 Documentation/networking/device_drivers/ti/cpsw_switchdev.txt create mode 100644 drivers/net/ethernet/ti/cpsw_new.c create mode 100644 drivers/net/ethernet/ti/cpsw_switchdev.c create mode 100644 drivers/net/ethernet/ti/cpsw_switchdev.h -- 2.17.1