Skip to content

Commit 35532c2

Browse files
Lennart Sorensendavem330
authored andcommitted
drivers: net: cpsw: Fix broken loop condition in switch mode
0d961b3 (drivers: net: cpsw: fix buggy loop condition) accidentally fixed a loop comparison in too many places while fixing a real bug. It was correct to fix the dual_emac mode section since there 'i' is used as an index into priv->slaves which is a 0 based array. However the other two changes (which are only used in switch mode) are wrong since there 'i' is actually the ALE port number, and port 0 is the host port, while port 1 and up are the slave ports. Putting the loop condition back in the switch mode section fixes it. A comment has been added to point out the intent clearly to avoid future confusion. Also a comment is fixed that said the opposite of what was actually happening. Signed-off-by: Len Sorensen <lsorense@csclub.uwaterloo.ca> Acked-by: Heiko Schocher <hs@denx.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0089b74 commit 35532c2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
591591
if (enable) {
592592
unsigned long timeout = jiffies + HZ;
593593

594-
/* Disable Learn for all ports */
595-
for (i = 0; i < priv->data.slaves; i++) {
594+
/* Disable Learn for all ports (host is port 0 and slaves are port 1 and up */
595+
for (i = 0; i <= priv->data.slaves; i++) {
596596
cpsw_ale_control_set(ale, i,
597597
ALE_PORT_NOLEARN, 1);
598598
cpsw_ale_control_set(ale, i,
@@ -616,11 +616,11 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
616616
cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1);
617617
dev_dbg(&ndev->dev, "promiscuity enabled\n");
618618
} else {
619-
/* Flood All Unicast Packets to Host port */
619+
/* Don't Flood All Unicast Packets to Host port */
620620
cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0);
621621

622-
/* Enable Learn for all ports */
623-
for (i = 0; i < priv->data.slaves; i++) {
622+
/* Enable Learn for all ports (host is port 0 and slaves are port 1 and up */
623+
for (i = 0; i <= priv->data.slaves; i++) {
624624
cpsw_ale_control_set(ale, i,
625625
ALE_PORT_NOLEARN, 0);
626626
cpsw_ale_control_set(ale, i,

0 commit comments

Comments
 (0)