Message ID | 20221108135643.15094-1-rogerq@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2720693wru; Tue, 8 Nov 2022 05:57:52 -0800 (PST) X-Google-Smtp-Source: AMsMyM5cVJD6eNmIR9x2//qUXtIi5OK4NFdnAhe1JN5PtpR/uUXz7PSSPW7kMKf1dLnDTeSoEYG4 X-Received: by 2002:a05:6402:718:b0:463:275:4753 with SMTP id w24-20020a056402071800b0046302754753mr52644900edx.160.1667915872253; Tue, 08 Nov 2022 05:57:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667915872; cv=none; d=google.com; s=arc-20160816; b=Xkt9XS/UfDD9P/tBl/csTydbz+A9ecjKGoIq5RWa3lq1XcdD8hMd8p4XzPKINj/eOs 7Z9k5+JDGUQbkxX1cMmn+VxwuhUF6FZ2x3yTg7saWDL5Eab6epbMIjq2KOeZGTwCWLxD DHBcDh+YN7PRgDcp74VbzeALBL0KAd8cBFnOtLOtz72qJQBXXcUnPXafHw3w7VR9P64V /4Bxc01plftnkc9iKk4JaeiZewhXWYI/pz7U7YntvyXbdqY0XzqhATQgJKxYfEjjdQtj K60NOZULA+EEdMCI7P08FGj6udCHqh+Sixr5nay/2qzI3TchHvERb7zCFMaDfm2vdxCd KWvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=mk0qF4LcoedcSRJxkwcuFhi5bDOTLhLD/0EkUte25zc=; b=0V2l6ZFmOgwgejxZzGCaOO6crNDg+8dC7wUIN60XR8bOSH+RUpsgEj2KHv7TPdo2JJ zS/z3atQnxsGECqH0Qb7UbFVuzepjzwGaI0Ycy0JvTKefx6mJPaozn/CKpuVL7qP5sgv G+ottIECkqZRBaagfQ7/Hb0f7R+7TxBk7/+KDD87hdjgyLuTNTqqa1Fv2bsODVXpahSY EXPqf+8aIB5iyAm1UdqVeS2BcGHUtdTPTpiiKiFYo2ii57i46ee6q2VVVJDgM2+iHAwT W/pNT73ayugxFqvacXGqjabCm/4OamFCfDS0dWr6nOEoSLb2CZT6qy9aP1cBMsZ4UM75 /aYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rarAumq7; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb3-20020a1709076d8300b0077945c44b7fsi14325738ejc.856.2022.11.08.05.57.28; Tue, 08 Nov 2022 05:57:52 -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=@kernel.org header.s=k20201202 header.b=rarAumq7; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234839AbiKHN5K (ORCPT <rfc822;david.rheinsberg@gmail.com> + 99 others); Tue, 8 Nov 2022 08:57:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234832AbiKHN5H (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Nov 2022 08:57:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEC1E60EB1; Tue, 8 Nov 2022 05:57:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9E0FAB816DD; Tue, 8 Nov 2022 13:57:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA918C433D7; Tue, 8 Nov 2022 13:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667915824; bh=tQ72T7lQxJkgX/x3mTSKvAAkisGq4na2N+MSF2k1IYY=; h=From:To:Cc:Subject:Date:From; b=rarAumq7Os55EgdCMr4oiL1ZaPvjcTFkoRgoClYflI+J2eso3fj/gOs/7NcFtEBuR tCnrMEOMpCrrK/vXxMdSco0tIDtJ0nh8Z3vefWysV/jc2j20LwVAFk1YczIPHWhzqx 2tPmVqNlJiAgL0kejIhO9igqnHwNBk5CQDMREI6vTkT87uj5q/OWOxiljk008e6DJm Wyc6NPHblK6OkQA2eqoXvfA8T+wNMRvqUjrr6KiM6UhfUrkcHS+Fn3DvPKyuRUygYP cBbHJpibmvWk92v0BX5xiv55xz/kVaFJOnuTlQFqd1a08xJvZ1kkQe/A/5wh9XRPks Qcv0qINm1Y9Vw== From: Roger Quadros <rogerq@kernel.org> To: davem@davemloft.net Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, vigneshr@ti.com, srk@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros <rogerq@kernel.org> Subject: [PATCH] net: ethernet: ti: cpsw_ale: optimize cpsw_ale_restore() Date: Tue, 8 Nov 2022 15:56:43 +0200 Message-Id: <20221108135643.15094-1-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748936553203351413?= X-GMAIL-MSGID: =?utf-8?q?1748936553203351413?= |
Series |
net: ethernet: ti: cpsw_ale: optimize cpsw_ale_restore()
|
|
Commit Message
Roger Quadros
Nov. 8, 2022, 1:56 p.m. UTC
If an entry was FREE then we don't have to restore it.
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
Patch depends on
https://lore.kernel.org/netdev/20221104132310.31577-3-rogerq@kernel.org/T/
drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On Tue, 8 Nov 2022 15:56:43 +0200 Roger Quadros wrote: > If an entry was FREE then we don't have to restore it. Motivation? Does it make the restore faster? > Signed-off-by: Roger Quadros <rogerq@kernel.org> > --- > > Patch depends on > https://lore.kernel.org/netdev/20221104132310.31577-3-rogerq@kernel.org/T/ > > drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c > index 0c5e783e574c..41bcf34a22f8 100644 > --- a/drivers/net/ethernet/ti/cpsw_ale.c > +++ b/drivers/net/ethernet/ti/cpsw_ale.c > @@ -1452,12 +1452,15 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) > } > } > > +/* ALE table should be cleared (ALE_CLEAR) before cpsw_ale_restore() */ Maybe my tree is old but I see we clear only if there is a netdev that needs to be opened but then always call ale_restore(). Is that okay? I'd also s/should/must/ > void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data) > { > - int i; > + int i, type; > > for (i = 0; i < ale->params.ale_entries; i++) { > - cpsw_ale_write(ale, i, data); > + type = cpsw_ale_get_entry_type(data); > + if (type != ALE_TYPE_FREE) > + cpsw_ale_write(ale, i, data); > data += ALE_ENTRY_WORDS; > } > }
On 10/11/2022 05:19, Jakub Kicinski wrote: > On Tue, 8 Nov 2022 15:56:43 +0200 Roger Quadros wrote: >> If an entry was FREE then we don't have to restore it. > > Motivation? Does it make the restore faster? Yes, since this would be called during system suspend/resume path. I will update the commit message to mention this. > >> Signed-off-by: Roger Quadros <rogerq@kernel.org> >> --- >> >> Patch depends on >> https://lore.kernel.org/netdev/20221104132310.31577-3-rogerq@kernel.org/T/ >> >> drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c >> index 0c5e783e574c..41bcf34a22f8 100644 >> --- a/drivers/net/ethernet/ti/cpsw_ale.c >> +++ b/drivers/net/ethernet/ti/cpsw_ale.c >> @@ -1452,12 +1452,15 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) >> } >> } >> >> +/* ALE table should be cleared (ALE_CLEAR) before cpsw_ale_restore() */ > > Maybe my tree is old but I see we clear only if there is a netdev that This patch depends on this series https://lore.kernel.org/netdev/20221104132310.31577-3-rogerq@kernel.org/T/ > needs to be opened but then always call ale_restore(). Is that okay? If netdev is closed and opened ale_restore() is not called. ale_restore() is only called during system suspend/resume path since CPSW-ALE might have lost context during suspend and we want to restore all valid ALE entries. I have a question here. How should ageable entries be treated in this case? > > I'd also s/should/must/ OK, will fix. > >> void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data) >> { >> - int i; >> + int i, type; >> >> for (i = 0; i < ale->params.ale_entries; i++) { >> - cpsw_ale_write(ale, i, data); >> + type = cpsw_ale_get_entry_type(data); >> + if (type != ALE_TYPE_FREE) >> + cpsw_ale_write(ale, i, data); >> data += ALE_ENTRY_WORDS; >> } >> } > cheers, -roger
On Thu, 10 Nov 2022 11:39:47 +0200 Roger Quadros wrote: > > Maybe my tree is old but I see we clear only if there is a netdev that > > This patch depends on this series > https://lore.kernel.org/netdev/20221104132310.31577-3-rogerq@kernel.org/T/ I do have those in my tree. > > needs to be opened but then always call ale_restore(). Is that okay? > > If netdev is closed and opened ale_restore() is not called. > ale_restore() is only called during system suspend/resume path > since CPSW-ALE might have lost context during suspend and we want to restore > all valid ALE entries. Ack, what I'm referring to is the contents of am65_cpsw_nuss_resume(). I'm guessing that ALE_CLEAR is expected to be triggered by cpsw_ale_start(). Assuming above is true and that ALE_CLEAR comes from cpsw_ale_start(), the call stack is: cpsw_ale_start() am65_cpsw_nuss_common_open() am65_cpsw_nuss_ndo_slave_open() am65_cpsw_nuss_resume() but resume() only calls ndo_slave_open under certain conditions: for (i = 0; i < common->port_num; i++) { if (netif_running(ndev)) { rtnl_lock(); ret = am65_cpsw_nuss_ndo_slave_open(ndev); Is there another path? Or perhaps there's nothing to restore if all netdevs are down? > I have a question here. How should ageable entries be treated in this case? Ah, no idea :) Let's me add experts to To:
Hi Jakub, On 10/11/2022 22:32, Jakub Kicinski wrote: > On Thu, 10 Nov 2022 11:39:47 +0200 Roger Quadros wrote: >>> Maybe my tree is old but I see we clear only if there is a netdev that >> >> This patch depends on this series >> https://lore.kernel.org/netdev/20221104132310.31577-3-rogerq@kernel.org/T/ > > I do have those in my tree. > >>> needs to be opened but then always call ale_restore(). Is that okay? >> >> If netdev is closed and opened ale_restore() is not called. >> ale_restore() is only called during system suspend/resume path >> since CPSW-ALE might have lost context during suspend and we want to restore >> all valid ALE entries. > > Ack, what I'm referring to is the contents of am65_cpsw_nuss_resume(). > > I'm guessing that ALE_CLEAR is expected to be triggered by > cpsw_ale_start(). > > Assuming above is true and that ALE_CLEAR comes from cpsw_ale_start(), > the call stack is: > > cpsw_ale_start() > am65_cpsw_nuss_common_open() > am65_cpsw_nuss_ndo_slave_open() > am65_cpsw_nuss_resume() > > but resume() only calls ndo_slave_open under certain conditions: > > for (i = 0; i < common->port_num; i++) { > if (netif_running(ndev)) { > rtnl_lock(); > ret = am65_cpsw_nuss_ndo_slave_open(ndev); > > Is there another path? Or perhaps there's nothing to restore > if all netdevs are down? I see your point now. We are missing a ALE_CLEAR if all interfaces were down during suspend/resume. In this case the call to cpsw_ale_restore() is pointless as ALE will be cleared again when one of the interfaces is brought up. I'll revise the patch to call cpsw_ale_restore only if any interface was running. > >> I have a question here. How should ageable entries be treated in this case? > > Ah, no idea :) Let's me add experts to To: Thanks. cheers, -roger
On Thu, Nov 10, 2022 at 12:32:49PM -0800, Jakub Kicinski wrote: > > I have a question here. How should ageable entries be treated in this case? > > Ah, no idea :) Let's me add experts to To: Not a real expert, but if suspend/resume loses the Ethernet link, I expect that no dynamically learned entries are preserved across a link loss event. In DSA for example, we only keep ageable entries in hardware as long as the port STP state, plus BR_LEARNING port flag, are compatible with having such FDB entries. Otherwise, any transition to such a state flushes the ageable FDB entries. A link loss generates a bridge port transition to the DISABLED state, which DSA uses to generate a SWITCHDEV_FDB_FLUSH_TO_BRIDGE event. I'm not sure if it would even be possible to accurately do the right thing and update the ageing timer of the FDB entries with the amount of time that the system was suspended.
On 11/11/2022 14:03, Vladimir Oltean wrote: > On Thu, Nov 10, 2022 at 12:32:49PM -0800, Jakub Kicinski wrote: >>> I have a question here. How should ageable entries be treated in this case? >> >> Ah, no idea :) Let's me add experts to To: > > Not a real expert, but if suspend/resume loses the Ethernet link, > I expect that no dynamically learned entries are preserved across > a link loss event. Understood. We loose the link in this particular case. > > In DSA for example, we only keep ageable entries in hardware as long as > the port STP state, plus BR_LEARNING port flag, are compatible with > having such FDB entries. Otherwise, any transition to such a state > flushes the ageable FDB entries. > > A link loss generates a bridge port transition to the DISABLED state, > which DSA uses to generate a SWITCHDEV_FDB_FLUSH_TO_BRIDGE event. > > I'm not sure if it would even be possible to accurately do the right > thing and update the ageing timer of the FDB entries with the amount of > time that the system was suspended. In that case I'll leave the entries as they are and let the Switch logic deal with the stale entries. They should eventually get flushed out. cheers, -roger
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c index 0c5e783e574c..41bcf34a22f8 100644 --- a/drivers/net/ethernet/ti/cpsw_ale.c +++ b/drivers/net/ethernet/ti/cpsw_ale.c @@ -1452,12 +1452,15 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) } } +/* ALE table should be cleared (ALE_CLEAR) before cpsw_ale_restore() */ void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data) { - int i; + int i, type; for (i = 0; i < ale->params.ale_entries; i++) { - cpsw_ale_write(ale, i, data); + type = cpsw_ale_get_entry_type(data); + if (type != ALE_TYPE_FREE) + cpsw_ale_write(ale, i, data); data += ALE_ENTRY_WORDS; } }