[PATCH] if_sis conversion from if_watchdog to sis_watchdog

From: Florian C. Smeets <flo_at_kasimir.com>
Date: Sat, 24 Feb 2007 15:19:56 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

i made a patch which converts if_sis from using the deprecated
if_watchdog interface to using sis_watchdog. As an example i used the
if_rl and if_fxp conversion.

This patch is running on my internet router for > 12 hours and i seems
to work fine.

Cheers
Florian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFF4EmMA+1tjUZ1YScRArEvAJ9GgfBE1b+g+JF+7PL80zNd1OUP4ACfR+cC
0zLtWf4vsm8Jf/pkcrwCeAI=
=Lbi3
-----END PGP SIGNATURE-----

--- if_sis.c.org	Fri Feb 23 23:28:15 2007
+++ if_sis.c	Sat Feb 24 11:26:23 2007
_at__at_ -137,7 +137,7 _at__at_
 static void sis_start(struct ifnet *);
 static void sis_startl(struct ifnet *);
 static void sis_stop(struct sis_softc *);
-static void sis_watchdog(struct ifnet *);
+static void sis_watchdog(struct sis_softc *);
 
 
 static struct resource_spec sis_res_spec[] = {
_at__at_ -1193,7 +1193,6 _at__at_
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = sis_ioctl;
 	ifp->if_start = sis_start;
-	ifp->if_watchdog = sis_watchdog;
 	ifp->if_init = sis_init;
 	IFQ_SET_MAXLEN(&ifp->if_snd, SIS_TX_LIST_CNT - 1);
 	ifp->if_snd.ifq_drv_maxlen = SIS_TX_LIST_CNT - 1;
_at__at_ -1540,7 +1539,7 _at__at_
 		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	}
 
-	ifp->if_timer = (sc->sis_tx_cnt == 0) ? 0 : 5;
+	sc->sis_watchdog_timer = (sc->sis_tx_cnt == 0) ? 0 : 5;
 
 	return;
 }
_at__at_ -1560,6 +1559,8 _at__at_
 	mii = device_get_softc(sc->sis_miibus);
 	mii_tick(mii);
 
+	sis_watchdog(sc);
+
 	if (!sc->sis_link && mii->mii_media_status & IFM_ACTIVE &&
 	    IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
 		sc->sis_link++;
_at__at_ -1822,7 +1823,7 _at__at_
 		/*
 		 * Set a timeout in case the chip goes out to lunch.
 		 */
-		ifp->if_timer = 5;
+		sc->sis_watchdog_timer = 5;
 	}
 }
 
_at__at_ -2165,29 +2166,27 _at__at_
 }
 
 static void
-sis_watchdog(struct ifnet *ifp)
+sis_watchdog(struct sis_softc *sc)
 {
-	struct sis_softc *sc;
-
-	sc = ifp->if_softc;
 
-	SIS_LOCK(sc);
+	SIS_LOCK_ASSERT(sc);
 	if (sc->sis_stopped) {
 		SIS_UNLOCK(sc);
 		return;
 	}
 
-	ifp->if_oerrors++;
-	if_printf(ifp, "watchdog timeout\n");
+	if (sc->sis_watchdog_timer == 0 || --sc->sis_watchdog_timer >0)
+		return;
+
+	device_printf(sc->sis_dev, "watchdog timeout\n");
+	sc->sis_ifp->if_oerrors++;
 
 	sis_stop(sc);
 	sis_reset(sc);
 	sis_initl(sc);
 
-	if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
-		sis_startl(ifp);
-
-	SIS_UNLOCK(sc);
+	if (!IFQ_DRV_IS_EMPTY(&sc->sis_ifp->if_snd))
+		sis_startl(sc->sis_ifp);
 }
 
 /*
_at__at_ -2205,7 +2204,7 _at__at_
 		return;
 	SIS_LOCK_ASSERT(sc);
 	ifp = sc->sis_ifp;
-	ifp->if_timer = 0;
+	sc->sis_watchdog_timer = 0;
 
 	callout_stop(&sc->sis_stat_ch);
 
--- if_sisreg.h.org	Fri Feb 23 23:54:25 2007
+++ if_sisreg.h	Fri Feb 23 23:58:30 2007
_at__at_ -454,6 +454,7 _at__at_
 	u_int32_t		sis_rx_paddr;
 	u_int32_t		sis_tx_paddr;
 	struct callout		sis_stat_ch;
+	int			sis_watchdog_timer;
 	int			sis_stopped;
 #ifdef DEVICE_POLLING
 	int			rxcycles;
Received on Sat Feb 24 2007 - 13:20:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:06 UTC