iwlwifi: mvm: Change FW channel info API
[linux-block.git] / drivers / net / wireless / intel / iwlwifi / mvm / mvm.h
index 503e51d32e7fde3cebdfcf6e34a54cc83b29f372..59d655436a8f7ab6ea329e0691015f659e5fa7fd 100644 (file)
@@ -83,7 +83,6 @@
 #include "sta.h"
 #include "fw-api.h"
 #include "constants.h"
-#include "tof.h"
 #include "fw/runtime.h"
 #include "fw/dbg.h"
 #include "fw/acpi.h"
@@ -95,6 +94,8 @@
 /* RSSI offset for WkP */
 #define IWL_RSSI_OFFSET 50
 #define IWL_MVM_MISSED_BEACONS_THRESHOLD 8
+#define IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG 16
+
 /* A TimeUnit is 1024 microsecond */
 #define MSEC_TO_TU(_msec)      (_msec*1000/1024)
 
@@ -781,8 +782,7 @@ struct iwl_mvm_geo_profile {
 struct iwl_mvm_txq {
        struct list_head list;
        u16 txq_id;
-       /* Protects TX path invocation from two places */
-       spinlock_t tx_path_lock;
+       atomic_t tx_request;
        bool stopped;
 };
 
@@ -965,6 +965,7 @@ struct iwl_mvm {
        struct debugfs_blob_wrapper nvm_calib_blob;
        struct debugfs_blob_wrapper nvm_prod_blob;
        struct debugfs_blob_wrapper nvm_phy_sku_blob;
+       struct debugfs_blob_wrapper nvm_reg_blob;
 
        struct iwl_mvm_frame_stats drv_rx_stats;
        spinlock_t drv_stats_lock;
@@ -988,6 +989,7 @@ struct iwl_mvm {
        u8 refs[IWL_MVM_REF_COUNT];
 
        u8 vif_count;
+       struct ieee80211_vif __rcu *vif_id_to_mac[NUM_MAC_INDEX_DRIVER];
 
        /* -1 for always, 0 for never, >0 for that many times */
        s8 fw_restart;
@@ -1123,7 +1125,6 @@ struct iwl_mvm {
 
        u32 ciphers[IWL_MVM_NUM_CIPHERS];
        struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS];
-       struct iwl_mvm_tof_data tof_data;
 
        struct ieee80211_vif *nan_vif;
 #define IWL_MAX_BAID   32
@@ -1183,7 +1184,6 @@ enum iwl_mvm_init_status {
        IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE = BIT(0),
        IWL_MVM_INIT_STATUS_LEDS_INIT_COMPLETE = BIT(1),
        IWL_MVM_INIT_STATUS_REG_HW_INIT_COMPLETE = BIT(2),
-       IWL_MVM_INIT_STATUS_TOF_INIT_COMPLETE = BIT(3),
 };
 
 static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
@@ -1240,6 +1240,19 @@ iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
        return iwl_mvm_sta_from_mac80211(sta);
 }
 
+static inline struct ieee80211_vif *
+iwl_mvm_rcu_dereference_vif_id(struct iwl_mvm *mvm, u8 vif_id, bool rcu)
+{
+       if (WARN_ON(vif_id >= ARRAY_SIZE(mvm->vif_id_to_mac)))
+               return NULL;
+
+       if (rcu)
+               return rcu_dereference(mvm->vif_id_to_mac[vif_id]);
+
+       return rcu_dereference_protected(mvm->vif_id_to_mac[vif_id],
+                                        lockdep_is_held(&mvm->mutex));
+}
+
 static inline bool iwl_mvm_is_d0i3_supported(struct iwl_mvm *mvm)
 {
        return !iwlwifi_mod_params.d0i3_disable &&
@@ -2046,4 +2059,59 @@ void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
                             struct dentry *dir);
 #endif
 
+/* Channel info utils */
+static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
+{
+       return fw_has_capa(&mvm->fw->ucode_capa,
+                          IWL_UCODE_TLV_CAPA_ULTRA_HB_CHANNELS);
+}
+
+static inline void *iwl_mvm_chan_info_cmd_tail(struct iwl_mvm *mvm,
+                                              struct iwl_fw_channel_info *ci)
+{
+       return (u8 *)ci + (iwl_mvm_has_ultra_hb_channel(mvm) ?
+                          sizeof(struct iwl_fw_channel_info) :
+                          sizeof(struct iwl_fw_channel_info_v1));
+}
+
+static inline size_t iwl_mvm_chan_info_padding(struct iwl_mvm *mvm)
+{
+       return iwl_mvm_has_ultra_hb_channel(mvm) ? 0 :
+               sizeof(struct iwl_fw_channel_info) -
+               sizeof(struct iwl_fw_channel_info_v1);
+}
+
+static inline void iwl_mvm_set_chan_info(struct iwl_mvm *mvm,
+                                        struct iwl_fw_channel_info *ci,
+                                        u32 chan, u8 band, u8 width,
+                                        u8 ctrl_pos)
+{
+       if (iwl_mvm_has_ultra_hb_channel(mvm)) {
+               ci->channel = cpu_to_le32(chan);
+               ci->band = band;
+               ci->width = width;
+               ci->ctrl_pos = ctrl_pos;
+       } else {
+               struct iwl_fw_channel_info_v1 *ci_v1 =
+                                       (struct iwl_fw_channel_info_v1 *)ci;
+
+               ci_v1->channel = chan;
+               ci_v1->band = band;
+               ci_v1->width = width;
+               ci_v1->ctrl_pos = ctrl_pos;
+       }
+}
+
+static inline void
+iwl_mvm_set_chan_info_chandef(struct iwl_mvm *mvm,
+                             struct iwl_fw_channel_info *ci,
+                             struct cfg80211_chan_def *chandef)
+{
+       iwl_mvm_set_chan_info(mvm, ci, chandef->chan->hw_value,
+                             (chandef->chan->band == NL80211_BAND_2GHZ ?
+                              PHY_BAND_24 : PHY_BAND_5),
+                              iwl_mvm_get_channel_width(chandef),
+                              iwl_mvm_get_ctrl_pos(chandef));
+}
+
 #endif /* __IWL_MVM_H__ */