Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1652181pxm; Fri, 4 Mar 2022 00:27:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsOgtqtzzmAs6h75py55nYCQxKTPKJaPz/JCWguiexAmQN7uj8IWFzSQMGd4HsYejGaW5m X-Received: by 2002:a17:90b:1c86:b0:1bf:2a7e:5c75 with SMTP id oo6-20020a17090b1c8600b001bf2a7e5c75mr1224567pjb.145.1646382443385; Fri, 04 Mar 2022 00:27:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646382443; cv=none; d=google.com; s=arc-20160816; b=V1g/BSX2X1QEb4lwkWTWMru37wF65jJEvWf8t3pjnXOfeVBYN7+FAfZO9qqrDzjaP/ EirVBfICjxRYMKRKdbBSIQ9+wYrP3jApKdZCRx1U4VKssnBnqP1Ffwfy1p/f7gIbY5dP izbRD7TgiABMM+MauZcwqkXqHDp+2Nweo6rDrDFCa0oMmPuhuDjx7S/BtnqDuzUnbRPb BXSyhuBJBepM8DaLO7vdjUdcFkE3MOzp7e840r8scDvEr5eCi1YFmeeHYZ50noZGSe/F 0mCNm+44VIgc1EpgD6s2+4ra4afUgSW0UEWrW/C9N4JPJRzmqif8nwFxFpGtHVzjtfLt DApA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2jvymI+YIK1YP+SxTJS86Vk86ZHIqmMtl8I6cmHaozU=; b=IKtrjZvKyQugc4HY2aiqE6Qn6IDGGfz0QleJQaVfylUPgC9FpDFYWTm+ladnVW1Fgs V7NXr4/dgHEPqgPEOTGJgtI7JqraYS1khSt08AzC9v8zHALH/CcGG/cQysHgALqPFPo8 m1GTZ7NeN4tn30eB2tKKH65uFdq6EajrasyvI/YHB9nxZRqV/GYz68fEIhKdfyhwgtPt OHBO+yabtiMd++hSIhua8SYbKQQ6UpMkybvu9KGSkujFr4tCXQPq4IBbxW369XW7l+T5 b/rA9vuefR7aVAUKxSUWgylLVJu5MiKD2bkoW6F01l6EC+Unu+a+hr8zZHDBmmEU8SEN ir5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kDg72aUs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a6561b1000000b0037882ed4058si4101726pgv.450.2022.03.04.00.27.08; Fri, 04 Mar 2022 00:27:23 -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=@gmail.com header.s=20210112 header.b=kDg72aUs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236400AbiCCVAN (ORCPT + 99 others); Thu, 3 Mar 2022 16:00:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235783AbiCCVAM (ORCPT ); Thu, 3 Mar 2022 16:00:12 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C42F310B8; Thu, 3 Mar 2022 12:59:25 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id i11so8196812eda.9; Thu, 03 Mar 2022 12:59:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2jvymI+YIK1YP+SxTJS86Vk86ZHIqmMtl8I6cmHaozU=; b=kDg72aUsPanwwxkWPEPBy1iRsw+wks3Vhk4NCYeXPs/EAzXBlPMvIjPof6RBPJsJf3 HF9+w9KlJawyapd8l2fK7mtPCAU2dcB/O38pPtexE2F5xY7qUfJ5yue9FkLjowtGJ2uH Zzyb7j2SjnqMtB67PcX2vVyjZt7XPF7aWnPeuZwIR/9eRKyVu7w/sX3VgcSBx7a2ySOT W3vOG31+oIb/kASH4ij62Vy7bFFcJIvHj58HdOivJc4yGJaugDfe0r/U+iwGc37Us65C neC8g+HHL8LOMaEedVeaU8MmTws01LWq4Xs2t+XdCDay84Ja4Z881/GWy7WLpWDpwm9J RGWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2jvymI+YIK1YP+SxTJS86Vk86ZHIqmMtl8I6cmHaozU=; b=uXWIxnNlLoi/oN+NHNjeuQf9o9LHYOQZf6G4yrH8pFrEDnDNRHeqSRvr8nny49MEwt vtpd6k5eQWWlbBA3nxYJH4Tb2hbCvYNQmVC7lvRUPlMg91ONge5UIo8hF6WXUWWqjMnw hdKUquzGC2BFK0dDP+EmDjGTUB+TB/isFfOdtsPb9hiKkwsfxMyiA2cw5flgVewpm4Fq pa8s58SEGJ80UiyQHb5t0Bgm6DmrRZ6FYJSo9VujH26gUulwJ0ndyKBZq+PwLo9U1nrc h/qte1C7aKPbldj9j2vw1RJvFRyP1tHzLHE6uNndxC363LY7SpuXWcdImzdmOj5MFWrJ uSFw== X-Gm-Message-State: AOAM533GGDC006mG6UbkJDU467r9DiXI+qg8Ba/4DoiHqBLqkp+Oiyax MDBGCxlTDw7wwXdR+f6x5WJCHQ9HuF8= X-Received: by 2002:aa7:cac8:0:b0:410:cc6c:6512 with SMTP id l8-20020aa7cac8000000b00410cc6c6512mr36024932edt.408.1646341164152; Thu, 03 Mar 2022 12:59:24 -0800 (PST) Received: from skbuf ([188.25.231.156]) by smtp.gmail.com with ESMTPSA id cf10-20020a0564020b8a00b00412b19c1aaesm1247433edb.12.2022.03.03.12.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 12:59:23 -0800 (PST) Date: Thu, 3 Mar 2022 22:59:21 +0200 From: Vladimir Oltean To: Tobias Waldekranz Cc: davem@davemloft.net, kuba@kernel.org, Andrew Lunn , Vivien Didelot , Florian Fainelli , 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: Re: [PATCH v2 net-next 04/10] net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations Message-ID: <20220303205921.sxb52jzw4jcdj6m7@skbuf> References: <20220301100321.951175-1-tobias@waldekranz.com> <20220301100321.951175-5-tobias@waldekranz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220301100321.951175-5-tobias@waldekranz.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 On Tue, Mar 01, 2022 at 11:03:15AM +0100, Tobias Waldekranz wrote: > 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; > + }; Do you see other VLAN attributes that would be added in the future, such as to justify making this a single-element union from the get-go? Anyway if that is the case, we're lacking an id for the attribute type, so we'd end up needing to change drivers when a second union element appears. Otherwise they'd all expect an 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, Is the bridge spinlock held (atomic context), or otherwise why is SWITCHDEV_F_DEFER needed here? > + .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); Treating a "VLAN attribute" as a "port attribute of the bridge" is pushing the taxonomy just a little, but I don't have a better suggestion. > + 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) "bool adding" is unused, and replaying the VLAN to MSTI associations before deleting them makes little sense anyway. I understand the appeal of symmetry, so maybe put an if (adding) { err = br_switchdev_vlan_attr_replay(...); if (err && err != -EOPNOTSUPP) return err; } at the end of br_switchdev_vlan_replay()? > +{ > + 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, I don't think SWITCHDEV_F_DEFER has any effect on a replay. > + .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 >