PERFORCE change 140229 for review

Sam Leffler sam at FreeBSD.org
Fri Apr 18 22:06:11 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=140229

Change 140229 by sam at sam_ebb on 2008/04/18 22:05:30

	Make drivers consistent in handling ieee80211_start_all, ioctls,
	resume, other stuff related to calling the if_init method.

Affected files ...

.. //depot/projects/vap/sys/dev/bwi/if_bwi.c#7 edit
.. //depot/projects/vap/sys/dev/ipw/if_ipw.c#13 edit
.. //depot/projects/vap/sys/dev/iwi/if_iwi.c#26 edit
.. //depot/projects/vap/sys/dev/iwn/if_iwn.c#10 edit
.. //depot/projects/vap/sys/dev/malo/if_malo.c#5 edit
.. //depot/projects/vap/sys/dev/mwl/if_mwl.c#6 edit
.. //depot/projects/vap/sys/dev/ral/rt2560.c#28 edit
.. //depot/projects/vap/sys/dev/ral/rt2661.c#26 edit
.. //depot/projects/vap/sys/dev/usb/if_rum.c#16 edit
.. //depot/projects/vap/sys/dev/usb/if_ural.c#18 edit
.. //depot/projects/vap/sys/dev/usb/if_zyd.c#16 edit
.. //depot/projects/vap/sys/dev/wi/if_wi.c#26 edit
.. //depot/projects/vap/sys/dev/wpi/if_wpi.c#18 edit

Differences ...

==== //depot/projects/vap/sys/dev/bwi/if_bwi.c#7 (text+ko) ====

@@ -655,11 +655,8 @@
 {
 	struct ifnet *ifp = sc->sc_ifp;
 
-	if (ifp->if_flags & IFF_UP) {
+	if (ifp->if_flags & IFF_UP)
 		bwi_init(sc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			bwi_start(ifp);
-	}
 }
 
 int
@@ -1303,8 +1300,9 @@
 	/* Enable intrs */
 	bwi_enable_intrs(sc, BWI_INIT_INTRS);
 
+	BWI_UNLOCK(sc);
+
 	ieee80211_start_all(ic);		/* start all vap's */
-	BWI_UNLOCK(sc);
 	return;
 bad:
 	bwi_stop(sc, 1);

==== //depot/projects/vap/sys/dev/ipw/if_ipw.c#13 (text+ko) ====

@@ -847,19 +847,11 @@
 {
 	struct ipw_softc *sc = device_get_softc(dev);
 	struct ifnet *ifp = sc->sc_ifp;
-	IPW_LOCK_DECL;
-
-	IPW_LOCK(sc);
 
 	pci_write_config(dev, 0x41, 0, 1);
 
-	if (ifp->if_flags & IFF_UP) {
-		ipw_init_locked(sc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			ipw_start_locked(ifp);
-	}
-
-	IPW_UNLOCK(sc);
+	if (ifp->if_flags & IFF_UP)
+		ipw_init(sc);
 
 	return 0;
 }
@@ -1852,20 +1844,21 @@
 	struct ipw_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0;
+	int error = 0, startall = 0;
 	IPW_LOCK_DECL;
 
+	IPW_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
-		IPW_LOCK(sc);
 		if (ifp->if_flags & IFF_UP) {
-			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
+			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
 				ipw_init_locked(sc);
+				startall = 1;
+			}
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 				ipw_stop_locked(sc);
 		}
-		IPW_UNLOCK(sc);
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
@@ -1874,6 +1867,10 @@
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 	}
+	IPW_UNLOCK(sc);
+
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 
@@ -2397,11 +2394,15 @@
 ipw_init(void *priv)
 {
 	struct ipw_softc *sc = priv;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
 	IPW_LOCK_DECL;
 
 	IPW_LOCK(sc);
 	ipw_init_locked(sc);
 	IPW_UNLOCK(sc);
+
+	ieee80211_start_all(ic);
 }
 
 static void
@@ -2495,8 +2496,6 @@
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 
-	ieee80211_start_all(ic);		/* start all vap's */
-
 	sc->flags &=~ IPW_FLAG_INIT_LOCKED;
 	return;
 

==== //depot/projects/vap/sys/dev/iwi/if_iwi.c#26 (text+ko) ====

