Lines Matching +full:3 +full:cg +full:- +full:2019
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2019-2020 Realtek Corporation
162 COUNTRY_REGD("CG", RTW89_ETSI, RTW89_ETSI, RTW89_NA),
260 static const char rtw89_alpha2_list_eu[][3] = {
319 return regd - rtw89_regd_map;
335 ##_argv, __r->alpha2[0], __r->alpha2[1], \
336 __r->txpwr_regd[RTW89_BAND_2G], \
337 __r->txpwr_regd[RTW89_BAND_5G], \
338 __r->txpwr_regd[RTW89_BAND_6G]); \
344 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
345 const struct rtw89_chip_info *chip = rtwdev->chip;
354 sband = wiphy->bands[NL80211_BAND_5GHZ];
358 if (!chip->support_unii4) {
359 sband->n_channels -= RTW89_5GHZ_UNII4_CHANNEL_NUM;
363 bitmap_fill(regulatory->block_unii4, RTW89_REGD_MAX_COUNTRY_NUM);
379 "acpi: eval if allow unii-4: 0x%x\n", val);
385 switch (regd->txpwr_regd[RTW89_BAND_5G]) {
388 clear_bit(i, regulatory->block_unii4);
392 clear_bit(i, regulatory->block_unii4);
403 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
414 set_bit(index, regulatory->block_6ghz);
416 clear_bit(index, regulatory->block_6ghz);
421 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
438 switch (ptr->policy_mode) {
445 bitmap_fill(regulatory->block_6ghz, RTW89_REGD_MAX_COUNTRY_NUM);
450 ptr->policy_mode);
454 for (i = 0; i < ptr->country_count; i++) {
455 country = &ptr->country_list[i];
456 if (memcmp("EU", country->alpha2, 2) != 0) {
458 country->alpha2);
473 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
483 "acpi: cannot eval policy 6ghz-sp: %d\n", ret);
489 switch (ptr->override) {
493 ptr->override);
501 bitmap_fill(regulatory->block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM);
503 enable_by_us = u8_get_bits(ptr->conf, RTW89_ACPI_CONF_6GHZ_SP_US);
508 if (enable_by_us && memcmp(tmp->alpha2, "US", 2) == 0)
509 clear_bit(i, regulatory->block_6ghz_sp);
518 const struct rtw89_chip_info *chip = rtwdev->chip;
519 bool chip_support_6ghz = chip->support_bands & BIT(NL80211_BAND_6GHZ);
562 sband = wiphy->bands[NL80211_BAND_6GHZ];
566 wiphy->bands[NL80211_BAND_6GHZ] = NULL;
567 kfree((__force void *)sband->iftype_data);
573 struct wiphy *wiphy = rtwdev->hw->wiphy;
576 return -EINVAL;
581 wiphy->reg_notifier = rtw89_regd_notifier;
589 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
591 struct wiphy *wiphy = rtwdev->hw->wiphy;
594 regulatory->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
597 return -EINVAL;
599 chip_regd = rtw89_regd_find_reg_by_name(rtwdev->efuse.country_code);
601 rtwdev->regulatory.regd = chip_regd;
605 rtwdev->regulatory.regd = chip_regd;
608 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
609 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
611 ret = regulatory_hint(rtwdev->hw->wiphy,
612 rtwdev->regulatory.regd->alpha2);
620 rtw89_debug_regd(rtwdev, rtwdev->regulatory.regd,
628 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
629 const struct rtw89_chip_info *chip = rtwdev->chip;
630 const struct rtw89_regd *regd = regulatory->regd;
635 sband = wiphy->bands[NL80211_BAND_5GHZ];
639 if (!chip->support_unii4)
644 !test_bit(index, regulatory->block_unii4))
647 rtw89_debug(rtwdev, RTW89_DBG_REGD, "%c%c unii-4 is blocked by policy\n",
648 regd->alpha2[0], regd->alpha2[1]);
650 for (i = RTW89_5GHZ_UNII4_START_INDEX; i < sband->n_channels; i++)
651 sband->channels[i].flags |= IEEE80211_CHAN_DISABLED;
657 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
658 const struct rtw89_regd *regd = regulatory->regd;
665 !test_bit(index, regulatory->block_6ghz))
669 regd->alpha2[0], regd->alpha2[1]);
671 sband = wiphy->bands[NL80211_BAND_6GHZ];
675 for (i = 0; i < sband->n_channels; i++)
676 sband->channels[i].flags |= IEEE80211_CHAN_DISABLED;
683 rtwdev->regulatory.regd = rtw89_regd_find_reg_by_name(request->alpha2);
688 if (request->initiator == NL80211_REGDOM_SET_BY_USER &&
689 !rtw89_regd_is_ww(rtwdev->regulatory.regd))
690 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;
692 wiphy->regulatory_flags &= ~REGULATORY_COUNTRY_IE_IGNORE;
701 struct rtw89_dev *rtwdev = hw->priv;
703 mutex_lock(&rtwdev->mutex);
706 if (wiphy->regd) {
712 rtw89_debug_regd(rtwdev, rtwdev->regulatory.regd,
714 request->initiator);
719 mutex_unlock(&rtwdev->mutex);
723 * Both units are 0.5 dB-based. Return a constraint in dB.
727 const u8 hw_deviation = 3; /* unit: 0.5 dB */
732 return (raw - offset) / 2;
737 if (tpe->valid) {
738 tpe->constraint = min(tpe->constraint, cstr);
742 tpe->constraint = cstr;
743 tpe->valid = true;
752 if (!eirp->valid)
755 for (i = 0; i < eirp->count; i++) {
756 cstr = tpe_get_constraint(eirp->power[i]);
775 if (!psd->valid)
778 for (i = 0; i < psd->count; i++) {
779 cstr_psd = tpe_get_constraint(psd->power[i]);
791 tpe_deal_with_eirp(result_tpe, &parsed_tpe->max_local[category]);
792 tpe_deal_with_eirp(result_tpe, &parsed_tpe->max_reg_client[category]);
793 tpe_deal_with_psd(result_tpe, &parsed_tpe->psd_local[category]);
794 tpe_deal_with_psd(result_tpe, &parsed_tpe->psd_reg_client[category]);
799 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
808 chan = rtw89_chan_get(rtwdev, rtwvif->sub_entity_idx);
809 if (chan->band_type != RTW89_BAND_6G)
812 tmp = &rtwvif->reg_6ghz_tpe;
813 if (!tmp->valid)
816 tpe_intersect_constraint(&new, tmp->constraint);
819 if (memcmp(®ulatory->reg_6ghz_tpe, &new,
820 sizeof(regulatory->reg_6ghz_tpe)) != 0)
832 regulatory->reg_6ghz_tpe = new;
843 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
844 struct rtw89_reg_6ghz_tpe *tpe = &rtwvif->reg_6ghz_tpe;
848 if (!active || rtwvif->reg_6ghz_power != RTW89_REG_6GHZ_POWER_STD)
851 rtw89_calculate_tpe(rtwdev, tpe, &bss_conf->tpe);
852 if (!tpe->valid)
855 if (tpe->constraint < RTW89_MIN_VALID_POWER_CONSTRAINT) {
858 __func__, tpe->constraint);
860 tpe->valid = false;
861 return -EINVAL;
871 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
872 const struct rtw89_regd *regd = regulatory->regd;
880 chan = rtw89_chan_get(rtwdev, rtwvif->sub_entity_idx);
881 if (chan->band_type != RTW89_BAND_6G)
884 if (count != 0 && rtwvif->reg_6ghz_power == sel)
887 sel = rtwvif->reg_6ghz_power;
897 test_bit(index, regulatory->block_6ghz_sp)) {
900 regd->alpha2[0], regd->alpha2[1]);
905 if (regulatory->reg_6ghz_power == sel)
911 regulatory->reg_6ghz_power = sel;
922 switch (vif->bss_conf.power_type) {
924 rtwvif->reg_6ghz_power = RTW89_REG_6GHZ_POWER_VLP;
927 rtwvif->reg_6ghz_power = RTW89_REG_6GHZ_POWER_LPI;
930 rtwvif->reg_6ghz_power = RTW89_REG_6GHZ_POWER_STD;
933 rtwvif->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
937 rtwvif->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
950 lockdep_assert_held(&rtwdev->mutex);