net: ethernet: ti: cpsw_ale: optimize cpsw_ale_restore()
Subsystems (3)
Roger Quadros
reviewerPATCH 1/1 net: ethernet: ti: cpsw_ale: optimize cpsw_ale_restore()
If an entry was FREE then we don't have to restore it.
---
Patch depends on
https://lore.kernel.org/netdev/[email protected]/T/
drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/cpsw_ale.c +5 -2
@@ -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 ; } }
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerQuoted 1 line · 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?
Quoted 14 lines
Signed-off-by Roger Quadros <[email protected]>---
Patch depends on
https://lore.kernel.org/netdev/[email protected]/T/drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/ethernet/ti/cpsw_ale.c +0
-0
drivers/net/ethernet/ti/cpsw_ale.c void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) · line 1455
Quoted 4 lines
drivers/net/ethernet/ti/cpsw_ale.c +1
-0@@ -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/
Quoted 13 lines
drivers/net/ethernet/ti/cpsw_ale.c +4
-2void 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 ; } }
Roger Quadros
reviewerQuoted 4 lines · Jakub Kicinski
Quoted 1 line · 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.
Quoted 18 lines
Quoted 18 lines
Signed-off-by Roger Quadros <[email protected]>---
Patch depends on
https://lore.kernel.org/netdev/[email protected]/T/drivers/net/ethernet/ti/cpsw_ale.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/ethernet/ti/cpsw_ale.c +0
-0@@ -1452,12 +1452,15 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) } }
Quoted 3 lines
drivers/net/ethernet/ti/cpsw_ale.c void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) · line 1455
Quoted 1 line
drivers/net/ethernet/ti/cpsw_ale.c +1
-0+/* 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/[email protected]/T/
Quoted 1 line
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?
Quoted 2 lines
I'd also s/should/must/
OK, will fix.
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/ti/cpsw_ale.c +1
-1void cpsw_ale_restore (struct cpsw_ale *ale,u32 *data) { -int i; +int i, type;
Quoted 9 lines
drivers/net/ethernet/ti/cpsw_ale.c void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) · line 1466
Quoted 8 lines
drivers/net/ethernet/ti/cpsw_ale.c +3
-1for (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
Jakub Kicinski
maintainerQuoted 4 lines · On Thu, 10 Nov 2022 11:39:47 +0200 Roger Quadros wrote:
Quoted 1 line
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/[email protected]/T/
I do have those in my tree.
Quoted 6 lines
Quoted 1 line
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?
Quoted 1 line
I have a question here. How should ageable entries be treated in this case?
Ah, no idea :) Let's me add experts to To:
Roger Quadros
reviewerHi Jakub,
Quoted 30 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 10 Nov 2022 11:39:47 +0200 Roger Quadros wrote:
Quoted 1 line
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/[email protected]/T/I do have those in my tree.
Quoted 6 lines
Quoted 1 line
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_CLEARis expected to be triggered bycpsw_ale_start().Assuming above is true and that
ALE_CLEARcomes fromcpsw_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 callsndo_slave_openunder certain conditions:
Quoted 7 lines
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.
Quoted 4 lines
Quoted 2 lines
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
Quoted 3 lines · Jakub Kicinski
Quoted 1 line
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.
Roger Quadros
reviewerQuoted 8 lines · Vladimir Oltean
Quoted 3 lines · Jakub Kicinski
Quoted 1 line
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.
Quoted 6 lines
In DSA for example, we only keep ageable entries in hardware as long as the port STP state, plus
BR_LEARNINGport flag, are compatible with having such FDB entries. Otherwise, any transition to such a state flushes the ageable FDB entries.
Quoted 6 lines
A link loss generates a bridge port transition to the DISABLED state, which DSA uses to generate a
SWITCHDEV_FDB_FLUSH_TO_BRIDGEevent.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