2010-12-24 07:43:16

by Bruno Randolf

[permalink] [raw]
Subject: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

Extend channel to frequency mapping for 802.11j Japan 4.9GHz band, according to
IEEE802.11 section 17.3.8.3.2 and Annex J. Because there are now overlapping
channel numbers in the 2GHz and 5GHz band we can't map from channel to
frequency without knowing the band. This is no problem as in most contexts we
know the band. In places where we don't know the band (and WEXT compatibility)
we assume the 2GHz band for channels below 14.

Signed-off-by: Bruno Randolf <[email protected]>
---
include/net/cfg80211.h | 3 ++-
net/mac80211/ibss.c | 2 +-
net/mac80211/mesh.c | 2 +-
net/mac80211/mlme.c | 8 +++++---
net/mac80211/scan.c | 3 ++-
net/wireless/reg.c | 6 +++---
net/wireless/util.c | 36 ++++++++++++++++++++++--------------
net/wireless/wext-compat.c | 5 ++++-
8 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bcc9f44..cfaac36 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1788,8 +1788,9 @@ static inline void *wdev_priv(struct wireless_dev *wdev)
/**
* ieee80211_channel_to_frequency - convert channel number to frequency
* @chan: channel number
+ * @band: band, necessary due to channel number overlap
*/
-extern int ieee80211_channel_to_frequency(int chan);
+extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band);

/**
* ieee80211_frequency_to_channel - convert frequency to channel number
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 53c7077..b9d8df1 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -270,7 +270,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
enum ieee80211_band band = rx_status->band;

if (elems->ds_params && elems->ds_params_len == 1)
- freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
+ freq = ieee80211_channel_to_frequency(elems->ds_params[0], band);
else
freq = rx_status->freq;

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index ca3af46..1430cdc 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
&elems);

if (elems.ds_params && elems.ds_params_len == 1)
- freq = ieee80211_channel_to_frequency(elems.ds_params[0]);
+ freq = ieee80211_channel_to_frequency(elems.ds_params[0], band);
else
freq = rx_status->freq;

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 45fbb9e..33bd6d4 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -176,7 +176,7 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,

/* check that channel matches the right operating channel */
if (local->hw.conf.channel->center_freq !=
- ieee80211_channel_to_frequency(hti->control_chan))
+ ieee80211_channel_to_frequency(hti->control_chan, sband->band))
enable_ht = false;

if (enable_ht) {
@@ -429,7 +429,8 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
container_of((void *)bss, struct cfg80211_bss, priv);
struct ieee80211_channel *new_ch;
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
- int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num);
+ int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
+ cbss->channel->band);

ASSERT_MGD_MTX(ifmgd);

@@ -1519,7 +1520,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
}

if (elems->ds_params && elems->ds_params_len == 1)
- freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
+ freq = ieee80211_channel_to_frequency(elems->ds_params[0],
+ rx_status->band);
else
freq = rx_status->freq;

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index fb274db..1ef73be 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -196,7 +196,8 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
ieee802_11_parse_elems(elements, skb->len - baselen, &elems);

if (elems.ds_params && elems.ds_params_len == 1)
- freq = ieee80211_channel_to_frequency(elems.ds_params[0]);
+ freq = ieee80211_channel_to_frequency(elems.ds_params[0],
+ rx_status->band);
else
freq = rx_status->freq;

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 99d4183..add7c81 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1801,9 +1801,9 @@ void regulatory_hint_disconnect(void)

static bool freq_is_chan_12_13_14(u16 freq)
{
- if (freq == ieee80211_channel_to_frequency(12) ||
- freq == ieee80211_channel_to_frequency(13) ||
- freq == ieee80211_channel_to_frequency(14))
+ if (freq == ieee80211_channel_to_frequency(12, IEEE80211_BAND_2GHZ) ||
+ freq == ieee80211_channel_to_frequency(13, IEEE80211_BAND_2GHZ) ||
+ freq == ieee80211_channel_to_frequency(14, IEEE80211_BAND_2GHZ))
return true;
return false;
}
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 7620ae2..4ed065d 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -29,29 +29,37 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
}
EXPORT_SYMBOL(ieee80211_get_response_rate);

