• Home
  • Raw
  • Download

Lines Matching +full:freq +full:- +full:domain

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
28 * determine which regulatory domain it should be operating under, then
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"
68 * channels allowed by the current regulatory domain.
73 * enum reg_request_treatment - regulatory request treatment
77 * @REG_REQ_INTERSECT: the regulatory domain resulting from this request should
110 * the current one and a world regulatory domain in case we have no
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()
221 /* We keep a static world regulatory domain in case of the absence of CRDA */
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");
331 * Dynamic world regulatory domain requested by the wireless
366 * Special case where regulatory domain was built by driver in is_unknown_alpha2()
377 * Special case where regulatory domain is the in is_intersected_alpha2()
378 * result of an intersection between two regulatory domain in is_intersected_alpha2()
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()
554 return -EINVAL; in call_crda()
561 pr_debug("Calling CRDA to update world regulatory domain\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()
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()
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()
795 if (request_firmware(&sig, "regulatory.db.p7s", &reg_pdev->dev)) in regdb_has_valid_signature()
798 result = verify_pkcs7_signature(data, size, sig->data, sig->size, in regdb_has_valid_signature()
836 if (hdr->magic != cpu_to_be32(FWDB_MAGIC)) in valid_regdb()
839 if (hdr->version != cpu_to_be32(FWDB_VERSION)) in valid_regdb()
845 country = &hdr->country[0]; in valid_regdb()
847 if (!country->coll_ptr) in valid_regdb()
862 struct ieee80211_wmm_rule *wmm_rule = &rrule->wmm_rule; in set_wmm_rule()
866 wmm_ptr = be16_to_cpu(rule->wmm_ptr) << 2; in set_wmm_rule()
870 pr_err("Invalid regulatory WMM rule %u-%u in domain %c%c\n", in set_wmm_rule()
871 be32_to_cpu(rule->start), be32_to_cpu(rule->end), in set_wmm_rule()
872 country->alpha2[0], country->alpha2[1]); in set_wmm_rule()
877 wmm_rule->client[i].cw_min = in set_wmm_rule()
878 ecw2cw((wmm->client[i].ecw & 0xf0) >> 4); in set_wmm_rule()
879 wmm_rule->client[i].cw_max = ecw2cw(wmm->client[i].ecw & 0x0f); in set_wmm_rule()
880 wmm_rule->client[i].aifsn = wmm->client[i].aifsn; in set_wmm_rule()
881 wmm_rule->client[i].cot = in set_wmm_rule()
882 1000 * be16_to_cpu(wmm->client[i].cot); in set_wmm_rule()
883 wmm_rule->ap[i].cw_min = ecw2cw((wmm->ap[i].ecw & 0xf0) >> 4); in set_wmm_rule()
884 wmm_rule->ap[i].cw_max = ecw2cw(wmm->ap[i].ecw & 0x0f); in set_wmm_rule()
885 wmm_rule->ap[i].aifsn = wmm->ap[i].aifsn; in set_wmm_rule()
886 wmm_rule->ap[i].cot = 1000 * be16_to_cpu(wmm->ap[i].cot); in set_wmm_rule()
889 rrule->has_wmm = true; in set_wmm_rule()
893 const struct fwdb_country *country, int freq, in __regdb_query_wmm() argument
896 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in __regdb_query_wmm()
900 for (i = 0; i < coll->n_rules; i++) { in __regdb_query_wmm()
901 __be16 *rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in __regdb_query_wmm()
905 if (rule->len < offsetofend(struct fwdb_rule, wmm_ptr)) in __regdb_query_wmm()
908 if (freq >= KHZ_TO_MHZ(be32_to_cpu(rule->start)) && in __regdb_query_wmm()
909 freq <= KHZ_TO_MHZ(be32_to_cpu(rule->end))) { in __regdb_query_wmm()
915 return -ENODATA; in __regdb_query_wmm()
918 int reg_query_regdb_wmm(char *alpha2, int freq, struct ieee80211_reg_rule *rule) in reg_query_regdb_wmm() argument
924 return -ENODATA; in reg_query_regdb_wmm()
929 country = &hdr->country[0]; in reg_query_regdb_wmm()
930 while (country->coll_ptr) { in reg_query_regdb_wmm()
931 if (alpha2_equal(alpha2, country->alpha2)) in reg_query_regdb_wmm()
932 return __regdb_query_wmm(regdb, country, freq, rule); in reg_query_regdb_wmm()
937 return -ENODATA; in reg_query_regdb_wmm()
944 unsigned int ptr = be16_to_cpu(country->coll_ptr) << 2; in regdb_query_country()
949 regdom = kzalloc(struct_size(regdom, reg_rules, coll->n_rules), in regdb_query_country()
952 return -ENOMEM; in regdb_query_country()
954 regdom->n_reg_rules = coll->n_rules; in regdb_query_country()
955 regdom->alpha2[0] = country->alpha2[0]; in regdb_query_country()
956 regdom->alpha2[1] = country->alpha2[1]; in regdb_query_country()
957 regdom->dfs_region = coll->dfs_region; in regdb_query_country()
959 for (i = 0; i < regdom->n_reg_rules; i++) { in regdb_query_country()
960 __be16 *rules_ptr = (void *)((u8 *)coll + ALIGN(coll->len, 2)); in regdb_query_country()
963 struct ieee80211_reg_rule *rrule = &regdom->reg_rules[i]; in regdb_query_country()
965 rrule->freq_range.start_freq_khz = be32_to_cpu(rule->start); in regdb_query_country()
966 rrule->freq_range.end_freq_khz = be32_to_cpu(rule->end); in regdb_query_country()
967 rrule->freq_range.max_bandwidth_khz = be32_to_cpu(rule->max_bw); in regdb_query_country()
969 rrule->power_rule.max_antenna_gain = 0; in regdb_query_country()
970 rrule->power_rule.max_eirp = be16_to_cpu(rule->max_eirp); in regdb_query_country()
972 rrule->flags = 0; in regdb_query_country()
973 if (rule->flags & FWDB_FLAG_NO_OFDM) in regdb_query_country()
974 rrule->flags |= NL80211_RRF_NO_OFDM; in regdb_query_country()
975 if (rule->flags & FWDB_FLAG_NO_OUTDOOR) in regdb_query_country()
976 rrule->flags |= NL80211_RRF_NO_OUTDOOR; in regdb_query_country()
977 if (rule->flags & FWDB_FLAG_DFS) in regdb_query_country()
978 rrule->flags |= NL80211_RRF_DFS; in regdb_query_country()
979 if (rule->flags & FWDB_FLAG_NO_IR) in regdb_query_country()
980 rrule->flags |= NL80211_RRF_NO_IR; in regdb_query_country()
981 if (rule->flags & FWDB_FLAG_AUTO_BW) in regdb_query_country()
982 rrule->flags |= NL80211_RRF_AUTO_BW; in regdb_query_country()
984 rrule->dfs_cac_ms = 0; in regdb_query_country()
987 if (rule->len >= offsetofend(struct fwdb_rule, cac_timeout)) in regdb_query_country()
988 rrule->dfs_cac_ms = in regdb_query_country()
989 1000 * be16_to_cpu(rule->cac_timeout); in regdb_query_country()
990 if (rule->len >= offsetofend(struct fwdb_rule, wmm_ptr)) in regdb_query_country()
1007 country = &hdr->country[0]; in query_regdb()
1008 while (country->coll_ptr) { in query_regdb()
1009 if (alpha2_equal(alpha2, country->alpha2)) in query_regdb()
1014 return -ENODATA; in query_regdb()
1025 set_error = -ENODATA; in regdb_fw_cb()
1026 } else if (!valid_regdb(fw->data, fw->size)) { in regdb_fw_cb()
1028 set_error = -EINVAL; in regdb_fw_cb()
1033 /* negative case - a bug in regdb_fw_cb()
1034 * positive case - can happen due to race in case of multiple cb's in in regdb_fw_cb()
1042 db = kmemdup(fw->data, fw->size, GFP_KERNEL); in regdb_fw_cb()
1070 return -ENOMEM; in query_regdb_file()
1073 &reg_pdev->dev, GFP_KERNEL, in query_regdb_file()
1083 err = request_firmware(&fw, "regulatory.db", &reg_pdev->dev); in reg_reload_regdb()
1087 if (!valid_regdb(fw->data, fw->size)) { in reg_reload_regdb()
1088 err = -ENODATA; in reg_reload_regdb()
1092 db = kmemdup(fw->data, fw->size, GFP_KERNEL); in reg_reload_regdb()
1094 err = -ENOMEM; in reg_reload_regdb()
1111 if (query_regdb_file(request->alpha2) == 0) in reg_query_database()
1114 if (call_crda(request->alpha2) == 0) in reg_query_database()
1124 if (!lr || lr->processed) in reg_is_valid_request()
1127 return alpha2_equal(lr->alpha2, alpha2); in reg_is_valid_request()
1135 * Follow the driver's regulatory domain, if present, unless a country in reg_get_regdomain()
1138 if (lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && in reg_get_regdomain()
1139 lr->initiator != NL80211_REGDOM_SET_BY_USER && in reg_get_regdomain()
1140 wiphy->regd) in reg_get_regdomain()
1150 const struct ieee80211_freq_range *freq_range = &rule->freq_range; in reg_get_max_bandwidth_from_range()
1155 for (idx = 0; idx < rd->n_reg_rules; idx++) in reg_get_max_bandwidth_from_range()
1156 if (rule == &rd->reg_rules[idx]) in reg_get_max_bandwidth_from_range()
1159 if (idx == rd->n_reg_rules) in reg_get_max_bandwidth_from_range()
1166 tmp = &rd->reg_rules[--no]; in reg_get_max_bandwidth_from_range()
1167 freq_range_tmp = &tmp->freq_range; in reg_get_max_bandwidth_from_range()
1169 if (freq_range_tmp->end_freq_khz < freq_range->start_freq_khz) in reg_get_max_bandwidth_from_range()
1175 start_freq = freq_range->start_freq_khz; in reg_get_max_bandwidth_from_range()
1178 freq_range = &rule->freq_range; in reg_get_max_bandwidth_from_range()
1181 while (no < rd->n_reg_rules - 1) { in reg_get_max_bandwidth_from_range()
1182 tmp = &rd->reg_rules[++no]; in reg_get_max_bandwidth_from_range()
1183 freq_range_tmp = &tmp->freq_range; in reg_get_max_bandwidth_from_range()
1185 if (freq_range_tmp->start_freq_khz > freq_range->end_freq_khz) in reg_get_max_bandwidth_from_range()
1191 end_freq = freq_range->end_freq_khz; in reg_get_max_bandwidth_from_range()
1193 return end_freq - start_freq; in reg_get_max_bandwidth_from_range()
1201 if (rule->flags & NL80211_RRF_NO_160MHZ) in reg_get_max_bandwidth()
1203 if (rule->flags & NL80211_RRF_NO_80MHZ) in reg_get_max_bandwidth()
1207 * HT40+/HT40- limits are handled per-channel. Only limit BW if both in reg_get_max_bandwidth()
1210 if (rule->flags & NL80211_RRF_NO_HT40MINUS && in reg_get_max_bandwidth()
1211 rule->flags & NL80211_RRF_NO_HT40PLUS) in reg_get_max_bandwidth()
1220 const struct ieee80211_freq_range *freq_range = &rule->freq_range; in is_valid_reg_rule()
1223 if (freq_range->start_freq_khz <= 0 || freq_range->end_freq_khz <= 0) in is_valid_reg_rule()
1226 if (freq_range->start_freq_khz > freq_range->end_freq_khz) in is_valid_reg_rule()
1229 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; in is_valid_reg_rule()
1231 if (freq_range->end_freq_khz <= freq_range->start_freq_khz || in is_valid_reg_rule()
1232 freq_range->max_bandwidth_khz > freq_diff) in is_valid_reg_rule()
1243 if (!rd->n_reg_rules) in is_valid_rd()
1246 if (WARN_ON(rd->n_reg_rules > NL80211_MAX_SUPP_REG_RULES)) in is_valid_rd()
1249 for (i = 0; i < rd->n_reg_rules; i++) { in is_valid_rd()
1250 reg_rule = &rd->reg_rules[i]; in is_valid_rd()
1259 * freq_in_rule_band - tells us if a frequency is in a frequency band
1267 * part of a frequency's band if the start freq or end freq are off by more
1278 * From 802.11ad: directional multi-gigabit (DMG): in freq_in_rule_band()
1284 if (abs(freq_khz - freq_range->start_freq_khz) <= limit) in freq_in_rule_band()
1286 if (abs(freq_khz - freq_range->end_freq_khz) <= limit) in freq_in_rule_band()
1310 intersect->cw_min = max_t(u16, wmm_ac1->cw_min, wmm_ac2->cw_min); in reg_wmm_rules_intersect()
1311 intersect->cw_max = max_t(u16, wmm_ac1->cw_max, wmm_ac2->cw_max); in reg_wmm_rules_intersect()
1312 intersect->cot = min_t(u16, wmm_ac1->cot, wmm_ac2->cot); in reg_wmm_rules_intersect()
1313 intersect->aifsn = max_t(u8, wmm_ac1->aifsn, wmm_ac2->aifsn); in reg_wmm_rules_intersect()
1334 freq_range1 = &rule1->freq_range; in reg_rules_intersect()
1335 freq_range2 = &rule2->freq_range; in reg_rules_intersect()
1336 freq_range = &intersected_rule->freq_range; in reg_rules_intersect()
1338 power_rule1 = &rule1->power_rule; in reg_rules_intersect()
1339 power_rule2 = &rule2->power_rule; in reg_rules_intersect()
1340 power_rule = &intersected_rule->power_rule; in reg_rules_intersect()
1342 wmm_rule1 = &rule1->wmm_rule; in reg_rules_intersect()
1343 wmm_rule2 = &rule2->wmm_rule; in reg_rules_intersect()
1344 wmm_rule = &intersected_rule->wmm_rule; in reg_rules_intersect()
1346 freq_range->start_freq_khz = max(freq_range1->start_freq_khz, in reg_rules_intersect()
1347 freq_range2->start_freq_khz); in reg_rules_intersect()
1348 freq_range->end_freq_khz = min(freq_range1->end_freq_khz, in reg_rules_intersect()
1349 freq_range2->end_freq_khz); in reg_rules_intersect()
1351 max_bandwidth1 = freq_range1->max_bandwidth_khz; in reg_rules_intersect()
1352 max_bandwidth2 = freq_range2->max_bandwidth_khz; in reg_rules_intersect()
1354 if (rule1->flags & NL80211_RRF_AUTO_BW) in reg_rules_intersect()
1356 if (rule2->flags & NL80211_RRF_AUTO_BW) in reg_rules_intersect()
1359 freq_range->max_bandwidth_khz = min(max_bandwidth1, max_bandwidth2); in reg_rules_intersect()
1361 intersected_rule->flags = rule1->flags | rule2->flags; in reg_rules_intersect()
1371 if ((rule1->flags & NL80211_RRF_AUTO_BW) && in reg_rules_intersect()
1372 (rule2->flags & NL80211_RRF_AUTO_BW)) in reg_rules_intersect()
1373 intersected_rule->flags |= NL80211_RRF_AUTO_BW; in reg_rules_intersect()
1375 intersected_rule->flags &= ~NL80211_RRF_AUTO_BW; in reg_rules_intersect()
1377 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; in reg_rules_intersect()
1378 if (freq_range->max_bandwidth_khz > freq_diff) in reg_rules_intersect()
1379 freq_range->max_bandwidth_khz = freq_diff; in reg_rules_intersect()
1381 power_rule->max_eirp = min(power_rule1->max_eirp, in reg_rules_intersect()
1382 power_rule2->max_eirp); in reg_rules_intersect()
1383 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain, in reg_rules_intersect()
1384 power_rule2->max_antenna_gain); in reg_rules_intersect()
1386 intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms, in reg_rules_intersect()
1387 rule2->dfs_cac_ms); in reg_rules_intersect()
1389 if (rule1->has_wmm && rule2->has_wmm) { in reg_rules_intersect()
1393 reg_wmm_rules_intersect(&wmm_rule1->client[ac], in reg_rules_intersect()
1394 &wmm_rule2->client[ac], in reg_rules_intersect()
1395 &wmm_rule->client[ac]); in reg_rules_intersect()
1396 reg_wmm_rules_intersect(&wmm_rule1->ap[ac], in reg_rules_intersect()
1397 &wmm_rule2->ap[ac], in reg_rules_intersect()
1398 &wmm_rule->ap[ac]); in reg_rules_intersect()
1401 intersected_rule->has_wmm = true; in reg_rules_intersect()
1402 } else if (rule1->has_wmm) { in reg_rules_intersect()
1404 intersected_rule->has_wmm = true; in reg_rules_intersect()
1405 } else if (rule2->has_wmm) { in reg_rules_intersect()
1407 intersected_rule->has_wmm = true; in reg_rules_intersect()
1409 intersected_rule->has_wmm = false; in reg_rules_intersect()
1413 return -EINVAL; in reg_rules_intersect()
1423 if (r1->flags != r2->flags) in rule_contains()
1427 if ((r1->power_rule.max_antenna_gain > in rule_contains()
1428 r2->power_rule.max_antenna_gain) || in rule_contains()
1429 r1->power_rule.max_eirp > r2->power_rule.max_eirp) in rule_contains()
1433 if (r1->freq_range.start_freq_khz > r2->freq_range.start_freq_khz || in rule_contains()
1434 r1->freq_range.end_freq_khz < r2->freq_range.end_freq_khz) in rule_contains()
1438 if (r1->freq_range.max_bandwidth_khz < in rule_contains()
1439 r2->freq_range.max_bandwidth_khz) in rule_contains()
1454 /* rule is already contained - do nothing */ in add_rule()
1470 * regdom_intersect - do the intersection between two regulatory domains
1471 * @rd1: first regulatory domain
1472 * @rd2: second regulatory domain
1476 * as no one single alpha2 can represent this regulatory domain.
1478 * Returns a pointer to the regulatory domain structure which will hold the
1500 * is it will return -EINVAL if the rule computed makes no sense. in regdom_intersect()
1504 for (x = 0; x < rd1->n_reg_rules; x++) { in regdom_intersect()
1505 rule1 = &rd1->reg_rules[x]; in regdom_intersect()
1506 for (y = 0; y < rd2->n_reg_rules; y++) { in regdom_intersect()
1507 rule2 = &rd2->reg_rules[y]; in regdom_intersect()
1521 for (x = 0; x < rd1->n_reg_rules; x++) { in regdom_intersect()
1522 rule1 = &rd1->reg_rules[x]; in regdom_intersect()
1523 for (y = 0; y < rd2->n_reg_rules; y++) { in regdom_intersect()
1524 rule2 = &rd2->reg_rules[y]; in regdom_intersect()
1534 add_rule(&intersected_rule, rd->reg_rules, in regdom_intersect()
1535 &rd->n_reg_rules); in regdom_intersect()
1539 rd->alpha2[0] = '9'; in regdom_intersect()
1540 rd->alpha2[1] = '8'; in regdom_intersect()
1541 rd->dfs_region = reg_intersect_dfs_region(rd1->dfs_region, in regdom_intersect()
1542 rd2->dfs_region); in regdom_intersect()
1586 return ERR_PTR(-EINVAL); in freq_reg_info_regd()
1588 for (i = 0; i < regd->n_reg_rules; i++) { in freq_reg_info_regd()
1592 rr = &regd->reg_rules[i]; in freq_reg_info_regd()
1593 fr = &rr->freq_range; in freq_reg_info_regd()
1610 return ERR_PTR(-ERANGE); in freq_reg_info_regd()
1612 return ERR_PTR(-EINVAL); in freq_reg_info_regd()
1621 int i = ARRAY_SIZE(bws) - 1; in __freq_reg_info()
1624 for (bw = MHZ_TO_KHZ(bws[i]); bw >= min_bw; bw = MHZ_TO_KHZ(bws[i--])) { in __freq_reg_info()
1666 bool is_s1g = chan->band == NL80211_BAND_S1GHZ; in reg_rule_to_chan_bw_flags()
1668 freq_range = &reg_rule->freq_range; in reg_rule_to_chan_bw_flags()
1670 max_bandwidth_khz = freq_range->max_bandwidth_khz; in reg_rule_to_chan_bw_flags()
1673 if (reg_rule->flags & NL80211_RRF_AUTO_BW) in reg_rule_to_chan_bw_flags()
1695 edge_offset = (center_freq_khz - ch_bw / 2) - in reg_rule_to_chan_bw_flags()
1696 freq_range->start_freq_khz; in reg_rule_to_chan_bw_flags()
1754 power_rule = &reg_rule->power_rule; in handle_channel_single_rule()
1757 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel_single_rule()
1759 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel_single_rule()
1761 * This guarantees the driver's requested regulatory domain in handle_channel_single_rule()
1765 chan->flags = chan->orig_flags = in handle_channel_single_rule()
1766 map_regdom_flags(reg_rule->flags) | bw_flags; in handle_channel_single_rule()
1767 chan->max_antenna_gain = chan->orig_mag = in handle_channel_single_rule()
1768 (int) MBI_TO_DBI(power_rule->max_antenna_gain); in handle_channel_single_rule()
1769 chan->max_reg_power = chan->max_power = chan->orig_mpwr = in handle_channel_single_rule()
1770 (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_single_rule()
1772 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_single_rule()
1773 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_single_rule()
1774 if (reg_rule->dfs_cac_ms) in handle_channel_single_rule()
1775 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_single_rule()
1781 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_single_rule()
1782 chan->dfs_state_entered = jiffies; in handle_channel_single_rule()
1784 chan->beacon_found = false; in handle_channel_single_rule()
1785 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); in handle_channel_single_rule()
1786 chan->max_antenna_gain = in handle_channel_single_rule()
1787 min_t(int, chan->orig_mag, in handle_channel_single_rule()
1788 MBI_TO_DBI(power_rule->max_antenna_gain)); in handle_channel_single_rule()
1789 chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_single_rule()
1791 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_single_rule()
1792 if (reg_rule->dfs_cac_ms) in handle_channel_single_rule()
1793 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_single_rule()
1795 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_single_rule()
1798 if (chan->orig_mpwr) { in handle_channel_single_rule()
1804 wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_FOLLOW_POWER) in handle_channel_single_rule()
1805 chan->max_power = chan->max_reg_power; in handle_channel_single_rule()
1807 chan->max_power = min(chan->orig_mpwr, in handle_channel_single_rule()
1808 chan->max_reg_power); in handle_channel_single_rule()
1810 chan->max_power = chan->max_reg_power; in handle_channel_single_rule()
1831 power_rule1 = &rrule1->power_rule; in handle_channel_adjacent_rules()
1832 power_rule2 = &rrule2->power_rule; in handle_channel_adjacent_rules()
1836 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel_adjacent_rules()
1838 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel_adjacent_rules()
1839 /* This guarantees the driver's requested regulatory domain in handle_channel_adjacent_rules()
1843 chan->flags = in handle_channel_adjacent_rules()
1844 map_regdom_flags(rrule1->flags) | in handle_channel_adjacent_rules()
1845 map_regdom_flags(rrule2->flags) | in handle_channel_adjacent_rules()
1848 chan->orig_flags = chan->flags; in handle_channel_adjacent_rules()
1849 chan->max_antenna_gain = in handle_channel_adjacent_rules()
1850 min_t(int, MBI_TO_DBI(power_rule1->max_antenna_gain), in handle_channel_adjacent_rules()
1851 MBI_TO_DBI(power_rule2->max_antenna_gain)); in handle_channel_adjacent_rules()
1852 chan->orig_mag = chan->max_antenna_gain; in handle_channel_adjacent_rules()
1853 chan->max_reg_power = in handle_channel_adjacent_rules()
1854 min_t(int, MBM_TO_DBM(power_rule1->max_eirp), in handle_channel_adjacent_rules()
1855 MBM_TO_DBM(power_rule2->max_eirp)); in handle_channel_adjacent_rules()
1856 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1857 chan->orig_mpwr = chan->max_reg_power; in handle_channel_adjacent_rules()
1859 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_adjacent_rules()
1860 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_adjacent_rules()
1861 if (rrule1->dfs_cac_ms || rrule2->dfs_cac_ms) in handle_channel_adjacent_rules()
1862 chan->dfs_cac_ms = max_t(unsigned int, in handle_channel_adjacent_rules()
1863 rrule1->dfs_cac_ms, in handle_channel_adjacent_rules()
1864 rrule2->dfs_cac_ms); in handle_channel_adjacent_rules()
1870 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_adjacent_rules()
1871 chan->dfs_state_entered = jiffies; in handle_channel_adjacent_rules()
1873 chan->beacon_found = false; in handle_channel_adjacent_rules()
1874 chan->flags = flags | bw_flags1 | bw_flags2 | in handle_channel_adjacent_rules()
1875 map_regdom_flags(rrule1->flags) | in handle_channel_adjacent_rules()
1876 map_regdom_flags(rrule2->flags); in handle_channel_adjacent_rules()
1884 chan->flags &= ~IEEE80211_CHAN_NO_10MHZ; in handle_channel_adjacent_rules()
1888 chan->flags &= ~IEEE80211_CHAN_NO_20MHZ; in handle_channel_adjacent_rules()
1890 chan->max_antenna_gain = in handle_channel_adjacent_rules()
1891 min_t(int, chan->orig_mag, in handle_channel_adjacent_rules()
1893 MBI_TO_DBI(power_rule1->max_antenna_gain), in handle_channel_adjacent_rules()
1894 MBI_TO_DBI(power_rule2->max_antenna_gain))); in handle_channel_adjacent_rules()
1895 chan->max_reg_power = min_t(int, in handle_channel_adjacent_rules()
1896 MBM_TO_DBM(power_rule1->max_eirp), in handle_channel_adjacent_rules()
1897 MBM_TO_DBM(power_rule2->max_eirp)); in handle_channel_adjacent_rules()
1899 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_adjacent_rules()
1900 if (rrule1->dfs_cac_ms || rrule2->dfs_cac_ms) in handle_channel_adjacent_rules()
1901 chan->dfs_cac_ms = max_t(unsigned int, in handle_channel_adjacent_rules()
1902 rrule1->dfs_cac_ms, in handle_channel_adjacent_rules()
1903 rrule2->dfs_cac_ms); in handle_channel_adjacent_rules()
1905 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_adjacent_rules()
1908 if (chan->orig_mpwr) { in handle_channel_adjacent_rules()
1913 wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_FOLLOW_POWER) in handle_channel_adjacent_rules()
1914 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1916 chan->max_power = min(chan->orig_mpwr, in handle_channel_adjacent_rules()
1917 chan->max_reg_power); in handle_channel_adjacent_rules()
1919 chan->max_power = chan->max_reg_power; in handle_channel_adjacent_rules()
1933 struct wiphy *request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in handle_channel()
1938 u32 flags = chan->orig_flags; in handle_channel()
1943 * chan - 20 MHz and chan + 20 MHz and test in handle_channel()
1947 orig_chan_freq - MHZ_TO_KHZ(20)); in handle_channel()
1953 if (rrule1->freq_range.end_freq_khz != in handle_channel()
1954 rrule2->freq_range.start_freq_khz) in handle_channel()
1958 rrule1->freq_range.start_freq_khz; in handle_channel()
1960 rrule2->freq_range.end_freq_khz; in handle_channel()
1963 rrule1->freq_range.max_bandwidth_khz, in handle_channel()
1964 rrule2->freq_range.max_bandwidth_khz); in handle_channel()
1989 PTR_ERR(rrule) == -ERANGE) in handle_channel()
1992 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in handle_channel()
1994 request_wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in handle_channel()
1995 pr_debug("Disabling freq %d.%03d MHz for good\n", in handle_channel()
1996 chan->center_freq, chan->freq_offset); in handle_channel()
1997 chan->orig_flags |= IEEE80211_CHAN_DISABLED; in handle_channel()
1998 chan->flags = chan->orig_flags; in handle_channel()
2000 pr_debug("Disabling freq %d.%03d MHz\n", in handle_channel()
2001 chan->center_freq, chan->freq_offset); in handle_channel()
2002 chan->flags |= IEEE80211_CHAN_DISABLED; in handle_channel()
2020 for (i = 0; i < sband->n_channels; i++) in handle_band()
2021 handle_channel(wiphy, initiator, &sband->channels[i]); in handle_band()
2026 if (request->initiator != NL80211_REGDOM_SET_BY_USER) in reg_request_cell_base()
2028 return request->user_reg_hint_type == NL80211_USER_REG_HINT_CELL_BASE; in reg_request_cell_base()
2047 !regdom_changes(pending_request->alpha2)) in reg_ignore_cell_hint()
2056 return !(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS); in reg_dev_ignore_cell_hint()
2073 if (wiphy->regulatory_flags & REGULATORY_STRICT_REG && in wiphy_strict_alpha2_regd()
2074 !(wiphy->regulatory_flags & REGULATORY_CUSTOM_REG)) in wiphy_strict_alpha2_regd()
2084 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in ignore_reg_update()
2094 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) { in ignore_reg_update()
2095 …g("Ignoring regulatory request set by %s since the driver uses its own custom regulatory domain\n", in ignore_reg_update()
2101 * wiphy->regd will be set once the device has its own in ignore_reg_update()
2102 * desired regulatory domain set in ignore_reg_update()
2104 if (wiphy_strict_alpha2_regd(wiphy) && !wiphy->regd && in ignore_reg_update()
2106 !is_world_regdom(lr->alpha2)) { in ignore_reg_update()
2107 …egulatory request set by %s since the driver requires its own regulatory domain to be set first\n", in ignore_reg_update()
2124 if (is_world_regdom(cr->alpha2) || (wr && is_world_regdom(wr->alpha2))) in reg_is_world_roaming()
2127 if (lr && lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && in reg_is_world_roaming()
2128 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) in reg_is_world_roaming()
2142 sband = wiphy->bands[reg_beacon->chan.band]; in handle_reg_beacon()
2143 chan = &sband->channels[chan_idx]; in handle_reg_beacon()
2145 if (likely(!ieee80211_channel_equal(chan, &reg_beacon->chan))) in handle_reg_beacon()
2148 if (chan->beacon_found) in handle_reg_beacon()
2151 chan->beacon_found = true; in handle_reg_beacon()
2156 if (wiphy->regulatory_flags & REGULATORY_DISABLE_BEACON_HINTS) in handle_reg_beacon()
2161 if (chan->flags & IEEE80211_CHAN_NO_IR) { in handle_reg_beacon()
2162 chan->flags &= ~IEEE80211_CHAN_NO_IR; in handle_reg_beacon()
2180 if (!wiphy->bands[reg_beacon->chan.band]) in wiphy_update_new_beacon()
2183 sband = wiphy->bands[reg_beacon->chan.band]; in wiphy_update_new_beacon()
2185 for (i = 0; i < sband->n_channels; i++) in wiphy_update_new_beacon()
2199 if (!wiphy->bands[reg_beacon->chan.band]) in wiphy_update_beacon_reg()
2201 sband = wiphy->bands[reg_beacon->chan.band]; in wiphy_update_beacon_reg()
2202 for (i = 0; i < sband->n_channels; i++) in wiphy_update_beacon_reg()
2223 if (chan->flags & IEEE80211_CHAN_DISABLED) in is_ht40_allowed()
2226 if ((chan->flags & IEEE80211_CHAN_NO_HT40) == IEEE80211_CHAN_NO_HT40) in is_ht40_allowed()
2234 struct ieee80211_supported_band *sband = wiphy->bands[channel->band]; in reg_process_ht_flags_channel()
2241 channel->flags |= IEEE80211_CHAN_NO_HT40; in reg_process_ht_flags_channel()
2247 * be able to use HT40- or HT40+, this finds them (or not) in reg_process_ht_flags_channel()
2249 for (i = 0; i < sband->n_channels; i++) { in reg_process_ht_flags_channel()
2250 struct ieee80211_channel *c = &sband->channels[i]; in reg_process_ht_flags_channel()
2252 if (c->center_freq == (channel->center_freq - 20)) in reg_process_ht_flags_channel()
2254 if (c->center_freq == (channel->center_freq + 20)) in reg_process_ht_flags_channel()
2262 freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq), in reg_process_ht_flags_channel()
2266 flags = reg_rule->flags; in reg_process_ht_flags_channel()
2276 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS; in reg_process_ht_flags_channel()
2278 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS; in reg_process_ht_flags_channel()
2282 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS; in reg_process_ht_flags_channel()
2284 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS; in reg_process_ht_flags_channel()
2295 for (i = 0; i < sband->n_channels; i++) in reg_process_ht_flags_band()
2296 reg_process_ht_flags_channel(wiphy, &sband->channels[i]); in reg_process_ht_flags_band()
2307 reg_process_ht_flags_band(wiphy, wiphy->bands[band]); in reg_process_ht_flags()
2313 if (wiphy->reg_notifier) in reg_call_notifier()
2314 wiphy->reg_notifier(wiphy, request); in reg_call_notifier()
2324 iftype = wdev->iftype; in reg_wdev_chan_valid()
2327 if (!wdev->netdev || !netif_running(wdev->netdev)) in reg_wdev_chan_valid()
2333 if (!wdev->beacon_interval) in reg_wdev_chan_valid()
2335 chandef = wdev->chandef; in reg_wdev_chan_valid()
2338 if (!wdev->ssid_len) in reg_wdev_chan_valid()
2340 chandef = wdev->chandef; in reg_wdev_chan_valid()
2344 if (!wdev->current_bss || in reg_wdev_chan_valid()
2345 !wdev->current_bss->pub.channel) in reg_wdev_chan_valid()
2348 if (!rdev->ops->get_channel || in reg_wdev_chan_valid()
2351 wdev->current_bss->pub.channel, in reg_wdev_chan_valid()
2394 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) in reg_leave_invalid_chans()
2407 if (!(rdev->wiphy.regulatory_flags & in reg_check_chans_work()
2409 reg_leave_invalid_chans(&rdev->wiphy); in reg_check_chans_work()
2435 * as some drivers used this to restore its orig_* reg domain. in wiphy_update_regulatory()
2438 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG && in wiphy_update_regulatory()
2439 !(wiphy->regulatory_flags & in wiphy_update_regulatory()
2445 lr->dfs_region = get_cfg80211_regdom()->dfs_region; in wiphy_update_regulatory()
2448 handle_band(wiphy, initiator, wiphy->bands[band]); in wiphy_update_regulatory()
2463 wiphy = &rdev->wiphy; in update_all_wiphy_regulatory()
2488 pr_debug("Disabling freq %d.%03d MHz as custom regd has no rule that fits it\n", in handle_channel_custom()
2489 chan->center_freq, chan->freq_offset); in handle_channel_custom()
2490 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in handle_channel_custom()
2491 chan->flags |= IEEE80211_CHAN_DISABLED; in handle_channel_custom()
2493 chan->orig_flags |= IEEE80211_CHAN_DISABLED; in handle_channel_custom()
2494 chan->flags = chan->orig_flags; in handle_channel_custom()
2499 power_rule = &reg_rule->power_rule; in handle_channel_custom()
2502 chan->dfs_state_entered = jiffies; in handle_channel_custom()
2503 chan->dfs_state = NL80211_DFS_USABLE; in handle_channel_custom()
2505 chan->beacon_found = false; in handle_channel_custom()
2507 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in handle_channel_custom()
2508 chan->flags = chan->orig_flags | bw_flags | in handle_channel_custom()
2509 map_regdom_flags(reg_rule->flags); in handle_channel_custom()
2511 chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; in handle_channel_custom()
2513 chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); in handle_channel_custom()
2514 chan->max_reg_power = chan->max_power = in handle_channel_custom()
2515 (int) MBM_TO_DBM(power_rule->max_eirp); in handle_channel_custom()
2517 if (chan->flags & IEEE80211_CHAN_RADAR) { in handle_channel_custom()
2518 if (reg_rule->dfs_cac_ms) in handle_channel_custom()
2519 chan->dfs_cac_ms = reg_rule->dfs_cac_ms; in handle_channel_custom()
2521 chan->dfs_cac_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; in handle_channel_custom()
2524 chan->max_power = chan->max_reg_power; in handle_channel_custom()
2539 * compatible to US, which permits 2402 - 2472 MHz. in handle_band_custom()
2541 for (i = 0; i < sband->n_channels; i++) in handle_band_custom()
2542 handle_channel_custom(wiphy, &sband->channels[i], regd, in handle_band_custom()
2553 WARN(!(wiphy->regulatory_flags & REGULATORY_CUSTOM_REG), in wiphy_apply_custom_regulatory()
2555 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; in wiphy_apply_custom_regulatory()
2558 if (!wiphy->bands[band]) in wiphy_apply_custom_regulatory()
2560 handle_band_custom(wiphy, wiphy->bands[band], regd); in wiphy_apply_custom_regulatory()
2577 lr->processed = true; in reg_set_request_processed()
2591 * reg_process_hint_core - process core regulatory requests
2601 core_request->intersect = false; in reg_process_hint_core()
2602 core_request->processed = false; in reg_process_hint_core()
2621 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) in __reg_process_hint_user()
2627 if (lr->initiator == NL80211_REGDOM_SET_BY_USER && in __reg_process_hint_user()
2628 lr->intersect) in __reg_process_hint_user()
2634 if ((lr->initiator == NL80211_REGDOM_SET_BY_CORE || in __reg_process_hint_user()
2635 lr->initiator == NL80211_REGDOM_SET_BY_DRIVER || in __reg_process_hint_user()
2636 lr->initiator == NL80211_REGDOM_SET_BY_USER) && in __reg_process_hint_user()
2637 regdom_changes(lr->alpha2)) in __reg_process_hint_user()
2640 if (!regdom_changes(user_request->alpha2)) in __reg_process_hint_user()
2647 * reg_process_hint_user - process user regulatory requests
2663 user_request->intersect = treatment == REG_REQ_INTERSECT; in reg_process_hint_user()
2664 user_request->processed = false; in reg_process_hint_user()
2668 user_alpha2[0] = user_request->alpha2[0]; in reg_process_hint_user()
2669 user_alpha2[1] = user_request->alpha2[1]; in reg_process_hint_user()
2681 if (lr->initiator == NL80211_REGDOM_SET_BY_CORE) { in __reg_process_hint_driver()
2682 if (regdom_changes(driver_request->alpha2)) in __reg_process_hint_driver()
2690 * loaded card also agrees on the regulatory domain. in __reg_process_hint_driver()
2692 if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER && in __reg_process_hint_driver()
2693 !regdom_changes(driver_request->alpha2)) in __reg_process_hint_driver()
2700 * reg_process_hint_driver - process driver regulatory requests
2730 rcu_assign_pointer(wiphy->regd, regd); in reg_process_hint_driver()
2735 driver_request->intersect = treatment == REG_REQ_INTERSECT; in reg_process_hint_driver()
2736 driver_request->processed = false; in reg_process_hint_driver()
2740 * have applied the requested regulatory domain before we just in reg_process_hint_driver()
2767 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2771 if (wiphy->regulatory_flags & REGULATORY_COUNTRY_IE_IGNORE) in __reg_process_hint_country_ie()
2775 if (unlikely(!is_an_alpha2(country_ie_request->alpha2))) in __reg_process_hint_country_ie()
2776 return -EINVAL; in __reg_process_hint_country_ie()
2778 if (lr->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) in __reg_process_hint_country_ie()
2781 last_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in __reg_process_hint_country_ie()
2790 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2795 if (regdom_changes(country_ie_request->alpha2)) in __reg_process_hint_country_ie()
2801 * reg_process_hint_country_ie - process regulatory requests from country IEs
2835 country_ie_request->intersect = false; in reg_process_hint_country_ie()
2836 country_ie_request->processed = false; in reg_process_hint_country_ie()
2856 wiphy1_regd = rcu_dereference(wiphy1->regd); in reg_dfs_domain_same()
2860 wiphy2_regd = rcu_dereference(wiphy2->regd); in reg_dfs_domain_same()
2864 dfs_domain_same = wiphy1_regd->dfs_region == wiphy2_regd->dfs_region; in reg_dfs_domain_same()
2874 if (!(dst_chan->flags & IEEE80211_CHAN_RADAR) || in reg_copy_dfs_chan_state()
2875 !(src_chan->flags & IEEE80211_CHAN_RADAR)) in reg_copy_dfs_chan_state()
2878 if (dst_chan->flags & IEEE80211_CHAN_DISABLED || in reg_copy_dfs_chan_state()
2879 src_chan->flags & IEEE80211_CHAN_DISABLED) in reg_copy_dfs_chan_state()
2882 if (src_chan->center_freq == dst_chan->center_freq && in reg_copy_dfs_chan_state()
2883 dst_chan->dfs_state == NL80211_DFS_USABLE) { in reg_copy_dfs_chan_state()
2884 dst_chan->dfs_state = src_chan->dfs_state; in reg_copy_dfs_chan_state()
2885 dst_chan->dfs_state_entered = src_chan->dfs_state_entered; in reg_copy_dfs_chan_state()
2900 dst_sband = dst_wiphy->bands[band]; in wiphy_share_dfs_chan_state()
2901 src_sband = src_wiphy->bands[band]; in wiphy_share_dfs_chan_state()
2905 for (i = 0; i < dst_sband->n_channels; i++) { in wiphy_share_dfs_chan_state()
2906 dst_chan = &dst_sband->channels[i]; in wiphy_share_dfs_chan_state()
2907 for (j = 0; j < src_sband->n_channels; j++) { in wiphy_share_dfs_chan_state()
2908 src_chan = &src_sband->channels[j]; in wiphy_share_dfs_chan_state()
2922 if (wiphy == &rdev->wiphy) in wiphy_all_share_dfs_chan_state()
2924 wiphy_share_dfs_chan_state(wiphy, &rdev->wiphy); in wiphy_all_share_dfs_chan_state()
2933 enum nl80211_reg_initiator initiator = reg_request->initiator; in reg_process_hint()
2935 if (reg_request->wiphy_idx != WIPHY_IDX_INVALID) in reg_process_hint()
2936 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); in reg_process_hint()
2970 wiphy->regulatory_flags & REGULATORY_STRICT_REG) { in reg_process_hint()
2988 wiphy = &rdev->wiphy; in notify_self_managed_wiphys()
2989 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED && in notify_self_managed_wiphys()
2990 request->initiator == NL80211_REGDOM_SET_BY_USER) in notify_self_managed_wiphys()
3006 /* When last_request->processed becomes true this will be rescheduled */ in reg_process_pending_hints()
3007 if (lr && !lr->processed) { in reg_process_pending_hints()
3022 list_del_init(&reg_request->list); in reg_process_pending_hints()
3033 if (!list_empty(&reg_requests_list) && lr && lr->processed) in reg_process_pending_hints()
3038 /* Processes beacon hints -- this has nothing to do with country IEs */
3049 list_del_init(&pending_beacon->list); in reg_process_pending_beacon_hints()
3053 wiphy_update_new_beacon(&rdev->wiphy, pending_beacon); in reg_process_pending_beacon_hints()
3056 list_add_tail(&pending_beacon->list, &reg_beacon_list); in reg_process_pending_beacon_hints()
3072 wiphy = &rdev->wiphy; in reg_process_self_managed_hints()
3075 regd = rdev->requested_regd; in reg_process_self_managed_hints()
3076 rdev->requested_regd = NULL; in reg_process_self_managed_hints()
3083 rcu_assign_pointer(wiphy->regd, regd); in reg_process_self_managed_hints()
3087 handle_band_custom(wiphy, wiphy->bands[band], regd); in reg_process_self_managed_hints()
3092 request.alpha2[0] = regd->alpha2[0]; in reg_process_self_managed_hints()
3093 request.alpha2[1] = regd->alpha2[1]; in reg_process_self_managed_hints()
3113 request->alpha2[0] = toupper(request->alpha2[0]); in queue_regulatory_request()
3114 request->alpha2[1] = toupper(request->alpha2[1]); in queue_regulatory_request()
3117 list_add_tail(&request->list, &reg_requests_list); in queue_regulatory_request()
3124 * Core regulatory hint -- happens during cfg80211_init()
3133 return -ENOMEM; in regulatory_hint_core()
3135 request->alpha2[0] = alpha2[0]; in regulatory_hint_core()
3136 request->alpha2[1] = alpha2[1]; in regulatory_hint_core()
3137 request->initiator = NL80211_REGDOM_SET_BY_CORE; in regulatory_hint_core()
3138 request->wiphy_idx = WIPHY_IDX_INVALID; in regulatory_hint_core()
3152 return -EINVAL; in regulatory_hint_user()
3155 return -EINVAL; in regulatory_hint_user()
3159 return -ENOMEM; in regulatory_hint_user()
3161 request->wiphy_idx = WIPHY_IDX_INVALID; in regulatory_hint_user()
3162 request->alpha2[0] = alpha2[0]; in regulatory_hint_user()
3163 request->alpha2[1] = alpha2[1]; in regulatory_hint_user()
3164 request->initiator = NL80211_REGDOM_SET_BY_USER; in regulatory_hint_user()
3165 request->user_reg_hint_type = user_reg_hint_type; in regulatory_hint_user()
3225 return -EINVAL; in regulatory_hint()
3227 wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG; in regulatory_hint()
3231 return -ENOMEM; in regulatory_hint()
3233 request->wiphy_idx = get_wiphy_idx(wiphy); in regulatory_hint()
3235 request->alpha2[0] = alpha2[0]; in regulatory_hint()
3236 request->alpha2[1] = alpha2[1]; in regulatory_hint()
3237 request->initiator = NL80211_REGDOM_SET_BY_DRIVER; in regulatory_hint()
3285 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE && in regulatory_hint_country_ie()
3286 lr->wiphy_idx != WIPHY_IDX_INVALID) in regulatory_hint_country_ie()
3289 request->wiphy_idx = get_wiphy_idx(wiphy); in regulatory_hint_country_ie()
3290 request->alpha2[0] = alpha2[0]; in regulatory_hint_country_ie()
3291 request->alpha2[1] = alpha2[1]; in regulatory_hint_country_ie()
3292 request->initiator = NL80211_REGDOM_SET_BY_COUNTRY_IE; in regulatory_hint_country_ie()
3293 request->country_ie_env = env; in regulatory_hint_country_ie()
3353 sband = wiphy->bands[band]; in restore_custom_reg_settings()
3356 for (i = 0; i < sband->n_channels; i++) { in restore_custom_reg_settings()
3357 chan = &sband->channels[i]; in restore_custom_reg_settings()
3358 chan->flags = chan->orig_flags; in restore_custom_reg_settings()
3359 chan->max_antenna_gain = chan->orig_mag; in restore_custom_reg_settings()
3360 chan->max_power = chan->orig_mpwr; in restore_custom_reg_settings()
3361 chan->beacon_found = false; in restore_custom_reg_settings()
3374 * - send a core regulatory hint
3375 * - send a user regulatory hint if applicable
3378 * keep their own regulatory domain on wiphy->regd so that does
3419 list_del(&reg_beacon->list); in restore_regulatory_settings()
3425 list_del(&reg_beacon->list); in restore_regulatory_settings()
3430 world_alpha2[0] = cfg80211_world_regdom->alpha2[0]; in restore_regulatory_settings()
3431 world_alpha2[1] = cfg80211_world_regdom->alpha2[1]; in restore_regulatory_settings()
3434 if (rdev->wiphy.regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) in restore_regulatory_settings()
3436 if (rdev->wiphy.regulatory_flags & REGULATORY_CUSTOM_REG) in restore_regulatory_settings()
3437 restore_custom_reg_settings(&rdev->wiphy); in restore_regulatory_settings()
3456 list_del(&ureq->list); in restore_regulatory_settings()
3491 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in is_wiphy_all_set_reg_flag()
3493 if (!(wdev->wiphy->regulatory_flags & flag)) { in is_wiphy_all_set_reg_flag()
3519 list_del(&reg_beacon->list); in regulatory_hint_disconnect()
3526 list_del(&reg_beacon->list); in regulatory_hint_disconnect()
3537 static bool freq_is_chan_12_13_14(u32 freq) in freq_is_chan_12_13_14() argument
3539 if (freq == ieee80211_channel_to_frequency(12, NL80211_BAND_2GHZ) || in freq_is_chan_12_13_14()
3540 freq == ieee80211_channel_to_frequency(13, NL80211_BAND_2GHZ) || in freq_is_chan_12_13_14()
3541 freq == ieee80211_channel_to_frequency(14, NL80211_BAND_2GHZ)) in freq_is_chan_12_13_14()
3552 &pending_beacon->chan)) in pending_reg_beacon()
3564 if (beacon_chan->beacon_found || in regulatory_hint_found_beacon()
3565 beacon_chan->flags & IEEE80211_CHAN_RADAR || in regulatory_hint_found_beacon()
3566 (beacon_chan->band == NL80211_BAND_2GHZ && in regulatory_hint_found_beacon()
3567 !freq_is_chan_12_13_14(beacon_chan->center_freq))) in regulatory_hint_found_beacon()
3579 return -ENOMEM; in regulatory_hint_found_beacon()
3582 beacon_chan->center_freq, beacon_chan->freq_offset, in regulatory_hint_found_beacon()
3587 memcpy(&reg_beacon->chan, beacon_chan, in regulatory_hint_found_beacon()
3591 * Since we can be called from BH or and non-BH context in regulatory_hint_found_beacon()
3595 list_add_tail(&reg_beacon->list, &reg_pending_beacons); in regulatory_hint_found_beacon()
3611 pr_debug(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)\n"); in print_rd_rules()
3613 for (i = 0; i < rd->n_reg_rules; i++) { in print_rd_rules()
3614 reg_rule = &rd->reg_rules[i]; in print_rd_rules()
3615 freq_range = &reg_rule->freq_range; in print_rd_rules()
3616 power_rule = &reg_rule->power_rule; in print_rd_rules()
3618 if (reg_rule->flags & NL80211_RRF_AUTO_BW) in print_rd_rules()
3620 freq_range->max_bandwidth_khz, in print_rd_rules()
3624 freq_range->max_bandwidth_khz); in print_rd_rules()
3626 if (reg_rule->flags & NL80211_RRF_DFS) in print_rd_rules()
3628 reg_rule->dfs_cac_ms/1000); in print_rd_rules()
3637 if (power_rule->max_antenna_gain) in print_rd_rules()
3638 pr_debug(" (%d KHz - %d KHz @ %s), (%d mBi, %d mBm), (%s)\n", in print_rd_rules()
3639 freq_range->start_freq_khz, in print_rd_rules()
3640 freq_range->end_freq_khz, in print_rd_rules()
3642 power_rule->max_antenna_gain, in print_rd_rules()
3643 power_rule->max_eirp, in print_rd_rules()
3646 pr_debug(" (%d KHz - %d KHz @ %s), (N/A, %d mBm), (%s)\n", in print_rd_rules()
3647 freq_range->start_freq_khz, in print_rd_rules()
3648 freq_range->end_freq_khz, in print_rd_rules()
3650 power_rule->max_eirp, in print_rd_rules()
3673 if (is_intersected_alpha2(rd->alpha2)) { in print_regdomain()
3674 if (lr->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { in print_regdomain()
3676 rdev = cfg80211_rdev_by_wiphy_idx(lr->wiphy_idx); in print_regdomain()
3678 pr_debug("Current regulatory domain updated by AP to: %c%c\n", in print_regdomain()
3679 rdev->country_ie_alpha2[0], in print_regdomain()
3680 rdev->country_ie_alpha2[1]); in print_regdomain()
3682 pr_debug("Current regulatory domain intersected:\n"); in print_regdomain()
3684 pr_debug("Current regulatory domain intersected:\n"); in print_regdomain()
3685 } else if (is_world_regdom(rd->alpha2)) { in print_regdomain()
3686 pr_debug("World regulatory domain updated:\n"); in print_regdomain()
3688 if (is_unknown_alpha2(rd->alpha2)) in print_regdomain()
3689 pr_debug("Regulatory domain changed to driver built-in settings (unknown country)\n"); in print_regdomain()
3692 pr_debug("Regulatory domain changed to country: %c%c by Cell Station\n", in print_regdomain()
3693 rd->alpha2[0], rd->alpha2[1]); in print_regdomain()
3695 pr_debug("Regulatory domain changed to country: %c%c\n", in print_regdomain()
3696 rd->alpha2[0], rd->alpha2[1]); in print_regdomain()
3700 pr_debug(" DFS Master region: %s", reg_dfs_region_str(rd->dfs_region)); in print_regdomain()
3706 pr_debug("Regulatory domain: %c%c\n", rd->alpha2[0], rd->alpha2[1]); in print_regdomain_info()
3712 if (!is_world_regdom(rd->alpha2)) in reg_set_rd_core()
3713 return -EINVAL; in reg_set_rd_core()
3723 if (!regdom_changes(rd->alpha2)) in reg_set_rd_user()
3724 return -EALREADY; in reg_set_rd_user()
3727 pr_err("Invalid regulatory domain detected: %c%c\n", in reg_set_rd_user()
3728 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_user()
3730 return -EINVAL; in reg_set_rd_user()
3733 if (!user_request->intersect) { in reg_set_rd_user()
3740 return -EINVAL; in reg_set_rd_user()
3757 if (is_world_regdom(rd->alpha2)) in reg_set_rd_driver()
3758 return -EINVAL; in reg_set_rd_driver()
3760 if (!regdom_changes(rd->alpha2)) in reg_set_rd_driver()
3761 return -EALREADY; in reg_set_rd_driver()
3764 pr_err("Invalid regulatory domain detected: %c%c\n", in reg_set_rd_driver()
3765 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_driver()
3767 return -EINVAL; in reg_set_rd_driver()
3770 request_wiphy = wiphy_idx_to_wiphy(driver_request->wiphy_idx); in reg_set_rd_driver()
3772 return -ENODEV; in reg_set_rd_driver()
3774 if (!driver_request->intersect) { in reg_set_rd_driver()
3775 if (request_wiphy->regd) in reg_set_rd_driver()
3776 return -EALREADY; in reg_set_rd_driver()
3782 rcu_assign_pointer(request_wiphy->regd, regd); in reg_set_rd_driver()
3789 return -EINVAL; in reg_set_rd_driver()
3794 * domain we keep it for its private use in reg_set_rd_driver()
3797 rcu_assign_pointer(request_wiphy->regd, rd); in reg_set_rd_driver()
3812 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && in reg_set_rd_country_ie()
3813 !is_unknown_alpha2(rd->alpha2)) in reg_set_rd_country_ie()
3814 return -EINVAL; in reg_set_rd_country_ie()
3823 pr_err("Invalid regulatory domain detected: %c%c\n", in reg_set_rd_country_ie()
3824 rd->alpha2[0], rd->alpha2[1]); in reg_set_rd_country_ie()
3826 return -EINVAL; in reg_set_rd_country_ie()
3829 request_wiphy = wiphy_idx_to_wiphy(country_ie_request->wiphy_idx); in reg_set_rd_country_ie()
3831 return -ENODEV; in reg_set_rd_country_ie()
3833 if (country_ie_request->intersect) in reg_set_rd_country_ie()
3834 return -EINVAL; in reg_set_rd_country_ie()
3841 * Use this call to set the current regulatory domain. Conflicts with
3853 return -ENODATA; in set_regdom()
3855 if (!reg_is_valid_request(rd->alpha2)) { in set_regdom()
3857 return -EINVAL; in set_regdom()
3866 switch (lr->initiator) { in set_regdom()
3882 WARN(1, "invalid initiator %d\n", lr->initiator); in set_regdom()
3884 return -EINVAL; in set_regdom()
3889 case -EALREADY: in set_regdom()
3902 if (WARN_ON(!lr->intersect && rd != get_cfg80211_regdom())) in set_regdom()
3903 return -EINVAL; in set_regdom()
3905 /* update all wiphys now with the new established regulatory domain */ in set_regdom()
3906 update_all_wiphy_regulatory(lr->initiator); in set_regdom()
3925 return -EINVAL; in __regulatory_set_wiphy_regd()
3927 if (WARN(!(wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED), in __regulatory_set_wiphy_regd()
3929 return -EPERM; in __regulatory_set_wiphy_regd()
3931 if (WARN(!is_valid_rd(rd), "Invalid regulatory domain detected\n")) { in __regulatory_set_wiphy_regd()
3933 return -EINVAL; in __regulatory_set_wiphy_regd()
3943 prev_regd = rdev->requested_regd; in __regulatory_set_wiphy_regd()
3944 rdev->requested_regd = regd; in __regulatory_set_wiphy_regd()
3985 /* self-managed devices ignore beacon hints and country IE */ in wiphy_regulatory_register()
3986 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) { in wiphy_regulatory_register()
3987 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS | in wiphy_regulatory_register()
3995 if (lr->initiator == NL80211_REGDOM_SET_BY_USER) in wiphy_regulatory_register()
4002 wiphy_update_regulatory(wiphy, lr->initiator); in wiphy_regulatory_register()
4014 reg_num_devs_support_basehint--; in wiphy_regulatory_deregister()
4017 RCU_INIT_POINTER(wiphy->regd, NULL); in wiphy_regulatory_deregister()
4020 request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); in wiphy_regulatory_deregister()
4025 lr->wiphy_idx = WIPHY_IDX_INVALID; in wiphy_regulatory_deregister()
4026 lr->country_ie_env = ENVIRON_ANY; in wiphy_regulatory_deregister()
4031 * 5GHz: https://www.fcc.gov/document/5-ghz-unlicensed-spectrum-unii
4032 * 6GHz: https://www.fcc.gov/document/fcc-proposes-more-spectrum-unlicensed-use-0
4034 int cfg80211_get_unii(int freq) in cfg80211_get_unii() argument
4036 /* UNII-1 */ in cfg80211_get_unii()
4037 if (freq >= 5150 && freq <= 5250) in cfg80211_get_unii()
4040 /* UNII-2A */ in cfg80211_get_unii()
4041 if (freq > 5250 && freq <= 5350) in cfg80211_get_unii()
4044 /* UNII-2B */ in cfg80211_get_unii()
4045 if (freq > 5350 && freq <= 5470) in cfg80211_get_unii()
4048 /* UNII-2C */ in cfg80211_get_unii()
4049 if (freq > 5470 && freq <= 5725) in cfg80211_get_unii()
4052 /* UNII-3 */ in cfg80211_get_unii()
4053 if (freq > 5725 && freq <= 5825) in cfg80211_get_unii()
4056 /* UNII-5 */ in cfg80211_get_unii()
4057 if (freq > 5925 && freq <= 6425) in cfg80211_get_unii()
4060 /* UNII-6 */ in cfg80211_get_unii()
4061 if (freq > 6425 && freq <= 6525) in cfg80211_get_unii()
4064 /* UNII-7 */ in cfg80211_get_unii()
4065 if (freq > 6525 && freq <= 6875) in cfg80211_get_unii()
4068 /* UNII-8 */ in cfg80211_get_unii()
4069 if (freq > 6875 && freq <= 7125) in cfg80211_get_unii()
4072 return -EINVAL; in cfg80211_get_unii()
4089 wiphy_regd = rcu_dereference(wiphy->regd); in regulatory_pre_cac_allowed()
4091 if (regd->dfs_region == NL80211_DFS_ETSI) in regulatory_pre_cac_allowed()
4099 if (regd->dfs_region == wiphy_regd->dfs_region && in regulatory_pre_cac_allowed()
4100 wiphy_regd->dfs_region == NL80211_DFS_ETSI) in regulatory_pre_cac_allowed()
4115 * either all channels are available - those the CAC_FINISHED in cfg80211_check_and_end_cac()
4117 * in unavailable state in wdev chandef - those the RADAR_DETECTED in cfg80211_check_and_end_cac()
4121 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_check_and_end_cac()
4122 if (wdev->cac_started && in cfg80211_check_and_end_cac()
4123 !cfg80211_chandef_dfs_usable(&rdev->wiphy, &wdev->chandef)) in cfg80211_check_and_end_cac()
4124 rdev_end_cac(rdev, wdev->netdev); in cfg80211_check_and_end_cac()
4141 if (wiphy == &rdev->wiphy) in regulatory_propagate_dfs_state()
4144 if (!reg_dfs_domain_same(wiphy, &rdev->wiphy)) in regulatory_propagate_dfs_state()
4147 if (!ieee80211_get_channel(&rdev->wiphy, in regulatory_propagate_dfs_state()
4148 chandef->chan->center_freq)) in regulatory_propagate_dfs_state()
4151 cfg80211_set_dfs_state(&rdev->wiphy, chandef, dfs_state); in regulatory_propagate_dfs_state()
4168 * It's possible that - due to other bugs/issues - cfg80211 in regulatory_init_db()
4174 return -EINVAL; in regulatory_init_db()
4181 err = regulatory_hint_core(cfg80211_world_regdom->alpha2); in regulatory_init_db()
4183 if (err == -ENOMEM) { in regulatory_init_db()
4192 * errors as non-fatal. in regulatory_init_db()
4247 dev_set_uevent_suppress(&reg_pdev->dev, true); in regulatory_exit()
4252 list_del(&reg_beacon->list); in regulatory_exit()
4257 list_del(&reg_beacon->list); in regulatory_exit()
4262 list_del(&reg_request->list); in regulatory_exit()