Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp962350pxp; Wed, 16 Mar 2022 22:45:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ034cawDrmmrgPHZRNqwzLiRl73+054Qa2Ie8xWPa8JQdLohBe8R2wlloOcsSqZ0VQdBm X-Received: by 2002:a17:90a:98b:b0:1c6:5824:cc0e with SMTP id 11-20020a17090a098b00b001c65824cc0emr3362450pjo.209.1647495956133; Wed, 16 Mar 2022 22:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647495956; cv=none; d=google.com; s=arc-20160816; b=NsEfi75g/oyM7y39JQE/Mf0zJZjt0MfIrDD5/IKYVyNUz+LzvCWVsCDEj4kSVFj7fK ap0GLtJAcqz7/DVJyDI/8oWVDOh+vV3L1UVCj4MWK1Cq/K4JJON0g1dBuz87zE2mcVXh LadeE6wJ7Y2/eU3xogA9hrr9lBOG2mUPXJQXiJcI7pkydervSGh7SyOlcEHpwpHk537P 2kMDACExzG5CByC3UXR8gl2FvU7YjvniwvAdK/jbR51UK2OuOnWOp+wQVZGhaWUNbEd1 lCoPXTh7Na76YJOfEQ0J2/eg1GNPREqbII8fbQafSi2hpEpZxpY08ruE28sBf3gvrrX3 uSLA== 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=GnM2vWwSx2i5cE2iNl+NO2cDrpNSR+FaAqPVnKFkrgM=; b=CAllKSseSFXqDTVjQzufwcrVbqxoOL1D9fkulIJdTQbgugqvCuEsW3VmHmK9G8eyH6 FLeFS8EHstD/pFjExYkJbIYMLAIdahsmvvsEDoE0I1LwPSDG83QqdS2X+QrBal9MUfrH +Qqp/cGz9qnO5y17bhq67vkw5HwK8f3E563QLWKTbMjtc5yEtnwfBUWYNsACaTAKWodo iw2MeM6x4nz5kg+5BbzIJgnr0LGG4Ka86HZ0WbI39FuSao+9hwg/4u6u2Eo8zUYPaYN1 sDYprks4w1NyNf27OyQTq/PMtqOqkralrdBSo5EhayQdFLIzFREoRA/qKNAqKkh5Kdbc 93Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=uyhfrzP7; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t9-20020a170902b20900b0014f21a5ea40si3603501plr.569.2022.03.16.22.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:45:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=uyhfrzP7; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3DD011E8CFB; Wed, 16 Mar 2022 21:40:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357079AbiCPPL0 (ORCPT + 99 others); Wed, 16 Mar 2022 11:11:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356991AbiCPPKy (ORCPT ); Wed, 16 Mar 2022 11:10:54 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88526673F1 for ; Wed, 16 Mar 2022 08:09:17 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id s25so3546438lji.5 for ; Wed, 16 Mar 2022 08:09:17 -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:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=GnM2vWwSx2i5cE2iNl+NO2cDrpNSR+FaAqPVnKFkrgM=; b=uyhfrzP7w9DjuBUBI2RL71VgIXkwbG6IgUN2y0ZJe7zvgp8IWsL1bDwgVyCDnoTfZ9 CHQA4UL9uMDbL2tZOAVJGcMjd3ekQIITSByP5SF129hYTSMLHsapZA8uro58+w3svgBx 51EtxzdMy9jSYcZv3YxmR9oMMdHCWHVUXbJw7lXaeDdfO+VUJnkA3GUlXevzhv1TM593 m9RFo1iNJo/OXZQxmkIvpd+zic1FlIbILxF5UVF06rgyMCg1ah8dZ3nBmQMsZM8cION6 onopmBEBmOr45EaQ1P9TlgmsjTmQ2K6WVeufmzgSglCsjZ39R0Lr+/TS6pyzGMMCD4wQ N9Dw== 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=GnM2vWwSx2i5cE2iNl+NO2cDrpNSR+FaAqPVnKFkrgM=; b=Of+mdbKQFe7XBdeDSMLsWJ8YbpgLAH6jXNU95Pn71bT//qt1hrDd1M9AJmdXhQUe0W fUjUpqlZPfaDV1jzelnO7PbGuweeBxX1B3+kABwjR5o0l+7ruGRS/EqtOPFUNEMITyFP BDk5bq3V+qefqwPJJwTYaQ5bMneGAFQkzQ893DIB1edanq1WEeizCTioR+AOVs2xJO0P u+hNO/ue8rgtMQAKvR7ouu61YyycPw3rMt+3OGu3xi09QD119vmQQLRtD01C+TT1Jrzx 7mZmcJxscuPTPYFfxsiFwZ+rXVid7c/MPB745XLdx3GVZNBNkB7QWCbrVTpKnaGCkF09 fICA== X-Gm-Message-State: AOAM532hItKtFpY88krHUqMaTQN9Y2zq5Y+On1/IFr4tw8KiLUeVUkfC f0Sc4Z//L3EyGhx4TZHnFV+qZQ== X-Received: by 2002:a2e:a584:0:b0:249:1463:cb84 with SMTP id m4-20020a2ea584000000b002491463cb84mr45535ljp.231.1647443355643; Wed, 16 Mar 2022 08:09:15 -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 d2-20020a194f02000000b00448b915e2d3sm176048lfb.99.2022.03.16.08.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:09:15 -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 , Petr Machata , Ido Schimmel , Matt Johnston , Cooper Lees , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bridge@lists.linux-foundation.org Subject: [PATCH v5 net-next 09/15] net: bridge: mst: Add helper to query a port's MST state Date: Wed, 16 Mar 2022 16:08:51 +0100 Message-Id: <20220316150857.2442916-10-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220316150857.2442916-1-tobias@waldekranz.com> References: <20220316150857.2442916-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,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 This is useful for switchdev drivers who are offloading MST states into hardware. As an example, a driver may wish to flush the FDB for a port when it transitions from forwarding to blocking - which means that the previous state must be discoverable. Signed-off-by: Tobias Waldekranz --- include/linux/if_bridge.h | 6 ++++++ net/bridge/br_mst.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h index 4efd5540279a..d62ef428e3aa 100644 --- a/include/linux/if_bridge.h +++ b/include/linux/if_bridge.h @@ -121,6 +121,7 @@ int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid, struct bridge_vlan_info *p_vinfo); bool br_mst_enabled(const struct net_device *dev); int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids); +int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state); #else static inline bool br_vlan_enabled(const struct net_device *dev) { @@ -164,6 +165,11 @@ static inline int br_mst_get_info(const struct net_device *dev, u16 msti, { return -EINVAL; } +static inline int br_mst_get_state(const struct net_device *dev, u16 msti, + u8 *state) +{ + return -EINVAL; +} #endif #if IS_ENABLED(CONFIG_BRIDGE) diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c index 830a5746479f..ee680adcee17 100644 --- a/net/bridge/br_mst.c +++ b/net/bridge/br_mst.c @@ -48,6 +48,31 @@ int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) } EXPORT_SYMBOL_GPL(br_mst_get_info); +int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state) +{ + const struct net_bridge_port *p = NULL; + const struct net_bridge_vlan_group *vg; + const struct net_bridge_vlan *v; + + ASSERT_RTNL(); + + p = br_port_get_check_rtnl(dev); + if (!p || !br_opt_get(p->br, BROPT_MST_ENABLED)) + return -EINVAL; + + vg = nbp_vlan_group(p); + + list_for_each_entry(v, &vg->vlan_list, vlist) { + if (v->brvlan->msti == msti) { + *state = v->state; + return 0; + } + } + + return -ENOENT; +} +EXPORT_SYMBOL_GPL(br_mst_get_state); + static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v, u8 state) { -- 2.25.1