-int ieee80211_channel_to_frequency(int chan)
+int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band)
{
- if (chan < 14)
- return 2407 + chan * 5;
-
- if (chan == 14)
- return 2484;
-
- /* FIXME: 802.11j 17.3.8.3.2 */
- return (chan + 1000) * 5;
+ /* see 802.11 17.3.8.3.2 and Annex J
+ * there are overlapping channel numbers in 5GHz and 2GHz bands */
+ if (band == IEEE80211_BAND_5GHZ) {
+ if (chan >= 182 && chan <= 196)
+ return 4000 + chan * 5;
+ else
+ return 5000 + chan * 5;
+ } else { /* IEEE80211_BAND_2GHZ */
+ if (chan == 14)
+ return 2484;
+ else if (chan < 14)
+ return 2407 + chan * 5;
+ else
+ return 0; /* not supported */
+ }
}
EXPORT_SYMBOL(ieee80211_channel_to_frequency);

int ieee80211_frequency_to_channel(int freq)
{
+ /* see 802.11 17.3.8.3.2 and Annex J */
if (freq == 2484)
return 14;
-
- if (freq < 2484)
+ else if (freq < 2484)
return (freq - 2407) / 5;
-
- /* FIXME: 802.11j 17.3.8.3.2 */
- return freq/5 - 1000;
+ else if (freq >= 4910 && freq <= 4980)
+ return (freq - 4000) / 5;
+ else
+ return (freq - 5000) / 5;
}
EXPORT_SYMBOL(ieee80211_frequency_to_channel);

diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 3e5dbd4..b0e18f0 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -267,9 +267,12 @@ int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq)
* -EINVAL for impossible things.
*/
if (freq->e == 0) {
+ int band = IEEE80211_BAND_2GHZ;
if (freq->m < 0)
return 0;
- return ieee80211_channel_to_frequency(freq->m);
+ if (freq->m > 14)
+ band = IEEE80211_BAND_5GHZ;
+ return ieee80211_channel_to_frequency(freq->m, band);
} else {
int i, div = 1000000;
for (i = 0; i < freq->e; i++)



2010-12-28 05:31:51

by Bruno Randolf

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Mon December 27 2010 19:57:39 Johannes Berg wrote:
> On Fri, 2010-12-24 at 16:44 +0900, Bruno Randolf wrote:
> > static bool freq_is_chan_12_13_14(u16 freq)
> > {
> >
> > - if (freq == ieee80211_channel_to_frequency(12) ||
> > - freq == ieee80211_channel_to_frequency(13) ||
> > - freq == ieee80211_channel_to_frequency(14))
> > + if (freq == ieee80211_channel_to_frequency(12, IEEE80211_BAND_2GHZ) ||
> > + freq == ieee80211_channel_to_frequency(13, IEEE80211_BAND_2GHZ) ||
> > + freq == ieee80211_channel_to_frequency(14, IEEE80211_BAND_2GHZ))
> >
> > return true;
>
> This seems strange ... why not just hardcode the values??

True, but this is not my code, I just did the change for the new function
parameter. It's in net/wireless/reg.c, so I'll CC: Luis.

> > if (freq->e == 0) {
> >
> > + int band = IEEE80211_BAND_2GHZ;
>
> enum?

Ok, thanks.

Any other comments on the code or purpose of this patch?

bruno

2010-12-28 09:51:07

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, 2010-12-28 at 18:43 +0900, Bruno Randolf wrote:

> > You don't have to use them, but there are a few channel/frequency
> > conversion routines in include/ieee80211.h which could be reused in
> > these functions.
>
> Thanks for that info, I didn't know about those functions. I just checked
> them and it seems most of them are not used, AFAICT:
>
> ieee80211_fhss_chan_to_freq - not used
> ieee80211_freq_to_fhss_chan - not used
> ieee80211_hr_chan_to_freq - not used
> ieee80211_freq_to_hr_chan - not used
> ieee80211_erp_chan_to_freq - not used
> ieee80211_freq_to_erp_chan - not used
> ieee80211_ofdm_chan_to_freq - not used
> ieee80211_freq_to_ofdm_chan - not used

Cute -- we should probably just remove these.

> The only two which are used are for 2GHz channels:
>
> ieee80211_dsss_chan_to_freq - atmel, airo, wl3501_cs, orinoco, rndis_wlan
> ieee80211_freq_to_dsss_chan - atmel, airo, orinoco, zd1201
>
> Anyhow i guess it would make sense to have a common channel to frequency
> mapping function for mac80211 and other wireless drivers? The problem is now
> we have to use enum ieee80211_band which is defined cfg80211.h...

Well, you're a bit wrong -- the function you're modifying is part of
cfg80211. Therefore, including cfg80211.h makes perfect sense, it's also
defined in there (therefore, your patch subject should begin with
"cfg80211:" instead of "mac80211:").

However, of those drivers you list only orinoco and rndis_wlan already
use cfg80211, so for the others using it would introduce an almost
"fake" dependency. In any case, it seems like all that should be
separate patches.

johannes


2010-12-28 09:01:14

by Jouni Malinen

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, Dec 28, 2010 at 09:38:33AM +0100, Johannes Berg wrote:
> Not really. I guess it seems fine. Do you know if there are ever any
> starting values used other than 4900 and 5000?

Quite a few.. At least 4.85 GHz and 3.0 GHz for 20 MHz channels and more
for 5 and 10 MHz channels (4.9375 GHz, 4.89 GHz, 3.0025 GHz, 4.0025 GHz,
5.0025 GHz) in channels defined by IEEE 802.11.

--
Jouni Malinen PGP id EFC895FA

2010-12-28 09:08:06

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, 2010-12-28 at 11:01 +0200, Jouni Malinen wrote:
> On Tue, Dec 28, 2010 at 09:38:33AM +0100, Johannes Berg wrote:
> > Not really. I guess it seems fine. Do you know if there are ever any
> > starting values used other than 4900 and 5000?
>
> Quite a few.. At least 4.85 GHz and 3.0 GHz for 20 MHz channels and more
> for 5 and 10 MHz channels (4.9375 GHz, 4.89 GHz, 3.0025 GHz, 4.0025 GHz,
> 5.0025 GHz) in channels defined by IEEE 802.11.

That's what I kinda thought ... doesn't that mean this patch is
insufficient?

johannes


2010-12-29 13:55:32

by Dave Kilroy

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, Dec 28, 2010 at 9:53 AM, Johannes Berg
<[email protected]> wrote:
> On Tue, 2010-12-28 at 10:51 +0100, Johannes Berg wrote:
>
>> > ieee80211_dsss_chan_to_freq - atmel, airo, wl3501_cs, orinoco, rndis_wlan
>> > ieee80211_freq_to_dsss_chan - atmel, airo, orinoco, zd1201
>> >
>> > Anyhow i guess it would make sense to have a common channel to frequency
>> > mapping function for mac80211 and other wireless drivers? The problem is now
>> > we have to use enum ieee80211_band which is defined cfg80211.h...
>
> Interestingly, I just noticed that the above ones also have different
> semantics -- they try to round to the nearest channel rather than
> returning an error if the center frequency isn't exact.

I suspect I introduced these functions while refactoring orinoco (well
before the cfg80211 conversion). If I recall correctly, there was no
specific reason for the round to nearest behaviour - it just seemed
more appropriate than rounding down the frequencies. So if it helps, I
don't see why we shouldn't modify the behaviour of the ieee80211
functions where necessary.

Dave.

2010-12-24 16:46:02

by Dave Kilroy

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Fri, Dec 24, 2010 at 7:44 AM, Bruno Randolf <[email protected]> wrote:
> Extend channel to frequency mapping for 802.11j Japan 4.9GHz band, according to
> IEEE802.11 section 17.3.8.3.2 and Annex J. Because there are now overlapping
> channel numbers in the 2GHz and 5GHz band we can't map from channel to
> frequency without knowing the band. This is no problem as in most contexts we
> know the band. In places where we don't know the band (and WEXT compatibility)
> we assume the 2GHz band for channels below 14.
>
> Signed-off-by: Bruno Randolf <[email protected]>
> ---
> -int ieee80211_channel_to_frequency(int chan)
> +int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band)
> ?{
> - ? ? ? if (chan < 14)
> - ? ? ? ? ? ? ? return 2407 + chan * 5;
> -
> - ? ? ? if (chan == 14)
> - ? ? ? ? ? ? ? return 2484;
> -
> - ? ? ? /* FIXME: 802.11j 17.3.8.3.2 */
> - ? ? ? return (chan + 1000) * 5;
> + ? ? ? /* see 802.11 17.3.8.3.2 and Annex J
> + ? ? ? ?* there are overlapping channel numbers in 5GHz and 2GHz bands */
> + ? ? ? if (band == IEEE80211_BAND_5GHZ) {
> + ? ? ? ? ? ? ? if (chan >= 182 && chan <= 196)
> + ? ? ? ? ? ? ? ? ? ? ? return 4000 + chan * 5;
> + ? ? ? ? ? ? ? else
> + ? ? ? ? ? ? ? ? ? ? ? return 5000 + chan * 5;
> + ? ? ? } else { /* IEEE80211_BAND_2GHZ */
> + ? ? ? ? ? ? ? if (chan == 14)
> + ? ? ? ? ? ? ? ? ? ? ? return 2484;
> + ? ? ? ? ? ? ? else if (chan < 14)
> + ? ? ? ? ? ? ? ? ? ? ? return 2407 + chan * 5;
> + ? ? ? ? ? ? ? else
> + ? ? ? ? ? ? ? ? ? ? ? return 0; /* not supported */
> + ? ? ? }
> ?}
> ?EXPORT_SYMBOL(ieee80211_channel_to_frequency);
>
> ?int ieee80211_frequency_to_channel(int freq)
> ?{
> + ? ? ? /* see 802.11 17.3.8.3.2 and Annex J */
> ? ? ? ?if (freq == 2484)
> ? ? ? ? ? ? ? ?return 14;
> -
> - ? ? ? if (freq < 2484)
> + ? ? ? else if (freq < 2484)
> ? ? ? ? ? ? ? ?return (freq - 2407) / 5;
> -
> - ? ? ? /* FIXME: 802.11j 17.3.8.3.2 */
> - ? ? ? return freq/5 - 1000;
> + ? ? ? else if (freq >= 4910 && freq <= 4980)
> + ? ? ? ? ? ? ? return (freq - 4000) / 5;
> + ? ? ? else
> + ? ? ? ? ? ? ? return (freq - 5000) / 5;
> ?}
> ?EXPORT_SYMBOL(ieee80211_frequency_to_channel);

You don't have to use them, but there are a few channel/frequency
conversion routines in include/ieee80211.h which could be reused in
these functions.


Regards,

Dave.

2010-12-28 09:43:59

by Bruno Randolf

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Sat December 25 2010 01:46:00 Dave Kilroy wrote:
> On Fri, Dec 24, 2010 at 7:44 AM, Bruno Randolf <[email protected]> wrote:
> > Extend channel to frequency mapping for 802.11j Japan 4.9GHz band,
> > according to IEEE802.11 section 17.3.8.3.2 and Annex J. Because there
> > are now overlapping channel numbers in the 2GHz and 5GHz band we can't
> > map from channel to frequency without knowing the band. This is no
> > problem as in most contexts we know the band. In places where we don't
> > know the band (and WEXT compatibility) we assume the 2GHz band for
> > channels below 14.
> >
> > Signed-off-by: Bruno Randolf <[email protected]>
> > ---
> > -int ieee80211_channel_to_frequency(int chan)
> > +int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band)
> > {
> > - if (chan < 14)
> > - return 2407 + chan * 5;
> > -
> > - if (chan == 14)
> > - return 2484;
> > -
> > - /* FIXME: 802.11j 17.3.8.3.2 */
> > - return (chan + 1000) * 5;
> > + /* see 802.11 17.3.8.3.2 and Annex J
> > + * there are overlapping channel numbers in 5GHz and 2GHz bands
> > */ + if (band == IEEE80211_BAND_5GHZ) {
> > + if (chan >= 182 && chan <= 196)
> > + return 4000 + chan * 5;
> > + else
> > + return 5000 + chan * 5;
> > + } else { /* IEEE80211_BAND_2GHZ */
> > + if (chan == 14)
> > + return 2484;
> > + else if (chan < 14)
> > + return 2407 + chan * 5;
> > + else
> > + return 0; /* not supported */
> > + }
> > }
> > EXPORT_SYMBOL(ieee80211_channel_to_frequency);
> >
> > int ieee80211_frequency_to_channel(int freq)
> > {
> > + /* see 802.11 17.3.8.3.2 and Annex J */
> > if (freq == 2484)
> > return 14;
> > -
> > - if (freq < 2484)
> > + else if (freq < 2484)
> > return (freq - 2407) / 5;
> > -
> > - /* FIXME: 802.11j 17.3.8.3.2 */
> > - return freq/5 - 1000;
> > + else if (freq >= 4910 && freq <= 4980)
> > + return (freq - 4000) / 5;
> > + else
> > + return (freq - 5000) / 5;
> > }
> > EXPORT_SYMBOL(ieee80211_frequency_to_channel);
>
> You don't have to use them, but there are a few channel/frequency
> conversion routines in include/ieee80211.h which could be reused in
> these functions.

Thanks for that info, I didn't know about those functions. I just checked
them and it seems most of them are not used, AFAICT:

ieee80211_fhss_chan_to_freq - not used
ieee80211_freq_to_fhss_chan - not used
ieee80211_hr_chan_to_freq - not used
ieee80211_freq_to_hr_chan - not used
ieee80211_erp_chan_to_freq - not used
ieee80211_freq_to_erp_chan - not used
ieee80211_ofdm_chan_to_freq - not used
ieee80211_freq_to_ofdm_chan - not used

The only two which are used are for 2GHz channels:

ieee80211_dsss_chan_to_freq - atmel, airo, wl3501_cs, orinoco, rndis_wlan
ieee80211_freq_to_dsss_chan - atmel, airo, orinoco, zd1201

Anyhow i guess it would make sense to have a common channel to frequency
mapping function for mac80211 and other wireless drivers? The problem is now
we have to use enum ieee80211_band which is defined cfg80211.h...

Any opinions?

bruno

2010-12-28 09:39:44

by Bruno Randolf

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue December 28 2010 18:25:10 Jouni Malinen wrote:
> On Tue, Dec 28, 2010 at 10:08:02AM +0100, Johannes Berg wrote:
> > On Tue, 2010-12-28 at 11:01 +0200, Jouni Malinen wrote:
> > > Quite a few.. At least 4.85 GHz and 3.0 GHz for 20 MHz channels and
> > > more for 5 and 10 MHz channels (4.9375 GHz, 4.89 GHz, 3.0025 GHz,
> > > 4.0025 GHz, 5.0025 GHz) in channels defined by IEEE 802.11.
> >
> > That's what I kinda thought ... doesn't that mean this patch is
> > insufficient?
>
> Depends on what it is trying to achieve. Based on the Subject: line, it
> aims to add support for channels defined in 802.11j and it does indeed
> seem to do that (most of those odd channel starting frequencies come
> from 802.11y). If the goal were to cover all channels defined in the
> current IEEE 802.11 standard, then sure, it would be insufficient, but
> it is not like we support 3.6 GHz band or sub-20 MHz channels anyway, so
> only the 4.85 GHz starting frequency for some emergency channels from
> 802.11y would not be covered.

Well, yeah, I'm was only concerned about the 802.11j part. And I left out all
stuff for non 20MHz channels. If it's needed these functions can be extended
more later... The Japanese need 802.11j now, not a theoretically complete
channel to frequency mapping... ;)

