svn commit: r311361 - head/sys/dev/ath/ath_hal
Adrian Chadd
adrian at FreeBSD.org
Thu Jan 5 04:56:06 UTC 2017
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) {
More information about the svn-src-all
mailing list