aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-12-04 09:07:34 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-03 07:01:28 -0500
commitfe7ef5e9ba0c60bab01390493a4c6790f7b093af (patch)
tree899add2d99d37b272a89c5c84eb4e1d9ba22781b
parent6913b49a5071064f49f7a74b432286fa735f7612 (diff)
regulatory: remove handling of channel bandwidth
The channel bandwidth handling isn't really quite right, it assumes that a 40 MHz channel is really two 20 MHz channels, which isn't strictly true. This is the way the regulatory database handling is defined right now though so remove the logic to handle other channel widths. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--drivers/net/wireless/ath/regd.c7
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/channel.c2
-rw-r--r--drivers/net/wireless/rtlwifi/regd.c9
-rw-r--r--include/net/cfg80211.h8
-rw-r--r--net/wireless/reg.c44
5 files changed, 21 insertions, 49 deletions
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index d81698015bf7..8ae58c404c67 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -195,7 +195,6 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
195 const struct ieee80211_reg_rule *reg_rule; 195 const struct ieee80211_reg_rule *reg_rule;
196 struct ieee80211_channel *ch; 196 struct ieee80211_channel *ch;
197 unsigned int i; 197 unsigned int i;
198 u32 bandwidth = 0;
199 int r; 198 int r;
200 199
201 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 200 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
@@ -216,7 +215,6 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
216 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { 215 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
217 r = freq_reg_info(wiphy, 216 r = freq_reg_info(wiphy,
218 ch->center_freq, 217 ch->center_freq,
219 bandwidth,
220 &reg_rule); 218 &reg_rule);
221 if (r) 219 if (r)
222 continue; 220 continue;
@@ -254,7 +252,6 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
254 struct ieee80211_supported_band *sband; 252 struct ieee80211_supported_band *sband;
255 struct ieee80211_channel *ch; 253 struct ieee80211_channel *ch;
256 const struct ieee80211_reg_rule *reg_rule; 254 const struct ieee80211_reg_rule *reg_rule;
257 u32 bandwidth = 0;
258 int r; 255 int r;
259 256
260 sband = wiphy->bands[IEEE80211_BAND_2GHZ]; 257 sband = wiphy->bands[IEEE80211_BAND_2GHZ];
@@ -283,7 +280,7 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
283 */ 280 */
284 281
285 ch = &sband->channels[11]; /* CH 12 */ 282 ch = &sband->channels[11]; /* CH 12 */
286 r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); 283 r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
287 if (!r) { 284 if (!r) {
288 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) 285 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
289 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) 286 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
@@ -291,7 +288,7 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
291 } 288 }
292 289
293 ch = &sband->channels[12]; /* CH 13 */ 290 ch = &sband->channels[12]; /* CH 13 */
294 r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); 291 r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
295 if (!r) { 292 if (!r) {
296 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) 293 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
297 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) 294 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
index a90b72202ec5..30272519d795 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
@@ -686,7 +686,7 @@ brcms_reg_apply_beaconing_flags(struct wiphy *wiphy,
686 686
687 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { 687 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
688 ret = freq_reg_info(wiphy, ch->center_freq, 688 ret = freq_reg_info(wiphy, ch->center_freq,
689 0, &rule); 689 &rule);
690 if (ret) 690 if (ret)
691 continue; 691 continue;
692 692
diff --git a/drivers/net/wireless/rtlwifi/regd.c b/drivers/net/wireless/rtlwifi/regd.c
index c1608cddc529..be55dc9167f0 100644
--- a/drivers/net/wireless/rtlwifi/regd.c
+++ b/drivers/net/wireless/rtlwifi/regd.c
@@ -158,7 +158,6 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
158 const struct ieee80211_reg_rule *reg_rule; 158 const struct ieee80211_reg_rule *reg_rule;
159 struct ieee80211_channel *ch; 159 struct ieee80211_channel *ch;
160 unsigned int i; 160 unsigned int i;
161 u32 bandwidth = 0;
162 int r; 161 int r;
163 162
164 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 163 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
@@ -174,8 +173,7 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
174 (ch->flags & IEEE80211_CHAN_RADAR)) 173 (ch->flags & IEEE80211_CHAN_RADAR))
175 continue; 174 continue;
176 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { 175 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
177 r = freq_reg_info(wiphy, ch->center_freq, 176 r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
178 bandwidth, &reg_rule);
179 if (r) 177 if (r)
180 continue; 178 continue;
181 179
@@ -211,7 +209,6 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
211 struct ieee80211_supported_band *sband; 209 struct ieee80211_supported_band *sband;
212 struct ieee80211_channel *ch; 210 struct ieee80211_channel *ch;
213 const struct ieee80211_reg_rule *reg_rule; 211 const struct ieee80211_reg_rule *reg_rule;
214 u32 bandwidth = 0;
215 int r; 212 int r;
216 213
217 if (!wiphy->bands[IEEE80211_BAND_2GHZ]) 214 if (!wiphy->bands[IEEE80211_BAND_2GHZ])
@@ -240,7 +237,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
240 */ 237 */
241 238
242 ch = &sband->channels[11]; /* CH 12 */ 239 ch = &sband->channels[11]; /* CH 12 */
243 r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); 240 r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
244 if (!r) { 241 if (!r) {
245 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) 242 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
246 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) 243 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
@@ -248,7 +245,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
248 } 245 }
249 246
250 ch = &sband->channels[12]; /* CH 13 */ 247 ch = &sband->channels[12]; /* CH 13 */
251 r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); 248 r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
252 if (!r) { 249 if (!r) {
253 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) 250 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
254 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) 251 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8e6a6b73b9c9..c222e5fbf53a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2938,10 +2938,6 @@ extern void wiphy_apply_custom_regulatory(
2938 * freq_reg_info - get regulatory information for the given frequency 2938 * freq_reg_info - get regulatory information for the given frequency
2939 * @wiphy: the wiphy for which we want to process this rule for 2939 * @wiphy: the wiphy for which we want to process this rule for
2940 * @center_freq: Frequency in KHz for which we want regulatory information for 2940 * @center_freq: Frequency in KHz for which we want regulatory information for
2941 * @desired_bw_khz: the desired max bandwidth you want to use per
2942 * channel. Note that this is still 20 MHz if you want to use HT40
2943 * as HT40 makes use of two channels for its 40 MHz width bandwidth.
2944 * If set to 0 we'll assume you want the standard 20 MHz.
2945 * @reg_rule: the regulatory rule which we have for this frequency 2941 * @reg_rule: the regulatory rule which we have for this frequency
2946 * 2942 *
2947 * Use this function to get the regulatory rule for a specific frequency on 2943 * Use this function to get the regulatory rule for a specific frequency on
@@ -2956,9 +2952,7 @@ extern void wiphy_apply_custom_regulatory(
2956 * freq_in_rule_band() for our current definition of a band -- this is purely 2952 * freq_in_rule_band() for our current definition of a band -- this is purely
2957 * subjective and right now its 802.11 specific. 2953 * subjective and right now its 802.11 specific.
2958 */ 2954 */
2959extern int freq_reg_info(struct wiphy *wiphy, 2955extern int freq_reg_info(struct wiphy *wiphy, u32 center_freq,
2960 u32 center_freq,
2961 u32 desired_bw_khz,
2962 const struct ieee80211_reg_rule **reg_rule); 2956 const struct ieee80211_reg_rule **reg_rule);
2963 2957
2964/* 2958/*
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index b3f94c957d1d..2e38b47939a3 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -480,8 +480,7 @@ static bool is_valid_rd(const struct ieee80211_regdomain *rd)
480} 480}
481 481
482static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range, 482static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
483 u32 center_freq_khz, 483 u32 center_freq_khz, u32 bw_khz)
484 u32 bw_khz)
485{ 484{
486 u32 start_freq_khz, end_freq_khz; 485 u32 start_freq_khz, end_freq_khz;
487 486
@@ -682,9 +681,7 @@ static u32 map_regdom_flags(u32 rd_flags)
682 return channel_flags; 681 return channel_flags;
683} 682}
684 683
685static int freq_reg_info_regd(struct wiphy *wiphy, 684static int freq_reg_info_regd(struct wiphy *wiphy, u32 center_freq,
686 u32 center_freq,
687 u32 desired_bw_khz,
688 const struct ieee80211_reg_rule **reg_rule, 685 const struct ieee80211_reg_rule **reg_rule,
689 const struct ieee80211_regdomain *regd) 686 const struct ieee80211_regdomain *regd)
690{ 687{
@@ -692,9 +689,6 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
692 bool band_rule_found = false; 689 bool band_rule_found = false;
693 bool bw_fits = false; 690 bool bw_fits = false;
694 691
695 if (!desired_bw_khz)
696 desired_bw_khz = MHZ_TO_KHZ(20);
697
698 if (!regd) 692 if (!regd)
699 return -EINVAL; 693 return -EINVAL;
700 694
@@ -713,7 +707,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
713 if (!band_rule_found) 707 if (!band_rule_found)
714 band_rule_found = freq_in_rule_band(fr, center_freq); 708 band_rule_found = freq_in_rule_band(fr, center_freq);
715 709
716 bw_fits = reg_does_bw_fit(fr, center_freq, desired_bw_khz); 710 bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20));
717 711
718 if (band_rule_found && bw_fits) { 712 if (band_rule_found && bw_fits) {
719 *reg_rule = rr; 713 *reg_rule = rr;
@@ -727,7 +721,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
727 return -EINVAL; 721 return -EINVAL;
728} 722}
729 723
730int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz, 724int freq_reg_info(struct wiphy *wiphy, u32 center_freq,
731 const struct ieee80211_reg_rule **reg_rule) 725 const struct ieee80211_reg_rule **reg_rule)
732{ 726{
733 const struct ieee80211_regdomain *regd; 727 const struct ieee80211_regdomain *regd;
@@ -746,8 +740,7 @@ int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz,
746 else 740 else
747 regd = cfg80211_regdomain; 741 regd = cfg80211_regdomain;
748 742
749 return freq_reg_info_regd(wiphy, center_freq, desired_bw_khz, 743 return freq_reg_info_regd(wiphy, center_freq, reg_rule, regd);
750 reg_rule, regd);
751} 744}
752EXPORT_SYMBOL(freq_reg_info); 745EXPORT_SYMBOL(freq_reg_info);
753 746
@@ -770,7 +763,6 @@ static const char *reg_initiator_name(enum nl80211_reg_initiator initiator)
770} 763}
771 764
772static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, 765static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
773 u32 desired_bw_khz,
774 const struct ieee80211_reg_rule *reg_rule) 766 const struct ieee80211_reg_rule *reg_rule)
775{ 767{
776 const struct ieee80211_power_rule *power_rule; 768 const struct ieee80211_power_rule *power_rule;
@@ -785,8 +777,8 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
785 else 777 else
786 snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain); 778 snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain);
787 779
788 REG_DBG_PRINT("Updating information on frequency %d MHz for a %d MHz width channel with regulatory rule:\n", 780 REG_DBG_PRINT("Updating information on frequency %d MHz with regulatory rule:\n",
789 chan->center_freq, KHZ_TO_MHZ(desired_bw_khz)); 781 chan->center_freq);
790 782
791 REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n", 783 REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n",
792 freq_range->start_freq_khz, freq_range->end_freq_khz, 784 freq_range->start_freq_khz, freq_range->end_freq_khz,
@@ -795,7 +787,6 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
795} 787}
796#else 788#else
797static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, 789static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
798 u32 desired_bw_khz,
799 const struct ieee80211_reg_rule *reg_rule) 790 const struct ieee80211_reg_rule *reg_rule)
800{ 791{
801 return; 792 return;
@@ -805,11 +796,7 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
805/* 796/*
806 * Note that right now we assume the desired channel bandwidth 797 * Note that right now we assume the desired channel bandwidth
807 * is always 20 MHz for each individual channel (HT40 uses 20 MHz 798 * is always 20 MHz for each individual channel (HT40 uses 20 MHz
808 * per channel, the primary and the extension channel). To support 799 * per channel, the primary and the extension channel).
809 * smaller custom bandwidths such as 5 MHz or 10 MHz we'll need a
810 * new ieee80211_channel.target_bw and re run the regulatory check
811 * on the wiphy with the target_bw specified. Then we can simply use
812 * that below for the desired_bw_khz below.
813 */ 800 */
814static void handle_channel(struct wiphy *wiphy, 801static void handle_channel(struct wiphy *wiphy,
815 enum nl80211_reg_initiator initiator, 802 enum nl80211_reg_initiator initiator,
@@ -817,7 +804,6 @@ static void handle_channel(struct wiphy *wiphy,
817{ 804{
818 int r; 805 int r;
819 u32 flags, bw_flags = 0; 806 u32 flags, bw_flags = 0;
820 u32 desired_bw_khz = MHZ_TO_KHZ(20);
821 const struct ieee80211_reg_rule *reg_rule = NULL; 807 const struct ieee80211_reg_rule *reg_rule = NULL;
822 const struct ieee80211_power_rule *power_rule = NULL; 808 const struct ieee80211_power_rule *power_rule = NULL;
823 const struct ieee80211_freq_range *freq_range = NULL; 809 const struct ieee80211_freq_range *freq_range = NULL;
@@ -829,8 +815,7 @@ static void handle_channel(struct wiphy *wiphy,
829 815
830 flags = chan->orig_flags; 816 flags = chan->orig_flags;
831 817
832 r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq), 818 r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq), &reg_rule);
833 desired_bw_khz, &reg_rule);
834 if (r) { 819 if (r) {
835 /* 820 /*
836 * We will disable all channels that do not match our 821 * We will disable all channels that do not match our
@@ -851,7 +836,7 @@ static void handle_channel(struct wiphy *wiphy,
851 return; 836 return;
852 } 837 }
853 838
854 chan_reg_rule_print_dbg(chan, desired_bw_khz, reg_rule); 839 chan_reg_rule_print_dbg(chan, reg_rule);
855 840
856 power_rule = &reg_rule->power_rule; 841 power_rule = &reg_rule->power_rule;
857 freq_range = &reg_rule->freq_range; 842 freq_range = &reg_rule->freq_range;
@@ -1223,23 +1208,22 @@ static void handle_channel_custom(struct wiphy *wiphy,
1223 const struct ieee80211_regdomain *regd) 1208 const struct ieee80211_regdomain *regd)
1224{ 1209{
1225 int r; 1210 int r;
1226 u32 desired_bw_khz = MHZ_TO_KHZ(20);
1227 u32 bw_flags = 0; 1211 u32 bw_flags = 0;
1228 const struct ieee80211_reg_rule *reg_rule = NULL; 1212 const struct ieee80211_reg_rule *reg_rule = NULL;
1229 const struct ieee80211_power_rule *power_rule = NULL; 1213 const struct ieee80211_power_rule *power_rule = NULL;
1230 const struct ieee80211_freq_range *freq_range = NULL; 1214 const struct ieee80211_freq_range *freq_range = NULL;
1231 1215
1232 r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq), 1216 r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq),
1233 desired_bw_khz, &reg_rule, regd); 1217 &reg_rule, regd);
1234 1218
1235 if (r) { 1219 if (r) {
1236 REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits a %d MHz wide channel\n", 1220 REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n",
1237 chan->center_freq, KHZ_TO_MHZ(desired_bw_khz)); 1221 chan->center_freq);
1238 chan->flags = IEEE80211_CHAN_DISABLED; 1222 chan->flags = IEEE80211_CHAN_DISABLED;
1239 return; 1223 return;
1240 } 1224 }
1241 1225
1242 chan_reg_rule_print_dbg(chan, desired_bw_khz, reg_rule); 1226 chan_reg_rule_print_dbg(chan, reg_rule);
1243 1227
1244 power_rule = &reg_rule->power_rule; 1228 power_rule = &reg_rule->power_rule;
1245 freq_range = &reg_rule->freq_range; 1229 freq_range = &reg_rule->freq_range;