Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Jan 2007 00:02:10 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 113230 for review
Message-ID:  <200701210002.l0L02AwA048810@repoman.freebsd.org>

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

Change 113230 by sam@sam_ebb on 2007/01/21 00:01:21

	IFC @ 113228

Affected files ...

.. //depot/projects/wifi/sys/dev/ath/ath_rate/sample/sample.c#11 integrate
.. //depot/projects/wifi/sys/dev/ath/ath_rate/sample/sample.h#6 integrate
.. //depot/projects/wifi/sys/dev/ath/if_ath.c#127 integrate
.. //depot/projects/wifi/sys/dev/ath/if_athvar.h#52 integrate

Differences ...

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

@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ath/ath_rate/sample/sample.c,v 1.15 2006/12/13 19:34:35 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ath/ath_rate/sample/sample.c,v 1.16 2007/01/15 01:17:44 sam Exp $");
 
 /*
  * John Bicket's SampleRate control algorithm.
@@ -534,24 +534,6 @@
 		    short_tries, long_tries);
 		return;
 	}
-
-	if (ts->ts_status) {		/* this packet failed */
-		DPRINTF(sc, ATH_DEBUG_RATE,
-"%s: %s size %d rate/try [%d/%d %d/%d %d/%d %d/%d] FAIL tries [%d/%d]\n", 
-		    __func__,
-		    ether_sprintf(an->an_node.ni_macaddr),
-		    bin_to_size(size_to_bin(frame_size)),
-		    sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate0)].ieeerate,
-			MS(ds0->ds_ctl2, AR_XmitDataTries0),
-		    sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate1)].ieeerate,
-			MS(ds0->ds_ctl2, AR_XmitDataTries1),
-		    sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate2)].ieeerate,
-			MS(ds0->ds_ctl2, AR_XmitDataTries2),
-		    sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate3)].ieeerate,
-			MS(ds0->ds_ctl2, AR_XmitDataTries3),
-		    short_tries, long_tries);
-	}
-
 	mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT);
 	if (!mrr || !(ts->ts_rate & HAL_TXSTAT_ALTRATE)) {
 		int ndx = rate_to_ndx(sn, final_rate);
@@ -572,32 +554,43 @@
 			     0, 0,
 			     short_tries, long_tries, ts->ts_status);
 	} else {
-		int rate0, tries0, ndx0;
-		int rate1, tries1, ndx1;
-		int rate2, tries2, ndx2;
-		int rate3, tries3, ndx3;
+		int hwrate0, rate0, tries0, ndx0;
+		int hwrate1, rate1, tries1, ndx1;
+		int hwrate2, rate2, tries2, ndx2;
+		int hwrate3, rate3, tries3, ndx3;
 		int finalTSIdx = ts->ts_finaltsi;
 
 		/*
 		 * Process intermediate rates that failed.
 		 */
-		rate0 = sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate0)].ieeerate;
+		if (sc->sc_ah->ah_magic != 0x20065416) {
+			hwrate0 = MS(ds0->ds_ctl3, AR_XmitRate0);
+			hwrate1 = MS(ds0->ds_ctl3, AR_XmitRate1);
+			hwrate2 = MS(ds0->ds_ctl3, AR_XmitRate2);
+			hwrate3 = MS(ds0->ds_ctl3, AR_XmitRate3);
+		} else {
+			hwrate0 = MS(ds0->ds_ctl3, AR5416_XmitRate0);
+			hwrate1 = MS(ds0->ds_ctl3, AR5416_XmitRate1);
+			hwrate2 = MS(ds0->ds_ctl3, AR5416_XmitRate2);
+			hwrate3 = MS(ds0->ds_ctl3, AR5416_XmitRate3);
+		}
+
+		rate0 = sc->sc_hwmap[hwrate0].ieeerate;
 		tries0 = MS(ds0->ds_ctl2, AR_XmitDataTries0);
 		ndx0 = rate_to_ndx(sn, rate0);
 
-		rate1 = sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate1)].ieeerate;
+		rate1 = sc->sc_hwmap[hwrate1].ieeerate;
 		tries1 = MS(ds0->ds_ctl2, AR_XmitDataTries1);
 		ndx1 = rate_to_ndx(sn, rate1);
 
-		rate2 = sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate2)].ieeerate;
+		rate2 = sc->sc_hwmap[hwrate2].ieeerate;
 		tries2 = MS(ds0->ds_ctl2, AR_XmitDataTries2);
 		ndx2 = rate_to_ndx(sn, rate2);
 
