diff options
author | Bruno Randolf <br1@einfach.org> | 2011-01-16 23:37:28 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-01-21 15:34:17 -0500 |
commit | 59eb21a6504731fc16db4cf9463065dd61093e08 (patch) | |
tree | 4a3732d451c85a5949c6d6294db51a56530677d8 /net/wireless | |
parent | 60f2d1d506195803fa6e1dcf3972637b740fdd60 (diff) |
cfg80211: Extend channel to frequency mapping for 802.11j
Extend channel to frequency mapping for 802.11j Japan 4.9GHz band, according to
IEEE802.11 section 17.3.8.3.2 and Annex J. Because there are now overlapping
channel numbers in the 2GHz and 5GHz band we can't map from channel to
frequency without knowing the band. This is no problem as in most contexts we
know the band. In places where we don't know the band (and WEXT compatibility)
we assume the 2GHz band for channels below 14.
This patch does not implement all channel to frequency mappings defined in
802.11, it's just an extension for 802.11j 20MHz channels. 5MHz and 10MHz
channels as well as 802.11y channels have been omitted.
The following drivers have been updated to reflect the API changes:
iwl-3945, iwl-agn, iwmc3200wifi, libertas, mwl8k, rt2x00, wl1251, wl12xx.
The drivers have been compile-tested only.
Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: Brian Prodoehl <bprodoehl@gmail.com>
Acked-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/reg.c | 6 | ||||
-rw-r--r-- | net/wireless/util.c | 36 | ||||
-rw-r--r-- | net/wireless/wext-compat.c | 5 |
3 files changed, 29 insertions, 18 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 37693b6ef23a..c565689f0b9f 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -1801,9 +1801,9 @@ void regulatory_hint_disconnect(void) | |||
1801 | 1801 | ||
1802 | static bool freq_is_chan_12_13_14(u16 freq) | 1802 | static bool freq_is_chan_12_13_14(u16 freq) |
1803 | { | 1803 | { |
1804 | if (freq == ieee80211_channel_to_frequency(12) || | 1804 | if (freq == ieee80211_channel_to_frequency(12, IEEE80211_BAND_2GHZ) || |
1805 | freq == ieee80211_channel_to_frequency(13) || | 1805 | freq == ieee80211_channel_to_frequency(13, IEEE80211_BAND_2GHZ) || |
1806 | freq == ieee80211_channel_to_frequency(14)) | 1806 | freq == ieee80211_channel_to_frequency(14, IEEE80211_BAND_2GHZ)) |
1807 | return true; | 1807 | return true; |
1808 | return false; | 1808 | return false; |
1809 | } | 1809 | } |
diff --git a/net/wireless/util.c b/net/wireless/util.c index 7620ae2fcf18..4ed065d8bb51 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -29,29 +29,37 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband, | |||
29 | } | 29 | } |
30 | EXPORT_SYMBOL(ieee80211_get_response_rate); | 30 | EXPORT_SYMBOL(ieee80211_get_response_rate); |
31 | 31 | ||
32 | int ieee80211_channel_to_frequency(int chan) | 32 | int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band) |
33 | { | 33 | { |
34 | if (chan < 14) | 34 | /* see 802.11 17.3.8.3.2 and Annex J |
35 | return 2407 + chan * 5; | 35 | * there are overlapping channel numbers in 5GHz and 2GHz bands */ |
36 | 36 | if (band == IEEE80211_BAND_5GHZ) { | |
37 | if (chan == 14) | 37 | if (chan >= 182 && chan <= 196) |
38 | return 2484; | 38 | return 4000 + chan * 5; |
39 | 39 | else | |
40 | /* FIXME: 802.11j 17.3.8.3.2 */ | 40 | return 5000 + chan * 5; |
41 | return (chan + 1000) * 5; | 41 | } else { /* IEEE80211_BAND_2GHZ */ |
42 | if (chan == 14) | ||
43 | return 2484; | ||
44 | else if (chan < 14) | ||
45 | return 2407 + chan * 5; | ||
46 | else | ||
47 | return 0; /* not supported */ | ||
48 | } | ||
42 | } | 49 | } |
43 | EXPORT_SYMBOL(ieee80211_channel_to_frequency); | 50 | EXPORT_SYMBOL(ieee80211_channel_to_frequency); |
44 | 51 | ||
45 | int ieee80211_frequency_to_channel(int freq) | 52 | int ieee80211_frequency_to_channel(int freq) |
46 | { | 53 | { |
54 | /* see 802.11 17.3.8.3.2 and Annex J */ | ||
47 | if (freq == 2484) | 55 | if (freq == 2484) |
48 | return 14; | 56 | return 14; |
49 | 57 | else if (freq < 2484) | |
50 | if (freq < 2484) | ||
51 | return (freq - 2407) / 5; | 58 | return (freq - 2407) / 5; |
52 | 59 | else if (freq >= 4910 && freq <= 4980) | |
53 | /* FIXME: 802.11j 17.3.8.3.2 */ | 60 | return (freq - 4000) / 5; |
54 | return freq/5 - 1000; | 61 | else |
62 | return (freq - 5000) / 5; | ||
55 | } | 63 | } |
56 | EXPORT_SYMBOL(ieee80211_frequency_to_channel); | 64 | EXPORT_SYMBOL(ieee80211_frequency_to_channel); |
57 | 65 | ||
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 3e5dbd4e4cd5..7f1f4ec49041 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -267,9 +267,12 @@ int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq) | |||
267 | * -EINVAL for impossible things. | 267 | * -EINVAL for impossible things. |
268 | */ | 268 | */ |
269 | if (freq->e == 0) { | 269 | if (freq->e == 0) { |
270 | enum ieee80211_band band = IEEE80211_BAND_2GHZ; | ||
270 | if (freq->m < 0) | 271 | if (freq->m < 0) |
271 | return 0; | 272 | return 0; |
272 | return ieee80211_channel_to_frequency(freq->m); | 273 | if (freq->m > 14) |
274 | band = IEEE80211_BAND_5GHZ; | ||
275 | return ieee80211_channel_to_frequency(freq->m, band); | ||
273 | } else { | 276 | } else { |
274 | int i, div = 1000000; | 277 | int i, div = 1000000; |
275 | for (i = 0; i < freq->e; i++) | 278 | for (i = 0; i < freq->e; i++) |