From owner-svn-src-head@freebsd.org Thu Jan 5 04:56:05 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9628C9E672; Thu, 5 Jan 2017 04:56:05 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4159150F; Thu, 5 Jan 2017 04:56:05 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v054u4sO086577; Thu, 5 Jan 2017 04:56:04 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v054u4p9086576; Thu, 5 Jan 2017 04:56:04 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201701050456.v054u4p9086576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 5 Jan 2017 04:56:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311361 - head/sys/dev/ath/ath_hal X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 05 Jan 2017 04:56:06 -0000 Author: adrian Date: Thu Jan 5 04:56:04 2017 New Revision: 311361 URL: https://svnweb.freebsd.org/changeset/base/311361 Log: [ath_hal] mad, mad hacks to get some semblence of correct HT/40 channels populated. The HT40 channel population logic was "just" doing pairs of channels starting with the band entry frequency. Trouble is, a lot of the rules start way off at 5120MHz, which isn't a valid 5GHz channel. Then, eg for HT40U, it would populate: * (5120,5140) * (5160,5180) * (5200,5220) * (5240,5260) .. as the HT40U pairs, with the first being the primary channel. Channel 36 is 5180MHz, and since it's not a primary channel here, it wouldn't populate it. Then, the next HT40U would be 5200/5220, which is highly wrong. HT40D had the same problem. So, this just forces that 5GHz HT40 channels start at channel 36 (5180), no matter what the band edge says. This includes eg doing 4.9GHz channels. This erm, meant that the HT40 channels for the low band was always wrong. Oops! Tested: * AR9380, STA mode * AR9344 SoC, AP mode MFC after: 1 week 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 Thu Jan 5 04:49:23 2017 (r311360) +++ head/sys/dev/ath/ath_hal/ah_regdomain.c Thu Jan 5 04:56:04 2017 (r311361) @@ -426,6 +426,10 @@ addchan(struct ath_hal *ah, struct ieee8 if (*nchans >= maxchans) return (HAL_ENOMEM); + HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, + "%s: %d: freq=%d, flags=0x%08x\n", + __func__, *nchans, (int) freq, flags); + c = &chans[(*nchans)++]; c->ic_freq = freq; c->ic_flags = flags; @@ -439,7 +443,7 @@ addchan(struct ath_hal *ah, struct ieee8 static int copychan_prev(struct ath_hal *ah, struct ieee80211_channel chans[], - u_int maxchans, int *nchans, uint16_t freq) + u_int maxchans, int *nchans, uint16_t freq, uint32_t flags) { struct ieee80211_channel *c; @@ -449,6 +453,10 @@ copychan_prev(struct ath_hal *ah, struct if (*nchans >= maxchans) return (HAL_ENOMEM); + HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, + "%s: %d: freq=%d, flags=0x%08x\n", + __func__, *nchans, (int) freq, flags); + c = &chans[(*nchans)++]; c[0] = c[-1]; c->ic_freq = freq; @@ -469,9 +477,13 @@ add_chanlist_band(struct ath_hal *ah, st if (freq_hi < freq_lo) return (0); + HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, + "%s: freq=%d..%d, flags=0x%08x, step=%d\n", __func__, + (int) freq_lo, (int) freq_hi, flags, step); + error = addchan(ah, chans, maxchans, nchans, freq, flags, fband, rd); for (freq += step; freq <= freq_hi && error == 0; freq += step) - error = copychan_prev(ah, chans, maxchans, nchans, freq); + error = copychan_prev(ah, chans, maxchans, nchans, freq, flags); return (error); } @@ -548,7 +560,6 @@ add_chanlist_mode(struct ath_hal *ah, st continue; } #endif - /* * XXX TODO: handle REG_EXT_FCC_CH_144. * @@ -558,11 +569,52 @@ add_chanlist_mode(struct ath_hal *ah, st bfreq_lo = MAX(fband->lowChannel + low_adj, freq_lo); bfreq_hi = MIN(fband->highChannel + hi_adj, freq_hi); + + /* + * Don't start the 5GHz channel list at 5120MHz. + * + * Unfortunately (sigh) the HT40 channel creation + * logic will create HT40U channels at 5120, 5160, 5200. + * This means that 36 (5180) isn't considered as a + * HT40 channel, and everything goes messed up from there. + */ + if ((cm->flags & IEEE80211_CHAN_5GHZ) && + (cm->flags & IEEE80211_CHAN_HT40U)) { + if (bfreq_lo < 5180) + bfreq_lo = 5180; + } + + /* + * Same with HT40D - need to start at 5200 or the low + * channels are all wrong again. + */ + if ((cm->flags & IEEE80211_CHAN_5GHZ) && + (cm->flags & IEEE80211_CHAN_HT40D)) { + if (bfreq_lo < 5200) + bfreq_lo = 5200; + } + if (fband->channelSep >= channelSep) step = fband->channelSep; else step = roundup(channelSep, fband->channelSep); + HALDEBUG(ah, HAL_DEBUG_REGDOMAIN, + "%s: freq_lo=%d, freq_hi=%d, low_adj=%d, hi_adj=%d, " + "bandlo=%d, bandhi=%d, bfreqlo=%d, bfreqhi=%d, step=%d, " + "flags=0x%08x\n", + __func__, + (int) freq_lo, + (int) freq_hi, + (int) low_adj, + (int) hi_adj, + (int) fband->lowChannel, + (int) fband->highChannel, + (int) bfreq_lo, + (int) bfreq_hi, + step, + (int) cm->flags); + error = add_chanlist_band(ah, chans, maxchans, nchans, bfreq_lo, bfreq_hi, step, cm->flags, fband, rd); if (error != 0) {