FreeBSD/sys/net80211/ieee80211_proto.c
/*
 * Handle post state change work common to all operating modes.
 */
Handle post state change work common to all operating modes.
Handle post state change work common to all operating modes .
static void
ieee80211_newstate_cb(void *xvap, int npending)
{
	struct ieee80211vap *vap = xvap;
	struct ieee80211com *ic = vap->iv_ic;
	enum ieee80211_state nstate, ostate;
	int arg, rc;
	IEEE80211_LOCK(ic);
	nstate = vap->iv_nstate;
	arg = vap->iv_nstate_arg;
	if (vap->iv_flags_ext & IEEE80211_FEXT_REINIT) {
		vap->iv_nstate = IEEE80211_S_INIT;
		IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
		    "%s: %s -> %s arg %d\n", __func__,
		    ieee80211_state_name[vap->iv_state],
		    ieee80211_state_name[vap->iv_nstate], arg);
		vap->iv_newstate(vap, vap->iv_nstate, 0);
		IEEE80211_LOCK_ASSERT(ic);
		vap->iv_flags_ext &= ~(IEEE80211_FEXT_REINIT |
		    IEEE80211_FEXT_STATEWAIT);
		ieee80211_new_state_locked(vap, nstate, arg);
		goto done;
	}
	ostate = vap->iv_state;
	if (nstate == IEEE80211_S_SCAN && ostate != IEEE80211_S_INIT) {
		markwaiting(vap);
	}
	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
	    "%s: %s -> %s arg %d\n", __func__,
	    ieee80211_state_name[ostate], ieee80211_state_name[nstate], arg);
	rc = vap->iv_newstate(vap, nstate, arg);
	IEEE80211_LOCK_ASSERT(ic);
	vap->iv_flags_ext &= ~IEEE80211_FEXT_STATEWAIT;
	if (rc != 0) {
		KASSERT(rc != EINPROGRESS, ("iv_newstate was deferred"));
		KASSERT(nstate != IEEE80211_S_INIT,
		    ("INIT state change failed"));
		IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
		    "%s: %s returned error %d\n", __func__,
		    ieee80211_state_name[nstate], rc);
		goto done;
	}
	if (ostate == nstate)
		goto done;
	if (nstate == IEEE80211_S_RUN) {
		vap->iv_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
		wakeupwaiting(vap);
	} else if (nstate == IEEE80211_S_INIT) {
		ieee80211_scan_flush(vap);
	}
done:
	IEEE80211_UNLOCK(ic);
}
static void ieee80211_newstate_cb ( void * xvap , int npending ) { struct ieee80211vap * vap = xvap ; struct ieee80211com * ic = vap -> iv_ic ; enum ieee80211_state nstate , ostate ; int arg , rc ; IEEE80211_LOCK ( ic ) ; nstate = vap -> iv_nstate ; arg = vap -> iv_nstate_arg ; if ( vap -> iv_flags_ext & IEEE80211_FEXT_REINIT ) { vap -> iv_nstate = IEEE80211_S_INIT ; IEEE80211_DPRINTF ( vap , IEEE80211_MSG_STATE , " \n " , __func__ , ieee80211_state_name [ vap -> iv_state ] , ieee80211_state_name [ vap -> iv_nstate ] , arg ) ; vap -> iv_newstate ( vap , vap -> iv_nstate , 0 ) ; IEEE80211_LOCK_ASSERT ( ic ) ; vap -> iv_flags_ext &= ~ ( IEEE80211_FEXT_REINIT | IEEE80211_FEXT_STATEWAIT ) ; ieee80211_new_state_locked ( vap , nstate , arg ) ; goto done ; } ostate = vap -> iv_state ; if ( nstate == IEEE80211_S_SCAN && ostate != IEEE80211_S_INIT ) { markwaiting ( vap ) ; } IEEE80211_DPRINTF ( vap , IEEE80211_MSG_STATE , " \n " , __func__ , ieee80211_state_name [ ostate ] , ieee80211_state_name [ nstate ] , arg ) ; rc = vap -> iv_newstate ( vap , nstate , arg ) ; IEEE80211_LOCK_ASSERT ( ic ) ; vap -> iv_flags_ext &= ~ IEEE80211_FEXT_STATEWAIT ; if ( rc != 0 ) { KASSERT ( rc != EINPROGRESS , ( " " ) ) ; KASSERT ( nstate != IEEE80211_S_INIT , ( " " ) ) ; IEEE80211_DPRINTF ( vap , IEEE80211_MSG_STATE , " \n " , __func__ , ieee80211_state_name [ nstate ] , rc ) ; goto done ; } if ( ostate == nstate ) goto done ; if ( nstate == IEEE80211_S_RUN ) { vap -> iv_ifp -> if_drv_flags &= ~ IFF_DRV_OACTIVE ; wakeupwaiting ( vap ) ; } else if ( nstate == IEEE80211_S_INIT ) { ieee80211_scan_flush ( vap ) ; } done : IEEE80211_UNLOCK ( ic ) ; }
Handle post state change work common to all operating modes.
Handle post state change work common to all operating modes .
/*
		 * We have been requested to drop back to the INIT before
		 * proceeding to the new state.
		 */ /* Deny any state changes while we are here. */ /* enqueue new state transition after cancel_scan() task */ /*
		 * SCAN was forced; e.g. on beacon miss.  Force other running
		 * vap's to INIT state and mark them as waiting for the scan to
		 * complete.  This insures they don't interfere with our
		 * scanning.  Since we are single threaded the vaps can not
		 * transition again while we are executing.
		 *
		 * XXX not always right, assumes ap follows sta
		 */ /* State transition failed */ /* No actual transition, skip post processing */ /*
		 * OACTIVE may be set on the vap if the upper layer
		 * tried to transmit (e.g. IPv6 NDP) before we reach
		 * RUN state.  Clear it and restart xmit.
		 *
		 * Note this can also happen as a result of SLEEP->RUN
		 * (i.e. coming out of power save mode).
		 */ /*
		 * XXX TODO Kick-start a VAP queue - this should be a method!
		 */ /* bring up any vaps waiting on us */ /*
		 * Flush the scan cache if we did the last scan (XXX?)
		 * and flush any frames on send queues from this vap.
		 * Note the mgt q is used only for legacy drivers and
		 * will go away shortly.
		 */ /*
		 * XXX TODO: ic/vap queue flush
		 */