@@ -196,6 +196,7 @@
 static int	iwi_queue_cmd(struct iwi_softc *, int, unsigned long);
 static int	iwi_auth_and_assoc(struct iwi_softc *, struct ieee80211vap *);
 static int	iwi_disassociate(struct iwi_softc *, int quiet);
+static void	iwi_init_locked(struct iwi_softc *);
 static void	iwi_init(void *);
 static int	iwi_init_fw_dma(struct iwi_softc *, int);
 static void	iwi_stop_locked(void *);
@@ -891,20 +892,12 @@
 {
 	struct iwi_softc *sc = device_get_softc(dev);
 	struct ifnet *ifp = sc->sc_ifp;
-	IWI_LOCK_DECL;
-
-	IWI_LOCK(sc);
 
 	pci_write_config(dev, 0x41, 0, 1);
 
-	if (ifp->if_flags & IFF_UP) {
-		ifp->if_init(ifp->if_softc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			ifp->if_start(ifp);
-	}
+	if (ifp->if_flags & IFF_UP)
+		iwi_init(sc);
 
-	IWI_UNLOCK(sc);
-
 	return 0;
 }
 
@@ -2056,16 +2049,20 @@
 	struct iwi_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0;
+	int error = 0, startall = 0;
+	IWI_LOCK_DECL;
 
+	IWI_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
 		if (ifp->if_flags & IFF_UP) {
-			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
-				iwi_init(sc);
+			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+				iwi_init_locked(sc);
+				startall = 1;
+			}
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-				iwi_stop(sc);
+				iwi_stop_locked(sc);
 		}
 		break;
 	case SIOCGIFMEDIA:
@@ -2076,6 +2073,10 @@
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
+	IWI_UNLOCK(sc);
+
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 
@@ -3072,19 +3073,15 @@
 }
 
 static void
-iwi_init(void *priv)
+iwi_init_locked(struct iwi_softc *sc)
 {
-	struct iwi_softc *sc = priv;
 	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
 	struct iwi_rx_data *data;
 	int i;
-	IWI_LOCK_DECL;
 
-	IWI_LOCK(sc);
+	IWI_LOCK_ASSERT(sc);
 
 	if (sc->fw_state == IWI_FW_LOADING) {
-		IWI_UNLOCK(sc);
 		device_printf(sc->sc_dev, "%s: already loading\n", __func__);
 		return;		/* XXX: condvar? */
 	}
@@ -3157,16 +3154,27 @@
 	callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
-
-	IWI_UNLOCK(sc);
-
-	ieee80211_start_all(ic);		/* start all vap's */
 	return;
 fail:
 	IWI_STATE_END(sc, IWI_FW_LOADING);
 fail2:
 	iwi_stop_locked(sc);
+}
+
+static void
+iwi_init(void *priv)
+{
+	struct iwi_softc *sc = priv;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	IWI_LOCK_DECL;
+
+	IWI_LOCK(sc);
+	iwi_init_locked(sc);
 	IWI_UNLOCK(sc);
+
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		ieee80211_start_all(ic);
 }
 
 static void
@@ -3224,9 +3232,7 @@
 {
 	struct iwi_softc *sc = arg;
 
-	/* XXX not right */
-	if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)
-		iwi_init(sc);
+	iwi_init(sc);
 }
 
 /*

==== //depot/projects/vap/sys/dev/iwn/if_iwn.c#10 (text+kox) ====

@@ -562,11 +562,8 @@
 
 	pci_write_config(dev, 0x41, 0, 1);
 
-	if (ifp->if_flags & IFF_UP) {
-		iwn_init(ifp->if_softc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			iwn_start(ifp);
-	}
+	if (ifp->if_flags & IFF_UP)
+		iwn_init(sc);
 	return 0;
 }
 
@@ -2362,31 +2359,21 @@
 	struct iwn_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0;
+	int error = 0, startall = 0;
 
+	IWN_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
 		if (ifp->if_flags & IFF_UP) {
-			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
-				iwn_init(sc);
+			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+				iwn_init_locked(sc);
+				startall = 1;
+			}
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-				iwn_stop(sc);
+				iwn_stop_locked(sc);
 		}
 		break;
-#if 0
-XXX Do we support mulitcast
-	case SIOCADDMULTI:
-	case SIOCDELMULTI:
-		ifr = (struct ifreq *)data;
-		error = (cmd == SIOCADDMULTI) ?
-		    ether_addmulti(ifr, &ic->ic_ac) :
-		    ether_delmulti(ifr, &ic->ic_ac);
-
-		if (error == ENETRESET)
-			error = 0;
-		break;
-#endif
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
@@ -2395,6 +2382,10 @@
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
+	IWN_UNLOCK(sc);
+
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 
@@ -4119,28 +4110,27 @@
 }
 
 void
-iwn_init(void *arg)
+iwn_init_locked(struct iwn_softc *sc)
 {
-	struct iwn_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	uint32_t tmp;
 	int error, qid;
 
-	IWN_LOCK(sc);
+	IWN_LOCK_ASSERT(sc);
 
 	/* load the firmware */
 	if (sc->fw_fp == NULL && (error = iwn_load_firmware(sc)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not load firmware, error %d\n", __func__, error);
-		goto fail;
+		return;
 	}
 
 	error = iwn_reset(sc);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not reset adapter, error %d\n", __func__, error);
-		goto fail;
+		return;
 	}
 
 	iwn_mem_lock(sc);
