aboutsummaryrefslogtreecommitdiffstats
path: root/net
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 /net
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>
Diffstat (limited to 'net')
-rw-r--r--net/wireless/reg.c44
1 files changed, 14 insertions, 30 deletions
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;