Lines Matching +full:can +full:- +full:primary
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2013-2014, 2018-2020, 2022-2023 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
11 #include "iwl-modparams.h"
13 #include "iwl-debug.h"
100 * Checking that we hold mvm->mutex is a good idea, but the rate in iwl_get_coex_type()
101 * control can't acquire the mutex since it runs in Tx path. in iwl_get_coex_type()
109 chanctx_conf = rcu_dereference(vif->bss_conf.chanctx_conf); in iwl_get_coex_type()
112 chanctx_conf->def.chan->band != NL80211_BAND_2GHZ) { in iwl_get_coex_type()
119 phy_ctx_id = *((u16 *)chanctx_conf->drv_priv); in iwl_get_coex_type()
120 primary_ch_phy_id = le32_to_cpu(mvm->last_bt_ci_cmd.primary_ch_phy_id); in iwl_get_coex_type()
122 le32_to_cpu(mvm->last_bt_ci_cmd.secondary_ch_phy_id); in iwl_get_coex_type()
125 ret = le32_to_cpu(mvm->last_bt_notif.primary_ch_lut); in iwl_get_coex_type()
127 ret = le32_to_cpu(mvm->last_bt_notif.secondary_ch_lut); in iwl_get_coex_type()
128 /* else - default = TX TX disallowed */ in iwl_get_coex_type()
140 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_bt_init_conf()
142 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS)) { in iwl_mvm_send_bt_init_conf()
143 switch (mvm->bt_force_ant_mode) { in iwl_mvm_send_bt_init_conf()
171 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); in iwl_mvm_send_bt_init_conf()
172 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd)); in iwl_mvm_send_bt_init_conf()
189 if (mvmsta->bt_reduced_txpower == enable) in iwl_mvm_bt_coex_reduced_txp()
192 value = mvmsta->deflink.sta_id; in iwl_mvm_bt_coex_reduced_txp()
201 mvmsta->bt_reduced_txpower = enable; in iwl_mvm_bt_coex_reduced_txp()
210 struct ieee80211_chanctx_conf *primary; member
224 mvmvif->bf_data.last_bt_coex_event = rssi; in iwl_mvm_bt_coex_enable_rssi_event()
225 mvmvif->bf_data.bt_coex_max_thold = in iwl_mvm_bt_coex_enable_rssi_event()
226 enable ? -IWL_MVM_BT_COEX_EN_RED_TXP_THRESH : 0; in iwl_mvm_bt_coex_enable_rssi_event()
227 mvmvif->bf_data.bt_coex_min_thold = in iwl_mvm_bt_coex_enable_rssi_event()
228 enable ? -IWL_MVM_BT_COEX_DIS_RED_TXP_THRESH : 0; in iwl_mvm_bt_coex_enable_rssi_event()
238 if (!time_after(now, mvm->bt_coex_last_tcm_ts + MVM_COEX_TCM_PERIOD)) in iwl_mvm_bt_coex_tcm_based_ci()
241 mvm->bt_coex_last_tcm_ts = now; in iwl_mvm_bt_coex_tcm_based_ci()
245 /* if the primary is low latency, it will stay primary */ in iwl_mvm_bt_coex_tcm_based_ci()
246 if (data->primary_ll) in iwl_mvm_bt_coex_tcm_based_ci()
249 if (data->primary_load >= data->secondary_load) in iwl_mvm_bt_coex_tcm_based_ci()
252 swap(data->primary, data->secondary); in iwl_mvm_bt_coex_tcm_based_ci()
260 /* default smps_mode is AUTOMATIC - only used for client modes */ in iwl_mvm_bt_notif_per_link()
269 lockdep_assert_held(&mvm->mutex); in iwl_mvm_bt_notif_per_link()
271 link_info = mvmvif->link[link_id]; in iwl_mvm_bt_notif_per_link()
275 link_conf = rcu_dereference(vif->link_conf[link_id]); in iwl_mvm_bt_notif_per_link()
276 /* This can happen due to races: if we receive the notification in iwl_mvm_bt_notif_per_link()
283 chanctx_conf = rcu_dereference(link_conf->chanctx_conf); in iwl_mvm_bt_notif_per_link()
287 chanctx_conf->def.chan->band != NL80211_BAND_2GHZ)) { in iwl_mvm_bt_notif_per_link()
288 if (vif->type == NL80211_IFTYPE_STATION) { in iwl_mvm_bt_notif_per_link()
292 iwl_mvm_bt_coex_reduced_txp(mvm, link_info->ap_sta_id, in iwl_mvm_bt_notif_per_link()
300 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2)) in iwl_mvm_bt_notif_per_link()
305 bt_activity_grading = le32_to_cpu(data->notif->bt_activity_grading); in iwl_mvm_bt_notif_per_link()
312 if (!vif->cfg.assoc) in iwl_mvm_bt_notif_per_link()
315 if (link_info->phy_ctxt && in iwl_mvm_bt_notif_per_link()
316 (mvm->last_bt_notif.rrc_status & BIT(link_info->phy_ctxt->id))) in iwl_mvm_bt_notif_per_link()
319 IWL_DEBUG_COEX(data->mvm, in iwl_mvm_bt_notif_per_link()
321 mvmvif->id, link_info->fw_link_id, in iwl_mvm_bt_notif_per_link()
324 if (vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_bt_notif_per_link()
328 /* low latency is always primary */ in iwl_mvm_bt_notif_per_link()
330 data->primary_ll = true; in iwl_mvm_bt_notif_per_link()
332 data->secondary = data->primary; in iwl_mvm_bt_notif_per_link()
333 data->primary = chanctx_conf; in iwl_mvm_bt_notif_per_link()
336 if (vif->type == NL80211_IFTYPE_AP) { in iwl_mvm_bt_notif_per_link()
337 if (!mvmvif->ap_ibss_active) in iwl_mvm_bt_notif_per_link()
340 if (chanctx_conf == data->primary) in iwl_mvm_bt_notif_per_link()
343 if (!data->primary_ll) { in iwl_mvm_bt_notif_per_link()
345 * downgrade the current primary no matter what its in iwl_mvm_bt_notif_per_link()
348 data->secondary = data->primary; in iwl_mvm_bt_notif_per_link()
349 data->primary = chanctx_conf; in iwl_mvm_bt_notif_per_link()
351 /* there is low latency vif - we will be secondary */ in iwl_mvm_bt_notif_per_link()
352 data->secondary = chanctx_conf; in iwl_mvm_bt_notif_per_link()
356 if (data->primary == chanctx_conf) in iwl_mvm_bt_notif_per_link()
357 data->primary_load = mvm->tcm.result.load[mvmvif->id]; in iwl_mvm_bt_notif_per_link()
358 else if (data->secondary == chanctx_conf) in iwl_mvm_bt_notif_per_link()
359 data->secondary_load = mvm->tcm.result.load[mvmvif->id]; in iwl_mvm_bt_notif_per_link()
364 * STA / P2P Client, try to be primary if first vif. If we are in low in iwl_mvm_bt_notif_per_link()
365 * latency mode, we are already in primary and just don't do much in iwl_mvm_bt_notif_per_link()
367 if (!data->primary || data->primary == chanctx_conf) in iwl_mvm_bt_notif_per_link()
368 data->primary = chanctx_conf; in iwl_mvm_bt_notif_per_link()
369 else if (!data->secondary) in iwl_mvm_bt_notif_per_link()
371 data->secondary = chanctx_conf; in iwl_mvm_bt_notif_per_link()
374 if (data->primary == chanctx_conf) in iwl_mvm_bt_notif_per_link()
375 data->primary_load = mvm->tcm.result.load[mvmvif->id]; in iwl_mvm_bt_notif_per_link()
376 else if (data->secondary == chanctx_conf) in iwl_mvm_bt_notif_per_link()
377 data->secondary_load = mvm->tcm.result.load[mvmvif->id]; in iwl_mvm_bt_notif_per_link()
385 le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) == BT_OFF || in iwl_mvm_bt_notif_per_link()
386 !vif->cfg.assoc) { in iwl_mvm_bt_notif_per_link()
387 iwl_mvm_bt_coex_reduced_txp(mvm, link_info->ap_sta_id, false); in iwl_mvm_bt_notif_per_link()
394 ave_rssi = mvmvif->bf_data.ave_beacon_signal; in iwl_mvm_bt_notif_per_link()
398 ave_rssi = -100; in iwl_mvm_bt_notif_per_link()
399 if (ave_rssi > -IWL_MVM_BT_COEX_EN_RED_TXP_THRESH) { in iwl_mvm_bt_notif_per_link()
400 if (iwl_mvm_bt_coex_reduced_txp(mvm, link_info->ap_sta_id, in iwl_mvm_bt_notif_per_link()
403 } else if (ave_rssi < -IWL_MVM_BT_COEX_DIS_RED_TXP_THRESH) { in iwl_mvm_bt_notif_per_link()
404 if (iwl_mvm_bt_coex_reduced_txp(mvm, link_info->ap_sta_id, in iwl_mvm_bt_notif_per_link()
419 struct iwl_mvm *mvm = data->mvm; in iwl_mvm_bt_notif_iterator()
422 lockdep_assert_held(&mvm->mutex); in iwl_mvm_bt_notif_iterator()
424 switch (vif->type) { in iwl_mvm_bt_notif_iterator()
428 if (!mvmvif->ap_ibss_active) in iwl_mvm_bt_notif_iterator()
443 .notif = &mvm->last_bt_notif, in iwl_mvm_bt_coex_notif_handle()
449 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS)) in iwl_mvm_bt_coex_notif_handle()
454 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_bt_coex_notif_handle()
459 if (data.primary) { in iwl_mvm_bt_coex_notif_handle()
460 struct ieee80211_chanctx_conf *chan = data.primary; in iwl_mvm_bt_coex_notif_handle()
461 if (WARN_ON(!chan->def.chan)) { in iwl_mvm_bt_coex_notif_handle()
466 if (chan->def.width < NL80211_CHAN_WIDTH_40) { in iwl_mvm_bt_coex_notif_handle()
469 if (chan->def.center_freq1 > in iwl_mvm_bt_coex_notif_handle()
470 chan->def.chan->center_freq) in iwl_mvm_bt_coex_notif_handle()
477 iwl_ci_mask[chan->def.chan->hw_value][ci_bw_idx]; in iwl_mvm_bt_coex_notif_handle()
479 cpu_to_le32(*((u16 *)data.primary->drv_priv)); in iwl_mvm_bt_coex_notif_handle()
484 if (WARN_ON(!data.secondary->def.chan)) { in iwl_mvm_bt_coex_notif_handle()
489 if (chan->def.width < NL80211_CHAN_WIDTH_40) { in iwl_mvm_bt_coex_notif_handle()
492 if (chan->def.center_freq1 > in iwl_mvm_bt_coex_notif_handle()
493 chan->def.chan->center_freq) in iwl_mvm_bt_coex_notif_handle()
500 iwl_ci_mask[chan->def.chan->hw_value][ci_bw_idx]; in iwl_mvm_bt_coex_notif_handle()
502 cpu_to_le32(*((u16 *)data.secondary->drv_priv)); in iwl_mvm_bt_coex_notif_handle()
508 if (memcmp(&cmd, &mvm->last_bt_ci_cmd, sizeof(cmd))) { in iwl_mvm_bt_coex_notif_handle()
512 memcpy(&mvm->last_bt_ci_cmd, &cmd, sizeof(cmd)); in iwl_mvm_bt_coex_notif_handle()
520 struct iwl_bt_coex_profile_notif *notif = (void *)pkt->data; in iwl_mvm_rx_bt_coex_notif()
523 IWL_DEBUG_COEX(mvm, "\tBT ci compliance %d\n", notif->bt_ci_compliance); in iwl_mvm_rx_bt_coex_notif()
525 le32_to_cpu(notif->primary_ch_lut)); in iwl_mvm_rx_bt_coex_notif()
527 le32_to_cpu(notif->secondary_ch_lut)); in iwl_mvm_rx_bt_coex_notif()
529 le32_to_cpu(notif->bt_activity_grading)); in iwl_mvm_rx_bt_coex_notif()
532 memcpy(&mvm->last_bt_notif, notif, sizeof(mvm->last_bt_notif)); in iwl_mvm_rx_bt_coex_notif()
543 lockdep_assert_held(&mvm->mutex); in iwl_mvm_bt_rssi_event()
546 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS)) in iwl_mvm_bt_rssi_event()
550 * Rssi update while not associated - can happen since the statistics in iwl_mvm_bt_rssi_event()
553 if (mvmvif->deflink.ap_sta_id == IWL_MVM_INVALID_STA) in iwl_mvm_bt_rssi_event()
556 /* No BT - reports should be disabled */ in iwl_mvm_bt_rssi_event()
557 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) == BT_OFF) in iwl_mvm_bt_rssi_event()
560 IWL_DEBUG_COEX(mvm, "RSSI for %pM is now %s\n", vif->bss_conf.bssid, in iwl_mvm_bt_rssi_event()
570 mvmvif->deflink.ap_sta_id, in iwl_mvm_bt_rssi_event()
574 mvmvif->deflink.ap_sta_id, in iwl_mvm_bt_rssi_event()
588 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif); in iwl_mvm_coex_agg_time_limit()
589 struct iwl_mvm_phy_ctxt *phy_ctxt = mvmvif->deflink.phy_ctxt; in iwl_mvm_coex_agg_time_limit()
592 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id)) in iwl_mvm_coex_agg_time_limit()
595 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) < in iwl_mvm_coex_agg_time_limit()
599 lut_type = iwl_get_coex_type(mvm, mvmsta->vif); in iwl_mvm_coex_agg_time_limit()
612 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif); in iwl_mvm_bt_coex_is_mimo_allowed()
613 struct iwl_mvm_phy_ctxt *phy_ctxt = mvmvif->deflink.phy_ctxt; in iwl_mvm_bt_coex_is_mimo_allowed()
616 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id)) in iwl_mvm_bt_coex_is_mimo_allowed()
619 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) < in iwl_mvm_bt_coex_is_mimo_allowed()
624 * In Tight / TxTxDis, BT can't Rx while we Tx, so use both antennas in iwl_mvm_bt_coex_is_mimo_allowed()
626 * In Loose, BT can Rx while we Tx, so forbid MIMO to let BT Rx while in iwl_mvm_bt_coex_is_mimo_allowed()
630 lut_type = iwl_get_coex_type(mvm, mvmsta->vif); in iwl_mvm_bt_coex_is_mimo_allowed()
636 if (ant & mvm->cfg->non_shared_ant) in iwl_mvm_bt_coex_is_ant_avail()
639 return le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) < in iwl_mvm_bt_coex_is_ant_avail()
645 return le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) < BT_HIGH_TRAFFIC; in iwl_mvm_bt_coex_is_shared_ant_avail()
651 u32 bt_activity = le32_to_cpu(mvm->last_bt_notif.bt_activity_grading); in iwl_mvm_bt_coex_is_tpc_allowed()
661 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2) && in iwl_mvm_bt_coex_get_single_ant_msk()
662 (mvm->cfg->non_shared_ant & enabled_ants)) in iwl_mvm_bt_coex_get_single_ant_msk()
663 return mvm->cfg->non_shared_ant; in iwl_mvm_bt_coex_get_single_ant_msk()
671 __le16 fc = hdr->frame_control; in iwl_mvm_bt_coex_tx_prio()
674 if (info->band != NL80211_BAND_2GHZ) in iwl_mvm_bt_coex_tx_prio()
677 if (unlikely(mvm->bt_tx_prio)) in iwl_mvm_bt_coex_tx_prio()
678 return mvm->bt_tx_prio - 1; in iwl_mvm_bt_coex_tx_prio()
692 } else if (is_multicast_ether_addr(hdr->addr1)) { in iwl_mvm_bt_coex_tx_prio()