Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 2008 17:51:28 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 146641 for review
Message-ID:  <200808041751.m74HpSXC092006@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146641

Change 146641 by sam@sam_ebb on 2008/08/04 17:50:59

	o change the hwmap so that it is indexed by the rate index instead
	  of the rate code; this is needed to deal with HT rates
	o simplify led blink logic after hwmap change
	o track hwmap change in sample algorithm
	o enable HT channels; current support is rx only (packet sniffing)

Affected files ...

.. //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#12 edit
.. //depot/projects/vap/sys/dev/ath/if_ath.c#89 edit

Differences ...

==== //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#12 (text+ko) ====

@@ -498,9 +498,11 @@
 	const struct ath_tx_status *ts = &bf->bf_status.ds_txstat;
 	const struct ath_desc *ds0 = &bf->bf_desc[0];
 	int final_rate, short_tries, long_tries, frame_size;
+	const HAL_RATE_TABLE *rt = sc->sc_currates;
 	int mrr;
 
-	final_rate = sc->sc_hwmap[ts->ts_rate &~ HAL_TXSTAT_ALTRATE].ieeerate;
+	final_rate = sc->sc_hwmap[
+	    rt->rateCodeToIndex[ts->ts_rate &~ HAL_TXSTAT_ALTRATE]].ieeerate;
 	short_tries = ts->ts_shortretry;
 	long_tries = ts->ts_longretry + 1;
 	frame_size = ds0->ds_ctl0 & 0x0fff; /* low-order 12 bits of ds_ctl0 */
@@ -558,19 +560,19 @@
 			hwrate3 = MS(ds0->ds_ctl3, AR5416_XmitRate3);
 		}
 
-		rate0 = sc->sc_hwmap[hwrate0].ieeerate;
+		rate0 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate0]].ieeerate;
 		tries0 = MS(ds0->ds_ctl2, AR_XmitDataTries0);
 		ndx0 = rate_to_ndx(sn, rate0);
 
-		rate1 = sc->sc_hwmap[hwrate1].ieeerate;
+		rate1 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate1]].ieeerate;
 		tries1 = MS(ds0->ds_ctl2, AR_XmitDataTries1);
 		ndx1 = rate_to_ndx(sn, rate1);
 
-		rate2 = sc->sc_hwmap[hwrate2].ieeerate;
+		rate2 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate2]].ieeerate;
 		tries2 = MS(ds0->ds_ctl2, AR_XmitDataTries2);
 		ndx2 = rate_to_ndx(sn, rate2);
 
-		rate3 = sc->sc_hwmap[hwrate3].ieeerate;
+		rate3 = sc->sc_hwmap[rt->rateCodeToIndex[hwrate3]].ieeerate;
 		tries3 = MS(ds0->ds_ctl2, AR_XmitDataTries3);
 		ndx3 = rate_to_ndx(sn, rate3);
 

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

@@ -524,6 +524,13 @@
 		| IEEE80211_C_BGSCAN		/* capable of bg scanning */
 		| IEEE80211_C_TXFRAG		/* handle tx frags */
 		;
+	ic->ic_htcaps =
+		  IEEE80211_HTC_HT		/* HT operation */
+		/* h/w capabilities */
+		| IEEE80211_HTCAP_CHWIDTH40	/* 40MHz channel width */
+		| IEEE80211_HTCAP_SHORTGI20	/* short GI in 20MHz */
+		| IEEE80211_HTCAP_SHORTGI40	/* short GI in 40MHz */
+		;
 	/*
 	 * Query the hal to figure out h/w crypto support.
 	 */
@@ -3879,12 +3886,13 @@
 ath_rx_tap(struct ifnet *ifp, struct mbuf *m,
 	const struct ath_rx_status *rs, u_int64_t tsf, int16_t nf)
 {
-#define	CHAN_HT		htole32(CHANNEL_HT20|CHANNEL_HT40PLUS|CHANNEL_HT40MINUS)
 #define	CHAN_HT20	htole32(IEEE80211_CHAN_HT20)
 #define	CHAN_HT40U	htole32(IEEE80211_CHAN_HT40U)
 #define	CHAN_HT40D	htole32(IEEE80211_CHAN_HT40D)
+#define	CHAN_HT		(CHAN_HT20|CHAN_HT40U|CHAN_HT40D)
 	struct ath_softc *sc = ifp->if_softc;
-	uint8_t rxrate;
+	const HAL_RATE_TABLE *rt;
+	uint8_t rix;
 
 	/*
 	 * Discard anything shorter than an ack or cts.
@@ -3895,12 +3903,14 @@
 		sc->sc_stats.ast_rx_tooshort++;
 		return 0;
 	}
-	rxrate = rs->rs_rate;
-	sc->sc_rx_th.wr_rate = sc->sc_hwmap[rxrate].ieeerate;
-	sc->sc_rx_th.wr_flags = sc->sc_hwmap[rxrate].rxflags;
+	rt = sc->sc_currates;
+	KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
+	rix = rt->rateCodeToIndex[rs->rs_rate];
+	sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate;
+	sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].rxflags;
 #if HAL_ABI_VERSION >= 0x07050400
 	sc->sc_rx_th.wr_chan_flags &= ~CHAN_HT;
-	if (sc->sc_rx_th.wr_rate & 0x80) {		/* HT rate */
+	if (sc->sc_rx_th.wr_rate & IEEE80211_RATE_MCS) {	/* HT rate */
 		if ((rs->rs_flags & HAL_RX_2040) == 0)
 			sc->sc_rx_th.wr_chan_flags |= CHAN_HT20;
 		else if (sc->sc_curchan.channelFlags & CHANNEL_HT40PLUS)
@@ -3922,10 +3932,10 @@
 	bpf_mtap2(ifp->if_bpf, &sc->sc_rx_th, sc->sc_rx_th_len, m);
 
 	return 1;
+#undef CHAN_HT
 #undef CHAN_HT20
 #undef CHAN_HT40U
 #undef CHAN_HT40D
-#undef CHAN_HT
 }
 
 static void
@@ -4155,9 +4165,11 @@
 		}
 
 		if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) {
+			const HAL_RATE_TABLE *rt = sc->sc_currates;
+			uint8_t rix = rt->rateCodeToIndex[rs->rs_rate];
+
 			ieee80211_dump_pkt(ic, mtod(m, caddr_t), len,
-				   sc->sc_hwmap[rs->rs_rate].ieeerate,
-				   rs->rs_rssi);
+			    sc->sc_hwmap[rix].ieeerate, rs->rs_rssi);
 		}
 
 		m_adj(m, -IEEE80211_CRC_LEN);
