Skip to contentSkip to conversation

net: cpsw: fix dual_emac VLAN issue

PATCH In review [email protected] 2 participants 3 messages Apr 9, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: cpsw: fix dual_emac VLAN issue

From: Yegor Yefremov <[email protected]>

dual_emac mode was first introduced in TI's PSP kernel 3.2. See repository git://arago-project.org/git/projects/linux-am33x.git
commit 6afa003a0b06a0376c941436b38204ba2edc4a98.

Since commit d9ba8f9e6298af71ec1c1fd3d88c3ef68abd0ec3 dual_emac feature was upstreamed, but with some changes compared to the original source, that led to following behavior:

Some stations in LAN don't answer CPSW's ARP request. PSP kernel 3.2 could talk to all stations in the same LAN.

Use the same cpsw_ale_add_vlan procedure as in PSP kernel 3.2 to fix this regression.

---
Changes:
v2: make more detailed description

 drivers/net/ethernet/ti/cpsw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/ethernet/ti/cpsw.c +3 -1
index 5d5fec6..aa06370 100644
@@ -1040,11 +1040,13 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
 	else
 		slave_write(slave, slave->port_vlan, CPSW2_PORT_VLAN);
 	cpsw_ale_add_vlan(priv->ale, slave->port_vlan, port_mask,
-			  port_mask, port_mask, 0);
+			  0, port_mask, port_mask);
 	cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
 			   port_mask, ALE_VLAN, slave->port_vlan, 0);
 	cpsw_ale_add_ucast(priv->ale, priv->mac_addr,
 		priv->host_port, ALE_VLAN, slave->port_vlan);
+	cpsw_ale_add_vlan(priv->ale, 0, ALE_ALL_PORTS << priv->host_port,
+		ALE_ALL_PORTS << priv->host_port, priv->host_port, 0);
 }
 
 static void soft_reset_slave(struct cpsw_slave *slave)
Signature · 1 line
1.7.7
#1 lore raw
Quoted 30 lines · On Wednesday 09 April 2014 06:23 PM, [email protected] wrote:

From: Yegor Yefremov <[email protected]>

dual_emac mode was first introduced in TI's PSP kernel 3.2. See repository git://arago-project.org/git/projects/linux-am33x.git
commit 6afa003a0b06a0376c941436b38204ba2edc4a98.

Since commit d9ba8f9e6298af71ec1c1fd3d88c3ef68abd0ec3 dual_emac feature was upstreamed, but with some changes compared to the original source, that led to following behavior:

Some stations in LAN don't answer CPSW's ARP request. PSP kernel 3.2 could talk to all stations in the same LAN.

Use the same cpsw_ale_add_vlan procedure as in PSP kernel 3.2 to fix this regression.

---
Changes:
v2: make more detailed description

 drivers/net/ethernet/ti/cpsw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/ethernet/ti/cpsw.c +0 -0
index 5d5fec6..aa06370 100644

drivers/net/ethernet/ti/cpsw.c static inline void cpsw_add_dual_emac_def_ale_entries( · line 1043

Quoted 5 lines
drivers/net/ethernet/ti/cpsw.c +1 -1
@@ -1040,11 +1040,13 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
 	else
 		slave_write(slave, slave->port_vlan, CPSW2_PORT_VLAN);
 	cpsw_ale_add_vlan(priv->ale, slave->port_vlan, port_mask,
-			  port_mask, port_mask, 0);
+			  0, port_mask, port_mask);

Dual EMAC VLAN must be untagged on egress and why you need unregistered multicast packet to be passed to CPU?

drivers/net/ethernet/ti/cpsw.c static inline void cpsw_add_dual_emac_def_ale_entries( · line 1049

Quoted 6 lines
drivers/net/ethernet/ti/cpsw.c +2 -0
 	cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
 			   port_mask, ALE_VLAN, slave->port_vlan, 0);
 	cpsw_ale_add_ucast(priv->ale, priv->mac_addr,
 		priv->host_port, ALE_VLAN, slave->port_vlan);
+	cpsw_ale_add_vlan(priv->ale, 0, ALE_ALL_PORTS << priv->host_port,
+		ALE_ALL_PORTS << priv->host_port, priv->host_port, 0);

Vlan ID 0 must not be used, cpsw default vlan id should be used, currently 0 is used as default VLAN for internal packet switching, in case some one using different default vlan id, then this fix will break.

I have fixed the issue already and submitted a patch.
http://patchwork.ozlabs.org/patch/337769/

Regards
Mugunthan V N

#2 lore raw
Quoted 47 lines · Mugunthan V N
Quoted 30 lines · On Wednesday 09 April 2014 06:23 PM, [email protected] wrote:

From: Yegor Yefremov <[email protected]>

dual_emac mode was first introduced in TI's PSP kernel 3.2. See repository git://arago-project.org/git/projects/linux-am33x.git
commit 6afa003a0b06a0376c941436b38204ba2edc4a98.

Since commit d9ba8f9e6298af71ec1c1fd3d88c3ef68abd0ec3 dual_emac feature was upstreamed, but with some changes compared to the original source, that led to following behavior:

Some stations in LAN don't answer CPSW's ARP request. PSP kernel 3.2 could talk to all stations in the same LAN.

Use the same cpsw_ale_add_vlan procedure as in PSP kernel 3.2 to fix this regression.

---
Changes:
v2: make more detailed description

 drivers/net/ethernet/ti/cpsw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/ethernet/ti/cpsw.c +0 -0
index 5d5fec6..aa06370 100644

drivers/net/ethernet/ti/cpsw.c static inline void cpsw_add_dual_emac_def_ale_entries( · line 1043

Quoted 5 lines
drivers/net/ethernet/ti/cpsw.c +1 -1
@@ -1040,11 +1040,13 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
      else
              slave_write(slave, slave->port_vlan, CPSW2_PORT_VLAN);
      cpsw_ale_add_vlan(priv->ale, slave->port_vlan, port_mask,
-                       port_mask, port_mask, 0);
+                       0, port_mask, port_mask);

Dual EMAC VLAN must be untagged on egress and why you need unregistered multicast packet to be passed to CPU?

drivers/net/ethernet/ti/cpsw.c static inline void cpsw_add_dual_emac_def_ale_entries( · line 1049

Quoted 6 lines
drivers/net/ethernet/ti/cpsw.c +2 -0
      cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
                         port_mask, ALE_VLAN, slave->port_vlan, 0);
      cpsw_ale_add_ucast(priv->ale, priv->mac_addr,
              priv->host_port, ALE_VLAN, slave->port_vlan);
+     cpsw_ale_add_vlan(priv->ale, 0, ALE_ALL_PORTS << priv->host_port,
+             ALE_ALL_PORTS << priv->host_port, priv->host_port, 0);
Quoted 6 lines

Vlan ID 0 must not be used, cpsw default vlan id should be used, currently 0 is used as default VLAN for internal packet switching, in case some one using different default vlan id, then this fix will break.

I have fixed the issue already and submitted a patch.
http://patchwork.ozlabs.org/patch/337769/

Good to know. I've tested it and I can talk to all stations now. Thanks.

I just compared both drivers (3.2 and upstream) and this was the first routine, that caught my eye, after implementing it the way 3.2 did, I got needed features running. But I wasn't sure, if my fix was correct, that's why I asked for testing and commenting.

Yegor