From patchwork Thu Jun 14 11:11:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 138551 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1968348lji; Thu, 14 Jun 2018 04:11:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJXeSWC3a0r2CTR3vmxSY+WCdFMWnIipdsjFmFfj0mV+sWNPgLFy0YoHcsx31U7Q7f80pO0 X-Received: by 2002:a65:4784:: with SMTP id e4-v6mr1915426pgs.58.1528974705501; Thu, 14 Jun 2018 04:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528974705; cv=none; d=google.com; s=arc-20160816; b=Oh05QOb8VHHoVhT8Slm6Gc8DsvsIvxidFX8G0ALjELLf30Ojw6IHF/wnnt2NLfVRSr IaIBsS2UvTJ21R+o6aZLy++FRBGE2JQB+gQNADpZzrXJUpmpQQ0Fl9hJefL8GyPA2fXC c1JUwA5xLQoUhBP9QUUa+zhA2BB+PIhooct/muDFRGv0d4SnsROye3GmQS1GfDpCUiy/ hZtpuG3juEsjL6ZsXxUNEhJ4RVleKLe7yF2Fhr8jUjwv5hMwltZZJrKPd7DTtgCQcLXk 4qe9I500v59iJC9mdZZvOE6gvBCqN7pB4uD0/EBXUMb9q2MzJfmOydP0Q+seH+OQ3nXo Npnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ok4t3xKxtcedPlWNYW3NxmpKjTKHclbnVY3QymU3cVY=; b=B8U6Ae03DrFtrpuYocB8aUJsWzmFFOYUR9q1pACetM6RPeSDpe+rzz1GdR9NuxG+DU Bl/U7QB7Fo3E3Ruob+kFHOaLXW5CzDh4rHv88/ZEHZJ7nZGBC8ZIpdO3zsgc646fFIN2 /mD6Ej9mCGbRuxtOjW1D2jLoBDe+RZbxb0Fnafhd3yYjRlEG03sDMx0uZD9pZIJQ6+Et rS2/doC96IjMugs1OlDcCz40UA/emCIoAFSrybWWsixy4DCTr977v/TXkLZDW68IgIQn r8Q9+8Yh7iVHc+3F5/wefP7l0eFy/wGn6XceSHqSAtbMc7U2+zFIcpoMSIwvaR35LZxi guew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CVBLJLPQ; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y83-v6si5037554pfb.284.2018.06.14.04.11.45; Thu, 14 Jun 2018 04:11:45 -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=@linaro.org header.s=google header.b=CVBLJLPQ; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754956AbeFNLLn (ORCPT + 9 others); Thu, 14 Jun 2018 07:11:43 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:38010 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754809AbeFNLLl (ORCPT ); Thu, 14 Jun 2018 07:11:41 -0400 Received: by mail-wr0-f178.google.com with SMTP id e18-v6so5991788wrs.5 for ; Thu, 14 Jun 2018 04:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ok4t3xKxtcedPlWNYW3NxmpKjTKHclbnVY3QymU3cVY=; b=CVBLJLPQrMShfE5S0g6sssvzyMjdM017JzbviYo0J+VASx/OdkgjGfoL409X/BWqdI mnK/jIvpiXa1Li8UzZFwIBBwGcXy37ILuKzbHjJ1b20rLjcGm46m0RWNIw14jVLI7oJC axAi8tdVP6MVH+SSGaSC0ABBZY+TSOJtwlP0A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ok4t3xKxtcedPlWNYW3NxmpKjTKHclbnVY3QymU3cVY=; b=VC4x9/fL0jsuOd1di0Mi+BgDtGQR8d/YO2BYw9ccPKY2eux5ZWt1LKgCKIku++5UKZ cgLAY4fq8iZA2aK27BPT5GwoedDdCZKRfZU8Nc6zMI/ru2IB+vXwJ6wu3ILVjgr4EhwF nwZdB33v7EDcmNjzk3g7pRONftOtmiHIE41U+SIP35iD2m5bpFGWKNWDLsF8Y21lkD5c PonlMGErtFVmYE0kS88JhjP9b9N+QBkIMWj9ANPK17L5+K542BPxkc+t5/YgEt4rqTl1 fYedo4emHKuvmpfNHDnyNh6ughPTZrEDcFO4dYfhsSXTUQaVU1wddtWf8fu0sETkdmH4 cNtg== X-Gm-Message-State: APt69E2qKRmDy5h05nY/deQGAjPvdKgZ/pWSLQC5zIo4FxLldmXL+hed lBl/OGYz7oyk2EAkILo70BOlCOroz9Y= X-Received: by 2002:adf:b445:: with SMTP id v5-v6mr1755471wrd.67.1528974699838; Thu, 14 Jun 2018 04:11:39 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:4609:4e00:6c01:5076:e5d5:7a4c]) by smtp.gmail.com with ESMTPSA id t124-v6sm3657466wmt.29.2018.06.14.04.11.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jun 2018 04:11:39 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, grygorii.strashko@ti.com, ivan.khoronzhuk@linaro.org, nsekhar@ti.com, jiri@resnulli.us, ivecera@redhat.com, andrew@lunn.ch, f.fainelli@gmail.com Cc: francois.ozog@linaro.org, yogeshs@ti.com, spatton@ti.com, Jose.Abreu@synopsys.com, Ilias Apalodimas Subject: [RFC v2, net-next, PATCH 0/4] Add switchdev on TI-CPSW Date: Thu, 14 Jun 2018 14:11:26 +0300 Message-Id: <1528974690-31600-1-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hello, This the RFC v2 which does not register the CPU port based on net-next. I didn't manage to rewrite the driver and splitting it to common library-old-new but, i did reorganize the patches a bit based on Andrew's suggestions. Hopefully it's easier to read. patch #1: Prepares headers files and move common code to cpsw_priv.h. patch #2: Adds functions to ALE for modifying VLANs/MDBs. patch #3: Prepares cpsw driver for switchdev mode, without changing any of the funtionality. patch #4: Adds new mode of operation based on switchdev. In order to enable this you need enable CONFIG_NET_SWITCHDEV, CONFIG_BRIDGE_VLAN_FILTERING, CONFIG_TI_CPSW_SWITCHDEV and add this to udev config: SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}=="0f011900", \ ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}" Since the phys_switch_id is based on cpsw version, users with different version will need to do 'ip -d link show dev sw0p1 | grep switchid' and replace with the correct value. This patch creates 2 ports, sw0p1 and sw0p2 both connected to PHYs. Bridge setup: 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 1 ip link set dev sw0p1 up ip link set dev sw0p2 up ip link set dev sw0p1 master br0 ip link set dev sw0p2 master br0 ifconfig br0 up - VLAN config: untagged: bridge vlan add dev sw0p1 vid 100 pvid untagged master bridge vlan add dev sw0p2 vid 100 pvid untagged master tagged: bridge vlan add dev sw0p1 vid 100 master bridge vlan add dev sw0p2 vid 100 master IP address on br0: This will add VLAN 100 on the cpu port. bridge vlan add dev br0 vid 100 pvid untagged self udhcpc -i br0 - FDBs: FDBs are automatically added on the appropriate switch port uppon detection Manually adding FDBs: bridge fdb add aa:bb:cc:dd:ee:ff dev sw0p1 master vlan 100 bridge fdb add aa:bb:cc:dd:ee:fe dev sw0p2 master - MDBs: MDBs are automatically added on the appropriate switch port uppon detection Manually adding MDBs: bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent vid 100 - Multicast testing client-port1(tagged on vlan 100) server-port1 switch-config is provided by TI (https://git.ti.com/switch-config) and is used to verify correct switch configuration. 1. switch-config output - type: vlan , vid = 100, untag_force = 0x4, reg_mcast = 0x6, unreg_mcast = 0x0, member_list = 0x6 Server running on sw0p2: iperf -s -u -B 239.1.1.1 -i 1 Client running on sw0p1: iperf -c 239.1.1.1 -u -b 990m -f m -i 5 -t 3600 No IGMP reaches the CPU port to add MDBs(since CPU does not receive unregistered multicast as programmed). If the MDB is added manually via: bridge mdb add dev br0 port sw0p2 grp 239.1.1.1 permanent vid 100 or unregistered flooding is enabled via: bridge link set dev sw0p2 mcast_flood on Multicast traffic is offloaded as expected. 2. switch-config output - type: vlan , vid = 100, untag_force = 0x7, reg_mcast = 0x7, unreg_mcast = 0x1, member_list = 0x7 In this case CPU port receives the IGMP message and programs the switch accordingly. tcpdump on br0 shows no packets. If the MDB entry is removed with "bridge mdb del dev br0 port sw0p1 grp 239.1.1.1 permanent" br0 is flooded with multicast packets correctly(since unreg multicast is set for the CPU port). If the the mdb entry is manually added tcpdump shows no packets and multicast offloading starts working again. root@ti:~# bridge mdb show dev br0 port sw0p1 grp ff02::fb temp offload vid 100 dev br0 port sw0p1 grp 239.1.1.1 temp offload vid 100 root@ti:~# switch-config -d type: mcast, vid = 100, addr = 01:00:5e:01:01:01, mcast_state = f, \ no super, port_mask = 0x2 - Multicast testing server-port0 client-port1 CPU port(port 0) does not show on bridge mdb show Using ti's switch-config to dump the switch status shows that the MDB is installed correctly. root@ti:~# switch-config -d type: mcast, vid = 100, addr = 01:00:5e:01:01:01, mcast_state = f, \ no super, port_mask = 0x1 - registered multicast: Setting on/off and IFF_MULTICAST (on eth0/eth1/br0) will affect registered multicast masks programmed in the switch(for port1, port2, cpu port respectively). This muct occur before adding VLANs on the interfaces. If you change the flag after the VLAN configuration you need to re-issue the VLAN config commands. If CPU port is participating the proper VLANs MDBs/FDBs will be offloaded by the switch as described in switchdev API. This will also be reflected on "bridge vlan/fdb/mdb show" command(in case the host sends the join the mdb entry won't show there, but ALE status confirms that it's added). - NFS: The only way for NFS to work is by chrooting to a minimal environment when switch configuration that will affect connectivity is needed. Assuming you are booting NFS with eth1 interface(the script is hacky and it's just there to prove NFS is doable). setup.sh: #!/bin/sh mkdir proc mount -t proc none /proc ifconfig br0 > /dev/null if [ $? -ne 0 ]; then echo "Setting up bridge" 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 1 ip link set eth1 down ip link set eth1 name sw0p1 ip link set dev sw0p1 up ip link set dev sw0p2 up ip link set dev sw0p2 master br0 ip link set dev sw0p1 master br0 bridge vlan add dev br0 vid 1 pvid untagged self ifconfig sw0p1 0.0.0.0 udhchc -i br0 fi umount /proc run_nfs.sh: #!/bin/sh mkdir /tmp/root/bin -p mkdir /tmp/root/lib -p cp -r /lib/ /tmp/root/ cp -r /bin/ /tmp/root/ cp /sbin/ip /tmp/root/bin cp /sbin/bridge /tmp/root/bin cp /sbin/ifconfig /tmp/root/bin cp /sbin/udhcpc /tmp/root/bin cp /path/to/setup.sh /tmp/root/bin chroot /tmp/root/ busybox sh /bin/run_nfs.sh run ./run_nfs.sh - Current issues/future work: 1. For this hardware and it's applications it's essential to control the CPU port individually. After removing the CPU port we lost the ability to control unregistered multicast traffic flags. This code unconditionally(if it participates on that VLAN) adds CPU port on the unregistered multicast mask, while for ports 1 and 2 this is configurable via: "bridge link set dev eth1 mcast_flood on/off" Petr Machata introduced a funtionality on VLANs(9c86ce2c1ae337fc10568a12aea812ed03de8319) where the command "bridge vlan add dev br0 vid 100 pvid untagged self" is propagated to the driver and allows us to configure the CPU port. Adding something similar for MDBs i.e "bridge link set dev br0 mcast_flood on self" that reaches the driver is an idea on how to control the CPU port independently and removing the need to add/remove the CPU port on the vlan group for this to happen. 2. VLAN CoS is always set to 0 3. Add support for ageing configuration 4. ALE_P0_UNI_FLOOD can be controlled via: "bridge link set dev br0 flood on self" if this propagates to the driver as well. 5. Add documentation for CPSW configuration on the patch - Changes since RFC v1: - Removed CPU port registration. User can now add CPU port VLANs with "bridge vlan add/del dev br0 vid 100 pvid untagged self". - Removing VLANs will modify registered/unregistered multicast port masks properly. - ALE_P0_UNI_FLOOD is controlled from bridge members. As long as the bridge has members(switch interfaces) this will be enabled. - added management for SWITCHDEV_OBJ_ID_HOST_MDB to control MDBs for the CPU port. - Added STP support. - Added multicast flood support. CPU port is always enabled for now. Ilias Apalodimas (4): net/cpsw: move common headers definitions to cpsw_priv.h net/cpsw_ale: add functions to modify VLANs/MDBs net/cpsw: prepare cpsw for switchdev support net/cpsw_switchdev: add switchdev mode of operation on cpsw driver drivers/net/ethernet/ti/Kconfig | 9 + drivers/net/ethernet/ti/Makefile | 1 + drivers/net/ethernet/ti/cpsw.c | 555 ++++++++++++++++++++++--------- drivers/net/ethernet/ti/cpsw_ale.c | 188 ++++++++++- drivers/net/ethernet/ti/cpsw_ale.h | 10 + drivers/net/ethernet/ti/cpsw_priv.h | 148 +++++++++ drivers/net/ethernet/ti/cpsw_switchdev.c | 418 +++++++++++++++++++++++ drivers/net/ethernet/ti/cpsw_switchdev.h | 4 + 8 files changed, 1167 insertions(+), 166 deletions(-) create mode 100644 drivers/net/ethernet/ti/cpsw_priv.h create mode 100644 drivers/net/ethernet/ti/cpsw_switchdev.c create mode 100644 drivers/net/ethernet/ti/cpsw_switchdev.h -- 2.7.4