Commit fe7ef5e9 authored by Johannes Berg's avatar Johannes Berg

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: default avatarJohannes Berg <johannes.berg@intel.com>
parent 6913b49a
...@@ -195,7 +195,6 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy, ...@@ -195,7 +195,6 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
const struct ieee80211_reg_rule *reg_rule; const struct ieee80211_reg_rule *reg_rule;
struct ieee80211_channel *ch; struct ieee80211_channel *ch;
unsigned int i; unsigned int i;
u32 bandwidth = 0;
int r; int r;
for (band = 0; band < IEEE80211_NUM_BANDS; band++) { for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
...@@ -216,7 +215,6 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy, ...@@ -216,7 +215,6 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
r = freq_reg_info(wiphy, r = freq_reg_info(wiphy,
ch->center_freq, ch->center_freq,
bandwidth,
&reg_rule); &reg_rule);
if (r) if (r)
continue; continue;
...@@ -254,7 +252,6 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy, ...@@ -254,7 +252,6 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch; struct ieee80211_channel *ch;
const struct ieee80211_reg_rule *reg_rule; const struct ieee80211_reg_rule *reg_rule;
u32 bandwidth = 0;
int r; int r;
sband = wiphy->bands[IEEE80211_BAND_2GHZ]; sband = wiphy->bands[IEEE80211_BAND_2GHZ];
...@@ -283,7 +280,7 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy, ...@@ -283,7 +280,7 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
*/ */
ch = &sband->channels[11]; /* CH 12 */ ch = &sband->channels[11]; /* CH 12 */
r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
if (!r) { if (!r) {
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
...@@ -291,7 +288,7 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy, ...@@ -291,7 +288,7 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
} }
ch = &sband->channels[12]; /* CH 13 */ ch = &sband->channels[12]; /* CH 13 */
r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
if (!r) { if (!r) {
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
......
...@@ -686,7 +686,7 @@ brcms_reg_apply_beaconing_flags(struct wiphy *wiphy, ...@@ -686,7 +686,7 @@ brcms_reg_apply_beaconing_flags(struct wiphy *wiphy,
if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
ret = freq_reg_info(wiphy, ch->center_freq, ret = freq_reg_info(wiphy, ch->center_freq,
0, &rule); &rule);
if (ret) if (ret)
continue; continue;
......
...@@ -158,7 +158,6 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy, ...@@ -158,7 +158,6 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
const struct ieee80211_reg_rule *reg_rule; const struct ieee80211_reg_rule *reg_rule;
struct ieee80211_channel *ch; struct ieee80211_channel *ch;
unsigned int i; unsigned int i;
u32 bandwidth = 0;
int r; int r;
for (band = 0; band < IEEE80211_NUM_BANDS; band++) { for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
...@@ -174,8 +173,7 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy, ...@@ -174,8 +173,7 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
(ch->flags & IEEE80211_CHAN_RADAR)) (ch->flags & IEEE80211_CHAN_RADAR))
continue; continue;
if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
r = freq_reg_info(wiphy, ch->center_freq, r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
bandwidth, &reg_rule);
if (r) if (r)
continue; continue;
...@@ -211,7 +209,6 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy, ...@@ -211,7 +209,6 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct ieee80211_channel *ch; struct ieee80211_channel *ch;
const struct ieee80211_reg_rule *reg_rule; const struct ieee80211_reg_rule *reg_rule;
u32 bandwidth = 0;
int r; int r;
if (!wiphy->bands[IEEE80211_BAND_2GHZ]) if (!wiphy->bands[IEEE80211_BAND_2GHZ])
...@@ -240,7 +237,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy, ...@@ -240,7 +237,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
*/ */
ch = &sband->channels[11]; /* CH 12 */ ch = &sband->channels[11]; /* CH 12 */
r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
if (!r) { if (!r) {
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
...@@ -248,7 +245,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy, ...@@ -248,7 +245,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
} }
ch = &sband->channels[12]; /* CH 13 */ ch = &sband->channels[12]; /* CH 13 */
r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule); r = freq_reg_info(wiphy, ch->center_freq, &reg_rule);
if (!r) { if (!r) {
if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
......
...@@ -2938,10 +2938,6 @@ extern void wiphy_apply_custom_regulatory( ...@@ -2938,10 +2938,6 @@ extern void wiphy_apply_custom_regulatory(
* freq_reg_info - get regulatory information for the given frequency * freq_reg_info - get regulatory information for the given frequency
* @wiphy: the wiphy for which we want to process this rule for * @wiphy: the wiphy for which we want to process this rule for
* @center_freq: Frequency in KHz for which we want regulatory information for * @center_freq: Frequency in KHz for which we want regulatory information for
* @desired_bw_khz: the desired max bandwidth you want to use per
* channel. Note that this is still 20 MHz if you want to use HT40
* as HT40 makes use of two channels for its 40 MHz width bandwidth.
* If set to 0 we'll assume you want the standard 20 MHz.
* @reg_rule: the regulatory rule which we have for this frequency * @reg_rule: the regulatory rule which we have for this frequency
* *
* Use this function to get the regulatory rule for a specific frequency on * Use this function to get the regulatory rule for a specific frequency on
...@@ -2956,9 +2952,7 @@ extern void wiphy_apply_custom_regulatory( ...@@ -2956,9 +2952,7 @@ extern void wiphy_apply_custom_regulatory(
* freq_in_rule_band() for our current definition of a band -- this is purely * freq_in_rule_band() for our current definition of a band -- this is purely
* subjective and right now its 802.11 specific. * subjective and right now its 802.11 specific.
*/ */
extern int freq_reg_info(struct wiphy *wiphy, extern int freq_reg_info(struct wiphy *wiphy, u32 center_freq,
u32 center_freq,
u32 desired_bw_khz,
const struct ieee80211_reg_rule **reg_rule); const struct ieee80211_reg_rule **reg_rule);
/* /*
......
...@@ -480,8 +480,7 @@ static bool is_valid_rd(const struct ieee80211_regdomain *rd) ...@@ -480,8 +480,7 @@ static bool is_valid_rd(const struct ieee80211_regdomain *rd)
} }
static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range, static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
u32 center_freq_khz, u32 center_freq_khz, u32 bw_khz)
u32 bw_khz)
{ {
u32 start_freq_khz, end_freq_khz; u32 start_freq_khz, end_freq_khz;
...@@ -682,9 +681,7 @@ static u32 map_regdom_flags(u32 rd_flags) ...@@ -682,9 +681,7 @@ static u32 map_regdom_flags(u32 rd_flags)
return channel_flags; return channel_flags;
} }
static int freq_reg_info_regd(struct wiphy *wiphy, static int freq_reg_info_regd(struct wiphy *wiphy, u32 center_freq,
u32 center_freq,
u32 desired_bw_khz,
const struct ieee80211_reg_rule **reg_rule, const struct ieee80211_reg_rule **reg_rule,
const struct ieee80211_regdomain *regd) const struct ieee80211_regdomain *regd)
{ {
...@@ -692,9 +689,6 @@ static int freq_reg_info_regd(struct wiphy *wiphy, ...@@ -692,9 +689,6 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
bool band_rule_found = false; bool band_rule_found = false;
bool bw_fits = false; bool bw_fits = false;
if (!desired_bw_khz)
desired_bw_khz = MHZ_TO_KHZ(20);
if (!regd) if (!regd)
return -EINVAL; return -EINVAL;
...@@ -713,7 +707,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy, ...@@ -713,7 +707,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
if (!band_rule_found) if (!band_rule_found)
band_rule_found = freq_in_rule_band(fr, center_freq); band_rule_found = freq_in_rule_band(fr, center_freq);
bw_fits = reg_does_bw_fit(fr, center_freq, desired_bw_khz); bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20));
if (band_rule_found && bw_fits) { if (band_rule_found && bw_fits) {
*reg_rule = rr; *reg_rule = rr;
...@@ -727,7 +721,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy, ...@@ -727,7 +721,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
return -EINVAL; return -EINVAL;
} }
int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz, int freq_reg_info(struct wiphy *wiphy, u32 center_freq,
const struct ieee80211_reg_rule **reg_rule) const struct ieee80211_reg_rule **reg_rule)
{ {
const struct ieee80211_regdomain *regd; const struct ieee80211_regdomain *regd;
...@@ -746,8 +740,7 @@ int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz, ...@@ -746,8 +740,7 @@ int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz,
else else
regd = cfg80211_regdomain; regd = cfg80211_regdomain;
return freq_reg_info_regd(wiphy, center_freq, desired_bw_khz, return freq_reg_info_regd(wiphy, center_freq, reg_rule, regd);
reg_rule, regd);
} }
EXPORT_SYMBOL(freq_reg_info); EXPORT_SYMBOL(freq_reg_info);
...@@ -770,7 +763,6 @@ static const char *reg_initiator_name(enum nl80211_reg_initiator initiator) ...@@ -770,7 +763,6 @@ static const char *reg_initiator_name(enum nl80211_reg_initiator initiator)
} }
static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
u32 desired_bw_khz,
const struct ieee80211_reg_rule *reg_rule) const struct ieee80211_reg_rule *reg_rule)
{ {
const struct ieee80211_power_rule *power_rule; const struct ieee80211_power_rule *power_rule;
...@@ -785,8 +777,8 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, ...@@ -785,8 +777,8 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
else else
snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain); snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain);
REG_DBG_PRINT("Updating information on frequency %d MHz for a %d MHz width channel with regulatory rule:\n", REG_DBG_PRINT("Updating information on frequency %d MHz with regulatory rule:\n",
chan->center_freq, KHZ_TO_MHZ(desired_bw_khz)); chan->center_freq);
REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n", REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n",
freq_range->start_freq_khz, freq_range->end_freq_khz, 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,7 +787,6 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
} }
#else #else
static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
u32 desired_bw_khz,
const struct ieee80211_reg_rule *reg_rule) const struct ieee80211_reg_rule *reg_rule)
{ {
return; return;
...@@ -805,11 +796,7 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, ...@@ -805,11 +796,7 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
/* /*
* Note that right now we assume the desired channel bandwidth * Note that right now we assume the desired channel bandwidth
* is always 20 MHz for each individual channel (HT40 uses 20 MHz * is always 20 MHz for each individual channel (HT40 uses 20 MHz
* per channel, the primary and the extension channel). To support * per channel, the primary and the extension channel).
* smaller custom bandwidths such as 5 MHz or 10 MHz we'll need a
* new ieee80211_channel.target_bw and re run the regulatory check
* on the wiphy with the target_bw specified. Then we can simply use
* that below for the desired_bw_khz below.
*/ */
static void handle_channel(struct wiphy *wiphy, static void handle_channel(struct wiphy *wiphy,
enum nl80211_reg_initiator initiator, enum nl80211_reg_initiator initiator,
...@@ -817,7 +804,6 @@ static void handle_channel(struct wiphy *wiphy, ...@@ -817,7 +804,6 @@ static void handle_channel(struct wiphy *wiphy,
{ {
int r; int r;
u32 flags, bw_flags = 0; u32 flags, bw_flags = 0;
u32 desired_bw_khz = MHZ_TO_KHZ(20);
const struct ieee80211_reg_rule *reg_rule = NULL; const struct ieee80211_reg_rule *reg_rule = NULL;
const struct ieee80211_power_rule *power_rule = NULL; const struct ieee80211_power_rule *power_rule = NULL;
const struct ieee80211_freq_range *freq_range = NULL; const struct ieee80211_freq_range *freq_range = NULL;
...@@ -829,8 +815,7 @@ static void handle_channel(struct wiphy *wiphy, ...@@ -829,8 +815,7 @@ static void handle_channel(struct wiphy *wiphy,
flags = chan->orig_flags; flags = chan->orig_flags;
r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq), r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq), &reg_rule);
desired_bw_khz, &reg_rule);
if (r) { if (r) {
/* /*
* We will disable all channels that do not match our * We will disable all channels that do not match our
...@@ -851,7 +836,7 @@ static void handle_channel(struct wiphy *wiphy, ...@@ -851,7 +836,7 @@ static void handle_channel(struct wiphy *wiphy,
return; return;
} }
chan_reg_rule_print_dbg(chan, desired_bw_khz, reg_rule); chan_reg_rule_print_dbg(chan, reg_rule);
power_rule = &reg_rule->power_rule; power_rule = &reg_rule->power_rule;
freq_range = &reg_rule->freq_range; freq_range = &reg_rule->freq_range;
...@@ -1223,23 +1208,22 @@ static void handle_channel_custom(struct wiphy *wiphy, ...@@ -1223,23 +1208,22 @@ static void handle_channel_custom(struct wiphy *wiphy,
const struct ieee80211_regdomain *regd) const struct ieee80211_regdomain *regd)
{ {
int r; int r;
u32 desired_bw_khz = MHZ_TO_KHZ(20);
u32 bw_flags = 0; u32 bw_flags = 0;
const struct ieee80211_reg_rule *reg_rule = NULL; const struct ieee80211_reg_rule *reg_rule = NULL;
const struct ieee80211_power_rule *power_rule = NULL; const struct ieee80211_power_rule *power_rule = NULL;
const struct ieee80211_freq_range *freq_range = NULL; const struct ieee80211_freq_range *freq_range = NULL;
r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq), r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq),
desired_bw_khz, &reg_rule, regd); &reg_rule, regd);
if (r) { if (r) {
REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits a %d MHz wide channel\n", REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n",
chan->center_freq, KHZ_TO_MHZ(desired_bw_khz)); chan->center_freq);
chan->flags = IEEE80211_CHAN_DISABLED; chan->flags = IEEE80211_CHAN_DISABLED;
return; return;
} }
chan_reg_rule_print_dbg(chan, desired_bw_khz, reg_rule); chan_reg_rule_print_dbg(chan, reg_rule);
power_rule = &reg_rule->power_rule; power_rule = &reg_rule->power_rule;
freq_range = &reg_rule->freq_range; freq_range = &reg_rule->freq_range;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment