From: Sara Sharon <sara.sha...@intel.com>

Verify we do not accept new beacon templates while beacon
injection is active.

Signed-off-by: Sara Sharon <sara.sha...@intel.com>
Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
---

In v2:

   * Move definition of beacon_inject_active outside CONFIG_PM;


drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c  | 7 +++++--
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 5 +++++
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h      | 1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 80b0b2ed69bb..05a6db2db478 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -8,7 +8,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018        Intel Corporation
+ * Copyright(c) 2018 - 2019 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018        Intel Corporation
+ * Copyright(c) 2018 - 2019 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1238,6 +1238,8 @@ static int _iwl_dbgfs_inject_beacon_ie(struct iwl_mvm 
*mvm, char *bin, int len)
                goto out_err;
        }
 
+       mvm->beacon_inject_active = true;
+
        mvmvif = iwl_mvm_vif_from_mac80211(vif);
        info = IEEE80211_SKB_CB(beacon);
        rate = iwl_mvm_mac_ctxt_get_lowest_rate(info, vif);
@@ -1287,6 +1289,7 @@ static ssize_t 
iwl_dbgfs_inject_beacon_ie_restore_write(struct iwl_mvm *mvm,
        int ret = _iwl_dbgfs_inject_beacon_ie(mvm, NULL, 0);
 
        mvm->hw->extra_beacon_tailroom = 0;
+       mvm->beacon_inject_active = false;
        return ret ?: count;
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 9bd4376cad9b..003a20630252 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -1041,6 +1041,11 @@ int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
        if (!beacon)
                return -ENOMEM;
 
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+       if (mvm->beacon_inject_active)
+               return -EBUSY;
+#endif
+
        ret = iwl_mvm_mac_ctxt_send_beacon(mvm, vif, beacon);
        dev_kfree_skb(beacon);
        return ret;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h 
b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 9993337a2bbd..acb4cca5bdcf 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -978,6 +978,7 @@ struct iwl_mvm {
        u32 dbgfs_prph_reg_addr;
        bool disable_power_off;
        bool disable_power_off_d3;
+       bool beacon_inject_active;
 
        bool scan_iter_notif_enabled;
 
-- 
2.20.1

Reply via email to