Skip to content

Commit 72c19df

Browse files
Miriam-Racheljmberg-intel
authored andcommitted
wifi: iwlwifi: cleanup EMLSR when BT is active handling
BT Coex disables EMLSR only for a 2.4 GHz link, but doesn't block the vif from using EMLSR with a different link pair. In addition, storing it in mvmvif:disable_esr_reason requires extracting the BT Coex bit before checking if EMLSR is blocked or not for a specific vif. Therefore, change the BT Coex bit to be an exit reason and not a blocker. On link selection, EMLSR mode will be re-calculated for the 2.4 GHz link instead of checking that bit. While at it, move the relevant function declarations to the EMLSR functions area in mvm.h Signed-off-by: Miri Korenblit <[email protected]> Link: https://msgid.link/20240505091420.a2e93b67c895.I183a0039ef076613144648cc46fbe9ab3d47c574@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 2f32414 commit 72c19df

File tree

6 files changed

+53
-66
lines changed

6 files changed

+53
-66
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/coex.c

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -257,38 +257,28 @@ static void iwl_mvm_bt_coex_tcm_based_ci(struct iwl_mvm *mvm,
257257
* This function receives the LB link id and checks if eSR should be
258258
* enabled or disabled (due to BT coex)
259259
*/
260-
static bool
260+
bool
261261
iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,
262262
struct ieee80211_vif *vif,
263-
int link_id)
263+
s32 link_rssi,
264+
bool primary)
264265
{
265266
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
266-
struct iwl_mvm_vif_link_info *link_info = mvmvif->link[link_id];
267267
bool have_wifi_loss_rate =
268268
iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
269269
BT_PROFILE_NOTIFICATION, 0) > 4;
270-
s8 link_rssi = 0;
271270
u8 wifi_loss_rate;
272271

273-
lockdep_assert_held(&mvm->mutex);
274-
275272
if (mvm->last_bt_notif.wifi_loss_low_rssi == BT_OFF)
276273
return true;
277274

278-
/* If LB link is the primary one we should always disable eSR */
279-
if (link_id == iwl_mvm_get_primary_link(vif))
275+
if (primary)
280276
return false;
281277

282278
/* The feature is not supported */
283279
if (!have_wifi_loss_rate)
284280
return true;
285281

286-
/*
287-
* We might not have a link_info when checking whether we can
288-
* (re)enable eSR - the LB link might not exist yet
289-
*/
290-
if (link_info)
291-
link_rssi = (s8)link_info->beacon_stats.avg_signal;
292282

293283
/*
294284
* In case we don't know the RSSI - take the lower wifi loss,
@@ -298,7 +288,7 @@ iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,
298288
if (!link_rssi)
299289
wifi_loss_rate = mvm->last_bt_notif.wifi_loss_mid_high_rssi;
300290

301-
else if (!(mvmvif->esr_disable_reason & IWL_MVM_ESR_BLOCKED_COEX))
291+
else if (mvmvif->esr_active)
302292
/* RSSI needs to get really low to disable eSR... */
303293
wifi_loss_rate =
304294
link_rssi <= -IWL_MVM_BT_COEX_DISABLE_ESR_THRESH ?
@@ -318,20 +308,20 @@ void iwl_mvm_bt_coex_update_link_esr(struct iwl_mvm *mvm,
318308
struct ieee80211_vif *vif,
319309
int link_id)
320310
{
321-
bool enable;
311+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
312+
struct iwl_mvm_vif_link_info *link = mvmvif->link[link_id];
322313

323314
if (!ieee80211_vif_is_mld(vif) ||
324-
!iwl_mvm_vif_from_mac80211(vif)->authorized)
315+
!iwl_mvm_vif_from_mac80211(vif)->authorized ||
316+
WARN_ON(!link))
325317
return;
326318

327-
enable = iwl_mvm_bt_coex_calculate_esr_mode(mvm, vif, link_id);
328-
329-
if (enable)
330-
iwl_mvm_unblock_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_COEX);
331-
else
319+
if (!iwl_mvm_bt_coex_calculate_esr_mode(mvm, vif,
320+
(s8)link->beacon_stats.avg_signal,
321+
link_id == iwl_mvm_get_primary_link(vif)))
332322
/* In case we decided to exit eSR - stay with the primary */
333-
iwl_mvm_block_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_COEX,
334-
iwl_mvm_get_primary_link(vif));
323+
iwl_mvm_exit_esr(mvm, vif, IWL_MVM_ESR_EXIT_COEX,
324+
iwl_mvm_get_primary_link(vif));
335325
}
336326