@@ -4208,14 +4198,14 @@
 	if (!(IWN_READ(sc, IWN_GPIO_CTL) & IWN_GPIO_RF_ENABLED)) {
 		device_printf(sc->sc_dev,
 		    "radio is disabled by hardware switch\n");
-		goto fail;
+		return;
 	}
 
 	error = iwn_transfer_firmware(sc);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not load firmware, error %d\n", __func__, error);
-		goto fail;
+		return;
 	}
 
 	/* firmware has notified us that it is alive.. */
@@ -4231,18 +4221,26 @@
 		device_printf(sc->sc_dev,
 		    "%s: could not configure device, error %d\n",
 		    __func__, error);
-		goto fail;
+		return;
 	}
 
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
+}
+
+void
+iwn_init(void *arg)
+{
+	struct iwn_softc *sc = arg;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
 
+	IWN_LOCK(sc);
+	iwn_init_locked(sc);
 	IWN_UNLOCK(sc);
 
-	ieee80211_start_all(ic);
-	return;
-fail:
-	IWN_UNLOCK(sc);
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		ieee80211_start_all(ic);
 }
 
 static void
@@ -4452,16 +4450,17 @@
 			}
 			break;
 		case IWN_REINIT:
-			//XXX DEBUG
-			break;
-			iwn_stop_locked(sc);
+			IWN_UNLOCK(sc);
 			iwn_init(sc);
+			IWN_LOCK(sc);
 			ieee80211_notify_radio(ic, 1);
 			break;
 		case IWN_RADIO_ENABLE:
 			KASSERT(sc->fw_fp != NULL,
 			    ("Fware Not Loaded, can't load from tq"));
+			IWN_UNLOCK(sc);
 			iwn_init(sc);
+			IWN_LOCK(sc);
 			break;
 		case IWN_RADIO_DISABLE:
 			ieee80211_notify_radio(ic, 0);

==== //depot/projects/vap/sys/dev/malo/if_malo.c#5 (text+ko) ====

@@ -1494,9 +1494,8 @@
 }
 
 static void
-malo_init(void *arg)
+malo_init_locked(struct malo_softc *sc)
 {
-	struct malo_softc *sc = (struct malo_softc *) arg;
 	struct ifnet *ifp = sc->malo_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct malo_hal *mh = sc->malo_mh;
@@ -1505,7 +1504,7 @@
 	DPRINTF(sc, MALO_DEBUG_ANY, "%s: if_flags 0x%x\n",
 	    __func__, ifp->if_flags);
 
-	MALO_LOCK(sc);
+	MALO_LOCK_ASSERT(sc);
 	
 	/*
 	 * Stop anything previously setup.  This is safe whether this is
@@ -1518,7 +1517,7 @@
 	 */
 	if (!malo_hal_reset(sc)) {
 		if_printf(ifp, "%s: unable to reset hardware\n", __func__);
-		goto done;
+		return;
 	}
 
 	/*
@@ -1528,7 +1527,7 @@
 	if (error != 0) {
 		if_printf(ifp, "%s: unable to start recv logic, error %d\n",
 		    __func__, error);
-		goto done;
+		return;
 	}
 
 	/*
@@ -1545,10 +1544,25 @@
 
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	malo_hal_intrset(mh, sc->malo_imask);
+}
+
+static void
+malo_init(void *arg)
+{
+	struct malo_softc *sc = (struct malo_softc *) arg;
+	struct ifnet *ifp = sc->malo_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	
+	DPRINTF(sc, MALO_DEBUG_ANY, "%s: if_flags 0x%x\n",
+	    __func__, ifp->if_flags);
+
+	MALO_LOCK(sc);
+	malo_init_locked(sc);
 
-	ieee80211_start_all(ic);	/* start all vap's */
-done:
 	MALO_UNLOCK(sc);
+
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		ieee80211_start_all(ic);	/* start all vap's */
 }
 
 /*
@@ -1720,11 +1734,11 @@
 	struct malo_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0;
+	int error = 0, startall = 0;
 
+	MALO_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
-		MALO_LOCK(sc);
 		if (MALO_IS_RUNNING(ifp)) {
 			/*
 			 * To avoid rescanning another access point,
@@ -1742,11 +1756,12 @@
 			 * torn down much of our state.  There's
 			 * probably a better way to deal with this.
 			 */
