• Home
  • Raw
  • Download

Lines Matching +full:country +full:- +full:code

2  * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright (C) 2018 - 2023 Intel Corporation
29 * looking up the allowable channels in a driver-local table and finally
42 * Note: When number of rules --> infinity we will not be able to
63 #include "rdev-ops.h"
73 * enum reg_request_treatment - regulatory request treatment
150 return rcu_dereference_check(wiphy->regd, in get_wiphy_regdom()
151 lockdep_is_held(&wiphy->mtx) || in get_wiphy_regdom()
179 dfs_region = regd->dfs_region; in reg_get_dfs_region()
188 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in reg_get_dfs_region()
189 dfs_region = wiphy_regd->dfs_region; in reg_get_dfs_region()
193 if (wiphy_regd->dfs_region == regd->dfs_region) in reg_get_dfs_region()
197 dev_name(&wiphy->dev), in reg_get_dfs_region()
198 reg_dfs_region_str(wiphy_regd->dfs_region), in reg_get_dfs_region()
199 reg_dfs_region_str(regd->dfs_region)); in reg_get_dfs_region()
247 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
249 REG_RULE(2467-10, 2472+10, 20, 6, 20,
251 /* IEEE 802.11 channel 14 - Only JP enables
253 REG_RULE(2484-10, 2484+10, 20, 6, 20,
257 REG_RULE(5180-10, 5240+10, 80, 6, 20,
261 /* IEEE 802.11a, channel 52..64 - DFS required */
262 REG_RULE(5260-10, 5320+10, 80, 6, 20,
267 /* IEEE 802.11a, channel 100..144 - DFS required */
268 REG_RULE(5500-10, 5720+10, 160, 6, 20,
273 REG_RULE(5745-10, 5825+10, 80, 6, 20,
277 REG_RULE(56160+2160*1-1080, 56160+2160*3+1080, 2160, 0, 0, 0),
290 MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code");
425 return !alpha2_equal(r->alpha2, alpha2); in regdom_changes()
453 regd = kzalloc(struct_size(regd, reg_rules, src_regd->n_reg_rules), in reg_copy_regd()
456 return ERR_PTR(-ENOMEM); in reg_copy_regd()
460 for (i = 0; i < src_regd->n_reg_rules; i++) in reg_copy_regd()
461 memcpy(&regd->reg_rules[i], &src_regd->reg_rules[i], in reg_copy_regd()
495 list_del(&request->list); in reg_regdb_apply()
497 set_regdom(request->regdom, REGD_SOURCE_INTERNAL_DB); in reg_regdb_apply()
514 return -ENOMEM; in reg_schedule_apply()
517 request->regdom = regdom; in reg_schedule_apply()
520 list_add_tail(&request->list, &reg_regdb_apply_list); in reg_schedule_apply()
561 * This lets us keep regulatory code which is updated on a regulatory
566 char country[12]; in call_crda() local
567 char *env[] = { country, NULL }; in call_crda()
570 snprintf(country, sizeof(country), "COUNTRY=%c%c", in call_crda()
575 return -EINVAL; in call_crda()
579 pr_debug("Calling CRDA for country: %c%c\n", in call_crda()
584 ret = kobject_uevent_env(&reg_pdev->dev.kobj, KOBJ_CHANGE, env); in call_crda()
598 return -ENODATA; in call_crda()
602 /* code to directly load a firmware database through request_firmware */
654 struct fwdb_country country[]; member
659 return (1 << ecw) - 1; in ecw2cw()
686 if ((u8 *)rule + sizeof(rule->len) > data + size) in valid_rule()
690 if (rule->len < offsetofend(struct fwdb_rule, max_bw)) in valid_rule()
692 if (rule->len >= offsetofend(struct fwdb_rule, wmm_ptr)) { in valid_rule()
693 u32 wmm_ptr = be16_to_cpu(rule->wmm_ptr) << 2; in valid_rule()
708 const struct fwdb_country *country) in valid_country() argument
710 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in valid_country()
720 if ((u8 *)coll + ALIGN(coll->len, 2) + in valid_country()
721 (coll->n_rules * 2) > data + size) in valid_country()
725 if (coll->len < offsetofend(struct fwdb_collection, dfs_region)) in valid_country()
728 rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in valid_country()
730 for (i = 0; i < coll->n_rules; i++) { in valid_country()
741 #include <keys/asymmetric-type.h>
756 pr_notice("Loading compiled-in X.509 certificates for regulatory database\n"); in load_builtin_regdb_keys()
780 if (request_firmware(&sig, "regulatory.db.p7s", &reg_pdev->dev)) in regdb_has_valid_signature()
783 result = verify_pkcs7_signature(data, size, sig->data, sig->size, in regdb_has_valid_signature()
816 const struct fwdb_country *country; in valid_regdb() local
821 if (hdr->magic != cpu_to_be32(FWDB_MAGIC)) in valid_regdb()
824 if (hdr->version != cpu_to_be32(FWDB_VERSION)) in valid_regdb()
830 country = &hdr->country[0]; in valid_regdb()
831 while ((u8 *)(country + 1) <= data + size) { in valid_regdb()
832 if (!country->coll_ptr) in valid_regdb()
834 if (!valid_country(data, size, country)) in valid_regdb()
836 country++; in valid_regdb()
843 const struct fwdb_country *country, in set_wmm_rule() argument
847 struct ieee80211_wmm_rule *wmm_rule = &rrule->wmm_rule; in set_wmm_rule()
851 wmm_ptr = be16_to_cpu(rule->wmm_ptr) << 2; in set_wmm_rule()
855 pr_err("Invalid regulatory WMM rule %u-%u in domain %c%c\n", in set_wmm_rule()
856 be32_to_cpu(rule->start), be32_to_cpu(rule->end), in set_wmm_rule()
857 country->alpha2[0], country->alpha2[1]); in set_wmm_rule()
862 wmm_rule->client[i].cw_min = in set_wmm_rule()
863 ecw2cw((wmm->client[i].ecw & 0xf0) >> 4); in set_wmm_rule()
864 wmm_rule->client[i].cw_max = ecw2cw(wmm->client[i].ecw & 0x0f); in set_wmm_rule()
865 wmm_rule->client[i].aifsn = wmm->client[i].aifsn; in set_wmm_rule()
866 wmm_rule->client[i].cot = in set_wmm_rule()
867 1000 * be16_to_cpu(wmm->client[i].cot); in set_wmm_rule()
868 wmm_rule->ap[i].cw_min = ecw2cw((wmm->ap[i].ecw & 0xf0) >> 4); in set_wmm_rule()
869 wmm_rule->ap[i].cw_max = ecw2cw(wmm->ap[i].ecw & 0x0f); in set_wmm_rule()
870 wmm_rule->ap[i].aifsn = wmm->ap[i].aifsn; in set_wmm_rule()
871 wmm_rule->ap[i].cot = 1000 * be16_to_cpu(wmm->ap[i].cot); in set_wmm_rule()
874 rrule->has_wmm = true; in set_wmm_rule()
878 const struct fwdb_country *country, int freq, in __regdb_query_wmm() argument
881 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in __regdb_query_wmm()
885 for (i = 0; i < coll->n_rules; i++) { in __regdb_query_wmm()
886 __be16 *rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in __regdb_query_wmm()
890 if (rule->len < offsetofend(struct fwdb_rule, wmm_ptr)) in __regdb_query_wmm()
893 if (freq >= KHZ_TO_MHZ(be32_to_cpu(rule->start)) && in __regdb_query_wmm()
894 freq <= KHZ_TO_MHZ(be32_to_cpu(rule->end))) { in __regdb_query_wmm()
895 set_wmm_rule(db, country, rule, rrule); in __regdb_query_wmm()
900 return -ENODATA; in __regdb_query_wmm()
906 const struct fwdb_country *country; in reg_query_regdb_wmm() local
909 return -ENODATA; in reg_query_regdb_wmm()
914 country = &hdr->country[0]; in reg_query_regdb_wmm()
915 while (country->coll_ptr) { in reg_query_regdb_wmm()
916 if (alpha2_equal(alpha2, country->alpha2)) in reg_query_regdb_wmm()
917 return __regdb_query_wmm(regdb, country, freq, rule); in reg_query_regdb_wmm()
919 country++; in reg_query_regdb_wmm()
922 return -ENODATA; in reg_query_regdb_wmm()
927 const struct fwdb_country *country) in regdb_query_country() argument
929 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in regdb_query_country()
934 regdom = kzalloc(struct_size(regdom, reg_rules, coll->n_rules), in regdb_query_country()
937 return -ENOMEM; in regdb_query_country()
939 regdom->n_reg_rules = coll->n_rules; in regdb_query_country()
940 regdom->alpha2[0] = country->alpha2[0]; in regdb_query_country()
941 regdom->alpha2[1] = country->alpha2[1]; in regdb_query_country()
942 regdom->dfs_region = coll->dfs_region; in regdb_query_country()
944 for (i = 0; i < regdom->n_reg_rules; i++) { in regdb_query_country()
945 __be16 *rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in regdb_query_country()
948 struct ieee80211_reg_rule *rrule = &regdom->reg_rules[i]; in regdb_query_country()
950 rrule->freq_range.start_freq_khz = be32_to_cpu(rule->start); in regdb_query_country()
951 rrule->freq_range.end_freq_khz = be32_to_cpu(rule->end); in regdb_query_country()
952 rrule->freq_range.max_bandwidth_khz = be32_to_cpu(rule->max_bw); in regdb_query_country()
954 rrule->power_rule.max_antenna_gain = 0; in regdb_query_country()
955 rrule->power_rule.max_eirp = be16_to_cpu(rule->max_eirp); in regdb_query_country()
957 rrule->flags = 0; in regdb_query_country()
958 if (rule->flags & FWDB_FLAG_NO_OFDM) in regdb_query_country()
959 rrule->flags |= NL80211_RRF_NO_OFDM; in regdb_query_country()
960 if (rule->flags & FWDB_FLAG_NO_OUTDOOR) in regdb_query_country()
961 rrule->flags |= NL80211_RRF_NO_OUTDOOR; in regdb_query_country()
962 if (rule->flags & FWDB_FLAG_DFS) in regdb_query_country()
963 rrule->flags |= NL80211_RRF_DFS; in regdb_query_country()
964 if (rule->flags & FWDB_FLAG_NO_IR) in regdb_query_country()
965 rrule->flags |= NL80211_RRF_NO_IR; in regdb_query_country()
966 if (rule->flags & FWDB_FLAG_AUTO_BW) in regdb_query_country()
967 rrule->flags |= NL80211_RRF_AUTO_BW; in regdb_query_country()
969 rrule->dfs_cac_ms = 0; in regdb_query_country()
972 if (rule->len >= offsetofend(struct fwdb_rule, cac_timeout)) in regdb_query_country()
973 rrule->dfs_cac_ms = in regdb_query_country()
974 1000 * be16_to_cpu(rule->cac_timeout); in regdb_query_country()
975 if (rule->len >= offsetofend(struct fwdb_rule, wmm_ptr)) in regdb_query_country()
976 set_wmm_rule(db, country, rule, rrule); in regdb_query_country()
985 const struct fwdb_country *country; in query_regdb() local
992 country = &hdr->country[0]; in query_regdb()
993 while (country->coll_ptr) { in query_regdb()
994 if (alpha2_equal(alpha2, country->alpha2)) in query_regdb()
995 return regdb_query_country(regdb, country); in query_regdb()
996 country++; in query_regdb()
999 return -ENODATA; in query_regdb()
1010 set_error = -ENODATA; in regdb_fw_cb()
1011 } else if (!valid_regdb(fw->data, fw->size)) { in regdb_fw_cb()
1013 set_error = -EINVAL; in regdb_fw_cb()
1018 /* negative case - a bug in regdb_fw_cb()
1019 * positive case - can happen due to race in case of multiple cb's in in regdb_fw_cb()
1027 db = kmemdup(fw->data, fw->size, GFP_KERNEL); in regdb_fw_cb()
1059 return -ENOMEM; in query_regdb_file()
1062 &reg_pdev->dev, GFP_KERNEL, in query_regdb_file()
1078 err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev); in reg_reload_regdb()
1082 if (!valid_regdb(fw->data, fw->size)) { in reg_reload_regdb()
1083 err = -ENODATA; in reg_reload_regdb()
1087 db = kmemdup(fw->data, fw->size, GFP_KERNEL); in reg_reload_regdb()
1089 err = -ENOMEM; in reg_reload_regdb()
1103 err = -ENOMEM; in reg_reload_regdb()
1107 request->wiphy_idx = WIPHY_IDX_INVALID; in reg_reload_regdb()
1108 request->alpha2[0] = current_regdomain->alpha2[0]; in reg_reload_regdb()
1109 request->alpha2[1] = current_regdomain->alpha2[1]; in reg_reload_regdb()
1110 request->initiator = NL80211_REGDOM_SET_BY_CORE; in reg_reload_regdb()
1111 request->user_reg_hint_type = NL80211_USER_REG_HINT_USER; in reg_reload_regdb()
1124 if (query_regdb_file(request->alpha2) == 0) in reg_query_database()
1127 if (call_crda(request->alpha2) == 0) in reg_query_database()
1137 if (!lr || lr->processed) in reg_is_valid_request()
1140 return alpha2_equal(lr->alpha2, alpha2); in reg_is_valid_request()
1148 * Follow the driver's regulatory domain, if present, unless a country in reg_get_regdomain()
1151 if (lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && in reg_get_regdomain()
1152 lr->initiator != NL80211_REGDOM_SET_BY_USER && in reg_get_regdomain()
1153 wiphy->regd) in reg_get_regdomain()
1163 const struct ieee80211_freq_range *freq_range = &rule->freq_range; in reg_get_max_bandwidth_from_range()
1168 for (idx = 0; idx < rd->n_reg_rules; idx++) in reg_get_max_bandwidth_from_range()
1169 if (rule == &rd->reg_rules[idx]) in reg_get_max_bandwidth_from_range()
1172 if (idx == rd->n_reg_rules) in reg_get_max_bandwidth_from_range()
1179 tmp = &rd->reg_rules[--no]; in reg_get_max_bandwidth_from_range()
1180 freq_range_tmp = &tmp->freq_range; in reg_get_max_bandwidth_from_range()
1182 if (freq_range_tmp->end_freq_khz < freq_range->start_freq_khz) in reg_get_max_bandwidth_from_range()
1188 start_freq = freq_range->start_freq_khz; in reg_get_max_bandwidth_from_range()
1191 freq_range = &rule->freq_range; in reg_get_max_bandwidth_from_range()
1194 while (no < rd->n_reg_rules - 1) { in reg_get_max_bandwidth_from_range()
1195 tmp = &rd->reg_rules[++no]; in reg_get_max_bandwidth_from_range()
1196 freq_range_tmp = &tmp->freq_range; in reg_get_max_bandwidth_from_range()
1198 if (freq_range_tmp->start_freq_khz > freq_range->end_freq_khz) in reg_get_max_bandwidth_from_range()
1204 end_freq = freq_range->end_freq_khz; in reg_get_max_bandwidth_from_range()
1206 return end_freq - start_freq; in reg_get_max_bandwidth_from_range()
1214 if (rule->flags & NL80211_RRF_NO_320MHZ) in reg_get_max_bandwidth()
1216 if (rule->flags & NL80211_RRF_NO_160MHZ) in reg_get_max_bandwidth()
1218 if (rule->flags & NL80211_RRF_NO_80MHZ) in reg_get_max_bandwidth()
1222 * HT40+/HT40- limits are handled per-channel. Only limit BW if both in reg_get_max_bandwidth()
1225 if (rule->flags & NL80211_RRF_NO_HT40MINUS && in reg_get_max_bandwidth()
1226 rule->flags & NL80211_RRF_NO_HT40PLUS) in reg_get_max_bandwidth()
1235 const struct ieee80211_freq_range *freq_range = &rule->freq_range; in is_valid_reg_rule()
1238 if (freq_range->start_freq_khz <= 0 || freq_range->end_freq_khz <= 0) in is_valid_reg_rule()
1241 if (freq_range->start_freq_khz > freq_range->end_freq_khz) in is_valid_reg_rule()
1244 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; in is_valid_reg_rule()
1246 if (freq_range->end_freq_khz <= freq_range->start_freq_khz || in is_valid_reg_rule()
1247 freq_range->max_bandwidth_khz > freq_diff) in is_valid_reg_rule()
1258 if (!rd->n_reg_rules) in is_valid_rd()
1261 if (WARN_ON(rd->n_reg_rules > NL80211_MAX_SUPP_REG_RULES)) in is_valid_rd()
1264 for (i = 0; i < rd->n_reg_rules; i++) { in is_valid_rd()
1265 reg_rule = &rd->reg_rules[i]; in is_valid_rd()
1274 * freq_in_rule_band - tells us if a frequency is in a frequency band
1293 * From 802.11ad: directional multi-gigabit (DMG): in freq_in_rule_band()
1299 if (abs(freq_khz - freq_range->start_freq_khz) <= limit) in freq_in_rule_band()
1301 if (abs(freq_khz - freq_range->end_freq_khz) <= limit) in freq_in_rule_band()
1325 intersect->cw_min = max_t(u16, wmm_ac1->cw_min, wmm_ac2->cw_min); in reg_wmm_rules_intersect()
1326 intersect->cw_max = max_t(u16, wmm_ac1->cw_max, wmm_ac2->cw_max); in reg_wmm_rules_intersect()
1327 intersect->cot = min_t(u16, wmm_ac1->cot, wmm_ac2->cot); in reg_wmm_rules_intersect()
1328 intersect->aifsn = max_t(u8, wmm_ac1->aifsn, wmm_ac2->aifsn); in reg_wmm_rules_intersect()
1349 freq_range1 = &rule1->freq_range; in reg_rules_intersect()
1350 freq_range2 = &rule2->freq_range; in reg_rules_intersect()
1351 freq_range = &intersected_rule->freq_range; in reg_rules_intersect()
1353 power_rule1 = &rule1->power_rule; in reg_rules_intersect()
1354 power_rule2 = &rule2->power_rule; in reg_rules_intersect()
1355 power_rule = &intersected_rule->power_rule; in reg_rules_intersect()
1357 wmm_rule1 = &rule1->wmm_rule; in reg_rules_intersect()
1358 wmm_rule2 = &rule2->wmm_rule; in reg_rules_intersect()
1359 wmm_rule = &intersected_rule->wmm_rule; in reg_rules_intersect()
1361 freq_range->start_freq_khz = max(freq_range1->start_freq_khz, in reg_rules_intersect()
1362 freq_range2->start_freq_khz); in reg_rules_intersect()
1363 freq_range->end_freq_khz = min(freq_range1->end_freq_khz, in reg_rules_intersect()
1364 freq_range2->end_freq_khz); in reg_rules_intersect()
1366 max_bandwidth1 = freq_range1->max_bandwidth_khz; in reg_rules_intersect()
1367 max_bandwidth2 = freq_range2->max_bandwidth_khz; in reg_rules_intersect()
1369 if (rule1->flags & NL80211_RRF_AUTO_BW) in reg_rules_intersect()
1371 if (rule2->flags & NL80211_RRF_AUTO_BW) in reg_rules_intersect()
1374 freq_range->max_bandwidth_khz = min(max_bandwidth1, max_bandwidth2); in reg_rules_intersect()
1376 intersected_rule->flags = rule1->flags | rule2->flags; in reg_rules_intersect()
1386 if ((rule1->flags & NL80211_RRF_AUTO_BW) && in reg_rules_intersect()
1387 (rule2->flags & NL80211_RRF_AUTO_BW)) in reg_rules_intersect()
1388 intersected_rule->flags |= NL80211_RRF_AUTO_BW; in reg_rules_intersect()
1390 intersected_rule->flags &= ~NL80211_RRF_AUTO_BW; in reg_rules_intersect()
1392 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; in reg_rules_intersect()
1393 if (freq_range->max_bandwidth_khz > freq_diff) in reg_rules_intersect()
1394 freq_range->max_bandwidth_khz = freq_diff; in reg_rules_intersect()
1396 power_rule->max_eirp = min(power_rule1->max_eirp, in reg_rules_intersect()
1397 power_rule2->max_eirp); in reg_rules_intersect()
1398 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain, in reg_rules_intersect()
1399 power_rule2->max_antenna_gain); in reg_rules_intersect()
1401 intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms, in reg_rules_intersect()
1402 rule2->dfs_cac_ms); in reg_rules_intersect()
1404 if (rule1->has_wmm && rule2->has_wmm) { in reg_rules_intersect()
1408 reg_wmm_rules_intersect(&wmm_rule1->client[ac], in reg_rules_intersect()
1409 &wmm_rule2->client[ac], in reg_rules_intersect()
1410 &wmm_rule->client[ac]); in reg_rules_intersect()
1411 reg_wmm_rules_intersect(&wmm_rule1->ap[ac], in reg_rules_intersect()
1412 &wmm_rule2->ap[ac], in reg_rules_intersect()
1413 &wmm_rule->ap[ac]); in reg_rules_intersect()
1416 intersected_rule->has_wmm = true; in reg_rules_intersect()
1417 } else if (rule1->has_wmm) { in reg_rules_intersect()
1419 intersected_rule->has_wmm = true; in reg_rules_intersect()
1420 } else if (rule2->has_wmm) { in reg_rules_intersect()
1422 intersected_rule->has_wmm = true; in reg_rules_intersect()
1424 intersected_rule->has_wmm = false; in reg_rules_intersect()
1428 return -EINVAL; in reg_rules_intersect()
1438 if (r1->flags != r2->flags) in rule_contains()
1442 if ((r1->power_rule.max_antenna_gain > in rule_contains()
1443 r2->power_rule.max_antenna_gain) || in rule_contains()
1444 r1->power_rule.max_eirp > r2->power_rule.max_eirp) in rule_contains()
1448 if (r1->freq_range.start_freq_khz > r2->freq_range.start_freq_khz || in rule_contains()
1449 r1->freq_range.end_freq_khz < r2->freq_range.end_freq_khz) in rule_contains()
1453 if (r1->freq_range.max_bandwidth_khz < in rule_contains()
1454 r2->freq_range.max_bandwidth_khz) in rule_contains()
1469 /* rule is already contained - do nothing */ in add_rule()
1485 * regdom_intersect - do the intersection between two regulatory domains
1515 * is it will return -EINVAL if the rule computed makes no sense. in regdom_intersect()
1519 for (x = 0; x < rd1->n_reg_rules; x++) { in regdom_intersect()
1520 rule1 = &rd1->reg_rules[x]; in regdom_intersect()
1521 for (y = 0; y < rd2->n_reg_rules; y++) { in regdom_intersect()
1522 rule2 = &rd2->reg_rules[y]; in regdom_intersect()
1536 for (x = 0; x < rd1->n_reg_rules; x++) { in regdom_intersect()
1537 rule1 = &rd1->reg_rules[x]; in regdom_intersect()
1538 for (y = 0; y < rd2->n_reg_rules; y++) { in regdom_intersect()
1539 rule2 = &rd2->reg_rules[y]; in regdom_intersect()
1549 add_rule(&intersected_rule, rd->reg_rules, in regdom_intersect()
1550 &rd->n_reg_rules); in regdom_intersect()
1554 rd->alpha2[0] = '9'; in regdom_intersect()
1555 rd->alpha2[1] = '8'; in regdom_intersect()
1556 rd->dfs_region = reg_intersect_dfs_region(rd1->dfs_region, in regdom_intersect()
1557 rd2->dfs_region); in regdom_intersect()
1605 return ERR_PTR(-EINVAL); in freq_reg_info_regd()
1607 for (i = 0; i < regd->n_reg_rules; i++) { in freq_reg_info_regd()
1611 rr = &regd->reg_rules[i]; in freq_reg_info_regd()
1612 fr = &rr->freq_range; in freq_reg_info_regd()
1629 return ERR_PTR(-ERANGE); in freq_reg_info_regd()
1631 return ERR_PTR(-EINVAL); in freq_reg_info_regd()
1639 const struct ieee80211_reg_rule *reg_rule = ERR_PTR(-ERANGE); in __freq_reg_info()
1640 int i = ARRAY_SIZE(bws) - 1; in __freq_reg_info()
1643 for (bw = MHZ_TO_KHZ(bws[i]); bw >= min_bw; bw = MHZ_TO_KHZ(bws[i--])) { in __freq_reg_info()
1671 return "country element"; in reg_initiator_name()
1685 bool is_s1g = chan->band == NL80211_BAND_S1GHZ; in reg_rule_to_chan_bw_flags()
1687 freq_range = &reg_rule->freq_range; in reg_rule_to_chan_bw_flags()
1689 max_bandwidth_khz = freq_range->max_bandwidth_khz; in reg_rule_to_chan_bw_flags()
1692 if (reg_rule->flags & NL80211_RRF_AUTO_BW) in reg_rule_to_chan_bw_flags()
1714 edge_offset = (center_freq_khz - ch_bw / 2) - in reg_rule_to_chan_bw_flags()
1715 freq_range->start_freq_khz; in reg_rule_to_chan_bw_flags()
1775 power_rule = &reg_rule->power_rule; in handle_channel_single_rule()
1778 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel_single_rule()
1780 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel_single_rule()
1786 chan->flags = chan->orig_flags = in handle_channel_single_rule()
1787 map_regdom_flags(reg_rule->flags) | bw_flags; in handle_channel_single_rule()
1788 chan->max_antenna_gain = chan->orig_mag = in handle_channel_single_rule()
1789 (int) MBI_TO_DBI(power_rule->max_antenna_gain); in handle_channel_single_rule()
1790 chan->max_reg_power = chan->max_power = chan->orig_mpwr = in handle_channel_single_rule()
1791 (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_single_rule()
1793 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_single_rule()
1794 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_single_rule()
1795 if (reg_rule->dfs_cac_ms) in handle_channel_single_rule()
1796 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_single_rule()
1802 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_single_rule()
1803 chan->dfs_state_entered = jiffies; in handle_channel_single_rule()
1805 chan->beacon_found = false; in handle_channel_single_rule()
1806 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); in handle_channel_single_rule()
1807 chan->max_antenna_gain = in handle_channel_single_rule()
1808 min_t(int, chan->orig_mag, in handle_channel_single_rule()
1809 MBI_TO_DBI(power_rule->max_antenna_gain)); in handle_channel_single_rule()
1810 chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_single_rule()
1812 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_single_rule()
1813 if (reg_rule->dfs_cac_ms) in handle_channel_single_rule()
1814 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_single_rule()
1816 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_single_rule()
1819 if (chan->orig_mpwr) { in handle_channel_single_rule()
1822 * will always follow the passed country IE power settings. in handle_channel_single_rule()
1825 wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_FOLLOW_POWER) in handle_channel_single_rule()
1826 chan->max_power = chan->max_reg_power; in handle_channel_single_rule()
1828 chan->max_power = min(chan->orig_mpwr, in handle_channel_single_rule()
1829 chan->max_reg_power); in handle_channel_single_rule()
1831 chan->max_power = chan->max_reg_power; in handle_channel_single_rule()
1852 power_rule1 = &rrule1->power_rule; in handle_channel_adjacent_rules()
1853 power_rule2 = &rrule2->power_rule; in handle_channel_adjacent_rules()
1857 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel_adjacent_rules()
1859 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel_adjacent_rules()
1864 chan->flags = in handle_channel_adjacent_rules()
1865 map_regdom_flags(rrule1->flags) | in handle_channel_adjacent_rules()
1866 map_regdom_flags(rrule2->flags) | in handle_channel_adjacent_rules()
1869 chan->orig_flags = chan->flags; in handle_channel_adjacent_rules()
1870 chan->max_antenna_gain = in handle_channel_adjacent_rules()
1871 min_t(int, MBI_TO_DBI(power_rule1->max_antenna_gain), in handle_channel_adjacent_rules()
1872 MBI_TO_DBI(power_rule2->max_antenna_gain)); in handle_channel_adjacent_rules()
1873 chan->orig_mag = chan->max_antenna_gain; in handle_channel_adjacent_rules()
1874 chan->max_reg_power = in handle_channel_adjacent_rules()
1875 min_t(int, MBM_TO_DBM(power_rule1->max_eirp), in handle_channel_adjacent_rules()
1876 MBM_TO_DBM(power_rule2->max_eirp)); in handle_channel_adjacent_rules()
1877 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1878 chan->orig_mpwr = chan->max_reg_power; in handle_channel_adjacent_rules()
1880 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_adjacent_rules()
1881 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_adjacent_rules()
1882 if (rrule1->dfs_cac_ms || rrule2->dfs_cac_ms) in handle_channel_adjacent_rules()
1883 chan->dfs_cac_ms = max_t(unsigned int, in handle_channel_adjacent_rules()
1884 rrule1->dfs_cac_ms, in handle_channel_adjacent_rules()
1885 rrule2->dfs_cac_ms); in handle_channel_adjacent_rules()
1891 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_adjacent_rules()
1892 chan->dfs_state_entered = jiffies; in handle_channel_adjacent_rules()
1894 chan->beacon_found = false; in handle_channel_adjacent_rules()
1895 chan->flags = flags | bw_flags1 | bw_flags2 | in handle_channel_adjacent_rules()
1896 map_regdom_flags(rrule1->flags) | in handle_channel_adjacent_rules()
1897 map_regdom_flags(rrule2->flags); in handle_channel_adjacent_rules()
1905 chan->flags &= ~IEEE80211_CHAN_NO_10MHZ; in handle_channel_adjacent_rules()
1909 chan->flags &= ~IEEE80211_CHAN_NO_20MHZ; in handle_channel_adjacent_rules()
1911 chan->max_antenna_gain = in handle_channel_adjacent_rules()
1912 min_t(int, chan->orig_mag, in handle_channel_adjacent_rules()
1914 MBI_TO_DBI(power_rule1->max_antenna_gain), in handle_channel_adjacent_rules()
1915 MBI_TO_DBI(power_rule2->max_antenna_gain))); in handle_channel_adjacent_rules()
1916 chan->max_reg_power = min_t(int, in handle_channel_adjacent_rules()
1917 MBM_TO_DBM(power_rule1->max_eirp), in handle_channel_adjacent_rules()
1918 MBM_TO_DBM(power_rule2->max_eirp)); in handle_channel_adjacent_rules()
1920 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_adjacent_rules()
1921 if (rrule1->dfs_cac_ms || rrule2->dfs_cac_ms) in handle_channel_adjacent_rules()
1922 chan->dfs_cac_ms = max_t(unsigned int, in handle_channel_adjacent_rules()
1923 rrule1->dfs_cac_ms, in handle_channel_adjacent_rules()
1924 rrule2->dfs_cac_ms); in handle_channel_adjacent_rules()
1926 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_adjacent_rules()
1929 if (chan->orig_mpwr) { in handle_channel_adjacent_rules()
1931 * will always follow the passed country IE power settings. in handle_channel_adjacent_rules()
1934 wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_FOLLOW_POWER) in handle_channel_adjacent_rules()
1935 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1937 chan->max_power = min(chan->orig_mpwr, in handle_channel_adjacent_rules()
1938 chan->max_reg_power); in handle_channel_adjacent_rules()
1940 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1954 struct wiphy *request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in handle_channel()
1959 u32 flags = chan->orig_flags; in handle_channel()
1964 * chan - 20 MHz and chan + 20 MHz and test in handle_channel()
1968 orig_chan_freq - MHZ_TO_KHZ(20)); in handle_channel()
1974 if (rrule1->freq_range.end_freq_khz != in handle_channel()
1975 rrule2->freq_range.start_freq_khz) in handle_channel()
1979 rrule1->freq_range.start_freq_khz; in handle_channel()
1981 rrule2->freq_range.end_freq_khz; in handle_channel()
1984 rrule1->freq_range.max_bandwidth_khz, in handle_channel()
1985 rrule2->freq_range.max_bandwidth_khz); in handle_channel()
2002 * from a Country IE and the Country IE had no information in handle_channel()
2006 * a country IE with information for the 2.4 GHz band in handle_channel()
2010 PTR_ERR(rrule) == -ERANGE) in handle_channel()
2013 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel()
2015 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel()
2017 chan->center_freq, chan->freq_offset); in handle_channel()
2018 chan->orig_flags |= IEEE80211_CHAN_DISABLED; in handle_channel()
2019 chan->flags = chan->orig_flags; in handle_channel()
2022 chan->center_freq, chan->freq_offset); in handle_channel()
2023 chan->flags |= IEEE80211_CHAN_DISABLED; in handle_channel()
2041 for (i = 0; i < sband->n_channels; i++) in handle_band()
2042 handle_channel(wiphy, initiator, &sband->channels[i]); in handle_band()
2047 if (request->initiator != NL80211_REGDOM_SET_BY_USER) in reg_request_cell_base()
2049 return request->user_reg_hint_type == NL80211_USER_REG_HINT_CELL_BASE; in reg_request_cell_base()
2068 !regdom_changes(pending_request->alpha2)) in reg_ignore_cell_hint()
2077 return !(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS); in reg_dev_ignore_cell_hint()
2094 if (wiphy->regulatory_flags & REGULATORY_STRICT_REG && in wiphy_strict_alpha2_regd()
2095 !(wiphy->regulatory_flags & REGULATORY_CUSTOM_REG)) in wiphy_strict_alpha2_regd()
2105 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in ignore_reg_update()
2115 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) { in ignore_reg_update()
2122 * wiphy->regd will be set once the device has its own in ignore_reg_update()
2125 if (wiphy_strict_alpha2_regd(wiphy) && !wiphy->regd && in ignore_reg_update()
2127 !is_world_regdom(lr->alpha2)) { in ignore_reg_update()
2145 if (is_world_regdom(cr->alpha2) || (wr && is_world_regdom(wr->alpha2))) in reg_is_world_roaming()
2148 if (lr && lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && in reg_is_world_roaming()
2149 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) in reg_is_world_roaming()
2163 sband = wiphy->bands[reg_beacon->chan.band]; in handle_reg_beacon()
2164 chan = &sband->channels[chan_idx]; in handle_reg_beacon()
2166 if (likely(!ieee80211_channel_equal(chan, &reg_beacon->chan))) in handle_reg_beacon()
2169 if (chan->beacon_found) in handle_reg_beacon()
2172 chan->beacon_found = true; in handle_reg_beacon()
2177 if (wiphy->regulatory_flags & REGULATORY_DISABLE_BEACON_HINTS) in handle_reg_beacon()
2182 if (chan->flags & IEEE80211_CHAN_NO_IR) { in handle_reg_beacon()
2183 chan->flags &= ~IEEE80211_CHAN_NO_IR; in handle_reg_beacon()
2201 if (!wiphy->bands[reg_beacon->chan.band]) in wiphy_update_new_beacon()
2204 sband = wiphy->bands[reg_beacon->chan.band]; in wiphy_update_new_beacon()
2206 for (i = 0; i < sband->n_channels; i++) in wiphy_update_new_beacon()
2220 if (!wiphy->bands[reg_beacon->chan.band]) in wiphy_update_beacon_reg()
2222 sband = wiphy->bands[reg_beacon->chan.band]; in wiphy_update_beacon_reg()
2223 for (i = 0; i < sband->n_channels; i++) in wiphy_update_beacon_reg()
2244 if (chan->flags & IEEE80211_CHAN_DISABLED) in is_ht40_allowed()
2247 if ((chan->flags & IEEE80211_CHAN_NO_HT40) == IEEE80211_CHAN_NO_HT40) in is_ht40_allowed()
2255 struct ieee80211_supported_band *sband = wiphy->bands[channel->band]; in reg_process_ht_flags_channel()
2262 channel->flags |= IEEE80211_CHAN_NO_HT40; in reg_process_ht_flags_channel()
2268 * be able to use HT40- or HT40+, this finds them (or not) in reg_process_ht_flags_channel()
2270 for (i = 0; i < sband->n_channels; i++) { in reg_process_ht_flags_channel()
2271 struct ieee80211_channel *c = &sband->channels[i]; in reg_process_ht_flags_channel()
2273 if (c->center_freq == (channel->center_freq - 20)) in reg_process_ht_flags_channel()
2275 if (c->center_freq == (channel->center_freq + 20)) in reg_process_ht_flags_channel()
2283 freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq), in reg_process_ht_flags_channel()
2287 flags = reg_rule->flags; in reg_process_ht_flags_channel()
2297 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS; in reg_process_ht_flags_channel()
2299 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS; in reg_process_ht_flags_channel()
2303 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS; in reg_process_ht_flags_channel()
2305 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS; in reg_process_ht_flags_channel()
2316 for (i = 0; i < sband->n_channels; i++) in reg_process_ht_flags_band()
2317 reg_process_ht_flags_channel(wiphy, &sband->channels[i]); in reg_process_ht_flags_band()
2328 reg_process_ht_flags_band(wiphy, wiphy->bands[band]); in reg_process_ht_flags()
2334 if (wiphy->reg_notifier) in reg_call_notifier()
2335 wiphy->reg_notifier(wiphy, request); in reg_call_notifier()
2347 iftype = wdev->iftype; in reg_wdev_chan_valid()
2350 if (!wdev->netdev || !netif_running(wdev->netdev)) in reg_wdev_chan_valid()
2353 for (link = 0; link < ARRAY_SIZE(wdev->links); link++) { in reg_wdev_chan_valid()
2356 if (!wdev->valid_links && link > 0) in reg_wdev_chan_valid()
2358 if (wdev->valid_links && !(wdev->valid_links & BIT(link))) in reg_wdev_chan_valid()
2363 if (!wdev->links[link].ap.beacon_interval) in reg_wdev_chan_valid()
2365 chandef = wdev->links[link].ap.chandef; in reg_wdev_chan_valid()
2368 if (!wdev->u.mesh.beacon_interval) in reg_wdev_chan_valid()
2370 chandef = wdev->u.mesh.chandef; in reg_wdev_chan_valid()
2373 if (!wdev->u.ibss.ssid_len) in reg_wdev_chan_valid()
2375 chandef = wdev->u.ibss.chandef; in reg_wdev_chan_valid()
2380 if (!wdev->links[link].client.current_bss) in reg_wdev_chan_valid()
2383 chan = wdev->links[link].client.current_bss->pub.channel; in reg_wdev_chan_valid()
2387 if (!rdev->ops->get_channel || in reg_wdev_chan_valid()
2398 if (!wdev->u.ocb.chandef.chan) in reg_wdev_chan_valid()
2400 chandef = wdev->u.ocb.chandef; in reg_wdev_chan_valid()
2452 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) in reg_leave_invalid_chans()
2466 reg_leave_invalid_chans(&rdev->wiphy); in reg_check_chans_work()
2495 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG && in wiphy_update_regulatory()
2496 !(wiphy->regulatory_flags & in wiphy_update_regulatory()
2502 lr->dfs_region = get_cfg80211_regdom()->dfs_region; in wiphy_update_regulatory()
2505 handle_band(wiphy, initiator, wiphy->bands[band]); in wiphy_update_regulatory()
2520 wiphy = &rdev->wiphy; in update_all_wiphy_regulatory()
2546 chan->center_freq, chan->freq_offset); in handle_channel_custom()
2547 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in handle_channel_custom()
2548 chan->flags |= IEEE80211_CHAN_DISABLED; in handle_channel_custom()
2550 chan->orig_flags |= IEEE80211_CHAN_DISABLED; in handle_channel_custom()
2551 chan->flags = chan->orig_flags; in handle_channel_custom()
2556 power_rule = &reg_rule->power_rule; in handle_channel_custom()
2559 chan->dfs_state_entered = jiffies; in handle_channel_custom()
2560 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_custom()
2562 chan->beacon_found = false; in handle_channel_custom()
2564 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in handle_channel_custom()
2565 chan->flags = chan->orig_flags | bw_flags | in handle_channel_custom()
2566 map_regdom_flags(reg_rule->flags); in handle_channel_custom()
2568 chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; in handle_channel_custom()
2570 chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); in handle_channel_custom()
2571 chan->max_reg_power = chan->max_power = in handle_channel_custom()
2572 (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_custom()
2574 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_custom()
2575 if (reg_rule->dfs_cac_ms) in handle_channel_custom()
2576 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_custom()
2578 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_custom()
2581 chan->max_power = chan->max_reg_power; in handle_channel_custom()
2596 * compatible to US, which permits 2402 - 2472 MHz. in handle_band_custom()
2598 for (i = 0; i < sband->n_channels; i++) in handle_band_custom()
2599 handle_channel_custom(wiphy, &sband->channels[i], regd, in handle_band_custom()
2611 WARN(!(wiphy->regulatory_flags & REGULATORY_CUSTOM_REG), in wiphy_apply_custom_regulatory()
2613 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; in wiphy_apply_custom_regulatory()
2616 if (!wiphy->bands[band]) in wiphy_apply_custom_regulatory()
2618 handle_band_custom(wiphy, wiphy->bands[band], regd); in wiphy_apply_custom_regulatory()
2635 rcu_assign_pointer(wiphy->regd, new_regd); in wiphy_apply_custom_regulatory()
2648 lr->processed = true; in reg_set_request_processed()
2662 * reg_process_hint_core - process core regulatory requests
2672 core_request->intersect = false; in reg_process_hint_core()
2673 core_request->processed = false; in reg_process_hint_core()
2692 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) in __reg_process_hint_user()
2696 * to their country before the IE is picked up in __reg_process_hint_user()
2698 if (lr->initiator == NL80211_REGDOM_SET_BY_USER && in __reg_process_hint_user()
2699 lr->intersect) in __reg_process_hint_user()
2705 if ((lr->initiator == NL80211_REGDOM_SET_BY_CORE || in __reg_process_hint_user()
2706 lr->initiator == NL80211_REGDOM_SET_BY_DRIVER || in __reg_process_hint_user()
2707 lr->initiator == NL80211_REGDOM_SET_BY_USER) && in __reg_process_hint_user()
2708 regdom_changes(lr->alpha2)) in __reg_process_hint_user()
2711 if (!regdom_changes(user_request->alpha2)) in __reg_process_hint_user()
2718 * reg_process_hint_user - process user regulatory requests
2734 user_request->intersect = treatment == REG_REQ_INTERSECT; in reg_process_hint_user()
2735 user_request->processed = false; in reg_process_hint_user()
2739 user_alpha2[0] = user_request->alpha2[0]; in reg_process_hint_user()
2740 user_alpha2[1] = user_request->alpha2[1]; in reg_process_hint_user()
2752 if (lr->initiator == NL80211_REGDOM_SET_BY_CORE) { in __reg_process_hint_driver()
2753 if (regdom_changes(driver_request->alpha2)) in __reg_process_hint_driver()
2763 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in __reg_process_hint_driver()
2764 !regdom_changes(driver_request->alpha2)) in __reg_process_hint_driver()
2771 * reg_process_hint_driver - process driver regulatory requests
2803 rcu_assign_pointer(wiphy->regd, regd); in reg_process_hint_driver()
2809 driver_request->intersect = treatment == REG_REQ_INTERSECT; in reg_process_hint_driver()
2810 driver_request->processed = false; in reg_process_hint_driver()
2840 /* Trust a Cell base station over the AP's country IE */ in __reg_process_hint_country_ie()
2841 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2845 if (wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_IGNORE) in __reg_process_hint_country_ie()
2849 if (unlikely(!is_an_alpha2(country_ie_request->alpha2))) in __reg_process_hint_country_ie()
2850 return -EINVAL; in __reg_process_hint_country_ie()
2852 if (lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) in __reg_process_hint_country_ie()
2855 last_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in __reg_process_hint_country_ie()
2860 * Country IE alpha2s. We could in __reg_process_hint_country_ie()
2864 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2869 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2875 * reg_process_hint_country_ie - process regulatory requests from country IEs
2877 * @country_ie_request: a regulatory request from a country IE
2880 * a regulatory request issued by a country Information Element.
2905 WARN_ONCE(1, "Unexpected intersection for country elements"); in reg_process_hint_country_ie()
2909 country_ie_request->intersect = false; in reg_process_hint_country_ie()
2910 country_ie_request->processed = false; in reg_process_hint_country_ie()
2930 wiphy1_regd = rcu_dereference(wiphy1->regd); in reg_dfs_domain_same()
2934 wiphy2_regd = rcu_dereference(wiphy2->regd); in reg_dfs_domain_same()
2938 dfs_domain_same = wiphy1_regd->dfs_region == wiphy2_regd->dfs_region; in reg_dfs_domain_same()
2948 if (!(dst_chan->flags & IEEE80211_CHAN_RADAR) || in reg_copy_dfs_chan_state()
2949 !(src_chan->flags & IEEE80211_CHAN_RADAR)) in reg_copy_dfs_chan_state()
2952 if (dst_chan->flags & IEEE80211_CHAN_DISABLED || in reg_copy_dfs_chan_state()
2953 src_chan->flags & IEEE80211_CHAN_DISABLED) in reg_copy_dfs_chan_state()
2956 if (src_chan->center_freq == dst_chan->center_freq && in reg_copy_dfs_chan_state()
2957 dst_chan->dfs_state == NL80211_DFS_USABLE) { in reg_copy_dfs_chan_state()
2958 dst_chan->dfs_state = src_chan->dfs_state; in reg_copy_dfs_chan_state()
2959 dst_chan->dfs_state_entered = src_chan->dfs_state_entered; in reg_copy_dfs_chan_state()
2974 dst_sband = dst_wiphy->bands[band]; in wiphy_share_dfs_chan_state()
2975 src_sband = src_wiphy->bands[band]; in wiphy_share_dfs_chan_state()
2979 for (i = 0; i < dst_sband->n_channels; i++) { in wiphy_share_dfs_chan_state()
2980 dst_chan = &dst_sband->channels[i]; in wiphy_share_dfs_chan_state()
2981 for (j = 0; j < src_sband->n_channels; j++) { in wiphy_share_dfs_chan_state()
2982 src_chan = &src_sband->channels[j]; in wiphy_share_dfs_chan_state()
2996 if (wiphy == &rdev->wiphy) in wiphy_all_share_dfs_chan_state()
2998 wiphy_share_dfs_chan_state(wiphy, &rdev->wiphy); in wiphy_all_share_dfs_chan_state()
3007 enum nl80211_reg_initiator initiator = reg_request->initiator; in reg_process_hint()
3009 if (reg_request->wiphy_idx != WIPHY_IDX_INVALID) in reg_process_hint()
3010 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); in reg_process_hint()
3044 wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in reg_process_hint()
3062 wiphy = &rdev->wiphy; in notify_self_managed_wiphys()
3063 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && in notify_self_managed_wiphys()
3064 request->initiator == NL80211_REGDOM_SET_BY_USER) in notify_self_managed_wiphys()
3080 /* When last_request->processed becomes true this will be rescheduled */ in reg_process_pending_hints()
3081 if (lr && !lr->processed) { in reg_process_pending_hints()
3096 list_del_init(&reg_request->list); in reg_process_pending_hints()
3107 if (!list_empty(&reg_requests_list) && lr && lr->processed) in reg_process_pending_hints()
3112 /* Processes beacon hints -- this has nothing to do with country IEs */
3123 list_del_init(&pending_beacon->list); in reg_process_pending_beacon_hints()
3127 wiphy_update_new_beacon(&rdev->wiphy, pending_beacon); in reg_process_pending_beacon_hints()
3130 list_add_tail(&pending_beacon->list, &reg_beacon_list); in reg_process_pending_beacon_hints()
3148 regd = rdev->requested_regd; in reg_process_self_managed_hint()
3149 rdev->requested_regd = NULL; in reg_process_self_managed_hint()
3156 rcu_assign_pointer(wiphy->regd, regd); in reg_process_self_managed_hint()
3160 handle_band_custom(wiphy, wiphy->bands[band], regd); in reg_process_self_managed_hint()
3165 request.alpha2[0] = regd->alpha2[0]; in reg_process_self_managed_hint()
3166 request.alpha2[1] = regd->alpha2[1]; in reg_process_self_managed_hint()
3169 if (wiphy->flags & WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER) in reg_process_self_managed_hint()
3182 wiphy_lock(&rdev->wiphy); in reg_process_self_managed_hints()
3183 reg_process_self_managed_hint(&rdev->wiphy); in reg_process_self_managed_hints()
3184 wiphy_unlock(&rdev->wiphy); in reg_process_self_managed_hints()
3201 request->alpha2[0] = toupper(request->alpha2[0]); in queue_regulatory_request()
3202 request->alpha2[1] = toupper(request->alpha2[1]); in queue_regulatory_request()
3205 list_add_tail(&request->list, &reg_requests_list); in queue_regulatory_request()
3212 * Core regulatory hint -- happens during cfg80211_init()
3221 return -ENOMEM; in regulatory_hint_core()
3223 request->alpha2[0] = alpha2[0]; in regulatory_hint_core()
3224 request->alpha2[1] = alpha2[1]; in regulatory_hint_core()
3225 request->initiator = NL80211_REGDOM_SET_BY_CORE; in regulatory_hint_core()
3226 request->wiphy_idx = WIPHY_IDX_INVALID; in regulatory_hint_core()
3240 return -EINVAL; in regulatory_hint_user()
3243 return -EINVAL; in regulatory_hint_user()
3247 return -ENOMEM; in regulatory_hint_user()
3249 request->wiphy_idx = WIPHY_IDX_INVALID; in regulatory_hint_user()
3250 request->alpha2[0] = alpha2[0]; in regulatory_hint_user()
3251 request->alpha2[1] = alpha2[1]; in regulatory_hint_user()
3252 request->initiator = NL80211_REGDOM_SET_BY_USER; in regulatory_hint_user()
3253 request->user_reg_hint_type = user_reg_hint_type; in regulatory_hint_user()
3313 return -EINVAL; in regulatory_hint()
3315 wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG; in regulatory_hint()
3319 return -ENOMEM; in regulatory_hint()
3321 request->wiphy_idx = get_wiphy_idx(wiphy); in regulatory_hint()
3323 request->alpha2[0] = alpha2[0]; in regulatory_hint()
3324 request->alpha2[1] = alpha2[1]; in regulatory_hint()
3325 request->initiator = NL80211_REGDOM_SET_BY_DRIVER; in regulatory_hint()
3373 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE && in regulatory_hint_country_ie()
3374 lr->wiphy_idx != WIPHY_IDX_INVALID) in regulatory_hint_country_ie()
3377 request->wiphy_idx = get_wiphy_idx(wiphy); in regulatory_hint_country_ie()
3378 request->alpha2[0] = alpha2[0]; in regulatory_hint_country_ie()
3379 request->alpha2[1] = alpha2[1]; in regulatory_hint_country_ie()
3380 request->initiator = NL80211_REGDOM_SET_BY_COUNTRY_IE; in regulatory_hint_country_ie()
3381 request->country_ie_env = env; in regulatory_hint_country_ie()
3441 sband = wiphy->bands[band]; in restore_custom_reg_settings()
3444 for (i = 0; i < sband->n_channels; i++) { in restore_custom_reg_settings()
3445 chan = &sband->channels[i]; in restore_custom_reg_settings()
3446 chan->flags = chan->orig_flags; in restore_custom_reg_settings()
3447 chan->max_antenna_gain = chan->orig_mag; in restore_custom_reg_settings()
3448 chan->max_power = chan->orig_mpwr; in restore_custom_reg_settings()
3449 chan->beacon_found = false; in restore_custom_reg_settings()
3456 * possibly stale country IE information and user regulatory
3458 * learned as we could have traveled outside to another country
3462 * - send a core regulatory hint
3463 * - send a user regulatory hint if applicable
3465 * Device drivers that send a regulatory hint for a specific country
3466 * keep their own regulatory domain on wiphy->regd so that does
3507 list_del(&reg_beacon->list); in restore_regulatory_settings()
3513 list_del(&reg_beacon->list); in restore_regulatory_settings()
3518 world_alpha2[0] = cfg80211_world_regdom->alpha2[0]; in restore_regulatory_settings()
3519 world_alpha2[1] = cfg80211_world_regdom->alpha2[1]; in restore_regulatory_settings()
3522 if (rdev->wiphy.regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in restore_regulatory_settings()
3524 if (rdev->wiphy.regulatory_flags & REGULATORY_CUSTOM_REG) in restore_regulatory_settings()
3525 restore_custom_reg_settings(&rdev->wiphy); in restore_regulatory_settings()
3544 list_del(&ureq->list); in restore_regulatory_settings()
3579 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in is_wiphy_all_set_reg_flag()
3581 if (!(wdev->wiphy->regulatory_flags & flag)) { in is_wiphy_all_set_reg_flag()
3607 list_del(&reg_beacon->list); in regulatory_hint_disconnect()
3614 list_del(&reg_beacon->list); in regulatory_hint_disconnect()
3640 &pending_beacon->chan)) in pending_reg_beacon()
3652 if (beacon_chan->beacon_found || in regulatory_hint_found_beacon()
3653 beacon_chan->flags & IEEE80211_CHAN_RADAR || in regulatory_hint_found_beacon()
3654 (beacon_chan->band == NL80211_BAND_2GHZ && in regulatory_hint_found_beacon()
3655 !freq_is_chan_12_13_14(beacon_chan->center_freq))) in regulatory_hint_found_beacon()
3667 return -ENOMEM; in regulatory_hint_found_beacon()
3670 beacon_chan->center_freq, beacon_chan->freq_offset, in regulatory_hint_found_beacon()
3675 memcpy(&reg_beacon->chan, beacon_chan, in regulatory_hint_found_beacon()
3679 * Since we can be called from BH or and non-BH context in regulatory_hint_found_beacon()
3683 list_add_tail(&reg_beacon->list, &reg_pending_beacons); in regulatory_hint_found_beacon()
3699 pr_debug(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)\n"); in print_rd_rules()
3701 for (i = 0; i < rd->n_reg_rules; i++) { in print_rd_rules()
3702 reg_rule = &rd->reg_rules[i]; in print_rd_rules()
3703 freq_range = &reg_rule->freq_range; in print_rd_rules()
3704 power_rule = &reg_rule->power_rule; in print_rd_rules()
3706 if (reg_rule->flags & NL80211_RRF_AUTO_BW) in print_rd_rules()
3708 freq_range->max_bandwidth_khz, in print_rd_rules()
3712 freq_range->max_bandwidth_khz); in print_rd_rules()
3714 if (reg_rule->flags & NL80211_RRF_DFS) in print_rd_rules()
3716 reg_rule->dfs_cac_ms/1000); in print_rd_rules()
3725 if (power_rule->max_antenna_gain) in print_rd_rules()
3726 pr_debug(" (%d KHz - %d KHz @ %s), (%d mBi, %d mBm), (%s)\n", in print_rd_rules()
3727 freq_range->start_freq_khz, in print_rd_rules()
3728 freq_range->end_freq_khz, in print_rd_rules()
3730 power_rule->max_antenna_gain, in print_rd_rules()
3731 power_rule->max_eirp, in print_rd_rules()
3734 pr_debug(" (%d KHz - %d KHz @ %s), (N/A, %d mBm), (%s)\n", in print_rd_rules()
3735 freq_range->start_freq_khz, in print_rd_rules()
3736 freq_range->end_freq_khz, in print_rd_rules()
3738 power_rule->max_eirp, in print_rd_rules()
3761 if (is_intersected_alpha2(rd->alpha2)) { in print_regdomain()
3762 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { in print_regdomain()
3764 rdev = cfg80211_rdev_by_wiphy_idx(lr->wiphy_idx); in print_regdomain()
3767 rdev->country_ie_alpha2[0], in print_regdomain()
3768 rdev->country_ie_alpha2[1]); in print_regdomain()
3773 } else if (is_world_regdom(rd->alpha2)) { in print_regdomain()
3776 if (is_unknown_alpha2(rd->alpha2)) in print_regdomain()
3777 pr_debug("Regulatory domain changed to driver built-in settings (unknown country)\n"); in print_regdomain()
3780 pr_debug("Regulatory domain changed to country: %c%c by Cell Station\n", in print_regdomain()
3781 rd->alpha2[0], rd->alpha2[1]); in print_regdomain()
3783 pr_debug("Regulatory domain changed to country: %c%c\n", in print_regdomain()
3784 rd->alpha2[0], rd->alpha2[1]); in print_regdomain()
3788 pr_debug(" DFS Master region: %s", reg_dfs_region_str(rd->dfs_region)); in print_regdomain()
3794 pr_debug("Regulatory domain: %c%c\n", rd->alpha2[0], rd->alpha2[1]); in print_regdomain_info()
3800 if (!is_world_regdom(rd->alpha2)) in reg_set_rd_core()
3801 return -EINVAL; in reg_set_rd_core()
3811 if (!regdom_changes(rd->alpha2)) in reg_set_rd_user()
3812 return -EALREADY; in reg_set_rd_user()
3816 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_user()
3818 return -EINVAL; in reg_set_rd_user()
3821 if (!user_request->intersect) { in reg_set_rd_user()
3828 return -EINVAL; in reg_set_rd_user()
3845 if (is_world_regdom(rd->alpha2)) in reg_set_rd_driver()
3846 return -EINVAL; in reg_set_rd_driver()
3848 if (!regdom_changes(rd->alpha2)) in reg_set_rd_driver()
3849 return -EALREADY; in reg_set_rd_driver()
3853 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_driver()
3855 return -EINVAL; in reg_set_rd_driver()
3858 request_wiphy = wiphy_idx_to_wiphy(driver_request->wiphy_idx); in reg_set_rd_driver()
3860 return -ENODEV; in reg_set_rd_driver()
3862 if (!driver_request->intersect) { in reg_set_rd_driver()
3865 if (request_wiphy->regd) { in reg_set_rd_driver()
3867 return -EALREADY; in reg_set_rd_driver()
3876 rcu_assign_pointer(request_wiphy->regd, regd); in reg_set_rd_driver()
3884 return -EINVAL; in reg_set_rd_driver()
3892 rcu_assign_pointer(request_wiphy->regd, rd); in reg_set_rd_driver()
3907 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && in reg_set_rd_country_ie()
3908 !is_unknown_alpha2(rd->alpha2)) in reg_set_rd_country_ie()
3909 return -EINVAL; in reg_set_rd_country_ie()
3914 * and the pending request came in from a country IE in reg_set_rd_country_ie()
3919 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_country_ie()
3921 return -EINVAL; in reg_set_rd_country_ie()
3924 request_wiphy = wiphy_idx_to_wiphy(country_ie_request->wiphy_idx); in reg_set_rd_country_ie()
3926 return -ENODEV; in reg_set_rd_country_ie()
3928 if (country_ie_request->intersect) in reg_set_rd_country_ie()
3929 return -EINVAL; in reg_set_rd_country_ie()
3948 return -ENODATA; in set_regdom()
3950 if (!reg_is_valid_request(rd->alpha2)) { in set_regdom()
3952 return -EINVAL; in set_regdom()
3961 switch (lr->initiator) { in set_regdom()
3977 WARN(1, "invalid initiator %d\n", lr->initiator); in set_regdom()
3979 return -EINVAL; in set_regdom()
3984 case -EALREADY: in set_regdom()
3997 if (WARN_ON(!lr->intersect && rd != get_cfg80211_regdom())) in set_regdom()
3998 return -EINVAL; in set_regdom()
4001 update_all_wiphy_regulatory(lr->initiator); in set_regdom()
4020 return -EINVAL; in __regulatory_set_wiphy_regd()
4022 if (WARN(!(wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED), in __regulatory_set_wiphy_regd()
4024 return -EPERM; in __regulatory_set_wiphy_regd()
4028 rd->alpha2[0], rd->alpha2[1])) { in __regulatory_set_wiphy_regd()
4030 return -EINVAL; in __regulatory_set_wiphy_regd()
4040 prev_regd = rdev->requested_regd; in __regulatory_set_wiphy_regd()
4041 rdev->requested_regd = regd; in __regulatory_set_wiphy_regd()
4083 /* self-managed devices ignore beacon hints and country IE */ in wiphy_regulatory_register()
4084 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in wiphy_regulatory_register()
4085 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS | in wiphy_regulatory_register()
4093 if (lr->initiator == NL80211_REGDOM_SET_BY_USER) in wiphy_regulatory_register()
4100 wiphy_update_regulatory(wiphy, lr->initiator); in wiphy_regulatory_register()
4113 reg_num_devs_support_basehint--; in wiphy_regulatory_deregister()
4116 RCU_INIT_POINTER(wiphy->regd, NULL); in wiphy_regulatory_deregister()
4119 request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in wiphy_regulatory_deregister()
4124 lr->wiphy_idx = WIPHY_IDX_INVALID; in wiphy_regulatory_deregister()
4125 lr->country_ie_env = ENVIRON_ANY; in wiphy_regulatory_deregister()
4130 * 5GHz: https://www.fcc.gov/document/5-ghz-unlicensed-spectrum-unii
4131 * 6GHz: https://www.fcc.gov/document/fcc-proposes-more-spectrum-unlicensed-use-0
4135 /* UNII-1 */ in cfg80211_get_unii()
4139 /* UNII-2A */ in cfg80211_get_unii()
4143 /* UNII-2B */ in cfg80211_get_unii()
4147 /* UNII-2C */ in cfg80211_get_unii()
4151 /* UNII-3 */ in cfg80211_get_unii()
4155 /* UNII-5 */ in cfg80211_get_unii()
4159 /* UNII-6 */ in cfg80211_get_unii()
4163 /* UNII-7 */ in cfg80211_get_unii()
4167 /* UNII-8 */ in cfg80211_get_unii()
4171 return -EINVAL; in cfg80211_get_unii()
4188 wiphy_regd = rcu_dereference(wiphy->regd); in regulatory_pre_cac_allowed()
4190 if (regd->dfs_region == NL80211_DFS_ETSI) in regulatory_pre_cac_allowed()
4198 if (regd->dfs_region == wiphy_regd->dfs_region && in regulatory_pre_cac_allowed()
4199 wiphy_regd->dfs_region == NL80211_DFS_ETSI) in regulatory_pre_cac_allowed()
4214 * either all channels are available - those the CAC_FINISHED in cfg80211_check_and_end_cac()
4216 * in unavailable state in wdev chandef - those the RADAR_DETECTED in cfg80211_check_and_end_cac()
4220 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_check_and_end_cac()
4223 if (!wdev->cac_started) in cfg80211_check_and_end_cac()
4231 if (!cfg80211_chandef_dfs_usable(&rdev->wiphy, chandef)) in cfg80211_check_and_end_cac()
4232 rdev_end_cac(rdev, wdev->netdev); in cfg80211_check_and_end_cac()
4249 if (wiphy == &rdev->wiphy) in regulatory_propagate_dfs_state()
4252 if (!reg_dfs_domain_same(wiphy, &rdev->wiphy)) in regulatory_propagate_dfs_state()
4255 if (!ieee80211_get_channel(&rdev->wiphy, in regulatory_propagate_dfs_state()
4256 chandef->chan->center_freq)) in regulatory_propagate_dfs_state()
4259 cfg80211_set_dfs_state(&rdev->wiphy, chandef, dfs_state); in regulatory_propagate_dfs_state()
4276 * It's possible that - due to other bugs/issues - cfg80211 in regulatory_init_db()
4282 return -EINVAL; in regulatory_init_db()
4291 err = regulatory_hint_core(cfg80211_world_regdom->alpha2); in regulatory_init_db()
4293 if (err == -ENOMEM) { in regulatory_init_db()
4302 * errors as non-fatal. in regulatory_init_db()
4353 dev_set_uevent_suppress(&reg_pdev->dev, true); in regulatory_exit()
4358 list_del(&reg_beacon->list); in regulatory_exit()
4363 list_del(&reg_beacon->list); in regulatory_exit()
4368 list_del(&reg_request->list); in regulatory_exit()