PERFORCE change 76758 for review

Sam Leffler sam at FreeBSD.org
Mon May 9 11:37:10 PDT 2005


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

Change 76758 by sam at sam_ebb on 2005/05/09 18:36:38

	misc cleanups

Affected files ...

.. //depot/projects/vap/sys/dev/ath/if_ath.c#11 edit

Differences ...

==== //depot/projects/vap/sys/dev/ath/if_ath.c#11 (text+ko) ====

@@ -664,6 +664,64 @@
 	return 0;
 }
 
+/*
+ * Hardware supports the bssid mask and a unique address
+ * was requested.  Assign a new mac address and expand
+ * our bssid mask to cover the active virtual ap's with
+ * distinct addresses.
+ */
+static void
+assign_address(struct ath_softc *sc, struct ieee80211vap *vap)
+{
+	struct ieee80211com *ic = vap->iv_ic;
+	struct ieee80211vap *v;
+	int id_mask, id;
+
+	/* do a full search to mark all the allocated vaps */
+	id_mask = 0;
+	TAILQ_FOREACH(v, &ic->ic_vaps, iv_next)
+		id_mask |= (1 << ATH_GET_VAP_ID(v->iv_myaddr));
+	for (id = 0; id < ATH_BCBUF; id++) {
+		/* get the first available slot */
+		if ((id_mask & (1 << id)) == 0) {
+			ATH_SET_VAP_BSSID(vap->iv_myaddr, id);
+			break;
+		}
+	}
+}
+
+/*
+ * Return an open beacon slot. The caller is assumed to
+ * check one is available.
+ */
+static int
+find_bslot(struct ath_softc *sc)
+{
+	int slot, bslot;
+
+	KASSERT(sc->sc_nvaps <= ATH_BCBUF,
+		("too many virtual ap's: %d", sc->sc_nvaps));
+	bslot = 0;
+	for (slot = 0; slot < ATH_BCBUF; slot++)
+		if (sc->sc_bslot[slot] == NULL) {
+			/*
+			 * XXX hack, space out slots to better
+			 * deal with misses
+			 */
+			if (slot+1 < ATH_BCBUF &&
+			    sc->sc_bslot[slot+1] == NULL) {
+				bslot = slot+1;
+				break;
+			}
+			bslot = slot;
+			/* NB: keep looking for a double slot */
+		}
+	return bslot;
+}
+
+/*
+ * Create a virtual ap.
+ */
 static struct ieee80211vap *
 ath_vap_create(struct ieee80211com *ic,
 	const char name[IFNAMSIZ], int unit, int opmode, int flags)
@@ -697,7 +755,7 @@
 		/* permit multiple ap's and/or wds links */
 		/* XXX device capability */
 		if (sc->sc_nvaps != 0 && ic->ic_opmode != IEEE80211_M_HOSTAP)
-		      return NULL;
+			return NULL;
 		if (opmode == IEEE80211_M_HOSTAP && STAILQ_EMPTY(&sc->sc_bbuf))
 			return NULL;
 		/*
@@ -732,31 +790,9 @@
 	vap->iv_key_update_end = ath_key_update_end;
 
 	if ((flags & IEEE80211_CLONE_BSSID) &&
-	    sc->sc_nvaps != 0 && opmode != IEEE80211_M_WDS && sc->sc_hasbmask) {
-		struct ieee80211vap *v;
-		int id_mask, id;
-
-		/*
-		 * Hardware supports the bssid mask and a unique
-		 * bssid was requested.  Assign a new mac address
-		 * and expand our bssid mask to cover the active
-		 * virtual ap's with distinct addresses.
-		 */
-		KASSERT(sc->sc_nvaps <= ATH_BCBUF,
-			("too many virtual ap's: %d", sc->sc_nvaps));
+	    sc->sc_nvaps != 0 && opmode != IEEE80211_M_WDS && sc->sc_hasbmask)
+		assign_address(sc, vap);
 
