u32 rate __maybe_unused =
                le32_to_cpu(beacon->beacon_notify_hdr.initial_rate);
 
+       lockdep_assert_held(&mvm->mutex);
+
        IWL_DEBUG_RX(mvm, "beacon status %#x retries:%d tsf:0x%16llX rate:%d\n",
                     status & TX_STATUS_MSK,
                     beacon->beacon_notify_hdr.failure_frame,
                     le64_to_cpu(beacon->tsf),
                     rate);
+
+       if (unlikely(mvm->csa_vif && mvm->csa_vif->csa_active)) {
+               if (!ieee80211_csa_is_complete(mvm->csa_vif)) {
+                       iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm->csa_vif);
+               } else {
+                       ieee80211_csa_finish(mvm->csa_vif);
+                       mvm->csa_vif = NULL;
+               }
+       }
+
        return 0;
 }
 
 
        if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD)
                hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
 
+       if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_CSA_FLOW)
+               hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
+
        hw->wiphy->iface_combinations = iwl_mvm_iface_combinations;
        hw->wiphy->n_iface_combinations =
                ARRAY_SIZE(iwl_mvm_iface_combinations);
 
        switch (vif->type) {
        case NL80211_IFTYPE_AP:
+               /* Unless it's a CSA flow we have nothing to do here */
+               if (vif->csa_active) {
+                       mvmvif->ap_ibss_active = true;
+                       break;
+               }
        case NL80211_IFTYPE_ADHOC:
                /*
                 * The AP binding flow is handled as part of the start_ap flow
                        goto out_remove_binding;
        }
 
+       /* Handle binding during CSA */
+       if (vif->type == NL80211_IFTYPE_AP) {
+               iwl_mvm_update_quotas(mvm, vif);
+               iwl_mvm_mac_ctxt_changed(mvm, vif);
+       }
+
        goto out_unlock;
 
  out_remove_binding:
        iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data);
 
        switch (vif->type) {
-       case NL80211_IFTYPE_AP:
        case NL80211_IFTYPE_ADHOC:
                goto out_unlock;
        case NL80211_IFTYPE_MONITOR:
                mvmvif->monitor_active = false;
                iwl_mvm_update_quotas(mvm, NULL);
                break;
+       case NL80211_IFTYPE_AP:
+               /* This part is triggered only during CSA */
+               if (!vif->csa_active || !mvmvif->ap_ibss_active)
+                       goto out_unlock;
+
+               mvmvif->ap_ibss_active = false;
+               iwl_mvm_update_quotas(mvm, NULL);
+               /*TODO: bt_coex notification here? */
        default:
                break;
        }
 }
 #endif
 
+static void iwl_mvm_channel_switch_beacon(struct ieee80211_hw *hw,
+                                         struct ieee80211_vif *vif,
+                                         struct cfg80211_chan_def *chandef)
+{
+       struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
+
+       mutex_lock(&mvm->mutex);
+       if (WARN(mvm->csa_vif && mvm->csa_vif->csa_active,
+                "Another CSA is already in progress"))
+               goto out_unlock;
+
+       IWL_DEBUG_MAC80211(mvm, "CSA started to freq %d\n",
+                          chandef->center_freq1);
+       mvm->csa_vif = vif;
+
+out_unlock:
+       mutex_unlock(&mvm->mutex);
+}
+
 const struct ieee80211_ops iwl_mvm_hw_ops = {
        .tx = iwl_mvm_mac_tx,
        .ampdu_action = iwl_mvm_mac_ampdu_action,
 
        .set_tim = iwl_mvm_set_tim,
 
+       .channel_switch_beacon = iwl_mvm_channel_switch_beacon,
+
        CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd)
 
 #ifdef CONFIG_PM_SLEEP
 
        RX_HANDLER(BA_NOTIF, iwl_mvm_rx_ba_notif, false),
 
        RX_HANDLER(BT_PROFILE_NOTIFICATION, iwl_mvm_rx_bt_coex_notif, true),
-       RX_HANDLER(BEACON_NOTIFICATION, iwl_mvm_rx_beacon_notif, false),
+       RX_HANDLER(BEACON_NOTIFICATION, iwl_mvm_rx_beacon_notif, true),
        RX_HANDLER(STATISTICS_NOTIFICATION, iwl_mvm_rx_statistics, true),
        RX_HANDLER(ANTENNA_COUPLING_NOTIFICATION,
                   iwl_mvm_rx_ant_coupling_notif, true),