linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost
@ 2018-10-12 15:28 Ivan Khoronzhuk
  2018-10-12 15:28 ` [PATCH 1/2] net: ethernet: ti: cpsw_ale: use const for API having pointer on mac address Ivan Khoronzhuk
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ivan Khoronzhuk @ 2018-10-12 15:28 UTC (permalink / raw)
  To: grygorii.strashko, davem
  Cc: linux-omap, netdev, linux-kernel, Ivan Khoronzhuk

The patchset omits redundant refresh of mcast address table and
prevents mcast packet lost.

Based on net-next/master
tested on am572x evm

Ivan Khoronzhuk (2):
  net: ethernet: ti: cpsw_ale: use const for API having pointer on mac
    address
  net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode
    update

 drivers/net/ethernet/ti/cpsw.c     | 46 ++++++++++++++++++------------
 drivers/net/ethernet/ti/cpsw_ale.c | 12 ++++----
 drivers/net/ethernet/ti/cpsw_ale.h |  8 +++---
 3 files changed, 38 insertions(+), 28 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] net: ethernet: ti: cpsw_ale: use const for API having pointer on mac address
  2018-10-12 15:28 [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Ivan Khoronzhuk
@ 2018-10-12 15:28 ` Ivan Khoronzhuk
  2018-10-12 15:28 ` [PATCH 2/2] net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update Ivan Khoronzhuk
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ivan Khoronzhuk @ 2018-10-12 15:28 UTC (permalink / raw)
  To: grygorii.strashko, davem
  Cc: linux-omap, netdev, linux-kernel, Ivan Khoronzhuk

It allows to use function under callbacks with same const qualifier of
mac address for farther changes.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 drivers/net/ethernet/ti/cpsw_ale.c | 12 ++++++------
 drivers/net/ethernet/ti/cpsw_ale.h |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 5766225a4ce1..798c989d5d93 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -136,7 +136,7 @@ static inline void cpsw_ale_get_addr(u32 *ale_entry, u8 *addr)
 		addr[i] = cpsw_ale_get_field(ale_entry, 40 - 8*i, 8);
 }
 
-static inline void cpsw_ale_set_addr(u32 *ale_entry, u8 *addr)
+static inline void cpsw_ale_set_addr(u32 *ale_entry, const u8 *addr)
 {
 	int i;
 
@@ -175,7 +175,7 @@ static int cpsw_ale_write(struct cpsw_ale *ale, int idx, u32 *ale_entry)
 	return idx;
 }
 
-static int cpsw_ale_match_addr(struct cpsw_ale *ale, u8 *addr, u16 vid)
+static int cpsw_ale_match_addr(struct cpsw_ale *ale, const u8 *addr, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS];
 	int type, idx;
@@ -309,7 +309,7 @@ static inline void cpsw_ale_set_vlan_entry_type(u32 *ale_entry,
 	}
 }
 
-int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
+int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 		       int flags, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
@@ -336,7 +336,7 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_add_ucast);
 
-int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
+int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 		       int flags, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
@@ -352,7 +352,7 @@ int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_del_ucast);
 
-int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
+int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		       int flags, u16 vid, int mcast_state)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
@@ -386,7 +386,7 @@ int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_add_mcast);
 
-int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
+int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		       int flags, u16 vid)
 {
 	u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index d4fe9016429b..cd07a3e96d57 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.h
+++ b/drivers/net/ethernet/ti/cpsw_ale.h
@@ -105,13 +105,13 @@ void cpsw_ale_start(struct cpsw_ale *ale);
 void cpsw_ale_stop(struct cpsw_ale *ale);
 
 int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid);
-int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
+int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 		       int flags, u16 vid);
-int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
+int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 		       int flags, u16 vid);
-int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
+int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		       int flags, u16 vid, int mcast_state);
-int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
+int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
 		       int flags, u16 vid);
 int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
 			int reg_mcast, int unreg_mcast);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update
  2018-10-12 15:28 [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Ivan Khoronzhuk
  2018-10-12 15:28 ` [PATCH 1/2] net: ethernet: ti: cpsw_ale: use const for API having pointer on mac address Ivan Khoronzhuk
@ 2018-10-12 15:28 ` Ivan Khoronzhuk
  2018-10-13  0:38 ` [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Grygorii Strashko
  2018-10-16  5:21 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ivan Khoronzhuk @ 2018-10-12 15:28 UTC (permalink / raw)
  To: grygorii.strashko, davem
  Cc: linux-omap, netdev, linux-kernel, Ivan Khoronzhuk

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>
---
 drivers/net/ethernet/ti/cpsw.c | 46 +++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 832bce07c385..b7a6a2a0f71d 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -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;
 
@@ -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 */
@@ -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)
@@ -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);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost
  2018-10-12 15:28 [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Ivan Khoronzhuk
  2018-10-12 15:28 ` [PATCH 1/2] net: ethernet: ti: cpsw_ale: use const for API having pointer on mac address Ivan Khoronzhuk
  2018-10-12 15:28 ` [PATCH 2/2] net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update Ivan Khoronzhuk
@ 2018-10-13  0:38 ` Grygorii Strashko
  2018-10-16  5:21 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Grygorii Strashko @ 2018-10-13  0:38 UTC (permalink / raw)
  To: Ivan Khoronzhuk, davem; +Cc: linux-omap, netdev, linux-kernel



On 10/12/2018 10:28 AM, Ivan Khoronzhuk wrote:
> The patchset omits redundant refresh of mcast address table and
> prevents mcast packet lost.
> 
> Based on net-next/master
> tested on am572x evm
> 
> Ivan Khoronzhuk (2):
>    net: ethernet: ti: cpsw_ale: use const for API having pointer on mac
>      address
>    net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode
>      update
> 
>   drivers/net/ethernet/ti/cpsw.c     | 46 ++++++++++++++++++------------
>   drivers/net/ethernet/ti/cpsw_ale.c | 12 ++++----
>   drivers/net/ethernet/ti/cpsw_ale.h |  8 +++---
>   3 files changed, 38 insertions(+), 28 deletions(-)
> 


Thank you.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost
  2018-10-12 15:28 [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Ivan Khoronzhuk
                   ` (2 preceding siblings ...)
  2018-10-13  0:38 ` [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Grygorii Strashko
@ 2018-10-16  5:21 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-10-16  5:21 UTC (permalink / raw)
  To: ivan.khoronzhuk; +Cc: grygorii.strashko, linux-omap, netdev, linux-kernel

From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Date: Fri, 12 Oct 2018 18:28:13 +0300

> The patchset omits redundant refresh of mcast address table and
> prevents mcast packet lost.
> 
> Based on net-next/master
> tested on am572x evm

Series applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-16  5:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 15:28 [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Ivan Khoronzhuk
2018-10-12 15:28 ` [PATCH 1/2] net: ethernet: ti: cpsw_ale: use const for API having pointer on mac address Ivan Khoronzhuk
2018-10-12 15:28 ` [PATCH 2/2] net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update Ivan Khoronzhuk
2018-10-13  0:38 ` [PATCH 0/2] net: ethernet: ti: cpsw fix mcast packet lost Grygorii Strashko
2018-10-16  5:21 ` 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).