From patchwork Thu May 24 06:56:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 136709 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1823617lji; Wed, 23 May 2018 23:56:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmXDR3aDg6dEtVK06ExhhLr5mvootmB6AbgiGw3UD1Plpq0WuNWC++8l1R02J5Pp3HRPL1 X-Received: by 2002:a17:902:9b83:: with SMTP id y3-v6mr6165748plp.263.1527145000141; Wed, 23 May 2018 23:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527145000; cv=none; d=google.com; s=arc-20160816; b=QS1DinTjnC9EApTmwsFuaNOw2MHWGg9K6kyT99gQVzWR3wIZwpELdgP3g0LNugUPew o2Ri9mnJ/XSzoSw93Z24maKmq/otL+ZCTDVJ2W+ayKP9XHhW4/OAElUkQ8GvV2kAvlIu HalxWTR6A/LzX1Mmro1OZsbZGsfzEDeY04yDwPL6TUb6AsFzHHEy9RSPfL0fccVmhmhT dlIXSijZS+qJLyAdQUhXcyFg5ZvDagUyhRhOzYToaHbggeffopa7LFbdbyL6BskGLNeC FIlWmSx87EwS1LXx9OPZBm99+pXF87pPLnz04ZHNT+RYeCvhIG9aMI0ap6NSclaA5tUp tyLA== 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=LWlMrwz6F2BbpUVdSTnQ79HhXe/eGhr20HU874DrZIo=; b=kIT6WJAqITnR1HOYWIR4wbi2aNcAtFOviWwJbwPCxEkistv/hajVqJZV0vmM0D71hJ Bt/VewHyU852ztw8B4+l+ZOstZ+OyOmUYWT3tsxdJJ3fGPT9s/ATBbkncaP/kPbrCJPp LhEkyOdCJoDIwPS4Ypfs9EjQkpUClVgs0gbC0qMUhmdsdgelf/0KhEouFovdQGdYiACt JJeoVD6+OdWb/sYkbRn/1H0NMud8YOpYGMieo5FWX0UGuln2aJMeGqkSMD4hnffVWw69 Qvdn24ubhaG/gPoFMQJYE/TWZDYw5al43NkhZJwLO7yR0YwHdfOhnWMQpr7GQ3pgFpAa DKvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h382HqH5; 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 v2-v6si8349741plo.577.2018.05.23.23.56.39; Wed, 23 May 2018 23:56:40 -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=h382HqH5; 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 S935617AbeEXG4h (ORCPT + 9 others); Thu, 24 May 2018 02:56:37 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38130 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935530AbeEXG4g (ORCPT ); Thu, 24 May 2018 02:56:36 -0400 Received: by mail-wm0-f66.google.com with SMTP id m129-v6so1992858wmb.3 for ; Wed, 23 May 2018 23:56:35 -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=LWlMrwz6F2BbpUVdSTnQ79HhXe/eGhr20HU874DrZIo=; b=h382HqH51z+h7G6VyP6A1Md9lyaWL6lDO7WfCKtBy8ooyOYoAWMjjVwc+4yJvoOKiP iFRJpvu+cpSmbtU0jHa8SmIrHeSx6ht8idlp9YA1nQqXFjBg7lPZHm8XgXV+zT75QhrU EvQ8gjKzQzRLSEGlUXcgdZ/koDQ0W5e/9We7A= 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=LWlMrwz6F2BbpUVdSTnQ79HhXe/eGhr20HU874DrZIo=; b=h7qNu8YJsxCW0Qs1RxBaPXjoAXlQ4dMCY1wQUwJW3J525Yo66jInyibzfVMsyE93g/ pl7Zbsa8Wqj2NCsZlsJK2tyvyYhryXDGpKIIq0fxmSXsOkXUM++b/0XHpiU18K0qefkH 0CY/QdXAeLaJOJ71Qj/a/4r6FjJKbuqImBnI69iJM1dH9ZGztsu1smRd6P7I2E/MGqe1 It8IajjDQyIryONnudXy81WeAAxA6qGhY6v7KdPbF1BDx/BkSjxtX2HvoZF/O2ey6vMY W6EGF25ct7Vi8er2AZeQ+mj//KZgo42gaRthidiXNJDAZfzpYVQDJJKOpM1G8U6E6+ZX 0s0w== X-Gm-Message-State: ALKqPwdGy49WwfJiomDjSlV0ipA8uEF2J+whQlznkSqHJ0EnLTG90d1B AectG3IRcgBwpVZNkpQv1zgWWzxP6P8= X-Received: by 2002:a1c:16ca:: with SMTP id 193-v6mr5954667wmw.37.1527144994527; Wed, 23 May 2018 23:56:34 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:460a:f200:b540:ba10:add4:9422]) by smtp.gmail.com with ESMTPSA id t198-v6sm4795257wmt.23.2018.05.23.23.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 23:56:33 -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 Cc: francois.ozog@linaro.org, yogeshs@ti.com, spatton@ti.com, Ilias Apalodimas Subject: [PATCH 0/4] RFC CPSW switchdev mode Date: Thu, 24 May 2018 09:56:20 +0300 Message-Id: <1527144984-31236-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 is adding a new mode on the cpsw driver based around switchdev. In order to enable this you need to enable CONFIG_NET_SWITCHDEV, CONFIG_BRIDGE_VLAN_FILTERING, CONFIG_TI_CPSW_SWITCHDEV and add 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 sw0p0 | grep switchid' and replace with the correct value. This patch creates 3 ports, sw0p0, sw0p1 and sw0p2. sw0p1 and sw0p2 are the netdev interfaces connected to PHY devices while sw0p0 is the switch 'cpu facing port'. sw0p0 will be unable to receive and transmit traffic and it's not 100% within switchdev scope but, it's used to configure switch cpu port individually as this is needed for various switch features and configuration scenarios. 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 sw0p0 up ip link set dev sw0p0 master br0 ip link set dev sw0p2 master br0 ip link set dev sw0p1 master br0 ip link set br0 address $(cat /sys/class/net/sw0p1/address) 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: bridge vlan add dev br0 vid 100 pvid untagged self bridge vlan add dev sw0p0 vid 100 pvid untagged master udhcpc -i br0 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: single vlan: bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent vid 100 all vlans: bridge mdb add dev br0 port sw0p2 grp 239.1.1.1 permanent bridge mdb add dev br0 port sw0p0 grp 239.1.1.1 permanent Multicast: setting multicast on and off will affect registered multicast setting allmulti on and off will affect unregistered multicast 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. Promiscuous mode: Adding/removing sw0p0 on the bridge will enable/disable ALE_P0_UNI_FLOOD 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 sw0p0 up ip link set dev sw0p0 master br0 ip link set dev sw0p2 master br0 ip link set dev sw0p1 master br0 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 This is on top of 4.17-rc2 tree. P.S: I am not 100% sure that the promiscuity handling is correct. Please let me know if i should change anything on that Ilias Apalodimas (4): cpsw: move common headers definitions to cpsw_priv.h cpsw_ale: add support functions for switchdev cpsw_switchdev: add switchdev support files cpsw: add switchdev support drivers/net/ethernet/ti/Kconfig | 9 + drivers/net/ethernet/ti/Makefile | 1 + drivers/net/ethernet/ti/cpsw.c | 610 ++++++++++++++++++++++--------- drivers/net/ethernet/ti/cpsw_ale.c | 129 +++++++ drivers/net/ethernet/ti/cpsw_ale.h | 8 + drivers/net/ethernet/ti/cpsw_priv.h | 148 ++++++++ drivers/net/ethernet/ti/cpsw_switchdev.c | 299 +++++++++++++++ drivers/net/ethernet/ti/cpsw_switchdev.h | 4 + 8 files changed, 1039 insertions(+), 169 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