Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4061011pxm; Tue, 1 Mar 2022 10:24:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWOAlTOS5DxDWsgkDdEMdhvLkXsTsNUB+RxP6vU2oSjWxZW6skX8/U7aUsc86yoK93CeUk X-Received: by 2002:a63:914b:0:b0:373:520f:d03b with SMTP id l72-20020a63914b000000b00373520fd03bmr23105002pge.123.1646159091366; Tue, 01 Mar 2022 10:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646159091; cv=none; d=google.com; s=arc-20160816; b=XjXO/GV3BS1DTUSdca0IY040XUmHNdjD0mQDsprXROWV5l7zaCdHOUetEbGntyZYQK Vl75EurQAN1LM1QJmafbI7UaUCHOAHuxodq90k6GLTJ9WRfR2IE1XlUzggw0uhhHODBV CdNGpi3Abnrxzo7wEEmmvQ9y9FlN7vrvoaLCTXim7bjhAlZznzxgbIU5I3B0nB1+Lhcg qD3iyRuElbptmiQhwt64q3vE39PCr/P9pP1eoqOYfIsEbHj58FJfuRQwm05EsLePzLeM dlTZDrIOVlzIGKD3x8k9Z9bkhwQdk7GxIsQUpfD5BL8d1rnDPqPmwsbgsMhUBCOgws1g XNgQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=az/xSk1cFf+663WFNGMDSdL6ZlzUb+e0Y66c2dIgICk=; b=b2sRpwvmyLWiJ134fKiIizv1DKqWsii/0T4HYpCOCJ5Cl5Z5how0GAoSOABoGIUwcy L+syDjkIHlZ4ypxmPZlIiQfFncvV/mxnyJA7qj+xr7vEvJwTaHrusHUiWYM/nPLmfiry GQO2yv3zdrVRe5oYd1Y8hEcIQ7QHLH0k5MojAXS7arOFWUR8QIw+5gQioBzX1/3662pI 6exbk9Lv7XH57x9O4v0EkPzv1K+PMShh6/78Aky8NKlYr7DUJa9Cerj34JZTyx0Tz+Eq DYqMxB28I8/D0bFVxryQc8NiY8o85yMhfLblkaxMxJZSdYJE1+UY5lmk2oZzCF35B8iT JMnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=BAOoXkp2; 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 a2-20020a170902900200b0015151edbb92si9175644plp.399.2022.03.01.10.24.35; Tue, 01 Mar 2022 10:24:51 -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=BAOoXkp2; 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 S234181AbiCAKEt (ORCPT + 99 others); Tue, 1 Mar 2022 05:04:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234120AbiCAKEe (ORCPT ); Tue, 1 Mar 2022 05:04:34 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9128CD85 for ; Tue, 1 Mar 2022 02:03:53 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id t13so13956003lfd.9 for ; Tue, 01 Mar 2022 02:03:53 -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:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=az/xSk1cFf+663WFNGMDSdL6ZlzUb+e0Y66c2dIgICk=; b=BAOoXkp2k++ip4yaBp/8jKULasDNMBKsbfUiwLa2swzc45xYddCAwlwEjXR/CkAjTQ wCBsk/75rf+PZDUPTGpFI7K70MMZADloPUZuf83G/riFugsxNBll2we87yL/E1xiVKEd 5oZhYXwr5B7Xwv2XyW0x7joHVlq23hwZlvGBaETYqOle7q9uB4/OLLf5UwlkM1o/YTcY flkohhEtgyDl22CNGpQrGrfUZUgkFua8LIT06Tp/j+zlV/PPHoheCUg9VssBL3i4EvfX f1S+TnJ3VtAPRJ4wJKBvVvIJrJtmhHyqaiz+UviJeKLvutwZ8tn2KbR5633jVxCDcood Ac0Q== 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:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=az/xSk1cFf+663WFNGMDSdL6ZlzUb+e0Y66c2dIgICk=; b=Zu6uATdIhE5IcnbgfGUYuHhfAUSXR+p/9AupBhWrs/GLMZWVMw19OOoGOXPfUIH5hb xuJa5g/2c4IUZB+1rFjC3zgk9YTWoufb99sAma8RRuOP4xMK45htPn+nASaJylZrcXkQ cuPo7z0kTzZgaH12MAdWBIHEqZ1Mem+YoxGH0Eg+slaP5Flqozq1qcEYcQyLv9buJJrm EFaM/qHQRIqNjikhVnUcWP5DP+GAnDyh3kslZ80gT7AWujzaHXeNPECZRHIUpLKi+wGI qZJDnSzCNE3rAZ+8CXbKQ3LEiuOqDKk37ej2/JlZCK9zaUxglbF6Qgg6aOPAg+wBU8eD jHPA== X-Gm-Message-State: AOAM530rjL8WPqN6s0XycL3WbLvxps1GSP+4sf/JtWzTbNPuS+H5kkt+ W/zVNyoSl/VLT1WsOL4fE8S3xg== X-Received: by 2002:a05:6512:22c4:b0:43a:13a8:7e55 with SMTP id g4-20020a05651222c400b0043a13a87e55mr15155916lfu.296.1646129031409; Tue, 01 Mar 2022 02:03:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 02:03:51 -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 04/10] net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations Date: Tue, 1 Mar 2022 11:03:15 +0100 Message-Id: <20220301100321.951175-5-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220301100321.951175-1-tobias@waldekranz.com> References: <20220301100321.951175-1-tobias@waldekranz.com> 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 Whenever a VLAN moves to a new MSTI, send a switchdev notification so that switchdevs can... ...either refuse the migration if the hardware does not support offloading of MST... ..or track a bridge's VID to MSTI mapping when offloading is supported. Signed-off-by: Tobias Waldekranz --- include/net/switchdev.h | 10 +++++++ net/bridge/br_mst.c | 15 +++++++++++ net/bridge/br_switchdev.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 3e424d40fae3..39e57aa5005a 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -28,6 +28,7 @@ enum switchdev_attr_id { SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED, SWITCHDEV_ATTR_ID_BRIDGE_MROUTER, SWITCHDEV_ATTR_ID_MRP_PORT_ROLE, + SWITCHDEV_ATTR_ID_VLAN_MSTI, }; struct switchdev_brport_flags { @@ -35,6 +36,14 @@ struct switchdev_brport_flags { unsigned long mask; }; +struct switchdev_vlan_attr { + u16 vid; + + union { + u16 msti; + }; +}; + struct switchdev_attr { struct net_device *orig_dev; enum switchdev_attr_id id; @@ -50,6 +59,7 @@ struct switchdev_attr { u16 vlan_protocol; /* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled; /* MC_DISABLED */ u8 mrp_port_role; /* MRP_PORT_ROLE */ + struct switchdev_vlan_attr vlan_attr; /* VLAN_* */ } u; }; diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c index 8dea8e7257fd..aba603675165 100644 --- a/net/bridge/br_mst.c +++ b/net/bridge/br_mst.c @@ -7,6 +7,7 @@ */ #include +#include #include "br_private.h" @@ -65,9 +66,23 @@ static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) int br_mst_vlan_set_msti(struct net_bridge_vlan *mv, u16 msti) { + struct switchdev_attr attr = { + .id = SWITCHDEV_ATTR_ID_VLAN_MSTI, + .flags = SWITCHDEV_F_DEFER, + .orig_dev = mv->br->dev, + .u.vlan_attr = { + .vid = mv->vid, + .msti = msti, + }, + }; struct net_bridge_vlan_group *vg; struct net_bridge_vlan *pv; struct net_bridge_port *p; + int err; + + err = switchdev_port_attr_set(mv->br->dev, &attr, NULL); + if (err && err != -EOPNOTSUPP) + return err; mv->msti = msti; diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index 6f6a70121a5e..160d7659f88a 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -428,6 +428,57 @@ static int br_switchdev_vlan_replay(struct net_device *br_dev, return 0; } +static int br_switchdev_mst_replay(struct net_device *br_dev, + const void *ctx, bool adding, + struct notifier_block *nb, + struct netlink_ext_ack *extack) +{ + struct switchdev_notifier_port_attr_info attr_info = { + .info = { + .dev = br_dev, + .extack = extack, + .ctx = ctx, + }, + }; + struct net_bridge *br = netdev_priv(br_dev); + struct net_bridge_vlan_group *vg; + struct net_bridge_vlan *v; + int err; + + ASSERT_RTNL(); + + if (!nb) + return 0; + + if (!netif_is_bridge_master(br_dev)) + return -EINVAL; + + vg = br_vlan_group(br); + + list_for_each_entry(v, &vg->vlan_list, vlist) { + struct switchdev_attr attr = { + .id = SWITCHDEV_ATTR_ID_VLAN_MSTI, + .flags = SWITCHDEV_F_DEFER, + .orig_dev = br_dev, + .u.vlan_attr = { + .vid = v->vid, + .msti = v->msti, + } + }; + + if (!v->msti) + continue; + + attr_info.attr = &attr; + err = nb->notifier_call(nb, SWITCHDEV_PORT_ATTR_SET, &attr_info); + err = notifier_to_errno(err); + if (err) + return err; + } + + return 0; +} + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING struct br_switchdev_mdb_complete_info { struct net_bridge_port *port; @@ -695,6 +746,10 @@ static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx, if (err && err != -EOPNOTSUPP) return err; + err = br_switchdev_mst_replay(br_dev, ctx, true, blocking_nb, extack); + if (err && err != -EOPNOTSUPP) + return err; + err = br_switchdev_mdb_replay(br_dev, dev, ctx, true, blocking_nb, extack); if (err && err != -EOPNOTSUPP) @@ -719,6 +774,8 @@ static void nbp_switchdev_unsync_objs(struct net_bridge_port *p, br_switchdev_mdb_replay(br_dev, dev, ctx, false, blocking_nb, NULL); + br_switchdev_mst_replay(br_dev, ctx, false, blocking_nb, NULL); + br_switchdev_vlan_replay(br_dev, ctx, false, blocking_nb, NULL); } -- 2.25.1