From owner-svn-src-head@FreeBSD.ORG Mon Oct 27 18:00:44 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05BDE1065674; Mon, 27 Oct 2008 18:00:44 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E81038FC18; Mon, 27 Oct 2008 18:00:43 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9RI0h5p047846; Mon, 27 Oct 2008 18:00:43 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RI0h3e047844; Mon, 27 Oct 2008 18:00:43 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271800.m9RI0h3e047844@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 18:00:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r184364 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2008 18:00:44 -0000 Author: sam Date: Mon Oct 27 18:00:43 2008 New Revision: 184364 URL: http://svn.freebsd.org/changeset/base/184364 Log: add hack to deal with Ubiquiti XR9 cards, they have a different mapping between 900MHz and 2.4GHz frequencies than SR9 cards; they are distinguished by different country codes Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Mon Oct 27 18:00:39 2008 (r184363) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 18:00:43 2008 (r184364) @@ -120,6 +120,8 @@ enum { ATH_LED_POLL, }; +#define CTRY_XR9 5001 /* Ubiquiti XR9 */ + static struct ieee80211vap *ath_vap_create(struct ieee80211com *, const char name[IFNAMSIZ], int unit, int opmode, int flags, const uint8_t bssid[IEEE80211_ADDR_LEN], @@ -1317,7 +1319,8 @@ ath_bmiss_proc(void *arg, int pending) * the frequency possibly mapped for GSM channels. */ static void -ath_mapchan(HAL_CHANNEL *hc, const struct ieee80211_channel *chan) +ath_mapchan(const struct ieee80211com *ic, + HAL_CHANNEL *hc, const struct ieee80211_channel *chan) { #define N(a) (sizeof(a) / sizeof(a[0])) static const u_int modeflags[IEEE80211_MODE_MAX] = { @@ -1348,8 +1351,13 @@ ath_mapchan(HAL_CHANNEL *hc, const struc if (IEEE80211_IS_CHAN_HT40U(chan)) hc->channelFlags |= CHANNEL_HT40PLUS; - hc->channel = IEEE80211_IS_CHAN_GSM(chan) ? - 2422 + (922 - chan->ic_freq) : chan->ic_freq; + if (IEEE80211_IS_CHAN_GSM(chan)) { + if (ic->ic_regdomain.country == CTRY_XR9) + hc->channel = 2427 + (chan->ic_freq - 907); + else + hc->channel = 2422 + (922 - chan->ic_freq); + } else + hc->channel = chan->ic_freq; #undef N } @@ -1402,7 +1410,7 @@ ath_init(void *arg) * be followed by initialization of the appropriate bits * and then setup of the interrupt mask. */ - ath_mapchan(&sc->sc_curchan, ic->ic_curchan); + ath_mapchan(ic, &sc->sc_curchan, ic->ic_curchan); ath_settkipmic(sc); 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", @@ -1539,7 +1547,7 @@ ath_reset(struct ifnet *ifp) * Convert to a HAL channel description with the flags * constrained to reflect the current operating mode. */ - ath_mapchan(&sc->sc_curchan, ic->ic_curchan); + ath_mapchan(ic, &sc->sc_curchan, ic->ic_curchan); ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* stop xmit side */ @@ -3723,7 +3731,7 @@ ath_node_getsignal(const struct ieee8021 *rssi = ic->ic_node_getrssi(ni); if (ni->ni_chan != IEEE80211_CHAN_ANYC) { - ath_mapchan(&hchan, ni->ni_chan); + ath_mapchan(ic, &hchan, ni->ni_chan); *noise = ath_hal_getchannoise(ah, &hchan); } else *noise = -95; /* nominally correct */ @@ -5435,7 +5443,7 @@ ath_chan_set(struct ath_softc *sc, struc * the flags constrained to reflect the current * operating mode. */ - ath_mapchan(&hchan, chan); + ath_mapchan(ic, &hchan, chan); DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, hal flags 0x%x) -> %u (%u MHz, hal flags 0x%x)\n", @@ -5918,8 +5926,15 @@ getchannels(struct ath_softc *sc, int *n } if (ath_hal_isgsmsku(ah)) { - /* remap to true frequencies */ - ichan->ic_freq = 922 + (2422 - ichan->ic_freq); + /* + * Remap to true frequencies: Ubiquiti XR9 cards use a + * frequency mapping different from their SR9 cards. + * We define special country codes to deal with this. + */ + if (cc == CTRY_XR9) + ichan->ic_freq = 907 + (ichan->ic_freq - 2427); + else + 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);