Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3642708pxm; Tue, 1 Mar 2022 02:29:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxznJX5fmQ92fIv9xMGM30OxFy4LWcuAM3l/itD3VY5J9XObPofxsSAooiJyZV7NwTg+yYq X-Received: by 2002:a05:6402:847:b0:412:f151:6ad1 with SMTP id b7-20020a056402084700b00412f1516ad1mr23956317edz.36.1646130541429; Tue, 01 Mar 2022 02:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646130541; cv=none; d=google.com; s=arc-20160816; b=FRpYn7sIXCKXpmpo5gBThp8OnSQ72FE/EC8vdVGUmw0nVujx2cVGKC5Nr4RSfilSmh urOUWBaZ5i3c2vfbKYH8zL2hFpG8q5B6e+OVgl933uesCaiPgBBi135zOKIZY+QWjKzj MJxKy0DT+enZ0sNtulZKe82kaqDD/ZsFCY9OtpMnyAOsXwt7DGcmTaHbqwLp3Y5a+9tz hdu6f+axVw9qCguSMrqcAhPtvuPiKwXyEJhRVGU5IEU6g+lLd41zrQaBrnk31bOzSW3I Ck0Vm5wcPV8kKIADi+NQldqLVaH29LnnBjfsEhn89oZGREc8lo92gKFND8PDsMcT+z6f YWmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=1yqD4KQaM9b/j4qTrGplWK9SeozZApe70PduPs9Vk3k=; b=B3h/W0jQckGZHaBCY+UbW/qwcyU7nOxPiLl/G000eLsUc0DdeEED8dsrPAM98YNpLk I3JvHfeb78a0d9o3vD5bJFRaLlzozDTJQGiJzolkejmXdPT6Vyg/x4mu5pLCNjE1OwPv Hh76NyuLQm9DpK+uS3wE2i8mYz0l6aTp2ZnzRG4zbmDYf1O0F5S+c/zSn7JqU0Ak0v4a 1Qaw70tSAT/mbBc0KG2+0iLHL20i5yDlNcMeJIL48X2VZ2V85JnoFY/sa4uVY+k7tHzK RnUlPhFDlzXxVie95nZxH/6Avmu5cA6egNriQ+cw3bib71ZRwxdxScYtrSFYwOYdj0GT vKyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=ok+9qxMt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p24-20020a1709061b5800b006ccc9a66bc8si7571434ejg.289.2022.03.01.02.28.37; Tue, 01 Mar 2022 02:29:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=ok+9qxMt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234095AbiCAKEm (ORCPT + 99 others); Tue, 1 Mar 2022 05:04:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233082AbiCAKEc (ORCPT ); Tue, 1 Mar 2022 05:04:32 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D28C8BF1E for ; Tue, 1 Mar 2022 02:03:49 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id bu29so26077223lfb.0 for ; Tue, 01 Mar 2022 02:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version:organization :content-transfer-encoding; bh=1yqD4KQaM9b/j4qTrGplWK9SeozZApe70PduPs9Vk3k=; b=ok+9qxMt9502Oui1Sb99TSBc1nMun/S4I+2zm9uMBsy9S2ZWqO/7/Wdh7OkhImeF8B TF/J4GXLY3GeZKzuF/0jIH4/jxCxVZxOfqfCdfARMS462dxwd5UVXMkRJVr62Z2gxcgB iopiSpgnOk6Nk7MXlQBCPGh1XpBAhDHzWvZzZif9A9V0oh1PS6qhhAh8X2w2tA9nrwR0 Ua1iyFST+99T1dDsWxCgqJeaeIt4wpUNMJTd+Gl2Z0iF2aJ6E7UdHkub7bDRpT86Cu5c ZQkWSItIfktnccjGPegT9KTh3D/8Qin3tqiCI0SDIRZ3qvAQ3vZ8dEm7cyDqofHrjuFk Hzbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :organization:content-transfer-encoding; bh=1yqD4KQaM9b/j4qTrGplWK9SeozZApe70PduPs9Vk3k=; b=M/KKeIM1o7a8+CuD7uS+AufxPMnilf/ED5GaR54NMItdO/eNhZY0Sb6kxi7rfK1rGE 3tLltLN0YCuRt1ptGNcSohPoopQwwoiuzSudsiDUGnw1EvRM6aA5pi+p+B7yxFC5WPOg Oyu6MKITk61wbutQ6UT8IfbwYW2p7GyHmZQFqf0Yrh1NdlsZuCrb9v73DwLL3aO3tY9Z m6uDiI+qj1hvfdS2SkmKW62iNAGUYF8jv2S0tY0eZxw2wf4HaJE/VMLZ4eIMNgcmCIyP OBV77dYOwu04L/5uvQxI8BXXM5iBDS5Qd686O3lXcUhf74jGh0ALryGxhe7o2KTl3J3A funQ== X-Gm-Message-State: AOAM531pd5JpPZ+y42dYIzIKQWZ3K6jzN6M6laz4y/7Yn+u0V3Qm4dXX yq1WXJs0BwUze1Iv6aFGWg8qYQ== X-Received: by 2002:a05:6512:3caa:b0:443:7e66:b98a with SMTP id h42-20020a0565123caa00b004437e66b98amr15570936lfv.169.1646129027199; Tue, 01 Mar 2022 02:03:47 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id s27-20020a05651c049b00b002460fd4252asm1826822ljc.100.2022.03.01.02.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 02:03:46 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Russell King , Petr Machata , Cooper Lees , Ido Schimmel , Matt Johnston , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bridge@lists.linux-foundation.org Subject: [PATCH v2 net-next 00/10] net: bridge: Multiple Spanning Trees Date: Tue, 1 Mar 2022 11:03:11 +0100 Message-Id: <20220301100321.951175-1-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Organization: Westermo Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bridge has had per-VLAN STP support for a while now, since: https://lore.kernel.org/netdev/20200124114022.10883-1-nikolay@cumulusnetworks.com/ The current implementation has some problems: - The mapping from VLAN to STP state is fixed as 1:1, i.e. each VLAN is managed independently. This is awkward from an MSTP (802.1Q-2018, Clause 13.5) point of view, where the model is that multiple VLANs are grouped into MST instances. Because of the way that the standard is written, presumably, this is also reflected in hardware implementations. It is not uncommon for a switch to support the full 4k range of VIDs, but that the pool of MST instances is much smaller. Some examples: Marvell LinkStreet (mv88e6xxx): 4k VLANs, but only 64 MSTIs Marvell Prestera: 4k VLANs, but only 128 MSTIs Microchip SparX-5i: 4k VLANs, but only 128 MSTIs - By default, the feature is enabled, and there is no way to disable it. This makes it hard to add offloading in a backwards compatible way, since any underlying switchdevs have no way to refuse the function if the hardware does not support it - The port-global STP state has precedence over per-VLAN states. In MSTP, as far as I understand it, all VLANs will use the common spanning tree (CST) by default - through traffic engineering you can then optimize your network to group subsets of VLANs to use different trees (MSTI). To my understanding, the way this is typically managed in silicon is roughly: Incoming packet: .----.----.--------------.----.------------- | DA | SA | 802.1Q VID=X | ET | Payload ... '----'----'--------------'----'------------- | '->|\ .----------------------------. | +--> | VID | Members | ... | MSTI | PVID -->|/ |-----|---------|-----|------| | 1 | 0001001 | ... | 0 | | 2 | 0001010 | ... | 10 | | 3 | 0001100 | ... | 10 | '----------------------------' | .-----------------------------' | .------------------------. '->| MSTI | Fwding | Lrning | |------|--------|--------| | 0 | 111110 | 111110 | | 10 | 110111 | 110111 | '------------------------' What this is trying to show is that the STP state (whether MSTP is used, or ye olde STP) is always accessed via the VLAN table. If STP is running, all MSTI pointers in that table will reference the same index in the STP stable - if MSTP is running, some VLANs may point to other trees (like in this example). The fact that in the Linux bridge, the global state (think: index 0 in most hardware implementations) is supposed to override the per-VLAN state, is very awkward to offload. In effect, this means that when the global state changes to blocking, drivers will have to iterate over all MSTIs in use, and alter them all to match. This also means that you have to cache whether the hardware state is currently tracking the global state or the per-VLAN state. In the first case, you also have to cache the per-VLAN state so that you can restore it if the global state transitions back to forwarding. This series adds a new mst_enable bridge setting (as suggested by Nik) that can only be changed when no VLANs are configured on the bridge. Enabling this mode has the following effect: - The port-global STP state is used to represent the CST (Common Spanning Tree) (1/10) - Ingress STP filtering is deferred until the frame's VLAN has been resolved (1/10) - The preexisting per-VLAN states can no longer be controlled directly (1/10). They are instead placed under the MST module's control, which is managed using a new netlink interface (described in 3/10) - VLANs can br mapped to MSTIs in an arbitrary M:N fashion, using a new global VLAN option (2/10) 4-5/10 adds switchdev notifications so that a driver can track VID to MSTI mappings and MST port states. An offloading implementation is this provided for mv88e6xxx. A proposal for the corresponding iproute2 interface is available here: https://github.com/wkz/iproute2/tree/mst Tobias Waldekranz (10): net: bridge: mst: Multiple Spanning Tree (MST) mode net: bridge: mst: Allow changing a VLAN's MSTI net: bridge: mst: Support setting and reporting MST port states net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations net: bridge: mst: Notify switchdev drivers of MST state changes net: dsa: Pass VLAN MSTI migration notifications to driver net: dsa: Pass MST state changes to driver net: dsa: mv88e6xxx: Disentangle STU from VTU net: dsa: mv88e6xxx: Export STU as devlink region net: dsa: mv88e6xxx: MST Offloading drivers/net/dsa/mv88e6xxx/chip.c | 232 ++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 38 +++ drivers/net/dsa/mv88e6xxx/devlink.c | 94 ++++++ drivers/net/dsa/mv88e6xxx/global1.h | 10 + drivers/net/dsa/mv88e6xxx/global1_vtu.c | 311 ++++++++++-------- include/net/dsa.h | 5 + include/net/switchdev.h | 17 + include/uapi/linux/if_bridge.h | 17 + include/uapi/linux/if_link.h | 1 + include/uapi/linux/rtnetlink.h | 5 + net/bridge/Makefile | 2 +- net/bridge/br_input.c | 17 +- net/bridge/br_mst.c | 402 ++++++++++++++++++++++++ net/bridge/br_netlink.c | 17 +- net/bridge/br_private.h | 31 ++ net/bridge/br_stp.c | 3 + net/bridge/br_switchdev.c | 57 ++++ net/bridge/br_vlan.c | 20 +- net/bridge/br_vlan_options.c | 24 +- net/dsa/dsa_priv.h | 3 + net/dsa/port.c | 40 +++ net/dsa/slave.c | 12 + 22 files changed, 1216 insertions(+), 142 deletions(-) create mode 100644 net/bridge/br_mst.c -- 2.25.1