Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp977427pxp; Wed, 16 Mar 2022 23:14:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+M9gM1svoIR9fbz9EwgIOie0teZVTKXlIrP1UGsyZMRhXEV9dNiDNkFbKgyuuPw3LJYlS X-Received: by 2002:a17:90a:e7cc:b0:1bf:5ab5:f481 with SMTP id kb12-20020a17090ae7cc00b001bf5ab5f481mr13981751pjb.215.1647497680785; Wed, 16 Mar 2022 23:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647497680; cv=none; d=google.com; s=arc-20160816; b=Z3aLRVmJTRpUjajSQx9tmajmCBWA9EXHZJTeEJQ0W9jxrVX6NyTR7+OjhufUA32ZjO xFNSTPPPG3iFU4DbDlylInmGRpMxwWLl3KFbYmlxObBpSH+Gv4FFUNOi7LrQxbUp19mw rVfj6zCQ7Ioo+nUtSg72FkOg29RWMTzvPBeXihZZ1JEaZIMmfMJYspJrtUA0dtW9TfoK 9fuOGGdA2P5Aa3QWOgeOzO7dtVuQSDQFuVELU4IJOnF6YhUUbUIbuBj0mkCdqDn4SaWD OdT41HQLbr7qzRCNUHtT45w2NpFbF+lC06NbUBXcOPVHBrEaKWm8waIwA/k++5kqBza8 jLzQ== 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=akWzYrIA0f7A74GU4gqxjh8xdXZeuUVFKu3EYBQU0u8=; b=QoHqKtDbN2CJkTMa/MA1hX25U6Du2LyW5ahBxsuTmj1dz7mp/QeXypXobfINU6y0Fk 2t7svnqD2i2ixP3oeawQLsBCHaChZZlQIjmM1KK6XCJXeqa+1TqWUPvIp+LtUmOxnzYX cUL2TW7qJQIeusjj3dpBOHcPdJaLz804r8a3CaYdNansBYxVAzArWA9Zjr1zPo51DNom 3HWthFhHlAkeQe7JFHczxphdlHUnooy5LqnmBax1+VYBXAa3eTma8j7lzLyjPudz1WnR mzZxZZBODZJbNHP5Wyfmya5muIB+vT8xZ2EF4vOZ/VnWYVovzkNA5uDETUmfravKPWbk FoDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20210112.gappssmtp.com header.s=20210112 header.b=5WCup1a1; 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 o15-20020a656a4f000000b0038206e0017esi909354pgu.558.2022.03.16.23.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:14:40 -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=5WCup1a1; 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 E2C00D9EAC; Wed, 16 Mar 2022 21:57:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357153AbiCPPLh (ORCPT + 99 others); Wed, 16 Mar 2022 11:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357060AbiCPPLD (ORCPT ); Wed, 16 Mar 2022 11:11:03 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7762674C5 for ; Wed, 16 Mar 2022 08:09:18 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id s25so4227168lfs.10 for ; Wed, 16 Mar 2022 08:09:18 -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=akWzYrIA0f7A74GU4gqxjh8xdXZeuUVFKu3EYBQU0u8=; b=5WCup1a1iZIhs6zKsDXNRtYiF+OmuSJenUiuhmrGMbgRY2VLwJEBUpkIv4WJZavNsG Li67VLDKgBwFlZAuviq670EL7VcNtfKUKkX44EYzda+3gd1yVkxcExaN+6F/yhPpmJHN vaEkjBUdAal3Uu/zxHVjZpqKA4gLOdYaz3bFDXPEr6uU5+405HHkzE4GB4omBcdKUPMR uA10X0CygKXZFgOFCIy5Jrm40jdf//jSpuMWLMXsEpb6Dvv41iM3bnfiL3R3LFsYcDtA gPrPy7pC6uKk+y1pj4Vs4N+SXANsU89aeiPDVnA5WXyPPfeBAu/42HZ5WTnhLXdvC2ai sZDw== 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=akWzYrIA0f7A74GU4gqxjh8xdXZeuUVFKu3EYBQU0u8=; b=pI7EGQSzLqdmq357mT9mBlSu9ab2sdI9lQ5G/3akRklA7LQ+qvQmTcXS9tZKyoFflJ PI2xJZ0UlaG1k6dIcIzyC19Gev7Z1ZnCOp5/whpQ/u1VdK8QNMXthS3rac4Ru8jS2dGD bEllNI6g7xqlzkoTdN0gW/pEl3GU3/eFxpd0VUwbEOTCXL1a/REoMtrMaW9YRkewXQCR PMCXs6nedpRuBBJjcH3W6CPG5kGt+cHaBmVpOGlsMrxwRnMhBpFfaNeulEQ7nnp9HHu+ x6ngL7D+EPNFizERm9f95KzjTKnopkgUeZ2FoRXtOimw2uzdZqnpN7APLUXx9/aHBrKC fO4A== X-Gm-Message-State: AOAM5316sdUSk54oesgqmtwOsZbl5tER72Bf3V6r/h3jpptCcm4gctP6 O8EclMe0DSNgjHZ6jFd9rgbALA== X-Received: by 2002:a05:6512:455:b0:448:24a7:a241 with SMTP id y21-20020a056512045500b0044824a7a241mr95256lfk.208.1647443356545; Wed, 16 Mar 2022 08:09:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:09:16 -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 10/15] net: dsa: Validate hardware support for MST Date: Wed, 16 Mar 2022 16:08:52 +0100 Message-Id: <20220316150857.2442916-11-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 When joining a bridge where MST is enabled, we validate that the proper offloading support is in place, otherwise we fallback to software bridging. When then mode is changed on a bridge in which we are members, we refuse the change if offloading is not supported. At the moment we only check for configurable learning, but this will be further restricted as we support more MST related switchdev events. Signed-off-by: Tobias Waldekranz --- net/dsa/dsa_priv.h | 2 ++ net/dsa/port.c | 22 ++++++++++++++++++++++ net/dsa/slave.c | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index f20bdd8ea0a8..2aba420696ef 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -234,6 +234,8 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, struct netlink_ext_ack *extack); bool dsa_port_skip_vlan_configuration(struct dsa_port *dp); int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock); +int dsa_port_mst_enable(struct dsa_port *dp, bool on, + struct netlink_ext_ack *extack); int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu, bool targeted_match); int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, diff --git a/net/dsa/port.c b/net/dsa/port.c index 58291df14cdb..02214033cec0 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -321,6 +321,11 @@ static void dsa_port_bridge_destroy(struct dsa_port *dp, kfree(bridge); } +static bool dsa_port_supports_mst(struct dsa_port *dp) +{ + return dsa_port_can_configure_learning(dp); +} + int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, struct netlink_ext_ack *extack) { @@ -334,6 +339,9 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, struct net_device *brport_dev; int err; + if (br_mst_enabled(br) && !dsa_port_supports_mst(dp)) + return -EOPNOTSUPP; + /* Here the interface is already bridged. Reflect the current * configuration so that drivers can program their chips accordingly. */ @@ -735,6 +743,20 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock) return 0; } +int dsa_port_mst_enable(struct dsa_port *dp, bool on, + struct netlink_ext_ack *extack) +{ + if (!on) + return 0; + + if (!dsa_port_supports_mst(dp)) { + NL_SET_ERR_MSG_MOD(extack, "Hardware does not support MST"); + return -EINVAL; + } + + return 0; +} + int dsa_port_pre_bridge_flags(const struct dsa_port *dp, struct switchdev_brport_flags flags, struct netlink_ext_ack *extack) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index f9cecda791d5..2e8f62476ce9 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -464,6 +464,12 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ret = dsa_port_ageing_time(dp, attr->u.ageing_time); break; + case SWITCHDEV_ATTR_ID_BRIDGE_MST: + if (!dsa_port_offloads_bridge_dev(dp, attr->orig_dev)) + return -EOPNOTSUPP; + + ret = dsa_port_mst_enable(dp, attr->u.mst, extack); + break; case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS: if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev)) return -EOPNOTSUPP; -- 2.25.1