diff options
| -rw-r--r-- | net/mac80211/Makefile | 1 | ||||
| -rw-r--r-- | net/mac80211/ieee80211.c | 3 | ||||
| -rw-r--r-- | net/mac80211/ieee80211_i.h | 5 | ||||
| -rw-r--r-- | net/mac80211/ieee80211_ioctl.c | 133 | ||||
| -rw-r--r-- | net/mac80211/regdomain.c | 157 |
5 files changed, 164 insertions, 135 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/ieee80211.c b/net/mac80211/ieee80211.c index 2ddf4ef4065e..6c63dcf9f1ec 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c | |||
| @@ -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 */ |
| 760 | int ieee80211_set_compression(struct ieee80211_local *local, | 760 | int 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); |
| 762 | int ieee80211_init_client(struct net_device *dev); | ||
| 763 | int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq); | 762 | int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq); |
| 764 | /* ieee80211_sta.c */ | 763 | /* ieee80211_sta.c */ |
| 765 | void ieee80211_sta_timer(unsigned long data); | 764 | void ieee80211_sta_timer(unsigned long data); |
| @@ -798,6 +797,10 @@ void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata); | |||
| 798 | int ieee80211_if_add_mgmt(struct ieee80211_local *local); | 797 | int ieee80211_if_add_mgmt(struct ieee80211_local *local); |
| 799 | void ieee80211_if_del_mgmt(struct ieee80211_local *local); | 798 | void ieee80211_if_del_mgmt(struct ieee80211_local *local); |
| 800 | 799 | ||
| 800 | /* regdomain.c */ | ||
| 801 | void ieee80211_regdomain_init(void); | ||
| 802 | void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode); | ||
| 803 | |||
| 801 | /* for wiphy privid */ | 804 | /* for wiphy privid */ |
| 802 | extern void *mac80211_wiphy_privid; | 805 | extern 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 | ||
| 30 | static int ieee80211_regdom = 0x10; /* FCC */ | ||
| 31 | module_param(ieee80211_regdom, int, 0444); | ||
| 32 | MODULE_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 | */ | ||
| 40 | static int ieee80211_japan_5ghz /* = 0 */; | ||
| 41 | module_param(ieee80211_japan_5ghz, int, 0444); | ||
| 42 | MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz"); | ||
| 43 | |||
| 44 | static void ieee80211_set_hw_encryption(struct net_device *dev, | 30 | static 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 | ||
| 415 | struct ieee80211_channel_range { | ||
| 416 | short start_freq; | ||
| 417 | short end_freq; | ||
| 418 | unsigned char power_level; | ||
| 419 | unsigned char antenna_max; | ||
| 420 | }; | ||
| 421 | |||
| 422 | static 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 | |||
| 430 | static 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 | |||
| 438 | static const struct ieee80211_channel_range *channel_range = | ||
| 439 | ieee80211_fcc_channels; | ||
| 440 | |||
| 441 | |||
| 442 | static 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 | |||
| 509 | static 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 | |||
| 525 | int 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 | |||
| 534 | static int ieee80211_ioctl_siwmode(struct net_device *dev, | 401 | static 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/regdomain.c b/net/mac80211/regdomain.c new file mode 100644 index 000000000000..32e5dca6b6b9 --- /dev/null +++ b/net/mac80211/regdomain.c | |||
| @@ -0,0 +1,157 @@ | |||
| 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 | |||
| 36 | static int ieee80211_regdom = 0x10; /* FCC */ | ||
| 37 | module_param(ieee80211_regdom, int, 0444); | ||
| 38 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK"); | ||
| 39 | |||
| 40 | /* | ||
| 41 | * If firmware is upgraded by the vendor, additional channels can be used based | ||
| 42 | * on the new Japanese regulatory rules. This is indicated by setting | ||
| 43 | * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel | ||
| 44 | * module. | ||
| 45 | */ | ||
| 46 | static int ieee80211_japan_5ghz /* = 0 */; | ||
| 47 | module_param(ieee80211_japan_5ghz, int, 0444); | ||
| 48 | MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz"); | ||
| 49 | |||
| 50 | |||
| 51 | struct ieee80211_channel_range { | ||
| 52 | short start_freq; | ||
| 53 | short end_freq; | ||
| 54 | unsigned char power_level; | ||
| 55 | unsigned char antenna_max; | ||
| 56 | }; | ||
| 57 | |||
| 58 | static const struct ieee80211_channel_range ieee80211_fcc_channels[] = { | ||
| 59 | { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */, | ||
| 60 | { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */, | ||
| 61 | { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */, | ||
| 62 | { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */, | ||
| 63 | { 0 } | ||
| 64 | }; | ||
| 65 | |||
| 66 | static const struct ieee80211_channel_range ieee80211_mkk_channels[] = { | ||
| 67 | { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */, | ||
| 68 | { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */, | ||
| 69 | { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */, | ||
| 70 | { 0 } | ||
| 71 | }; | ||
| 72 | |||
| 73 | |||
| 74 | static const struct ieee80211_channel_range *channel_range = | ||
| 75 | ieee80211_fcc_channels; | ||
| 76 | |||
| 77 | |||
| 78 | static void ieee80211_unmask_channel(int mode, struct ieee80211_channel *chan) | ||
| 79 | { | ||
| 80 | int i; | ||
| 81 | |||
| 82 | chan->flag = 0; | ||
| 83 | |||
| 84 | if (ieee80211_regdom == 64 && | ||
| 85 | (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) { | ||
| 86 | /* Do not allow Turbo modes in Japan. */ | ||
| 87 | return; | ||
| 88 | } | ||
| 89 | |||
| 90 | for (i = 0; channel_range[i].start_freq; i++) { | ||
| 91 | const struct ieee80211_channel_range *r = &channel_range[i]; | ||
| 92 | if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) { | ||
| 93 | if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz && | ||
| 94 | chan->freq >= 5260 && chan->freq <= 5320) { | ||
| 95 | /* | ||
| 96 | * Skip new channels in Japan since the | ||
| 97 | * firmware was not marked having been upgraded | ||
| 98 | * by the vendor. | ||
| 99 | */ | ||
| 100 | continue; | ||
| 101 | } | ||
| 102 | |||
| 103 | if (ieee80211_regdom == 0x10 && | ||
| 104 | (chan->freq == 5190 || chan->freq == 5210 || | ||
| 105 | chan->freq == 5230)) { | ||
| 106 | /* Skip MKK channels when in FCC domain. */ | ||
| 107 | continue; | ||
| 108 | } | ||
| 109 | |||
| 110 | chan->flag |= IEEE80211_CHAN_W_SCAN | | ||
| 111 | IEEE80211_CHAN_W_ACTIVE_SCAN | | ||
| 112 | IEEE80211_CHAN_W_IBSS; | ||
| 113 | chan->power_level = r->power_level; | ||
| 114 | chan->antenna_max = r->antenna_max; | ||
| 115 | |||
| 116 | if (ieee80211_regdom == 64 && | ||
| 117 | (chan->freq == 5170 || chan->freq == 5190 || | ||
| 118 | chan->freq == 5210 || chan->freq == 5230)) { | ||
| 119 | /* | ||
| 120 | * New regulatory rules in Japan have backwards | ||
| 121 | * compatibility with old channels in 5.15-5.25 | ||
| 122 | * GHz band, but the station is not allowed to | ||
| 123 | * use active scan on these old channels. | ||
| 124 | */ | ||
| 125 | chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN; | ||
| 126 | } | ||
| 127 | |||
| 128 | if (ieee80211_regdom == 64 && | ||
| 129 | (chan->freq == 5260 || chan->freq == 5280 || | ||
| 130 | chan->freq == 5300 || chan->freq == 5320)) { | ||
| 131 | /* | ||
| 132 | * IBSS is not allowed on 5.25-5.35 GHz band | ||
| 133 | * due to radar detection requirements. | ||
| 134 | */ | ||
| 135 | chan->flag &= ~IEEE80211_CHAN_W_IBSS; | ||
| 136 | } | ||
| 137 | |||
| 138 | break; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | |||
| 144 | void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode) | ||
| 145 | { | ||
| 146 | int c; | ||
| 147 | for (c = 0; c < mode->num_channels; c++) | ||
| 148 | ieee80211_unmask_channel(mode->mode, &mode->channels[c]); | ||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | void ieee80211_regdomain_init(void) | ||
| 153 | { | ||
| 154 | if (ieee80211_regdom == 0x40) | ||
| 155 | channel_range = ieee80211_mkk_channels; | ||
| 156 | } | ||
| 157 | |||
