From: "Luis R. Rodriguez" <lrodriguez@atheros.com>
To: Tomas Winkler <tomasw@gmail.com>
Cc: Luis Rodriguez <Luis.Rodriguez@Atheros.com>,
Marcel Holtmann <holtmann@linux.intel.com>,
Johannes Berg <johannes@sipsolutions.net>,
"John W. Linville" <linville@tuxdriver.com>,
Zhu Yi <yi.zhu@intel.com>,
"Kolekar, Abhijeet" <abhijeet.kolekar@intel.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: New Regulatory Domain Api.
Date: Wed, 15 Oct 2008 11:56:36 -0700 [thread overview]
Message-ID: <20081015185636.GH15902@tesla> (raw)
In-Reply-To: <1ba2fa240810151757r11060dfble6b58c76a7d0d8d1@mail.gmail.com>
On Wed, Oct 15, 2008 at 05:57:20PM -0700, Tomas Winkler wrote:
> On Wed, Oct 15, 2008 at 7:44 PM, Luis R. Rodriguez
> <lrodriguez@atheros.com> wrote:
> > Anyway since you only have 3 this should be very simple to resolve...
> > Just add the 5 GHz frequency ranges you always support. Obviously the BG
> > card will not be able to make use of them :)
>
> It's ugly but possible w/a but we still have 3945 and 4965 where it is
> not so simple.
Ah. I see. Ok then please try this patch. What do you guys think?
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 626dbb6..703382a 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -469,6 +469,31 @@ static u32 freq_max_bandwidth(const struct ieee80211_freq_range *freq_range,
return 0;
}
+/**
+ * freq_in_rule_band - tells us if a frequency rule is in freqs 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_HZ 1000000000
+ if (abs(freq_khz - freq_range->start_freq_khz) <= (2 * ONE_GHZ_IN_HZ))
+ return true;
+ if (abs(freq_khz - freq_range->end_freq_khz) <= (2 * ONE_GHZ_IN_HZ))
+ return true;
+ return false;
+#undef ONE_GHZ_IN_HZ
+}
+
/* XXX: add support for the rest of enum nl80211_reg_rule_flags, we may
* want to just have the channel structure use these */
static u32 map_regdom_flags(u32 rd_flags)
@@ -492,11 +517,17 @@ static u32 map_regdom_flags(u32 rd_flags)
* @reg_rule: the regulatory rule which we have for this frequency
*
* Use this function to get the regulatory rule for a specific frequency.
+ * It 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 -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.
*/
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)
@@ -510,6 +541,9 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth,
rr = &cfg80211_regdomain->reg_rules[i];
fr = &rr->freq_range;
pr = &rr->power_rule;
+
+ 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;
@@ -518,6 +552,9 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth,
}
}
+ if (!band_rule_found)
+ return -ERANGE;
+
return !max_bandwidth;
}
@@ -533,8 +570,15 @@ static void handle_channel(struct ieee80211_channel *chan)
&max_bandwidth, ®_rule);
if (r) {
- flags |= IEEE80211_CHAN_DISABLED;
- chan->flags = flags;
+ /* This means a regulatory rule was found with a frequency
+ * range in center_freq's band. In this case we know the
+ * regulatory rule has at least *one* regulatory rule for
+ * the band so we must respect its band definitions. Otherwise
+ * we assume it may not even know anything about our band */
+ if (r != -ERANGE) {
+ flags |= IEEE80211_CHAN_DISABLED;
+ chan->flags = flags;
+ }
return;
}
next prev parent reply other threads:[~2008-10-16 1:56 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-09 22:17 New Regulatory Domain Api Kolekar, Abhijeet
2008-10-09 15:45 ` Luis R. Rodriguez
2008-10-10 3:22 ` Zhu Yi
2008-10-10 16:49 ` Luis R. Rodriguez
2008-10-14 6:59 ` Zhu Yi
2008-10-14 7:04 ` Luis R. Rodriguez
2008-10-14 7:36 ` Zhu Yi
2008-10-14 9:04 ` Luis R. Rodriguez
2008-10-14 9:13 ` Luis R. Rodriguez
2008-10-14 9:23 ` Zhu Yi
2008-10-14 9:27 ` Zhu Yi
2008-10-14 9:32 ` Johannes Berg
2008-10-14 9:30 ` Luis R. Rodriguez
2008-10-14 20:35 ` John W. Linville
2008-10-14 21:15 ` Johannes Berg
2008-10-14 21:19 ` John W. Linville
2008-10-14 21:27 ` Johannes Berg
2008-10-14 21:50 ` John W. Linville
2008-10-14 21:57 ` Johannes Berg
2008-10-15 15:46 ` Marcel Holtmann
2008-10-15 15:59 ` Johannes Berg
2008-10-15 17:26 ` Marcel Holtmann
2008-10-15 17:39 ` Luis R. Rodriguez
2008-10-15 17:45 ` Johannes Berg
2008-10-15 18:11 ` Luis R. Rodriguez
2008-10-15 17:47 ` Marcel Holtmann
2008-10-15 11:25 ` Luis R. Rodriguez
2008-10-15 19:25 ` Marcel Holtmann
2008-10-15 13:16 ` Luis R. Rodriguez
2008-10-15 23:31 ` Tomas Winkler
2008-10-15 17:08 ` Luis R. Rodriguez
2008-10-16 0:35 ` Tomas Winkler
2008-10-15 17:44 ` Luis R. Rodriguez
2008-10-16 0:57 ` Tomas Winkler
2008-10-15 18:56 ` Luis R. Rodriguez [this message]
2008-10-16 3:00 ` Zhu Yi
2008-10-16 11:38 ` Luis R. Rodriguez
2008-10-20 2:51 ` Zhu Yi
2008-10-20 3:40 ` Luis R. Rodriguez
2008-10-20 5:18 ` Zhu Yi
2008-10-20 6:33 ` Luis R. Rodriguez
2008-10-20 6:38 ` Johannes Berg
2008-10-20 6:46 ` Luis R. Rodriguez
2008-10-20 6:50 ` Johannes Berg
2008-10-20 6:59 ` Luis R. Rodriguez
2008-10-20 7:22 ` Zhu Yi
2008-10-20 16:43 ` Marcel Holtmann
2008-10-21 1:34 ` Zhu Yi
2008-10-21 1:42 ` Luis R. Rodriguez
2008-10-21 1:58 ` Zhu Yi
2008-10-21 2:37 ` Luis R. Rodriguez
2008-10-21 4:02 ` Zhu Yi
2008-10-21 4:58 ` Luis R. Rodriguez
2008-10-21 5:28 ` Zhu Yi
2008-10-21 6:02 ` Luis R. Rodriguez
2008-10-21 6:46 ` Zhu Yi
2008-10-21 6:07 ` Marcel Holtmann
2008-10-21 6:29 ` Luis R. Rodriguez
2008-10-21 6:51 ` Marcel Holtmann
2008-10-21 17:13 ` John W. Linville
2008-10-21 17:43 ` Marcel Holtmann
2008-10-21 17:48 ` John W. Linville
2008-10-21 11:02 ` Luis R. Rodriguez
2008-10-21 18:05 ` John W. Linville
2008-10-21 11:21 ` Luis R. Rodriguez
2008-10-22 9:20 ` Zhu Yi
2008-10-22 10:13 ` Luis R. Rodriguez
2008-10-23 2:29 ` Zhu Yi
2008-10-21 6:40 ` Johannes Berg
2008-10-21 6:47 ` Marcel Holtmann
2008-10-21 7:05 ` Johannes Berg
[not found] ` <79124FD53D2E084387D88C71BEB48F3EDD3625@CPEXBE-EML29.kpnsp.local>
2008-10-21 7:37 ` Johannes Berg
2008-10-21 16:39 ` Marcel Holtmann
2008-10-21 11:04 ` Luis R. Rodriguez
2008-10-21 16:40 ` Johannes Berg
2008-10-15 17:40 ` Johannes Berg
2008-10-15 2:00 ` Zhu Yi
2008-10-14 9:19 ` Johannes Berg
2008-10-15 1:40 ` Zhu Yi
2008-10-15 15:50 ` Marcel Holtmann
2008-10-15 16:01 ` Johannes Berg
2008-10-15 17:29 ` Marcel Holtmann
2008-10-15 17:36 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081015185636.GH15902@tesla \
--to=lrodriguez@atheros.com \
--cc=Luis.Rodriguez@Atheros.com \
--cc=abhijeet.kolekar@intel.com \
--cc=holtmann@linux.intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=tomasw@gmail.com \
--cc=yi.zhu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).