337327
static void iwl_mvm_bt_notif_per_link(struct iwl_mvm *mvm,
@@ -515,10 +505,6 @@ static void iwl_mvm_bt_notif_iterator(void *_data, u8 *mac,
515505
return;
516506
}
517507

518-
/* When BT is off this will be 0 */
519-
if (data->notif->wifi_loss_low_rssi == BT_OFF)
520-
iwl_mvm_unblock_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_COEX);
521-
522508
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++)
523509
iwl_mvm_bt_notif_per_link(mvm, vif, data, link_id);
524510
}

drivers/net/wireless/intel/iwlwifi/mvm/link.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,8 @@ s8 iwl_mvm_get_esr_rssi_thresh(struct iwl_mvm *mvm,
592592

593593
static u32
594594
iwl_mvm_esr_disallowed_with_link(struct ieee80211_vif *vif,
595-
const struct iwl_mvm_link_sel_data *link)
595+
const struct iwl_mvm_link_sel_data *link,
596+
bool primary)
596597
{
597598
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
598599
struct iwl_mvm *mvm = mvmvif->mvm;
@@ -601,8 +602,10 @@ iwl_mvm_esr_disallowed_with_link(struct ieee80211_vif *vif,
601602

602603
/* BT Coex effects eSR mode only if one of the links is on LB */
603604
if (link->chandef->chan->band == NL80211_BAND_2GHZ &&
604-
mvmvif->esr_disable_reason & IWL_MVM_ESR_BLOCKED_COEX)
605-
ret |= IWL_MVM_ESR_BLOCKED_COEX;
605+
(!iwl_mvm_bt_coex_calculate_esr_mode(mvm, vif, link->signal,
606+
primary)))
607+
ret |= IWL_MVM_ESR_EXIT_COEX;
608+
606609
thresh = iwl_mvm_get_esr_rssi_thresh(mvm, link->chandef,
607610
false);
608611

@@ -622,8 +625,8 @@ bool iwl_mvm_mld_valid_link_pair(struct ieee80211_vif *vif,
622625
const struct iwl_mvm_link_sel_data *b)
623626
{
624627
/* Per-link considerations */
625-
if (iwl_mvm_esr_disallowed_with_link(vif, a) ||
626-
iwl_mvm_esr_disallowed_with_link(vif, b))
628+
if (iwl_mvm_esr_disallowed_with_link(vif, a, true) ||
629+
iwl_mvm_esr_disallowed_with_link(vif, b, false))
627630
return false;
628631

629632
/* Per-combination considerations */

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,23 +3877,6 @@ iwl_mvm_sta_state_auth_to_assoc(struct ieee80211_hw *hw,
38773877
return callbacks->update_sta(mvm, vif, sta);
38783878
}
38793879

3880-
static void iwl_mvm_bt_coex_update_vif_esr(struct iwl_mvm *mvm,
3881-
struct ieee80211_vif *vif)
3882-
{
3883-
unsigned long usable_links = ieee80211_vif_usable_links(vif);
3884-
u8 link_id;
3885-
3886-
for_each_set_bit(link_id, &usable_links, IEEE80211_MLD_MAX_NUM_LINKS) {
3887-
struct ieee80211_bss_conf *link_conf =
3888-
link_conf_dereference_protected(vif, link_id);
3889-
3890-
if (WARN_ON_ONCE(!link_conf))
3891-
return;
3892-
3893-
if (link_conf->chanreq.oper.chan->band == NL80211_BAND_2GHZ)
3894-
iwl_mvm_bt_coex_update_link_esr(mvm, vif, link_id);
3895-
}
3896-
}
38973880

38983881
static int
38993882
iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm *mvm,
@@ -3928,9 +3911,6 @@ iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm *mvm,
39283911
memset(&mvmvif->last_esr_exit, 0,
39293912
sizeof(mvmvif->last_esr_exit));
39303913

3931-
/* Calculate eSR mode due to BT coex */
3932-
iwl_mvm_bt_coex_update_vif_esr(mvm, vif);
3933-
39343914
/* when client is authorized (AP station marked as such),
39353915
* try to enable the best link(s).
39363916
*/

drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ bool iwl_mvm_esr_allowed_on_vif(struct iwl_mvm *mvm,
11801180
!(ext_capa->eml_capabilities & IEEE80211_EML_CAP_EMLSR_SUPP))
11811181
return false;
11821182

1183-
return !(mvmvif->esr_disable_reason & ~IWL_MVM_ESR_BLOCKED_COEX);
1183+
return !mvmvif->esr_disable_reason;
11841184
}
11851185

11861186
static bool iwl_mvm_mld_can_activate_links(struct ieee80211_hw *hw,

drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,20 +353,21 @@ struct iwl_mvm_vif_link_info {
353353
* For the blocking reasons - use iwl_mvm_(un)block_esr(), and for the exit
354354
* reasons - use iwl_mvm_exit_esr().
355355
*
356-
* @IWL_MVM_ESR_BLOCKED_COEX: COEX is preventing the enablement of EMLSR
357356
* @IWL_MVM_ESR_BLOCKED_PREVENTION: Prevent EMLSR to avoid entering and exiting
358357
* in a loop.
359358
* @IWL_MVM_ESR_BLOCKED_WOWLAN: WOWLAN is preventing the enablement of EMLSR
360359
* @IWL_MVM_ESR_EXIT_MISSED_BEACON: exited EMLSR due to missed beacons
361360
* @IWL_MVM_ESR_EXIT_LOW_RSSI: link is deactivated/not allowed for EMLSR
362361
* due to low RSSI.
362+
* @IWL_MVM_ESR_EXIT_COEX: link is deactivated/not allowed for EMLSR
363+
* due to BT Coex.
363364
*/
364365
enum iwl_mvm_esr_state {
365-
IWL_MVM_ESR_BLOCKED_COEX = 0x1,
366-
IWL_MVM_ESR_BLOCKED_PREVENTION = 0x2,
367-
IWL_MVM_ESR_BLOCKED_WOWLAN = 0x4,
366+
IWL_MVM_ESR_BLOCKED_PREVENTION = 0x1,
367+
IWL_MVM_ESR_BLOCKED_WOWLAN = 0x2,
368368
IWL_MVM_ESR_EXIT_MISSED_BEACON = 0x10000,
369369
IWL_MVM_ESR_EXIT_LOW_RSSI = 0x20000,
370+
IWL_MVM_ESR_EXIT_COEX = 0x40000,
370371
};
371372

372373
#define IWL_MVM_BLOCK_ESR_REASONS 0xffff
@@ -2221,9 +2222,6 @@ bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,
22212222
u8 iwl_mvm_bt_coex_get_single_ant_msk(struct iwl_mvm *mvm, u8 enabled_ants);
22222223
u8 iwl_mvm_bt_coex_tx_prio(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr,
22232224
struct ieee80211_tx_info *info, u8 ac);
2224-
void iwl_mvm_bt_coex_update_link_esr(struct iwl_mvm *mvm,
2225-
struct ieee80211_vif *vif,
2226-
int link_id);
22272225

22282226
/* beacon filtering */
22292227
#ifdef CONFIG_IWLWIFI_DEBUGFS
@@ -2888,5 +2886,12 @@ void iwl_mvm_exit_esr(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
28882886
s8 iwl_mvm_get_esr_rssi_thresh(struct iwl_mvm *mvm,
28892887
const struct cfg80211_chan_def *chandef,
28902888
bool low);
2891-
2889+
void iwl_mvm_bt_coex_update_link_esr(struct iwl_mvm *mvm,
2890+
struct ieee80211_vif *vif,
2891+
int link_id);
2892+
bool
2893+
iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,
2894+
struct ieee80211_vif *vif,
2895+
s32 link_rssi,
2896+
bool primary);
28922897
#endif /* __IWL_MVM_H__ */

drivers/net/wireless/intel/iwlwifi/mvm/tests/links.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,20 @@ static struct cfg80211_bss bss = {};
3737

3838
static struct ieee80211_bss_conf link_conf = {.bss = &bss};
3939

40-
static struct iwl_mvm mvm = {};
40+
static const struct iwl_fw_cmd_version entry = {
41+
.group = LEGACY_GROUP,
42+
.cmd = BT_PROFILE_NOTIFICATION,
43+
.notif_ver = 4
44+
};
45+
46+
static struct iwl_fw fw = {
47+
.ucode_capa = {
48+
.n_cmd_versions = 1,
49+
.cmd_versions = &entry,
50+
},
51+
};
52+
53+
static struct iwl_mvm mvm = {.fw = &fw};
4154

4255
static const struct link_grading_case {
4356
const char *desc;
@@ -217,7 +230,7 @@ kunit_test_suite(link_grading);
217230

218231
static const struct valid_link_pair_case {
219232
const char *desc;
220-
u32 esr_disable_reason;
233+
bool bt;
221234
struct ieee80211_channel *chan_a;
222235
struct ieee80211_channel *chan_b;
223236
enum nl80211_chan_width cw_a;
@@ -240,7 +253,7 @@ static const struct valid_link_pair_case {
240253
},
241254
{
242255
.desc = "LB + HB, with BT.",
243-
.esr_disable_reason = 0x1,
256+
.bt = true,
244257
.chan_a = &chan_2ghz,
245258
.chan_b = &chan_5ghz,
246259
.valid = false,
@@ -370,7 +383,7 @@ static void test_valid_link_pair(struct kunit *test)
370383
#endif
371384
mvm.trans = trans;
372385

373-
mvmvif->esr_disable_reason = params->esr_disable_reason;
386+
mvm.last_bt_notif.wifi_loss_low_rssi = params->bt;
374387
mvmvif->mvm = &mvm;
375388

376389
result = iwl_mvm_mld_valid_link_pair(vif, &link_a, &link_b);

0 commit comments

Comments
 (0)