Commit 7ef0aab6 authored by Andrei Otcheretianski's avatar Andrei Otcheretianski Committed by Emmanuel Grumbach

iwlwifi: mvm: Handle failed beacon transmissions during CSA

The spec requires to decrement the CSA counters based on TBTT,
regardless if the beacon was actually transmitted. Previously, the fw
would send beacon notifications only for successfully transmitted
beacons. This behavior resulted in inaccurate CSA countdown. In order
to address this issue, the fw was changed to send beacon
notifications also for not transmitted beacons. Such notifications
have TX_STATUS_INTERNAL_ABORT (0x92).
Don't start the CSA countdown before first successfully transmitted
beacon, in order to guarantee that the CSA is announced for a
required period.
Signed-off-by: default avatarAndrei Otcheretianski <andrei.otcheretianski@intel.com>
parent 6fd1fb63
...@@ -1263,17 +1263,25 @@ int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif) ...@@ -1263,17 +1263,25 @@ int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
} }
static void iwl_mvm_csa_count_down(struct iwl_mvm *mvm, static void iwl_mvm_csa_count_down(struct iwl_mvm *mvm,
struct ieee80211_vif *csa_vif, u32 gp2) struct ieee80211_vif *csa_vif, u32 gp2,
bool tx_success)
{ {
struct iwl_mvm_vif *mvmvif = struct iwl_mvm_vif *mvmvif =
iwl_mvm_vif_from_mac80211(csa_vif); iwl_mvm_vif_from_mac80211(csa_vif);
/* Don't start to countdown from a failed beacon */
if (!tx_success && !mvmvif->csa_countdown)
return;
mvmvif->csa_countdown = true;
if (!ieee80211_csa_is_complete(csa_vif)) { if (!ieee80211_csa_is_complete(csa_vif)) {
int c = ieee80211_csa_update_counter(csa_vif); int c = ieee80211_csa_update_counter(csa_vif);
iwl_mvm_mac_ctxt_beacon_changed(mvm, csa_vif); iwl_mvm_mac_ctxt_beacon_changed(mvm, csa_vif);
if (csa_vif->p2p && if (csa_vif->p2p &&
!iwl_mvm_te_scheduled(&mvmvif->time_event_data) && gp2) { !iwl_mvm_te_scheduled(&mvmvif->time_event_data) && gp2 &&
tx_success) {
u32 rel_time = (c + 1) * u32 rel_time = (c + 1) *
csa_vif->bss_conf.beacon_int - csa_vif->bss_conf.beacon_int -
IWL_MVM_CHANNEL_SWITCH_TIME_GO; IWL_MVM_CHANNEL_SWITCH_TIME_GO;
...@@ -1300,6 +1308,7 @@ int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, ...@@ -1300,6 +1308,7 @@ int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
struct ieee80211_vif *csa_vif; struct ieee80211_vif *csa_vif;
struct ieee80211_vif *tx_blocked_vif; struct ieee80211_vif *tx_blocked_vif;
u64 tsf; u64 tsf;
u16 status;
lockdep_assert_held(&mvm->mutex); lockdep_assert_held(&mvm->mutex);
...@@ -1316,18 +1325,18 @@ int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm, ...@@ -1316,18 +1325,18 @@ int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
tsf = le64_to_cpu(beacon->tsf); tsf = le64_to_cpu(beacon->tsf);
} }
status = le16_to_cpu(beacon_notify_hdr->status.status) & TX_STATUS_MSK;
IWL_DEBUG_RX(mvm, IWL_DEBUG_RX(mvm,
"beacon status %#x retries:%d tsf:0x%16llX gp2:0x%X rate:%d\n", "beacon status %#x retries:%d tsf:0x%16llX gp2:0x%X rate:%d\n",
le16_to_cpu(beacon_notify_hdr->status.status) & status, beacon_notify_hdr->failure_frame, tsf,
TX_STATUS_MSK,
beacon_notify_hdr->failure_frame, tsf,
mvm->ap_last_beacon_gp2, mvm->ap_last_beacon_gp2,
le32_to_cpu(beacon_notify_hdr->initial_rate)); le32_to_cpu(beacon_notify_hdr->initial_rate));
csa_vif = rcu_dereference_protected(mvm->csa_vif, csa_vif = rcu_dereference_protected(mvm->csa_vif,
lockdep_is_held(&mvm->mutex)); lockdep_is_held(&mvm->mutex));
if (unlikely(csa_vif && csa_vif->csa_active)) if (unlikely(csa_vif && csa_vif->csa_active))
iwl_mvm_csa_count_down(mvm, csa_vif, mvm->ap_last_beacon_gp2); iwl_mvm_csa_count_down(mvm, csa_vif, mvm->ap_last_beacon_gp2,
(status == TX_STATUS_SUCCESS));
tx_blocked_vif = rcu_dereference_protected(mvm->csa_tx_blocked_vif, tx_blocked_vif = rcu_dereference_protected(mvm->csa_tx_blocked_vif,
lockdep_is_held(&mvm->mutex)); lockdep_is_held(&mvm->mutex));
......
...@@ -2909,6 +2909,8 @@ static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm, ...@@ -2909,6 +2909,8 @@ static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
if (!vif->csa_active || !mvmvif->ap_ibss_active) if (!vif->csa_active || !mvmvif->ap_ibss_active)
goto out; goto out;
mvmvif->csa_countdown = false;
/* Set CS bit on all the stations */ /* Set CS bit on all the stations */
iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true); iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true);
...@@ -3164,6 +3166,7 @@ static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw, ...@@ -3164,6 +3166,7 @@ static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct ieee80211_vif *csa_vif; struct ieee80211_vif *csa_vif;
struct iwl_mvm_vif *mvmvif;
int ret; int ret;
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
...@@ -3183,6 +3186,14 @@ static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw, ...@@ -3183,6 +3186,14 @@ static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,
} }
rcu_assign_pointer(mvm->csa_vif, vif); rcu_assign_pointer(mvm->csa_vif, vif);
mvmvif = iwl_mvm_vif_from_mac80211(vif);
if (WARN_ONCE(mvmvif->csa_countdown,
"Previous CSA countdown didn't complete")) {
ret = -EBUSY;
goto out_unlock;
}
break; break;
default: default:
break; break;
......
...@@ -399,6 +399,9 @@ struct iwl_mvm_vif { ...@@ -399,6 +399,9 @@ struct iwl_mvm_vif {
/* FW identified misbehaving AP */ /* FW identified misbehaving AP */
u8 uapsd_misbehaving_bssid[ETH_ALEN]; u8 uapsd_misbehaving_bssid[ETH_ALEN];
/* Indicates that CSA countdown may be started */
bool csa_countdown;
}; };
static inline struct iwl_mvm_vif * static inline struct iwl_mvm_vif *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment