netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: fec: reset rx mode when do suspend/resume or link status change
@ 2013-06-27  5:09 Fugang Duan
  2013-06-27 13:15 ` Shawn Guo
  0 siblings, 1 reply; 4+ messages in thread
From: Fugang Duan @ 2013-06-27  5:09 UTC (permalink / raw)
  To: b20596, davem; +Cc: netdev, shawn.guo, bhutchings, R49496, stephen

When do suspend/resume, or plug/unplug network cable, or net watchdog
timeout process, fec_restart reinit the enet group hash table to zero.

It is not reasonable for this, so re-config the enet group hash table
when these actions happen.

Signed-off-by: Fugang Duan  <B38611@freescale.com>
---
 drivers/net/ethernet/freescale/fec_main.c |  153 ++++++++++++++---------------
 1 files changed, 76 insertions(+), 77 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index a667015..ce7615d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -264,6 +264,81 @@ fec_enet_clear_csum(struct sk_buff *skb, struct net_device *ndev)
 	return 0;
 }
 
+/* Set or clear the multicast filter for this adaptor.
+ * Skeleton taken from sunlance driver.
+ * The CPM Ethernet implementation allows Multicast as well as individual
+ * MAC address filtering.  Some of the drivers check to make sure it is
+ * a group multicast address, and discard those that are not.  I guess I
+ * will do the same for now, but just remove the test if you want
+ * individual filtering as well (do the upper net layers want or support
+ * this kind of feature?).
+ */
+
+#define HASH_BITS	6		/* #bits in hash */
+#define CRC32_POLY	0xEDB88320
+
+static void set_multicast_list(struct net_device *ndev)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+	struct netdev_hw_addr *ha;
+	unsigned int i, bit, data, crc, tmp;
+	unsigned char hash;
+
+	if (ndev->flags & IFF_PROMISC) {
+		tmp = readl(fep->hwp + FEC_R_CNTRL);
+		tmp |= 0x8;
+		writel(tmp, fep->hwp + FEC_R_CNTRL);
+		return;
+	}
+
+	tmp = readl(fep->hwp + FEC_R_CNTRL);
+	tmp &= ~0x8;
+	writel(tmp, fep->hwp + FEC_R_CNTRL);
+
+	if (ndev->flags & IFF_ALLMULTI) {
+		/* Catch all multicast addresses, so set the
+		 * filter to all 1's
+		 */
+		writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+		writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+
+		return;
+	}
+
+	/* Clear filter and add the addresses in hash register
+	 */
+	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+
+	netdev_for_each_mc_addr(ha, ndev) {
+		/* calculate crc32 value of mac address */
+		crc = 0xffffffff;
+
+		for (i = 0; i < ndev->addr_len; i++) {
+			data = ha->addr[i];
+			for (bit = 0; bit < 8; bit++, data >>= 1) {
+				crc = (crc >> 1) ^
+				(((crc ^ data) & 1) ? CRC32_POLY : 0);
+			}
+		}
+
+		/* only upper 6 bits (HASH_BITS) are used
+		 * which point to specific bit in he hash registers
+		 */
+		hash = (crc >> (32 - HASH_BITS)) & 0x3f;
+
+		if (hash > 31) {
+			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+			tmp |= 1 << (hash - 32);
+			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
+		} else {
+			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+			tmp |= 1 << hash;
+			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+		}
+	}
+}
+
 static netdev_tx_t
 fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
@@ -472,8 +547,7 @@ fec_restart(struct net_device *ndev, int duplex)
 	writel(0xffc00000, fep->hwp + FEC_IEVENT);
 
 	/* Reset all multicast.	*/
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
+	set_multicast_list(ndev);
 #ifndef CONFIG_M5272
 	writel(0, fep->hwp + FEC_HASH_TABLE_HIGH);
 	writel(0, fep->hwp + FEC_HASH_TABLE_LOW);
@@ -1590,81 +1664,6 @@ fec_enet_close(struct net_device *ndev)
 	return 0;
 }
 
-/* Set or clear the multicast filter for this adaptor.
- * Skeleton taken from sunlance driver.
- * The CPM Ethernet implementation allows Multicast as well as individual
- * MAC address filtering.  Some of the drivers check to make sure it is
- * a group multicast address, and discard those that are not.  I guess I
- * will do the same for now, but just remove the test if you want
- * individual filtering as well (do the upper net layers want or support
- * this kind of feature?).
- */
-
-#define HASH_BITS	6		/* #bits in hash */
-#define CRC32_POLY	0xEDB88320
-
-static void set_multicast_list(struct net_device *ndev)
-{
-	struct fec_enet_private *fep = netdev_priv(ndev);
-	struct netdev_hw_addr *ha;
-	unsigned int i, bit, data, crc, tmp;
-	unsigned char hash;
-
-	if (ndev->flags & IFF_PROMISC) {
-		tmp = readl(fep->hwp + FEC_R_CNTRL);
-		tmp |= 0x8;
-		writel(tmp, fep->hwp + FEC_R_CNTRL);
-		return;
-	}
-
-	tmp = readl(fep->hwp + FEC_R_CNTRL);
-	tmp &= ~0x8;
-	writel(tmp, fep->hwp + FEC_R_CNTRL);
-
-	if (ndev->flags & IFF_ALLMULTI) {
-		/* Catch all multicast addresses, so set the
-		 * filter to all 1's
-		 */
-		writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-		writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-
-		return;
-	}
-
-	/* Clear filter and add the addresses in hash register
-	 */
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-	writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-
-	netdev_for_each_mc_addr(ha, ndev) {
-		/* calculate crc32 value of mac address */
-		crc = 0xffffffff;
-
-		for (i = 0; i < ndev->addr_len; i++) {
-			data = ha->addr[i];
-			for (bit = 0; bit < 8; bit++, data >>= 1) {
-				crc = (crc >> 1) ^
-				(((crc ^ data) & 1) ? CRC32_POLY : 0);
-			}
-		}
-
-		/* only upper 6 bits (HASH_BITS) are used
-		 * which point to specific bit in he hash registers
-		 */
-		hash = (crc >> (32 - HASH_BITS)) & 0x3f;
-
-		if (hash > 31) {
-			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-			tmp |= 1 << (hash - 32);
-			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
-		} else {
-			tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-			tmp |= 1 << hash;
-			writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
-		}
-	}
-}
-
 /* Set a MAC change in hardware. */
 static int
 fec_set_mac_address(struct net_device *ndev, void *p)
-- 
1.7.1

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

* Re: [PATCH] net: fec: reset rx mode when do suspend/resume or link status change
  2013-06-27  5:09 [PATCH] net: fec: reset rx mode when do suspend/resume or link status change Fugang Duan
@ 2013-06-27 13:15 ` Shawn Guo
  2013-06-27 13:21   ` Fabio Estevam
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2013-06-27 13:15 UTC (permalink / raw)
  To: Fugang Duan; +Cc: b20596, davem, netdev, bhutchings, R49496, stephen

On Thu, Jun 27, 2013 at 01:09:19PM +0800, Fugang Duan wrote:
> When do suspend/resume, or plug/unplug network cable, or net watchdog
> timeout process, fec_restart reinit the enet group hash table to zero.
> 
> It is not reasonable for this, so re-config the enet group hash table
> when these actions happen.
> 
> Signed-off-by: Fugang Duan  <B38611@freescale.com>
> ---
>  drivers/net/ethernet/freescale/fec_main.c |  153 ++++++++++++++---------------
>  1 files changed, 76 insertions(+), 77 deletions(-)

A forward declaration of set_multicast_list() can simply save these
dramatic diff stat?

Shawn

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

* Re: [PATCH] net: fec: reset rx mode when do suspend/resume or link status change
  2013-06-27 13:15 ` Shawn Guo
