Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 130152
b: refs/heads/master
c: 0c7dc45
h: refs/heads/master
v: v3
  • Loading branch information
Luis R. Rodriguez authored and John W. Linville committed Jan 16, 2009
1 parent 637e2f6 commit 0cb4288
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a92a3ce72483d7f0902dff8a3be8cdcee215a37c
refs/heads/master: 0c7dc45d21de6ae212b5ccb7cdff5beff795ccf0
82 changes: 79 additions & 3 deletions trunk/net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,31 @@ static u32 freq_max_bandwidth(const struct ieee80211_freq_range *freq_range,
return 0;
}

/**
* freq_in_rule_band - tells us if a frequency is in a frequency band
* @freq_range: frequency rule we want to query
* @freq_khz: frequency we are inquiring about
*
* This lets us know if a specific frequency rule is or is not relevant to
* a specific frequency's band. Bands are device specific and artificial
* definitions (the "2.4 GHz band" and the "5 GHz band"), however it is
* safe for now to assume that a frequency rule should not be part of a
* frequency's band if the start freq or end freq are off by more than 2 GHz.
* This resolution can be lowered and should be considered as we add
* regulatory rule support for other "bands".
**/
static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
u32 freq_khz)
{
#define ONE_GHZ_IN_KHZ 1000000
if (abs(freq_khz - freq_range->start_freq_khz) <= (2 * ONE_GHZ_IN_KHZ))
return true;
if (abs(freq_khz - freq_range->end_freq_khz) <= (2 * ONE_GHZ_IN_KHZ))
return true;
return false;
#undef ONE_GHZ_IN_KHZ
}

/* Converts a country IE to a regulatory domain. A regulatory domain
* structure has a lot of information which the IE doesn't yet have,
* so for the other values we use upper max values as we will intersect
Expand Down Expand Up @@ -748,12 +773,23 @@ static u32 map_regdom_flags(u32 rd_flags)
* this value to the maximum allowed bandwidth.
* @reg_rule: the regulatory rule which we have for this frequency
*
* Use this function to get the regulatory rule for a specific frequency.
* Use this function to get the regulatory rule for a specific frequency on
* a given wireless device. If the device has a specific regulatory domain
* it wants to follow we respect that unless a country IE has been received
* and processed already.
*
* Returns 0 if it was able to find a valid regulatory rule which does
* apply to the given center_freq otherwise it returns non-zero. It will
* also return -ERANGE if we determine the given center_freq does not even have
* a regulatory rule for a frequency range in the center_freq's band. See
* freq_in_rule_band() for our current definition of a band -- this is purely
* subjective and right now its 802.11 specific.
*/
static int freq_reg_info(u32 center_freq, u32 *bandwidth,
const struct ieee80211_reg_rule **reg_rule)
{
int i;
bool band_rule_found = false;
u32 max_bandwidth = 0;

if (!cfg80211_regdomain)
Expand All @@ -767,14 +803,25 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth,
rr = &cfg80211_regdomain->reg_rules[i];
fr = &rr->freq_range;
pr = &rr->power_rule;

/* We only need to know if one frequency rule was
* was in center_freq's band, that's enough, so lets
* not overwrite it once found */
if (!band_rule_found)
band_rule_found = freq_in_rule_band(fr, center_freq);

max_bandwidth = freq_max_bandwidth(fr, center_freq);

if (max_bandwidth && *bandwidth <= max_bandwidth) {
*reg_rule = rr;
*bandwidth = max_bandwidth;
break;
}
}

if (!band_rule_found)
return -ERANGE;

return !max_bandwidth;
}

Expand All @@ -799,8 +846,37 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
&max_bandwidth, &reg_rule);

if (r) {
flags |= IEEE80211_CHAN_DISABLED;
chan->flags = flags;
/* This means no regulatory rule was found in the country IE
* with a frequency range on the center_freq's band, since
* IEEE-802.11 allows for a country IE to have a subset of the
* regulatory information provided in a country we ignore
* disabling the channel unless at least one reg rule was
* found on the center_freq's band. For details see this
* clarification:
*
* http://tinyurl.com/11d-clarification
*/
if (r == -ERANGE &&
last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
#ifdef CONFIG_CFG80211_REG_DEBUG
printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz "
"intact on %s - no rule found in band on "
"Country IE\n",
chan->center_freq, wiphy_name(wiphy));
#endif
} else {
/* In this case we know the country IE has at least one reg rule
* for the band so we respect its band definitions */
#ifdef CONFIG_CFG80211_REG_DEBUG
if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
printk(KERN_DEBUG "cfg80211: Disabling "
"channel %d MHz on %s due to "
"Country IE\n",
chan->center_freq, wiphy_name(wiphy));
#endif
flags |= IEEE80211_CHAN_DISABLED;
chan->flags = flags;
}
return;
}

Expand Down

0 comments on commit 0cb4288

Please sign in to comment.