Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 2007 15:19:56 +0100
From:      "Florian C. Smeets" <flo@kasimir.com>
To:        freebsd-current@freebsd.org
Subject:   [PATCH] if_sis conversion from if_watchdog to sis_watchdog
Message-ID:  <45E0498C.1040003@kasimir.com>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------060108050509060706060204
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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

--------------060108050509060706060204
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
	name="sis_watchdog.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="sis_watchdog.diff"

--- if_sis.c.org	Fri Feb 23 23:28:15 2007
+++ if_sis.c	Sat Feb 24 11:26:23 2007
@@ -137,7 +137,7 @@
 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[] = {
@@ -1193,7 +1193,6 @@
 	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;
@@ -1540,7 +1539,7 @@
 		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;
 }
@@ -1560,6 +1559,8 @@
 	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++;
@@ -1822,7 +1823,7 @@
 		/*
 		 * Set a timeout in case the chip goes out to lunch.
 		 */
-		ifp->if_timer = 5;
+		sc->sis_watchdog_timer = 5;
 	}
 }
 
@@ -2165,29 +2166,27 @@
 }
 
 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);
 }
 
 /*
@@ -2205,7 +2204,7 @@
 		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
@@ -454,6 +454,7 @@
 	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;

--------------060108050509060706060204--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45E0498C.1040003>