-		rate3 = sc->sc_hwmap[MS(ds0->ds_ctl3, AR_XmitRate3)].ieeerate;
+		rate3 = sc->sc_hwmap[hwrate3].ieeerate;
 		tries3 = MS(ds0->ds_ctl2, AR_XmitDataTries3);
 		ndx3 = rate_to_ndx(sn, rate3);
 
-#if 1
 		DPRINTF(sc, ATH_DEBUG_RATE,
 "%s: %s size %d finaltsidx %d tries %d %s rate/try [%d/%d %d/%d %d/%d %d/%d]\n", 
 		     __func__, ether_sprintf(an->an_node.ni_macaddr),
@@ -609,7 +602,6 @@
 		     rate1, tries1,
 		     rate2, tries2,
 		     rate3, tries3);
-#endif
 
 		/*
 		 * NB: series > 0 are not penalized for failure

==== //depot/projects/wifi/sys/dev/ath/ath_rate/sample/sample.h#6 (text+ko) ====

@@ -33,7 +33,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: src/sys/dev/ath/ath_rate/sample/sample.h,v 1.6 2006/12/13 19:34:35 sam Exp $
+ * $FreeBSD: src/sys/dev/ath/ath_rate/sample/sample.h,v 1.7 2007/01/15 01:17:44 sam Exp $
  */
 
 /*
@@ -136,6 +136,16 @@
 #define	AR_XmitRate3		0x000f8000	/* series 3 tx rate */
 #define	AR_XmitRate3_S		15
 
+/* TX ds_ctl3 for 5416 */
+#define	AR5416_XmitRate0	0x000000ff	/* series 0 tx rate */
+#define	AR5416_XmitRate0_S	0
+#define	AR5416_XmitRate1	0x0000ff00	/* series 1 tx rate */
+#define	AR5416_XmitRate1_S	8
+#define	AR5416_XmitRate2	0x00ff0000	/* series 2 tx rate */
+#define	AR5416_XmitRate2_S	16
+#define	AR5416_XmitRate3	0xff000000	/* series 3 tx rate */
+#define	AR5416_XmitRate3_S	24
+
 #define MS(_v, _f)	(((_v) & (_f)) >> _f##_S)
 
 /*

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

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.158 2006/12/27 19:07:09 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.159 2007/01/15 01:15:57 sam Exp $");
 
 /*
  * Driver for the Atheros Wireless LAN controller.
@@ -370,8 +370,8 @@
 	ath_rate_setup(sc, IEEE80211_MODE_TURBO_A);
 	ath_rate_setup(sc, IEEE80211_MODE_TURBO_G);
 	ath_rate_setup(sc, IEEE80211_MODE_STURBO_A);
-	ath_rate_setup(sc, IEEE80211_MODE_11A_HALF);
-	ath_rate_setup(sc, IEEE80211_MODE_11A_QUARTER);
+	ath_rate_setup(sc, IEEE80211_MODE_HALF);
+	ath_rate_setup(sc, IEEE80211_MODE_QUARTER);
 
 	/* NB: setup here so ath_rate_update is happy */
 	ath_setcurmode(sc, IEEE80211_MODE_11A);
@@ -945,8 +945,13 @@
 	}
 }
 
-static u_int
-ath_chan2flags(struct ieee80211_channel *chan)
+/*
+ * Convert net80211 channel to a HAL channel with the flags
+ * constrained to reflect the current operating mode and
+ * the frequency possibly mapped for GSM channels.
+ */
+static void
+ath_mapchan(HAL_CHANNEL *hc, const struct ieee80211_channel *chan)
 {
 #define	N(a)	(sizeof(a) / sizeof(a[0]))
 	static const u_int modeflags[] = {
@@ -960,16 +965,17 @@
 		CHANNEL_ST		/* IEEE80211_MODE_STURBO_A */
 	};
 	enum ieee80211_phymode mode = ieee80211_chan2mode(chan);
-	int flags;
 
 	KASSERT(mode < N(modeflags), ("unexpected phy mode %u", mode));
 	KASSERT(modeflags[mode] != 0, ("mode %u undefined", mode));
-	flags = modeflags[mode];
+	hc->channelFlags = modeflags[mode];
 	if (IEEE80211_IS_CHAN_HALF(chan))
-		flags |= CHANNEL_HALF;
-	else if (IEEE80211_IS_CHAN_QUARTER(chan))
-		flags |= CHANNEL_QUARTER;
-	return flags;
+		hc->channelFlags |= CHANNEL_HALF;
+	if (IEEE80211_IS_CHAN_QUARTER(chan))
+		hc->channelFlags |= CHANNEL_QUARTER;
+
+	hc->channel = IEEE80211_IS_CHAN_GSM(chan) ?
+		2422 + (922 - chan->ic_freq) : chan->ic_freq;
 #undef N
 }
 
