Commit 5b3a5a14 authored by Ivan Khoronzhuk's avatar Ivan Khoronzhuk Committed by David S. Miller

net: ethernet: ti: cpsw: use for mcast entries only host port

In dual-emac mode the cpsw driver sends directed packets, that means
that packets go to the directed port, but an ALE lookup is performed
to determine untagged egress only. It means that on tx side no need
to add port bit for ALE mcast entry mask, and basically ALE entry
for port identification is needed only on rx side.

So, add only host port in dual_emac mode as used directed
transmission, and no need in one more port. For single port boards
and switch mode all ports used, as usual, so no changes for them.
Also it simplifies farther changes.

In other words, mcast entries for dual-emac should behave exactly
like unicast. It also can help avoid leaking packets between ports
with same vlan on h/w level if ports could became members of same vid.

So now, for instance, if mcast address 33:33:00:00:00:01 is added then
entries in ALE table:

vid = 1, addr = 33:33:00:00:00:01, port_mask = 0x1
vid = 2, addr = 33:33:00:00:00:01, port_mask = 0x1

Instead of:
vid = 1, addr = 33:33:00:00:00:01, port_mask = 0x3
vid = 2, addr = 33:33:00:00:00:01, port_mask = 0x5

With the same considerations, set only host port for unregistered
mcast for dual-emac mode in case of IFF_ALLMULTI is set, exactly like
it's done in cpsw_ale_set_allmulti().
Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ba722f9b
...@@ -576,10 +576,8 @@ static void cpsw_add_mcast(struct cpsw_priv *priv, const u8 *addr) ...@@ -576,10 +576,8 @@ static void cpsw_add_mcast(struct cpsw_priv *priv, const u8 *addr)
if (cpsw->data.dual_emac) { if (cpsw->data.dual_emac) {
struct cpsw_slave *slave = cpsw->slaves + priv->emac_port; struct cpsw_slave *slave = cpsw->slaves + priv->emac_port;
int slave_port = cpsw_get_slave_port(slave->slave_num);
cpsw_ale_add_mcast(cpsw->ale, addr, cpsw_ale_add_mcast(cpsw->ale, addr, ALE_PORT_HOST,
1 << slave_port | ALE_PORT_HOST,
ALE_VLAN, slave->port_vlan, 0); ALE_VLAN, slave->port_vlan, 0);
return; return;
} }
...@@ -1419,7 +1417,7 @@ static inline void cpsw_add_dual_emac_def_ale_entries( ...@@ -1419,7 +1417,7 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask, cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask,
port_mask, port_mask, 0); port_mask, port_mask, 0);
cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
port_mask, ALE_VLAN, slave->port_vlan, 0); ALE_PORT_HOST, ALE_VLAN, slave->port_vlan, 0);
cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr,
HOST_PORT_NUM, ALE_VLAN | HOST_PORT_NUM, ALE_VLAN |
ALE_SECURE, slave->port_vlan); ALE_SECURE, slave->port_vlan);
...@@ -2303,16 +2301,19 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv, ...@@ -2303,16 +2301,19 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
{ {
int ret; int ret;
int unreg_mcast_mask = 0; int unreg_mcast_mask = 0;
int mcast_mask;
u32 port_mask; u32 port_mask;
struct cpsw_common *cpsw = priv->cpsw; struct cpsw_common *cpsw = priv->cpsw;
if (cpsw->data.dual_emac) { if (cpsw->data.dual_emac) {
port_mask = (1 << (priv->emac_port + 1)) | ALE_PORT_HOST; port_mask = (1 << (priv->emac_port + 1)) | ALE_PORT_HOST;
mcast_mask = ALE_PORT_HOST;
if (priv->ndev->flags & IFF_ALLMULTI) if (priv->ndev->flags & IFF_ALLMULTI)
unreg_mcast_mask = port_mask; unreg_mcast_mask = mcast_mask;
} else { } else {
port_mask = ALE_ALL_PORTS; port_mask = ALE_ALL_PORTS;
mcast_mask = port_mask;
if (priv->ndev->flags & IFF_ALLMULTI) if (priv->ndev->flags & IFF_ALLMULTI)
unreg_mcast_mask = ALE_ALL_PORTS; unreg_mcast_mask = ALE_ALL_PORTS;
...@@ -2331,7 +2332,7 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv, ...@@ -2331,7 +2332,7 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
goto clean_vid; goto clean_vid;
ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast,
port_mask, ALE_VLAN, vid, 0); mcast_mask, ALE_VLAN, vid, 0);
if (ret != 0) if (ret != 0)
goto clean_vlan_ucast; goto clean_vlan_ucast;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment