Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp330926rwb; Thu, 27 Jul 2023 13:30:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFm0Jg/Jv4QifScB49+z2yP+yOENQyawKuf19jyND6zhK070xS2CApDEl9cIgaATcxpAoLE X-Received: by 2002:a19:6710:0:b0:4fe:19ef:879e with SMTP id b16-20020a196710000000b004fe19ef879emr172384lfc.28.1690489804963; Thu, 27 Jul 2023 13:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690489804; cv=none; d=google.com; s=arc-20160816; b=MnTCTxaj1cKnT9B9Gwjw19vbjZnQM+P3h4hhY9q15670BzLzoD/JYKuHKBLzLxbiSE Ab5oHURyWasMn5BaJwQbd6jlR0m1aCdFXBB5N+nYB2Z8qHh3KsIlekisyFwog5mXZW/w igpWZv9I/+q7LOCkK4MTTOxDjRSTiRDSLAmOwSRICalqDSCp/C+VOykhi2Tpm8DSC2B/ u3ccubD91VsvF3qtoLNHQ/s5tUGvFAWEOSz/p9jl5+SMRQ2dk1HQW5pH04gJLOuKbJJd DT3SkcdG0/bGMkPlQEdcvPsk1PRuEMUH26pWKztWvvB8c5NCEitbJEiEQ0M0KT0WvnjA u3vA== 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:subject:cc:to:from:date:message-id:dkim-signature; bh=nIx6nzK1csipmfPjI95rDJjLnMfx1PFSyc3lWa7vvrc=; fh=fFkegOqkyAIP8iJMFJfPVjJmsDMq00/FaZ6ESbBLjkI=; b=yg9FglK2Zq2ONqpc11x4XwTa1gZ4prxTptmjkVGLGTptFnD2505DJU4qXeR6AAmj7S e6PQB4gNd9y59Pzc/mmI1ZFDMV2O1qwrHm9fskeU0gPeJO6IgOSHkHLfdPsASSxrfBE4 Rr825mtmBu1W/BXpE/9JqXljaLkVSSFC2YFVAI4IUGnkrI67Dq7n7UDrhX1YVHJu0g34 w55sADBdd5GaRya4U9rNd+WKBnQhIFXtHAvBvdB1z1qN7DjoUew+ziBCKzgC8l6p/pK4 N0v1GhCwY3rLndTEZGoGh8RdnVIofbqZYFwnl86miR+ogTZ/3VRSOL+j03d9UMYja38O UqSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ii3hjhVJ; 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 u4-20020aa7d0c4000000b005223a219e26si1498735edo.191.2023.07.27.13.29.39; Thu, 27 Jul 2023 13:30:04 -0700 (PDT) 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=20221208 header.b=ii3hjhVJ; 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 S231927AbjG0TFf (ORCPT + 99 others); Thu, 27 Jul 2023 15:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjG0TFe (ORCPT ); Thu, 27 Jul 2023 15:05:34 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85FB9210B; Thu, 27 Jul 2023 12:05:32 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fc0aecf15bso14676015e9.1; Thu, 27 Jul 2023 12:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690484731; x=1691089531; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=nIx6nzK1csipmfPjI95rDJjLnMfx1PFSyc3lWa7vvrc=; b=ii3hjhVJ3BJkubwmKOh79nhvCZikM1KTN7kY7sfD45meSp7XEmATGp7W4mWIx3bJwB CWHV25uZpWDIMGKGBBkmv4v67g+DrVd8gHuzFmhoY3wD/3wAKMzIFSVWdBV5QPcFBFm3 Twe6zGISOulfT8GJ/E3+ow2I0ftejuCVdBdCO+16BcXIoKorJ2RE3aq8iVGlIFJLfBjT SHTjPulLqzlRZkdL95WuaYRA5iRhX1+OuWYdfJEwCXcc6LGpM7bQ7Trsb2nYFVmE6XRx p+prALiRW6zqI9u9cUB1uUrirm1/f0ce626pVkA4ael7U2AbiuhN3EhIN0ar1G37IFm/ 3rkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690484731; x=1691089531; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nIx6nzK1csipmfPjI95rDJjLnMfx1PFSyc3lWa7vvrc=; b=Hro1a4x4QBX02zHlg/IncbuxUpTW5ZK0gMVo/2xrPjR+vEFMwggU8h7cBRGY+joUCE ZpnBevSsIjhk/5zGBsnsEetQVXzAugI/urGtJXqOYnKqYejdxMmmN0/ZrPXfTxc+8pEr MCx1Ro8bRQLYLq0TNW4o3ilAcRIqAb3vvMxMTLn2NJ2A6wR6rTaE9tQltPQ1UBEOKSu3 PQ6fXN3jtiEKIMM26iiExjv5KdScrmOd6pt3CRr1JduA9Nj3ahRQuwmoHbIkhSCPpIFB +LjflgVfHpzJ+ZM/f85ZX/05bOPeyGyDv1oMmPHrcydn08Cj2SUdLbGtDxXYJ/pSguUX Y90A== X-Gm-Message-State: ABy/qLbX4kGhXYPd6GzCaL6j3DSfVlgsy7/BmU+z/wKgbykMmU6t3ljx hxYgPehq5Ig6YnbvHfra5HhmF07MK8ehdg== X-Received: by 2002:a7b:c4d3:0:b0:3f8:fac0:ad40 with SMTP id g19-20020a7bc4d3000000b003f8fac0ad40mr2449541wmk.29.1690484730568; Thu, 27 Jul 2023 12:05:30 -0700 (PDT) Received: from Ansuel-xps. (host-87-19-253-131.retail.telecomitalia.it. [87.19.253.131]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c029100b003f9bd9e3226sm2530980wmk.7.2023.07.27.12.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 12:05:29 -0700 (PDT) Message-ID: <64c2bff9.050a0220.49b7e.cb84@mx.google.com> X-Google-Original-Message-ID: Date: Thu, 27 Jul 2023 21:05:28 +0200 From: Christian Marangi To: Vladimir Oltean Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [net-next PATCH 2/3] net: dsa: qca8k: make learning configurable and keep off if standalone References: <20230724033058.16795-1-ansuelsmth@gmail.com> <20230724033058.16795-1-ansuelsmth@gmail.com> <20230724033058.16795-2-ansuelsmth@gmail.com> <20230724033058.16795-2-ansuelsmth@gmail.com> <20230726121213.3uehfygkz7rchlqf@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230726121213.3uehfygkz7rchlqf@skbuf> 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 Wed, Jul 26, 2023 at 03:12:13PM +0300, Vladimir Oltean wrote: > On Mon, Jul 24, 2023 at 05:30:57AM +0200, Christian Marangi wrote: > > Address learning should initially be turned off by the driver for port > > operation in standalone mode, then the DSA core handles changes to it > > via ds->ops->port_bridge_flags(). > > > > Currently this is not the case for qca8k where learning is enabled > > unconditionally in qca8k_setup for every user port. > > > > Handle ports configured in standalone mode by making the learning > > configurable and not enabling it by default. > > > > Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to > > enable learning for bridge that request it and tweak > > .port_stp_state_set to correctly disable learning when port is > > configured in standalone mode. > > > > Signed-off-by: Christian Marangi > > --- > > Reviewed-by: Vladimir Oltean > > Small nitpick below. > > > drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++-- > > drivers/net/dsa/qca/qca8k-common.c | 44 ++++++++++++++++++++++++++++++ > > drivers/net/dsa/qca/qca8k.h | 6 ++++ > > 3 files changed, 54 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c > > index ae088a4df794..31552853fdd4 100644 > > --- a/drivers/net/dsa/qca/qca8k-8xxx.c > > +++ b/drivers/net/dsa/qca/qca8k-8xxx.c > > @@ -1870,9 +1870,8 @@ qca8k_setup(struct dsa_switch *ds) > > if (ret) > > return ret; > > > > - /* Enable ARP Auto-learning by default */ > > - ret = regmap_set_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(i), > > - QCA8K_PORT_LOOKUP_LEARN); > > + ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(i), > > + QCA8K_PORT_LOOKUP_LEARN); > > if (ret) > > return ret; > > > > @@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { > > .port_change_mtu = qca8k_port_change_mtu, > > .port_max_mtu = qca8k_port_max_mtu, > > .port_stp_state_set = qca8k_port_stp_state_set, > > + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, > > + .port_bridge_flags = qca8k_port_bridge_flags, > > .port_bridge_join = qca8k_port_bridge_join, > > .port_bridge_leave = qca8k_port_bridge_leave, > > .port_fast_age = qca8k_port_fast_age, > > diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c > > index 13b8452ce5b2..e53694d2852a 100644 > > --- a/drivers/net/dsa/qca/qca8k-common.c > > +++ b/drivers/net/dsa/qca/qca8k-common.c > > @@ -565,9 +565,26 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, > > return 0; > > } > > > > +static int qca8k_port_configure_learning(struct dsa_switch *ds, int port, > > + bool learning) > > +{ > > + struct qca8k_priv *priv = ds->priv; > > + > > + if (learning) > > + return regmap_set_bits(priv->regmap, > > + QCA8K_PORT_LOOKUP_CTRL(port), > > + QCA8K_PORT_LOOKUP_LEARN); > > + else > > + return regmap_clear_bits(priv->regmap, > > + QCA8K_PORT_LOOKUP_CTRL(port), > > + QCA8K_PORT_LOOKUP_LEARN); > > +} > > + > > void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) > > { > > + struct dsa_port *dp = dsa_to_port(ds, port); > > struct qca8k_priv *priv = ds->priv; > > + bool learning = false; > > u32 stp_state; > > > > switch (state) { > > @@ -582,8 +599,11 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) > > break; > > case BR_STATE_LEARNING: > > stp_state = QCA8K_PORT_LOOKUP_STATE_LEARNING; > > + learning = dp->learning; > > break; > > case BR_STATE_FORWARDING: > > + learning = dp->learning; > > + fallthrough; > > default: > > stp_state = QCA8K_PORT_LOOKUP_STATE_FORWARD; > > break; > > @@ -591,6 +611,30 @@ void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) > > > > qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port), > > QCA8K_PORT_LOOKUP_STATE_MASK, stp_state); > > + > > + qca8k_port_configure_learning(ds, port, learning); > > +} > > + > > +int qca8k_port_pre_bridge_flags(struct dsa_switch *ds, int port, > > + struct switchdev_brport_flags flags, > > + struct netlink_ext_ack *extack) > > +{ > > + if (flags.mask & ~BR_LEARNING) > > + return -EINVAL; > > + > > + return 0; > > +} > > + > > +int qca8k_port_bridge_flags(struct dsa_switch *ds, int port, > > + struct switchdev_brport_flags flags, > > + struct netlink_ext_ack *extack) > > +{ > > + int ret; > > + > > + ret = qca8k_port_configure_learning(ds, port, > > + flags.val & BR_LEARNING); > > + > > + return ret; > > I worry that the way in this is formulated will attract patches from > kernel janitors to simplify it to: > > return qca8k_port_configure_learning(...) > > I agree that it's not strictly necessary to check flags.mask when > port_pre_bridge_flags supports a single flag, but if you did that and > structured the code for more future flags, you could avoid that. > > int ret; > > if (flags.mask & BR_LEARNING) { > ret = qca8k_port_configure_learning(..., > flags.val & BR_LEARNING); > if (ret) > return ret; > } > > return 0; > > Anyway, probably not a big deal. > > > } I hope and expect to send fbd isolation later with FLOOD flags so I will send v2 of this with the suggested format. > > > > int qca8k_port_bridge_join(struct dsa_switch *ds, int port, > > diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h > > index c5cc8a172d65..8f88b7db384d 100644 > > --- a/drivers/net/dsa/qca/qca8k.h > > +++ b/drivers/net/dsa/qca/qca8k.h > > @@ -522,6 +522,12 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e); > > > > /* Common bridge function */ > > void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state); > > +int qca8k_port_pre_bridge_flags(struct dsa_switch *ds, int port, > > + struct switchdev_brport_flags flags, > > + struct netlink_ext_ack *extack); > > +int qca8k_port_bridge_flags(struct dsa_switch *ds, int port, > > + struct switchdev_brport_flags flags, > > + struct netlink_ext_ack *extack); > > int qca8k_port_bridge_join(struct dsa_switch *ds, int port, > > struct dsa_bridge bridge, > > bool *tx_fwd_offload, > > -- > > 2.40.1 > > > -- Ansuel