-			if (!sc->malo_invalid)
-				malo_init(sc);
+			if (!sc->malo_invalid) {
+				malo_init_locked(sc);
+				startall = 1;
+			}
 		} else
 			malo_stop_locked(ifp, 1);
-		MALO_UNLOCK(sc);
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
@@ -1756,6 +1771,10 @@
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
+	MALO_UNLOCK(sc);
+
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 #undef MALO_IS_RUNNING
 }
@@ -2304,9 +2323,6 @@
 	DPRINTF(sc, MALO_DEBUG_ANY, "%s: if_flags %x\n",
 		__func__, ifp->if_flags);
 
-	if (ifp->if_flags & IFF_UP) {
+	if (ifp->if_flags & IFF_UP)
 		malo_init(sc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			malo_start(ifp);
-	}
 }

==== //depot/projects/vap/sys/dev/mwl/if_mwl.c#6 (text+ko) ====

@@ -96,10 +96,10 @@
 		    int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
 static void	mwl_vap_delete(struct ieee80211vap *);
-static void	mwl_ifinit(void *);
 static int	mwl_setupdma(struct mwl_softc *);
 static int	mwl_hal_reset(struct mwl_softc *sc);
-static int	mwl_init(struct mwl_softc *);
+static int	mwl_init_locked(struct mwl_softc *);
+static void	mwl_init(void *);
 static void	mwl_stop_locked(struct ifnet *, int);
 static int	mwl_reset(struct ieee80211vap *, u_long);
 static void	mwl_stop(struct ifnet *, int);
@@ -417,7 +417,7 @@
 	ifp->if_start = mwl_start;
 	ifp->if_watchdog = mwl_watchdog;
 	ifp->if_ioctl = mwl_ioctl;
-	ifp->if_init = mwl_ifinit;
+	ifp->if_init = mwl_init;
 	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
 	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
 	IFQ_SET_READY(&ifp->if_snd);
@@ -819,11 +819,8 @@
 	DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags %x\n",
 		__func__, ifp->if_flags);
 
-	if (ifp->if_flags & IFF_UP) {
+	if (ifp->if_flags & IFF_UP)
 		mwl_init(sc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			mwl_start(ifp);
-	}
 }
 
 void
@@ -1004,14 +1001,6 @@
 	/* XXX 10MHz channels */
 }
 
-static void
-mwl_ifinit(void *arg)
-{
-	struct mwl_softc *sc = arg;
-
-	(void) mwl_init(sc);
-}
-
 /*
  * Inform firmware of our tx/rx dma setup.  The BAR 0
  * writes below are for compatibility with older firmware.
@@ -1193,17 +1182,16 @@
 }
 
 static int
-mwl_init(struct mwl_softc *sc)
+mwl_init_locked(struct mwl_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
 	struct mwl_hal *mh = sc->sc_mh;
 	int error = 0;
 
 	DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags 0x%x\n",
 		__func__, ifp->if_flags);
 
-	MWL_LOCK(sc);
+	MWL_LOCK_ASSERT(sc);
 
 	/*
 	 * Stop anything previously setup.  This is safe
@@ -1216,8 +1204,7 @@
 	 */
 	if (!mwl_hal_reset(sc)) {
 		if_printf(ifp, "unable to reset hardware\n");
-		error = EIO;
-		goto done;
+		return EIO;
 	}
 
 	/*
@@ -1226,7 +1213,7 @@
 	error = mwl_startrecv(sc);
 	if (error != 0) {
 		if_printf(ifp, "unable to start recv logic\n");
-		goto done;
+		return error;
 	}
 
 	/*
@@ -1250,10 +1237,26 @@
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	mwl_hal_intrset(mh, sc->sc_imask);
 
-	ieee80211_start_all(ic);	/* start all vap's */
-done:
+	return 0;
+}
+
+static void
+mwl_init(void *arg)
+{
+	struct mwl_softc *sc = arg;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	int error = 0;
+
+	DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags 0x%x\n",
+		__func__, ifp->if_flags);
+
+	MWL_LOCK(sc);
+	error = mwl_init_locked(sc);
 	MWL_UNLOCK(sc);
