These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / net / wireless / ath / ath10k / core.h
index f65310c..858d75f 100644 (file)
@@ -35,6 +35,8 @@
 #include "../dfs_pattern_detector.h"
 #include "spectral.h"
 #include "thermal.h"
+#include "wow.h"
+#include "swap.h"
 
 #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
 #define ATH10K_SCAN_ID 0
 #define WMI_READY_TIMEOUT (5 * HZ)
 #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)
-#define ATH10K_NUM_CHANS 38
+#define ATH10K_CONNECTION_LOSS_HZ (3*HZ)
+#define ATH10K_NUM_CHANS 39
 
 /* Antenna noise floor */
 #define ATH10K_DEFAULT_NOISE_FLOOR -95
 
 #define ATH10K_MAX_NUM_MGMT_PENDING 128
 
-/* number of failed packets */
-#define ATH10K_KICKOUT_THRESHOLD 50
+/* number of failed packets (20 packets with 16 sw reties each) */
+#define ATH10K_KICKOUT_THRESHOLD (20 * 16)
 
 /*
  * Use insanely high numbers to make sure that the firmware implementation
@@ -82,11 +85,14 @@ struct ath10k_skb_cb {
        dma_addr_t paddr;
        u8 eid;
        u8 vdev_id;
+       enum ath10k_hw_txrx_mode txmode;
+       bool is_protected;
 
        struct {
                u8 tid;
                u16 freq;
                bool is_offchan;
+               bool nohwcrypt;
                struct ath10k_htt_txbuf *txbuf;
                u32 txbuf_paddr;
        } __packed htt;
@@ -147,6 +153,7 @@ struct ath10k_wmi {
        const struct wmi_ops *ops;
 
        u32 num_mem_chunks;
+       u32 rx_decap_mode;
        struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
 };
 
@@ -207,6 +214,7 @@ struct ath10k_fw_stats_pdev {
        s32 hw_queued;
        s32 hw_reaped;
        s32 underrun;
+       u32 hw_paused;
        s32 tx_abort;
        s32 mpdus_requed;
        u32 tx_ko;
@@ -219,6 +227,16 @@ struct ath10k_fw_stats_pdev {
        u32 pdev_resets;
        u32 phy_underrun;
        u32 txop_ovf;
+       u32 seq_posted;
+       u32 seq_failed_queueing;
+       u32 seq_completed;
+       u32 seq_restarted;
+       u32 mu_seq_posted;
+       u32 mpdus_sw_flush;
+       u32 mpdus_hw_filter;
+       u32 mpdus_truncated;
+       u32 mpdus_ack_failed;
+       u32 mpdus_expired;
 
        /* PDEV RX stats */
        s32 mid_ppdu_route_change;
