summaryrefslogtreecommitdiffstats
path: root/sys/dev/cnw
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-08-09 10:20:02 +0000
committerrwatson <rwatson@FreeBSD.org>2005-08-09 10:20:02 +0000
commit5d770a09e85126b8b3e9fe302c36350a90210cbe (patch)
treebb70e59641e2310a3c26ec449af5ab0cb7420d9d /sys/dev/cnw
parent74759aaa78777146f23aa05c856f574efdfb41d9 (diff)
downloadFreeBSD-src-5d770a09e85126b8b3e9fe302c36350a90210cbe.zip
FreeBSD-src-5d770a09e85126b8b3e9fe302c36350a90210cbe.tar.gz
Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to ifnet.if_drv_flags. Device drivers are now responsible for synchronizing access to these flags, as they are in if_drv_flags. This helps prevent races between the network stack and device driver in maintaining the interface flags field. Many __FreeBSD__ and __FreeBSD_version checks maintained and continued; some less so. Reviewed by: pjd, bz MFC after: 7 days
Diffstat (limited to 'sys/dev/cnw')
-rw-r--r--sys/dev/cnw/if_cnw.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/sys/dev/cnw/if_cnw.c b/sys/dev/cnw/if_cnw.c
index 3baf8a0..900feb9 100644
--- a/sys/dev/cnw/if_cnw.c
+++ b/sys/dev/cnw/if_cnw.c
@@ -773,16 +773,22 @@ cnw_start(ifp)
#ifdef CNW_DEBUG
if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG)
printf("%s: cnw_start\n", ifp->if_xname);
+#if defined(__FreeBSD__)
+ if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
+#else
if (ifp->if_flags & IFF_OACTIVE)
+#endif
printf("%s: cnw_start reentered\n", ifp->if_xname);
#endif
#if defined(__FreeBSD__)
if (sc->cnw_gone)
return;
-#endif
+ ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+#else
ifp->if_flags |= IFF_OACTIVE;
+#endif
for (;;) {
#ifdef ONE_AT_A_TIME
@@ -863,7 +869,11 @@ cnw_start(ifp)
sc->sc_active = 1;
}
+#if defined(__FreeBSD__)
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+#else
ifp->if_flags &= ~IFF_OACTIVE;
+#endif
}
/*
@@ -1086,7 +1096,7 @@ cnw_intr(arg)
(sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
return (0);
#else
- if ((ifp->if_flags & IFF_RUNNING) == 0)
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
#endif
ifp->if_timer = 0; /* stop watchdog timer */
@@ -1201,7 +1211,11 @@ cnw_intr(arg)
}
sc->sc_active = 0;
+#if defined(__FreeBSD__)
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+#else
ifp->if_flags &= ~IFF_OACTIVE;
+#endif
/* Continue to send packets from the queue */
#if !defined(__FreeBSD__)
@@ -1291,7 +1305,7 @@ cnw_ioctl(ifp, cmd, data)
if (ifp->if_flags & IFF_UP) {
cnw_freebsd_init(sc);
} else {
- if (ifp->if_flags & IFF_RUNNING) {
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
cnw_stop(sc);
} else {
cnw_freebsd_init(sc);
@@ -1352,7 +1366,11 @@ cnw_ioctl(ifp, cmd, data)
#endif
if (error)
break;
+#if !defined(__FreeBSD__)
if ((ifp->if_flags & IFF_RUNNING) == 0)
+#else
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+#endif
break;
bus_space_read_region_1(sc->sc_memt, sc->sc_memh,
sc->sc_memoff + CNW_EREG_CB,
@@ -1464,7 +1482,7 @@ cnw_detach(self, flags)
struct cnw_softc *sc = (struct cnw_softc *)self;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
- /* cnw_disable() checks IFF_RUNNING */
+ /* cnw_disable() checks IFF_DRV_RUNNING */
cnw_disable(sc);
if ((sc->sc_resource & CNW_RES_NET) != 0) {
@@ -1508,12 +1526,12 @@ static void cnw_freebsd_init(xsc)
cnw_init(sc);
#if 0
- if (ifp->if_flags & IFF_RUNNING)
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING)
cnw_stop(sc);
#endif
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
/* sc->cnw_stat_ch = timeout(cnw_inquire, sc, hz * 60); */
@@ -1535,7 +1553,7 @@ static void cnw_stop(sc)
cnw_reset(sc);
ifp = sc->sc_ifp;
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+ ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
return;
}
OpenPOWER on IntegriCloud