Lines Matching +full:ignore +full:- +full:power +full:- +full:on +full:- +full:sel

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2019-2020 Realtek Corporation
310 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_find_reg_by_name()
311 const struct rtw89_regd_ctrl *regd_ctrl = &regulatory->ctrl; in rtw89_regd_find_reg_by_name()
314 for (i = 0; i < regd_ctrl->nr; i++) { in rtw89_regd_find_reg_by_name()
315 if (!memcmp(regd_ctrl->map[i].alpha2, alpha2, 2)) in rtw89_regd_find_reg_by_name()
316 return &regd_ctrl->map[i]; in rtw89_regd_find_reg_by_name()
329 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_get_index()
330 const struct rtw89_regd_ctrl *regd_ctrl = &regulatory->ctrl; in rtw89_regd_get_index()
337 return regd - regd_ctrl->map; in rtw89_regd_get_index()
353 ##_argv, __r->alpha2[0], __r->alpha2[1], \
354 __r->txpwr_regd[RTW89_BAND_2G], \
355 __r->txpwr_regd[RTW89_BAND_5G], \
356 __r->txpwr_regd[RTW89_BAND_6G]); \
362 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_setup_unii4()
363 const struct rtw89_regd_ctrl *regd_ctrl = &regulatory->ctrl; in rtw89_regd_setup_unii4()
364 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_regd_setup_unii4()
373 sband = wiphy->bands[NL80211_BAND_5GHZ]; in rtw89_regd_setup_unii4()
377 if (!chip->support_unii4) { in rtw89_regd_setup_unii4()
378 sband->n_channels -= RTW89_5GHZ_UNII4_CHANNEL_NUM; in rtw89_regd_setup_unii4()
382 bitmap_fill(regulatory->block_unii4, RTW89_REGD_MAX_COUNTRY_NUM); in rtw89_regd_setup_unii4()
398 "acpi: eval if allow unii-4: 0x%x\n", val); in rtw89_regd_setup_unii4()
401 for (i = 0; i < regd_ctrl->nr; i++) { in rtw89_regd_setup_unii4()
402 const struct rtw89_regd *regd = &regd_ctrl->map[i]; in rtw89_regd_setup_unii4()
404 switch (regd->txpwr_regd[RTW89_BAND_5G]) { in rtw89_regd_setup_unii4()
407 clear_bit(i, regulatory->block_unii4); in rtw89_regd_setup_unii4()
411 clear_bit(i, regulatory->block_unii4); in rtw89_regd_setup_unii4()
422 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in __rtw89_regd_setup_policy_6ghz()
433 set_bit(index, regulatory->block_6ghz); in __rtw89_regd_setup_policy_6ghz()
435 clear_bit(index, regulatory->block_6ghz); in __rtw89_regd_setup_policy_6ghz()
440 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_setup_policy_6ghz()
457 switch (ptr->policy_mode) { in rtw89_regd_setup_policy_6ghz()
464 bitmap_fill(regulatory->block_6ghz, RTW89_REGD_MAX_COUNTRY_NUM); in rtw89_regd_setup_policy_6ghz()
469 ptr->policy_mode); in rtw89_regd_setup_policy_6ghz()
473 for (i = 0; i < ptr->country_count; i++) { in rtw89_regd_setup_policy_6ghz()
474 country = &ptr->country_list[i]; in rtw89_regd_setup_policy_6ghz()
475 if (memcmp("EU", country->alpha2, 2) != 0) { in rtw89_regd_setup_policy_6ghz()
477 country->alpha2); in rtw89_regd_setup_policy_6ghz()
492 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_setup_policy_6ghz_sp()
493 const struct rtw89_regd_ctrl *regd_ctrl = &regulatory->ctrl; in rtw89_regd_setup_policy_6ghz_sp()
503 "acpi: cannot eval policy 6ghz-sp: %d\n", ret); in rtw89_regd_setup_policy_6ghz_sp()
509 switch (ptr->override) { in rtw89_regd_setup_policy_6ghz_sp()
513 ptr->override); in rtw89_regd_setup_policy_6ghz_sp()
521 bitmap_fill(regulatory->block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM); in rtw89_regd_setup_policy_6ghz_sp()
523 enable_by_us = u8_get_bits(ptr->conf, RTW89_ACPI_CONF_6GHZ_SP_US); in rtw89_regd_setup_policy_6ghz_sp()
525 for (i = 0; i < regd_ctrl->nr; i++) { in rtw89_regd_setup_policy_6ghz_sp()
526 const struct rtw89_regd *tmp = &regd_ctrl->map[i]; in rtw89_regd_setup_policy_6ghz_sp()
528 if (enable_by_us && memcmp(tmp->alpha2, "US", 2) == 0) in rtw89_regd_setup_policy_6ghz_sp()
529 clear_bit(i, regulatory->block_6ghz_sp); in rtw89_regd_setup_policy_6ghz_sp()
538 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_regd_setup_6ghz()
539 bool chip_support_6ghz = chip->support_bands & BIT(NL80211_BAND_6GHZ); in rtw89_regd_setup_6ghz()
582 sband = wiphy->bands[NL80211_BAND_6GHZ]; in rtw89_regd_setup_6ghz()
586 wiphy->bands[NL80211_BAND_6GHZ] = NULL; in rtw89_regd_setup_6ghz()
587 kfree((__force void *)sband->iftype_data); in rtw89_regd_setup_6ghz()
593 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_setup()
594 struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; in rtw89_regd_setup()
595 const struct rtw89_regd_data *regd_data = elm_info->regd; in rtw89_regd_setup()
596 struct wiphy *wiphy = rtwdev->hw->wiphy; in rtw89_regd_setup()
599 regulatory->ctrl.nr = regd_data->nr; in rtw89_regd_setup()
600 regulatory->ctrl.map = regd_data->map; in rtw89_regd_setup()
602 regulatory->ctrl.nr = ARRAY_SIZE(rtw89_regd_map); in rtw89_regd_setup()
603 regulatory->ctrl.map = rtw89_regd_map; in rtw89_regd_setup()
606 regulatory->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT; in rtw89_regd_setup()
609 return -EINVAL; in rtw89_regd_setup()
614 wiphy->reg_notifier = rtw89_regd_notifier; in rtw89_regd_setup()
621 struct wiphy *wiphy = rtwdev->hw->wiphy; in rtw89_regd_init_hint()
625 return -EINVAL; in rtw89_regd_init_hint()
627 chip_regd = rtw89_regd_find_reg_by_name(rtwdev, rtwdev->efuse.country_code); in rtw89_regd_init_hint()
629 rtwdev->regulatory.regd = chip_regd; in rtw89_regd_init_hint()
630 /* Ignore country ie if there is a country domain programmed in chip */ in rtw89_regd_init_hint()
631 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE; in rtw89_regd_init_hint()
632 wiphy->regulatory_flags |= REGULATORY_STRICT_REG; in rtw89_regd_init_hint()
634 ret = regulatory_hint(rtwdev->hw->wiphy, in rtw89_regd_init_hint()
635 rtwdev->regulatory.regd->alpha2); in rtw89_regd_init_hint()
643 rtw89_debug_regd(rtwdev, rtwdev->regulatory.regd, in rtw89_regd_init_hint()
651 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_apply_policy_unii4()
652 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_regd_apply_policy_unii4()
653 const struct rtw89_regd *regd = regulatory->regd; in rtw89_regd_apply_policy_unii4()
658 sband = wiphy->bands[NL80211_BAND_5GHZ]; in rtw89_regd_apply_policy_unii4()
662 if (!chip->support_unii4) in rtw89_regd_apply_policy_unii4()
667 !test_bit(index, regulatory->block_unii4)) in rtw89_regd_apply_policy_unii4()
670 rtw89_debug(rtwdev, RTW89_DBG_REGD, "%c%c unii-4 is blocked by policy\n", in rtw89_regd_apply_policy_unii4()
671 regd->alpha2[0], regd->alpha2[1]); in rtw89_regd_apply_policy_unii4()
673 for (i = RTW89_5GHZ_UNII4_START_INDEX; i < sband->n_channels; i++) in rtw89_regd_apply_policy_unii4()
674 sband->channels[i].flags |= IEEE80211_CHAN_DISABLED; in rtw89_regd_apply_policy_unii4()
679 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in regd_is_6ghz_blocked()
680 const struct rtw89_regd *regd = regulatory->regd; in regd_is_6ghz_blocked()
685 !test_bit(index, regulatory->block_6ghz)) in regd_is_6ghz_blocked()
689 regd->alpha2[0], regd->alpha2[1]); in regd_is_6ghz_blocked()
695 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in regd_is_6ghz_not_applicable()
696 const struct rtw89_regd *regd = regulatory->regd; in regd_is_6ghz_not_applicable()
698 if (regd->txpwr_regd[RTW89_BAND_6G] != RTW89_NA) in regd_is_6ghz_not_applicable()
702 regd->alpha2[0], regd->alpha2[1]); in regd_is_6ghz_not_applicable()
716 sband = wiphy->bands[NL80211_BAND_6GHZ]; in rtw89_regd_apply_policy_6ghz()
720 for (i = 0; i < sband->n_channels; i++) in rtw89_regd_apply_policy_6ghz()
721 sband->channels[i].flags |= IEEE80211_CHAN_DISABLED; in rtw89_regd_apply_policy_6ghz()
726 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_apply_policy_tas()
727 const struct rtw89_regd *regd = regulatory->regd; in rtw89_regd_apply_policy_tas()
728 struct rtw89_tas_info *tas = &rtwdev->tas; in rtw89_regd_apply_policy_tas()
730 if (!tas->enable) in rtw89_regd_apply_policy_tas()
733 tas->block_regd = !test_bit(RTW89_REGD_FUNC_TAS, regd->func_bitmap); in rtw89_regd_apply_policy_tas()
738 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in rtw89_regd_apply_policy_ant_gain()
739 struct rtw89_ant_gain_info *ant_gain = &rtwdev->ant_gain; in rtw89_regd_apply_policy_ant_gain()
740 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_regd_apply_policy_ant_gain()
741 const struct rtw89_regd *regd = regulatory->regd; in rtw89_regd_apply_policy_ant_gain()
743 if (!chip->support_ant_gain) in rtw89_regd_apply_policy_ant_gain()
746 ant_gain->block_country = !test_bit(RTW89_REGD_FUNC_DAG, regd->func_bitmap); in rtw89_regd_apply_policy_ant_gain()
753 rtwdev->regulatory.regd = rtw89_regd_find_reg_by_name(rtwdev, request->alpha2); in rtw89_regd_notifier_apply()
758 if (request->initiator == NL80211_REGDOM_SET_BY_USER && in rtw89_regd_notifier_apply()
759 !rtw89_regd_is_ww(rtwdev->regulatory.regd)) in rtw89_regd_notifier_apply()
760 wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE; in rtw89_regd_notifier_apply()
762 wiphy->regulatory_flags &= ~REGULATORY_COUNTRY_IE_IGNORE; in rtw89_regd_notifier_apply()
774 struct rtw89_dev *rtwdev = hw->priv; in rtw89_regd_notifier()
779 if (wiphy->regd) { in rtw89_regd_notifier()
781 "There is a country domain programmed in chip, ignore notifications\n"); in rtw89_regd_notifier()
785 rtw89_debug_regd(rtwdev, rtwdev->regulatory.regd, in rtw89_regd_notifier()
787 request->initiator); in rtw89_regd_notifier()
795 /* Maximum Transmit Power field (@raw) can be EIRP or PSD.
796 * Both units are 0.5 dB-based. Return a constraint in dB.
805 return (raw - offset) / 2; in tpe_get_constraint()
810 if (tpe->valid) { in tpe_intersect_constraint()
811 tpe->constraint = min(tpe->constraint, cstr); in tpe_intersect_constraint()
815 tpe->constraint = cstr; in tpe_intersect_constraint()
816 tpe->valid = true; in tpe_intersect_constraint()
825 if (!eirp->valid) in tpe_deal_with_eirp()
828 for (i = 0; i < eirp->count; i++) { in tpe_deal_with_eirp()
829 cstr = tpe_get_constraint(eirp->power[i]); in tpe_deal_with_eirp()
848 if (!psd->valid) in tpe_deal_with_psd()
851 for (i = 0; i < psd->count; i++) { in tpe_deal_with_psd()
852 cstr_psd = tpe_get_constraint(psd->power[i]); in tpe_deal_with_psd()
864 tpe_deal_with_eirp(result_tpe, &parsed_tpe->max_local[category]); in rtw89_calculate_tpe()
865 tpe_deal_with_eirp(result_tpe, &parsed_tpe->max_reg_client[category]); in rtw89_calculate_tpe()
866 tpe_deal_with_psd(result_tpe, &parsed_tpe->psd_local[category]); in rtw89_calculate_tpe()
867 tpe_deal_with_psd(result_tpe, &parsed_tpe->psd_reg_client[category]); in rtw89_calculate_tpe()
872 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in __rtw89_reg_6ghz_tpe_recalc()
884 chan = rtw89_chan_get(rtwdev, rtwvif_link->chanctx_idx); in __rtw89_reg_6ghz_tpe_recalc()
885 if (chan->band_type != RTW89_BAND_6G) in __rtw89_reg_6ghz_tpe_recalc()
888 tmp = &rtwvif_link->reg_6ghz_tpe; in __rtw89_reg_6ghz_tpe_recalc()
889 if (!tmp->valid) in __rtw89_reg_6ghz_tpe_recalc()
892 tpe_intersect_constraint(&new, tmp->constraint); in __rtw89_reg_6ghz_tpe_recalc()
896 if (memcmp(&regulatory->reg_6ghz_tpe, &new, in __rtw89_reg_6ghz_tpe_recalc()
897 sizeof(regulatory->reg_6ghz_tpe)) != 0) in __rtw89_reg_6ghz_tpe_recalc()
909 regulatory->reg_6ghz_tpe = new; in __rtw89_reg_6ghz_tpe_recalc()
919 struct rtw89_reg_6ghz_tpe *tpe = &rtwvif_link->reg_6ghz_tpe; in rtw89_reg_6ghz_tpe_recalc()
924 if (!active || rtwvif_link->reg_6ghz_power != RTW89_REG_6GHZ_POWER_STD) in rtw89_reg_6ghz_tpe_recalc()
930 rtw89_calculate_tpe(rtwdev, tpe, &bss_conf->tpe); in rtw89_reg_6ghz_tpe_recalc()
934 if (!tpe->valid) in rtw89_reg_6ghz_tpe_recalc()
937 if (tpe->constraint < RTW89_MIN_VALID_POWER_CONSTRAINT) { in rtw89_reg_6ghz_tpe_recalc()
940 __func__, tpe->constraint); in rtw89_reg_6ghz_tpe_recalc()
942 tpe->valid = false; in rtw89_reg_6ghz_tpe_recalc()
943 return -EINVAL; in rtw89_reg_6ghz_tpe_recalc()
953 struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; in __rtw89_reg_6ghz_power_recalc()
954 const struct rtw89_regd *regd = regulatory->regd; in __rtw89_reg_6ghz_power_recalc()
955 enum rtw89_reg_6ghz_power sel; in __rtw89_reg_6ghz_power_recalc() local
965 chan = rtw89_chan_get(rtwdev, rtwvif_link->chanctx_idx); in __rtw89_reg_6ghz_power_recalc()
966 if (chan->band_type != RTW89_BAND_6G) in __rtw89_reg_6ghz_power_recalc()
969 if (count != 0 && rtwvif_link->reg_6ghz_power == sel) in __rtw89_reg_6ghz_power_recalc()
972 sel = rtwvif_link->reg_6ghz_power; in __rtw89_reg_6ghz_power_recalc()
978 sel = RTW89_REG_6GHZ_POWER_DFLT; in __rtw89_reg_6ghz_power_recalc()
980 if (sel == RTW89_REG_6GHZ_POWER_STD) { in __rtw89_reg_6ghz_power_recalc()
983 test_bit(index, regulatory->block_6ghz_sp)) { in __rtw89_reg_6ghz_power_recalc()
986 regd->alpha2[0], regd->alpha2[1]); in __rtw89_reg_6ghz_power_recalc()
987 sel = RTW89_REG_6GHZ_POWER_DFLT; in __rtw89_reg_6ghz_power_recalc()
991 if (regulatory->reg_6ghz_power == sel) in __rtw89_reg_6ghz_power_recalc()
995 "recalc 6 GHz reg power type to %d\n", sel); in __rtw89_reg_6ghz_power_recalc()
997 regulatory->reg_6ghz_power = sel; in __rtw89_reg_6ghz_power_recalc()
1012 switch (bss_conf->power_type) { in rtw89_reg_6ghz_power_recalc()
1014 rtwvif_link->reg_6ghz_power = RTW89_REG_6GHZ_POWER_VLP; in rtw89_reg_6ghz_power_recalc()
1017 rtwvif_link->reg_6ghz_power = RTW89_REG_6GHZ_POWER_LPI; in rtw89_reg_6ghz_power_recalc()
1020 rtwvif_link->reg_6ghz_power = RTW89_REG_6GHZ_POWER_STD; in rtw89_reg_6ghz_power_recalc()
1023 rtwvif_link->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT; in rtw89_reg_6ghz_power_recalc()
1027 rtwvif_link->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT; in rtw89_reg_6ghz_power_recalc()
1042 lockdep_assert_wiphy(rtwdev->hw->wiphy); in rtw89_reg_6ghz_recalc()
1044 /* The result of reg_6ghz_tpe may depend on reg_6ghz_power type, in rtw89_reg_6ghz_recalc()