Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp110319pxp; Wed, 16 Mar 2022 01:26:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqFtczHJV9ZdEC4AftxpIXRGVzmBfiufoTGyB5kkmgyRyFthK8OwJXKKIrZqHk1ARzL48J X-Received: by 2002:a17:906:26c6:b0:6da:ecd5:fd48 with SMTP id u6-20020a17090626c600b006daecd5fd48mr25113516ejc.93.1647419179216; Wed, 16 Mar 2022 01:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647419179; cv=none; d=google.com; s=arc-20160816; b=DcFhqKMX14CTCENzHRGpX+8V3Y9d5siWXbbiighClsWvKPEr3byzHt4nw+8WQLKyQ4 JWbDjWiTSxYJDJE+AVNu0Z2cdfKbxcI4FIRj7nfkBAtAfI6x2AlKz9LZy9PW1KoOI1UU +DVcDsdBPC6T6lr3Ew6pCtUYD+V7HUXldRN8W8EybWWc6XK+c59ZjU6OLg/XjV4bBSte jpgj5X4CatDlM5OHpd2XiXkzCiJ8vjlvtfAHFMLnXPPPn1g2ZNyPhjWeYqb4d+7IYbez y7G9KCo0J7HFg4IHI58xMyHbHQ6vvDIGbgjDVe/x0Ys/WZ7ZP9DyHS/fqSTDgv9sfpGV buMA== 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=xMFvgybvJF3VqtR+/cQDnuYW+EVkWBbAn5g045aqjjs=; b=Wmvx0pgLKlLw9x1TBIVU9a5LntjjSxQErHgZCgrccnnSc9VwP/wGi4pmur54HXG/uC U57aiPl8PJmOk+FBk7sfaXBnGvDddPjQl+R5u5XvYVCpBWwoc7O13caqBpCT+1YKwWXi bxmcL9e8/avoxlZOy3/dyn/OhbZFoIBoYeD6j5RM8mSyxxpa+y+8Tv6ljf5A3lFMwmFK THw5UA6eH7CW+XY+OrGHkUxAD6bmiHHX92uItFe537oIJ+ArZ49YqMXQYAVfkjw1XPag RTu7YWvy8kAmWBV87FuRaF6N/3nwS5deMReEpmfRmoxUkMLDP0f3/qX0Itkw5mfm8WxS djhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=EhJVlZkV; 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 b10-20020a170906834a00b006df839f0afcsi208294ejy.518.2022.03.16.01.25.53; Wed, 16 Mar 2022 01:26:19 -0700 (PDT) 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=EhJVlZkV; 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 S238134AbiCNJyK (ORCPT + 99 others); Mon, 14 Mar 2022 05:54:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237396AbiCNJyH (ORCPT ); Mon, 14 Mar 2022 05:54:07 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 276E9C62 for ; Mon, 14 Mar 2022 02:52:56 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id o6so20981930ljp.3 for ; Mon, 14 Mar 2022 02:52:56 -0700 (PDT) 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=xMFvgybvJF3VqtR+/cQDnuYW+EVkWBbAn5g045aqjjs=; b=EhJVlZkVs2Xkt4rI91TPXAMB8GE5CuQUnrCjhdqKM78NXlyd2KT1xa82G7L123WaK4 sk+8gBjWJv/tz4QeL1Wj2ho7VlzGU6i3j/G9L2MfSyrbKbMyeZrvxhN3qFhFz75VqsQj 8HtZfXOQqy3Jwp0oWGeypz0WosQYneZa++8U1Vm+DTPm893QA9d+V8bZjOjsv2XlsIdr RMuszCzrq10aoOump6Bg3MqM0FCzi6vlLY2ofwGR2lUb3yIQnI3vMEWAlBIgGq0oHFil Vuklcxa6QrwBecnnMQhxSpVw34ML5gGET07e3S60l21BxgxZ7AJD8kRAP6OldLkM8Yrg obrQ== 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=xMFvgybvJF3VqtR+/cQDnuYW+EVkWBbAn5g045aqjjs=; b=gOPTwFtDgo7uco1vBXBUKph5yOGEinLKXD4nXScDyEEw9yZ8iSmoVR846vM7KxdxyP w22jYpWODIgb96uyCOlrB4B8in5U/pdYnRrmT4nqN9/B/J07wkalF+1OmuEQHE3ht8sv E4XMIxhrGx9kMJMnNR6YjWqZpGzmCTynT//I3s/O4nRmg2AZjF6I6hFYVfdcyiJCZGVx LvCUCaRMYBWGxErLF0AzPQtfOVA8VRg37s9qIQXlQYLrp5wiPYhMUV8X2pnBj4RaOMym LHlvfbV3i3ylrLBovJMiqio9njHgTVGQP3f+pdcYD7She4tkZzIfToA8k1KNhS7MpFuY Jckg== X-Gm-Message-State: AOAM5307bh9XhkkaKRESsSBTL21cYT1kdTpeNm3PesxWsycRajnnk7sv rK7jdjhesBE9SNzfmY5tOSOsl/mJ7RzIAZcN X-Received: by 2002:a05:651c:171b:b0:248:c74:76f0 with SMTP id be27-20020a05651c171b00b002480c7476f0mr12705190ljb.106.1647251574338; Mon, 14 Mar 2022 02:52:54 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id b3-20020a056512304300b004488e49f2fasm984870lfb.129.2022.03.14.02.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 02:52:53 -0700 (PDT) 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 , Ido Schimmel , Petr Machata , Cooper Lees , Matt Johnston , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bridge@lists.linux-foundation.org Subject: [PATCH v3 net-next 00/14] net: bridge: Multiple Spanning Trees Date: Mon, 14 Mar 2022 10:52:17 +0100 Message-Id: <20220314095231.3486931-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/14) - Ingress STP filtering is deferred until the frame's VLAN has been resolved (1/14) - The preexisting per-VLAN states can no longer be controlled directly (1/14). They are instead placed under the MST module's control, which is managed using a new netlink interface (described in 3/14) - VLANs can br mapped to MSTIs in an arbitrary M:N fashion, using a new global VLAN option (2/14) Switchdev notifications are added so that a driver can track: - MST enabled state - VID to MSTI mappings - 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 v2 -> v3: Bridge: - Use new boolopt API to enable/disable the MST mode (Nik) - Mark br_mst_vlan_set_state as static (Vladimir) - Avoid updates/notifications on repeated VLAN to MSTI mapping configurations (Vladimir) - Configure MSTI states via the existing RTM_GET/SETLINK interface (Roopa) - Refactor switchdev replay logic (Vladimir) - Send switchdev notifications when enabling/disabling MST (Vladimir) DSA: - Align VLAN MSTI callback with existing APIs (Vladimir) - Only flush entries in the affected VLANs when changing an MST state (Vladimir) - Refuse offloading, unless all required ops are implemented (Vladimir) mv88e6xxx: - Always keep the driver's MST state in sync with hardware (Vladimir) - Fix SID leaks (Vladimir) - Only flush entries in the affected VLANs when changing an MST state (Vladimir) v1 (RFC) -> v2: - Add a separate MST mode that is distinct from the exiting per-VLAN state functionality - Control MSTI states explicitly, rather than via an associated VLAN Tobias Waldekranz (14): 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 MST mode changes net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations net: bridge: mst: Notify switchdev drivers of MST state changes net: bridge: mst: Add helper to map an MSTI to a VID set net: bridge: mst: Add helper to check if MST is enabled net: dsa: Validate hardware support for MST net: dsa: Pass VLAN MSTI migration notifications to driver net: dsa: Handle MST state changes 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 | 305 ++++++++++++++++++++++- 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/linux/if_bridge.h | 11 + include/net/dsa.h | 6 + include/net/switchdev.h | 16 ++ include/uapi/linux/if_bridge.h | 19 ++ include/uapi/linux/rtnetlink.h | 1 + net/bridge/Makefile | 2 +- net/bridge/br.c | 5 + net/bridge/br_input.c | 17 +- net/bridge/br_mst.c | 310 +++++++++++++++++++++++ net/bridge/br_netlink.c | 32 ++- net/bridge/br_private.h | 43 ++++ net/bridge/br_stp.c | 3 + net/bridge/br_switchdev.c | 46 ++++ net/bridge/br_vlan.c | 20 +- net/bridge/br_vlan_options.c | 20 ++ net/dsa/dsa_priv.h | 6 + net/dsa/port.c | 99 +++++++- net/dsa/slave.c | 18 ++ 23 files changed, 1281 insertions(+), 151 deletions(-) create mode 100644 net/bridge/br_mst.c -- 2.25.1