@@ -4897,18 +4909,18 @@
 
 	if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT))
 		ieee80211_dump_pkt(ic, mtod(m0, caddr_t), m0->m_len,
-			sc->sc_hwmap[txrate].ieeerate, -1);
+			sc->sc_hwmap[rix].ieeerate, -1);
 
 	if (bpf_peers_present(ifp->if_bpf)) {
 		u_int64_t tsf = ath_hal_gettsf64(ah);
 
 		sc->sc_tx_th.wt_tsf = htole64(tsf);
-		sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].txflags;
+		sc->sc_tx_th.wt_flags = sc->sc_hwmap[rix].txflags;
 		if (iswep)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
 		if (isfrag)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_FRAG;
-		sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate;
+		sc->sc_tx_th.wt_rate = sc->sc_hwmap[rix].ieeerate;
 		sc->sc_tx_th.wt_txpower = ni->ni_txpower;
 		sc->sc_tx_th.wt_antenna = sc->sc_txantenna;
 
@@ -6066,14 +6078,10 @@
 static void
 ath_led_event(struct ath_softc *sc, int rix)
 {
-	uint8_t code;
-
 	sc->sc_ledevent = ticks;	/* time of last event */
 	if (sc->sc_blinking)		/* don't interrupt active blink */
 		return;
-	/* temp write-around before we change sc_hwmap */
-	code = sc->sc_currates->info[rix].rateCode;
-	ath_led_blink(sc, sc->sc_hwmap[code].ledon, sc->sc_hwmap[code].ledoff);
+	ath_led_blink(sc, sc->sc_hwmap[rix].ledon, sc->sc_hwmap[rix].ledoff);
 }
 
 static int
@@ -6161,20 +6169,19 @@
 	for (i = 0; i < rt->rateCount; i++)
 		sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i;
 	memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap));
-	for (i = 0; i < 32; i++) {
-		u_int8_t ix = rt->rateCodeToIndex[i];
-		if (ix == 0xff) {
+	for (i = 0; i < N(sc->sc_hwmap); i++) {
+		if (i >= rt->rateCount) {
 			sc->sc_hwmap[i].ledon = (500 * hz) / 1000;
 			sc->sc_hwmap[i].ledoff = (130 * hz) / 1000;
 			continue;
 		}
 		sc->sc_hwmap[i].ieeerate =
-			rt->info[ix].dot11Rate & IEEE80211_RATE_VAL;
-		if (rt->info[ix].phy == IEEE80211_T_HT)
+			rt->info[i].dot11Rate & IEEE80211_RATE_VAL;
+		if (rt->info[i].phy == IEEE80211_T_HT)
 			sc->sc_hwmap[i].ieeerate |= 0x80;	/* MCS */
 		sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD;
-		if (rt->info[ix].shortPreamble ||
-		    rt->info[ix].phy == IEEE80211_T_OFDM)
+		if (rt->info[i].shortPreamble ||
+		    rt->info[i].phy == IEEE80211_T_OFDM)
 			sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE;
 		/* NB: receive frames include FCS */
 		sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags |
@@ -6890,16 +6897,16 @@
 
 	if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT))
 		ieee80211_dump_pkt(ic, mtod(m0, caddr_t), m0->m_len,
-			sc->sc_hwmap[txrate].ieeerate, -1);
+			sc->sc_hwmap[rix].ieeerate, -1);
 	
 	if (bpf_peers_present(ifp->if_bpf)) {
 		u_int64_t tsf = ath_hal_gettsf64(ah);
 
 		sc->sc_tx_th.wt_tsf = htole64(tsf);
-		sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].txflags;
+		sc->sc_tx_th.wt_flags = sc->sc_hwmap[rix].txflags;
 		if (wh->i_fc[1] & IEEE80211_FC1_WEP)
 			sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
-		sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate;
+		sc->sc_tx_th.wt_rate = sc->sc_hwmap[rix].ieeerate;
 		sc->sc_tx_th.wt_txpower = ni->ni_txpower;
 		sc->sc_tx_th.wt_antenna = sc->sc_txantenna;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808041751.m74HpSXC092006>