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
10 * Copyright(c) 2017 Intel Deutschland GmbH
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
26 * The full GNU General Public License is included in this distribution
27 * in the file called COPYING.
29 * Contact Information:
30 * Intel Linux Wireless <linuxwifi@intel.com>
31 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
35 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
36 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
37 * Copyright(c) 2017 Intel Deutschland GmbH
38 * All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
44 * * Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * * Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in
48 * the documentation and/or other materials provided with the
50 * * Neither the name Intel Corporation nor the names of its
51 * contributors may be used to endorse or promote products derived
52 * from this software without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
60 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
61 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 *****************************************************************************/
68 #include <linux/ieee80211.h>
69 #include <linux/etherdevice.h>
70 #include <net/mac80211.h>
72 #include "fw/api/coex.h"
73 #include "iwl-modparams.h"
75 #include "iwl-debug.h"
77 /* 20MHz / 40MHz below / 40Mhz above*/
78 static const __le64 iwl_ci_mask[][3] = {
79 /* dummy entry for channel 0 */
80 {cpu_to_le64(0), cpu_to_le64(0), cpu_to_le64(0)},
82 cpu_to_le64(0x0000001FFFULL),
84 cpu_to_le64(0x00007FFFFFULL),
87 cpu_to_le64(0x000000FFFFULL),
89 cpu_to_le64(0x0003FFFFFFULL),
92 cpu_to_le64(0x000003FFFCULL),
94 cpu_to_le64(0x000FFFFFFCULL),
97 cpu_to_le64(0x00001FFFE0ULL),
99 cpu_to_le64(0x007FFFFFE0ULL),
102 cpu_to_le64(0x00007FFF80ULL),
103 cpu_to_le64(0x00007FFFFFULL),
104 cpu_to_le64(0x01FFFFFF80ULL),
107 cpu_to_le64(0x0003FFFC00ULL),
108 cpu_to_le64(0x0003FFFFFFULL),
109 cpu_to_le64(0x0FFFFFFC00ULL),
112 cpu_to_le64(0x000FFFF000ULL),
113 cpu_to_le64(0x000FFFFFFCULL),
114 cpu_to_le64(0x3FFFFFF000ULL),
117 cpu_to_le64(0x007FFF8000ULL),
118 cpu_to_le64(0x007FFFFFE0ULL),
119 cpu_to_le64(0xFFFFFF8000ULL),
122 cpu_to_le64(0x01FFFE0000ULL),
123 cpu_to_le64(0x01FFFFFF80ULL),
124 cpu_to_le64(0xFFFFFE0000ULL),
127 cpu_to_le64(0x0FFFF00000ULL),
128 cpu_to_le64(0x0FFFFFFC00ULL),
132 cpu_to_le64(0x3FFFC00000ULL),
133 cpu_to_le64(0x3FFFFFF000ULL),
137 cpu_to_le64(0xFFFE000000ULL),
138 cpu_to_le64(0xFFFFFF8000ULL),
142 cpu_to_le64(0xFFF8000000ULL),
143 cpu_to_le64(0xFFFFFE0000ULL),
147 cpu_to_le64(0xFE00000000ULL),
153 static enum iwl_bt_coex_lut_type
154 iwl_get_coex_type(struct iwl_mvm *mvm, const struct ieee80211_vif *vif)
156 struct ieee80211_chanctx_conf *chanctx_conf;
157 enum iwl_bt_coex_lut_type ret;
159 u32 primary_ch_phy_id, secondary_ch_phy_id;
162 * Checking that we hold mvm->mutex is a good idea, but the rate
163 * control can't acquire the mutex since it runs in Tx path.
164 * So this is racy in that case, but in the worst case, the AMPDU
165 * size limit will be wrong for a short time which is not a big
171 chanctx_conf = rcu_dereference(vif->chanctx_conf);
174 chanctx_conf->def.chan->band != NL80211_BAND_2GHZ) {
176 return BT_COEX_INVALID_LUT;
179 ret = BT_COEX_TX_DIS_LUT;
181 if (mvm->cfg->bt_shared_single_ant) {
186 phy_ctx_id = *((u16 *)chanctx_conf->drv_priv);
187 primary_ch_phy_id = le32_to_cpu(mvm->last_bt_ci_cmd.primary_ch_phy_id);
188 secondary_ch_phy_id =
189 le32_to_cpu(mvm->last_bt_ci_cmd.secondary_ch_phy_id);
191 if (primary_ch_phy_id == phy_ctx_id)
192 ret = le32_to_cpu(mvm->last_bt_notif.primary_ch_lut);
193 else if (secondary_ch_phy_id == phy_ctx_id)
194 ret = le32_to_cpu(mvm->last_bt_notif.secondary_ch_lut);
195 /* else - default = TX TX disallowed */
202 int iwl_mvm_send_bt_init_conf(struct iwl_mvm *mvm)
204 struct iwl_bt_coex_cmd bt_cmd = {};
207 lockdep_assert_held(&mvm->mutex);
209 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS)) {
210 switch (mvm->bt_force_ant_mode) {
211 case BT_FORCE_ANT_BT:
214 case BT_FORCE_ANT_WIFI:
222 bt_cmd.mode = cpu_to_le32(mode);
226 mode = iwlwifi_mod_params.bt_coex_active ? BT_COEX_NW : BT_COEX_DISABLE;
227 bt_cmd.mode = cpu_to_le32(mode);
229 if (IWL_MVM_BT_COEX_SYNC2SCO)
230 bt_cmd.enabled_modules |=
231 cpu_to_le32(BT_COEX_SYNC2SCO_ENABLED);
233 if (iwl_mvm_is_mplut_supported(mvm))
234 bt_cmd.enabled_modules |= cpu_to_le32(BT_COEX_MPLUT_ENABLED);
236 bt_cmd.enabled_modules |= cpu_to_le32(BT_COEX_HIGH_BAND_RET);
239 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif));
240 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd));
242 return iwl_mvm_send_cmd_pdu(mvm, BT_CONFIG, 0, sizeof(bt_cmd), &bt_cmd);
245 static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id,
248 struct iwl_bt_coex_reduced_txp_update_cmd cmd = {};
249 struct iwl_mvm_sta *mvmsta;
253 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
258 if (mvmsta->bt_reduced_txpower == enable)
261 value = mvmsta->sta_id;
264 value |= BT_REDUCED_TX_POWER_BIT;
266 IWL_DEBUG_COEX(mvm, "%sable reduced Tx Power for sta %d\n",
267 enable ? "en" : "dis", sta_id);
269 cmd.reduced_txp = cpu_to_le32(value);
270 mvmsta->bt_reduced_txpower = enable;
272 ret = iwl_mvm_send_cmd_pdu(mvm, BT_COEX_UPDATE_REDUCED_TXP, CMD_ASYNC,
278 struct iwl_bt_iterator_data {
279 struct iwl_bt_coex_profile_notif *notif;
281 struct ieee80211_chanctx_conf *primary;
282 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 /* must be called under rcu_read_lock */
301 static void iwl_mvm_bt_notif_iterator(void *_data, u8 *mac,
302 struct ieee80211_vif *vif)
304 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
305 struct iwl_bt_iterator_data *data = _data;
306 struct iwl_mvm *mvm = data->mvm;
307 struct ieee80211_chanctx_conf *chanctx_conf;
308 /* default smps_mode is AUTOMATIC - only used for client modes */
309 enum ieee80211_smps_mode smps_mode = IEEE80211_SMPS_AUTOMATIC;
310 u32 bt_activity_grading;
313 lockdep_assert_held(&mvm->mutex);
316 case NL80211_IFTYPE_STATION:
318 case NL80211_IFTYPE_AP:
319 if (!mvmvif->ap_ibss_active)
326 chanctx_conf = rcu_dereference(vif->chanctx_conf);
328 /* If channel context is invalid or not on 2.4GHz .. */
329 if ((!chanctx_conf ||
330 chanctx_conf->def.chan->band != NL80211_BAND_2GHZ)) {
331 if (vif->type == NL80211_IFTYPE_STATION) {
332 /* ... relax constraints and disable rssi events */
333 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_BT_COEX,
335 iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id,
337 iwl_mvm_bt_coex_enable_rssi_event(mvm, vif, false, 0);
342 bt_activity_grading = le32_to_cpu(data->notif->bt_activity_grading);
343 if (bt_activity_grading >= BT_HIGH_TRAFFIC)
344 smps_mode = IEEE80211_SMPS_STATIC;
345 else if (bt_activity_grading >= BT_LOW_TRAFFIC)
346 smps_mode = IEEE80211_SMPS_DYNAMIC;
348 /* relax SMPS constraints for next association */
349 if (!vif->bss_conf.assoc)
350 smps_mode = IEEE80211_SMPS_AUTOMATIC;
352 if (mvmvif->phy_ctxt &&
353 (mvm->last_bt_notif.rrc_status & BIT(mvmvif->phy_ctxt->id)))
354 smps_mode = IEEE80211_SMPS_AUTOMATIC;
356 IWL_DEBUG_COEX(data->mvm,
357 "mac %d: bt_activity_grading %d smps_req %d\n",
358 mvmvif->id, bt_activity_grading, smps_mode);
360 if (vif->type == NL80211_IFTYPE_STATION)
361 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_BT_COEX,
364 /* low latency is always primary */
365 if (iwl_mvm_vif_low_latency(mvmvif)) {
366 data->primary_ll = true;
368 data->secondary = data->primary;
369 data->primary = chanctx_conf;
372 if (vif->type == NL80211_IFTYPE_AP) {
373 if (!mvmvif->ap_ibss_active)
376 if (chanctx_conf == data->primary)
379 if (!data->primary_ll) {
381 * downgrade the current primary no matter what its
384 data->secondary = data->primary;
385 data->primary = chanctx_conf;
387 /* there is low latency vif - we will be secondary */
388 data->secondary = chanctx_conf;
394 * STA / P2P Client, try to be primary if first vif. If we are in low
395 * latency mode, we are already in primary and just don't do much
397 if (!data->primary || data->primary == chanctx_conf)
398 data->primary = chanctx_conf;
399 else if (!data->secondary)
400 /* if secondary is not NULL, it might be a GO */
401 data->secondary = chanctx_conf;
404 * don't reduce the Tx power if one of these is true:
406 * single share antenna product
408 * we are not associated
410 if (iwl_get_coex_type(mvm, vif) == BT_COEX_LOOSE_LUT ||
411 mvm->cfg->bt_shared_single_ant || !vif->bss_conf.assoc ||
412 le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) == BT_OFF) {
413 iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, false);
414 iwl_mvm_bt_coex_enable_rssi_event(mvm, vif, false, 0);
418 /* try to get the avg rssi from fw */
419 ave_rssi = mvmvif->bf_data.ave_beacon_signal;
421 /* if the RSSI isn't valid, fake it is very low */
424 if (ave_rssi > -IWL_MVM_BT_COEX_EN_RED_TXP_THRESH) {
425 if (iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, true))
426 IWL_ERR(mvm, "Couldn't send BT_CONFIG cmd\n");
427 } else if (ave_rssi < -IWL_MVM_BT_COEX_DIS_RED_TXP_THRESH) {
428 if (iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, false))
429 IWL_ERR(mvm, "Couldn't send BT_CONFIG cmd\n");
432 /* Begin to monitor the RSSI: it may influence the reduced Tx power */
433 iwl_mvm_bt_coex_enable_rssi_event(mvm, vif, true, ave_rssi);
436 static void iwl_mvm_bt_coex_notif_handle(struct iwl_mvm *mvm)
438 struct iwl_bt_iterator_data data = {
440 .notif = &mvm->last_bt_notif,
442 struct iwl_bt_coex_ci_cmd cmd = {};
445 /* Ignore updates if we are in force mode */
446 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS))
450 ieee80211_iterate_active_interfaces_atomic(
451 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
452 iwl_mvm_bt_notif_iterator, &data);
455 struct ieee80211_chanctx_conf *chan = data.primary;
456 if (WARN_ON(!chan->def.chan)) {
461 if (chan->def.width < NL80211_CHAN_WIDTH_40) {
464 if (chan->def.center_freq1 >
465 chan->def.chan->center_freq)
472 iwl_ci_mask[chan->def.chan->hw_value][ci_bw_idx];
473 cmd.primary_ch_phy_id =
474 cpu_to_le32(*((u16 *)data.primary->drv_priv));
477 if (data.secondary) {
478 struct ieee80211_chanctx_conf *chan = data.secondary;
479 if (WARN_ON(!data.secondary->def.chan)) {
484 if (chan->def.width < NL80211_CHAN_WIDTH_40) {
487 if (chan->def.center_freq1 >
488 chan->def.chan->center_freq)
494 cmd.bt_secondary_ci =
495 iwl_ci_mask[chan->def.chan->hw_value][ci_bw_idx];
496 cmd.secondary_ch_phy_id =
497 cpu_to_le32(*((u16 *)data.secondary->drv_priv));
502 /* Don't spam the fw with the same command over and over */
503 if (memcmp(&cmd, &mvm->last_bt_ci_cmd, sizeof(cmd))) {
504 if (iwl_mvm_send_cmd_pdu(mvm, BT_COEX_CI, 0,
506 IWL_ERR(mvm, "Failed to send BT_CI cmd\n");
507 memcpy(&mvm->last_bt_ci_cmd, &cmd, sizeof(cmd));
511 void iwl_mvm_rx_bt_coex_notif(struct iwl_mvm *mvm,
512 struct iwl_rx_cmd_buffer *rxb)
514 struct iwl_rx_packet *pkt = rxb_addr(rxb);
515 struct iwl_bt_coex_profile_notif *notif = (void *)pkt->data;
517 if (!iwl_mvm_has_new_ats_coex_api(mvm)) {
518 struct iwl_bt_coex_profile_notif_v4 *v4 = (void *)pkt->data;
520 mvm->last_bt_notif.mbox_msg[0] = v4->mbox_msg[0];
521 mvm->last_bt_notif.mbox_msg[1] = v4->mbox_msg[1];
522 mvm->last_bt_notif.mbox_msg[2] = v4->mbox_msg[2];
523 mvm->last_bt_notif.mbox_msg[3] = v4->mbox_msg[3];
524 mvm->last_bt_notif.msg_idx = v4->msg_idx;
525 mvm->last_bt_notif.bt_ci_compliance = v4->bt_ci_compliance;
526 mvm->last_bt_notif.primary_ch_lut = v4->primary_ch_lut;
527 mvm->last_bt_notif.secondary_ch_lut = v4->secondary_ch_lut;
528 mvm->last_bt_notif.bt_activity_grading =
529 v4->bt_activity_grading;
530 mvm->last_bt_notif.ttc_status = v4->ttc_status;
531 mvm->last_bt_notif.rrc_status = v4->rrc_status;
533 /* save this notification for future use: rssi fluctuations */
534 memcpy(&mvm->last_bt_notif, notif, sizeof(mvm->last_bt_notif));
537 IWL_DEBUG_COEX(mvm, "BT Coex Notification received\n");
538 IWL_DEBUG_COEX(mvm, "\tBT ci compliance %d\n",
539 mvm->last_bt_notif.bt_ci_compliance);
540 IWL_DEBUG_COEX(mvm, "\tBT primary_ch_lut %d\n",
541 le32_to_cpu(mvm->last_bt_notif.primary_ch_lut));
542 IWL_DEBUG_COEX(mvm, "\tBT secondary_ch_lut %d\n",
543 le32_to_cpu(mvm->last_bt_notif.secondary_ch_lut));
544 IWL_DEBUG_COEX(mvm, "\tBT activity grading %d\n",
545 le32_to_cpu(mvm->last_bt_notif.bt_activity_grading));
548 iwl_mvm_bt_coex_notif_handle(mvm);
551 void iwl_mvm_bt_rssi_event(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
552 enum ieee80211_rssi_event_data rssi_event)
554 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
557 lockdep_assert_held(&mvm->mutex);
559 /* Ignore updates if we are in force mode */
560 if (unlikely(mvm->bt_force_ant_mode != BT_FORCE_ANT_DIS))
564 * Rssi update while not associated - can happen since the statistics
565 * are handled asynchronously
567 if (mvmvif->ap_sta_id == IWL_MVM_INVALID_STA)
570 /* No BT - reports should be disabled */
571 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) == BT_OFF)
574 IWL_DEBUG_COEX(mvm, "RSSI for %pM is now %s\n", vif->bss_conf.bssid,
575 rssi_event == RSSI_EVENT_HIGH ? "HIGH" : "LOW");
578 * Check if rssi is good enough for reduced Tx power, but not in loose
581 if (rssi_event == RSSI_EVENT_LOW || mvm->cfg->bt_shared_single_ant ||
582 iwl_get_coex_type(mvm, vif) == BT_COEX_LOOSE_LUT)
583 ret = iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id,
586 ret = iwl_mvm_bt_coex_reduced_txp(mvm, mvmvif->ap_sta_id, true);
589 IWL_ERR(mvm, "couldn't send BT_CONFIG HCMD upon RSSI event\n");
592 #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000)
593 #define LINK_QUAL_AGG_TIME_LIMIT_BT_ACT (1200)
595 u16 iwl_mvm_coex_agg_time_limit(struct iwl_mvm *mvm,
596 struct ieee80211_sta *sta)
598 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
599 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
600 struct iwl_mvm_phy_ctxt *phy_ctxt = mvmvif->phy_ctxt;
601 enum iwl_bt_coex_lut_type lut_type;
603 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id))
604 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
606 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
608 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
610 lut_type = iwl_get_coex_type(mvm, mvmsta->vif);
612 if (lut_type == BT_COEX_LOOSE_LUT || lut_type == BT_COEX_INVALID_LUT)
613 return LINK_QUAL_AGG_TIME_LIMIT_DEF;
615 /* tight coex, high bt traffic, reduce AGG time limit */
616 return LINK_QUAL_AGG_TIME_LIMIT_BT_ACT;
619 bool iwl_mvm_bt_coex_is_mimo_allowed(struct iwl_mvm *mvm,
620 struct ieee80211_sta *sta)
622 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
623 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
624 struct iwl_mvm_phy_ctxt *phy_ctxt = mvmvif->phy_ctxt;
625 enum iwl_bt_coex_lut_type lut_type;
627 if (mvm->last_bt_notif.ttc_status & BIT(phy_ctxt->id))
630 if (le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
635 * In Tight / TxTxDis, BT can't Rx while we Tx, so use both antennas
636 * since BT is already killed.
637 * In Loose, BT can Rx while we Tx, so forbid MIMO to let BT Rx while
639 * When we are in 5GHz, we'll get BT_COEX_INVALID_LUT allowing MIMO.
641 lut_type = iwl_get_coex_type(mvm, mvmsta->vif);
642 return lut_type != BT_COEX_LOOSE_LUT;
645 bool iwl_mvm_bt_coex_is_ant_avail(struct iwl_mvm *mvm, u8 ant)
647 /* there is no other antenna, shared antenna is always available */
648 if (mvm->cfg->bt_shared_single_ant)
651 if (ant & mvm->cfg->non_shared_ant)
654 return le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) <
658 bool iwl_mvm_bt_coex_is_shared_ant_avail(struct iwl_mvm *mvm)
660 /* there is no other antenna, shared antenna is always available */
661 if (mvm->cfg->bt_shared_single_ant)
664 return le32_to_cpu(mvm->last_bt_notif.bt_activity_grading) < BT_HIGH_TRAFFIC;
667 bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
668 enum nl80211_band band)
670 u32 bt_activity = le32_to_cpu(mvm->last_bt_notif.bt_activity_grading);
672 if (band != NL80211_BAND_2GHZ)
675 return bt_activity >= BT_LOW_TRAFFIC;
678 u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
679 struct ieee80211_tx_info *info, u8 ac)
681 __le16 fc = hdr->frame_control;
682 bool mplut_enabled = iwl_mvm_is_mplut_supported(mvm);
684 if (info->band != NL80211_BAND_2GHZ)
687 if (unlikely(mvm->bt_tx_prio))
688 return mvm->bt_tx_prio - 1;
690 if (likely(ieee80211_is_data(fc))) {
691 if (likely(ieee80211_is_data_qos(fc))) {
693 case IEEE80211_AC_BE:
694 return mplut_enabled ? 1 : 0;
695 case IEEE80211_AC_VI:
696 return mplut_enabled ? 2 : 3;
697 case IEEE80211_AC_VO:
702 } else if (is_multicast_ether_addr(hdr->addr1)) {
706 } else if (ieee80211_is_mgmt(fc)) {
707 return ieee80211_is_disassoc(fc) ? 0 : 3;
708 } else if (ieee80211_is_ctl(fc)) {
709 /* ignore cfend and cfendack frames as we never send those */
716 void iwl_mvm_bt_coex_vif_change(struct iwl_mvm *mvm)
718 iwl_mvm_bt_coex_notif_handle(mvm);