@@ -999,8 +1005,7 @@
 	 * be followed by initialization of the appropriate bits
 	 * and then setup of the interrupt mask.
 	 */
-	sc->sc_curchan.channel = ic->ic_curchan->ic_freq;
-	sc->sc_curchan.channelFlags = ath_chan2flags(ic->ic_curchan);
+	ath_mapchan(&sc->sc_curchan, ic->ic_curchan);
 	if (!ath_hal_reset(ah, sc->sc_opmode, &sc->sc_curchan, AH_FALSE, &status)) {
 		if_printf(ifp, "unable to reset hardware; hal status %u\n",
 			status);
@@ -1158,16 +1163,13 @@
 	struct ath_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = &sc->sc_ic;
 	struct ath_hal *ah = sc->sc_ah;
-	struct ieee80211_channel *c;
 	HAL_STATUS status;
 
 	/*
 	 * Convert to a HAL channel description with the flags
 	 * constrained to reflect the current operating mode.
 	 */
-	c = ic->ic_curchan;
-	sc->sc_curchan.channel = c->ic_freq;
-	sc->sc_curchan.channelFlags = ath_chan2flags(c);
+	ath_mapchan(&sc->sc_curchan, ic->ic_curchan);
 
 	ath_hal_intrset(ah, 0);		/* disable interrupts */
 	ath_draintxq(sc);		/* stop xmit side */
@@ -1185,7 +1187,7 @@
 	 * that changes the channel so update any state that
 	 * might change as a result.
 	 */
-	ath_chan_change(sc, c);
+	ath_chan_change(sc, ic->ic_curchan);
 	if (ath_startrecv(sc) != 0)	/* restart recv */
 		if_printf(ifp, "%s: unable to start recv logic\n", __func__);
 	if (ic->ic_state == IEEE80211_S_RUN)
@@ -2376,17 +2378,19 @@
 	struct ath_hal *ah = sc->sc_ah;
 	u_int usec;
 
-	if (IEEE80211_IS_CHAN_A(ic->ic_curchan)) {
-		if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan))
-			usec = 13;
-		else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan))
-			usec = 21;
+	if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan))
+		usec = 13;
+	else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan))
+		usec = 21;
+	else if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
+		/* honor short/long slot time only in 11g */
+		/* XXX shouldn't honor on pure g or turbo g channel */
+		if (ic->ic_flags & IEEE80211_F_SHSLOT)
+			usec = HAL_SLOT_TIME_9;
 		else
-			usec = HAL_SLOT_TIME_9;
-	} else if (ic->ic_flags & IEEE80211_F_SHSLOT)
+			usec = HAL_SLOT_TIME_20;
+	} else
 		usec = HAL_SLOT_TIME_9;
-	else
-		usec = HAL_SLOT_TIME_20;
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: chan %u MHz flags 0x%x %s slot, %u usec\n",
@@ -3243,8 +3247,7 @@
 
 	*rssi = ath_node_getrssi(ni);
 	if (ni->ni_chan != IEEE80211_CHAN_ANYC) {
-		hchan.channel = ni->ni_chan->ic_freq;
-		hchan.channelFlags = ath_chan2flags(ni->ni_chan);
+		ath_mapchan(&hchan, ni->ni_chan);
 		*noise = ath_hal_getchannoise(ah, &hchan);
 	} else
 		*noise = -95;		/* nominally correct */
@@ -4959,13 +4962,12 @@
 	 * Change channels and update the h/w rate map
 	 * if we're switching; e.g. 11a to 11b/g.
 	 */
