diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2009-02-21 00:04:31 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-02-27 14:52:57 -0500 |
commit | fb1fc7add5d205c1db2fa323af1367c3cd4dced2 (patch) | |
tree | fceea0a9a78d46301a76710a156a22f37dab8ba4 /net/wireless/reg.c | |
parent | fe33eb390854886e1fd5d4835d833b80d145aafb (diff) |
cfg80211: comments style cleanup
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r-- | net/wireless/reg.c | 299 |
1 files changed, 199 insertions, 100 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 0b8c4b86789a..7ecb9033ad42 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -54,14 +54,18 @@ static u32 supported_bandwidths[] = { | |||
54 | MHZ_TO_KHZ(20), | 54 | MHZ_TO_KHZ(20), |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /* Central wireless core regulatory domains, we only need two, | 57 | /* |
58 | * Central wireless core regulatory domains, we only need two, | ||
58 | * the current one and a world regulatory domain in case we have no | 59 | * the current one and a world regulatory domain in case we have no |
59 | * information to give us an alpha2 */ | 60 | * information to give us an alpha2 |
61 | */ | ||
60 | const struct ieee80211_regdomain *cfg80211_regdomain; | 62 | const struct ieee80211_regdomain *cfg80211_regdomain; |
61 | 63 | ||
62 | /* We use this as a place for the rd structure built from the | 64 | /* |
65 | * We use this as a place for the rd structure built from the | ||
63 | * last parsed country IE to rest until CRDA gets back to us with | 66 | * last parsed country IE to rest until CRDA gets back to us with |
64 | * what it thinks should apply for the same country */ | 67 | * what it thinks should apply for the same country |
68 | */ | ||
65 | static const struct ieee80211_regdomain *country_ie_regdomain; | 69 | static const struct ieee80211_regdomain *country_ie_regdomain; |
66 | 70 | ||
67 | static LIST_HEAD(reg_requests_list); | 71 | static LIST_HEAD(reg_requests_list); |
@@ -86,9 +90,11 @@ static char *ieee80211_regdom = "US"; | |||
86 | module_param(ieee80211_regdom, charp, 0444); | 90 | module_param(ieee80211_regdom, charp, 0444); |
87 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); | 91 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); |
88 | 92 | ||
89 | /* We assume 40 MHz bandwidth for the old regulatory work. | 93 | /* |
94 | * We assume 40 MHz bandwidth for the old regulatory work. | ||
90 | * We make emphasis we are using the exact same frequencies | 95 | * We make emphasis we are using the exact same frequencies |
91 | * as before */ | 96 | * as before |
97 | */ | ||
92 | 98 | ||
93 | static const struct ieee80211_regdomain us_regdom = { | 99 | static const struct ieee80211_regdomain us_regdom = { |
94 | .n_reg_rules = 6, | 100 | .n_reg_rules = 6, |
@@ -127,8 +133,10 @@ static const struct ieee80211_regdomain jp_regdom = { | |||
127 | 133 | ||
128 | static const struct ieee80211_regdomain eu_regdom = { | 134 | static const struct ieee80211_regdomain eu_regdom = { |
129 | .n_reg_rules = 6, | 135 | .n_reg_rules = 6, |
130 | /* This alpha2 is bogus, we leave it here just for stupid | 136 | /* |
131 | * backward compatibility */ | 137 | * This alpha2 is bogus, we leave it here just for stupid |
138 | * backward compatibility | ||
139 | */ | ||
132 | .alpha2 = "EU", | 140 | .alpha2 = "EU", |
133 | .reg_rules = { | 141 | .reg_rules = { |
134 | /* IEEE 802.11b/g, channels 1..13 */ | 142 | /* IEEE 802.11b/g, channels 1..13 */ |
@@ -197,8 +205,10 @@ static void reset_regdomains(void) | |||
197 | cfg80211_regdomain = NULL; | 205 | cfg80211_regdomain = NULL; |
198 | } | 206 | } |
199 | 207 | ||
200 | /* Dynamic world regulatory domain requested by the wireless | 208 | /* |
201 | * core upon initialization */ | 209 | * Dynamic world regulatory domain requested by the wireless |
210 | * core upon initialization | ||
211 | */ | ||
202 | static void update_world_regdomain(const struct ieee80211_regdomain *rd) | 212 | static void update_world_regdomain(const struct ieee80211_regdomain *rd) |
203 | { | 213 | { |
204 | BUG_ON(!last_request); | 214 | BUG_ON(!last_request); |
@@ -239,8 +249,10 @@ static bool is_unknown_alpha2(const char *alpha2) | |||
239 | { | 249 | { |
240 | if (!alpha2) | 250 | if (!alpha2) |
241 | return false; | 251 | return false; |
242 | /* Special case where regulatory domain was built by driver | 252 | /* |
243 | * but a specific alpha2 cannot be determined */ | 253 | * Special case where regulatory domain was built by driver |
254 | * but a specific alpha2 cannot be determined | ||
255 | */ | ||
244 | if (alpha2[0] == '9' && alpha2[1] == '9') | 256 | if (alpha2[0] == '9' && alpha2[1] == '9') |
245 | return true; | 257 | return true; |
246 | return false; | 258 | return false; |
@@ -250,9 +262,11 @@ static bool is_intersected_alpha2(const char *alpha2) | |||
250 | { | 262 | { |
251 | if (!alpha2) | 263 | if (!alpha2) |
252 | return false; | 264 | return false; |
253 | /* Special case where regulatory domain is the | 265 | /* |
266 | * Special case where regulatory domain is the | ||
254 | * result of an intersection between two regulatory domain | 267 | * result of an intersection between two regulatory domain |
255 | * structures */ | 268 | * structures |
269 | */ | ||
256 | if (alpha2[0] == '9' && alpha2[1] == '8') | 270 | if (alpha2[0] == '9' && alpha2[1] == '8') |
257 | return true; | 271 | return true; |
258 | return false; | 272 | return false; |
@@ -307,8 +321,10 @@ static bool country_ie_integrity_changes(u32 checksum) | |||
307 | return false; | 321 | return false; |
308 | } | 322 | } |
309 | 323 | ||
310 | /* This lets us keep regulatory code which is updated on a regulatory | 324 | /* |
311 | * basis in userspace. */ | 325 | * This lets us keep regulatory code which is updated on a regulatory |
326 | * basis in userspace. | ||
327 | */ | ||
312 | static int call_crda(const char *alpha2) | 328 | static int call_crda(const char *alpha2) |
313 | { | 329 | { |
314 | char country_env[9 + 2] = "COUNTRY="; | 330 | char country_env[9 + 2] = "COUNTRY="; |
@@ -419,10 +435,12 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, | |||
419 | #undef ONE_GHZ_IN_KHZ | 435 | #undef ONE_GHZ_IN_KHZ |
420 | } | 436 | } |
421 | 437 | ||
422 | /* Converts a country IE to a regulatory domain. A regulatory domain | 438 | /* |
439 | * Converts a country IE to a regulatory domain. A regulatory domain | ||
423 | * structure has a lot of information which the IE doesn't yet have, | 440 | * structure has a lot of information which the IE doesn't yet have, |
424 | * so for the other values we use upper max values as we will intersect | 441 | * so for the other values we use upper max values as we will intersect |
425 | * with our userspace regulatory agent to get lower bounds. */ | 442 | * with our userspace regulatory agent to get lower bounds. |
443 | */ | ||
426 | static struct ieee80211_regdomain *country_ie_2_rd( | 444 | static struct ieee80211_regdomain *country_ie_2_rd( |
427 | u8 *country_ie, | 445 | u8 *country_ie, |
428 | u8 country_ie_len, | 446 | u8 country_ie_len, |
@@ -467,9 +485,11 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
467 | 485 | ||
468 | *checksum ^= ((flags ^ alpha2[0] ^ alpha2[1]) << 8); | 486 | *checksum ^= ((flags ^ alpha2[0] ^ alpha2[1]) << 8); |
469 | 487 | ||
470 | /* We need to build a reg rule for each triplet, but first we must | 488 | /* |
489 | * We need to build a reg rule for each triplet, but first we must | ||
471 | * calculate the number of reg rules we will need. We will need one | 490 | * calculate the number of reg rules we will need. We will need one |
472 | * for each channel subband */ | 491 | * for each channel subband |
492 | */ | ||
473 | while (country_ie_len >= 3) { | 493 | while (country_ie_len >= 3) { |
474 | int end_channel = 0; | 494 | int end_channel = 0; |
475 | struct ieee80211_country_ie_triplet *triplet = | 495 | struct ieee80211_country_ie_triplet *triplet = |
@@ -507,9 +527,11 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
507 | if (cur_sub_max_channel < cur_channel) | 527 | if (cur_sub_max_channel < cur_channel) |
508 | return NULL; | 528 | return NULL; |
509 | 529 | ||
510 | /* Do not allow overlapping channels. Also channels | 530 | /* |
531 | * Do not allow overlapping channels. Also channels | ||
511 | * passed in each subband must be monotonically | 532 | * passed in each subband must be monotonically |
512 | * increasing */ | 533 | * increasing |
534 | */ | ||
513 | if (last_sub_max_channel) { | 535 | if (last_sub_max_channel) { |
514 | if (cur_channel <= last_sub_max_channel) | 536 | if (cur_channel <= last_sub_max_channel) |
515 | return NULL; | 537 | return NULL; |
@@ -517,10 +539,12 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
517 | return NULL; | 539 | return NULL; |
518 | } | 540 | } |
519 | 541 | ||
520 | /* When dot11RegulatoryClassesRequired is supported | 542 | /* |
543 | * When dot11RegulatoryClassesRequired is supported | ||
521 | * we can throw ext triplets as part of this soup, | 544 | * we can throw ext triplets as part of this soup, |
522 | * for now we don't care when those change as we | 545 | * for now we don't care when those change as we |
523 | * don't support them */ | 546 | * don't support them |
547 | */ | ||
524 | *checksum ^= ((cur_channel ^ cur_sub_max_channel) << 8) | | 548 | *checksum ^= ((cur_channel ^ cur_sub_max_channel) << 8) | |
525 | ((cur_sub_max_channel ^ cur_sub_max_channel) << 16) | | 549 | ((cur_sub_max_channel ^ cur_sub_max_channel) << 16) | |
526 | ((triplet->chans.max_power ^ cur_sub_max_channel) << 24); | 550 | ((triplet->chans.max_power ^ cur_sub_max_channel) << 24); |
@@ -531,8 +555,10 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
531 | country_ie_len -= 3; | 555 | country_ie_len -= 3; |
532 | num_rules++; | 556 | num_rules++; |
533 | 557 | ||
534 | /* Note: this is not a IEEE requirement but | 558 | /* |
535 | * simply a memory requirement */ | 559 | * Note: this is not a IEEE requirement but |
560 | * simply a memory requirement | ||
561 | */ | ||
536 | if (num_rules > NL80211_MAX_SUPP_REG_RULES) | 562 | if (num_rules > NL80211_MAX_SUPP_REG_RULES) |
537 | return NULL; | 563 | return NULL; |
538 | } | 564 | } |
@@ -560,8 +586,10 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
560 | struct ieee80211_freq_range *freq_range = NULL; | 586 | struct ieee80211_freq_range *freq_range = NULL; |
561 | struct ieee80211_power_rule *power_rule = NULL; | 587 | struct ieee80211_power_rule *power_rule = NULL; |
562 | 588 | ||
563 | /* Must parse if dot11RegulatoryClassesRequired is true, | 589 | /* |
564 | * we don't support this yet */ | 590 | * Must parse if dot11RegulatoryClassesRequired is true, |
591 | * we don't support this yet | ||
592 | */ | ||
565 | if (triplet->ext.reg_extension_id >= | 593 | if (triplet->ext.reg_extension_id >= |
566 | IEEE80211_COUNTRY_EXTENSION_ID) { | 594 | IEEE80211_COUNTRY_EXTENSION_ID) { |
567 | country_ie += 3; | 595 | country_ie += 3; |
@@ -583,10 +611,12 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
583 | end_channel = triplet->chans.first_channel + | 611 | end_channel = triplet->chans.first_channel + |
584 | (4 * (triplet->chans.num_channels - 1)); | 612 | (4 * (triplet->chans.num_channels - 1)); |
585 | 613 | ||
586 | /* The +10 is since the regulatory domain expects | 614 | /* |
615 | * The +10 is since the regulatory domain expects | ||
587 | * the actual band edge, not the center of freq for | 616 | * the actual band edge, not the center of freq for |
588 | * its start and end freqs, assuming 20 MHz bandwidth on | 617 | * its start and end freqs, assuming 20 MHz bandwidth on |
589 | * the channels passed */ | 618 | * the channels passed |
619 | */ | ||
590 | freq_range->start_freq_khz = | 620 | freq_range->start_freq_khz = |
591 | MHZ_TO_KHZ(ieee80211_channel_to_frequency( | 621 | MHZ_TO_KHZ(ieee80211_channel_to_frequency( |
592 | triplet->chans.first_channel) - 10); | 622 | triplet->chans.first_channel) - 10); |
@@ -594,9 +624,11 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
594 | MHZ_TO_KHZ(ieee80211_channel_to_frequency( | 624 | MHZ_TO_KHZ(ieee80211_channel_to_frequency( |
595 | end_channel) + 10); | 625 | end_channel) + 10); |
596 | 626 | ||
597 | /* Large arbitrary values, we intersect later */ | 627 | /* |
598 | /* Increment this if we ever support >= 40 MHz channels | 628 | * These are large arbitrary values we use to intersect later. |
599 | * in IEEE 802.11 */ | 629 | * Increment this if we ever support >= 40 MHz channels |
630 | * in IEEE 802.11 | ||
631 | */ | ||
600 | freq_range->max_bandwidth_khz = MHZ_TO_KHZ(40); | 632 | freq_range->max_bandwidth_khz = MHZ_TO_KHZ(40); |
601 | power_rule->max_antenna_gain = DBI_TO_MBI(100); | 633 | power_rule->max_antenna_gain = DBI_TO_MBI(100); |
602 | power_rule->max_eirp = DBM_TO_MBM(100); | 634 | power_rule->max_eirp = DBM_TO_MBM(100); |
@@ -612,8 +644,10 @@ static struct ieee80211_regdomain *country_ie_2_rd( | |||
612 | } | 644 | } |
613 | 645 | ||
614 | 646 | ||
615 | /* Helper for regdom_intersect(), this does the real | 647 | /* |
616 | * mathematical intersection fun */ | 648 | * Helper for regdom_intersect(), this does the real |
649 | * mathematical intersection fun | ||
650 | */ | ||
617 | static int reg_rules_intersect( | 651 | static int reg_rules_intersect( |
618 | const struct ieee80211_reg_rule *rule1, | 652 | const struct ieee80211_reg_rule *rule1, |
619 | const struct ieee80211_reg_rule *rule2, | 653 | const struct ieee80211_reg_rule *rule2, |
@@ -691,11 +725,13 @@ static struct ieee80211_regdomain *regdom_intersect( | |||
691 | if (!rd1 || !rd2) | 725 | if (!rd1 || !rd2) |
692 | return NULL; | 726 | return NULL; |
693 | 727 | ||
694 | /* First we get a count of the rules we'll need, then we actually | 728 | /* |
729 | * First we get a count of the rules we'll need, then we actually | ||
695 | * build them. This is to so we can malloc() and free() a | 730 | * build them. This is to so we can malloc() and free() a |
696 | * regdomain once. The reason we use reg_rules_intersect() here | 731 | * regdomain once. The reason we use reg_rules_intersect() here |
697 | * is it will return -EINVAL if the rule computed makes no sense. | 732 | * is it will return -EINVAL if the rule computed makes no sense. |
698 | * All rules that do check out OK are valid. */ | 733 | * All rules that do check out OK are valid. |
734 | */ | ||
699 | 735 | ||
700 | for (x = 0; x < rd1->n_reg_rules; x++) { | 736 | for (x = 0; x < rd1->n_reg_rules; x++) { |
701 | rule1 = &rd1->reg_rules[x]; | 737 | rule1 = &rd1->reg_rules[x]; |
@@ -723,14 +759,18 @@ static struct ieee80211_regdomain *regdom_intersect( | |||
723 | rule1 = &rd1->reg_rules[x]; | 759 | rule1 = &rd1->reg_rules[x]; |
724 | for (y = 0; y < rd2->n_reg_rules; y++) { | 760 | for (y = 0; y < rd2->n_reg_rules; y++) { |
725 | rule2 = &rd2->reg_rules[y]; | 761 | rule2 = &rd2->reg_rules[y]; |
726 | /* This time around instead of using the stack lets | 762 | /* |
763 | * This time around instead of using the stack lets | ||
727 | * write to the target rule directly saving ourselves | 764 | * write to the target rule directly saving ourselves |
728 | * a memcpy() */ | 765 | * a memcpy() |
766 | */ | ||
729 | intersected_rule = &rd->reg_rules[rule_idx]; | 767 | intersected_rule = &rd->reg_rules[rule_idx]; |
730 | r = reg_rules_intersect(rule1, rule2, | 768 | r = reg_rules_intersect(rule1, rule2, |
731 | intersected_rule); | 769 | intersected_rule); |
732 | /* No need to memset here the intersected rule here as | 770 | /* |
733 | * we're not using the stack anymore */ | 771 | * No need to memset here the intersected rule here as |
772 | * we're not using the stack anymore | ||
773 | */ | ||
734 | if (r) | 774 | if (r) |
735 | continue; | 775 | continue; |
736 | rule_idx++; | 776 | rule_idx++; |
@@ -749,8 +789,10 @@ static struct ieee80211_regdomain *regdom_intersect( | |||
749 | return rd; | 789 | return rd; |
750 | } | 790 | } |
751 | 791 | ||
752 | /* XXX: add support for the rest of enum nl80211_reg_rule_flags, we may | 792 | /* |
753 | * want to just have the channel structure use these */ | 793 | * XXX: add support for the rest of enum nl80211_reg_rule_flags, we may |
794 | * want to just have the channel structure use these | ||
795 | */ | ||
754 | static u32 map_regdom_flags(u32 rd_flags) | 796 | static u32 map_regdom_flags(u32 rd_flags) |
755 | { | 797 | { |
756 | u32 channel_flags = 0; | 798 | u32 channel_flags = 0; |
@@ -776,8 +818,10 @@ static int freq_reg_info_regd(struct wiphy *wiphy, | |||
776 | 818 | ||
777 | regd = custom_regd ? custom_regd : cfg80211_regdomain; | 819 | regd = custom_regd ? custom_regd : cfg80211_regdomain; |
778 | 820 | ||
779 | /* Follow the driver's regulatory domain, if present, unless a country | 821 | /* |
780 | * IE has been processed or a user wants to help complaince further */ | 822 | * Follow the driver's regulatory domain, if present, unless a country |
823 | * IE has been processed or a user wants to help complaince further | ||
824 | */ | ||
781 | if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE && | 825 | if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE && |
782 | last_request->initiator != REGDOM_SET_BY_USER && | 826 | last_request->initiator != REGDOM_SET_BY_USER && |
783 | wiphy->regd) | 827 | wiphy->regd) |
@@ -795,9 +839,11 @@ static int freq_reg_info_regd(struct wiphy *wiphy, | |||
795 | fr = &rr->freq_range; | 839 | fr = &rr->freq_range; |
796 | pr = &rr->power_rule; | 840 | pr = &rr->power_rule; |
797 | 841 | ||
798 | /* We only need to know if one frequency rule was | 842 | /* |
843 | * We only need to know if one frequency rule was | ||
799 | * was in center_freq's band, that's enough, so lets | 844 | * was in center_freq's band, that's enough, so lets |
800 | * not overwrite it once found */ | 845 | * not overwrite it once found |
846 | */ | ||
801 | if (!band_rule_found) | 847 | if (!band_rule_found) |
802 | band_rule_found = freq_in_rule_band(fr, center_freq); | 848 | band_rule_found = freq_in_rule_band(fr, center_freq); |
803 | 849 | ||
@@ -850,7 +896,8 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band, | |||
850 | &max_bandwidth, ®_rule); | 896 | &max_bandwidth, ®_rule); |
851 | 897 | ||
852 | if (r) { | 898 | if (r) { |
853 | /* This means no regulatory rule was found in the country IE | 899 | /* |
900 | * This means no regulatory rule was found in the country IE | ||
854 | * with a frequency range on the center_freq's band, since | 901 | * with a frequency range on the center_freq's band, since |
855 | * IEEE-802.11 allows for a country IE to have a subset of the | 902 | * IEEE-802.11 allows for a country IE to have a subset of the |
856 | * regulatory information provided in a country we ignore | 903 | * regulatory information provided in a country we ignore |
@@ -869,8 +916,10 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band, | |||
869 | chan->center_freq, wiphy_name(wiphy)); | 916 | chan->center_freq, wiphy_name(wiphy)); |
870 | #endif | 917 | #endif |
871 | } else { | 918 | } else { |
872 | /* In this case we know the country IE has at least one reg rule | 919 | /* |
873 | * for the band so we respect its band definitions */ | 920 | * In this case we know the country IE has at least one reg rule |
921 | * for the band so we respect its band definitions | ||
922 | */ | ||
874 | #ifdef CONFIG_CFG80211_REG_DEBUG | 923 | #ifdef CONFIG_CFG80211_REG_DEBUG |
875 | if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) | 924 | if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) |
876 | printk(KERN_DEBUG "cfg80211: Disabling " | 925 | printk(KERN_DEBUG "cfg80211: Disabling " |
@@ -889,9 +938,11 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band, | |||
889 | if (last_request->initiator == REGDOM_SET_BY_DRIVER && | 938 | if (last_request->initiator == REGDOM_SET_BY_DRIVER && |
890 | request_wiphy && request_wiphy == wiphy && | 939 | request_wiphy && request_wiphy == wiphy && |
891 | request_wiphy->strict_regulatory) { | 940 | request_wiphy->strict_regulatory) { |
892 | /* This gaurantees the driver's requested regulatory domain | 941 | /* |
942 | * This gaurantees the driver's requested regulatory domain | ||
893 | * will always be used as a base for further regulatory | 943 | * will always be used as a base for further regulatory |
894 | * settings */ | 944 | * settings |
945 | */ | ||
895 | chan->flags = chan->orig_flags = | 946 | chan->flags = chan->orig_flags = |
896 | map_regdom_flags(reg_rule->flags); | 947 | map_regdom_flags(reg_rule->flags); |
897 | chan->max_antenna_gain = chan->orig_mag = | 948 | chan->max_antenna_gain = chan->orig_mag = |
@@ -932,8 +983,10 @@ static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby) | |||
932 | if (setby == REGDOM_SET_BY_CORE && | 983 | if (setby == REGDOM_SET_BY_CORE && |
933 | wiphy->custom_regulatory) | 984 | wiphy->custom_regulatory) |
934 | return true; | 985 | return true; |
935 | /* wiphy->regd will be set once the device has its own | 986 | /* |
936 | * desired regulatory domain set */ | 987 | * wiphy->regd will be set once the device has its own |
988 | * desired regulatory domain set | ||
989 | */ | ||
937 | if (wiphy->strict_regulatory && !wiphy->regd && | 990 | if (wiphy->strict_regulatory && !wiphy->regd && |
938 | !is_world_regdom(last_request->alpha2)) | 991 | !is_world_regdom(last_request->alpha2)) |
939 | return true; | 992 | return true; |
@@ -1043,8 +1096,10 @@ static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd, | |||
1043 | return 0; | 1096 | return 0; |
1044 | } | 1097 | } |
1045 | 1098 | ||
1046 | /* Return value which can be used by ignore_request() to indicate | 1099 | /* |
1047 | * it has been determined we should intersect two regulatory domains */ | 1100 | * Return value which can be used by ignore_request() to indicate |
1101 | * it has been determined we should intersect two regulatory domains | ||
1102 | */ | ||
1048 | #define REG_INTERSECT 1 | 1103 | #define REG_INTERSECT 1 |
1049 | 1104 | ||
1050 | /* This has the logic which determines when a new request | 1105 | /* This has the logic which determines when a new request |
@@ -1084,8 +1139,10 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by, | |||
1084 | return -EOPNOTSUPP; | 1139 | return -EOPNOTSUPP; |
1085 | return -EALREADY; | 1140 | return -EALREADY; |
1086 | } | 1141 | } |
1087 | /* Two consecutive Country IE hints on the same wiphy. | 1142 | /* |
1088 | * This should be picked up early by the driver/stack */ | 1143 | * Two consecutive Country IE hints on the same wiphy. |
1144 | * This should be picked up early by the driver/stack | ||
1145 | */ | ||
1089 | if (WARN_ON(!alpha2_equal(cfg80211_regdomain->alpha2, | 1146 | if (WARN_ON(!alpha2_equal(cfg80211_regdomain->alpha2, |
1090 | alpha2))) | 1147 | alpha2))) |
1091 | return 0; | 1148 | return 0; |
@@ -1104,13 +1161,17 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by, | |||
1104 | case REGDOM_SET_BY_USER: | 1161 | case REGDOM_SET_BY_USER: |
1105 | if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) | 1162 | if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) |
1106 | return REG_INTERSECT; | 1163 | return REG_INTERSECT; |
1107 | /* If the user knows better the user should set the regdom | 1164 | /* |
1108 | * to their country before the IE is picked up */ | 1165 | * If the user knows better the user should set the regdom |
1166 | * to their country before the IE is picked up | ||
1167 | */ | ||
1109 | if (last_request->initiator == REGDOM_SET_BY_USER && | 1168 | if (last_request->initiator == REGDOM_SET_BY_USER && |
1110 | last_request->intersect) | 1169 | last_request->intersect) |
1111 | return -EOPNOTSUPP; | 1170 | return -EOPNOTSUPP; |
1112 | /* Process user requests only after previous user/driver/core | 1171 | /* |
1113 | * requests have been processed */ | 1172 | * Process user requests only after previous user/driver/core |
1173 | * requests have been processed | ||
1174 | */ | ||
1114 | if (last_request->initiator == REGDOM_SET_BY_CORE || | 1175 | if (last_request->initiator == REGDOM_SET_BY_CORE || |
1115 | last_request->initiator == REGDOM_SET_BY_DRIVER || | 1176 | last_request->initiator == REGDOM_SET_BY_DRIVER || |
1116 | last_request->initiator == REGDOM_SET_BY_USER) { | 1177 | last_request->initiator == REGDOM_SET_BY_USER) { |
@@ -1151,9 +1212,11 @@ int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by, | |||
1151 | } | 1212 | } |
1152 | intersect = true; | 1213 | intersect = true; |
1153 | } else if (r) { | 1214 | } else if (r) { |
1154 | /* If the regulatory domain being requested by the | 1215 | /* |
1216 | * If the regulatory domain being requested by the | ||
1155 | * driver has already been set just copy it to the | 1217 | * driver has already been set just copy it to the |
1156 | * wiphy */ | 1218 | * wiphy |
1219 | */ | ||
1157 | if (r == -EALREADY && set_by == REGDOM_SET_BY_DRIVER) { | 1220 | if (r == -EALREADY && set_by == REGDOM_SET_BY_DRIVER) { |
1158 | r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); | 1221 | r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); |
1159 | if (r) | 1222 | if (r) |
@@ -1363,9 +1426,11 @@ static bool reg_same_country_ie_hint(struct wiphy *wiphy, | |||
1363 | 1426 | ||
1364 | if (likely(request_wiphy != wiphy)) | 1427 | if (likely(request_wiphy != wiphy)) |
1365 | return !country_ie_integrity_changes(country_ie_checksum); | 1428 | return !country_ie_integrity_changes(country_ie_checksum); |
1366 | /* We should not have let these through at this point, they | 1429 | /* |
1430 | * We should not have let these through at this point, they | ||
1367 | * should have been picked up earlier by the first alpha2 check | 1431 | * should have been picked up earlier by the first alpha2 check |
1368 | * on the device */ | 1432 | * on the device |
1433 | */ | ||
1369 | if (WARN_ON(!country_ie_integrity_changes(country_ie_checksum))) | 1434 | if (WARN_ON(!country_ie_integrity_changes(country_ie_checksum))) |
1370 | return true; | 1435 | return true; |
1371 | return false; | 1436 | return false; |
@@ -1395,9 +1460,11 @@ void regulatory_hint_11d(struct wiphy *wiphy, | |||
1395 | if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) | 1460 | if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) |
1396 | goto out; | 1461 | goto out; |
1397 | 1462 | ||
1398 | /* Pending country IE processing, this can happen after we | 1463 | /* |
1464 | * Pending country IE processing, this can happen after we | ||
1399 | * call CRDA and wait for a response if a beacon was received before | 1465 | * call CRDA and wait for a response if a beacon was received before |
1400 | * we were able to process the last regulatory_hint_11d() call */ | 1466 | * we were able to process the last regulatory_hint_11d() call |
1467 | */ | ||
1401 | if (country_ie_regdomain) | 1468 | if (country_ie_regdomain) |
1402 | goto out; | 1469 | goto out; |
1403 | 1470 | ||
@@ -1409,34 +1476,44 @@ void regulatory_hint_11d(struct wiphy *wiphy, | |||
1409 | else if (country_ie[2] == 'O') | 1476 | else if (country_ie[2] == 'O') |
1410 | env = ENVIRON_OUTDOOR; | 1477 | env = ENVIRON_OUTDOOR; |
1411 | 1478 | ||
1412 | /* We will run this for *every* beacon processed for the BSSID, so | 1479 | /* |
1480 | * We will run this for *every* beacon processed for the BSSID, so | ||
1413 | * we optimize an early check to exit out early if we don't have to | 1481 | * we optimize an early check to exit out early if we don't have to |
1414 | * do anything */ | 1482 | * do anything |
1483 | */ | ||
1415 | if (likely(wiphy_idx_valid(last_request->wiphy_idx))) { | 1484 | if (likely(wiphy_idx_valid(last_request->wiphy_idx))) { |
1416 | struct cfg80211_registered_device *drv_last_ie; | 1485 | struct cfg80211_registered_device *drv_last_ie; |
1417 | 1486 | ||
1418 | drv_last_ie = | 1487 | drv_last_ie = |
1419 | cfg80211_drv_by_wiphy_idx(last_request->wiphy_idx); | 1488 | cfg80211_drv_by_wiphy_idx(last_request->wiphy_idx); |
1420 | 1489 | ||
1421 | /* Lets keep this simple -- we trust the first AP | 1490 | /* |
1422 | * after we intersect with CRDA */ | 1491 | * Lets keep this simple -- we trust the first AP |
1492 | * after we intersect with CRDA | ||
1493 | */ | ||
1423 | if (likely(&drv_last_ie->wiphy == wiphy)) { | 1494 | if (likely(&drv_last_ie->wiphy == wiphy)) { |
1424 | /* Ignore IEs coming in on this wiphy with | 1495 | /* |
1425 | * the same alpha2 and environment cap */ | 1496 | * Ignore IEs coming in on this wiphy with |
1497 | * the same alpha2 and environment cap | ||
1498 | */ | ||
1426 | if (likely(alpha2_equal(drv_last_ie->country_ie_alpha2, | 1499 | if (likely(alpha2_equal(drv_last_ie->country_ie_alpha2, |
1427 | alpha2) && | 1500 | alpha2) && |
1428 | env == drv_last_ie->env)) { | 1501 | env == drv_last_ie->env)) { |
1429 | goto out; | 1502 | goto out; |
1430 | } | 1503 | } |
1431 | /* the wiphy moved on to another BSSID or the AP | 1504 | /* |
1505 | * the wiphy moved on to another BSSID or the AP | ||
1432 | * was reconfigured. XXX: We need to deal with the | 1506 | * was reconfigured. XXX: We need to deal with the |
1433 | * case where the user suspends and goes to goes | 1507 | * case where the user suspends and goes to goes |
1434 | * to another country, and then gets IEs from an | 1508 | * to another country, and then gets IEs from an |
1435 | * AP with different settings */ | 1509 | * AP with different settings |
1510 | */ | ||
1436 | goto out; | 1511 | goto out; |
1437 | } else { | 1512 | } else { |
1438 | /* Ignore IEs coming in on two separate wiphys with | 1513 | /* |
1439 | * the same alpha2 and environment cap */ | 1514 | * Ignore IEs coming in on two separate wiphys with |
1515 | * the same alpha2 and environment cap | ||
1516 | */ | ||
1440 | if (likely(alpha2_equal(drv_last_ie->country_ie_alpha2, | 1517 | if (likely(alpha2_equal(drv_last_ie->country_ie_alpha2, |
1441 | alpha2) && | 1518 | alpha2) && |
1442 | env == drv_last_ie->env)) { | 1519 | env == drv_last_ie->env)) { |
@@ -1467,8 +1544,10 @@ void regulatory_hint_11d(struct wiphy *wiphy, | |||
1467 | if (!request) | 1544 | if (!request) |
1468 | goto free_rd_out; | 1545 | goto free_rd_out; |
1469 | 1546 | ||
1470 | /* We keep this around for when CRDA comes back with a response so | 1547 | /* |
1471 | * we can intersect with that */ | 1548 | * We keep this around for when CRDA comes back with a response so |
1549 | * we can intersect with that | ||
1550 | */ | ||
1472 | country_ie_regdomain = rd; | 1551 | country_ie_regdomain = rd; |
1473 | 1552 | ||
1474 | request->wiphy_idx = get_wiphy_idx(wiphy); | 1553 | request->wiphy_idx = get_wiphy_idx(wiphy); |
@@ -1506,8 +1585,10 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd) | |||
1506 | freq_range = ®_rule->freq_range; | 1585 | freq_range = ®_rule->freq_range; |
1507 | power_rule = ®_rule->power_rule; | 1586 | power_rule = ®_rule->power_rule; |
1508 | 1587 | ||
1509 | /* There may not be documentation for max antenna gain | 1588 | /* |
1510 | * in certain regions */ | 1589 | * There may not be documentation for max antenna gain |
1590 | * in certain regions | ||
1591 | */ | ||
1511 | if (power_rule->max_antenna_gain) | 1592 | if (power_rule->max_antenna_gain) |
1512 | printk(KERN_INFO "\t(%d KHz - %d KHz @ %d KHz), " | 1593 | printk(KERN_INFO "\t(%d KHz - %d KHz @ %d KHz), " |
1513 | "(%d mBi, %d mBm)\n", | 1594 | "(%d mBi, %d mBm)\n", |
@@ -1618,21 +1699,27 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
1618 | if (!last_request) | 1699 | if (!last_request) |
1619 | return -EINVAL; | 1700 | return -EINVAL; |
1620 | 1701 | ||
1621 | /* Lets only bother proceeding on the same alpha2 if the current | 1702 | /* |
1703 | * Lets only bother proceeding on the same alpha2 if the current | ||
1622 | * rd is non static (it means CRDA was present and was used last) | 1704 | * rd is non static (it means CRDA was present and was used last) |
1623 | * and the pending request came in from a country IE */ | 1705 | * and the pending request came in from a country IE |
1706 | */ | ||
1624 | if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) { | 1707 | if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) { |
1625 | /* If someone else asked us to change the rd lets only bother | 1708 | /* |
1626 | * checking if the alpha2 changes if CRDA was already called */ | 1709 | * If someone else asked us to change the rd lets only bother |
1710 | * checking if the alpha2 changes if CRDA was already called | ||
1711 | */ | ||
1627 | if (!is_old_static_regdom(cfg80211_regdomain) && | 1712 | if (!is_old_static_regdom(cfg80211_regdomain) && |
1628 | !regdom_changed(rd->alpha2)) | 1713 | !regdom_changed(rd->alpha2)) |
1629 | return -EINVAL; | 1714 | return -EINVAL; |
1630 | } | 1715 | } |
1631 | 1716 | ||
1632 | /* Now lets set the regulatory domain, update all driver channels | 1717 | /* |
1718 | * Now lets set the regulatory domain, update all driver channels | ||
1633 | * and finally inform them of what we have done, in case they want | 1719 | * and finally inform them of what we have done, in case they want |
1634 | * to review or adjust their own settings based on their own | 1720 | * to review or adjust their own settings based on their own |
1635 | * internal EEPROM data */ | 1721 | * internal EEPROM data |
1722 | */ | ||
1636 | 1723 | ||
1637 | if (WARN_ON(!reg_is_valid_request(rd->alpha2))) | 1724 | if (WARN_ON(!reg_is_valid_request(rd->alpha2))) |
1638 | return -EINVAL; | 1725 | return -EINVAL; |
@@ -1655,8 +1742,10 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
1655 | return 0; | 1742 | return 0; |
1656 | } | 1743 | } |
1657 | 1744 | ||
1658 | /* For a driver hint, lets copy the regulatory domain the | 1745 | /* |
1659 | * driver wanted to the wiphy to deal with conflicts */ | 1746 | * For a driver hint, lets copy the regulatory domain the |
1747 | * driver wanted to the wiphy to deal with conflicts | ||
1748 | */ | ||
1660 | 1749 | ||
1661 | BUG_ON(request_wiphy->regd); | 1750 | BUG_ON(request_wiphy->regd); |
1662 | 1751 | ||
@@ -1677,9 +1766,11 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
1677 | if (!intersected_rd) | 1766 | if (!intersected_rd) |
1678 | return -EINVAL; | 1767 | return -EINVAL; |
1679 | 1768 | ||
1680 | /* We can trash what CRDA provided now. | 1769 | /* |
1770 | * We can trash what CRDA provided now. | ||
1681 | * However if a driver requested this specific regulatory | 1771 | * However if a driver requested this specific regulatory |
1682 | * domain we keep it for its private use */ | 1772 | * domain we keep it for its private use |
1773 | */ | ||
1683 | if (last_request->initiator == REGDOM_SET_BY_DRIVER) | 1774 | if (last_request->initiator == REGDOM_SET_BY_DRIVER) |
1684 | request_wiphy->regd = rd; | 1775 | request_wiphy->regd = rd; |
1685 | else | 1776 | else |
@@ -1701,8 +1792,10 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
1701 | BUG_ON(!country_ie_regdomain); | 1792 | BUG_ON(!country_ie_regdomain); |
1702 | 1793 | ||
1703 | if (rd != country_ie_regdomain) { | 1794 | if (rd != country_ie_regdomain) { |
1704 | /* Intersect what CRDA returned and our what we | 1795 | /* |
1705 | * had built from the Country IE received */ | 1796 | * Intersect what CRDA returned and our what we |
1797 | * had built from the Country IE received | ||
1798 | */ | ||
1706 | 1799 | ||
1707 | intersected_rd = regdom_intersect(rd, country_ie_regdomain); | 1800 | intersected_rd = regdom_intersect(rd, country_ie_regdomain); |
1708 | 1801 | ||
@@ -1712,9 +1805,11 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
1712 | kfree(country_ie_regdomain); | 1805 | kfree(country_ie_regdomain); |
1713 | country_ie_regdomain = NULL; | 1806 | country_ie_regdomain = NULL; |
1714 | } else { | 1807 | } else { |
1715 | /* This would happen when CRDA was not present and | 1808 | /* |
1809 | * This would happen when CRDA was not present and | ||
1716 | * OLD_REGULATORY was enabled. We intersect our Country | 1810 | * OLD_REGULATORY was enabled. We intersect our Country |
1717 | * IE rd and what was set on cfg80211 originally */ | 1811 | * IE rd and what was set on cfg80211 originally |
1812 | */ | ||
1718 | intersected_rd = regdom_intersect(rd, cfg80211_regdomain); | 1813 | intersected_rd = regdom_intersect(rd, cfg80211_regdomain); |
1719 | } | 1814 | } |
1720 | 1815 | ||
@@ -1739,9 +1834,11 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
1739 | } | 1834 | } |
1740 | 1835 | ||
1741 | 1836 | ||
1742 | /* Use this call to set the current regulatory domain. Conflicts with | 1837 | /* |
1838 | * Use this call to set the current regulatory domain. Conflicts with | ||
1743 | * multiple drivers can be ironed out later. Caller must've already | 1839 | * multiple drivers can be ironed out later. Caller must've already |
1744 | * kmalloc'd the rd structure. Caller must hold cfg80211_mutex */ | 1840 | * kmalloc'd the rd structure. Caller must hold cfg80211_mutex |
1841 | */ | ||
1745 | int set_regdom(const struct ieee80211_regdomain *rd) | 1842 | int set_regdom(const struct ieee80211_regdomain *rd) |
1746 | { | 1843 | { |
1747 | int r; | 1844 | int r; |
@@ -1800,10 +1897,12 @@ int regulatory_init(void) | |||
1800 | 1897 | ||
1801 | printk(KERN_INFO "cfg80211: Using static regulatory domain info\n"); | 1898 | printk(KERN_INFO "cfg80211: Using static regulatory domain info\n"); |
1802 | print_regdomain_info(cfg80211_regdomain); | 1899 | print_regdomain_info(cfg80211_regdomain); |
1803 | /* The old code still requests for a new regdomain and if | 1900 | /* |
1901 | * The old code still requests for a new regdomain and if | ||
1804 | * you have CRDA you get it updated, otherwise you get | 1902 | * you have CRDA you get it updated, otherwise you get |
1805 | * stuck with the static values. We ignore "EU" code as | 1903 | * stuck with the static values. We ignore "EU" code as |
1806 | * that is not a valid ISO / IEC 3166 alpha2 */ | 1904 | * that is not a valid ISO / IEC 3166 alpha2 |
1905 | */ | ||
1807 | if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U') | 1906 | if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U') |
1808 | err = regulatory_hint_core(ieee80211_regdom); | 1907 | err = regulatory_hint_core(ieee80211_regdom); |
1809 | #else | 1908 | #else |