-	return error;
+
+	if (error == 0)
+		ieee80211_start_all(ic);	/* start all vap's */
 }
 
 static void
@@ -5191,11 +5194,12 @@
 	struct mwl_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *)data;
-	int error = 0;
+	int error = 0, startall;
 
-	MWL_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
+		MWL_LOCK(sc);
+		startall = 0;
 		if (IS_RUNNING(ifp)) {
 			/*
 			 * To avoid rescanning another access point,
@@ -5213,20 +5217,15 @@
 			 * torn down much of our state.  There's
 			 * probably a better way to deal with this.
 			 */
-			if (!sc->sc_invalid)
-				mwl_init(sc);	/* XXX lose error */
+			if (!sc->sc_invalid) {
+				mwl_init_locked(sc);	/* XXX lose error */
+				startall = 1;
+			}
 		} else
 			mwl_stop_locked(ifp, 1);
-		break;
-	case SIOCADDMULTI:
-	case SIOCDELMULTI:
-		/*
-		 * The upper layer has already installed/removed
-		 * the multicast address(es), just recalculate the
-		 * multicast filter for the card.
-		 */
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			mwl_mode_init(sc);
+		MWL_UNLOCK(sc);
+		if (startall)
+			ieee80211_start_all(ic);
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
@@ -5237,7 +5236,6 @@
 		/* NB: embed these numbers to get a consistent view */
 		sc->sc_stats.mst_tx_packets = ifp->if_opackets;
 		sc->sc_stats.mst_rx_packets = ifp->if_ipackets;
-		MWL_UNLOCK(sc);
 		/*
 		 * NB: Drop the softc lock in case of a page fault;
 		 * we'll accept any potential inconsisentcy in the
@@ -5249,18 +5247,18 @@
 #ifdef MWL_DIAGAPI
 	case SIOCGMVDIAG:
 		/* XXX check privs */
-		MWL_UNLOCK(sc);			/* XXX copyout */
 		return mwl_ioctl_diag(sc, (struct mwl_diag *) ifr);
 	case SIOCGMVRESET:
 		/* XXX check privs */
+		MWL_LOCK(sc);
 		error = mwl_ioctl_reset(sc,(struct mwl_diag *) ifr); 
+		MWL_UNLOCK(sc);
 		break;
 #endif /* MWL_DIAGAPI */
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
-	MWL_UNLOCK(sc);
 	return error;
 #undef IS_RUNNING
 }

==== //depot/projects/vap/sys/dev/ral/rt2560.c#28 (text) ====

@@ -459,11 +459,8 @@
 	struct rt2560_softc *sc = xsc;
 	struct ifnet *ifp = sc->sc_ifp;
 
-	if (ifp->if_flags & IFF_UP) {
-		ifp->if_init(ifp->if_softc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			ifp->if_start(ifp);
-	}
+	if (ifp->if_flags & IFF_UP)
+		rt2560_init(sc);
 }
 
 static void
@@ -2006,12 +2003,11 @@
 	struct rt2560_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0, startall;
+	int error = 0, startall = 0;
 
+	RAL_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
-		RAL_LOCK(sc);
-		startall = 0;
 		if (ifp->if_flags & IFF_UP) {
 			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
 				rt2560_init_locked(sc);
@@ -2022,9 +2018,6 @@
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 				rt2560_stop_locked(sc);
 		}
-		RAL_UNLOCK(sc);
-		if (startall)		/* NB: need to drop lock */
-			ieee80211_start_all(ic);
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
@@ -2034,6 +2027,10 @@
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
+	RAL_UNLOCK(sc);
+
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 

==== //depot/projects/vap/sys/dev/ral/rt2661.c#26 (text) ====

@@ -475,11 +475,8 @@
 	struct rt2661_softc *sc = xsc;
 	struct ifnet *ifp = sc->sc_ifp;
 
