netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: margitsw@t-online.de (Margit Schubert-While)
To: jgarzik@pobox.com
Cc: netdev@oss.sgi.com, prism54-devel@prism54.org
Subject: [PATCH Linux-2.6.7-bk19] prism54 freq to channel incorrect for 5GHz
Date: Wed, 7 Jul 2004 08:31:47 +0200	[thread overview]
Message-ID: <200407070831.47896.margitsw@t-online.de> (raw)

Jeff scribeth:
> any comment on Sam's comment ?

Sam was referring to this from the sourceforge madwifi
project :
 * Convert MHz frequency to IEEE channel number.
 */
u_int
ieee80211_mhz2ieee(u_int freq, u_int flags)
{
        if (flags & IEEE80211_CHAN_2GHZ) {      /* 2GHz band */
                if (freq == 2484)
                        return 14;
                if (freq < 2484)
                        return (freq - 2407) / 5;
                else
                        return 15 + ((freq - 2512) / 20);
        } else if (flags & IEEE80211_CHAN_5GHZ) {       /* 5Ghz band */
                return (freq - 5000) / 5;
        } else {                                /* either, guess */
                if (freq == 2484)
                        return 14;
                if (freq < 2484)
                        return (freq - 2407) / 5;
                if (freq < 5000)
                        return 15 + ((freq - 2512) / 20);
                return (freq - 5000) / 5;
        }
}

Mostly, the wirless drivers (airo, orinoco, prism54, etc) have a table for the
freq's.
For something generic, I would suggest something like this :
u_int
ieee80211_freq_to_channel(u_int freq)
{
	/* 2.4 GHz channel 14 */
	if ( freq == 2484 )
		return 14;
	/* 2.4 GHz channels 1 - 13 */
	if ( freq >= 2412 && freq <= 2472 )
		return (freq - 2407) / 5;
	/* 2.4 GHz unofficial channels */
	if ( freq > 2484 && freq < 5000 )
		return 15 + ((freq - 2512) / 20);
	/* 5 GHz channels 0 - 200 */
	if ( freq >= 5000 && freq <= 6000 )
		return (freq - 5000) / 5;
	/* Undefined */
	return 0;
}

Note that AFAIK, the 5GHz WLAN channels start at 34 (5.17 GHz)
(but I am not sure) and I don't know the top limit (except that
it is <= 6GHz). Maybe somebody can shed light on this.
If there is a clear definition, that should be reflected int the code.
And something similar for channel_to_freq.
Apparently Japan is doing something in the 10GHz band -
will have to look for details.

Margit

             reply	other threads:[~2004-07-07  6:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-07  6:31 Margit Schubert-While [this message]
2004-07-07  7:49 ` [PATCH Linux-2.6.7-bk19] prism54 freq to channel incorrect for 5GHz Bjørn Mork
2004-07-08 18:43 ` Vladimir Kondratiev
2004-07-09  6:58 ` Vladimir Kondratiev
  -- strict thread matches above, loose matches on Subject: below --
2004-07-06 15:38 Margit Schubert-While
2004-07-06 15:50 ` Sam Leffler
2004-07-07  5:02 ` Jeff Garzik

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=200407070831.47896.margitsw@t-online.de \
    --to=margitsw@t-online.de \
    --cc=jgarzik@pobox.com \
    --cc=netdev@oss.sgi.com \
    --cc=prism54-devel@prism54.org \
    /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).