Skip to content

Commit

Permalink
net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update
Browse files Browse the repository at this point in the history
Whenever kernel or user decides to call rx mode update, it clears
every multicast entry from forwarding table and in some time adds
it again. This time can be enough to drop incoming multicast packets.

That's why clear only staled multicast entries and update or add new
one afterwards.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ivan Khoronzhuk authored and David S. Miller committed Oct 16, 2018
1 parent 58bdeac commit 5da1948
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions drivers/net/ethernet/ti/cpsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static inline int cpsw_get_slave_port(u32 slave_num)
return slave_num + 1;
}

static void cpsw_add_mcast(struct cpsw_priv *priv, u8 *addr)
static void cpsw_add_mcast(struct cpsw_priv *priv, const u8 *addr)
{
struct cpsw_common *cpsw = priv->cpsw;

Expand Down Expand Up @@ -662,16 +662,35 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
}
}

static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
static int cpsw_add_mc_addr(struct net_device *ndev, const u8 *addr)
{
struct cpsw_priv *priv = netdev_priv(ndev);

cpsw_add_mcast(priv, addr);
return 0;
}

static int cpsw_del_mc_addr(struct net_device *ndev, const u8 *addr)
{
struct cpsw_priv *priv = netdev_priv(ndev);
struct cpsw_common *cpsw = priv->cpsw;
int vid;
int vid, flags;

if (cpsw->data.dual_emac)
if (cpsw->data.dual_emac) {
vid = cpsw->slaves[priv->emac_port].port_vlan;
else
vid = cpsw->data.default_vlan;
flags = ALE_VLAN;
} else {
vid = 0;
flags = 0;
}

cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid);
return 0;
}

static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
{
struct cpsw_common *cpsw = ndev_to_cpsw(ndev);

if (ndev->flags & IFF_PROMISC) {
/* Enable promiscuous mode */
Expand All @@ -684,19 +703,9 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
}

/* Restore allmulti on vlans if necessary */
cpsw_ale_set_allmulti(cpsw->ale, priv->ndev->flags & IFF_ALLMULTI);

/* Clear all mcast from ALE */
cpsw_ale_flush_multicast(cpsw->ale, ALE_ALL_PORTS, vid);
cpsw_ale_set_allmulti(cpsw->ale, ndev->flags & IFF_ALLMULTI);

if (!netdev_mc_empty(ndev)) {
struct netdev_hw_addr *ha;

/* program multicast address list into ALE register */
netdev_for_each_mc_addr(ha, ndev) {
cpsw_add_mcast(priv, ha->addr);
}
}
__dev_mc_sync(ndev, cpsw_add_mc_addr, cpsw_del_mc_addr);
}

static void cpsw_intr_enable(struct cpsw_common *cpsw)
Expand Down Expand Up @@ -1956,6 +1965,7 @@ static int cpsw_ndo_stop(struct net_device *ndev)
struct cpsw_common *cpsw = priv->cpsw;

cpsw_info(priv, ifdown, "shutting down cpsw device\n");
__dev_mc_unsync(priv->ndev, cpsw_del_mc_addr);
netif_tx_stop_all_queues(priv->ndev);
netif_carrier_off(priv->ndev);

Expand Down

0 comments on commit 5da1948

Please sign in to comment.