Skip to contentSkip to conversation

fec_mpc52xx: add NAPI support

RFC-PATCH Wolfgang Grandegger 1 participant 1 message Mar 31, 2010 Network drivers

lore
Share & tools
lore
#0 lore raw

This patch adds NAPI support to the MPC52xx FEC network driver. The main reason for using NAPI is to solve the problem of system hangs under heavy packet storms causing interrupt flooding. While NAPI support is straight-forward, recovering from RX FIFO errors is more delicate. Actually, under packet storms, the RX FIFO error is triggered, requiring a full reset of the FEC and the Bestcom tasks. Furthermore, the link goes down and the only way to recover is to reset the phy as well. To handle the reset properly, it's performed by a work queue task. The reset does not really harm because the packets can not be digested (processed) by the system at that rate anyhow. NAPI can be enabled via Kconfig parameter CONFIG_FEC_MPC52xx_NAPI. Throughput measurements with netperf showed almost the same results with and without NAPI.

---
 drivers/net/Kconfig           |    7 +++
 drivers/net/fec_mpc52xx.c     |  121 ++++++++++++++++++++++++++++++++++++++++-
 drivers/net/fec_mpc52xx_phy.c |    4 +-
 3 files changed, 127 insertions(+), 5 deletions(-)
drivers/net/Kconfig +7 -0
index 0ba5b8e..b973e28 100644
@@ -1938,6 +1938,13 @@ config FEC_MPC52xx
 	  Fast Ethernet Controller
 	  If compiled as module, it will be called fec_mpc52xx.
 
+config FEC_MPC52xx_NAPI
+	bool "Use NAPI for MPC52xx FEC driver"
+	depends on FEC_MPC52xx
+	---help---
+	  This option enables NAPI support for the MPC5200's on-chip
+	  Fast Ethernet Controller driver.
+
 config FEC_MPC52xx_MDIO
 	bool "MPC52xx FEC MDIO bus driver"
 	depends on FEC_MPC52xx
drivers/net/fec_mpc52xx.c +118 -3

219 lines not on this page · raw message

drivers/net/fec_mpc52xx_phy.c +2 -2
index ee0f3c6..4f02f8b 100644
@@ -29,7 +29,7 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
 {
 	struct mpc52xx_fec_mdio_priv *priv = bus->priv;
 	struct mpc52xx_fec __iomem *fec;
-	int tries = 3;
+	int tries = 10;
 
 	value |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK;
 	value |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK;
@@ -40,7 +40,7 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
 
 	/* wait for it to finish, this takes about 23 us on lite5200b */
 	while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries)
-		msleep(1);
+		udelay(10);
 
 	if (!tries)
 		return -ETIMEDOUT;
Signature · 1 line
1.6.2.5