PERFORCE change 65266 for review

Sam Leffler sam at FreeBSD.org
Tue Nov 16 09:19:29 PST 2004


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

Change 65266 by sam at sam_ebb on 2004/11/16 17:19:25

	o restore power-save mode capability
	o import revised false bssid support from netbsd
	o reduce max aid per netbsd
	o minor changes to bring code slightly more in line with netbsd

Affected files ...

.. //depot/projects/wifi/sys/dev/wi/if_wi.c#5 edit
.. //depot/projects/wifi/sys/dev/wi/if_wivar.h#3 edit

Differences ...

==== //depot/projects/wifi/sys/dev/wi/if_wi.c#5 (text+ko) ====

@@ -310,9 +310,11 @@
 	ic->ic_ifp = ifp;
 	ic->ic_phytype = IEEE80211_T_DS;
 	ic->ic_opmode = IEEE80211_M_STA;
-	ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_AHDEMO;
 	ic->ic_state = IEEE80211_S_INIT;
-	ic->ic_caps = IEEE80211_C_WEP;		/* everyone supports WEP */
+	ic->ic_caps = IEEE80211_C_PMGT
+		    | IEEE80211_C_WEP		/* everyone supports WEP */
+		    ;
+	ic->ic_max_aid = WI_MAX_AID;
 
 	/*
 	 * Query the card for available channels and setup the
@@ -705,8 +707,9 @@
 	IEEE80211_ADDR_COPY(ic->ic_myaddr, LLADDR(sdl));
 	wi_write_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, IEEE80211_ADDR_LEN);
 
-	wi_write_val(sc, WI_RID_PM_ENABLED,
-	    (ic->ic_flags & IEEE80211_F_PMGTON) ? 1 : 0);
+	if (ic->ic_caps & IEEE80211_C_PMGT)
+		wi_write_val(sc, WI_RID_PM_ENABLED,
+		    (ic->ic_flags & IEEE80211_F_PMGTON) ? 1 : 0);
 
 	/* not yet common 802.11 configuration */
 	wi_write_val(sc, WI_RID_MAX_DATALEN, sc->sc_max_datalen);
@@ -848,7 +851,6 @@
 
 	sc->sc_tx_timer = 0;
 	sc->sc_scan_timer = 0;
-	sc->sc_syn_timer = 0;
 	sc->sc_false_syns = 0;
 	sc->sc_naps = 0;
 	ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
@@ -1057,18 +1059,6 @@
 			ifp->if_timer = 1;
 	}
 
-	if (sc->sc_syn_timer) {
-		if (--sc->sc_syn_timer == 0) {
-			struct ieee80211com *ic = (struct ieee80211com *) ifp;
-			DPRINTF2(("wi_watchdog: %d false syns\n",
-			    sc->sc_false_syns));
-			sc->sc_false_syns = 0;
-			ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
-			sc->sc_syn_timer = 5;
-		}
-		ifp->if_timer = 1;
-	}
-
 	/* TODO: rate control */
 	ieee80211_watchdog(&sc->sc_ic);
 }
@@ -1253,23 +1243,22 @@
 	    (sc->sc_flags & WI_FLAGS_OUTRANGE) == 0)
 		imr->ifm_status |= IFM_ACTIVE;
 	len = sizeof(val);
