aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-01-20 17:37:10 -0500
committerDavid S. Miller <davem@davemloft.net>2009-01-20 17:37:10 -0500
commit518aa1b5443c8a36300c20a5473df01fb8975dad (patch)
tree0fe7200d4061dbfcd9b58b8f5f9264edbd9f7c05 /net
parent66f9a2590aa87dc77cddaeaf46177de76edd2339 (diff)
parent674743033c1ae9f7cc94e1e0037f6f719e6d1d67 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/sta_info.h1
-rw-r--r--net/wireless/reg.c128
2 files changed, 117 insertions, 12 deletions
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index dc2606d0ae77..e49a5b99cf10 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -195,7 +195,6 @@ struct sta_ampdu_mlme {
195 * @tx_packets: number of RX/TX MSDUs 195 * @tx_packets: number of RX/TX MSDUs
196 * @tx_bytes: number of bytes transmitted to this STA 196 * @tx_bytes: number of bytes transmitted to this STA
197 * @tx_fragments: number of transmitted MPDUs 197 * @tx_fragments: number of transmitted MPDUs
198 * @last_txrate: description of the last used transmit rate
199 * @tid_seq: per-TID sequence numbers for sending to this STA 198 * @tid_seq: per-TID sequence numbers for sending to this STA
200 * @ampdu_mlme: A-MPDU state machine state 199 * @ampdu_mlme: A-MPDU state machine state
201 * @timer_to_tid: identity mapping to ID timers 200 * @timer_to_tid: identity mapping to ID timers
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 4f877535e666..bc494cef2102 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -421,6 +421,31 @@ static u32 freq_max_bandwidth(const struct ieee80211_freq_range *freq_range,
421 return 0; 421 return 0;
422} 422}
423 423
424/**
425 * freq_in_rule_band - tells us if a frequency is in a frequency band
426 * @freq_range: frequency rule we want to query
427 * @freq_khz: frequency we are inquiring about
428 *
429 * This lets us know if a specific frequency rule is or is not relevant to
430 * a specific frequency's band. Bands are device specific and artificial
431 * definitions (the "2.4 GHz band" and the "5 GHz band"), however it is
432 * safe for now to assume that a frequency rule should not be part of a
433 * frequency's band if the start freq or end freq are off by more than 2 GHz.
434 * This resolution can be lowered and should be considered as we add
435 * regulatory rule support for other "bands".
436 **/
437static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
438 u32 freq_khz)
439{
440#define ONE_GHZ_IN_KHZ 1000000
441 if (abs(freq_khz - freq_range->start_freq_khz) <= (2 * ONE_GHZ_IN_KHZ))
442 return true;
443 if (abs(freq_khz - freq_range->end_freq_khz) <= (2 * ONE_GHZ_IN_KHZ))
444 return true;
445 return false;
446#undef ONE_GHZ_IN_KHZ
447}
448
424/* Converts a country IE to a regulatory domain. A regulatory domain 449/* Converts a country IE to a regulatory domain. A regulatory domain
425 * structure has a lot of information which the IE doesn't yet have, 450 * structure has a lot of information which the IE doesn't yet have,
426 * so for the other values we use upper max values as we will intersect 451 * so for the other values we use upper max values as we will intersect
@@ -538,6 +563,7 @@ static struct ieee80211_regdomain *country_ie_2_rd(
538 563
539 /* This time around we fill in the rd */ 564 /* This time around we fill in the rd */
540 while (country_ie_len >= 3) { 565 while (country_ie_len >= 3) {
566 int end_channel = 0;
541 struct ieee80211_country_ie_triplet *triplet = 567 struct ieee80211_country_ie_triplet *triplet =
542 (struct ieee80211_country_ie_triplet *) country_ie; 568 (struct ieee80211_country_ie_triplet *) country_ie;
543 struct ieee80211_reg_rule *reg_rule = NULL; 569 struct ieee80211_reg_rule *reg_rule = NULL;
@@ -559,6 +585,23 @@ static struct ieee80211_regdomain *country_ie_2_rd(
559 585
560 reg_rule->flags = flags; 586 reg_rule->flags = flags;
561 587
588 /* 2 GHz */
589 if (triplet->chans.first_channel <= 14)
590 end_channel = triplet->chans.first_channel +
591 triplet->chans.num_channels;
592 else
593 /*
594 * 5 GHz -- For example in country IEs if the first
595 * channel given is 36 and the number of channels is 4
596 * then the individual channel numbers defined for the
597 * 5 GHz PHY by these parameters are: 36, 40, 44, and 48
598 * and not 36, 37, 38, 39.
599 *
600 * See: http://tinyurl.com/11d-clarification
601 */
602 end_channel = triplet->chans.first_channel +
603 (4 * (triplet->chans.num_channels - 1));
604
562 /* The +10 is since the regulatory domain expects 605 /* The +10 is since the regulatory domain expects
563 * the actual band edge, not the center of freq for 606 * the actual band edge, not the center of freq for
564 * its start and end freqs, assuming 20 MHz bandwidth on 607 * its start and end freqs, assuming 20 MHz bandwidth on
@@ -568,8 +611,7 @@ static struct ieee80211_regdomain *country_ie_2_rd(
568 triplet->chans.first_channel) - 10); 611 triplet->chans.first_channel) - 10);
569 freq_range->end_freq_khz = 612 freq_range->end_freq_khz =
570 MHZ_TO_KHZ(ieee80211_channel_to_frequency( 613 MHZ_TO_KHZ(ieee80211_channel_to_frequency(
571 triplet->chans.first_channel + 614 end_channel) + 10);
572 triplet->chans.num_channels) + 10);
573 615
574 /* Large arbitrary values, we intersect later */ 616 /* Large arbitrary values, we intersect later */
575 /* Increment this if we ever support >= 40 MHz channels 617 /* Increment this if we ever support >= 40 MHz channels
@@ -748,12 +790,23 @@ static u32 map_regdom_flags(u32 rd_flags)
748 * this value to the maximum allowed bandwidth. 790 * this value to the maximum allowed bandwidth.
749 * @reg_rule: the regulatory rule which we have for this frequency 791 * @reg_rule: the regulatory rule which we have for this frequency
750 * 792 *
751 * Use this function to get the regulatory rule for a specific frequency. 793 * Use this function to get the regulatory rule for a specific frequency on
794 * a given wireless device. If the device has a specific regulatory domain
795 * it wants to follow we respect that unless a country IE has been received
796 * and processed already.
797 *
798 * Returns 0 if it was able to find a valid regulatory rule which does
799 * apply to the given center_freq otherwise it returns non-zero. It will
800 * also return -ERANGE if we determine the given center_freq does not even have
801 * a regulatory rule for a frequency range in the center_freq's band. See
802 * freq_in_rule_band() for our current definition of a band -- this is purely
803 * subjective and right now its 802.11 specific.
752 */ 804 */
753static int freq_reg_info(u32 center_freq, u32 *bandwidth, 805static int freq_reg_info(u32 center_freq, u32 *bandwidth,
754 const struct ieee80211_reg_rule **reg_rule) 806 const struct ieee80211_reg_rule **reg_rule)
755{ 807{
756 int i; 808 int i;
809 bool band_rule_found = false;
757 u32 max_bandwidth = 0; 810 u32 max_bandwidth = 0;
758 811
759 if (!cfg80211_regdomain) 812 if (!cfg80211_regdomain)
@@ -767,7 +820,15 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth,
767 rr = &cfg80211_regdomain->reg_rules[i]; 820 rr = &cfg80211_regdomain->reg_rules[i];
768 fr = &rr->freq_range; 821 fr = &rr->freq_range;
769 pr = &rr->power_rule; 822 pr = &rr->power_rule;
823
824 /* We only need to know if one frequency rule was
825 * was in center_freq's band, that's enough, so lets
826 * not overwrite it once found */
827 if (!band_rule_found)
828 band_rule_found = freq_in_rule_band(fr, center_freq);
829
770 max_bandwidth = freq_max_bandwidth(fr, center_freq); 830 max_bandwidth = freq_max_bandwidth(fr, center_freq);
831
771 if (max_bandwidth && *bandwidth <= max_bandwidth) { 832 if (max_bandwidth && *bandwidth <= max_bandwidth) {
772 *reg_rule = rr; 833 *reg_rule = rr;
773 *bandwidth = max_bandwidth; 834 *bandwidth = max_bandwidth;
@@ -775,23 +836,64 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth,
775 } 836 }
776 } 837 }
777 838
839 if (!band_rule_found)
840 return -ERANGE;
841
778 return !max_bandwidth; 842 return !max_bandwidth;
779} 843}
780 844
781static void handle_channel(struct ieee80211_channel *chan) 845static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
846 unsigned int chan_idx)
782{ 847{
783 int r; 848 int r;
784 u32 flags = chan->orig_flags; 849 u32 flags;
785 u32 max_bandwidth = 0; 850 u32 max_bandwidth = 0;
786 const struct ieee80211_reg_rule *reg_rule = NULL; 851 const struct ieee80211_reg_rule *reg_rule = NULL;
787 const struct ieee80211_power_rule *power_rule = NULL; 852 const struct ieee80211_power_rule *power_rule = NULL;
853 struct ieee80211_supported_band *sband;
854 struct ieee80211_channel *chan;
855
856 sband = wiphy->bands[band];
857 BUG_ON(chan_idx >= sband->n_channels);
858 chan = &sband->channels[chan_idx];
859
860 flags = chan->orig_flags;
788 861
789 r = freq_reg_info(MHZ_TO_KHZ(chan->center_freq), 862 r = freq_reg_info(MHZ_TO_KHZ(chan->center_freq),
790 &max_bandwidth, &reg_rule); 863 &max_bandwidth, &reg_rule);
791 864
792 if (r) { 865 if (r) {
793 flags |= IEEE80211_CHAN_DISABLED; 866 /* This means no regulatory rule was found in the country IE
794 chan->flags = flags; 867 * with a frequency range on the center_freq's band, since
868 * IEEE-802.11 allows for a country IE to have a subset of the
869 * regulatory information provided in a country we ignore
870 * disabling the channel unless at least one reg rule was
871 * found on the center_freq's band. For details see this
872 * clarification:
873 *
874 * http://tinyurl.com/11d-clarification
875 */
876 if (r == -ERANGE &&
877 last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
878#ifdef CONFIG_CFG80211_REG_DEBUG
879 printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz "
880 "intact on %s - no rule found in band on "
881 "Country IE\n",
882 chan->center_freq, wiphy_name(wiphy));
883#endif
884 } else {
885 /* In this case we know the country IE has at least one reg rule
886 * for the band so we respect its band definitions */
887#ifdef CONFIG_CFG80211_REG_DEBUG
888 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE)
889 printk(KERN_DEBUG "cfg80211: Disabling "
890 "channel %d MHz on %s due to "
891 "Country IE\n",
892 chan->center_freq, wiphy_name(wiphy));
893#endif
894 flags |= IEEE80211_CHAN_DISABLED;
895 chan->flags = flags;
896 }
795 return; 897 return;
796 } 898 }
797 899
@@ -808,12 +910,16 @@ static void handle_channel(struct ieee80211_channel *chan)
808 chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); 910 chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp);
809} 911}
810 912
811static void handle_band(struct ieee80211_supported_band *sband) 913static void handle_band(struct wiphy *wiphy, enum ieee80211_band band)
812{ 914{
813 int i; 915 unsigned int i;
916 struct ieee80211_supported_band *sband;
917
918 BUG_ON(!wiphy->bands[band]);
919 sband = wiphy->bands[band];
814 920
815 for (i = 0; i < sband->n_channels; i++) 921 for (i = 0; i < sband->n_channels; i++)
816 handle_channel(&sband->channels[i]); 922 handle_channel(wiphy, band, i);
817} 923}
818 924
819static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby) 925static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby)
@@ -840,7 +946,7 @@ void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby)
840 enum ieee80211_band band; 946 enum ieee80211_band band;
841 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 947 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
842 if (wiphy->bands[band]) 948 if (wiphy->bands[band])
843 handle_band(wiphy->bands[band]); 949 handle_band(wiphy, band);
844 if (wiphy->reg_notifier) 950 if (wiphy->reg_notifier)
845 wiphy->reg_notifier(wiphy, setby); 951 wiphy->reg_notifier(wiphy, setby);
846 } 952 }