@@ -235,6 +253,7 @@ struct ath10k_fw_stats_pdev {
        s32 phy_errs;
        s32 phy_err_drop;
        s32 mpdu_errs;
+       s32 rx_ovfl_errs;
 };
 
 struct ath10k_fw_stats {
@@ -243,6 +262,30 @@ struct ath10k_fw_stats {
        struct list_head peers;
 };
 
+#define ATH10K_TPC_TABLE_TYPE_FLAG     1
+#define ATH10K_TPC_PREAM_TABLE_END     0xFFFF
+
+struct ath10k_tpc_table {
+       u32 pream_idx[WMI_TPC_RATE_MAX];
+       u8 rate_code[WMI_TPC_RATE_MAX];
+       char tpc_value[WMI_TPC_RATE_MAX][WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
+};
+
+struct ath10k_tpc_stats {
+       u32 reg_domain;
+       u32 chan_freq;
+       u32 phy_mode;
+       u32 twice_antenna_reduction;
+       u32 twice_max_rd_power;
+       s32 twice_antenna_gain;
+       u32 power_limit;
+       u32 num_tx_chain;
+       u32 ctl;
+       u32 rate_max;
+       u8 flag[WMI_TPC_FLAG];
+       struct ath10k_tpc_table tpc_table[WMI_TPC_FLAG];
+};
+
 struct ath10k_dfs_stats {
        u32 phy_errors;
        u32 pulses_total;
@@ -301,6 +344,7 @@ struct ath10k_vif {
        enum ath10k_beacon_state beacon_state;
        void *beacon_buf;
        dma_addr_t beacon_paddr;
+       unsigned long tx_paused; /* arbitrary values defined by target */
 
        struct ath10k *ar;
        struct ieee80211_vif *vif;
@@ -322,8 +366,8 @@ struct ath10k_vif {
                        u32 uapsd;
                } sta;
                struct {
-                       /* 127 stations; wmi limit */
-                       u8 tim_bitmap[16];
+                       /* 512 stations */
+                       u8 tim_bitmap[64];
                        u8 tim_len;
                        u32 ssid_len;
                        u8 ssid[IEEE80211_MAX_SSID_LEN];
@@ -334,13 +378,14 @@ struct ath10k_vif {
                } ap;
        } u;
 
-       u8 fixed_rate;
-       u8 fixed_nss;
-       u8 force_sgi;
        bool use_cts_prot;
+       bool nohwcrypt;
        int num_legacy_stations;
        int txpower;
        struct wmi_wmm_params_all_arg wmm_params;
+       struct work_struct ap_csa_work;
+       struct delayed_work connection_loss_work;
+       struct cfg80211_bitrate_mask bitrate_mask;
 };
 
 struct ath10k_vif_iter {
@@ -369,6 +414,11 @@ struct ath10k_debug {
        struct ath10k_dfs_stats dfs_stats;
        struct ath_dfs_pool_stats dfs_pool_stats;
 
+       /* used for tpc-dump storage, protected by data-lock */
+       struct ath10k_tpc_stats *tpc_stats;
+
+       struct completion tpc_complete;
+
        /* protected by conf_mutex */
        u32 fw_dbglog_mask;
        u32 fw_dbglog_level;
@@ -376,9 +426,6 @@ struct ath10k_debug {
        u32 reg_addr;
        u32 nf_cal_period;
 
-       u8 htt_max_amsdu;
-       u8 htt_max_ampdu;
-
        struct ath10k_fw_crash_data *fw_crash_data;
 };
 
@@ -440,6 +487,31 @@ enum ath10k_fw_features {
         */
        ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT = 5,
 
+       /* Some firmware revisions have an incomplete WoWLAN implementation
+        * despite WMI service bit being advertised. This feature flag is used
+        * to distinguish whether WoWLAN is really supported or not.
+        */
+       ATH10K_FW_FEATURE_WOWLAN_SUPPORT = 6,
+
+       /* Don't trust error code from otp.bin */
+       ATH10K_FW_FEATURE_IGNORE_OTP_RESULT = 7,
+
+       /* Some firmware revisions pad 4th hw address to 4 byte boundary making
+        * it 8 bytes long in Native Wifi Rx decap.
+        */
+       ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING = 8,
+
+       /* Firmware supports bypassing PLL setting on init. */
+       ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT = 9,
+
+       /* Raw mode support. If supported, FW supports receiving and trasmitting
+        * frames in raw mode.
+        */
+       ATH10K_FW_FEATURE_RAW_MODE_SUPPORT = 10,
+
+       /* Firmware Supports Adaptive CCA*/
+       ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA = 11,
+
        /* keep last */
        ATH10K_FW_FEATURE_COUNT,
 };
@@ -453,6 +525,15 @@ enum ath10k_dev_flags {
         * waiters should immediately cancel instead of waiting for a time out.
         */
        ATH10K_FLAG_CRASH_FLUSH,
+
+       /* Use Raw mode instead of native WiFi Tx/Rx encap mode.
+        * Raw mode supports both hardware and software crypto. Native WiFi only
+        * supports hardware crypto.
+        */
+       ATH10K_FLAG_RAW_MODE,
+
+       /* Disable HW crypto engine */
+       ATH10K_FLAG_HW_CRYPTO_DISABLED,
 };
 
 enum ath10k_cal_mode {
@@ -461,6 +542,13 @@ enum ath10k_cal_mode {
        ATH10K_CAL_MODE_DT,
 };
 
+enum ath10k_crypt_mode {
+       /* Only use hardware crypto engine */
+       ATH10K_CRYPT_MODE_HW,
+       /* Only use software crypto engine */
+       ATH10K_CRYPT_MODE_SW,
+};
+
 static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
 {
        switch (mode) {
@@ -498,6 +586,11 @@ static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
        return "unknown";
 }
 
+enum ath10k_tx_pause_reason {
+       ATH10K_TX_PAUSE_Q_FULL,
+       ATH10K_TX_PAUSE_MAX,
+};
+
 struct ath10k {
        struct ath_common ath_common;
        struct ieee80211_hw *hw;
@@ -505,18 +598,23 @@ struct ath10k {
        u8 mac_addr[ETH_ALEN];
 
        enum ath10k_hw_rev hw_rev;
+       u16 dev_id;
        u32 chip_id;
        u32 target_version;
        u8 fw_version_major;
        u32 fw_version_minor;
        u16 fw_version_release;
        u16 fw_version_build;
+       u32 fw_stats_req_mask;
        u32 phy_capability;
        u32 hw_min_tx_power;
        u32 hw_max_tx_power;
        u32 ht_cap_info;
        u32 vht_cap_info;
        u32 num_rf_chains;
+       u32 max_spatial_stream;
+       /* protected by conf_mutex */
+       bool ani_enabled;
 
        DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
 
@@ -530,6 +628,7 @@ struct ath10k {
        struct completion target_suspend;
 
        const struct ath10k_hw_regs *regs;
+       const struct ath10k_hw_values *hw_values;
        struct ath10k_bmi bmi;
        struct ath10k_wmi wmi;
        struct ath10k_htc htc;
@@ -537,9 +636,31 @@ struct ath10k {
 
        struct ath10k_hw_params {
                u32 id;
+               u16 dev_id;
                const char *name;
                u32 patch_load_addr;
                int uart_pin;
+               u32 otp_exe_param;
+
+               /* This is true if given HW chip has a quirky Cycle Counter
+                * wraparound which resets to 0x7fffffff instead of 0. All
+                * other CC related counters (e.g. Rx Clear Count) are divided
+                * by 2 so they never wraparound themselves.
+                */
+               bool has_shifted_cc_wraparound;
+
+               /* Some of chip expects fragment descriptor to be continuous
+                * memory for any TX operation. Set continuous_frag_desc flag
+                * for the hardware which have such requirement.
+                */
+               bool continuous_frag_desc;
+
+               u32 channel_counters_freq_hz;
+
+               /* Mgmt tx descriptors threshold for limiting probe response
+                * frames.
+                */
+               u32 max_probe_resp_desc_thres;
 
                struct ath10k_hw_params_fw {
                        const char *dir;
@@ -565,7 +686,25 @@ struct ath10k {
 
        const struct firmware *cal_file;
 
+       struct {
+               const void *firmware_codeswap_data;
+               size_t firmware_codeswap_len;
+               struct ath10k_swap_code_seg_info *firmware_swap_code_seg_info;
+       } swap;
+
+       struct {
+               u32 vendor;
+               u32 device;
+               u32 subsystem_vendor;
+               u32 subsystem_device;
+
+               bool bmi_ids_valid;
+               u8 bmi_board_id;
+               u8 bmi_chip_id;
+       } id;
+
        int fw_api;
+       int bd_api;
        enum ath10k_cal_mode cal_mode;
 
        struct {
@@ -577,6 +716,7 @@ struct ath10k {
                bool is_roc;
                int vdev_id;
                int roc_freq;
+               bool roc_notify;
        } scan;
 
        struct {
@@ -593,20 +733,19 @@ struct ath10k {
        struct cfg80211_chan_def chandef;
 
        unsigned long long free_vdev_map;
+       struct ath10k_vif *monitor_arvif;
        bool monitor;
        int monitor_vdev_id;
        bool monitor_started;
        unsigned int filter_flags;
        unsigned long dev_flags;
-       u32 dfs_block_radar_events;
+       bool dfs_block_radar_events;
 
        /* protected by conf_mutex */
        bool radar_enabled;
        int num_started_vdevs;
 
        /* Protected by conf-mutex */
-       u8 supp_tx_chainmask;
-       u8 supp_rx_chainmask;
        u8 cfg_tx_chainmask;
        u8 cfg_rx_chainmask;
 
@@ -615,6 +754,8 @@ struct ath10k {
        struct completion vdev_setup_done;
 
        struct workqueue_struct *workqueue;
+       /* Auxiliary workqueue */
+       struct workqueue_struct *workqueue_aux;
 
        /* prevents concurrent FW reconfiguration */
        struct mutex conf_mutex;
@@ -633,6 +774,12 @@ struct ath10k {
        int max_num_peers;
        int max_num_stations;
        int max_num_vdevs;
+       int max_num_tdls_vdevs;
+       int num_active_peers;
+       int num_tids;
+
+       struct work_struct svc_rdy_work;
+       struct sk_buff *svc_rdy_skb;
 
        struct work_struct offchan_tx_work;
        struct sk_buff_head offchan_tx_queue;
@@ -653,8 +800,18 @@ struct ath10k {
        u32 survey_last_cycle_count;
        struct survey_info survey[ATH10K_NUM_CHANS];
 
+       /* Channel info events are expected to come in pairs without and with
+        * COMPLETE flag set respectively for each channel visit during scan.
+        *
+        * However there are deviations from this rule. This flag is used to
+        * avoid reporting garbage data.
+        */
+       bool ch_info_can_report_survey;
+
        struct dfs_pattern_detector *dfs_detector;
 
+       unsigned long tx_paused; /* see ATH10K_TX_PAUSE_ */
+
 #ifdef CONFIG_ATH10K_DEBUGFS
        struct ath10k_debug debug;
 #endif
@@ -671,9 +828,12 @@ struct ath10k {
        struct {
                /* protected by conf_mutex */
                const struct firmware *utf;
+               char utf_version[32];
+               const void *utf_firmware_data;
+               size_t utf_firmware_len;
                DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
                enum ath10k_fw_wmi_op_version orig_wmi_op_version;
-
+               enum ath10k_fw_wmi_op_version op_version;
                /* protected by data_lock */
                bool utf_monitor;
        } testmode;
@@ -686,6 +846,7 @@ struct ath10k {
        } stats;
 
        struct ath10k_thermal thermal;
+       struct ath10k_wow wow;
 
        /* must be last */
        u8 drv_priv[0] __aligned(sizeof(void *));
@@ -696,6 +857,9 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
                                  enum ath10k_hw_rev hw_rev,
                                  const struct ath10k_hif_ops *hif_ops);
 void ath10k_core_destroy(struct ath10k *ar);
+void ath10k_core_get_fw_features_str(struct ath10k *ar,
+                                    char *buf,
+                                    size_t max_len);
 
 int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
 int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);