aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/reg.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r--net/wireless/reg.c122
1 files changed, 34 insertions, 88 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 547ceecc0523..c5fb317eee68 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -60,13 +60,6 @@
60#include "regdb.h" 60#include "regdb.h"
61#include "nl80211.h" 61#include "nl80211.h"
62 62
63#ifdef CONFIG_CFG80211_REG_DEBUG
64#define REG_DBG_PRINT(format, args...) \
65 printk(KERN_DEBUG pr_fmt(format), ##args)
66#else
67#define REG_DBG_PRINT(args...)
68#endif
69
70/* 63/*
71 * Grace period we give before making sure all current interfaces reside on 64 * Grace period we give before making sure all current interfaces reside on
72 * channels allowed by the current regulatory domain. 65 * channels allowed by the current regulatory domain.
@@ -178,12 +171,10 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy)
178 if (wiphy_regd->dfs_region == regd->dfs_region) 171 if (wiphy_regd->dfs_region == regd->dfs_region)
179 goto out; 172 goto out;
180 173
181 REG_DBG_PRINT("%s: device specific dfs_region " 174 pr_debug("%s: device specific dfs_region (%s) disagrees with cfg80211's central dfs_region (%s)\n",
182 "(%s) disagrees with cfg80211's " 175 dev_name(&wiphy->dev),
183 "central dfs_region (%s)\n", 176 reg_dfs_region_str(wiphy_regd->dfs_region),
184 dev_name(&wiphy->dev), 177 reg_dfs_region_str(regd->dfs_region));
185 reg_dfs_region_str(wiphy_regd->dfs_region),
186 reg_dfs_region_str(regd->dfs_region));
187 178
188out: 179out:
189 return regd->dfs_region; 180 return regd->dfs_region;
@@ -543,7 +534,7 @@ static DECLARE_DELAYED_WORK(crda_timeout, crda_timeout_work);
543 534
544static void crda_timeout_work(struct work_struct *work) 535static void crda_timeout_work(struct work_struct *work)
545{ 536{
546 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n"); 537 pr_debug("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
547 rtnl_lock(); 538 rtnl_lock();
548 reg_crda_timeouts++; 539 reg_crda_timeouts++;
549 restore_regulatory_settings(true); 540 restore_regulatory_settings(true);
@@ -585,7 +576,7 @@ static int call_crda(const char *alpha2)
585 576
586 if (!is_world_regdom((char *) alpha2)) 577 if (!is_world_regdom((char *) alpha2))
587 pr_debug("Calling CRDA for country: %c%c\n", 578 pr_debug("Calling CRDA for country: %c%c\n",
588 alpha2[0], alpha2[1]); 579 alpha2[0], alpha2[1]);
589 else 580 else
590 pr_debug("Calling CRDA to update world regulatory domain\n"); 581 pr_debug("Calling CRDA to update world regulatory domain\n");
591 582
@@ -1132,42 +1123,6 @@ const char *reg_initiator_name(enum nl80211_reg_initiator initiator)
1132} 1123}
1133EXPORT_SYMBOL(reg_initiator_name); 1124EXPORT_SYMBOL(reg_initiator_name);
1134 1125
1135static void chan_reg_rule_print_dbg(const struct ieee80211_regdomain *regd,
1136 struct ieee80211_channel *chan,
1137 const struct ieee80211_reg_rule *reg_rule)
1138{
1139#ifdef CONFIG_CFG80211_REG_DEBUG
1140 const struct ieee80211_power_rule *power_rule;
1141 const struct ieee80211_freq_range *freq_range;
1142 char max_antenna_gain[32], bw[32];
1143
1144 power_rule = &reg_rule->power_rule;
1145 freq_range = &reg_rule->freq_range;
1146
1147 if (!power_rule->max_antenna_gain)
1148 snprintf(max_antenna_gain, sizeof(max_antenna_gain), "N/A");
1149 else
1150 snprintf(max_antenna_gain, sizeof(max_antenna_gain), "%d mBi",
1151 power_rule->max_antenna_gain);
1152
1153 if (reg_rule->flags & NL80211_RRF_AUTO_BW)
1154 snprintf(bw, sizeof(bw), "%d KHz, %d KHz AUTO",
1155 freq_range->max_bandwidth_khz,
1156 reg_get_max_bandwidth(regd, reg_rule));
1157 else
1158 snprintf(bw, sizeof(bw), "%d KHz",
1159 freq_range->max_bandwidth_khz);
1160
1161 REG_DBG_PRINT("Updating information on frequency %d MHz with regulatory rule:\n",
1162 chan->center_freq);
1163
1164 REG_DBG_PRINT("(%d KHz - %d KHz @ %s), (%s, %d mBm)\n",
1165 freq_range->start_freq_khz, freq_range->end_freq_khz,
1166 bw, max_antenna_gain,
1167 power_rule->max_eirp);
1168#endif
1169}
1170
1171static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd, 1126static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd,
1172 const struct ieee80211_reg_rule *reg_rule, 1127 const struct ieee80211_reg_rule *reg_rule,
1173 const struct ieee80211_channel *chan) 1128 const struct ieee80211_channel *chan)
@@ -1242,20 +1197,19 @@ static void handle_channel(struct wiphy *wiphy,
1242 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && 1197 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
1243 request_wiphy && request_wiphy == wiphy && 1198 request_wiphy && request_wiphy == wiphy &&
1244 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { 1199 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) {
1245 REG_DBG_PRINT("Disabling freq %d MHz for good\n", 1200 pr_debug("Disabling freq %d MHz for good\n",
1246 chan->center_freq); 1201 chan->center_freq);
1247 chan->orig_flags |= IEEE80211_CHAN_DISABLED; 1202 chan->orig_flags |= IEEE80211_CHAN_DISABLED;
1248 chan->flags = chan->orig_flags; 1203 chan->flags = chan->orig_flags;
1249 } else { 1204 } else {
1250 REG_DBG_PRINT("Disabling freq %d MHz\n", 1205 pr_debug("Disabling freq %d MHz\n",
1251 chan->center_freq); 1206 chan->center_freq);
1252 chan->flags |= IEEE80211_CHAN_DISABLED; 1207 chan->flags |= IEEE80211_CHAN_DISABLED;
1253 } 1208 }
1254 return; 1209 return;
1255 } 1210 }
1256 1211
1257 regd = reg_get_regdomain(wiphy); 1212 regd = reg_get_regdomain(wiphy);
1258 chan_reg_rule_print_dbg(regd, chan, reg_rule);
1259 1213
1260 power_rule = &reg_rule->power_rule; 1214 power_rule = &reg_rule->power_rule;
1261 bw_flags = reg_rule_to_chan_bw_flags(regd, reg_rule, chan); 1215 bw_flags = reg_rule_to_chan_bw_flags(regd, reg_rule, chan);
@@ -1393,18 +1347,15 @@ static bool ignore_reg_update(struct wiphy *wiphy,
1393 return true; 1347 return true;
1394 1348
1395 if (!lr) { 1349 if (!lr) {
1396 REG_DBG_PRINT("Ignoring regulatory request set by %s " 1350 pr_debug("Ignoring regulatory request set by %s since last_request is not set\n",
1397 "since last_request is not set\n", 1351 reg_initiator_name(initiator));
1398 reg_initiator_name(initiator));
1399 return true; 1352 return true;
1400 } 1353 }
1401 1354
1402 if (initiator == NL80211_REGDOM_SET_BY_CORE && 1355 if (initiator == NL80211_REGDOM_SET_BY_CORE &&
1403 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) { 1356 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) {
1404 REG_DBG_PRINT("Ignoring regulatory request set by %s " 1357 pr_debug("Ignoring regulatory request set by %s since the driver uses its own custom regulatory domain\n",
1405 "since the driver uses its own custom " 1358 reg_initiator_name(initiator));
1406 "regulatory domain\n",
1407 reg_initiator_name(initiator));
1408 return true; 1359 return true;
1409 } 1360 }
1410 1361
@@ -1415,10 +1366,8 @@ static bool ignore_reg_update(struct wiphy *wiphy,
1415 if (wiphy_strict_alpha2_regd(wiphy) && !wiphy->regd && 1366 if (wiphy_strict_alpha2_regd(wiphy) && !wiphy->regd &&
1416 initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && 1367 initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
1417 !is_world_regdom(lr->alpha2)) { 1368 !is_world_regdom(lr->alpha2)) {
1418 REG_DBG_PRINT("Ignoring regulatory request set by %s " 1369 pr_debug("Ignoring regulatory request set by %s since the driver requires its own regulatory domain to be set first\n",
1419 "since the driver requires its own regulatory " 1370 reg_initiator_name(initiator));
1420 "domain to be set first\n",
1421 reg_initiator_name(initiator));
1422 return true; 1371 return true;
1423 } 1372 }
1424 1373
@@ -1699,7 +1648,7 @@ static void reg_check_chans_work(struct work_struct *work)
1699{ 1648{
1700 struct cfg80211_registered_device *rdev; 1649 struct cfg80211_registered_device *rdev;
1701 1650
1702 REG_DBG_PRINT("Verifying active interfaces after reg change\n"); 1651 pr_debug("Verifying active interfaces after reg change\n");
1703 rtnl_lock(); 1652 rtnl_lock();
1704 1653
1705 list_for_each_entry(rdev, &cfg80211_rdev_list, list) 1654 list_for_each_entry(rdev, &cfg80211_rdev_list, list)
@@ -1781,8 +1730,8 @@ static void handle_channel_custom(struct wiphy *wiphy,
1781 } 1730 }
1782 1731
1783 if (IS_ERR(reg_rule)) { 1732 if (IS_ERR(reg_rule)) {
1784 REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits it\n", 1733 pr_debug("Disabling freq %d MHz as custom regd has no rule that fits it\n",
1785 chan->center_freq); 1734 chan->center_freq);
1786 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { 1735 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) {
1787 chan->flags |= IEEE80211_CHAN_DISABLED; 1736 chan->flags |= IEEE80211_CHAN_DISABLED;
1788 } else { 1737 } else {
@@ -1792,8 +1741,6 @@ static void handle_channel_custom(struct wiphy *wiphy,
1792 return; 1741 return;
1793 } 1742 }
1794 1743
1795 chan_reg_rule_print_dbg(regd, chan, reg_rule);
1796
1797 power_rule = &reg_rule->power_rule; 1744 power_rule = &reg_rule->power_rule;
1798 bw_flags = reg_rule_to_chan_bw_flags(regd, reg_rule, chan); 1745 bw_flags = reg_rule_to_chan_bw_flags(regd, reg_rule, chan);
1799 1746
@@ -2524,7 +2471,7 @@ static void restore_alpha2(char *alpha2, bool reset_user)
2524 if (is_user_regdom_saved()) { 2471 if (is_user_regdom_saved()) {
2525 /* Unless we're asked to ignore it and reset it */ 2472 /* Unless we're asked to ignore it and reset it */
2526 if (reset_user) { 2473 if (reset_user) {
2527 REG_DBG_PRINT("Restoring regulatory settings including user preference\n"); 2474 pr_debug("Restoring regulatory settings including user preference\n");
2528 user_alpha2[0] = '9'; 2475 user_alpha2[0] = '9';
2529 user_alpha2[1] = '7'; 2476 user_alpha2[1] = '7';
2530 2477
@@ -2534,24 +2481,24 @@ static void restore_alpha2(char *alpha2, bool reset_user)
2534 * back as they were for a full restore. 2481 * back as they were for a full restore.
2535 */ 2482 */
2536 if (!is_world_regdom(ieee80211_regdom)) { 2483 if (!is_world_regdom(ieee80211_regdom)) {
2537 REG_DBG_PRINT("Keeping preference on module parameter ieee80211_regdom: %c%c\n", 2484 pr_debug("Keeping preference on module parameter ieee80211_regdom: %c%c\n",
2538 ieee80211_regdom[0], ieee80211_regdom[1]); 2485 ieee80211_regdom[0], ieee80211_regdom[1]);
2539 alpha2[0] = ieee80211_regdom[0]; 2486 alpha2[0] = ieee80211_regdom[0];
2540 alpha2[1] = ieee80211_regdom[1]; 2487 alpha2[1] = ieee80211_regdom[1];
2541 } 2488 }
2542 } else { 2489 } else {
2543 REG_DBG_PRINT("Restoring regulatory settings while preserving user preference for: %c%c\n", 2490 pr_debug("Restoring regulatory settings while preserving user preference for: %c%c\n",
2544 user_alpha2[0], user_alpha2[1]); 2491 user_alpha2[0], user_alpha2[1]);
2545 alpha2[0] = user_alpha2[0]; 2492 alpha2[0] = user_alpha2[0];
2546 alpha2[1] = user_alpha2[1]; 2493 alpha2[1] = user_alpha2[1];
2547 } 2494 }
2548 } else if (!is_world_regdom(ieee80211_regdom)) { 2495 } else if (!is_world_regdom(ieee80211_regdom)) {
2549 REG_DBG_PRINT("Keeping preference on module parameter ieee80211_regdom: %c%c\n", 2496 pr_debug("Keeping preference on module parameter ieee80211_regdom: %c%c\n",
2550 ieee80211_regdom[0], ieee80211_regdom[1]); 2497 ieee80211_regdom[0], ieee80211_regdom[1]);
2551 alpha2[0] = ieee80211_regdom[0]; 2498 alpha2[0] = ieee80211_regdom[0];
2552 alpha2[1] = ieee80211_regdom[1]; 2499 alpha2[1] = ieee80211_regdom[1];
2553 } else 2500 } else
2554 REG_DBG_PRINT("Restoring regulatory settings\n"); 2501 pr_debug("Restoring regulatory settings\n");
2555} 2502}
2556 2503
2557static void restore_custom_reg_settings(struct wiphy *wiphy) 2504static void restore_custom_reg_settings(struct wiphy *wiphy)
@@ -2663,14 +2610,14 @@ static void restore_regulatory_settings(bool reset_user)
2663 list_splice_tail_init(&tmp_reg_req_list, &reg_requests_list); 2610 list_splice_tail_init(&tmp_reg_req_list, &reg_requests_list);
2664 spin_unlock(&reg_requests_lock); 2611 spin_unlock(&reg_requests_lock);
2665 2612
2666 REG_DBG_PRINT("Kicking the queue\n"); 2613 pr_debug("Kicking the queue\n");
2667 2614
2668 schedule_work(&reg_work); 2615 schedule_work(&reg_work);
2669} 2616}
2670 2617
2671void regulatory_hint_disconnect(void) 2618void regulatory_hint_disconnect(void)
2672{ 2619{
2673 REG_DBG_PRINT("All devices are disconnected, going to restore regulatory settings\n"); 2620 pr_debug("All devices are disconnected, going to restore regulatory settings\n");
2674 restore_regulatory_settings(false); 2621 restore_regulatory_settings(false);
2675} 2622}
2676 2623
@@ -2718,10 +2665,10 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy,
2718 if (!reg_beacon) 2665 if (!reg_beacon)
2719 return -ENOMEM; 2666 return -ENOMEM;
2720 2667
2721 REG_DBG_PRINT("Found new beacon on frequency: %d MHz (Ch %d) on %s\n", 2668 pr_debug("Found new beacon on frequency: %d MHz (Ch %d) on %s\n",
2722 beacon_chan->center_freq, 2669 beacon_chan->center_freq,
2723 ieee80211_frequency_to_channel(beacon_chan->center_freq), 2670 ieee80211_frequency_to_channel(beacon_chan->center_freq),
2724 wiphy_name(wiphy)); 2671 wiphy_name(wiphy));
2725 2672
2726 memcpy(&reg_beacon->chan, beacon_chan, 2673 memcpy(&reg_beacon->chan, beacon_chan,
2727 sizeof(struct ieee80211_channel)); 2674 sizeof(struct ieee80211_channel));
@@ -2800,8 +2747,7 @@ bool reg_supported_dfs_region(enum nl80211_dfs_regions dfs_region)
2800 case NL80211_DFS_JP: 2747 case NL80211_DFS_JP:
2801 return true; 2748 return true;
2802 default: 2749 default:
2803 REG_DBG_PRINT("Ignoring uknown DFS master region: %d\n", 2750 pr_debug("Ignoring uknown DFS master region: %d\n", dfs_region);
2804 dfs_region);
2805 return false; 2751 return false;
2806 } 2752 }
2807} 2753}