Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net80211/ieee80211.c
Show First 20 Lines • Show All 1,157 Lines • ▼ Show 20 Lines | struct vht_chan_range vht80_chan_ranges[] = { | ||||
{ 5250, 5330 }, | { 5250, 5330 }, | ||||
{ 5490, 5570 }, | { 5490, 5570 }, | ||||
{ 5570, 5650 }, | { 5570, 5650 }, | ||||
{ 5650, 5730 }, | { 5650, 5730 }, | ||||
{ 5735, 5815 }, | { 5735, 5815 }, | ||||
{ 0, 0 } | { 0, 0 } | ||||
}; | }; | ||||
struct vht_chan_range vht160_chan_ranges[] = { | |||||
{ 5170, 5330 }, | |||||
{ 5490, 5650 }, | |||||
{ 0, 0 } | |||||
}; | |||||
static int | static int | ||||
set_vht_extchan(struct ieee80211_channel *c) | set_vht_extchan(struct ieee80211_channel *c) | ||||
{ | { | ||||
int i; | int i; | ||||
if (! IEEE80211_IS_CHAN_VHT(c)) | if (! IEEE80211_IS_CHAN_VHT(c)) | ||||
return (0); | return (0); | ||||
if (IEEE80211_IS_CHAN_VHT80P80(c)) { | if (IEEE80211_IS_CHAN_VHT80P80(c)) { | ||||
printf("%s: TODO VHT80+80 channel (ieee=%d, flags=0x%08x)\n", | printf("%s: TODO VHT80+80 channel (ieee=%d, flags=0x%08x)\n", | ||||
__func__, c->ic_ieee, c->ic_flags); | __func__, c->ic_ieee, c->ic_flags); | ||||
} | } | ||||
if (IEEE80211_IS_CHAN_VHT160(c)) { | if (IEEE80211_IS_CHAN_VHT160(c)) { | ||||
printf("%s: TODO VHT160 channel (ieee=%d, flags=0x%08x)\n", | for (i = 0; vht160_chan_ranges[i].freq_start != 0; i++) { | ||||
__func__, c->ic_ieee, c->ic_flags); | if (c->ic_freq >= vht160_chan_ranges[i].freq_start && | ||||
c->ic_freq < vht160_chan_ranges[i].freq_end) { | |||||
int midpoint; | |||||
midpoint = vht160_chan_ranges[i].freq_start + 80; | |||||
c->ic_vht_ch_freq1 = | |||||
ieee80211_mhz2ieee(midpoint, c->ic_flags); | |||||
c->ic_vht_ch_freq2 = 0; | |||||
#if 0 | |||||
printf("%s: %d, freq=%d, midpoint=%d, freq1=%d, freq2=%d\n", | |||||
__func__, c->ic_ieee, c->ic_freq, midpoint, | |||||
c->ic_vht_ch_freq1, c->ic_vht_ch_freq2); | |||||
#endif | |||||
return (1); | |||||
} | } | ||||
} | |||||
return (0); | |||||
} | |||||
if (IEEE80211_IS_CHAN_VHT80(c)) { | if (IEEE80211_IS_CHAN_VHT80(c)) { | ||||
for (i = 0; vht80_chan_ranges[i].freq_start != 0; i++) { | for (i = 0; vht80_chan_ranges[i].freq_start != 0; i++) { | ||||
if (c->ic_freq >= vht80_chan_ranges[i].freq_start && | if (c->ic_freq >= vht80_chan_ranges[i].freq_start && | ||||
c->ic_freq < vht80_chan_ranges[i].freq_end) { | c->ic_freq < vht80_chan_ranges[i].freq_end) { | ||||
int midpoint; | int midpoint; | ||||
midpoint = vht80_chan_ranges[i].freq_start + 40; | midpoint = vht80_chan_ranges[i].freq_start + 40; | ||||
Show All 29 Lines | #endif | ||||
printf("%s: unknown VHT channel type (ieee=%d, flags=0x%08x)\n", | printf("%s: unknown VHT channel type (ieee=%d, flags=0x%08x)\n", | ||||
__func__, c->ic_ieee, c->ic_flags); | __func__, c->ic_ieee, c->ic_flags); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Return whether the current channel could possibly be a part of | * Return whether the current channel could possibly be a part of | ||||
* a VHT80 channel. | * a VHT80/VHT160 channel. | ||||
* | * | ||||
* This doesn't check that the whole range is in the allowed list | * This doesn't check that the whole range is in the allowed list | ||||
* according to regulatory. | * according to regulatory. | ||||
*/ | */ | ||||
static bool | |||||
is_vht160_valid_freq(uint16_t freq) | |||||
{ | |||||
int i; | |||||
for (i = 0; vht160_chan_ranges[i].freq_start != 0; i++) { | |||||
if (freq >= vht160_chan_ranges[i].freq_start && | |||||
freq < vht160_chan_ranges[i].freq_end) | |||||
return (true); | |||||
} | |||||
return (false); | |||||
} | |||||
static int | static int | ||||
is_vht80_valid_freq(uint16_t freq) | is_vht80_valid_freq(uint16_t freq) | ||||
{ | { | ||||
int i; | int i; | ||||
for (i = 0; vht80_chan_ranges[i].freq_start != 0; i++) { | for (i = 0; vht80_chan_ranges[i].freq_start != 0; i++) { | ||||
if (freq >= vht80_chan_ranges[i].freq_start && | if (freq >= vht80_chan_ranges[i].freq_start && | ||||
freq < vht80_chan_ranges[i].freq_end) | freq < vht80_chan_ranges[i].freq_end) | ||||
return (1); | return (1); | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | getflags(const uint8_t bands[], uint32_t flags[], int cbw_flags) | ||||
} else | } else | ||||
getflags_2ghz(bands, flags, cbw_flags); | getflags_2ghz(bands, flags, cbw_flags); | ||||
} | } | ||||
/* | /* | ||||
* Add one 20 MHz channel into specified channel list. | * Add one 20 MHz channel into specified channel list. | ||||
* You MUST NOT mix bands when calling this. It will not add 5ghz | * You MUST NOT mix bands when calling this. It will not add 5ghz | ||||
* channels if you have any B/G/N band bit set. | * channels if you have any B/G/N band bit set. | ||||
* This also does not support 40/80/160/80+80. | * The _cbw() variant does also support HT40/VHT80/160/80+80. | ||||
*/ | */ | ||||
/* XXX VHT */ | |||||
int | int | ||||
ieee80211_add_channel(struct ieee80211_channel chans[], int maxchans, | ieee80211_add_channel_cbw(struct ieee80211_channel chans[], int maxchans, | ||||
int *nchans, uint8_t ieee, uint16_t freq, int8_t maxregpower, | int *nchans, uint8_t ieee, uint16_t freq, int8_t maxregpower, | ||||
uint32_t chan_flags, const uint8_t bands[]) | uint32_t chan_flags, const uint8_t bands[], int cbw_flags) | ||||
{ | { | ||||
uint32_t flags[IEEE80211_MODE_MAX]; | uint32_t flags[IEEE80211_MODE_MAX]; | ||||
int i, error; | int i, error; | ||||
getflags(bands, flags, 0); | getflags(bands, flags, cbw_flags); | ||||
KASSERT(flags[0] != 0, ("%s: no correct mode provided\n", __func__)); | KASSERT(flags[0] != 0, ("%s: no correct mode provided\n", __func__)); | ||||
error = addchan(chans, maxchans, nchans, ieee, freq, maxregpower, | error = addchan(chans, maxchans, nchans, ieee, freq, maxregpower, | ||||
flags[0] | chan_flags); | flags[0] | chan_flags); | ||||
for (i = 1; flags[i] != 0 && error == 0; i++) { | for (i = 1; flags[i] != 0 && error == 0; i++) { | ||||
error = copychan_prev(chans, maxchans, nchans, | error = copychan_prev(chans, maxchans, nchans, | ||||
flags[i] | chan_flags); | flags[i] | chan_flags); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
int | |||||
ieee80211_add_channel(struct ieee80211_channel chans[], int maxchans, | |||||
int *nchans, uint8_t ieee, uint16_t freq, int8_t maxregpower, | |||||
uint32_t chan_flags, const uint8_t bands[]) | |||||
{ | |||||
return (ieee80211_add_channel_cbw(chans, maxchans, nchans, ieee, freq, | |||||
maxregpower, chan_flags, bands, 0)); | |||||
} | |||||
static struct ieee80211_channel * | static struct ieee80211_channel * | ||||
findchannel(struct ieee80211_channel chans[], int nchans, uint16_t freq, | findchannel(struct ieee80211_channel chans[], int nchans, uint16_t freq, | ||||
uint32_t flags) | uint32_t flags) | ||||
{ | { | ||||
struct ieee80211_channel *c; | struct ieee80211_channel *c; | ||||
int i; | int i; | ||||
flags &= IEEE80211_CHAN_ALLTURBO; | flags &= IEEE80211_CHAN_ALLTURBO; | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | for (j = 0; flags[j] != 0; j++) { | ||||
* we need to be careful that we actually allow that. | * we need to be careful that we actually allow that. | ||||
* + VHT80, VHT160 will coexist with HT40/VHT40, so | * + VHT80, VHT160 will coexist with HT40/VHT40, so | ||||
* make sure it's not skipped because of the overlap | * make sure it's not skipped because of the overlap | ||||
* check used for (V)HT40. | * check used for (V)HT40. | ||||
*/ | */ | ||||
is_vht = !! (flags[j] & IEEE80211_CHAN_VHT); | is_vht = !! (flags[j] & IEEE80211_CHAN_VHT); | ||||
/* XXX TODO FIXME VHT80P80. */ | /* XXX TODO FIXME VHT80P80. */ | ||||
/* XXX TODO FIXME VHT160. */ | |||||
/* Test for VHT160 analogue to the VHT80 below. */ | |||||
if (is_vht && flags[j] & IEEE80211_CHAN_VHT160) | |||||
if (! is_vht160_valid_freq(freq)) | |||||
continue; | |||||
/* | /* | ||||
* Test for VHT80. | * Test for VHT80. | ||||
* XXX This is all very broken right now. | * XXX This is all very broken right now. | ||||
* What we /should/ do is: | * What we /should/ do is: | ||||
* | * | ||||
* + check that the frequency is in the list of | * + check that the frequency is in the list of | ||||
* allowed VHT80 ranges; and | * allowed VHT80 ranges; and | ||||
▲ Show 20 Lines • Show All 1,002 Lines • Show Last 20 Lines |