• 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 - 2019 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
144 return rcu_dereference_rtnl(wiphy->regd); in get_wiphy_regdom()
175 if (wiphy_regd->dfs_region == regd->dfs_region) in reg_get_dfs_region()
179 dev_name(&wiphy->dev), in reg_get_dfs_region()
180 reg_dfs_region_str(wiphy_regd->dfs_region), in reg_get_dfs_region()
181 reg_dfs_region_str(regd->dfs_region)); in reg_get_dfs_region()
184 return regd->dfs_region; in reg_get_dfs_region()
227 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
229 REG_RULE(2467-10, 2472+10, 20, 6, 20,
231 /* IEEE 802.11 channel 14 - Only JP enables
233 REG_RULE(2484-10, 2484+10, 20, 6, 20,
237 REG_RULE(5180-10, 5240+10, 80, 6, 20,
241 /* IEEE 802.11a, channel 52..64 - DFS required */
242 REG_RULE(5260-10, 5320+10, 80, 6, 20,
247 /* IEEE 802.11a, channel 100..144 - DFS required */
248 REG_RULE(5500-10, 5720+10, 160, 6, 20,
253 REG_RULE(5745-10, 5825+10, 80, 6, 20,
257 REG_RULE(56160+2160*1-1080, 56160+2160*3+1080, 2160, 0, 0, 0),
270 MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code");
404 return !alpha2_equal(r->alpha2, alpha2); in regdom_changes()
432 regd = kzalloc(struct_size(regd, reg_rules, src_regd->n_reg_rules), in reg_copy_regd()
435 return ERR_PTR(-ENOMEM); in reg_copy_regd()
439 for (i = 0; i < src_regd->n_reg_rules; i++) in reg_copy_regd()
440 memcpy(&regd->reg_rules[i], &src_regd->reg_rules[i], in reg_copy_regd()
474 list_del(&request->list); in reg_regdb_apply()
476 set_regdom(request->regdom, REGD_SOURCE_INTERNAL_DB); in reg_regdb_apply()
493 return -ENOMEM; in reg_schedule_apply()
496 request->regdom = regdom; in reg_schedule_apply()
499 list_add_tail(&request->list, &reg_regdb_apply_list); in reg_schedule_apply()
540 * This lets us keep regulatory code which is updated on a regulatory
545 char country[12]; in call_crda() local
546 char *env[] = { country, NULL }; in call_crda()
549 snprintf(country, sizeof(country), "COUNTRY=%c%c", in call_crda()
554 return -EINVAL; in call_crda()
558 pr_debug("Calling CRDA for country: %c%c\n", in call_crda()
563 ret = kobject_uevent_env(&reg_pdev->dev.kobj, KOBJ_CHANGE, env); in call_crda()
577 return -ENODATA; in call_crda()
581 /* code to directly load a firmware database through request_firmware */
633 struct fwdb_country country[]; member
638 return (1 << ecw) - 1; in ecw2cw()
665 if ((u8 *)rule + sizeof(rule->len) > data + size) in valid_rule()
669 if (rule->len < offsetofend(struct fwdb_rule, max_bw)) in valid_rule()
671 if (rule->len >= offsetofend(struct fwdb_rule, wmm_ptr)) { in valid_rule()
672 u32 wmm_ptr = be16_to_cpu(rule->wmm_ptr) << 2; in valid_rule()
687 const struct fwdb_country *country) in valid_country() argument
689 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in valid_country()
699 if ((u8 *)coll + ALIGN(coll->len, 2) + in valid_country()
700 (coll->n_rules * 2) > data + size) in valid_country()
704 if (coll->len < offsetofend(struct fwdb_collection, dfs_region)) in valid_country()
707 rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in valid_country()
709 for (i = 0; i < coll->n_rules; i++) { in valid_country()
732 if (end - p < 4) in load_keys_from_buffer()
739 if (plen > end - p) in load_keys_from_buffer()
750 pr_err("Problem loading in-kernel X.509 certificate (%ld)\n", in load_keys_from_buffer()
754 key_ref_to_ptr(key)->description); in load_keys_from_buffer()
763 pr_err("Problem parsing in-kernel X.509 certificate list\n"); in load_keys_from_buffer()
777 pr_notice("Loading compiled-in X.509 certificates for regulatory database\n"); in load_builtin_regdb_keys()
797 if (request_firmware(&sig, "regulatory.db.p7s", &reg_pdev->dev)) in regdb_has_valid_signature()
800 result = verify_pkcs7_signature(data, size, sig->data, sig->size, in regdb_has_valid_signature()
833 const struct fwdb_country *country; in valid_regdb() local
838 if (hdr->magic != cpu_to_be32(FWDB_MAGIC)) in valid_regdb()
841 if (hdr->version != cpu_to_be32(FWDB_VERSION)) in valid_regdb()
847 country = &hdr->country[0]; in valid_regdb()
848 while ((u8 *)(country + 1) <= data + size) { in valid_regdb()
849 if (!country->coll_ptr) in valid_regdb()
851 if (!valid_country(data, size, country)) in valid_regdb()
853 country++; in valid_regdb()
860 const struct fwdb_country *country, in set_wmm_rule() argument
864 struct ieee80211_wmm_rule *wmm_rule = &rrule->wmm_rule; in set_wmm_rule()
868 wmm_ptr = be16_to_cpu(rule->wmm_ptr) << 2; in set_wmm_rule()
872 pr_err("Invalid regulatory WMM rule %u-%u in domain %c%c\n", in set_wmm_rule()
873 be32_to_cpu(rule->start), be32_to_cpu(rule->end), in set_wmm_rule()
874 country->alpha2[0], country->alpha2[1]); in set_wmm_rule()
879 wmm_rule->client[i].cw_min = in set_wmm_rule()
880 ecw2cw((wmm->client[i].ecw & 0xf0) >> 4); in set_wmm_rule()
881 wmm_rule->client[i].cw_max = ecw2cw(wmm->client[i].ecw & 0x0f); in set_wmm_rule()
882 wmm_rule->client[i].aifsn = wmm->client[i].aifsn; in set_wmm_rule()
883 wmm_rule->client[i].cot = in set_wmm_rule()
884 1000 * be16_to_cpu(wmm->client[i].cot); in set_wmm_rule()
885 wmm_rule->ap[i].cw_min = ecw2cw((wmm->ap[i].ecw & 0xf0) >> 4); in set_wmm_rule()
886 wmm_rule->ap[i].cw_max = ecw2cw(wmm->ap[i].ecw & 0x0f); in set_wmm_rule()
887 wmm_rule->ap[i].aifsn = wmm->ap[i].aifsn; in set_wmm_rule()
888 wmm_rule->ap[i].cot = 1000 * be16_to_cpu(wmm->ap[i].cot); in set_wmm_rule()
891 rrule->has_wmm = true; in set_wmm_rule()
895 const struct fwdb_country *country, int freq, in __regdb_query_wmm() argument
898 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in __regdb_query_wmm()
902 for (i = 0; i < coll->n_rules; i++) { in __regdb_query_wmm()
903 __be16 *rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in __regdb_query_wmm()
907 if (rule->len < offsetofend(struct fwdb_rule, wmm_ptr)) in __regdb_query_wmm()
910 if (freq >= KHZ_TO_MHZ(be32_to_cpu(rule->start)) && in __regdb_query_wmm()
911 freq <= KHZ_TO_MHZ(be32_to_cpu(rule->end))) { in __regdb_query_wmm()
912 set_wmm_rule(db, country, rule, rrule); in __regdb_query_wmm()
917 return -ENODATA; in __regdb_query_wmm()
923 const struct fwdb_country *country; in reg_query_regdb_wmm() local
926 return -ENODATA; in reg_query_regdb_wmm()
931 country = &hdr->country[0]; in reg_query_regdb_wmm()
932 while (country->coll_ptr) { in reg_query_regdb_wmm()
933 if (alpha2_equal(alpha2, country->alpha2)) in reg_query_regdb_wmm()
934 return __regdb_query_wmm(regdb, country, freq, rule); in reg_query_regdb_wmm()
936 country++; in reg_query_regdb_wmm()
939 return -ENODATA; in reg_query_regdb_wmm()
944 const struct fwdb_country *country) in regdb_query_country() argument
946 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in regdb_query_country()
951 regdom = kzalloc(struct_size(regdom, reg_rules, coll->n_rules), in regdb_query_country()
954 return -ENOMEM; in regdb_query_country()
956 regdom->n_reg_rules = coll->n_rules; in regdb_query_country()
957 regdom->alpha2[0] = country->alpha2[0]; in regdb_query_country()
958 regdom->alpha2[1] = country->alpha2[1]; in regdb_query_country()
959 regdom->dfs_region = coll->dfs_region; in regdb_query_country()
961 for (i = 0; i < regdom->n_reg_rules; i++) { in regdb_query_country()
962 __be16 *rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in regdb_query_country()
965 struct ieee80211_reg_rule *rrule = &regdom->reg_rules[i]; in regdb_query_country()
967 rrule->freq_range.start_freq_khz = be32_to_cpu(rule->start); in regdb_query_country()
968 rrule->freq_range.end_freq_khz = be32_to_cpu(rule->end); in regdb_query_country()
969 rrule->freq_range.max_bandwidth_khz = be32_to_cpu(rule->max_bw); in regdb_query_country()
971 rrule->power_rule.max_antenna_gain = 0; in regdb_query_country()
972 rrule->power_rule.max_eirp = be16_to_cpu(rule->max_eirp); in regdb_query_country()
974 rrule->flags = 0; in regdb_query_country()
975 if (rule->flags & FWDB_FLAG_NO_OFDM) in regdb_query_country()
976 rrule->flags |= NL80211_RRF_NO_OFDM; in regdb_query_country()
977 if (rule->flags & FWDB_FLAG_NO_OUTDOOR) in regdb_query_country()
978 rrule->flags |= NL80211_RRF_NO_OUTDOOR; in regdb_query_country()
979 if (rule->flags & FWDB_FLAG_DFS) in regdb_query_country()
980 rrule->flags |= NL80211_RRF_DFS; in regdb_query_country()
981 if (rule->flags & FWDB_FLAG_NO_IR) in regdb_query_country()
982 rrule->flags |= NL80211_RRF_NO_IR; in regdb_query_country()
983 if (rule->flags & FWDB_FLAG_AUTO_BW) in regdb_query_country()
984 rrule->flags |= NL80211_RRF_AUTO_BW; in regdb_query_country()
986 rrule->dfs_cac_ms = 0; in regdb_query_country()
989 if (rule->len >= offsetofend(struct fwdb_rule, cac_timeout)) in regdb_query_country()
990 rrule->dfs_cac_ms = in regdb_query_country()
991 1000 * be16_to_cpu(rule->cac_timeout); in regdb_query_country()
992 if (rule->len >= offsetofend(struct fwdb_rule, wmm_ptr)) in regdb_query_country()
993 set_wmm_rule(db, country, rule, rrule); in regdb_query_country()
1002 const struct fwdb_country *country; in query_regdb() local
1009 country = &hdr->country[0]; in query_regdb()
1010 while (country->coll_ptr) { in query_regdb()
1011 if (alpha2_equal(alpha2, country->alpha2)) in query_regdb()
1012 return regdb_query_country(regdb, country); in query_regdb()
1013 country++; in query_regdb()
1016 return -ENODATA; in query_regdb()
1027 set_error = -ENODATA; in regdb_fw_cb()
1028 } else if (!valid_regdb(fw->data, fw->size)) { in regdb_fw_cb()
1030 set_error = -EINVAL; in regdb_fw_cb()
1035 /* negative case - a bug in regdb_fw_cb()
1036 * positive case - can happen due to race in case of multiple cb's in in regdb_fw_cb()
1044 db = kmemdup(fw->data, fw->size, GFP_KERNEL); in regdb_fw_cb()
1076 return -ENOMEM; in query_regdb_file()
1079 &reg_pdev->dev, GFP_KERNEL, in query_regdb_file()
1093 err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev); in reg_reload_regdb()
1097 if (!valid_regdb(fw->data, fw->size)) { in reg_reload_regdb()
1098 err = -ENODATA; in reg_reload_regdb()
1102 db = kmemdup(fw->data, fw->size, GFP_KERNEL); in reg_reload_regdb()
1104 err = -ENOMEM; in reg_reload_regdb()
1121 if (query_regdb_file(request->alpha2) == 0) in reg_query_database()
1124 if (call_crda(request->alpha2) == 0) in reg_query_database()
1134 if (!lr || lr->processed) in reg_is_valid_request()
1137 return alpha2_equal(lr->alpha2, alpha2); in reg_is_valid_request()
1145 * Follow the driver's regulatory domain, if present, unless a country in reg_get_regdomain()
1148 if (lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && in reg_get_regdomain()
1149 lr->initiator != NL80211_REGDOM_SET_BY_USER && in reg_get_regdomain()
1150 wiphy->regd) in reg_get_regdomain()
1160 const struct ieee80211_freq_range *freq_range = &rule->freq_range; in reg_get_max_bandwidth_from_range()
1165 for (idx = 0; idx < rd->n_reg_rules; idx++) in reg_get_max_bandwidth_from_range()
1166 if (rule == &rd->reg_rules[idx]) in reg_get_max_bandwidth_from_range()
1169 if (idx == rd->n_reg_rules) in reg_get_max_bandwidth_from_range()
1176 tmp = &rd->reg_rules[--no]; in reg_get_max_bandwidth_from_range()
1177 freq_range_tmp = &tmp->freq_range; in reg_get_max_bandwidth_from_range()
1179 if (freq_range_tmp->end_freq_khz < freq_range->start_freq_khz) in reg_get_max_bandwidth_from_range()
1185 start_freq = freq_range->start_freq_khz; in reg_get_max_bandwidth_from_range()
1188 freq_range = &rule->freq_range; in reg_get_max_bandwidth_from_range()
1191 while (no < rd->n_reg_rules - 1) { in reg_get_max_bandwidth_from_range()
1192 tmp = &rd->reg_rules[++no]; in reg_get_max_bandwidth_from_range()
1193 freq_range_tmp = &tmp->freq_range; in reg_get_max_bandwidth_from_range()
1195 if (freq_range_tmp->start_freq_khz > freq_range->end_freq_khz) in reg_get_max_bandwidth_from_range()
1201 end_freq = freq_range->end_freq_khz; in reg_get_max_bandwidth_from_range()
1203 return end_freq - start_freq; in reg_get_max_bandwidth_from_range()
1211 if (rule->flags & NL80211_RRF_NO_160MHZ) in reg_get_max_bandwidth()
1213 if (rule->flags & NL80211_RRF_NO_80MHZ) in reg_get_max_bandwidth()
1217 * HT40+/HT40- limits are handled per-channel. Only limit BW if both in reg_get_max_bandwidth()
1220 if (rule->flags & NL80211_RRF_NO_HT40MINUS && in reg_get_max_bandwidth()
1221 rule->flags & NL80211_RRF_NO_HT40PLUS) in reg_get_max_bandwidth()
1230 const struct ieee80211_freq_range *freq_range = &rule->freq_range; in is_valid_reg_rule()
1233 if (freq_range->start_freq_khz <= 0 || freq_range->end_freq_khz <= 0) in is_valid_reg_rule()
1236 if (freq_range->start_freq_khz > freq_range->end_freq_khz) in is_valid_reg_rule()
1239 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; in is_valid_reg_rule()
1241 if (freq_range->end_freq_khz <= freq_range->start_freq_khz || in is_valid_reg_rule()
1242 freq_range->max_bandwidth_khz > freq_diff) in is_valid_reg_rule()
1253 if (!rd->n_reg_rules) in is_valid_rd()
1256 if (WARN_ON(rd->n_reg_rules > NL80211_MAX_SUPP_REG_RULES)) in is_valid_rd()
1259 for (i = 0; i < rd->n_reg_rules; i++) { in is_valid_rd()
1260 reg_rule = &rd->reg_rules[i]; in is_valid_rd()
1269 * freq_in_rule_band - tells us if a frequency is in a frequency band
1288 * From 802.11ad: directional multi-gigabit (DMG): in freq_in_rule_band()
1294 if (abs(freq_khz - freq_range->start_freq_khz) <= limit) in freq_in_rule_band()
1296 if (abs(freq_khz - freq_range->end_freq_khz) <= limit) in freq_in_rule_band()
1320 intersect->cw_min = max_t(u16, wmm_ac1->cw_min, wmm_ac2->cw_min); in reg_wmm_rules_intersect()
1321 intersect->cw_max = max_t(u16, wmm_ac1->cw_max, wmm_ac2->cw_max); in reg_wmm_rules_intersect()
1322 intersect->cot = min_t(u16, wmm_ac1->cot, wmm_ac2->cot); in reg_wmm_rules_intersect()
1323 intersect->aifsn = max_t(u8, wmm_ac1->aifsn, wmm_ac2->aifsn); in reg_wmm_rules_intersect()
1344 freq_range1 = &rule1->freq_range; in reg_rules_intersect()
1345 freq_range2 = &rule2->freq_range; in reg_rules_intersect()
1346 freq_range = &intersected_rule->freq_range; in reg_rules_intersect()
1348 power_rule1 = &rule1->power_rule; in reg_rules_intersect()
1349 power_rule2 = &rule2->power_rule; in reg_rules_intersect()
1350 power_rule = &intersected_rule->power_rule; in reg_rules_intersect()
1352 wmm_rule1 = &rule1->wmm_rule; in reg_rules_intersect()
1353 wmm_rule2 = &rule2->wmm_rule; in reg_rules_intersect()
1354 wmm_rule = &intersected_rule->wmm_rule; in reg_rules_intersect()
1356 freq_range->start_freq_khz = max(freq_range1->start_freq_khz, in reg_rules_intersect()
1357 freq_range2->start_freq_khz); in reg_rules_intersect()
1358 freq_range->end_freq_khz = min(freq_range1->end_freq_khz, in reg_rules_intersect()
1359 freq_range2->end_freq_khz); in reg_rules_intersect()
1361 max_bandwidth1 = freq_range1->max_bandwidth_khz; in reg_rules_intersect()
1362 max_bandwidth2 = freq_range2->max_bandwidth_khz; in reg_rules_intersect()
1364 if (rule1->flags & NL80211_RRF_AUTO_BW) in reg_rules_intersect()
1366 if (rule2->flags & NL80211_RRF_AUTO_BW) in reg_rules_intersect()
1369 freq_range->max_bandwidth_khz = min(max_bandwidth1, max_bandwidth2); in reg_rules_intersect()
1371 intersected_rule->flags = rule1->flags | rule2->flags; in reg_rules_intersect()
1381 if ((rule1->flags & NL80211_RRF_AUTO_BW) && in reg_rules_intersect()
1382 (rule2->flags & NL80211_RRF_AUTO_BW)) in reg_rules_intersect()
1383 intersected_rule->flags |= NL80211_RRF_AUTO_BW; in reg_rules_intersect()
1385 intersected_rule->flags &= ~NL80211_RRF_AUTO_BW; in reg_rules_intersect()
1387 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; in reg_rules_intersect()
1388 if (freq_range->max_bandwidth_khz > freq_diff) in reg_rules_intersect()
1389 freq_range->max_bandwidth_khz = freq_diff; in reg_rules_intersect()
1391 power_rule->max_eirp = min(power_rule1->max_eirp, in reg_rules_intersect()
1392 power_rule2->max_eirp); in reg_rules_intersect()
1393 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain, in reg_rules_intersect()
1394 power_rule2->max_antenna_gain); in reg_rules_intersect()
1396 intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms, in reg_rules_intersect()
1397 rule2->dfs_cac_ms); in reg_rules_intersect()
1399 if (rule1->has_wmm && rule2->has_wmm) { in reg_rules_intersect()
1403 reg_wmm_rules_intersect(&wmm_rule1->client[ac], in reg_rules_intersect()
1404 &wmm_rule2->client[ac], in reg_rules_intersect()
1405 &wmm_rule->client[ac]); in reg_rules_intersect()
1406 reg_wmm_rules_intersect(&wmm_rule1->ap[ac], in reg_rules_intersect()
1407 &wmm_rule2->ap[ac], in reg_rules_intersect()
1408 &wmm_rule->ap[ac]); in reg_rules_intersect()
1411 intersected_rule->has_wmm = true; in reg_rules_intersect()
1412 } else if (rule1->has_wmm) { in reg_rules_intersect()
1414 intersected_rule->has_wmm = true; in reg_rules_intersect()
1415 } else if (rule2->has_wmm) { in reg_rules_intersect()
1417 intersected_rule->has_wmm = true; in reg_rules_intersect()
1419 intersected_rule->has_wmm = false; in reg_rules_intersect()
1423 return -EINVAL; in reg_rules_intersect()
1433 if (r1->flags != r2->flags) in rule_contains()
1437 if ((r1->power_rule.max_antenna_gain > in rule_contains()
1438 r2->power_rule.max_antenna_gain) || in rule_contains()
1439 r1->power_rule.max_eirp > r2->power_rule.max_eirp) in rule_contains()
1443 if (r1->freq_range.start_freq_khz > r2->freq_range.start_freq_khz || in rule_contains()
1444 r1->freq_range.end_freq_khz < r2->freq_range.end_freq_khz) in rule_contains()
1448 if (r1->freq_range.max_bandwidth_khz < in rule_contains()
1449 r2->freq_range.max_bandwidth_khz) in rule_contains()
1464 /* rule is already contained - do nothing */ in add_rule()
1480 * regdom_intersect - do the intersection between two regulatory domains
1510 * is it will return -EINVAL if the rule computed makes no sense. in regdom_intersect()
1514 for (x = 0; x < rd1->n_reg_rules; x++) { in regdom_intersect()
1515 rule1 = &rd1->reg_rules[x]; in regdom_intersect()
1516 for (y = 0; y < rd2->n_reg_rules; y++) { in regdom_intersect()
1517 rule2 = &rd2->reg_rules[y]; in regdom_intersect()
1531 for (x = 0; x < rd1->n_reg_rules; x++) { in regdom_intersect()
1532 rule1 = &rd1->reg_rules[x]; in regdom_intersect()
1533 for (y = 0; y < rd2->n_reg_rules; y++) { in regdom_intersect()
1534 rule2 = &rd2->reg_rules[y]; in regdom_intersect()
1544 add_rule(&intersected_rule, rd->reg_rules, in regdom_intersect()
1545 &rd->n_reg_rules); in regdom_intersect()
1549 rd->alpha2[0] = '9'; in regdom_intersect()
1550 rd->alpha2[1] = '8'; in regdom_intersect()
1551 rd->dfs_region = reg_intersect_dfs_region(rd1->dfs_region, in regdom_intersect()
1552 rd2->dfs_region); in regdom_intersect()
1596 return ERR_PTR(-EINVAL); in freq_reg_info_regd()
1598 for (i = 0; i < regd->n_reg_rules; i++) { in freq_reg_info_regd()
1602 rr = &regd->reg_rules[i]; in freq_reg_info_regd()
1603 fr = &rr->freq_range; in freq_reg_info_regd()
1620 return ERR_PTR(-ERANGE); in freq_reg_info_regd()
1622 return ERR_PTR(-EINVAL); in freq_reg_info_regd()
1631 int i = ARRAY_SIZE(bws) - 1; in __freq_reg_info()
1634 for (bw = MHZ_TO_KHZ(bws[i]); bw >= min_bw; bw = MHZ_TO_KHZ(bws[i--])) { in __freq_reg_info()
1662 return "country element"; in reg_initiator_name()
1676 bool is_s1g = chan->band == NL80211_BAND_S1GHZ; in reg_rule_to_chan_bw_flags()
1678 freq_range = &reg_rule->freq_range; in reg_rule_to_chan_bw_flags()
1680 max_bandwidth_khz = freq_range->max_bandwidth_khz; in reg_rule_to_chan_bw_flags()
1683 if (reg_rule->flags & NL80211_RRF_AUTO_BW) in reg_rule_to_chan_bw_flags()
1705 edge_offset = (center_freq_khz - ch_bw / 2) - in reg_rule_to_chan_bw_flags()
1706 freq_range->start_freq_khz; in reg_rule_to_chan_bw_flags()
1764 power_rule = &reg_rule->power_rule; in handle_channel_single_rule()
1767 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel_single_rule()
1769 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel_single_rule()
1775 chan->flags = chan->orig_flags = in handle_channel_single_rule()
1776 map_regdom_flags(reg_rule->flags) | bw_flags; in handle_channel_single_rule()
1777 chan->max_antenna_gain = chan->orig_mag = in handle_channel_single_rule()
1778 (int) MBI_TO_DBI(power_rule->max_antenna_gain); in handle_channel_single_rule()
1779 chan->max_reg_power = chan->max_power = chan->orig_mpwr = in handle_channel_single_rule()
1780 (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_single_rule()
1782 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_single_rule()
1783 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_single_rule()
1784 if (reg_rule->dfs_cac_ms) in handle_channel_single_rule()
1785 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_single_rule()
1791 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_single_rule()
1792 chan->dfs_state_entered = jiffies; in handle_channel_single_rule()
1794 chan->beacon_found = false; in handle_channel_single_rule()
1795 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); in handle_channel_single_rule()
1796 chan->max_antenna_gain = in handle_channel_single_rule()
1797 min_t(int, chan->orig_mag, in handle_channel_single_rule()
1798 MBI_TO_DBI(power_rule->max_antenna_gain)); in handle_channel_single_rule()
1799 chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_single_rule()
1801 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_single_rule()
1802 if (reg_rule->dfs_cac_ms) in handle_channel_single_rule()
1803 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_single_rule()
1805 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_single_rule()
1808 if (chan->orig_mpwr) { in handle_channel_single_rule()
1811 * will always follow the passed country IE power settings. in handle_channel_single_rule()
1814 wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_FOLLOW_POWER) in handle_channel_single_rule()
1815 chan->max_power = chan->max_reg_power; in handle_channel_single_rule()
1817 chan->max_power = min(chan->orig_mpwr, in handle_channel_single_rule()
1818 chan->max_reg_power); in handle_channel_single_rule()
1820 chan->max_power = chan->max_reg_power; in handle_channel_single_rule()
1841 power_rule1 = &rrule1->power_rule; in handle_channel_adjacent_rules()
1842 power_rule2 = &rrule2->power_rule; in handle_channel_adjacent_rules()
1846 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel_adjacent_rules()
1848 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel_adjacent_rules()
1853 chan->flags = in handle_channel_adjacent_rules()
1854 map_regdom_flags(rrule1->flags) | in handle_channel_adjacent_rules()
1855 map_regdom_flags(rrule2->flags) | in handle_channel_adjacent_rules()
1858 chan->orig_flags = chan->flags; in handle_channel_adjacent_rules()
1859 chan->max_antenna_gain = in handle_channel_adjacent_rules()
1860 min_t(int, MBI_TO_DBI(power_rule1->max_antenna_gain), in handle_channel_adjacent_rules()
1861 MBI_TO_DBI(power_rule2->max_antenna_gain)); in handle_channel_adjacent_rules()
1862 chan->orig_mag = chan->max_antenna_gain; in handle_channel_adjacent_rules()
1863 chan->max_reg_power = in handle_channel_adjacent_rules()
1864 min_t(int, MBM_TO_DBM(power_rule1->max_eirp), in handle_channel_adjacent_rules()
1865 MBM_TO_DBM(power_rule2->max_eirp)); in handle_channel_adjacent_rules()
1866 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1867 chan->orig_mpwr = chan->max_reg_power; in handle_channel_adjacent_rules()
1869 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_adjacent_rules()
1870 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_adjacent_rules()
1871 if (rrule1->dfs_cac_ms || rrule2->dfs_cac_ms) in handle_channel_adjacent_rules()
1872 chan->dfs_cac_ms = max_t(unsigned int, in handle_channel_adjacent_rules()
1873 rrule1->dfs_cac_ms, in handle_channel_adjacent_rules()
1874 rrule2->dfs_cac_ms); in handle_channel_adjacent_rules()
1880 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_adjacent_rules()
1881 chan->dfs_state_entered = jiffies; in handle_channel_adjacent_rules()
1883 chan->beacon_found = false; in handle_channel_adjacent_rules()
1884 chan->flags = flags | bw_flags1 | bw_flags2 | in handle_channel_adjacent_rules()
1885 map_regdom_flags(rrule1->flags) | in handle_channel_adjacent_rules()
1886 map_regdom_flags(rrule2->flags); in handle_channel_adjacent_rules()
1894 chan->flags &= ~IEEE80211_CHAN_NO_10MHZ; in handle_channel_adjacent_rules()
1898 chan->flags &= ~IEEE80211_CHAN_NO_20MHZ; in handle_channel_adjacent_rules()
1900 chan->max_antenna_gain = in handle_channel_adjacent_rules()
1901 min_t(int, chan->orig_mag, in handle_channel_adjacent_rules()
1903 MBI_TO_DBI(power_rule1->max_antenna_gain), in handle_channel_adjacent_rules()
1904 MBI_TO_DBI(power_rule2->max_antenna_gain))); in handle_channel_adjacent_rules()
1905 chan->max_reg_power = min_t(int, in handle_channel_adjacent_rules()
1906 MBM_TO_DBM(power_rule1->max_eirp), in handle_channel_adjacent_rules()
1907 MBM_TO_DBM(power_rule2->max_eirp)); in handle_channel_adjacent_rules()
1909 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_adjacent_rules()
1910 if (rrule1->dfs_cac_ms || rrule2->dfs_cac_ms) in handle_channel_adjacent_rules()
1911 chan->dfs_cac_ms = max_t(unsigned int, in handle_channel_adjacent_rules()
1912 rrule1->dfs_cac_ms, in handle_channel_adjacent_rules()
1913 rrule2->dfs_cac_ms); in handle_channel_adjacent_rules()
1915 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_adjacent_rules()
1918 if (chan->orig_mpwr) { in handle_channel_adjacent_rules()
1920 * will always follow the passed country IE power settings. in handle_channel_adjacent_rules()
1923 wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_FOLLOW_POWER) in handle_channel_adjacent_rules()
1924 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1926 chan->max_power = min(chan->orig_mpwr, in handle_channel_adjacent_rules()
1927 chan->max_reg_power); in handle_channel_adjacent_rules()
1929 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1943 struct wiphy *request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in handle_channel()
1948 u32 flags = chan->orig_flags; in handle_channel()
1953 * chan - 20 MHz and chan + 20 MHz and test in handle_channel()
1957 orig_chan_freq - MHZ_TO_KHZ(20)); in handle_channel()
1963 if (rrule1->freq_range.end_freq_khz != in handle_channel()
1964 rrule2->freq_range.start_freq_khz) in handle_channel()
1968 rrule1->freq_range.start_freq_khz; in handle_channel()
1970 rrule2->freq_range.end_freq_khz; in handle_channel()
1973 rrule1->freq_range.max_bandwidth_khz, in handle_channel()
1974 rrule2->freq_range.max_bandwidth_khz); in handle_channel()
1991 * from a Country IE and the Country IE had no information in handle_channel()
1995 * a country IE with information for the 2.4 GHz band in handle_channel()
1999 PTR_ERR(rrule) == -ERANGE) in handle_channel()
2002 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel()
2004 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel()
2006 chan->center_freq, chan->freq_offset); in handle_channel()
2007 chan->orig_flags |= IEEE80211_CHAN_DISABLED; in handle_channel()
2008 chan->flags = chan->orig_flags; in handle_channel()
2011 chan->center_freq, chan->freq_offset); in handle_channel()
2012 chan->flags |= IEEE80211_CHAN_DISABLED; in handle_channel()
2030 for (i = 0; i < sband->n_channels; i++) in handle_band()
2031 handle_channel(wiphy, initiator, &sband->channels[i]); in handle_band()
2036 if (request->initiator != NL80211_REGDOM_SET_BY_USER) in reg_request_cell_base()
2038 return request->user_reg_hint_type == NL80211_USER_REG_HINT_CELL_BASE; in reg_request_cell_base()
2057 !regdom_changes(pending_request->alpha2)) in reg_ignore_cell_hint()
2066 return !(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS); in reg_dev_ignore_cell_hint()
2083 if (wiphy->regulatory_flags & REGULATORY_STRICT_REG && in wiphy_strict_alpha2_regd()
2084 !(wiphy->regulatory_flags & REGULATORY_CUSTOM_REG)) in wiphy_strict_alpha2_regd()
2094 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in ignore_reg_update()
2104 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) { in ignore_reg_update()
2111 * wiphy->regd will be set once the device has its own in ignore_reg_update()
2114 if (wiphy_strict_alpha2_regd(wiphy) && !wiphy->regd && in ignore_reg_update()
2116 !is_world_regdom(lr->alpha2)) { in ignore_reg_update()
2134 if (is_world_regdom(cr->alpha2) || (wr && is_world_regdom(wr->alpha2))) in reg_is_world_roaming()
2137 if (lr && lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && in reg_is_world_roaming()
2138 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) in reg_is_world_roaming()
2152 sband = wiphy->bands[reg_beacon->chan.band]; in handle_reg_beacon()
2153 chan = &sband->channels[chan_idx]; in handle_reg_beacon()
2155 if (likely(!ieee80211_channel_equal(chan, &reg_beacon->chan))) in handle_reg_beacon()
2158 if (chan->beacon_found) in handle_reg_beacon()
2161 chan->beacon_found = true; in handle_reg_beacon()
2166 if (wiphy->regulatory_flags & REGULATORY_DISABLE_BEACON_HINTS) in handle_reg_beacon()
2171 if (chan->flags & IEEE80211_CHAN_NO_IR) { in handle_reg_beacon()
2172 chan->flags &= ~IEEE80211_CHAN_NO_IR; in handle_reg_beacon()
2190 if (!wiphy->bands[reg_beacon->chan.band]) in wiphy_update_new_beacon()
2193 sband = wiphy->bands[reg_beacon->chan.band]; in wiphy_update_new_beacon()
2195 for (i = 0; i < sband->n_channels; i++) in wiphy_update_new_beacon()
2209 if (!wiphy->bands[reg_beacon->chan.band]) in wiphy_update_beacon_reg()
2211 sband = wiphy->bands[reg_beacon->chan.band]; in wiphy_update_beacon_reg()
2212 for (i = 0; i < sband->n_channels; i++) in wiphy_update_beacon_reg()
2233 if (chan->flags & IEEE80211_CHAN_DISABLED) in is_ht40_allowed()
2236 if ((chan->flags & IEEE80211_CHAN_NO_HT40) == IEEE80211_CHAN_NO_HT40) in is_ht40_allowed()
2244 struct ieee80211_supported_band *sband = wiphy->bands[channel->band]; in reg_process_ht_flags_channel()
2251 channel->flags |= IEEE80211_CHAN_NO_HT40; in reg_process_ht_flags_channel()
2257 * be able to use HT40- or HT40+, this finds them (or not) in reg_process_ht_flags_channel()
2259 for (i = 0; i < sband->n_channels; i++) { in reg_process_ht_flags_channel()
2260 struct ieee80211_channel *c = &sband->channels[i]; in reg_process_ht_flags_channel()
2262 if (c->center_freq == (channel->center_freq - 20)) in reg_process_ht_flags_channel()
2264 if (c->center_freq == (channel->center_freq + 20)) in reg_process_ht_flags_channel()
2272 freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq), in reg_process_ht_flags_channel()
2276 flags = reg_rule->flags; in reg_process_ht_flags_channel()
2286 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS; in reg_process_ht_flags_channel()
2288 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS; in reg_process_ht_flags_channel()
2292 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS; in reg_process_ht_flags_channel()
2294 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS; in reg_process_ht_flags_channel()
2305 for (i = 0; i < sband->n_channels; i++) in reg_process_ht_flags_band()
2306 reg_process_ht_flags_channel(wiphy, &sband->channels[i]); in reg_process_ht_flags_band()
2317 reg_process_ht_flags_band(wiphy, wiphy->bands[band]); in reg_process_ht_flags()
2323 if (wiphy->reg_notifier) in reg_call_notifier()
2324 wiphy->reg_notifier(wiphy, request); in reg_call_notifier()
2334 iftype = wdev->iftype; in reg_wdev_chan_valid()
2337 if (!wdev->netdev || !netif_running(wdev->netdev)) in reg_wdev_chan_valid()
2343 if (!wdev->beacon_interval) in reg_wdev_chan_valid()
2345 chandef = wdev->chandef; in reg_wdev_chan_valid()
2348 if (!wdev->ssid_len) in reg_wdev_chan_valid()
2350 chandef = wdev->chandef; in reg_wdev_chan_valid()
2354 if (!wdev->current_bss || in reg_wdev_chan_valid()
2355 !wdev->current_bss->pub.channel) in reg_wdev_chan_valid()
2358 if (!rdev->ops->get_channel || in reg_wdev_chan_valid()
2361 wdev->current_bss->pub.channel, in reg_wdev_chan_valid()
2404 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) in reg_leave_invalid_chans()
2417 if (!(rdev->wiphy.regulatory_flags & in reg_check_chans_work()
2419 reg_leave_invalid_chans(&rdev->wiphy); in reg_check_chans_work()
2448 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG && in wiphy_update_regulatory()
2449 !(wiphy->regulatory_flags & in wiphy_update_regulatory()
2455 lr->dfs_region = get_cfg80211_regdom()->dfs_region; in wiphy_update_regulatory()
2458 handle_band(wiphy, initiator, wiphy->bands[band]); in wiphy_update_regulatory()
2473 wiphy = &rdev->wiphy; in update_all_wiphy_regulatory()
2499 chan->center_freq, chan->freq_offset); in handle_channel_custom()
2500 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in handle_channel_custom()
2501 chan->flags |= IEEE80211_CHAN_DISABLED; in handle_channel_custom()
2503 chan->orig_flags |= IEEE80211_CHAN_DISABLED; in handle_channel_custom()
2504 chan->flags = chan->orig_flags; in handle_channel_custom()
2509 power_rule = &reg_rule->power_rule; in handle_channel_custom()
2512 chan->dfs_state_entered = jiffies; in handle_channel_custom()
2513 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_custom()
2515 chan->beacon_found = false; in handle_channel_custom()
2517 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in handle_channel_custom()
2518 chan->flags = chan->orig_flags | bw_flags | in handle_channel_custom()
2519 map_regdom_flags(reg_rule->flags); in handle_channel_custom()
2521 chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; in handle_channel_custom()
2523 chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); in handle_channel_custom()
2524 chan->max_reg_power = chan->max_power = in handle_channel_custom()
2525 (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_custom()
2527 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_custom()
2528 if (reg_rule->dfs_cac_ms) in handle_channel_custom()
2529 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_custom()
2531 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_custom()
2534 chan->max_power = chan->max_reg_power; in handle_channel_custom()
2549 * compatible to US, which permits 2402 - 2472 MHz. in handle_band_custom()
2551 for (i = 0; i < sband->n_channels; i++) in handle_band_custom()
2552 handle_channel_custom(wiphy, &sband->channels[i], regd, in handle_band_custom()
2563 WARN(!(wiphy->regulatory_flags & REGULATORY_CUSTOM_REG), in wiphy_apply_custom_regulatory()
2565 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; in wiphy_apply_custom_regulatory()
2568 if (!wiphy->bands[band]) in wiphy_apply_custom_regulatory()
2570 handle_band_custom(wiphy, wiphy->bands[band], regd); in wiphy_apply_custom_regulatory()
2587 lr->processed = true; in reg_set_request_processed()
2601 * reg_process_hint_core - process core regulatory requests
2611 core_request->intersect = false; in reg_process_hint_core()
2612 core_request->processed = false; in reg_process_hint_core()
2631 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) in __reg_process_hint_user()
2635 * to their country before the IE is picked up in __reg_process_hint_user()
2637 if (lr->initiator == NL80211_REGDOM_SET_BY_USER && in __reg_process_hint_user()
2638 lr->intersect) in __reg_process_hint_user()
2644 if ((lr->initiator == NL80211_REGDOM_SET_BY_CORE || in __reg_process_hint_user()
2645 lr->initiator == NL80211_REGDOM_SET_BY_DRIVER || in __reg_process_hint_user()
2646 lr->initiator == NL80211_REGDOM_SET_BY_USER) && in __reg_process_hint_user()
2647 regdom_changes(lr->alpha2)) in __reg_process_hint_user()
2650 if (!regdom_changes(user_request->alpha2)) in __reg_process_hint_user()
2657 * reg_process_hint_user - process user regulatory requests
2673 user_request->intersect = treatment == REG_REQ_INTERSECT; in reg_process_hint_user()
2674 user_request->processed = false; in reg_process_hint_user()
2678 user_alpha2[0] = user_request->alpha2[0]; in reg_process_hint_user()
2679 user_alpha2[1] = user_request->alpha2[1]; in reg_process_hint_user()
2691 if (lr->initiator == NL80211_REGDOM_SET_BY_CORE) { in __reg_process_hint_driver()
2692 if (regdom_changes(driver_request->alpha2)) in __reg_process_hint_driver()
2702 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in __reg_process_hint_driver()
2703 !regdom_changes(driver_request->alpha2)) in __reg_process_hint_driver()
2710 * reg_process_hint_driver - process driver regulatory requests
2740 rcu_assign_pointer(wiphy->regd, regd); in reg_process_hint_driver()
2745 driver_request->intersect = treatment == REG_REQ_INTERSECT; in reg_process_hint_driver()
2746 driver_request->processed = false; in reg_process_hint_driver()
2776 /* Trust a Cell base station over the AP's country IE */ in __reg_process_hint_country_ie()
2777 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2781 if (wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_IGNORE) in __reg_process_hint_country_ie()
2785 if (unlikely(!is_an_alpha2(country_ie_request->alpha2))) in __reg_process_hint_country_ie()
2786 return -EINVAL; in __reg_process_hint_country_ie()
2788 if (lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) in __reg_process_hint_country_ie()
2791 last_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in __reg_process_hint_country_ie()
2796 * Country IE alpha2s. We could in __reg_process_hint_country_ie()
2800 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2805 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2811 * reg_process_hint_country_ie - process regulatory requests from country IEs
2813 * @country_ie_request: a regulatory request from a country IE
2816 * a regulatory request issued by a country Information Element.
2841 WARN_ONCE(1, "Unexpected intersection for country elements"); in reg_process_hint_country_ie()
2845 country_ie_request->intersect = false; in reg_process_hint_country_ie()
2846 country_ie_request->processed = false; in reg_process_hint_country_ie()
2866 wiphy1_regd = rcu_dereference(wiphy1->regd); in reg_dfs_domain_same()
2870 wiphy2_regd = rcu_dereference(wiphy2->regd); in reg_dfs_domain_same()
2874 dfs_domain_same = wiphy1_regd->dfs_region == wiphy2_regd->dfs_region; in reg_dfs_domain_same()
2884 if (!(dst_chan->flags & IEEE80211_CHAN_RADAR) || in reg_copy_dfs_chan_state()
2885 !(src_chan->flags & IEEE80211_CHAN_RADAR)) in reg_copy_dfs_chan_state()
2888 if (dst_chan->flags & IEEE80211_CHAN_DISABLED || in reg_copy_dfs_chan_state()
2889 src_chan->flags & IEEE80211_CHAN_DISABLED) in reg_copy_dfs_chan_state()
2892 if (src_chan->center_freq == dst_chan->center_freq && in reg_copy_dfs_chan_state()
2893 dst_chan->dfs_state == NL80211_DFS_USABLE) { in reg_copy_dfs_chan_state()
2894 dst_chan->dfs_state = src_chan->dfs_state; in reg_copy_dfs_chan_state()
2895 dst_chan->dfs_state_entered = src_chan->dfs_state_entered; in reg_copy_dfs_chan_state()
2910 dst_sband = dst_wiphy->bands[band]; in wiphy_share_dfs_chan_state()
2911 src_sband = src_wiphy->bands[band]; in wiphy_share_dfs_chan_state()
2915 for (i = 0; i < dst_sband->n_channels; i++) { in wiphy_share_dfs_chan_state()
2916 dst_chan = &dst_sband->channels[i]; in wiphy_share_dfs_chan_state()
2917 for (j = 0; j < src_sband->n_channels; j++) { in wiphy_share_dfs_chan_state()
2918 src_chan = &src_sband->channels[j]; in wiphy_share_dfs_chan_state()
2932 if (wiphy == &rdev->wiphy) in wiphy_all_share_dfs_chan_state()
2934 wiphy_share_dfs_chan_state(wiphy, &rdev->wiphy); in wiphy_all_share_dfs_chan_state()
2943 enum nl80211_reg_initiator initiator = reg_request->initiator; in reg_process_hint()
2945 if (reg_request->wiphy_idx != WIPHY_IDX_INVALID) in reg_process_hint()
2946 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); in reg_process_hint()
2980 wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in reg_process_hint()
2998 wiphy = &rdev->wiphy; in notify_self_managed_wiphys()
2999 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && in notify_self_managed_wiphys()
3000 request->initiator == NL80211_REGDOM_SET_BY_USER) in notify_self_managed_wiphys()
3016 /* When last_request->processed becomes true this will be rescheduled */ in reg_process_pending_hints()
3017 if (lr && !lr->processed) { in reg_process_pending_hints()
3032 list_del_init(&reg_request->list); in reg_process_pending_hints()
3043 if (!list_empty(&reg_requests_list) && lr && lr->processed) in reg_process_pending_hints()
3048 /* Processes beacon hints -- this has nothing to do with country IEs */
3059 list_del_init(&pending_beacon->list); in reg_process_pending_beacon_hints()
3063 wiphy_update_new_beacon(&rdev->wiphy, pending_beacon); in reg_process_pending_beacon_hints()
3066 list_add_tail(&pending_beacon->list, &reg_beacon_list); in reg_process_pending_beacon_hints()
3082 wiphy = &rdev->wiphy; in reg_process_self_managed_hints()
3085 regd = rdev->requested_regd; in reg_process_self_managed_hints()
3086 rdev->requested_regd = NULL; in reg_process_self_managed_hints()
3093 rcu_assign_pointer(wiphy->regd, regd); in reg_process_self_managed_hints()
3097 handle_band_custom(wiphy, wiphy->bands[band], regd); in reg_process_self_managed_hints()
3102 request.alpha2[0] = regd->alpha2[0]; in reg_process_self_managed_hints()
3103 request.alpha2[1] = regd->alpha2[1]; in reg_process_self_managed_hints()
3123 request->alpha2[0] = toupper(request->alpha2[0]); in queue_regulatory_request()
3124 request->alpha2[1] = toupper(request->alpha2[1]); in queue_regulatory_request()
3127 list_add_tail(&request->list, &reg_requests_list); in queue_regulatory_request()
3134 * Core regulatory hint -- happens during cfg80211_init()
3143 return -ENOMEM; in regulatory_hint_core()
3145 request->alpha2[0] = alpha2[0]; in regulatory_hint_core()
3146 request->alpha2[1] = alpha2[1]; in regulatory_hint_core()
3147 request->initiator = NL80211_REGDOM_SET_BY_CORE; in regulatory_hint_core()
3148 request->wiphy_idx = WIPHY_IDX_INVALID; in regulatory_hint_core()
3162 return -EINVAL; in regulatory_hint_user()
3165 return -EINVAL; in regulatory_hint_user()
3169 return -ENOMEM; in regulatory_hint_user()
3171 request->wiphy_idx = WIPHY_IDX_INVALID; in regulatory_hint_user()
3172 request->alpha2[0] = alpha2[0]; in regulatory_hint_user()
3173 request->alpha2[1] = alpha2[1]; in regulatory_hint_user()
3174 request->initiator = NL80211_REGDOM_SET_BY_USER; in regulatory_hint_user()
3175 request->user_reg_hint_type = user_reg_hint_type; in regulatory_hint_user()
3235 return -EINVAL; in regulatory_hint()
3237 wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG; in regulatory_hint()
3241 return -ENOMEM; in regulatory_hint()
3243 request->wiphy_idx = get_wiphy_idx(wiphy); in regulatory_hint()
3245 request->alpha2[0] = alpha2[0]; in regulatory_hint()
3246 request->alpha2[1] = alpha2[1]; in regulatory_hint()
3247 request->initiator = NL80211_REGDOM_SET_BY_DRIVER; in regulatory_hint()
3295 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE && in regulatory_hint_country_ie()
3296 lr->wiphy_idx != WIPHY_IDX_INVALID) in regulatory_hint_country_ie()
3299 request->wiphy_idx = get_wiphy_idx(wiphy); in regulatory_hint_country_ie()
3300 request->alpha2[0] = alpha2[0]; in regulatory_hint_country_ie()
3301 request->alpha2[1] = alpha2[1]; in regulatory_hint_country_ie()
3302 request->initiator = NL80211_REGDOM_SET_BY_COUNTRY_IE; in regulatory_hint_country_ie()
3303 request->country_ie_env = env; in regulatory_hint_country_ie()
3363 sband = wiphy->bands[band]; in restore_custom_reg_settings()
3366 for (i = 0; i < sband->n_channels; i++) { in restore_custom_reg_settings()
3367 chan = &sband->channels[i]; in restore_custom_reg_settings()
3368 chan->flags = chan->orig_flags; in restore_custom_reg_settings()
3369 chan->max_antenna_gain = chan->orig_mag; in restore_custom_reg_settings()
3370 chan->max_power = chan->orig_mpwr; in restore_custom_reg_settings()
3371 chan->beacon_found = false; in restore_custom_reg_settings()
3378 * possibly stale country IE information and user regulatory
3380 * learned as we could have traveled outside to another country
3384 * - send a core regulatory hint
3385 * - send a user regulatory hint if applicable
3387 * Device drivers that send a regulatory hint for a specific country
3388 * keep their own regulatory domain on wiphy->regd so that does
3429 list_del(&reg_beacon->list); in restore_regulatory_settings()
3435 list_del(&reg_beacon->list); in restore_regulatory_settings()
3440 world_alpha2[0] = cfg80211_world_regdom->alpha2[0]; in restore_regulatory_settings()
3441 world_alpha2[1] = cfg80211_world_regdom->alpha2[1]; in restore_regulatory_settings()
3444 if (rdev->wiphy.regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in restore_regulatory_settings()
3446 if (rdev->wiphy.regulatory_flags & REGULATORY_CUSTOM_REG) in restore_regulatory_settings()
3447 restore_custom_reg_settings(&rdev->wiphy); in restore_regulatory_settings()
3466 list_del(&ureq->list); in restore_regulatory_settings()
3501 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in is_wiphy_all_set_reg_flag()
3503 if (!(wdev->wiphy->regulatory_flags & flag)) { in is_wiphy_all_set_reg_flag()
3529 list_del(&reg_beacon->list); in regulatory_hint_disconnect()
3536 list_del(&reg_beacon->list); in regulatory_hint_disconnect()
3562 &pending_beacon->chan)) in pending_reg_beacon()
3574 if (beacon_chan->beacon_found || in regulatory_hint_found_beacon()
3575 beacon_chan->flags & IEEE80211_CHAN_RADAR || in regulatory_hint_found_beacon()
3576 (beacon_chan->band == NL80211_BAND_2GHZ && in regulatory_hint_found_beacon()
3577 !freq_is_chan_12_13_14(beacon_chan->center_freq))) in regulatory_hint_found_beacon()
3589 return -ENOMEM; in regulatory_hint_found_beacon()
3592 beacon_chan->center_freq, beacon_chan->freq_offset, in regulatory_hint_found_beacon()
3597 memcpy(&reg_beacon->chan, beacon_chan, in regulatory_hint_found_beacon()
3601 * Since we can be called from BH or and non-BH context in regulatory_hint_found_beacon()
3605 list_add_tail(&reg_beacon->list, &reg_pending_beacons); in regulatory_hint_found_beacon()
3621 pr_debug(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)\n"); in print_rd_rules()
3623 for (i = 0; i < rd->n_reg_rules; i++) { in print_rd_rules()
3624 reg_rule = &rd->reg_rules[i]; in print_rd_rules()
3625 freq_range = &reg_rule->freq_range; in print_rd_rules()
3626 power_rule = &reg_rule->power_rule; in print_rd_rules()
3628 if (reg_rule->flags & NL80211_RRF_AUTO_BW) in print_rd_rules()
3630 freq_range->max_bandwidth_khz, in print_rd_rules()
3634 freq_range->max_bandwidth_khz); in print_rd_rules()
3636 if (reg_rule->flags & NL80211_RRF_DFS) in print_rd_rules()
3638 reg_rule->dfs_cac_ms/1000); in print_rd_rules()
3647 if (power_rule->max_antenna_gain) in print_rd_rules()
3648 pr_debug(" (%d KHz - %d KHz @ %s), (%d mBi, %d mBm), (%s)\n", in print_rd_rules()
3649 freq_range->start_freq_khz, in print_rd_rules()
3650 freq_range->end_freq_khz, in print_rd_rules()
3652 power_rule->max_antenna_gain, in print_rd_rules()
3653 power_rule->max_eirp, in print_rd_rules()
3656 pr_debug(" (%d KHz - %d KHz @ %s), (N/A, %d mBm), (%s)\n", in print_rd_rules()
3657 freq_range->start_freq_khz, in print_rd_rules()
3658 freq_range->end_freq_khz, in print_rd_rules()
3660 power_rule->max_eirp, in print_rd_rules()
3683 if (is_intersected_alpha2(rd->alpha2)) { in print_regdomain()
3684 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { in print_regdomain()
3686 rdev = cfg80211_rdev_by_wiphy_idx(lr->wiphy_idx); in print_regdomain()
3689 rdev->country_ie_alpha2[0], in print_regdomain()
3690 rdev->country_ie_alpha2[1]); in print_regdomain()
3695 } else if (is_world_regdom(rd->alpha2)) { in print_regdomain()
3698 if (is_unknown_alpha2(rd->alpha2)) in print_regdomain()
3699 pr_debug("Regulatory domain changed to driver built-in settings (unknown country)\n"); in print_regdomain()
3702 pr_debug("Regulatory domain changed to country: %c%c by Cell Station\n", in print_regdomain()
3703 rd->alpha2[0], rd->alpha2[1]); in print_regdomain()
3705 pr_debug("Regulatory domain changed to country: %c%c\n", in print_regdomain()
3706 rd->alpha2[0], rd->alpha2[1]); in print_regdomain()
3710 pr_debug(" DFS Master region: %s", reg_dfs_region_str(rd->dfs_region)); in print_regdomain()
3716 pr_debug("Regulatory domain: %c%c\n", rd->alpha2[0], rd->alpha2[1]); in print_regdomain_info()
3722 if (!is_world_regdom(rd->alpha2)) in reg_set_rd_core()
3723 return -EINVAL; in reg_set_rd_core()
3733 if (!regdom_changes(rd->alpha2)) in reg_set_rd_user()
3734 return -EALREADY; in reg_set_rd_user()
3738 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_user()
3740 return -EINVAL; in reg_set_rd_user()
3743 if (!user_request->intersect) { in reg_set_rd_user()
3750 return -EINVAL; in reg_set_rd_user()
3767 if (is_world_regdom(rd->alpha2)) in reg_set_rd_driver()
3768 return -EINVAL; in reg_set_rd_driver()
3770 if (!regdom_changes(rd->alpha2)) in reg_set_rd_driver()
3771 return -EALREADY; in reg_set_rd_driver()
3775 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_driver()
3777 return -EINVAL; in reg_set_rd_driver()
3780 request_wiphy = wiphy_idx_to_wiphy(driver_request->wiphy_idx); in reg_set_rd_driver()
3782 return -ENODEV; in reg_set_rd_driver()
3784 if (!driver_request->intersect) { in reg_set_rd_driver()
3785 if (request_wiphy->regd) in reg_set_rd_driver()
3786 return -EALREADY; in reg_set_rd_driver()
3792 rcu_assign_pointer(request_wiphy->regd, regd); in reg_set_rd_driver()
3799 return -EINVAL; in reg_set_rd_driver()
3807 rcu_assign_pointer(request_wiphy->regd, rd); in reg_set_rd_driver()
3822 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && in reg_set_rd_country_ie()
3823 !is_unknown_alpha2(rd->alpha2)) in reg_set_rd_country_ie()
3824 return -EINVAL; in reg_set_rd_country_ie()
3829 * and the pending request came in from a country IE in reg_set_rd_country_ie()
3834 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_country_ie()
3836 return -EINVAL; in reg_set_rd_country_ie()
3839 request_wiphy = wiphy_idx_to_wiphy(country_ie_request->wiphy_idx); in reg_set_rd_country_ie()
3841 return -ENODEV; in reg_set_rd_country_ie()
3843 if (country_ie_request->intersect) in reg_set_rd_country_ie()
3844 return -EINVAL; in reg_set_rd_country_ie()
3863 return -ENODATA; in set_regdom()
3865 if (!reg_is_valid_request(rd->alpha2)) { in set_regdom()
3867 return -EINVAL; in set_regdom()
3876 switch (lr->initiator) { in set_regdom()
3892 WARN(1, "invalid initiator %d\n", lr->initiator); in set_regdom()
3894 return -EINVAL; in set_regdom()
3899 case -EALREADY: in set_regdom()
3912 if (WARN_ON(!lr->intersect && rd != get_cfg80211_regdom())) in set_regdom()
3913 return -EINVAL; in set_regdom()
3916 update_all_wiphy_regulatory(lr->initiator); in set_regdom()
3935 return -EINVAL; in __regulatory_set_wiphy_regd()
3937 if (WARN(!(wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED), in __regulatory_set_wiphy_regd()
3939 return -EPERM; in __regulatory_set_wiphy_regd()
3943 return -EINVAL; in __regulatory_set_wiphy_regd()
3953 prev_regd = rdev->requested_regd; in __regulatory_set_wiphy_regd()
3954 rdev->requested_regd = regd; in __regulatory_set_wiphy_regd()
3995 /* self-managed devices ignore beacon hints and country IE */ in wiphy_regulatory_register()
3996 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in wiphy_regulatory_register()
3997 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS | in wiphy_regulatory_register()
4005 if (lr->initiator == NL80211_REGDOM_SET_BY_USER) in wiphy_regulatory_register()
4012 wiphy_update_regulatory(wiphy, lr->initiator); in wiphy_regulatory_register()
4025 reg_num_devs_support_basehint--; in wiphy_regulatory_deregister()
4028 RCU_INIT_POINTER(wiphy->regd, NULL); in wiphy_regulatory_deregister()
4031 request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in wiphy_regulatory_deregister()
4036 lr->wiphy_idx = WIPHY_IDX_INVALID; in wiphy_regulatory_deregister()
4037 lr->country_ie_env = ENVIRON_ANY; in wiphy_regulatory_deregister()
4042 * 5GHz: https://www.fcc.gov/document/5-ghz-unlicensed-spectrum-unii
4043 * 6GHz: https://www.fcc.gov/document/fcc-proposes-more-spectrum-unlicensed-use-0
4047 /* UNII-1 */ in cfg80211_get_unii()
4051 /* UNII-2A */ in cfg80211_get_unii()
4055 /* UNII-2B */ in cfg80211_get_unii()
4059 /* UNII-2C */ in cfg80211_get_unii()
4063 /* UNII-3 */ in cfg80211_get_unii()
4067 /* UNII-5 */ in cfg80211_get_unii()
4071 /* UNII-6 */ in cfg80211_get_unii()
4075 /* UNII-7 */ in cfg80211_get_unii()
4079 /* UNII-8 */ in cfg80211_get_unii()
4083 return -EINVAL; in cfg80211_get_unii()
4100 wiphy_regd = rcu_dereference(wiphy->regd); in regulatory_pre_cac_allowed()
4102 if (regd->dfs_region == NL80211_DFS_ETSI) in regulatory_pre_cac_allowed()
4110 if (regd->dfs_region == wiphy_regd->dfs_region && in regulatory_pre_cac_allowed()
4111 wiphy_regd->dfs_region == NL80211_DFS_ETSI) in regulatory_pre_cac_allowed()
4126 * either all channels are available - those the CAC_FINISHED in cfg80211_check_and_end_cac()
4128 * in unavailable state in wdev chandef - those the RADAR_DETECTED in cfg80211_check_and_end_cac()
4132 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_check_and_end_cac()
4133 if (wdev->cac_started && in cfg80211_check_and_end_cac()
4134 !cfg80211_chandef_dfs_usable(&rdev->wiphy, &wdev->chandef)) in cfg80211_check_and_end_cac()
4135 rdev_end_cac(rdev, wdev->netdev); in cfg80211_check_and_end_cac()
4152 if (wiphy == &rdev->wiphy) in regulatory_propagate_dfs_state()
4155 if (!reg_dfs_domain_same(wiphy, &rdev->wiphy)) in regulatory_propagate_dfs_state()
4158 if (!ieee80211_get_channel(&rdev->wiphy, in regulatory_propagate_dfs_state()
4159 chandef->chan->center_freq)) in regulatory_propagate_dfs_state()
4162 cfg80211_set_dfs_state(&rdev->wiphy, chandef, dfs_state); in regulatory_propagate_dfs_state()
4179 * It's possible that - due to other bugs/issues - cfg80211 in regulatory_init_db()
4185 return -EINVAL; in regulatory_init_db()
4194 err = regulatory_hint_core(cfg80211_world_regdom->alpha2); in regulatory_init_db()
4196 if (err == -ENOMEM) { in regulatory_init_db()
4205 * errors as non-fatal. in regulatory_init_db()
4260 dev_set_uevent_suppress(&reg_pdev->dev, true); in regulatory_exit()
4265 list_del(&reg_beacon->list); in regulatory_exit()
4270 list_del(&reg_beacon->list); in regulatory_exit()
4275 list_del(&reg_request->list); in regulatory_exit()