Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp992387pxp; Wed, 16 Mar 2022 23:45:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/wvCdi0Ca+QbD9MFdAdii7MOu2glhSIk4Lb//0tULQ+Po6+4OxwEkupv40044KGFYsaDD X-Received: by 2002:a63:316:0:b0:380:37ef:4428 with SMTP id 22-20020a630316000000b0038037ef4428mr2538435pgd.303.1647499502866; Wed, 16 Mar 2022 23:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647499502; cv=none; d=google.com; s=arc-20160816; b=j++JifP++GXelXnLOUIxPFngLQgZ8r0ypBRZTQUI6L5wcuuph92fSojLEnVKEu5mjd aiLpMQ/S1Sh7qfL25oI06OTtH/WMfpAoD+a7rKdimODlgt1yFWGfCrUJ8TBInXEtQC5U DXrA7Avut/y64m5PTEmZqR/Y835AT360asgMVo0apjUrxdquqS1F20xhHvH/jYdnMrb+ 4n/8ulyEZQ3ttth8rxIYEd18VCrNKB/s7hU12TVqs8xHHWtwRtmkbzwTCfM3ZcG+bYHO rrVSl4HYyz11tZqaEKqBIYjQFcOK/95THc+7cFfzSf6qe1dn43QGQYhxo9HsUOV17k4g HX0A== 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=76757SLn2m3kynx16q8kTjn2S8FyWnl1tPy4d5M2WAU=; b=wh02RSPvK7M8sDReTtlT9PwtMQk71PjcFfDvkxOxIg7dWoRdKZlsVX8osMceTTfqcI 85C/c3AR7CGMzfei4PmDNgYnAiqgi6I7wBLFN6D04rYUMS3Q1DLubLs+xETX8KMMMZhc jfpKo5athpWftBYYOChN1P0yQqsXOpVRARiweI34KOErLArylksMxBcLXNl0rUDxefv6 qvldnu3olRVeQQPvU4UqFV4pVRQVeUMxyb0Ek3uYaCUN3PfVcZ1II12KIGCdTdrQNF46 6d4jyPYA6A9EwvHu0ErCWD2InQ3/I2+fRRp6RJ+I3MqQIZcr0OVuCuvhQXvoV/IjvALR 74dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=fOo4unQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o13-20020a17090a4b4d00b001bf6913eb4bsi7333247pjl.155.2022.03.16.23.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=fOo4unQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 53A0F1F51BA; Wed, 16 Mar 2022 22:29:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357122AbiCPPLO (ORCPT + 99 others); Wed, 16 Mar 2022 11:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357042AbiCPPKt (ORCPT ); Wed, 16 Mar 2022 11:10:49 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6EA673E2 for ; Wed, 16 Mar 2022 08:09:16 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 17so3561406lji.1 for ; Wed, 16 Mar 2022 08:09:16 -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=76757SLn2m3kynx16q8kTjn2S8FyWnl1tPy4d5M2WAU=; b=fOo4unQQPl/kO4jXHli7n90QN01vhns0vLZqV98YC5kcPh3XSV4992TiZQhGEWLRkO 4kQIWapNT6BhIwx1qJMnISKt1aVfLh+wmFCjRFNnyo87bfUqDdyQXxi4JyoyVi7jVrdY AS70kYTbecf/dmgzPTY/g6vBo8hAUwaLrQ71P4J6OIdGUmvi25LuDBqaP0i32eXebJh2 XZ11KLYwSgtlweOgOO+6geRrcVtKd3XWEKWuFGTV9QaA1TAbExBR1NiZF8tk3narzKcH D6X2aS7K94orJvwQlXXN0/WKsgPPGoPEBS7nVyFdP86HCRk8hZFSU57Le42G3Y0afvAu H1cw== 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=76757SLn2m3kynx16q8kTjn2S8FyWnl1tPy4d5M2WAU=; b=YEQnFnpvOyTIhFvCzldzs9kCsKeeQgeMgiUI8eCcEVzlt7X+fe3HcBbuf/2odX8/tR ur/gLywPkbTNm+Oyj7mJd3eQL3kyfBo9XH2QB73tJL38StgIoHKnehR6yFx8cTmaLc0j 1upBunBrqjiAjW/entnOZucpCIFIVQgsh/mjj3JM4AKIMrXW7LycqUX2Awc4b5UvYWwN 4e70Vh4BB7TSGvL/NodlS4qmCXqgaY1zhax+ZQGumd2M1WCtcJpA4rk3DHDvW4rs22Jr yS0//7DqXnYBBy7vMUy4msRRP/zfiMJF71ORnaQKdJUlnjcHEilMl46TbWuIszpb6oG9 MmIg== X-Gm-Message-State: AOAM533f6CY7WMN9AJSze/OLFeXXz4XxPuL0QxjC3p9d72ZgpuhDgfbM oVmFwUcf/w5iBjrMWHaB4sHq8Q== X-Received: by 2002:a2e:9847:0:b0:244:4deb:70d1 with SMTP id e7-20020a2e9847000000b002444deb70d1mr91331ljj.146.1647443354786; Wed, 16 Mar 2022 08:09:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:09:14 -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 08/15] net: bridge: mst: Add helper to check if MST is enabled Date: Wed, 16 Mar 2022 16:08:50 +0100 Message-Id: <20220316150857.2442916-9-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 that might want to refuse to join a bridge where MST is enabled, if the hardware can't support it. Signed-off-by: Tobias Waldekranz --- include/linux/if_bridge.h | 6 ++++++ net/bridge/br_mst.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h index 1cf0cc46d90d..4efd5540279a 100644 --- a/include/linux/if_bridge.h +++ b/include/linux/if_bridge.h @@ -119,6 +119,7 @@ int br_vlan_get_info(const struct net_device *dev, u16 vid, struct bridge_vlan_info *p_vinfo); 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); #else static inline bool br_vlan_enabled(const struct net_device *dev) @@ -153,6 +154,11 @@ static inline int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid, return -EINVAL; } +static inline bool br_mst_enabled(const struct net_device *dev) +{ + return false; +} + static inline int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) { diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c index 00b36e629224..830a5746479f 100644 --- a/net/bridge/br_mst.c +++ b/net/bridge/br_mst.c @@ -13,6 +13,15 @@ DEFINE_STATIC_KEY_FALSE(br_mst_used); +bool br_mst_enabled(const struct net_device *dev) +{ + if (!netif_is_bridge_master(dev)) + return false; + + return br_opt_get(netdev_priv(dev), BROPT_MST_ENABLED); +} +EXPORT_SYMBOL_GPL(br_mst_enabled); + int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) { const struct net_bridge_vlan_group *vg; -- 2.25.1