-	if (ifp->if_flags & IFF_UP) {
-		ifp->if_init(ifp->if_softc);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			ifp->if_start(ifp);
-	}
+	if (ifp->if_flags & IFF_UP)
+		rt2661_init(sc);
 }
 
 static void
@@ -1748,12 +1745,11 @@
 	struct rt2661_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0, startall;
+	int error = 0, startall = 0;
 
+	RAL_LOCK(sc);
 	switch (cmd) {
 	case SIOCSIFFLAGS:
-		RAL_LOCK(sc);
-		startall = 0;
 		if (ifp->if_flags & IFF_UP) {
 			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
 				rt2661_init_locked(sc);
@@ -1764,9 +1760,6 @@
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 				rt2661_stop_locked(sc);
 		}
-		RAL_UNLOCK(sc);
-		if (startall)		/* NB: need to drop lock */
-			ieee80211_start_all(ic);
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
@@ -1776,6 +1769,10 @@
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
+	RAL_UNLOCK(sc);
+
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 

==== //depot/projects/vap/sys/dev/usb/if_rum.c#16 (text+ko) ====

@@ -186,6 +186,7 @@
 static const char	*rum_get_rf(int);
 static void		rum_read_eeprom(struct rum_softc *);
 static int		rum_bbp_init(struct rum_softc *);
+static void		rum_init_locked(struct rum_softc *);
 static void		rum_init(void *);
 static void		rum_stop(void *);
 static int		rum_load_microcode(struct rum_softc *, const u_char *,
@@ -1423,17 +1424,17 @@
 	struct rum_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0;
+	int error = 0, startall = 0;
 
 	RUM_LOCK(sc);
-
 	switch (cmd) {
 	case SIOCSIFFLAGS:
 		if (ifp->if_flags & IFF_UP) {
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+				rum_init(sc);
+				startall = 1;
+			} else
 				rum_update_promisc(sc);
-			else
-				rum_init(sc);
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 				rum_stop(sc);
@@ -1446,9 +1447,10 @@
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 	}
-
 	RUM_UNLOCK(sc);
 
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 
@@ -2020,10 +2022,9 @@
 }
 
 static void
-rum_init(void *priv)
+rum_init_locked(struct rum_softc *sc)
 {
 #define N(a)	(sizeof (a) / sizeof ((a)[0]))
-	struct rum_softc *sc = priv;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct rum_rx_data *data;
@@ -2139,9 +2140,6 @@
 
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
-
-	ieee80211_start_all(ic);		/* start all vap's */
-
 	return;
 
 fail:	rum_stop(sc);
@@ -2149,6 +2147,21 @@
 }
 
 static void
+rum_init(void *priv)
+{
+	struct rum_softc *sc = priv;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+
+	RUM_LOCK(sc);
+	rum_init_locked(sc);
+	RUM_UNLOCK(sc);
+
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		ieee80211_start_all(ic);		/* start all vap's */
+}
+
+static void
 rum_stop(void *priv)
 {
 	struct rum_softc *sc = priv;

==== //depot/projects/vap/sys/dev/usb/if_ural.c#18 (text+ko) ====

@@ -177,6 +177,7 @@
 static int		ural_bbp_init(struct ural_softc *);
 static void		ural_set_txantenna(struct ural_softc *, int);
 static void		ural_set_rxantenna(struct ural_softc *, int);
+static void		ural_init_locked(struct ural_softc *);
 static void		ural_init(void *);
 static void		ural_stop(void *);
 static int		ural_raw_xmit(struct ieee80211_node *, struct mbuf *,
@@ -1517,17 +1518,17 @@
 	struct ural_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *) data;
-	int error = 0;
+	int error = 0, startall = 1;
 
 	RAL_LOCK(sc);
-
 	switch (cmd) {
 	case SIOCSIFFLAGS:
 		if (ifp->if_flags & IFF_UP) {
-			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+				ural_init_locked(sc);
+				startall = 1;
+			} else
 				ural_update_promisc(sc);
-			else
-				ural_init(sc);
 		} else {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 				ural_stop(sc);
@@ -1541,9 +1542,10 @@
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	}
-
 	RAL_UNLOCK(sc);
 
+	if (startall)
+		ieee80211_start_all(ic);
 	return error;
 }
 
@@ -2184,10 +2186,9 @@
 }

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list