netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: fec: Clear and enable MIB counters on imx51
@ 2017-06-07  1:57 Andrew Lunn
  2017-06-07 13:32 ` Fabio Estevam
  2017-06-07 14:07 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Lunn @ 2017-06-07  1:57 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Nikita Yushchenko, Fabio Estevam, Chris Healy,
	Andrew Lunn

Both the IMX51 and IMX53 datasheet indicates that the MIB counters
should be cleared during setup. Otherwise random numbers are returned
via ethtool -S.  Add a quirk and a function to do this.

Tested on an IMX51.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/freescale/fec.h      |  4 ++++
 drivers/net/ethernet/freescale/fec_main.c | 27 ++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 5ea740b4cf14..38c7b21e5d63 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -446,6 +446,10 @@ struct bufdesc_ex {
 #define FEC_QUIRK_HAS_COALESCE		(1 << 13)
 /* Interrupt doesn't wake CPU from deep idle */
 #define FEC_QUIRK_ERR006687		(1 << 14)
+/* The MIB counters should be cleared and enabled during
+ * initialisation.
+ */
+#define FEC_QUIRK_MIB_CLEAR		(1 << 15)
 
 struct bufdesc_prop {
 	int qid;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f7c8649fd28f..297fd196c879 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -89,10 +89,10 @@ static struct platform_device_id fec_devtype[] = {
 		.driver_data = 0,
 	}, {
 		.name = "imx25-fec",
-		.driver_data = FEC_QUIRK_USE_GASKET,
+		.driver_data = FEC_QUIRK_USE_GASKET | FEC_QUIRK_MIB_CLEAR,
 	}, {
 		.name = "imx27-fec",
-		.driver_data = 0,
+		.driver_data = FEC_QUIRK_MIB_CLEAR,
 	}, {
 		.name = "imx28-fec",
 		.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
@@ -184,6 +184,9 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
 #define FEC_RACC_SHIFT16	BIT(7)
 #define FEC_RACC_OPTIONS	(FEC_RACC_IPDIS | FEC_RACC_PRODIS)
 
+/* MIB Control Register */
+#define FEC_MIB_CTRLSTAT_DISABLE	BIT(31)
+
 /*
  * The 5270/5271/5280/5282/532x RX control register also contains maximum frame
  * size bits. Other FEC hardware does not, so we need to take that into
@@ -2356,6 +2359,21 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
 	}
 }
 
+static void fec_enet_clear_ethtool_stats(struct net_device *dev)
+{
+	struct fec_enet_private *fep = netdev_priv(dev);
+	int i;
+
+	/* Disable MIB statistics counters */
+	writel(FEC_MIB_CTRLSTAT_DISABLE, fep->hwp + FEC_MIB_CTRLSTAT);
+
+	for (i = 0; i < ARRAY_SIZE(fec_stats); i++)
+		writel(0, fep->hwp + fec_stats[i].offset);
+
+	/* Don't disable MIB statistics counters */
+	writel(0, fep->hwp + FEC_MIB_CTRLSTAT);
+}
+
 #else	/* !defined(CONFIG_M5272) */
 #define FEC_STATS_SIZE	0
 static inline void fec_enet_update_ethtool_stats(struct net_device *dev)
@@ -3182,7 +3200,10 @@ static int fec_enet_init(struct net_device *ndev)
 
 	fec_restart(ndev);
 
-	fec_enet_update_ethtool_stats(ndev);
+	if (fep->quirks & FEC_QUIRK_MIB_CLEAR)
+		fec_enet_clear_ethtool_stats(ndev);
+	else
+		fec_enet_update_ethtool_stats(ndev);
 
 	return 0;
 }
-- 
2.11.0

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

* Re: [PATCH net-next] net: fec: Clear and enable MIB counters on imx51
  2017-06-07  1:57 [PATCH net-next] net: fec: Clear and enable MIB counters on imx51 Andrew Lunn
@ 2017-06-07 13:32 ` Fabio Estevam
  2017-06-07 14:07 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2017-06-07 13:32 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David Miller, netdev, Nikita Yushchenko, Fabio Estevam,
	Chris Healy

On Tue, Jun 6, 2017 at 10:57 PM, Andrew Lunn <andrew@lunn.ch> wrote:
> Both the IMX51 and IMX53 datasheet indicates that the MIB counters
> should be cleared during setup. Otherwise random numbers are returned
> via ethtool -S.  Add a quirk and a function to do this.
>
> Tested on an IMX51.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Thanks for the fix:

Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>

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