bruno

2010-12-28 08:38:36

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, 2010-12-28 at 14:31 +0900, Bruno Randolf wrote:

> > > - if (freq == ieee80211_channel_to_frequency(12) ||
> > > - freq == ieee80211_channel_to_frequency(13) ||
> > > - freq == ieee80211_channel_to_frequency(14))
> > > + if (freq == ieee80211_channel_to_frequency(12, IEEE80211_BAND_2GHZ) ||
> > > + freq == ieee80211_channel_to_frequency(13, IEEE80211_BAND_2GHZ) ||
> > > + freq == ieee80211_channel_to_frequency(14, IEEE80211_BAND_2GHZ))
> > >
> > > return true;
> >
> > This seems strange ... why not just hardcode the values??
>
> True, but this is not my code, I just did the change for the new function
> parameter. It's in net/wireless/reg.c, so I'll CC: Luis.

Right. It seems rather complicated though, especially with this change.


> Any other comments on the code or purpose of this patch?

Not really. I guess it seems fine. Do you know if there are ever any
starting values used other than 4900 and 5000?

johannes


2010-12-28 09:53:06

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, 2010-12-28 at 10:51 +0100, Johannes Berg wrote:

> > ieee80211_dsss_chan_to_freq - atmel, airo, wl3501_cs, orinoco, rndis_wlan
> > ieee80211_freq_to_dsss_chan - atmel, airo, orinoco, zd1201
> >
> > Anyhow i guess it would make sense to have a common channel to frequency
> > mapping function for mac80211 and other wireless drivers? The problem is now
> > we have to use enum ieee80211_band which is defined cfg80211.h...

