aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/mac80211/Makefile1
-rw-r--r--net/mac80211/debugfs_netdev.c9
-rw-r--r--net/mac80211/ieee80211.c7
-rw-r--r--net/mac80211/ieee80211_i.h5
-rw-r--r--net/mac80211/ieee80211_ioctl.c133
-rw-r--r--net/mac80211/ieee80211_sta.c6
-rw-r--r--net/mac80211/regdomain.c158
7 files changed, 173 insertions, 146 deletions
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index e9738dad2d7c..a9c2d0787d4a 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -13,6 +13,7 @@ mac80211-objs := \
13 ieee80211_iface.o \ 13 ieee80211_iface.o \
14 ieee80211_rate.o \ 14 ieee80211_rate.o \
15 michael.o \ 15 michael.o \
16 regdomain.o \
16 tkip.o \ 17 tkip.o \
17 aes_ccm.o \ 18 aes_ccm.o \
18 wme.o \ 19 wme.o \
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index a3e01d76d503..799a9208c4b4 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -397,6 +397,8 @@ static int netdev_notify(struct notifier_block * nb,
397 void *ndev) 397 void *ndev)
398{ 398{
399 struct net_device *dev = ndev; 399 struct net_device *dev = ndev;
400 struct dentry *dir;
401 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
400 char buf[10+IFNAMSIZ]; 402 char buf[10+IFNAMSIZ];
401 403
402 if (state != NETDEV_CHANGENAME) 404 if (state != NETDEV_CHANGENAME)
@@ -408,10 +410,11 @@ static int netdev_notify(struct notifier_block * nb,
408 if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid) 410 if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
409 return 0; 411 return 0;
410 412
411 /* TODO
412 sprintf(buf, "netdev:%s", dev->name); 413 sprintf(buf, "netdev:%s", dev->name);
413 debugfs_rename(IEEE80211_DEV_TO_SUB_IF(dev)->debugfsdir, buf); 414 dir = sdata->debugfsdir;
414 */ 415 if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
416 printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
417 "dir to %s\n", buf);
415 418
416 return 0; 419 return 0;
417} 420}
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index 2ddf4ef4065e..c944b17d0fc0 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -4986,8 +4986,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
4986 * and we need some headroom for passing the frame to monitor 4986 * and we need some headroom for passing the frame to monitor
4987 * interfaces, but never both at the same time. 4987 * interfaces, but never both at the same time.
4988 */ 4988 */
4989 local->tx_headroom = max(local->hw.extra_tx_headroom, 4989 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
4990 sizeof(struct ieee80211_tx_status_rtap_hdr)); 4990 sizeof(struct ieee80211_tx_status_rtap_hdr));
4991 4991
4992 debugfs_hw_add(local); 4992 debugfs_hw_add(local);
4993 4993
@@ -5095,7 +5095,7 @@ int ieee80211_register_hwmode(struct ieee80211_hw *hw,
5095 } 5095 }
5096 5096
5097 if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) 5097 if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
5098 ieee80211_init_client(local->mdev); 5098 ieee80211_set_default_regdomain(mode);
5099 5099
5100 return 0; 5100 return 0;
5101} 5101}
@@ -5246,6 +5246,7 @@ static int __init ieee80211_init(void)
5246 } 5246 }
5247 5247
5248 ieee80211_debugfs_netdev_init(); 5248 ieee80211_debugfs_netdev_init();
5249 ieee80211_regdomain_init();
5249 5250
5250 return 0; 5251 return 0;
5251} 5252}
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 055a2a912185..6f7bae7ef9c0 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -759,7 +759,6 @@ void ieee80211_update_default_wep_only(struct ieee80211_local *local);
759/* ieee80211_ioctl.c */ 759/* ieee80211_ioctl.c */
760int ieee80211_set_compression(struct ieee80211_local *local, 760int ieee80211_set_compression(struct ieee80211_local *local,
761 struct net_device *dev, struct sta_info *sta); 761 struct net_device *dev, struct sta_info *sta);
762int ieee80211_init_client(struct net_device *dev);
763int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq); 762int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq);
764/* ieee80211_sta.c */ 763/* ieee80211_sta.c */
765void ieee80211_sta_timer(unsigned long data); 764void ieee80211_sta_timer(unsigned long data);
@@ -798,6 +797,10 @@ void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
798int ieee80211_if_add_mgmt(struct ieee80211_local *local); 797int ieee80211_if_add_mgmt(struct ieee80211_local *local);
799void ieee80211_if_del_mgmt(struct ieee80211_local *local); 798void ieee80211_if_del_mgmt(struct ieee80211_local *local);
800 799
800/* regdomain.c */
801void ieee80211_regdomain_init(void);
802void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode);
803
801/* for wiphy privid */ 804/* for wiphy privid */
802extern void *mac80211_wiphy_privid; 805extern void *mac80211_wiphy_privid;
803 806
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c
index 5918dd079e12..d0e1ab5589db 100644
--- a/net/mac80211/ieee80211_ioctl.c
+++ b/net/mac80211/ieee80211_ioctl.c
@@ -27,20 +27,6 @@
27#include "aes_ccm.h" 27#include "aes_ccm.h"
28#include "debugfs_key.h" 28#include "debugfs_key.h"
29 29
30static int ieee80211_regdom = 0x10; /* FCC */
31module_param(ieee80211_regdom, int, 0444);
32MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK");
33
34/*
35 * If firmware is upgraded by the vendor, additional channels can be used based
36 * on the new Japanese regulatory rules. This is indicated by setting
37 * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel
38 * module.
39 */
40static int ieee80211_japan_5ghz /* = 0 */;
41module_param(ieee80211_japan_5ghz, int, 0444);
42MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz");
43
44static void ieee80211_set_hw_encryption(struct net_device *dev, 30static void ieee80211_set_hw_encryption(struct net_device *dev,
45 struct sta_info *sta, u8 addr[ETH_ALEN], 31 struct sta_info *sta, u8 addr[ETH_ALEN],
46 struct ieee80211_key *key) 32 struct ieee80211_key *key)
@@ -412,125 +398,6 @@ static int ieee80211_ioctl_giwrange(struct net_device *dev,
412} 398}
413 399
414 400
415struct ieee80211_channel_range {
416 short start_freq;
417 short end_freq;
418 unsigned char power_level;
419 unsigned char antenna_max;
420};
421
422static const struct ieee80211_channel_range ieee80211_fcc_channels[] = {
423 { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */,
424 { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */,
425 { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */,
426 { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */,
427 { 0 }
428};
429
430static const struct ieee80211_channel_range ieee80211_mkk_channels[] = {
431 { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */,
432 { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */,
433 { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */,
434 { 0 }
435};
436
437
438static const struct ieee80211_channel_range *channel_range =
439 ieee80211_fcc_channels;
440
441
442static void ieee80211_unmask_channel(struct net_device *dev, int mode,
443 struct ieee80211_channel *chan)
444{
445 int i;
446
447 chan->flag = 0;
448
449 if (ieee80211_regdom == 64 &&
450 (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) {
451 /* Do not allow Turbo modes in Japan. */
452 return;
453 }
454
455 for (i = 0; channel_range[i].start_freq; i++) {
456 const struct ieee80211_channel_range *r = &channel_range[i];
457 if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) {
458 if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz &&
459 chan->freq >= 5260 && chan->freq <= 5320) {
460 /*
461 * Skip new channels in Japan since the
462 * firmware was not marked having been upgraded
463 * by the vendor.
464 */
465 continue;
466 }
467
468 if (ieee80211_regdom == 0x10 &&
469 (chan->freq == 5190 || chan->freq == 5210 ||
470 chan->freq == 5230)) {
471 /* Skip MKK channels when in FCC domain. */
472 continue;
473 }
474
475 chan->flag |= IEEE80211_CHAN_W_SCAN |
476 IEEE80211_CHAN_W_ACTIVE_SCAN |
477 IEEE80211_CHAN_W_IBSS;
478 chan->power_level = r->power_level;
479 chan->antenna_max = r->antenna_max;
480
481 if (ieee80211_regdom == 64 &&
482 (chan->freq == 5170 || chan->freq == 5190 ||
483 chan->freq == 5210 || chan->freq == 5230)) {
484 /*
485 * New regulatory rules in Japan have backwards
486 * compatibility with old channels in 5.15-5.25
487 * GHz band, but the station is not allowed to
488 * use active scan on these old channels.
489 */
490 chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN;
491 }
492
493 if (ieee80211_regdom == 64 &&
494 (chan->freq == 5260 || chan->freq == 5280 ||
495 chan->freq == 5300 || chan->freq == 5320)) {
496 /*
497 * IBSS is not allowed on 5.25-5.35 GHz band
498 * due to radar detection requirements.
499 */
500 chan->flag &= ~IEEE80211_CHAN_W_IBSS;
501 }
502
503 break;
504 }
505 }
506}
507
508
509static int ieee80211_unmask_channels(struct net_device *dev)
510{
511 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
512 struct ieee80211_hw_mode *mode;
513 int c;
514
515 list_for_each_entry(mode, &local->modes_list, list) {
516 for (c = 0; c < mode->num_channels; c++) {
517 ieee80211_unmask_channel(dev, mode->mode,
518 &mode->channels[c]);
519 }
520 }
521 return 0;
522}
523
524
525int ieee80211_init_client(struct net_device *dev)
526{
527 if (ieee80211_regdom == 0x40)
528 channel_range = ieee80211_mkk_channels;
529 ieee80211_unmask_channels(dev);
530 return 0;
531}
532
533
534static int ieee80211_ioctl_siwmode(struct net_device *dev, 401static int ieee80211_ioctl_siwmode(struct net_device *dev,
535 struct iw_request_info *info, 402 struct iw_request_info *info,
536 __u32 *mode, char *extra) 403 __u32 *mode, char *extra)
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index ba2bf8f0a347..952d8dd0676c 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -25,7 +25,6 @@
25#include <linux/wireless.h> 25#include <linux/wireless.h>
26#include <linux/random.h> 26#include <linux/random.h>
27#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
28#include <linux/rtnetlink.h>
29#include <net/iw_handler.h> 28#include <net/iw_handler.h>
30#include <asm/types.h> 29#include <asm/types.h>
31 30
@@ -2107,12 +2106,9 @@ static int ieee80211_sta_config_auth(struct net_device *dev,
2107 struct ieee80211_sta_bss *bss, *selected = NULL; 2106 struct ieee80211_sta_bss *bss, *selected = NULL;
2108 int top_rssi = 0, freq; 2107 int top_rssi = 0, freq;
2109 2108
2110 rtnl_lock();
2111
2112 if (!ifsta->auto_channel_sel && !ifsta->auto_bssid_sel && 2109 if (!ifsta->auto_channel_sel && !ifsta->auto_bssid_sel &&
2113 !ifsta->auto_ssid_sel) { 2110 !ifsta->auto_ssid_sel) {
2114 ifsta->state = IEEE80211_AUTHENTICATE; 2111 ifsta->state = IEEE80211_AUTHENTICATE;
2115 rtnl_unlock();
2116 ieee80211_sta_reset_auth(dev, ifsta); 2112 ieee80211_sta_reset_auth(dev, ifsta);
2117 return 0; 2113 return 0;
2118 } 2114 }
@@ -2155,7 +2151,6 @@ static int ieee80211_sta_config_auth(struct net_device *dev,
2155 ieee80211_sta_set_bssid(dev, selected->bssid); 2151 ieee80211_sta_set_bssid(dev, selected->bssid);
2156 ieee80211_rx_bss_put(dev, selected); 2152 ieee80211_rx_bss_put(dev, selected);
2157 ifsta->state = IEEE80211_AUTHENTICATE; 2153 ifsta->state = IEEE80211_AUTHENTICATE;
2158 rtnl_unlock();
2159 ieee80211_sta_reset_auth(dev, ifsta); 2154 ieee80211_sta_reset_auth(dev, ifsta);
2160 return 0; 2155 return 0;
2161 } else { 2156 } else {
@@ -2166,7 +2161,6 @@ static int ieee80211_sta_config_auth(struct net_device *dev,
2166 } else 2161 } else
2167 ifsta->state = IEEE80211_DISABLED; 2162 ifsta->state = IEEE80211_DISABLED;
2168 } 2163 }
2169 rtnl_unlock();
2170 return -1; 2164 return -1;
2171} 2165}
2172 2166
diff --git a/net/mac80211/regdomain.c b/net/mac80211/regdomain.c
new file mode 100644
index 000000000000..b697a2afbb4b
--- /dev/null
+++ b/net/mac80211/regdomain.c
@@ -0,0 +1,158 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10/*
11 * This regulatory domain control implementation is known to be incomplete
12 * and confusing. mac80211 regulatory domain control will be significantly
13 * reworked in the not-too-distant future.
14 *
15 * For now, drivers wishing to control which channels are and aren't available
16 * are advised as follows:
17 * - set the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag
18 * - continue to include *ALL* possible channels in the modes registered
19 * through ieee80211_register_hwmode()
20 * - for each allowable ieee80211_channel structure registered in the above
21 * call, set the flag member to some meaningful value such as
22 * IEEE80211_CHAN_W_SCAN | IEEE80211_CHAN_W_ACTIVE_SCAN |
23 * IEEE80211_CHAN_W_IBSS.
24 * - leave flag as 0 for non-allowable channels
25 *
26 * The usual implementation is for a driver to read a device EEPROM to
27 * determine which regulatory domain it should be operating under, then
28 * looking up the allowable channels in a driver-local table, then performing
29 * the above.
30 */
31
32#include <linux/module.h>
33#include <linux/netdevice.h>
34#include <net/mac80211.h>
35#include "ieee80211_i.h"
36
37static int ieee80211_regdom = 0x10; /* FCC */
38module_param(ieee80211_regdom, int, 0444);
39MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK");
40
41/*
42 * If firmware is upgraded by the vendor, additional channels can be used based
43 * on the new Japanese regulatory rules. This is indicated by setting
44 * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel
45 * module.
46 */
47static int ieee80211_japan_5ghz /* = 0 */;
48module_param(ieee80211_japan_5ghz, int, 0444);
49MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz");
50
51
52struct ieee80211_channel_range {
53 short start_freq;
54 short end_freq;
55 unsigned char power_level;
56 unsigned char antenna_max;
57};
58
59static const struct ieee80211_channel_range ieee80211_fcc_channels[] = {
60 { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */,
61 { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */,
62 { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */,
63 { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */,
64 { 0 }
65};
66
67static const struct ieee80211_channel_range ieee80211_mkk_channels[] = {
68 { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */,
69 { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */,
70 { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */,
71 { 0 }
72};
73
74
75static const struct ieee80211_channel_range *channel_range =
76 ieee80211_fcc_channels;
77
78
79static void ieee80211_unmask_channel(int mode, struct ieee80211_channel *chan)
80{
81 int i;
82
83 chan->flag = 0;
84
85 if (ieee80211_regdom == 64 &&
86 (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) {
87 /* Do not allow Turbo modes in Japan. */
88 return;
89 }
90
91 for (i = 0; channel_range[i].start_freq; i++) {
92 const struct ieee80211_channel_range *r = &channel_range[i];
93 if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) {
94 if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz &&
95 chan->freq >= 5260 && chan->freq <= 5320) {
96 /*
97 * Skip new channels in Japan since the
98 * firmware was not marked having been upgraded
99 * by the vendor.
100 */
101 continue;
102 }
103
104 if (ieee80211_regdom == 0x10 &&
105 (chan->freq == 5190 || chan->freq == 5210 ||
106 chan->freq == 5230)) {
107 /* Skip MKK channels when in FCC domain. */
108 continue;
109 }
110
111 chan->flag |= IEEE80211_CHAN_W_SCAN |
112 IEEE80211_CHAN_W_ACTIVE_SCAN |
113 IEEE80211_CHAN_W_IBSS;
114 chan->power_level = r->power_level;
115 chan->antenna_max = r->antenna_max;
116
117 if (ieee80211_regdom == 64 &&
118 (chan->freq == 5170 || chan->freq == 5190 ||
119 chan->freq == 5210 || chan->freq == 5230)) {
120 /*
121 * New regulatory rules in Japan have backwards
122 * compatibility with old channels in 5.15-5.25
123 * GHz band, but the station is not allowed to
124 * use active scan on these old channels.
125 */
126 chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN;
127 }
128
129 if (ieee80211_regdom == 64 &&
130 (chan->freq == 5260 || chan->freq == 5280 ||
131 chan->freq == 5300 || chan->freq == 5320)) {
132 /*
133 * IBSS is not allowed on 5.25-5.35 GHz band
134 * due to radar detection requirements.
135 */
136 chan->flag &= ~IEEE80211_CHAN_W_IBSS;
137 }
138
139 break;
140 }
141 }
142}
143
144
145void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode)
146{
147 int c;
148 for (c = 0; c < mode->num_channels; c++)
149 ieee80211_unmask_channel(mode->mode, &mode->channels[c]);
150}
151
152
153void ieee80211_regdomain_init(void)
154{
155 if (ieee80211_regdom == 0x40)
156 channel_range = ieee80211_mkk_channels;
157}
158