aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2011-01-16 23:37:28 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-01-21 15:34:17 -0500
commit59eb21a6504731fc16db4cf9463065dd61093e08 (patch)
tree4a3732d451c85a5949c6d6294db51a56530677d8
parent60f2d1d506195803fa6e1dcf3972637b740fdd60 (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>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c3
-rw-r--r--drivers/net/wireless/iwmc3200wifi/cfg80211.c3
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rx.c7
-rw-r--r--drivers/net/wireless/libertas/cfg.c6
-rw-r--r--drivers/net/wireless/mwl8k.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c5
-rw-r--r--drivers/net/wireless/wl1251/rx.c3
-rw-r--r--drivers/net/wireless/wl12xx/rx.c2
-rw-r--r--include/net/cfg80211.h3
-rw-r--r--net/mac80211/ibss.c3
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mlme.c8
-rw-r--r--net/mac80211/scan.c3
-rw-r--r--net/wireless/reg.c6
-rw-r--r--net/wireless/util.c36
-rw-r--r--net/wireless/wext-compat.c5
18 files changed, 71 insertions, 40 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index a9b852be4509..1d9dcd7e3b82 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -594,10 +594,11 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv,
594 594
595 rx_status.flag = 0; 595 rx_status.flag = 0;
596 rx_status.mactime = le64_to_cpu(rx_end->timestamp); 596 rx_status.mactime = le64_to_cpu(rx_end->timestamp);
597 rx_status.freq =
598 ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel));
599 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 597 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
600 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 598 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
599 rx_status.freq =
600 ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel),
601 rx_status.band);
601 602
602 rx_status.rate_idx = iwl3945_hwrate_to_plcp_idx(rx_hdr->rate); 603 rx_status.rate_idx = iwl3945_hwrate_to_plcp_idx(rx_hdr->rate);
603 if (rx_status.band == IEEE80211_BAND_5GHZ) 604 if (rx_status.band == IEEE80211_BAND_5GHZ)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 29dcda0bde65..c7d03874b380 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -1162,10 +1162,11 @@ void iwlagn_rx_reply_rx(struct iwl_priv *priv,
1162 1162
1163 /* rx_status carries information about the packet to mac80211 */ 1163 /* rx_status carries information about the packet to mac80211 */
1164 rx_status.mactime = le64_to_cpu(phy_res->timestamp); 1164 rx_status.mactime = le64_to_cpu(phy_res->timestamp);
1165 rx_status.freq =
1166 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel));
1167 rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 1165 rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
1168 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 1166 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
1167 rx_status.freq =
1168 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),
1169 rx_status.band);
1169 rx_status.rate_idx = 1170 rx_status.rate_idx =
1170 iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); 1171 iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);
1171 rx_status.flag = 0; 1172 rx_status.flag = 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index efbde1f1a8bf..a8d4a936a2e7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -227,7 +227,8 @@ int iwlcore_init_geos(struct iwl_priv *priv)
227 geo_ch = &sband->channels[sband->n_channels++]; 227 geo_ch = &sband->channels[sband->n_channels++];
228 228
229 geo_ch->center_freq = 229 geo_ch->center_freq =
230 ieee80211_channel_to_frequency(ch->channel); 230 ieee80211_channel_to_frequency(ch->channel,
231 sband->band);
231 geo_ch->max_power = ch->max_power_avg; 232 geo_ch->max_power = ch->max_power_avg;
232 geo_ch->max_antenna_gain = 0xff; 233 geo_ch->max_antenna_gain = 0xff;
233 geo_ch->hw_value = ch->channel; 234 geo_ch->hw_value = ch->channel;
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
index 5a4982271e96..ed57e4402800 100644
--- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c
+++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
@@ -287,7 +287,8 @@ int iwm_cfg80211_inform_bss(struct iwm_priv *iwm)
287 return -EINVAL; 287 return -EINVAL;
288 } 288 }
289 289
290 freq = ieee80211_channel_to_frequency(umac_bss->channel); 290 freq = ieee80211_channel_to_frequency(umac_bss->channel,
291 band->band);
291 channel = ieee80211_get_channel(wiphy, freq); 292 channel = ieee80211_get_channel(wiphy, freq);
292 signal = umac_bss->rssi * 100; 293 signal = umac_bss->rssi * 100;
293 294
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
index a944893ae3ca..9a57cf6a488f 100644
--- a/drivers/net/wireless/iwmc3200wifi/rx.c
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -543,7 +543,10 @@ static int iwm_mlme_assoc_complete(struct iwm_priv *iwm, u8 *buf,
543 switch (le32_to_cpu(complete->status)) { 543 switch (le32_to_cpu(complete->status)) {
544 case UMAC_ASSOC_COMPLETE_SUCCESS: 544 case UMAC_ASSOC_COMPLETE_SUCCESS:
545 chan = ieee80211_get_channel(wiphy, 545 chan = ieee80211_get_channel(wiphy,
546 ieee80211_channel_to_frequency(complete->channel)); 546 ieee80211_channel_to_frequency(complete->channel,
547 complete->band == UMAC_BAND_2GHZ ?
548 IEEE80211_BAND_2GHZ :
549 IEEE80211_BAND_5GHZ));
547 if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) { 550 if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) {
548 /* Associated to a unallowed channel, disassociate. */ 551 /* Associated to a unallowed channel, disassociate. */
549 __iwm_invalidate_mlme_profile(iwm); 552 __iwm_invalidate_mlme_profile(iwm);
@@ -841,7 +844,7 @@ static int iwm_mlme_update_bss_table(struct iwm_priv *iwm, u8 *buf,
841 goto err; 844 goto err;
842 } 845 }
843 846
844 freq = ieee80211_channel_to_frequency(umac_bss->channel); 847 freq = ieee80211_channel_to_frequency(umac_bss->channel, band->band);
845 channel = ieee80211_get_channel(wiphy, freq); 848 channel = ieee80211_get_channel(wiphy, freq);
846 signal = umac_bss->rssi * 100; 849 signal = umac_bss->rssi * 100;
847 850
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 698a1f7694ed..30ef0351bfc4 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -607,7 +607,8 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy,
607 /* No channel, no luck */ 607 /* No channel, no luck */
608 if (chan_no != -1) { 608 if (chan_no != -1) {
609 struct wiphy *wiphy = priv->wdev->wiphy; 609 struct wiphy *wiphy = priv->wdev->wiphy;
610 int freq = ieee80211_channel_to_frequency(chan_no); 610 int freq = ieee80211_channel_to_frequency(chan_no,
611 IEEE80211_BAND_2GHZ);
611 struct ieee80211_channel *channel = 612 struct ieee80211_channel *channel =
612 ieee80211_get_channel(wiphy, freq); 613 ieee80211_get_channel(wiphy, freq);
613 614
@@ -1597,7 +1598,8 @@ static int lbs_get_survey(struct wiphy *wiphy, struct net_device *dev,
1597 lbs_deb_enter(LBS_DEB_CFG80211); 1598 lbs_deb_enter(LBS_DEB_CFG80211);
1598 1599
1599 survey->channel = ieee80211_get_channel(wiphy, 1600 survey->channel = ieee80211_get_channel(wiphy,
1600 ieee80211_channel_to_frequency(priv->channel)); 1601 ieee80211_channel_to_frequency(priv->channel,
1602 IEEE80211_BAND_2GHZ));
1601 1603
1602 ret = lbs_get_rssi(priv, &signal, &noise); 1604 ret = lbs_get_rssi(priv, &signal, &noise);
1603 if (ret == 0) { 1605 if (ret == 0) {
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 106b427d0064..af4f2c64f242 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -906,7 +906,8 @@ mwl8k_rxd_8366_ap_process(void *_rxd, struct ieee80211_rx_status *status,
906 } else { 906 } else {
907 status->band = IEEE80211_BAND_2GHZ; 907 status->band = IEEE80211_BAND_2GHZ;
908 } 908 }
909 status->freq = ieee80211_channel_to_frequency(rxd->channel); 909 status->freq = ieee80211_channel_to_frequency(rxd->channel,
910 status->band);
910 911
911 *qos = rxd->qos_control; 912 *qos = rxd->qos_control;
912 913
@@ -1013,7 +1014,8 @@ mwl8k_rxd_sta_process(void *_rxd, struct ieee80211_rx_status *status,
1013 } else { 1014 } else {
1014 status->band = IEEE80211_BAND_2GHZ; 1015 status->band = IEEE80211_BAND_2GHZ;
1015 } 1016 }
1016 status->freq = ieee80211_channel_to_frequency(rxd->channel); 1017 status->freq = ieee80211_channel_to_frequency(rxd->channel,
1018 status->band);
1017 1019
1018 *qos = rxd->qos_control; 1020 *qos = rxd->qos_control;
1019 if ((rxd->rx_ctrl & MWL8K_STA_RX_CTRL_DECRYPT_ERROR) && 1021 if ((rxd->rx_ctrl & MWL8K_STA_RX_CTRL_DECRYPT_ERROR) &&
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 9597a03242cc..31b7db05abd9 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -649,7 +649,10 @@ static void rt2x00lib_channel(struct ieee80211_channel *entry,
649 const int channel, const int tx_power, 649 const int channel, const int tx_power,
650 const int value) 650 const int value)
651{ 651{
652 entry->center_freq = ieee80211_channel_to_frequency(channel); 652 /* XXX: this assumption about the band is wrong for 802.11j */
653 entry->band = channel <= 14 ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
654 entry->center_freq = ieee80211_channel_to_frequency(channel,
655 entry->band);
653 entry->hw_value = value; 656 entry->hw_value = value;
654 entry->max_power = tx_power; 657 entry->max_power = tx_power;
655 entry->max_antenna_gain = 0xff; 658 entry->max_antenna_gain = 0xff;
diff --git a/drivers/net/wireless/wl1251/rx.c b/drivers/net/wireless/wl1251/rx.c
index efa53607d5c9..86eef456d7b2 100644
--- a/drivers/net/wireless/wl1251/rx.c
+++ b/drivers/net/wireless/wl1251/rx.c
@@ -78,7 +78,8 @@ static void wl1251_rx_status(struct wl1251 *wl,
78 */ 78 */
79 wl->noise = desc->rssi - desc->snr / 2; 79 wl->noise = desc->rssi - desc->snr / 2;
80 80
81 status->freq = ieee80211_channel_to_frequency(desc->channel); 81 status->freq = ieee80211_channel_to_frequency(desc->channel,
82 status->band);
82 83
83 status->flag |= RX_FLAG_TSFT; 84 status->flag |= RX_FLAG_TSFT;
84 85
diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c
index 682304c30b81..ec8d843d41cf 100644
--- a/drivers/net/wireless/wl12xx/rx.c
+++ b/drivers/net/wireless/wl12xx/rx.c
@@ -76,7 +76,7 @@ static void wl1271_rx_status(struct wl1271 *wl,
76 */ 76 */
77 wl->noise = desc->rssi - (desc->snr >> 1); 77 wl->noise = desc->rssi - (desc->snr >> 1);
78 78
79 status->freq = ieee80211_channel_to_frequency(desc->channel); 79 status->freq = ieee80211_channel_to_frequency(desc->channel, desc_band);
80 80
81 if (desc->flags & WL1271_RX_DESC_ENCRYPT_MASK) { 81 if (desc->flags & WL1271_RX_DESC_ENCRYPT_MASK) {
82 status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED; 82 status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1322695beb52..679a0494b5f2 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1790,8 +1790,9 @@ static inline void *wdev_priv(struct wireless_dev *wdev)
1790/** 1790/**
1791 * ieee80211_channel_to_frequency - convert channel number to frequency 1791 * ieee80211_channel_to_frequency - convert channel number to frequency
1792 * @chan: channel number 1792 * @chan: channel number
1793 * @band: band, necessary due to channel number overlap
1793 */ 1794 */
1794extern int ieee80211_channel_to_frequency(int chan); 1795extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band);
1795 1796
1796/** 1797/**
1797 * ieee80211_frequency_to_channel - convert frequency to channel number 1798 * ieee80211_frequency_to_channel - convert frequency to channel number
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 53c7077ffd4f..775fb63471c4 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -270,7 +270,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
270 enum ieee80211_band band = rx_status->band; 270 enum ieee80211_band band = rx_status->band;
271 271
272 if (elems->ds_params && elems->ds_params_len == 1) 272 if (elems->ds_params && elems->ds_params_len == 1)
273 freq = ieee80211_channel_to_frequency(elems->ds_params[0]); 273 freq = ieee80211_channel_to_frequency(elems->ds_params[0],
274 band);
274 else 275 else
275 freq = rx_status->freq; 276 freq = rx_status->freq;
276 277
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 2563fd1ea998..2a57cc02c618 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
574 &elems); 574 &elems);
575 575
576 if (elems.ds_params && elems.ds_params_len == 1) 576 if (elems.ds_params && elems.ds_params_len == 1)
577 freq = ieee80211_channel_to_frequency(elems.ds_params[0]); 577 freq = ieee80211_channel_to_frequency(elems.ds_params[0], band);
578 else 578 else
579 freq = rx_status->freq; 579 freq = rx_status->freq;
580 580
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index eecbb1fcd2ab..32210695b8b6 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -176,7 +176,7 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
176 176
177 /* check that channel matches the right operating channel */ 177 /* check that channel matches the right operating channel */
178 if (local->hw.conf.channel->center_freq != 178 if (local->hw.conf.channel->center_freq !=
179 ieee80211_channel_to_frequency(hti->control_chan)) 179 ieee80211_channel_to_frequency(hti->control_chan, sband->band))
180 enable_ht = false; 180 enable_ht = false;
181 181
182 if (enable_ht) { 182 if (enable_ht) {
@@ -429,7 +429,8 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
429 container_of((void *)bss, struct cfg80211_bss, priv); 429 container_of((void *)bss, struct cfg80211_bss, priv);
430 struct ieee80211_channel *new_ch; 430 struct ieee80211_channel *new_ch;
431 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 431 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
432 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); 432 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
433 cbss->channel->band);
433 434
434 ASSERT_MGD_MTX(ifmgd); 435 ASSERT_MGD_MTX(ifmgd);
435 436
@@ -1519,7 +1520,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1519 } 1520 }
1520 1521
1521 if (elems->ds_params && elems->ds_params_len == 1) 1522 if (elems->ds_params && elems->ds_params_len == 1)
1522 freq = ieee80211_channel_to_frequency(elems->ds_params[0]); 1523 freq = ieee80211_channel_to_frequency(elems->ds_params[0],
1524 rx_status->band);
1523 else 1525 else
1524 freq = rx_status->freq; 1526 freq = rx_status->freq;
1525 1527
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index fb274db77e3c..1ef73be76b25 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -196,7 +196,8 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
196 ieee802_11_parse_elems(elements, skb->len - baselen, &elems); 196 ieee802_11_parse_elems(elements, skb->len - baselen, &elems);
197 197
198 if (elems.ds_params && elems.ds_params_len == 1) 198 if (elems.ds_params && elems.ds_params_len == 1)
199 freq = ieee80211_channel_to_frequency(elems.ds_params[0]); 199 freq = ieee80211_channel_to_frequency(elems.ds_params[0],
200 rx_status->band);
200 else 201 else
201 freq = rx_status->freq; 202 freq = rx_status->freq;
202 203
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
1802static bool freq_is_chan_12_13_14(u16 freq) 1802static 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}
30EXPORT_SYMBOL(ieee80211_get_response_rate); 30EXPORT_SYMBOL(ieee80211_get_response_rate);
31 31
32int ieee80211_channel_to_frequency(int chan) 32int 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}
43EXPORT_SYMBOL(ieee80211_channel_to_frequency); 50EXPORT_SYMBOL(ieee80211_channel_to_frequency);
44 51
45int ieee80211_frequency_to_channel(int freq) 52int 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}
56EXPORT_SYMBOL(ieee80211_frequency_to_channel); 64EXPORT_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++)