-	mode = ieee80211_chan2mode(chan);
-	if (mode == IEEE80211_MODE_11A) {
-		if (IEEE80211_IS_CHAN_HALF(chan))
-			mode = IEEE80211_MODE_11A_HALF;
-		else if (IEEE80211_IS_CHAN_QUARTER(chan))
-			mode = IEEE80211_MODE_11A_QUARTER;
-	}
+	if (IEEE80211_IS_CHAN_HALF(chan))
+		mode = IEEE80211_MODE_HALF;
+	else if (IEEE80211_IS_CHAN_QUARTER(chan))
+		mode = IEEE80211_MODE_QUARTER;
+	else
+		mode = ieee80211_chan2mode(chan);
 	if (mode != sc->sc_curmode)
 		ath_setcurmode(sc, mode);
 	/*
@@ -4980,6 +4982,10 @@
 		flags = IEEE80211_CHAN_B;
 	if (IEEE80211_IS_CHAN_TURBO(chan))
 		flags |= IEEE80211_CHAN_TURBO;
+	if (IEEE80211_IS_CHAN_HALF(chan))
+		flags |= IEEE80211_CHAN_HALF;
+	if (IEEE80211_IS_CHAN_QUARTER(chan))
+		flags |= IEEE80211_CHAN_QUARTER;
 	sc->sc_tx_th.wt_chan_freq = sc->sc_rx_th.wr_chan_freq =
 		htole16(chan->ic_freq);
 	sc->sc_tx_th.wt_chan_flags = sc->sc_rx_th.wr_chan_flags =
@@ -5040,8 +5046,7 @@
 	 * the flags constrained to reflect the current
 	 * operating mode.
 	 */
-	hchan.channel = chan->ic_freq;
-	hchan.channelFlags = ath_chan2flags(chan);
+	ath_mapchan(&hchan, chan);
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: %u (%u MHz, hal flags 0x%x) -> %u (%u MHz, hal flags 0x%x)\n",
@@ -5488,6 +5493,13 @@
 			ichan->ic_ieee += 37;		/* XXX */
 		ichan->ic_freq = c->channel;
 		ichan->ic_flags = c->channelFlags;
+		if (ath_hal_isgsmsku(ah)) {
+			/* remap to true frequencies */
+			ichan->ic_freq = 922 + (2422 - ichan->ic_freq);
+			ichan->ic_flags |= IEEE80211_CHAN_GSM;
+			ichan->ic_ieee = ieee80211_mhz2ieee(ichan->ic_freq,
+				ichan->ic_flags);
+		}
 		ichan->ic_maxregpower = c->maxRegTxPower;	/* dBm */
 		ichan->ic_maxpower = c->maxTxPower / 2;		/* 1/2 dBm */
 		ichan->ic_minpower = c->minTxPower / 2;		/* 1/2 dBm */
@@ -5590,10 +5602,10 @@
 	case IEEE80211_MODE_11A:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11A);
 		break;
-	case IEEE80211_MODE_11A_HALF:
+	case IEEE80211_MODE_HALF:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE);
 		break;
-	case IEEE80211_MODE_11A_QUARTER:
+	case IEEE80211_MODE_QUARTER:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE);
 		break;
 	case IEEE80211_MODE_11B:
@@ -5644,6 +5656,7 @@
 		{   4, 267,  66 },
 		{   2, 400, 100 },
 		{   0, 500, 130 },
+		/* XXX half/quarter rates */
 	};
 	const HAL_RATE_TABLE *rt;
 	int i, j;

==== //depot/projects/wifi/sys/dev/ath/if_athvar.h#52 (text+ko) ====

@@ -33,7 +33,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.56 2006/12/27 19:07:09 sam Exp $
+ * $FreeBSD: src/sys/dev/ath/if_athvar.h,v 1.58 2007/01/15 04:26:19 sam Exp $
  */
 
 /*
@@ -227,8 +227,8 @@
 				sc_outdoor  : 1,/* outdoor operation */
 				sc_dturbo  : 1;	/* dynamic turbo in use */
 						/* rate tables */
-#define	IEEE80211_MODE_11A_HALF		(IEEE80211_MODE_MAX+0)
-#define	IEEE80211_MODE_11A_QUARTER	(IEEE80211_MODE_MAX+1)
+#define	IEEE80211_MODE_HALF	(IEEE80211_MODE_MAX+0)
+#define	IEEE80211_MODE_QUARTER	(IEEE80211_MODE_MAX+1)
 	const HAL_RATE_TABLE	*sc_rates[IEEE80211_MODE_MAX+2];
 	const HAL_RATE_TABLE	*sc_half_rates;	/* half rate table */
 	const HAL_RATE_TABLE	*sc_quarter_rates;/* quarter rate table */
@@ -579,6 +579,11 @@
 	(((ah)->ah_regdomain == 0 && (ah)->ah_countryCode == 842) || \
 	 (ah)->ah_regdomain == 0x12)
 #endif
+#if HAL_ABI_VERSION < 0x06122400
+/* XXX yech, can't get to regdomain so just hack a compat shim */
+#define	ath_hal_isgsmsku(ah) \
+	((ah)->ah_countryCode == 843)
+#endif
 
 #define	ath_hal_setuprxdesc(_ah, _ds, _size, _intreq) \
 	((*(_ah)->ah_setupRxDesc)((_ah), (_ds), (_size), (_intreq)))



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