-		/* do a full search to mark all the allocated vaps */
-		id_mask = 0;
-		TAILQ_FOREACH(v, &ic->ic_vaps, iv_next)
-			id_mask |= (1 << ATH_GET_VAP_ID(v->iv_myaddr));
-		for (id = 0; id < ATH_BCBUF; id++) {
-			/* get the first available slot */
-			if ((id_mask & (1 << id)) == 0) {
-				ATH_SET_VAP_BSSID(vap->iv_myaddr, id);
-				break;
-			}
-		}
-	}
 	avp->av_bslot = -1;
 	switch (opmode) {
 	case IEEE80211_M_HOSTAP:
@@ -773,26 +809,11 @@
 		avp->av_bcbuf = STAILQ_FIRST(&sc->sc_bbuf);
 		STAILQ_REMOVE_HEAD(&sc->sc_bbuf, bf_list);
 		if (opmode == IEEE80211_M_HOSTAP || !sc->sc_hasveol) {
-			int slot;
 			/*
 			 * Assign the vap to a beacon xmit slot.  As
 			 * above, this cannot fail to find one.
 			 */
-			avp->av_bslot = 0;
-			for (slot = 0; slot < ATH_BCBUF; slot++)
-				if (sc->sc_bslot[slot] == NULL) {
-					/*
-					 * XXX hack, space out slots to better
-					 * deal with misses
-					 */
-					if (slot+1 < ATH_BCBUF &&
-					    sc->sc_bslot[slot+1] == NULL) {
-						avp->av_bslot = slot+1;
-						break;
-					}
-					avp->av_bslot = slot;
-					/* NB: keep looking for a double slot */
-				}
+			avp->av_bslot = find_bslot(sc);
 			KASSERT(sc->sc_bslot[avp->av_bslot] == NULL,
 				("beacon slot %u not empty?", avp->av_bslot));
 			sc->sc_bslot[avp->av_bslot] = vap;
@@ -829,6 +850,9 @@
 	return vap;
 }
 
+/*
+ * Delete/destroy a virtual ap.
+ */
 void
 ath_vap_delete(struct ieee80211vap *vap)
 {
@@ -1157,15 +1181,12 @@
 	ath_update_txpow(sc);
 
 	/*
-	 * Setup the hardware after reset: the key cache
-	 * is filled as needed and the receive engine is
-	 * set going.  Frame transmit is handled entirely
-	 * in the frame output path; there's nothing to do
-	 * here except setup the interrupt mask.
+	 * Setup the hardware after reset.  All we need
+	 * to do is set the receive engine going.  Frame
+	 * transmit is handled entirely in the frame output
+	 * path; there's nothing to do here except setup
+	 * the interrupt mask.
 	 */
-#if 0
-	ath_initkeytable(sc);		/* XXX still needed? */
-#endif
 	if (ath_startrecv(sc) != 0) {
 		if_printf(ifp, "unable to start recv logic\n");
 		goto done;
@@ -2084,8 +2105,8 @@
 	 */
 	ni = sc->sc_keyixmap[keyix];
 	if (ni != NULL) {
+		sc->sc_keyixmap[keyix] = NULL;
 		ieee80211_free_node(ni);
-		sc->sc_keyixmap[keyix] = NULL;
 	}
 	/*
 	 * Handle split tx/rx keying required for TKIP with h/w MIC.
@@ -2095,8 +2116,8 @@
 		ath_hal_keyreset(ah, keyix+32);		/* RX key */
 		ni = sc->sc_keyixmap[keyix+32];
 		if (ni != NULL) {			/* as above... */
+			sc->sc_keyixmap[keyix+32] = NULL;
 			ieee80211_free_node(ni);
-			sc->sc_keyixmap[keyix+32] = NULL;
 		}
 	}
 	if (keyix >= IEEE80211_WEP_NKID) {


More information about the p4-projects mailing list