linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bruno Randolf <br1@einfach.org>
To: Dave Kilroy <kilroyd@googlemail.com>
Cc: johannes@sipsolutions.net, linville@tuxdriver.com,
	linux-wireless@vger.kernel.org
Subject: Re: [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j
Date: Tue, 28 Dec 2010 18:43:57 +0900	[thread overview]
Message-ID: <201012281843.57453.br1@einfach.org> (raw)
In-Reply-To: <AANLkTi=R58EGLrsT5sTk7JTqWvaeJ5caytHMt3VCSOki@mail.gmail.com>

On Sat December 25 2010 01:46:00 Dave Kilroy wrote:
> On Fri, Dec 24, 2010 at 7:44 AM, Bruno Randolf <br1@einfach.org> 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 <br1@einfach.org>
> > ---
> > -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

  reply	other threads:[~2010-12-28  9:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-24  7:44 [PATCH RFC] mac80211: Extend channel to frequency mapping for 802.11j Bruno Randolf
2010-12-24 16:46 ` Dave Kilroy
2010-12-28  9:43   ` Bruno Randolf [this message]
2010-12-28  9:51     ` Johannes Berg
2010-12-28  9:53       ` Johannes Berg
2010-12-29 13:55         ` Dave Kilroy
2010-12-27 10:57 ` Johannes Berg
2010-12-28  5:31   ` Bruno Randolf
2010-12-28  8:38     ` Johannes Berg
2010-12-28  9:01       ` Jouni Malinen
2010-12-28  9:08         ` Johannes Berg
2010-12-28  9:25           ` Jouni Malinen
2010-12-28  9:39             ` Bruno Randolf

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=201012281843.57453.br1@einfach.org \
    --to=br1@einfach.org \
    --cc=johannes@sipsolutions.net \
    --cc=kilroyd@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.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).