1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
25 * The full GNU General Public License is included in this distribution
26 * in the file called COPYING.
28 * Contact Information:
29 * Intel Linux Wireless <linuxwifi@intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
34 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
35 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
36 * All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
42 * * Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in
46 * the documentation and/or other materials provided with the
48 * * Neither the name Intel Corporation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *****************************************************************************/
66 #include <linux/ieee80211.h>
67 #include <linux/etherdevice.h>
68 #include <net/mac80211.h>
70 #include "fw/api/coex.h"
71 #include "iwl-modparams.h"
73 #include "iwl-debug.h"
75 /* 20MHz / 40MHz below / 40Mhz above*/
76 static const __le64 iwl_ci_mask[][3] = {
77 /* dummy entry for channel 0 */
78 {cpu_to_le64(0), cpu_to_le64(0), cpu_to_le64(0)},
80 cpu_to_le64(0x0000001FFFULL),
82 cpu_to_le64(0x00007FFFFFULL),
85 cpu_to_le64(0x000000FFFFULL),
87 cpu_to_le64(0x0003FFFFFFULL),
90 cpu_to_le64(0x000003FFFCULL),
92 cpu_to_le64(0x000FFFFFFCULL),
95 cpu_to_le64(0x00001FFFE0ULL),
97 cpu_to_le64(0x007FFFFFE0ULL),
100 cpu_to_le64(0x00007FFF80ULL),
101 cpu_to_le64(0x00007FFFFFULL),
102 cpu_to_le64(0x01FFFFFF80ULL),
105 cpu_to_le64(0x0003FFFC00ULL),
106 cpu_to_le64(0x0003FFFFFFULL),
107 cpu_to_le64(0x0FFFFFFC00ULL),
110 cpu_to_le64(0x000FFFF000ULL),
111 cpu_to_le64(0x000FFFFFFCULL),
112 cpu_to_le64(0x3FFFFFF000ULL),
115 cpu_to_le64(0x007FFF8000ULL),
116 cpu_to_le64(0x007FFFFFE0ULL),
117 cpu_to_le64(0xFFFFFF8000ULL),
120 cpu_to_le64(0x01FFFE0000ULL),
121 cpu_to_le64(0x01FFFFFF80ULL),
122 cpu_to_le64(0xFFFFFE0000ULL),
125 cpu_to_le64(0x0FFFF00000ULL),
126 cpu_to_le64(0x0FFFFFFC00ULL),
130 cpu_to_le64(0x3FFFC00000ULL),
131 cpu_to_le64(0x3FFFFFF000ULL),
135 cpu_to_le64(0xFFFE000000ULL),
136 cpu_to_le64(0xFFFFFF8000ULL),
140 cpu_to_le64(0xFFF8000000ULL),
141 cpu_to_le64(0xFFFFFE0000ULL),
145 cpu_to_le64(0xFE00000000ULL),
151 static enum iwl_bt_coex_lut_type
152 iwl_get_coex_type(struct iwl_mvm *mvm, const struct ieee80211_vif *vif)
154 struct ieee80211_chanctx_conf *chanctx_conf;
155 enum iwl_bt_coex_lut_type ret;
157 u32 primary_ch_phy_id, secondary_ch_phy_id;
160 * Checking that we hold mvm->mutex is a good idea, but the rate
161 * control can't acquire the mutex since it runs in Tx path.
162 * So this is racy in that case, but in the worst case, the AMPDU
163 * size limit will be wrong for a short time which is not a big
169 chanctx_conf = rcu_dereference(vif->chanctx_conf);
172 chanctx_conf->def.chan->band != NL80211_BAND_2GHZ) {
174 return BT_COEX_INVALID_LUT;
177 ret = BT_COEX_TX_DIS_LUT;
179 if (mvm->cfg->bt_shared_single_ant) {
184 phy_ctx_id = *((u16 *)chanctx_conf->drv_priv);
185 primary_ch_phy_id = le32_to_cpu(mvm->last_bt_ci_cmd.primary_ch_phy_id);
186 secondary_ch_phy_id =
187 le32_to_cpu(mvm->last_bt_ci_cmd.secondary_ch_phy_id);
189 if (primary_ch_phy_id == phy_ctx_id)
190 ret = le32_to_cpu(mvm->last_bt_notif.primary_ch_lut);
191 else if (secondary_ch_phy_id == phy_ctx_id)
192 ret = le32_to_cpu(mvm->last_bt_notif.secondary_ch_lut);
193 /* else - default = TX TX disallowed */
200 int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm)
202 struct iwl_bt_coex_cmd bt_cmd = {};
205 lockdep_assert_held(&mvm->mutex);
207 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS)) {
208 switch (mvm->bt_force_ant_mode) {
209 case BT_FORCE_ANT_BT:
212 case BT_FORCE_ANT_WIFI:
220 bt_cmd.mode = cpu_to_le32(mode);
224 mode = iwlwifi_mod_params.bt_coex_active ? BT_COEX_NW : BT_COEX_DISABLE;
225 bt_cmd.mode = cpu_to_le32(mode);
227 if (IWL_MVM_BT_COEX_SYNC2SCO)
228 bt_cmd.enabled_modules |=
229 cpu_to_le32(BT_COEX_SYNC2SCO_ENABLED);
231 if (iwl_mvm_is_mplut_supported(mvm))
232 bt_cmd.enabled_modules |= cpu_to_le32(BT_COEX_MPLUT_ENABLED);
234 bt_cmd.enabled_modules |= cpu_to_le32(BT_COEX_HIGH_BAND_RET);
237 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif));
238 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd));
240 return iwl_mvm_send_cmd_pdu(mvm, BT_CONFIG, 0, sizeof(bt_cmd), &bt_cmd);
243 static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id,
246 struct iwl_bt_coex_reduced_txp_update_cmd cmd = {};
247 struct iwl_mvm_sta *mvmsta;
251 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
256 if (mvmsta->bt_reduced_txpower == enable)
259 value = mvmsta->sta_id;
262 value |= BT_REDUCED_TX_POWER_BIT;
264 IWL_DEBUG_COEX(mvm, "%sable reduced Tx Power for sta %d\n",
265 enable ? "en" : "dis", sta_id);
267 cmd.reduced_txp = cpu_to_le32(value);
268 mvmsta->bt_reduced_txpower = enable;
270 ret = iwl_mvm_send_cmd_pdu(mvm, BT_COEX_UPDATE_REDUCED_TXP, CMD_ASYNC,
276 struct iwl_bt_iterator_data {
277 struct iwl_bt_coex_profile_notif *notif;
279 struct ieee80211_chanctx_conf *primary;
280 struct ieee80211_chanctx_conf *secondary;
287 void iwl_mvm_bt_coex_enable_rssi_event(struct iwl_mvm *mvm,
288 struct ieee80211_vif *vif,
289 bool enable, int rssi)
291 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
293 mvmvif->bf_data.last_bt_coex_event = rssi;
294 mvmvif->bf_data.bt_coex_max_thold =
295 enable ? -IWL_MVM_BT_COEX_EN_RED_TXP_THRESH : 0;
296 mvmvif->bf_data.bt_coex_min_thold =
297 enable ? -IWL_MVM_BT_COEX_DIS_RED_TXP_THRESH : 0;
300 #define MVM_COEX_TCM_PERIOD (HZ * 10)
302 static void iwl_mvm_bt_coex_tcm_based_ci(struct iwl_mvm *mvm,
303 struct iwl_bt_iterator_data *data)
305 unsigned long now = jiffies;
307 if (!time_after(now, mvm->bt_coex_last_tcm_ts + MVM_COEX_TCM_PERIOD))
310 mvm->bt_coex_last_tcm_ts = now;
312 /* We assume here that we don't have more than 2 vifs on 2.4GHz */
314 /* if the primary is low latency, it will stay primary */
315 if (data->primary_ll)
318 if (data->primary_load >= data->secondary_load)
321 swap(data->primary, data->secondary);
324 /* must be called under rcu_read_lock */
325 static void iwl_mvm_bt_notif_iterator(void *_data, u8 *mac,
326 struct ieee80211_vif *vif)
328 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
329 struct iwl_bt_iterator_data *data = _data;
330 struct iwl_mvm *mvm = data->mvm;
331 struct ieee80211_chanctx_conf *chanctx_conf;
332 /* default smps_mode is AUTOMATIC - only used for client modes */
333 enum ieee80211_smps_mode smps_mode = IEEE80211_SMPS_AUTOMATIC;
334 u32 bt_activity_grading;
337 lockdep_assert_held(&mvm->mutex);
340 case NL80211_IFTYPE_STATION:
342 case NL80211_IFTYPE_AP:
343 if (!mvmvif->ap_ibss_active)
350 chanctx_conf = rcu_dereference(vif->chanctx_conf);
352 /* If channel context is invalid or not on 2.4GHz .. */
353 if ((!chanctx_conf ||
354 chanctx_conf->def.chan->band != NL80211_BAND_2GHZ)) {
355 if (vif->type == NL80211_IFTYPE_STATION) {
356 /* ... relax constraints and disable rssi events */
357 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_BT_COEX,
359 iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id,
361 iwl_mvm_bt_coex_enable_rssi_event(mvm, vif, false, 0);
366 bt_activity_grading = le32_to_cpu(data->notif->bt_activity_grading);
367 if (bt_activity_grading >= BT_HIGH_TRAFFIC)
368 smps_mode = IEEE80211_SMPS_STATIC;
369 else if (bt_activity_grading >= BT_LOW_TRAFFIC)
370 smps_mode = IEEE80211_SMPS_DYNAMIC;
372 /* relax SMPS constraints for next association */
373 if (!vif->bss_conf.assoc)
374 smps_mode = IEEE80211_SMPS_AUTOMATIC;
376 if (mvmvif->phy_ctxt &&
377 (mvm->last_bt_notif.rrc_status & BIT(mvmvif->phy_ctxt->id)))
378 smps_mode = IEEE80211_SMPS_AUTOMATIC;
380 IWL_DEBUG_COEX(data->mvm,
381 "mac %d: bt_activity_grading %d smps_req %d\n",
382 mvmvif->id, bt_activity_grading, smps_mode);
384 if (vif->type == NL80211_IFTYPE_STATION)
385 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_BT_COEX,
388 /* low latency is always primary */
389 if (iwl_mvm_vif_low_latency(mvmvif)) {
390 data->primary_ll = true;
392 data->secondary = data->primary;
393 data->primary = chanctx_conf;
396 if (vif->type == NL80211_IFTYPE_AP) {
397 if (!mvmvif->ap_ibss_active)
400 if (chanctx_conf == data->primary)
403 if (!data->primary_ll) {
405 * downgrade the current primary no matter what its
408 data->secondary = data->primary;
409 data->primary = chanctx_conf;
411 /* there is low latency vif - we will be secondary */
412 data->secondary = chanctx_conf;
415 if (data->primary == chanctx_conf)
416 data->primary_load = mvm->tcm.result.load[mvmvif->id];
417 else if (data->secondary == chanctx_conf)
418 data->secondary_load = mvm->tcm.result.load[mvmvif->id];
423 * STA / P2P Client, try to be primary if first vif. If we are in low
424 * latency mode, we are already in primary and just don't do much
426 if (!data->primary || data->primary == chanctx_conf)
427 data->primary = chanctx_conf;
428 else if (!data->secondary)
429 /* if secondary is not NULL, it might be a GO */
430 data->secondary = chanctx_conf;
432 if (data->primary == chanctx_conf)
433 data->primary_load = mvm->tcm.result.load[mvmvif->id];
434 else if (data->secondary == chanctx_conf)
435 data->secondary_load = mvm->tcm.result.load[mvmvif->id];
437 * don't reduce the Tx power if one of these is true:
439 * single share antenna product
441 * we are not associated
443 if (iwl_get_coex_type(mvm, vif) == BT_COEX_LOOSE_LUT ||
444 mvm->cfg->bt_shared_single_ant || !vif->bss_conf.assoc ||
445 le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) == BT_OFF) {
446 iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, false);
447 iwl_mvm_bt_coex_enable_rssi_event(mvm, vif, false, 0);
451 /* try to get the avg rssi from fw */
452 ave_rssi = mvmvif->bf_data.ave_beacon_signal;
454 /* if the RSSI isn't valid, fake it is very low */
457 if (ave_rssi > -IWL_MVM_BT_COEX_EN_RED_TXP_THRESH) {
458 if (iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, true))
459 IWL_ERR(mvm, "Couldn't send BT_CONFIG cmd\n");
460 } else if (ave_rssi < -IWL_MVM_BT_COEX_DIS_RED_TXP_THRESH) {
461 if (iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, false))
462 IWL_ERR(mvm, "Couldn't send BT_CONFIG cmd\n");
465 /* Begin to monitor the RSSI: it may influence the reduced Tx power */
466 iwl_mvm_bt_coex_enable_rssi_event(mvm, vif, true, ave_rssi);
469 static void iwl_mvm_bt_coex_notif_handle(struct iwl_mvm *mvm)
471 struct iwl_bt_iterator_data data = {
473 .notif = &mvm->last_bt_notif,
475 struct iwl_bt_coex_ci_cmd cmd = {};
478 /* Ignore updates if we are in force mode */
479 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS))
483 ieee80211_iterate_active_interfaces_atomic(
484 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
485 iwl_mvm_bt_notif_iterator, &data);
487 iwl_mvm_bt_coex_tcm_based_ci(mvm, &data);
490 struct ieee80211_chanctx_conf *chan = data.primary;
491 if (WARN_ON(!chan->def.chan)) {
496 if (chan->def.width < NL80211_CHAN_WIDTH_40) {
499 if (chan->def.center_freq1 >
500 chan->def.chan->center_freq)
507 iwl_ci_mask[chan->def.chan->hw_value][ci_bw_idx];
508 cmd.primary_ch_phy_id =
509 cpu_to_le32(*((u16 *)data.primary->drv_priv));
512 if (data.secondary) {
513 struct ieee80211_chanctx_conf *chan = data.secondary;
514 if (WARN_ON(!data.secondary->def.chan)) {
519 if (chan->def.width < NL80211_CHAN_WIDTH_40) {
522 if (chan->def.center_freq1 >
523 chan->def.chan->center_freq)
529 cmd.bt_secondary_ci =
530 iwl_ci_mask[chan->def.chan->hw_value][ci_bw_idx];
531 cmd.secondary_ch_phy_id =
532 cpu_to_le32(*((u16 *)data.secondary->drv_priv));
537 /* Don't spam the fw with the same command over and over */
538 if (memcmp(&cmd, &mvm->last_bt_ci_cmd, sizeof(cmd))) {
539 if (iwl_mvm_send_cmd_pdu(mvm, BT_COEX_CI, 0,
541 IWL_ERR(mvm, "Failed to send BT_CI cmd\n");
542 memcpy(&mvm->last_bt_ci_cmd, &cmd, sizeof(cmd));
546 void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
547 struct iwl_rx_cmd_buffer *rxb)
549 struct iwl_rx_packet *pkt = rxb_addr(rxb);
550 struct iwl_bt_coex_profile_notif *notif = (void *)pkt->data;
552 IWL_DEBUG_COEX(mvm, "BT Coex Notification received\n");
553 IWL_DEBUG_COEX(mvm, "\tBT ci compliance %d\n", notif->bt_ci_compliance);
554 IWL_DEBUG_COEX(mvm, "\tBT primary_ch_lut %d\n",
555 le32_to_cpu(notif->primary_ch_lut));
556 IWL_DEBUG_COEX(mvm, "\tBT secondary_ch_lut %d\n",
557 le32_to_cpu(notif->secondary_ch_lut));
558 IWL_DEBUG_COEX(mvm, "\tBT activity grading %d\n",
559 le32_to_cpu(notif->bt_activity_grading));
561 /* remember this notification for future use: rssi fluctuations */
562 memcpy(&mvm->last_bt_notif, notif, sizeof(mvm->last_bt_notif));
564 iwl_mvm_bt_coex_notif_handle(mvm);
567 void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
568 enum ieee80211_rssi_event_data rssi_event)
570 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
573 lockdep_assert_held(&mvm->mutex);
575 /* Ignore updates if we are in force mode */
576 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS))
580 * Rssi update while not associated - can happen since the statistics
581 * are handled asynchronously
583 if (mvmvif->ap_sta_id == IWL_MVM_INVALID_STA)
586 /* No BT - reports should be disabled */
587 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) == BT_OFF)
590 IWL_DEBUG_COEX(mvm, "RSSI for %pM is now %s\n", vif->bss_conf.bssid,
591 rssi_event == RSSI_EVENT_HIGH ? "HIGH" : "LOW");
594 * Check if rssi is good enough for reduced Tx power, but not in loose
597 if (rssi_event == RSSI_EVENT_LOW || mvm->cfg->bt_shared_single_ant ||
598 iwl_get_coex_type(mvm, vif) == BT_COEX_LOOSE_LUT)
599 ret = iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id,
602 ret = iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, true);
605 IWL_ERR(mvm, "couldn't send BT_CONFIG HCMD upon RSSI event\n");
608 #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000)
609 #define LINK_QUAL_AGG_TIME_LIMIT_BT_ACT (1200)
611 u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
612 struct ieee80211_sta *sta)
614 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
615 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
616 struct iwl_mvm_phy_ctxt *phy_ctxt = mvmvif->phy_ctxt;
617 enum iwl_bt_coex_lut_type lut_type;
619 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id))
620 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
622 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
624 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
626 lut_type = iwl_get_coex_type(mvm, mvmsta->vif);
628 if (lut_type == BT_COEX_LOOSE_LUT || lut_type == BT_COEX_INVALID_LUT)
629 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
631 /* tight coex, high bt traffic, reduce AGG time limit */
632 return LINK_QUAL_AGG_TIME_LIMIT_BT_ACT;
635 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
636 struct ieee80211_sta *sta)
638 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
639 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
640 struct iwl_mvm_phy_ctxt *phy_ctxt = mvmvif->phy_ctxt;
641 enum iwl_bt_coex_lut_type lut_type;
643 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id))
646 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
651 * In Tight / TxTxDis, BT can't Rx while we Tx, so use both antennas
652 * since BT is already killed.
653 * In Loose, BT can Rx while we Tx, so forbid MIMO to let BT Rx while
655 * When we are in 5GHz, we'll get BT_COEX_INVALID_LUT allowing MIMO.
657 lut_type = iwl_get_coex_type(mvm, mvmsta->vif);
658 return lut_type != BT_COEX_LOOSE_LUT;
661 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant)
663 /* there is no other antenna, shared antenna is always available */
664 if (mvm->cfg->bt_shared_single_ant)
667 if (ant & mvm->cfg->non_shared_ant)
670 return le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
674 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm)
676 /* there is no other antenna, shared antenna is always available */
677 if (mvm->cfg->bt_shared_single_ant)
680 return le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) < BT_HIGH_TRAFFIC;
683 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
684 enum nl80211_band band)
686 u32 bt_activity = le32_to_cpu(mvm->last_bt_notif.bt_activity_grading);
688 if (band != NL80211_BAND_2GHZ)
691 return bt_activity >= BT_LOW_TRAFFIC;
694 u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
695 struct ieee80211_tx_info *info, u8 ac)
697 __le16 fc = hdr->frame_control;
698 bool mplut_enabled = iwl_mvm_is_mplut_supported(mvm);
700 if (info->band != NL80211_BAND_2GHZ)
703 if (unlikely(mvm->bt_tx_prio))
704 return mvm->bt_tx_prio - 1;
706 if (likely(ieee80211_is_data(fc))) {
707 if (likely(ieee80211_is_data_qos(fc))) {
709 case IEEE80211_AC_BE:
710 return mplut_enabled ? 1 : 0;
711 case IEEE80211_AC_VI:
712 return mplut_enabled ? 2 : 3;
713 case IEEE80211_AC_VO:
718 } else if (is_multicast_ether_addr(hdr->addr1)) {
722 } else if (ieee80211_is_mgmt(fc)) {
723 return ieee80211_is_disassoc(fc) ? 0 : 3;
724 } else if (ieee80211_is_ctl(fc)) {
725 /* ignore cfend and cfendack frames as we never send those */
732 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm)
734 iwl_mvm_bt_coex_notif_handle(mvm);