Interestingly, I just noticed that the above ones also have different
semantics -- they try to round to the nearest channel rather than
returning an error if the center frequency isn't exact.

johannes


2010-12-28 09:25:21

by Jouni Malinen

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Tue, Dec 28, 2010 at 10:08:02AM +0100, Johannes Berg wrote:
> On Tue, 2010-12-28 at 11:01 +0200, Jouni Malinen wrote:
> > Quite a few.. At least 4.85 GHz and 3.0 GHz for 20 MHz channels and more
> > for 5 and 10 MHz channels (4.9375 GHz, 4.89 GHz, 3.0025 GHz, 4.0025 GHz,
> > 5.0025 GHz) in channels defined by IEEE 802.11.
>
> That's what I kinda thought ... doesn't that mean this patch is
> insufficient?

Depends on what it is trying to achieve. Based on the Subject: line, it
aims to add support for channels defined in 802.11j and it does indeed
seem to do that (most of those odd channel starting frequencies come
from 802.11y). If the goal were to cover all channels defined in the
current IEEE 802.11 standard, then sure, it would be insufficient, but
it is not like we support 3.6 GHz band or sub-20 MHz channels anyway, so
only the 4.85 GHz starting frequency for some emergency channels from
802.11y would not be covered.

--
Jouni Malinen PGP id EFC895FA

2010-12-27 10:57:42

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j

On Fri, 2010-12-24 at 16:44 +0900, Bruno Randolf wrote:

> static bool freq_is_chan_12_13_14(u16 freq)
> {
> - if (freq == ieee80211_channel_to_frequency(12) ||
> - freq == ieee80211_channel_to_frequency(13) ||
> - freq == ieee80211_channel_to_frequency(14))
> + if (freq == ieee80211_channel_to_frequency(12, IEEE80211_BAND_2GHZ) ||
> + freq == ieee80211_channel_to_frequency(13, IEEE80211_BAND_2GHZ) ||
> + freq == ieee80211_channel_to_frequency(14, IEEE80211_BAND_2GHZ))
> return true;

This seems strange ... why not just hardcode the values??

> if (freq->e == 0) {
> + int band = IEEE80211_BAND_2GHZ;

enum?

johannes