Skip to content

Commit 2b30842

Browse files
lunndavem330
authored andcommitted
net: fec: Clear and enable MIB counters on imx51
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 <[email protected]> Reviewed-by: Fabio Estevam <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 216fe8f commit 2b30842

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

drivers/net/ethernet/freescale/fec.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ struct bufdesc_ex {
446446
#define FEC_QUIRK_HAS_COALESCE (1 << 13)
447447
/* Interrupt doesn't wake CPU from deep idle */
448448
#define FEC_QUIRK_ERR006687 (1 << 14)
449+
/* The MIB counters should be cleared and enabled during
450+
* initialisation.
451+
*/
452+
#define FEC_QUIRK_MIB_CLEAR (1 << 15)
449453

450454
struct bufdesc_prop {
451455
int qid;

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ static struct platform_device_id fec_devtype[] = {
8989
.driver_data = 0,
9090
}, {
9191
.name = "imx25-fec",
92-
.driver_data = FEC_QUIRK_USE_GASKET,
92+
.driver_data = FEC_QUIRK_USE_GASKET | FEC_QUIRK_MIB_CLEAR,
9393
}, {
9494
.name = "imx27-fec",
95-
.driver_data = 0,
95+
.driver_data = FEC_QUIRK_MIB_CLEAR,
9696
}, {
9797
.name = "imx28-fec",
9898
.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
@@ -184,6 +184,9 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
184184
#define FEC_RACC_SHIFT16 BIT(7)
185185
#define FEC_RACC_OPTIONS (FEC_RACC_IPDIS | FEC_RACC_PRODIS)
186186

187+
/* MIB Control Register */
188+
#define FEC_MIB_CTRLSTAT_DISABLE BIT(31)
189+
187190
/*
188191
* The 5270/5271/5280/5282/532x RX control register also contains maximum frame
189192
* 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)
23562359
}
23572360
}
23582361

2362+
static void fec_enet_clear_ethtool_stats(struct net_device *dev)
2363+
{
2364+
struct fec_enet_private *fep = netdev_priv(dev);
2365+
int i;
2366+
2367+
/* Disable MIB statistics counters */
2368+
writel(FEC_MIB_CTRLSTAT_DISABLE, fep->hwp + FEC_MIB_CTRLSTAT);
2369+
2370+
for (i = 0; i < ARRAY_SIZE(fec_stats); i++)
2371+
writel(0, fep->hwp + fec_stats[i].offset);
2372+
2373+
/* Don't disable MIB statistics counters */
2374+
writel(0, fep->hwp + FEC_MIB_CTRLSTAT);
2375+
}
2376+
23592377
#else /* !defined(CONFIG_M5272) */
23602378
#define FEC_STATS_SIZE 0
23612379
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)
31823200

31833201
fec_restart(ndev);
31843202

3185-
fec_enet_update_ethtool_stats(ndev);
3203+
if (fep->quirks & FEC_QUIRK_MIB_CLEAR)
3204+
fec_enet_clear_ethtool_stats(ndev);
3205+
else
3206+
fec_enet_update_ethtool_stats(ndev);
31863207

31873208
return 0;
31883209
}

0 commit comments

Comments
 (0)