aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-03-09 22:07:41 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-03-16 18:09:40 -0400
commit7db90f4a25bd4184f3d36dfa4f512f53b0448da7 (patch)
tree839b8103801cac9342763e1b62e84730a8050ccc /net/wireless
parent0fee54cab7d5ebc58fad8c6a0703c4ea016405e3 (diff)
cfg80211: move enum reg_set_by to nl80211.h
We do this so we can later inform userspace who set the regulatory domain and provide details of the request. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/core.c2
-rw-r--r--net/wireless/core.h3
-rw-r--r--net/wireless/reg.c82
3 files changed, 48 insertions, 39 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c
index dd7f222919fe..c939f5ee065e 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -350,7 +350,7 @@ int wiphy_register(struct wiphy *wiphy)
350 mutex_lock(&cfg80211_mutex); 350 mutex_lock(&cfg80211_mutex);
351 351
352 /* set up regulatory info */ 352 /* set up regulatory info */
353 wiphy_update_regulatory(wiphy, REGDOM_SET_BY_CORE); 353 wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
354 354
355 res = device_add(&drv->wiphy.dev); 355 res = device_add(&drv->wiphy.dev);
356 if (res) 356 if (res)
diff --git a/net/wireless/core.h b/net/wireless/core.h
index f6c53f5807f4..6acd483a61f8 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -136,7 +136,8 @@ extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv,
136 char *newname); 136 char *newname);
137 137
138void ieee80211_set_bitrate_flags(struct wiphy *wiphy); 138void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
139void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby); 139void wiphy_update_regulatory(struct wiphy *wiphy,
140 enum nl80211_reg_initiator setby);
140 141
141void cfg80211_bss_expire(struct cfg80211_registered_device *dev); 142void cfg80211_bss_expire(struct cfg80211_registered_device *dev);
142void cfg80211_bss_age(struct cfg80211_registered_device *dev, 143void cfg80211_bss_age(struct cfg80211_registered_device *dev,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 47ff44751b70..68fde6d33dc3 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -857,8 +857,8 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
857 * Follow the driver's regulatory domain, if present, unless a country 857 * Follow the driver's regulatory domain, if present, unless a country
858 * IE has been processed or a user wants to help complaince further 858 * IE has been processed or a user wants to help complaince further
859 */ 859 */
860 if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE && 860 if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
861 last_request->initiator != REGDOM_SET_BY_USER && 861 last_request->initiator != NL80211_REGDOM_SET_BY_USER &&
862 wiphy->regd) 862 wiphy->regd)
863 regd = wiphy->regd; 863 regd = wiphy->regd;
864 864
@@ -943,7 +943,8 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
943 * http://tinyurl.com/11d-clarification 943 * http://tinyurl.com/11d-clarification
944 */ 944 */
945 if (r == -ERANGE && 945 if (r == -ERANGE &&
946 last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) { 946 last_request->initiator ==
947 NL80211_REGDOM_SET_BY_COUNTRY_IE) {
947#ifdef CONFIG_CFG80211_REG_DEBUG 948#ifdef CONFIG_CFG80211_REG_DEBUG
948 printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz " 949 printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz "
949 "intact on %s - no rule found in band on " 950 "intact on %s - no rule found in band on "
@@ -956,7 +957,8 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
956 * for the band so we respect its band definitions 957 * for the band so we respect its band definitions
957 */ 958 */
958#ifdef CONFIG_CFG80211_REG_DEBUG 959#ifdef CONFIG_CFG80211_REG_DEBUG
959 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) 960 if (last_request->initiator ==
961 NL80211_REGDOM_SET_BY_COUNTRY_IE)
960 printk(KERN_DEBUG "cfg80211: Disabling " 962 printk(KERN_DEBUG "cfg80211: Disabling "
961 "channel %d MHz on %s due to " 963 "channel %d MHz on %s due to "
962 "Country IE\n", 964 "Country IE\n",
@@ -970,7 +972,7 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
970 972
971 power_rule = &reg_rule->power_rule; 973 power_rule = &reg_rule->power_rule;
972 974
973 if (last_request->initiator == REGDOM_SET_BY_DRIVER && 975 if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
974 request_wiphy && request_wiphy == wiphy && 976 request_wiphy && request_wiphy == wiphy &&
975 request_wiphy->strict_regulatory) { 977 request_wiphy->strict_regulatory) {
976 /* 978 /*
@@ -1011,11 +1013,12 @@ static void handle_band(struct wiphy *wiphy, enum ieee80211_band band)
1011 handle_channel(wiphy, band, i); 1013 handle_channel(wiphy, band, i);
1012} 1014}
1013 1015
1014static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby) 1016static bool ignore_reg_update(struct wiphy *wiphy,
1017 enum nl80211_reg_initiator initiator)
1015{ 1018{
1016 if (!last_request) 1019 if (!last_request)
1017 return true; 1020 return true;
1018 if (setby == REGDOM_SET_BY_CORE && 1021 if (initiator == NL80211_REGDOM_SET_BY_CORE &&
1019 wiphy->custom_regulatory) 1022 wiphy->custom_regulatory)
1020 return true; 1023 return true;
1021 /* 1024 /*
@@ -1028,12 +1031,12 @@ static bool ignore_reg_update(struct wiphy *wiphy, enum reg_set_by setby)
1028 return false; 1031 return false;
1029} 1032}
1030 1033
1031static void update_all_wiphy_regulatory(enum reg_set_by setby) 1034static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator)
1032{ 1035{
1033 struct cfg80211_registered_device *drv; 1036 struct cfg80211_registered_device *drv;
1034 1037
1035 list_for_each_entry(drv, &cfg80211_drv_list, list) 1038 list_for_each_entry(drv, &cfg80211_drv_list, list)
1036 wiphy_update_regulatory(&drv->wiphy, setby); 1039 wiphy_update_regulatory(&drv->wiphy, initiator);
1037} 1040}
1038 1041
1039static void handle_reg_beacon(struct wiphy *wiphy, 1042static void handle_reg_beacon(struct wiphy *wiphy,
@@ -1124,7 +1127,7 @@ static bool reg_is_world_roaming(struct wiphy *wiphy)
1124 if (is_world_regdom(cfg80211_regdomain->alpha2) || 1127 if (is_world_regdom(cfg80211_regdomain->alpha2) ||
1125 (wiphy->regd && is_world_regdom(wiphy->regd->alpha2))) 1128 (wiphy->regd && is_world_regdom(wiphy->regd->alpha2)))
1126 return true; 1129 return true;
1127 if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE && 1130 if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
1128 wiphy->custom_regulatory) 1131 wiphy->custom_regulatory)
1129 return true; 1132 return true;
1130 return false; 1133 return false;
@@ -1138,11 +1141,12 @@ static void reg_process_beacons(struct wiphy *wiphy)
1138 wiphy_update_beacon_reg(wiphy); 1141 wiphy_update_beacon_reg(wiphy);
1139} 1142}
1140 1143
1141void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby) 1144void wiphy_update_regulatory(struct wiphy *wiphy,
1145 enum nl80211_reg_initiator initiator)
1142{ 1146{
1143 enum ieee80211_band band; 1147 enum ieee80211_band band;
1144 1148
1145 if (ignore_reg_update(wiphy, setby)) 1149 if (ignore_reg_update(wiphy, initiator))
1146 goto out; 1150 goto out;
1147 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 1151 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1148 if (wiphy->bands[band]) 1152 if (wiphy->bands[band])
@@ -1255,15 +1259,16 @@ static int ignore_request(struct wiphy *wiphy,
1255 return 0; 1259 return 0;
1256 1260
1257 switch (pending_request->initiator) { 1261 switch (pending_request->initiator) {
1258 case REGDOM_SET_BY_CORE: 1262 case NL80211_REGDOM_SET_BY_CORE:
1259 return -EINVAL; 1263 return -EINVAL;
1260 case REGDOM_SET_BY_COUNTRY_IE: 1264 case NL80211_REGDOM_SET_BY_COUNTRY_IE:
1261 1265
1262 last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 1266 last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx);
1263 1267
1264 if (unlikely(!is_an_alpha2(pending_request->alpha2))) 1268 if (unlikely(!is_an_alpha2(pending_request->alpha2)))
1265 return -EINVAL; 1269 return -EINVAL;
1266 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) { 1270 if (last_request->initiator ==
1271 NL80211_REGDOM_SET_BY_COUNTRY_IE) {
1267 if (last_wiphy != wiphy) { 1272 if (last_wiphy != wiphy) {
1268 /* 1273 /*
1269 * Two cards with two APs claiming different 1274 * Two cards with two APs claiming different
@@ -1284,8 +1289,8 @@ static int ignore_request(struct wiphy *wiphy,
1284 return -EALREADY; 1289 return -EALREADY;
1285 } 1290 }
1286 return REG_INTERSECT; 1291 return REG_INTERSECT;
1287 case REGDOM_SET_BY_DRIVER: 1292 case NL80211_REGDOM_SET_BY_DRIVER:
1288 if (last_request->initiator == REGDOM_SET_BY_CORE) { 1293 if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE) {
1289 if (is_old_static_regdom(cfg80211_regdomain)) 1294 if (is_old_static_regdom(cfg80211_regdomain))
1290 return 0; 1295 return 0;
1291 if (regdom_changes(pending_request->alpha2)) 1296 if (regdom_changes(pending_request->alpha2))
@@ -1298,28 +1303,28 @@ static int ignore_request(struct wiphy *wiphy,
1298 * back in or if you add a new device for which the previously 1303 * back in or if you add a new device for which the previously
1299 * loaded card also agrees on the regulatory domain. 1304 * loaded card also agrees on the regulatory domain.
1300 */ 1305 */
1301 if (last_request->initiator == REGDOM_SET_BY_DRIVER && 1306 if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
1302 !regdom_changes(pending_request->alpha2)) 1307 !regdom_changes(pending_request->alpha2))
1303 return -EALREADY; 1308 return -EALREADY;
1304 1309
1305 return REG_INTERSECT; 1310 return REG_INTERSECT;
1306 case REGDOM_SET_BY_USER: 1311 case NL80211_REGDOM_SET_BY_USER:
1307 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) 1312 if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE)
1308 return REG_INTERSECT; 1313 return REG_INTERSECT;
1309 /* 1314 /*
1310 * If the user knows better the user should set the regdom 1315 * If the user knows better the user should set the regdom
1311 * to their country before the IE is picked up 1316 * to their country before the IE is picked up
1312 */ 1317 */
1313 if (last_request->initiator == REGDOM_SET_BY_USER && 1318 if (last_request->initiator == NL80211_REGDOM_SET_BY_USER &&
1314 last_request->intersect) 1319 last_request->intersect)
1315 return -EOPNOTSUPP; 1320 return -EOPNOTSUPP;
1316 /* 1321 /*
1317 * Process user requests only after previous user/driver/core 1322 * Process user requests only after previous user/driver/core
1318 * requests have been processed 1323 * requests have been processed
1319 */ 1324 */
1320 if (last_request->initiator == REGDOM_SET_BY_CORE || 1325 if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE ||
1321 last_request->initiator == REGDOM_SET_BY_DRIVER || 1326 last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER ||
1322 last_request->initiator == REGDOM_SET_BY_USER) { 1327 last_request->initiator == NL80211_REGDOM_SET_BY_USER) {
1323 if (regdom_changes(last_request->alpha2)) 1328 if (regdom_changes(last_request->alpha2))
1324 return -EAGAIN; 1329 return -EAGAIN;
1325 } 1330 }
@@ -1359,7 +1364,8 @@ static int __regulatory_hint(struct wiphy *wiphy,
1359 r = ignore_request(wiphy, pending_request); 1364 r = ignore_request(wiphy, pending_request);
1360 1365
1361 if (r == REG_INTERSECT) { 1366 if (r == REG_INTERSECT) {
1362 if (pending_request->initiator == REGDOM_SET_BY_DRIVER) { 1367 if (pending_request->initiator ==
1368 NL80211_REGDOM_SET_BY_DRIVER) {
1363 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); 1369 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
1364 if (r) { 1370 if (r) {
1365 kfree(pending_request); 1371 kfree(pending_request);
@@ -1374,7 +1380,8 @@ static int __regulatory_hint(struct wiphy *wiphy,
1374 * wiphy 1380 * wiphy
1375 */ 1381 */
1376 if (r == -EALREADY && 1382 if (r == -EALREADY &&
1377 pending_request->initiator == REGDOM_SET_BY_DRIVER) { 1383 pending_request->initiator ==
1384 NL80211_REGDOM_SET_BY_DRIVER) {
1378 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); 1385 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
1379 if (r) { 1386 if (r) {
1380 kfree(pending_request); 1387 kfree(pending_request);
@@ -1425,7 +1432,7 @@ static void reg_process_hint(struct regulatory_request *reg_request)
1425 if (wiphy_idx_valid(reg_request->wiphy_idx)) 1432 if (wiphy_idx_valid(reg_request->wiphy_idx))
1426 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); 1433 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
1427 1434
1428 if (reg_request->initiator == REGDOM_SET_BY_DRIVER && 1435 if (reg_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
1429 !wiphy) { 1436 !wiphy) {
1430 kfree(reg_request); 1437 kfree(reg_request);
1431 goto out; 1438 goto out;
@@ -1439,7 +1446,7 @@ out:
1439 mutex_unlock(&cfg80211_mutex); 1446 mutex_unlock(&cfg80211_mutex);
1440} 1447}
1441 1448
1442/* Processes regulatory hints, this is all the REGDOM_SET_BY_* */ 1449/* Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_* */
1443static void reg_process_pending_hints(void) 1450static void reg_process_pending_hints(void)
1444 { 1451 {
1445 struct regulatory_request *reg_request; 1452 struct regulatory_request *reg_request;
@@ -1523,7 +1530,7 @@ static int regulatory_hint_core(const char *alpha2)
1523 1530
1524 request->alpha2[0] = alpha2[0]; 1531 request->alpha2[0] = alpha2[0];
1525 request->alpha2[1] = alpha2[1]; 1532 request->alpha2[1] = alpha2[1];
1526 request->initiator = REGDOM_SET_BY_CORE; 1533 request->initiator = NL80211_REGDOM_SET_BY_CORE;
1527 1534
1528 queue_regulatory_request(request); 1535 queue_regulatory_request(request);
1529 1536
@@ -1544,7 +1551,7 @@ int regulatory_hint_user(const char *alpha2)
1544 request->wiphy_idx = WIPHY_IDX_STALE; 1551 request->wiphy_idx = WIPHY_IDX_STALE;
1545 request->alpha2[0] = alpha2[0]; 1552 request->alpha2[0] = alpha2[0];
1546 request->alpha2[1] = alpha2[1]; 1553 request->alpha2[1] = alpha2[1];
1547 request->initiator = REGDOM_SET_BY_USER, 1554 request->initiator = NL80211_REGDOM_SET_BY_USER,
1548 1555
1549 queue_regulatory_request(request); 1556 queue_regulatory_request(request);
1550 1557
@@ -1570,7 +1577,7 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
1570 1577
1571 request->alpha2[0] = alpha2[0]; 1578 request->alpha2[0] = alpha2[0];
1572 request->alpha2[1] = alpha2[1]; 1579 request->alpha2[1] = alpha2[1];
1573 request->initiator = REGDOM_SET_BY_DRIVER; 1580 request->initiator = NL80211_REGDOM_SET_BY_DRIVER;
1574 1581
1575 queue_regulatory_request(request); 1582 queue_regulatory_request(request);
1576 1583
@@ -1719,7 +1726,7 @@ void regulatory_hint_11d(struct wiphy *wiphy,
1719 request->wiphy_idx = get_wiphy_idx(wiphy); 1726 request->wiphy_idx = get_wiphy_idx(wiphy);
1720 request->alpha2[0] = rd->alpha2[0]; 1727 request->alpha2[0] = rd->alpha2[0];
1721 request->alpha2[1] = rd->alpha2[1]; 1728 request->alpha2[1] = rd->alpha2[1];
1722 request->initiator = REGDOM_SET_BY_COUNTRY_IE; 1729 request->initiator = NL80211_REGDOM_SET_BY_COUNTRY_IE;
1723 request->country_ie_checksum = checksum; 1730 request->country_ie_checksum = checksum;
1724 request->country_ie_env = env; 1731 request->country_ie_env = env;
1725 1732
@@ -1827,7 +1834,8 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
1827 1834
1828 if (is_intersected_alpha2(rd->alpha2)) { 1835 if (is_intersected_alpha2(rd->alpha2)) {
1829 1836
1830 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) { 1837 if (last_request->initiator ==
1838 NL80211_REGDOM_SET_BY_COUNTRY_IE) {
1831 struct cfg80211_registered_device *drv; 1839 struct cfg80211_registered_device *drv;
1832 drv = cfg80211_drv_by_wiphy_idx( 1840 drv = cfg80211_drv_by_wiphy_idx(
1833 last_request->wiphy_idx); 1841 last_request->wiphy_idx);
@@ -1919,7 +1927,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
1919 * rd is non static (it means CRDA was present and was used last) 1927 * rd is non static (it means CRDA was present and was used last)
1920 * and the pending request came in from a country IE 1928 * and the pending request came in from a country IE
1921 */ 1929 */
1922 if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) { 1930 if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
1923 /* 1931 /*
1924 * If someone else asked us to change the rd lets only bother 1932 * If someone else asked us to change the rd lets only bother
1925 * checking if the alpha2 changes if CRDA was already called 1933 * checking if the alpha2 changes if CRDA was already called
@@ -1951,7 +1959,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
1951 if (!last_request->intersect) { 1959 if (!last_request->intersect) {
1952 int r; 1960 int r;
1953 1961
1954 if (last_request->initiator != REGDOM_SET_BY_DRIVER) { 1962 if (last_request->initiator != NL80211_REGDOM_SET_BY_DRIVER) {
1955 reset_regdomains(); 1963 reset_regdomains();
1956 cfg80211_regdomain = rd; 1964 cfg80211_regdomain = rd;
1957 return 0; 1965 return 0;
@@ -1975,7 +1983,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
1975 1983
1976 /* Intersection requires a bit more work */ 1984 /* Intersection requires a bit more work */
1977 1985
1978 if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) { 1986 if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
1979 1987
1980 intersected_rd = regdom_intersect(rd, cfg80211_regdomain); 1988 intersected_rd = regdom_intersect(rd, cfg80211_regdomain);
1981 if (!intersected_rd) 1989 if (!intersected_rd)
@@ -1986,7 +1994,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
1986 * However if a driver requested this specific regulatory 1994 * However if a driver requested this specific regulatory
1987 * domain we keep it for its private use 1995 * domain we keep it for its private use
1988 */ 1996 */
1989 if (last_request->initiator == REGDOM_SET_BY_DRIVER) 1997 if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER)
1990 request_wiphy->regd = rd; 1998 request_wiphy->regd = rd;
1991 else 1999 else
1992 kfree(rd); 2000 kfree(rd);