* [PATCH net] net: dsa: bcm_sf2: Fix ageing conditions and operation
@ 2015-09-05 20:07 Florian Fainelli
2015-09-09 5:28 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2015-09-05 20:07 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli, vivien.didelot, linux, andrew
The comparison check between cur_hw_state and hw_state is currently
invalid because cur_hw_state is right shifted by G_MISTP_SHIFT, while
hw_state is not, so we end-up comparing bits 2:0 with bits 7:5, which is
going to cause an additional aging to occur. Fix this by not shifting
cur_hw_state while reading it, but instead, mask the value with the
appropriately shitfted bitmask.
The other problem with the fast-ageing process is that we did not set
the EN_AGE_DYNAMIC bit to request the ageing to occur for dynamically
learned MAC addresses. Finally, write back 0 to the FAST_AGE_CTRL
register to avoid leaving spurious bits sets from one operation to the
other.
Fixes: 12f460f23423 ("net: dsa: bcm_sf2: add HW bridging support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
David, this dates back to 4.1, could you queue this for -stable?
Thanks!
drivers/net/dsa/bcm_sf2.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 289e20443d83..9d56515f4c4d 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -418,7 +418,7 @@ static int bcm_sf2_sw_fast_age_port(struct dsa_switch *ds, int port)
core_writel(priv, port, CORE_FAST_AGE_PORT);
reg = core_readl(priv, CORE_FAST_AGE_CTRL);
- reg |= EN_AGE_PORT | FAST_AGE_STR_DONE;
+ reg |= EN_AGE_PORT | EN_AGE_DYNAMIC | FAST_AGE_STR_DONE;
core_writel(priv, reg, CORE_FAST_AGE_CTRL);
do {
@@ -432,6 +432,8 @@ static int bcm_sf2_sw_fast_age_port(struct dsa_switch *ds, int port)
if (!timeout)
return -ETIMEDOUT;
+ core_writel(priv, 0, CORE_FAST_AGE_CTRL);
+
return 0;
}
@@ -507,7 +509,7 @@ static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
u32 reg;
reg = core_readl(priv, CORE_G_PCTL_PORT(port));
- cur_hw_state = reg >> G_MISTP_STATE_SHIFT;
+ cur_hw_state = reg & (G_MISTP_STATE_MASK << G_MISTP_STATE_SHIFT);
switch (state) {
case BR_STATE_DISABLED:
@@ -531,10 +533,12 @@ static int bcm_sf2_sw_br_set_stp_state(struct dsa_switch *ds, int port,
}
/* Fast-age ARL entries if we are moving a port from Learning or
- * Forwarding state to Disabled, Blocking or Listening state
+ * Forwarding (cur_hw_state) state to Disabled, Blocking or Listening
+ * state (hw_state)
*/
if (cur_hw_state != hw_state) {
- if (cur_hw_state & 4 && !(hw_state & 4)) {
+ if (cur_hw_state >= G_MISTP_LEARN_STATE &&
+ hw_state <= G_MISTP_LISTEN_STATE) {
ret = bcm_sf2_sw_fast_age_port(ds, port);
if (ret) {
pr_err("%s: fast-ageing failed\n", __func__);
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: dsa: bcm_sf2: Fix ageing conditions and operation
2015-09-05 20:07 [PATCH net] net: dsa: bcm_sf2: Fix ageing conditions and operation Florian Fainelli
@ 2015-09-09 5:28 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-09-09 5:28 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev, vivien.didelot, linux, andrew
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Sat, 5 Sep 2015 13:07:27 -0700
> The comparison check between cur_hw_state and hw_state is currently
> invalid because cur_hw_state is right shifted by G_MISTP_SHIFT, while
> hw_state is not, so we end-up comparing bits 2:0 with bits 7:5, which is
> going to cause an additional aging to occur. Fix this by not shifting
> cur_hw_state while reading it, but instead, mask the value with the
> appropriately shitfted bitmask.
>
> The other problem with the fast-ageing process is that we did not set
> the EN_AGE_DYNAMIC bit to request the ageing to occur for dynamically
> learned MAC addresses. Finally, write back 0 to the FAST_AGE_CTRL
> register to avoid leaving spurious bits sets from one operation to the
> other.
>
> Fixes: 12f460f23423 ("net: dsa: bcm_sf2: add HW bridging support")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> David, this dates back to 4.1, could you queue this for -stable?
Applied and queued up for -stable, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-09 5:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-05 20:07 [PATCH net] net: dsa: bcm_sf2: Fix ageing conditions and operation Florian Fainelli
2015-09-09 5:28 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).