From owner-svn-src-all@FreeBSD.ORG Mon Aug 8 17:33:36 2011 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 55E50106566C; Mon, 8 Aug 2011 17:33:36 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 457CA8FC12; Mon, 8 Aug 2011 17:33:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p78HXaJv057250; Mon, 8 Aug 2011 17:33:36 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p78HXa2p057248; Mon, 8 Aug 2011 17:33:36 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108081733.p78HXa2p057248@svn.freebsd.org> From: Adrian Chadd Date: Mon, 8 Aug 2011 17:33:36 +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: r224718 - head/sys/dev/ath/ath_hal 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, 08 Aug 2011 17:33:36 -0000 Author: adrian Date: Mon Aug 8 17:33:35 2011 New Revision: 224718 URL: http://svn.freebsd.org/changeset/base/224718 Log: The older HAL code sets up the regulatory domain once; FreeBSD/net80211 allows it to be overridden at runtime. Thus, add a function which updates ah_dfsDomain after a channel set call to ath_hal_set_channels(). Approved by: re (kib, blanket) Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain.c Mon Aug 8 16:29:07 2011 (r224717) +++ head/sys/dev/ath/ath_hal/ah_regdomain.c Mon Aug 8 17:33:35 2011 (r224718) @@ -125,6 +125,8 @@ static const struct cmode modes[] = { IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D }, }; +static void ath_hal_update_dfsdomain(struct ath_hal *ah); + static OS_INLINE uint16_t getEepromRD(struct ath_hal *ah) { @@ -687,9 +689,8 @@ ath_hal_init_channels(struct ath_hal *ah HAL_BOOL enableExtendedChannels) { COUNTRY_CODE_TO_ENUM_RD *country; - REG_DOMAIN *rd5GHz = AH_NULL, *rd2GHz; + REG_DOMAIN *rd5GHz, *rd2GHz; HAL_STATUS status; - HAL_DFS_DOMAIN dfsDomain = HAL_DFS_UNINIT_DOMAIN; status = getchannels(ah, chans, maxchans, nchans, modeSelect, cc, regDmn, enableExtendedChannels, &country, &rd2GHz, &rd5GHz); @@ -701,20 +702,12 @@ ath_hal_init_channels(struct ath_hal *ah ah->ah_countryCode = country->countryCode; HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, "%s: cc %u\n", __func__, ah->ah_countryCode); + + /* Update current DFS domain */ + ath_hal_update_dfsdomain(ah); } else status = HAL_EINVAL; - /* Update the DFS setting for the current regulatory domain */ - if (status == HAL_OK && rd5GHz != AH_NULL) { - if (rd5GHz->dfsMask & DFS_FCC3) - dfsDomain = HAL_DFS_FCC_DOMAIN; - if (rd5GHz->dfsMask & DFS_ETSI) - dfsDomain = HAL_DFS_ETSI_DOMAIN; - if (rd5GHz->dfsMask & DFS_MKK4) - dfsDomain = HAL_DFS_MKK4_DOMAIN; - } - AH_PRIVATE(ah)->ah_dfsDomain = dfsDomain; - return status; } @@ -759,6 +752,11 @@ ath_hal_set_channels(struct ath_hal *ah, __func__, ah->ah_countryCode); } else status = HAL_EINVAL; + + if (status == HAL_OK) { + /* Update current DFS domain */ + (void) ath_hal_update_dfsdomain(ah); + } return status; } @@ -824,6 +822,37 @@ ath_hal_getctl(struct ath_hal *ah, const return ctl; } + +/* + * Update the current dfsDomain setting based on the given + * country code. + * + * Since FreeBSD/net80211 allows the channel set to change + * after the card has been setup (via ath_hal_init_channels()) + * this function method is needed to update ah_dfsDomain. + */ +void +ath_hal_update_dfsdomain(struct ath_hal *ah) +{ + const REG_DOMAIN *rd5GHz = AH_PRIVATE(ah)->ah_rd5GHz; + HAL_CTRY_CODE cc = ah->ah_countryCode; + HAL_DFS_DOMAIN dfsDomain = HAL_DFS_UNINIT_DOMAIN; + HAL_REG_DOMAIN regDmn = AH_PRIVATE(ah)->ah_currentRD; + + HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, "%s CC: %d, RegDmn: %d\n",__func__, + cc, regDmn); + if (rd5GHz->dfsMask & DFS_FCC3) + dfsDomain = HAL_DFS_FCC_DOMAIN; + if (rd5GHz->dfsMask & DFS_ETSI) + dfsDomain = HAL_DFS_ETSI_DOMAIN; + if (rd5GHz->dfsMask & DFS_MKK4) + dfsDomain = HAL_DFS_MKK4_DOMAIN; + AH_PRIVATE(ah)->ah_dfsDomain = dfsDomain; + HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, "%s ah_dfsDomain: %d\n", + __func__, AH_PRIVATE(ah)->ah_dfsDomain); +} + + /* * Return the max allowed antenna gain and apply any regulatory * domain specific changes.