-	if (wi_read_rid(sc, WI_RID_CUR_TX_RATE, &val, &len) != 0)
-		rate = 0;
-	else {
+	if (wi_read_rid(sc, WI_RID_CUR_TX_RATE, &val, &len) == 0 &&
+	    len == sizeof(val)) {
 		/* convert to 802.11 rate */
+		val = le16toh(val);
 		rate = val * 2;
 		if (sc->sc_firmware_type == WI_LUCENT) {
-			if (rate == 4 * 2)
+			if (rate == 10)
 				rate = 11;	/* 5.5Mbps */
-			else if (rate == 5 * 2)
-				rate = 22;	/* 11Mbps */
 		} else {
 			if (rate == 4*2)
 				rate = 11;	/* 5.5Mbps */
 			else if (rate == 8*2)
 				rate = 22;	/* 11Mbps */
 		}
-	}
+	} else
+		rate = 0;
 	imr->ifm_active |= ieee80211_rate2media(ic, rate, IEEE80211_MODE_11B);
 	switch (ic->ic_opmode) {
 	case IEEE80211_M_STA:
@@ -1307,7 +1296,8 @@
 	 * change-of-BSSID indications.
 	 */
 	if ((ifp->if_flags & IFF_PROMISC) != 0 &&
-	    sc->sc_false_syns >= WI_MAX_FALSE_SYNS)
+	    !ppsratecheck(&sc->sc_last_syn, &sc->sc_false_syns,
+	                 WI_MAX_FALSE_SYNS))
 		return;
 
 	ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
@@ -1515,7 +1505,7 @@
 	 * then pass this node (referenced) up to the 802.11
 	 * layer for its use.
 	 */
-	ni = ieee80211_find_rxnode(ic, wh);
+	ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *) wh);
 	/*
 	 * Send frame up for processing.
 	 */
@@ -2687,6 +2677,7 @@
 	case IEEE80211_S_RUN:
 		sc->sc_flags &= ~WI_FLAGS_OUTRANGE;
 		buflen = IEEE80211_ADDR_LEN;
+		IEEE80211_ADDR_COPY(old_bssid, ni->ni_bssid);
 		wi_read_rid(sc, WI_RID_CURRENT_BSSID, ni->ni_bssid, &buflen);
 		IEEE80211_ADDR_COPY(ni->ni_macaddr, ni->ni_bssid);
 		buflen = sizeof(val);
@@ -2700,10 +2691,9 @@
 			htole16(ni->ni_chan->ic_flags);
 #endif
 
-		if (IEEE80211_ADDR_EQ(old_bssid, ni->ni_bssid))
-			sc->sc_false_syns++;
-		else
-			sc->sc_false_syns = 0;
+		/* If not equal, then discount a false synchronization. */
+		if (!IEEE80211_ADDR_EQ(old_bssid, ni->ni_bssid))
+			sc->sc_false_syns = MAX(0, sc->sc_false_syns - 1);
 
 		if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
 			ni->ni_esslen = ic->ic_des_esslen;
@@ -2740,8 +2730,8 @@
 		(void)wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_SCAN_RESULTS, 0, 0);
 		break;
 	case WI_INTERSIL:
-		val[0] = chanmask;	/* channel */
-		val[1] = txrate;	/* tx rate */
+		val[0] = htole16(chanmask);	/* channel */
+		val[1] = htole16(txrate);	/* tx rate */
 		error = wi_write_rid(sc, WI_RID_SCAN_REQ, val, sizeof(val));
 		break;
 	case WI_SYMBOL:

==== //depot/projects/wifi/sys/dev/wi/if_wivar.h#3 (text+ko) ====

@@ -59,6 +59,8 @@
 #define WI_RID_ROAMING_MODE	0xFC2D
 #define WI_RID_CUR_TX_RATE	0xFD44 /* current TX rate */
 
+#define	WI_MAX_AID		256	/* max stations for ap operation */
+
 struct wi_softc	{
 	struct arpcom		sc_arp;
 	struct ieee80211com	sc_ic;
@@ -135,7 +137,6 @@
 	int			sc_txcur;		/* index of current TX*/
 	int			sc_tx_timer;
 	int			sc_scan_timer;
-	int			sc_syn_timer;
 
 	struct wi_counters	sc_stats;
 	u_int16_t		sc_ibss_port;
@@ -161,6 +162,7 @@
 		u_int16_t               wi_confbits_param0;
 	} wi_debug;
 
+	struct timeval		sc_last_syn;
 	int			sc_false_syns;
 
 	u_int16_t		sc_txbuf[IEEE80211_MAX_LEN/2];


More information about the p4-projects mailing list