@ 2013-06-27 13:21   ` Fabio Estevam
  2013-06-29  4:25     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2013-06-27 13:21 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Fugang Duan, b20596, davem, netdev, bhutchings, R49496, stephen,
	christoph.muellner

On Thu, Jun 27, 2013 at 10:15 AM, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Thu, Jun 27, 2013 at 01:09:19PM +0800, Fugang Duan wrote:
>> When do suspend/resume, or plug/unplug network cable, or net watchdog
>> timeout process, fec_restart reinit the enet group hash table to zero.
>>
>> It is not reasonable for this, so re-config the enet group hash table
>> when these actions happen.
>>
>> Signed-off-by: Fugang Duan  <B38611@freescale.com>
>> ---
>>  drivers/net/ethernet/freescale/fec_main.c |  153 ++++++++++++++---------------
>>  1 files changed, 76 insertions(+), 77 deletions(-)
>
> A forward declaration of set_multicast_list() can simply save these
> dramatic diff stat?

Correct, and this has been already been posted:
http://patchwork.ozlabs.org/patch/253290/

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

* Re: [PATCH] net: fec: reset rx mode when do suspend/resume or link status change
  2013-06-27 13:21   ` Fabio Estevam
@ 2013-06-29  4:25     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-06-29  4:25 UTC (permalink / raw)
  To: festevam
  Cc: shawn.guo, B38611, b20596, netdev, bhutchings, R49496, stephen,
	christoph.muellner

From: Fabio Estevam <festevam@gmail.com>
Date: Thu, 27 Jun 2013 10:21:14 -0300

> On Thu, Jun 27, 2013 at 10:15 AM, Shawn Guo <shawn.guo@linaro.org> wrote:
>> On Thu, Jun 27, 2013 at 01:09:19PM +0800, Fugang Duan wrote:
>>> When do suspend/resume, or plug/unplug network cable, or net watchdog
>>> timeout process, fec_restart reinit the enet group hash table to zero.
>>>
>>> It is not reasonable for this, so re-config the enet group hash table
>>> when these actions happen.
>>>
>>> Signed-off-by: Fugang Duan  <B38611@freescale.com>
>>> ---
>>>  drivers/net/ethernet/freescale/fec_main.c |  153 ++++++++++++++---------------
>>>  1 files changed, 76 insertions(+), 77 deletions(-)
>>
>> A forward declaration of set_multicast_list() can simply save these
>> dramatic diff stat?
> 
> Correct, and this has been already been posted:
> http://patchwork.ozlabs.org/patch/253290/

A new version of that patch needs to be posted, and then this one respun
against it.

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

end of thread, other threads:[~2013-06-29  4:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-27  5:09 [PATCH] net: fec: reset rx mode when do suspend/resume or link status change Fugang Duan
2013-06-27 13:15 ` Shawn Guo
2013-06-27 13:21   ` Fabio Estevam
2013-06-29  4:25     ` 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).