aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@googlemail.com>2008-12-23 09:03:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:46 -0500
commit9ee677c2276bfcbcf68042ec2718a504af0c5fd7 (patch)
tree0b5528241690e143c60832d319ddbb2ad1c5d7f1 /drivers
parenteaee7cc2c180c291084a1c1f49cd2bf13002b3e1 (diff)
wireless: Add channel/frequency conversions to ieee80211.h
Added mappings for FHSS, DSSS and OFDM channels - with macros to point HR DSSS and ERP to the DSSS mappings. Currently just static inline functions. Use the new functions in the older fullmac drivers. This eliminates a number of const static buffers and removes a couple of range checks that are now redundant. Signed-off-by: David Kilroy <kilroyd@googlemail.com> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Richard Farina <sidhayn@gmail.com> Acked-by: Jeroen Vreeken <pe1rxq@amsat.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/airo.c25
-rw-r--r--drivers/net/wireless/atmel.c20
-rw-r--r--drivers/net/wireless/orinoco/orinoco.c33
-rw-r--r--drivers/net/wireless/rndis_wlan.c13
-rw-r--r--drivers/net/wireless/wl3501_cs.c9
-rw-r--r--drivers/net/wireless/zd1201.c7
6 files changed, 39 insertions, 68 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index fc4322ca669f..2ff588bb0a7c 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1070,10 +1070,6 @@ static WifiCtlHdr wifictlhdr8023 = {
1070 } 1070 }
1071}; 1071};
1072 1072
1073// Frequency list (map channels to frequencies)
1074static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
1075 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
1076
1077// A few details needed for WEP (Wireless Equivalent Privacy) 1073// A few details needed for WEP (Wireless Equivalent Privacy)
1078#define MAX_KEY_SIZE 13 // 128 (?) bits 1074#define MAX_KEY_SIZE 13 // 128 (?) bits
1079#define MIN_KEY_SIZE 5 // 40 bits RC4 - WEP 1075#define MIN_KEY_SIZE 5 // 40 bits RC4 - WEP
@@ -5725,16 +5721,12 @@ static int airo_set_freq(struct net_device *dev,
5725 int rc = -EINPROGRESS; /* Call commit handler */ 5721 int rc = -EINPROGRESS; /* Call commit handler */
5726 5722
5727 /* If setting by frequency, convert to a channel */ 5723 /* If setting by frequency, convert to a channel */
5728 if((fwrq->e == 1) && 5724 if(fwrq->e == 1) {
5729 (fwrq->m >= (int) 2.412e8) &&
5730 (fwrq->m <= (int) 2.487e8)) {
5731 int f = fwrq->m / 100000; 5725 int f = fwrq->m / 100000;
5732 int c = 0; 5726
5733 while((c < 14) && (f != frequency_list[c]))
5734 c++;
5735 /* Hack to fall through... */ 5727 /* Hack to fall through... */
5736 fwrq->e = 0; 5728 fwrq->e = 0;
5737 fwrq->m = c + 1; 5729 fwrq->m = ieee80211_freq_to_dsss_chan(f);
5738 } 5730 }
5739 /* Setting by channel number */ 5731 /* Setting by channel number */
5740 if((fwrq->m > 1000) || (fwrq->e > 0)) 5732 if((fwrq->m > 1000) || (fwrq->e > 0))
@@ -5778,7 +5770,7 @@ static int airo_get_freq(struct net_device *dev,
5778 5770
5779 ch = le16_to_cpu(status_rid.channel); 5771 ch = le16_to_cpu(status_rid.channel);
5780 if((ch > 0) && (ch < 15)) { 5772 if((ch > 0) && (ch < 15)) {
5781 fwrq->m = frequency_list[ch - 1] * 100000; 5773 fwrq->m = ieee80211_dsss_chan_to_freq(ch) * 100000;
5782 fwrq->e = 1; 5774 fwrq->e = 1;
5783 } else { 5775 } else {
5784 fwrq->m = ch; 5776 fwrq->m = ch;
@@ -6795,8 +6787,8 @@ static int airo_get_range(struct net_device *dev,
6795 k = 0; 6787 k = 0;
6796 for(i = 0; i < 14; i++) { 6788 for(i = 0; i < 14; i++) {
6797 range->freq[k].i = i + 1; /* List index */ 6789 range->freq[k].i = i + 1; /* List index */
6798 range->freq[k].m = frequency_list[i] * 100000; 6790 range->freq[k].m = ieee80211_dsss_chan_to_freq(i + 1) * 100000;
6799 range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ 6791 range->freq[k++].e = 1; /* Values in MHz -> * 10^5 * 10 */
6800 } 6792 }
6801 range->num_frequency = k; 6793 range->num_frequency = k;
6802 6794
@@ -7189,10 +7181,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
7189 /* Add frequency */ 7181 /* Add frequency */
7190 iwe.cmd = SIOCGIWFREQ; 7182 iwe.cmd = SIOCGIWFREQ;
7191 iwe.u.freq.m = le16_to_cpu(bss->dsChannel); 7183 iwe.u.freq.m = le16_to_cpu(bss->dsChannel);
7192 /* iwe.u.freq.m containt the channel (starting 1), our 7184 iwe.u.freq.m = ieee80211_dsss_chan_to_freq(iwe.u.freq.m) * 100000;
7193 * frequency_list array start at index 0...
7194 */
7195 iwe.u.freq.m = frequency_list[iwe.u.freq.m - 1] * 100000;
7196 iwe.u.freq.e = 1; 7185 iwe.u.freq.e = 1;
7197 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 7186 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
7198 &iwe, IW_EV_FREQ_LEN); 7187 &iwe, IW_EV_FREQ_LEN);
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 4223672c4432..91930a2c3c6b 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -2204,9 +2204,6 @@ static int atmel_get_frag(struct net_device *dev,
2204 return 0; 2204 return 0;
2205} 2205}
2206 2206
2207static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
2208 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
2209
2210static int atmel_set_freq(struct net_device *dev, 2207static int atmel_set_freq(struct net_device *dev,
2211 struct iw_request_info *info, 2208 struct iw_request_info *info,
2212 struct iw_freq *fwrq, 2209 struct iw_freq *fwrq,
@@ -2216,16 +2213,12 @@ static int atmel_set_freq(struct net_device *dev,
2216 int rc = -EINPROGRESS; /* Call commit handler */ 2213 int rc = -EINPROGRESS; /* Call commit handler */
2217 2214
2218 /* If setting by frequency, convert to a channel */ 2215 /* If setting by frequency, convert to a channel */
2219 if ((fwrq->e == 1) && 2216 if (fwrq->e == 1) {
2220 (fwrq->m >= (int) 241200000) &&
2221 (fwrq->m <= (int) 248700000)) {
2222 int f = fwrq->m / 100000; 2217 int f = fwrq->m / 100000;
2223 int c = 0; 2218
2224 while ((c < 14) && (f != frequency_list[c]))
2225 c++;
2226 /* Hack to fall through... */ 2219 /* Hack to fall through... */
2227 fwrq->e = 0; 2220 fwrq->e = 0;
2228 fwrq->m = c + 1; 2221 fwrq->m = ieee80211_freq_to_dsss_chan(f);
2229 } 2222 }
2230 /* Setting by channel number */ 2223 /* Setting by channel number */
2231 if ((fwrq->m > 1000) || (fwrq->e > 0)) 2224 if ((fwrq->m > 1000) || (fwrq->e > 0))
@@ -2384,8 +2377,11 @@ static int atmel_get_range(struct net_device *dev,
2384 if (range->num_channels != 0) { 2377 if (range->num_channels != 0) {
2385 for (k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) { 2378 for (k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) {
2386 range->freq[k].i = i; /* List index */ 2379 range->freq[k].i = i; /* List index */
2387 range->freq[k].m = frequency_list[i - 1] * 100000; 2380
2388 range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ 2381 /* Values in MHz -> * 10^5 * 10 */
2382 range->freq[k].m = (ieee80211_dsss_chan_to_freq(i) *
2383 100000);
2384 range->freq[k++].e = 1;
2389 } 2385 }
2390 range->num_frequency = k; 2386 range->num_frequency = k;
2391 } 2387 }
diff --git a/drivers/net/wireless/orinoco/orinoco.c b/drivers/net/wireless/orinoco/orinoco.c
index 45a04faa7818..beb4d1f8c184 100644
--- a/drivers/net/wireless/orinoco/orinoco.c
+++ b/drivers/net/wireless/orinoco/orinoco.c
@@ -178,12 +178,7 @@ static const struct ethtool_ops orinoco_ethtool_ops;
178/* Data tables */ 178/* Data tables */
179/********************************************************************/ 179/********************************************************************/
180 180
181/* The frequency of each channel in MHz */ 181#define NUM_CHANNELS 14
182static const long channel_frequency[] = {
183 2412, 2417, 2422, 2427, 2432, 2437, 2442,
184 2447, 2452, 2457, 2462, 2467, 2472, 2484
185};
186#define NUM_CHANNELS ARRAY_SIZE(channel_frequency)
187 182
188/* This tables gives the actual meanings of the bitrate IDs returned 183/* This tables gives the actual meanings of the bitrate IDs returned
189 * by the firmware. */ 184 * by the firmware. */
@@ -3742,13 +3737,13 @@ static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
3742 return err; 3737 return err;
3743} 3738}
3744 3739
3745static long orinoco_hw_get_freq(struct orinoco_private *priv) 3740static int orinoco_hw_get_freq(struct orinoco_private *priv)
3746{ 3741{
3747 3742
3748 hermes_t *hw = &priv->hw; 3743 hermes_t *hw = &priv->hw;
3749 int err = 0; 3744 int err = 0;
3750 u16 channel; 3745 u16 channel;
3751 long freq = 0; 3746 int freq = 0;
3752 unsigned long flags; 3747 unsigned long flags;
3753 3748
3754 if (orinoco_lock(priv, &flags) != 0) 3749 if (orinoco_lock(priv, &flags) != 0)
@@ -3771,7 +3766,7 @@ static long orinoco_hw_get_freq(struct orinoco_private *priv)
3771 goto out; 3766 goto out;
3772 3767
3773 } 3768 }
3774 freq = channel_frequency[channel-1] * 100000; 3769 freq = ieee80211_dsss_chan_to_freq(channel);
3775 3770
3776 out: 3771 out:
3777 orinoco_unlock(priv, &flags); 3772 orinoco_unlock(priv, &flags);
@@ -3998,7 +3993,8 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
3998 for (i = 0; i < NUM_CHANNELS; i++) { 3993 for (i = 0; i < NUM_CHANNELS; i++) {
3999 if (priv->channel_mask & (1 << i)) { 3994 if (priv->channel_mask & (1 << i)) {
4000 range->freq[k].i = i + 1; 3995 range->freq[k].i = i + 1;
4001 range->freq[k].m = channel_frequency[i] * 100000; 3996 range->freq[k].m = (ieee80211_dsss_chan_to_freq(i + 1) *
3997 100000);
4002 range->freq[k].e = 1; 3998 range->freq[k].e = 1;
4003 k++; 3999 k++;
4004 } 4000 }
@@ -4346,16 +4342,15 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
4346 /* Setting by channel number */ 4342 /* Setting by channel number */
4347 chan = frq->m; 4343 chan = frq->m;
4348 } else { 4344 } else {
4349 /* Setting by frequency - search the table */ 4345 /* Setting by frequency */
4350 int mult = 1; 4346 int denom = 1;
4351 int i; 4347 int i;
4352 4348
4349 /* Calculate denominator to rescale to MHz */
4353 for (i = 0; i < (6 - frq->e); i++) 4350 for (i = 0; i < (6 - frq->e); i++)
4354 mult *= 10; 4351 denom *= 10;
4355 4352
4356 for (i = 0; i < NUM_CHANNELS; i++) 4353 chan = ieee80211_freq_to_dsss_chan(frq->m / denom);
4357 if (frq->m == (channel_frequency[i] * mult))
4358 chan = i+1;
4359 } 4354 }
4360 4355
4361 if ( (chan < 1) || (chan > NUM_CHANNELS) || 4356 if ( (chan < 1) || (chan > NUM_CHANNELS) ||
@@ -4392,7 +4387,7 @@ static int orinoco_ioctl_getfreq(struct net_device *dev,
4392 return tmp; 4387 return tmp;
4393 } 4388 }
4394 4389
4395 frq->m = tmp; 4390 frq->m = tmp * 100000;
4396 frq->e = 1; 4391 frq->e = 1;
4397 4392
4398 return 0; 4393 return 0;
@@ -5609,7 +5604,7 @@ static inline char *orinoco_translate_scan(struct net_device *dev,
5609 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 5604 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5610 &iwe, IW_EV_FREQ_LEN); 5605 &iwe, IW_EV_FREQ_LEN);
5611 5606
5612 iwe.u.freq.m = channel_frequency[channel-1] * 100000; 5607 iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000;
5613 iwe.u.freq.e = 1; 5608 iwe.u.freq.e = 1;
5614 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 5609 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5615 &iwe, IW_EV_FREQ_LEN); 5610 &iwe, IW_EV_FREQ_LEN);
@@ -5760,7 +5755,7 @@ static inline char *orinoco_translate_ext_scan(struct net_device *dev,
5760 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 5755 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5761 &iwe, IW_EV_FREQ_LEN); 5756 &iwe, IW_EV_FREQ_LEN);
5762 5757
5763 iwe.u.freq.m = channel_frequency[channel-1] * 100000; 5758 iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000;
5764 iwe.u.freq.e = 1; 5759 iwe.u.freq.e = 1;
5765 current_ev = iwe_stream_add_event(info, current_ev, end_buf, 5760 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
5766 &iwe, IW_EV_FREQ_LEN); 5761 &iwe, IW_EV_FREQ_LEN);
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index ed93ac41297f..105f214e21f4 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -369,9 +369,6 @@ struct rndis_wext_private {
369}; 369};
370 370
371 371
372static const int freq_chan[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
373 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
374
375static const int rates_80211g[8] = { 6, 9, 12, 18, 24, 36, 48, 54 }; 372static const int rates_80211g[8] = { 6, 9, 12, 18, 24, 36, 48, 54 };
376 373
377static const int bcm4320_power_output[4] = { 25, 50, 75, 100 }; 374static const int bcm4320_power_output[4] = { 25, 50, 75, 100 };
@@ -640,8 +637,8 @@ static void dsconfig_to_freq(unsigned int dsconfig, struct iw_freq *freq)
640static int freq_to_dsconfig(struct iw_freq *freq, unsigned int *dsconfig) 637static int freq_to_dsconfig(struct iw_freq *freq, unsigned int *dsconfig)
641{ 638{
642 if (freq->m < 1000 && freq->e == 0) { 639 if (freq->m < 1000 && freq->e == 0) {
643 if (freq->m >= 1 && freq->m <= ARRAY_SIZE(freq_chan)) 640 if (freq->m >= 1 && freq->m <= 14)
644 *dsconfig = freq_chan[freq->m - 1] * 1000; 641 *dsconfig = ieee80211_dsss_chan_to_freq(freq->m) * 1000;
645 else 642 else
646 return -1; 643 return -1;
647 } else { 644 } else {
@@ -1178,11 +1175,11 @@ static int rndis_iw_get_range(struct net_device *dev,
1178 range->throughput = 11 * 1000 * 1000 / 2; 1175 range->throughput = 11 * 1000 * 1000 / 2;
1179 } 1176 }
1180 1177
1181 range->num_channels = ARRAY_SIZE(freq_chan); 1178 range->num_channels = 14;
1182 1179
1183 for (i = 0; i < ARRAY_SIZE(freq_chan) && i < IW_MAX_FREQUENCIES; i++) { 1180 for (i = 0; (i < 14) && (i < IW_MAX_FREQUENCIES); i++) {
1184 range->freq[i].i = i + 1; 1181 range->freq[i].i = i + 1;
1185 range->freq[i].m = freq_chan[i] * 100000; 1182 range->freq[i].m = ieee80211_dsss_chan_to_freq(i + 1) * 100000;
1186 range->freq[i].e = 1; 1183 range->freq[i].e = 1;
1187 } 1184 }
1188 range->num_frequency = i; 1185 range->num_frequency = i;
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index c99a1b6b948f..c8d5c34e8ddf 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -44,6 +44,7 @@
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/wireless.h> 46#include <linux/wireless.h>
47#include <linux/ieee80211.h>
47 48
48#include <net/iw_handler.h> 49#include <net/iw_handler.h>
49 50
@@ -111,12 +112,6 @@ static void wl3501_release(struct pcmcia_device *link);
111 */ 112 */
112static dev_info_t wl3501_dev_info = "wl3501_cs"; 113static dev_info_t wl3501_dev_info = "wl3501_cs";
113 114
114static int wl3501_chan2freq[] = {
115 [0] = 2412, [1] = 2417, [2] = 2422, [3] = 2427, [4] = 2432,
116 [5] = 2437, [6] = 2442, [7] = 2447, [8] = 2452, [9] = 2457,
117 [10] = 2462, [11] = 2467, [12] = 2472, [13] = 2477,
118};
119
120static const struct { 115static const struct {
121 int reg_domain; 116 int reg_domain;
122 int min, max, deflt; 117 int min, max, deflt;
@@ -1510,7 +1505,7 @@ static int wl3501_get_freq(struct net_device *dev, struct iw_request_info *info,
1510{ 1505{
1511 struct wl3501_card *this = netdev_priv(dev); 1506 struct wl3501_card *this = netdev_priv(dev);
1512 1507
1513 wrqu->freq.m = wl3501_chan2freq[this->chan - 1] * 100000; 1508 wrqu->freq.m = ieee80211_dsss_chan_to_freq(this->chan) * 100000;
1514 wrqu->freq.e = 1; 1509 wrqu->freq.e = 1;
1515 return 0; 1510 return 0;
1516} 1511}
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index b45c27d42fd8..6226ac2357f8 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -919,10 +919,9 @@ static int zd1201_set_freq(struct net_device *dev,
919 if (freq->e == 0) 919 if (freq->e == 0)
920 channel = freq->m; 920 channel = freq->m;
921 else { 921 else {
922 if (freq->m >= 2482) 922 channel = ieee80211_freq_to_dsss_chan(freq->m);
923 channel = 14; 923 if (channel < 0)
924 if (freq->m >= 2407) 924 channel = 0;
925 channel = (freq->m-2407)/5;
926 } 925 }
927 926
928 err = zd1201_setconfig16(zd, ZD1201_RID_CNFOWNCHANNEL, channel); 927 err = zd1201_setconfig16(zd, ZD1201_RID_CNFOWNCHANNEL, channel);