From owner-svn-src-all@FreeBSD.ORG Mon Oct 27 17:41:32 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 836B41065670; Mon, 27 Oct 2008 17:41:32 +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 7120A8FC0A; Mon, 27 Oct 2008 17:41:32 +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 m9RHfWZq047106; Mon, 27 Oct 2008 17:41:32 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9RHfWAc047104; Mon, 27 Oct 2008 17:41:32 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200810271741.m9RHfWAc047104@svn.freebsd.org> From: Sam Leffler Date: Mon, 27 Oct 2008 17:41:32 +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: r184356 - head/sys/dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2008 17:41:32 -0000 Author: sam Date: Mon Oct 27 17:41:32 2008 New Revision: 184356 URL: http://svn.freebsd.org/changeset/base/184356 Log: Regdomain fixups: o pass country code, outdoor indication, and ecm mode into the hal when requesting a channel list o add a console msg when regulatory setup fails o add placeholder code to map between Atheros sku's and 802.11 sku's that handles only the debug country code used to unlock the full channel list (to be used only for debugging) o fix multiple instances of mismapping the 802.11 location to the outdoor indication (anywhere may be outdoor also) 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 17:35:09 2008 (r184355) +++ head/sys/dev/ath/if_ath.c Mon Oct 27 17:41:32 2008 (r184356) @@ -5873,7 +5873,11 @@ getchannels(struct ath_softc *sc, int *n } error = 0; if (!ath_hal_init_channels(ah, halchans, IEEE80211_CHAN_MAX, &nhalchans, - NULL, 0, NULL, CTRY_DEFAULT, HAL_MODE_ALL, AH_FALSE, AH_TRUE)) { + NULL, 0, NULL, cc, HAL_MODE_ALL, outdoor, ecm)) { + u_int32_t rd; + (void) ath_hal_getregdomain(ah, &rd); + device_printf(sc->sc_dev, "ath_hal_init_channels failed, " + "rd %d cc %u outdoor %u ecm %u\n", rd, cc, outdoor, ecm); error = EINVAL; goto done; } @@ -5926,25 +5930,47 @@ done: return error; } +/* XXX hard to include ieee80211_regdomain.h right now */ +#define SKU_DEBUG 0x1ff + +static void +ath_maprd(const struct ieee80211_regdomain *rd, + u_int32_t *ath_rd, u_int32_t *ath_cc) +{ + /* map SKU's to Atheros sku's */ + switch (rd->regdomain) { + case SKU_DEBUG: + if (rd->country == 0) { + *ath_rd = 0; + *ath_cc = CTRY_DEBUG; + return; + } + break; + } + *ath_rd = rd->regdomain; + *ath_cc = rd->country; +} + static int ath_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd, int nchans, struct ieee80211_channel chans[]) { struct ath_softc *sc = ic->ic_ifp->if_softc; struct ath_hal *ah = sc->sc_ah; - u_int32_t ord; + u_int32_t ord, regdomain, cc; int error; (void) ath_hal_getregdomain(ah, &ord); - /* XXX map sku->rd */ + ath_maprd(rd, ®domain, &cc); DPRINTF(sc, ATH_DEBUG_REGDOMAIN, - "%s: rd %u cc %u location %c ecm %u\n", - __func__, rd->regdomain, rd->country, rd->location, rd->ecm); - ath_hal_setregdomain(ah, rd->regdomain); + "%s: rd %u cc %u location %c ecm %u (mapped rd %u cc %u)\n", + __func__, rd->regdomain, rd->country, rd->location, rd->ecm, + regdomain, cc); + ath_hal_setregdomain(ah, regdomain); - error = getchannels(sc, &nchans, chans, rd->country, + error = getchannels(sc, &nchans, chans, cc, rd->ecm ? AH_TRUE : AH_FALSE, - rd->location == 'O' ? AH_TRUE : AH_FALSE); + rd->location != 'I' ? AH_TRUE : AH_FALSE); if (error != 0) { /* * Restore previous state. @@ -5952,7 +5978,7 @@ ath_setregdomain(struct ieee80211com *ic ath_hal_setregdomain(ah, ord); (void) getchannels(sc, NULL, NULL, ic->ic_regdomain.country, ic->ic_regdomain.ecm ? AH_TRUE : AH_FALSE, - ic->ic_regdomain.location == 'O' ? AH_TRUE : AH_FALSE); + ic->ic_regdomain.location != 'I' ? AH_TRUE : AH_FALSE); return error; } return 0; @@ -5979,14 +6005,28 @@ ath_getradiocaps(struct ieee80211com *ic ath_hal_setregdomain(ah, ord); (void) getchannels(sc, NULL, NULL, ic->ic_regdomain.country, ic->ic_regdomain.ecm ? AH_TRUE : AH_FALSE, - ic->ic_regdomain.location == 'O' ? AH_TRUE : AH_FALSE); + ic->ic_regdomain.location != 'I' ? AH_TRUE : AH_FALSE); } -static int -ath_mapregdomain(struct ath_softc *sc, u_int32_t rd) +static void +ath_mapsku(u_int32_t ath_rd, u_int32_t ath_cc, struct ieee80211_regdomain *rd) { - /* map Atheros rd's to SKU's */ - return rd; + rd->isocc[0] = ' '; /* XXX don't know */ + rd->isocc[1] = ' '; + + /* map Atheros sku's to SKU's */ + switch (ath_rd) { + case 0: + if (ath_cc == CTRY_DEBUG) { + rd->regdomain = SKU_DEBUG; + rd->country = 0; + return; + } + break; + } + /* XXX net80211 types too small */ + rd->regdomain = (uint16_t) ath_rd; + rd->country = (uint16_t) ath_cc; } static int @@ -6013,12 +6053,9 @@ ath_getchannels(struct ath_softc *sc) } return error; } - ic->ic_regdomain.regdomain = ath_mapregdomain(sc, sc->sc_eerd); - ic->ic_regdomain.country = sc->sc_eecc; ic->ic_regdomain.ecm = 1; ic->ic_regdomain.location = 'I'; - ic->ic_regdomain.isocc[0] = ' '; /* XXX don't know */ - ic->ic_regdomain.isocc[1] = ' '; + ath_mapsku(sc->sc_eerd, sc->sc_eecc, &ic->ic_regdomain); DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: eeprom rd %u cc %u (mapped rd %u cc %u) location %c ecm %u\n",