* Re: [PATCH net-next] net: fec: Clear and enable MIB counters on imx51
  2017-06-07  1:57 [PATCH net-next] net: fec: Clear and enable MIB counters on imx51 Andrew Lunn
  2017-06-07 13:32 ` Fabio Estevam
@ 2017-06-07 14:07 ` David Miller
  2017-06-10  1:01   ` Paul Gortmaker
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2017-06-07 14:07 UTC (permalink / raw)
  To: andrew; +Cc: netdev, nikita.yoush, fabio.estevam, cphealy

From: Andrew Lunn <andrew@lunn.ch>
Date: Wed,  7 Jun 2017 03:57:09 +0200

> Both the IMX51 and IMX53 datasheet indicates that the MIB counters
> should be cleared during setup. Otherwise random numbers are returned
> via ethtool -S.  Add a quirk and a function to do this.
> 
> Tested on an IMX51.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Applied, thanks.

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

* Re: [PATCH net-next] net: fec: Clear and enable MIB counters on imx51
  2017-06-07 14:07 ` David Miller
@ 2017-06-10  1:01   ` Paul Gortmaker
  2017-06-10  1:12     ` Fabio Estevam
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Gortmaker @ 2017-06-10  1:01 UTC (permalink / raw)
  To: David Miller
  Cc: andrew, netdev, nikita.yoush, fabio.estevam, cphealy,
	linux-next@vger.kernel.org

On Wed, Jun 7, 2017 at 10:07 AM, David Miller <davem@davemloft.net> wrote:
> From: Andrew Lunn <andrew@lunn.ch>
> Date: Wed,  7 Jun 2017 03:57:09 +0200
>
>> Both the IMX51 and IMX53 datasheet indicates that the MIB counters
>> should be cleared during setup. Otherwise random numbers are returned
>> via ethtool -S.  Add a quirk and a function to do this.

Seems to break one of the automated linux-next builds:

http://kisskb.ellerman.id.au/kisskb/buildresult/13057702/

A mindless automated bisect reports:

2b30842b23b9e6796c7bd5f0916fd2ebf6b7d633 is the first bad commit
commit 2b30842b23b9e6796c7bd5f0916fd2ebf6b7d633
Author: Andrew Lunn <andrew@lunn.ch>
Date:   Wed Jun 7 03:57:09 2017 +0200

    net: fec: Clear and enable MIB counters on imx51

Paul.

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

* Re: [PATCH net-next] net: fec: Clear and enable MIB counters on imx51
  2017-06-10  1:01   ` Paul Gortmaker
@ 2017-06-10  1:12     ` Fabio Estevam
  0 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2017-06-10  1:12 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: David Miller, Andrew Lunn, netdev, Nikita Yushchenko,
	Fabio Estevam, Chris Healy, linux-next@vger.kernel.org

Hi Paul,

On Fri, Jun 9, 2017 at 10:01 PM, Paul Gortmaker
<paul.gortmaker@windriver.com> wrote:

> Seems to break one of the automated linux-next builds:
>
> http://kisskb.ellerman.id.au/kisskb/buildresult/13057702/
>
> A mindless automated bisect reports:
>
> 2b30842b23b9e6796c7bd5f0916fd2ebf6b7d633 is the first bad commit
> commit 2b30842b23b9e6796c7bd5f0916fd2ebf6b7d633
> Author: Andrew Lunn <andrew@lunn.ch>
> Date:   Wed Jun 7 03:57:09 2017 +0200
>
>     net: fec: Clear and enable MIB counters on imx51

This should fix it:

--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2379,6 +2379,10 @@ static void fec_enet_clear_ethtool_stats(struct
net_device *dev)
 static inline void fec_enet_update_ethtool_stats(struct net_device *dev)
 {
 }
+
+static inline void fec_enet_clear_ethtool_stats(struct net_device *dev)
+{
+}
 #endif /* !defined(CONFIG_M5272) */

 /* ITR clock source is enet system clock (clk_ahb).

Will test it and submit a formal patch in case it works.

Thanks

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

end of thread, other threads:[~2017-06-10  1:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07  1:57 [PATCH net-next] net: fec: Clear and enable MIB counters on imx51 Andrew Lunn
2017-06-07 13:32 ` Fabio Estevam
2017-06-07 14:07 ` David Miller
2017-06-10  1:01   ` Paul Gortmaker
2017-06-10  1:12     ` Fabio Estevam

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).