ath10k: clean up num_peers locking
[cascardo/linux.git] / drivers / net / wireless / ath / ath10k / core.h
index fe531ea..0a01821 100644 (file)
 
 struct ath10k;
 
+enum ath10k_bus {
+       ATH10K_BUS_PCI,
+};
+
+static inline const char *ath10k_bus_str(enum ath10k_bus bus)
+{
+       switch (bus) {
+       case ATH10K_BUS_PCI:
+               return "pci";
+       }
+
+       return "unknown";
+}
+
 struct ath10k_skb_cb {
        dma_addr_t paddr;
        u8 vdev_id;
 
        struct {
                u8 tid;
+               u16 freq;
                bool is_offchan;
                struct ath10k_htt_txbuf *txbuf;
                u32 txbuf_paddr;
@@ -96,8 +111,6 @@ struct ath10k_bmi {
        bool done_sent;
 };
 
-#define ATH10K_MAX_MEM_REQS 16
-
 struct ath10k_mem_chunk {
        void *vaddr;
        dma_addr_t paddr;
@@ -115,17 +128,21 @@ struct ath10k_wmi {
        struct wmi_pdev_param_map *pdev_param;
 
        u32 num_mem_chunks;
-       struct ath10k_mem_chunk mem_chunks[ATH10K_MAX_MEM_REQS];
+       struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
 };
 
-struct ath10k_peer_stat {
+struct ath10k_fw_stats_peer {
+       struct list_head list;
+
        u8 peer_macaddr[ETH_ALEN];
        u32 peer_rssi;
        u32 peer_tx_rate;
        u32 peer_rx_rate; /* 10x only */
 };
 
-struct ath10k_target_stats {
+struct ath10k_fw_stats_pdev {
+       struct list_head list;
+
        /* PDEV stats */
        s32 ch_noise_floor;
        u32 tx_frame_count;
@@ -180,15 +197,11 @@ struct ath10k_target_stats {
        s32 phy_errs;
        s32 phy_err_drop;
        s32 mpdu_errs;
+};
 
-       /* VDEV STATS */
-
-       /* PEER STATS */
-       u8 peers;
-       struct ath10k_peer_stat peer_stat[TARGET_NUM_PEERS];
-
-       /* TODO: Beacon filter stats */
-
+struct ath10k_fw_stats {
+       struct list_head pdevs;
+       struct list_head peers;
 };
 
 struct ath10k_dfs_stats {
@@ -206,6 +219,8 @@ struct ath10k_peer {
        int vdev_id;
        u8 addr[ETH_ALEN];
        DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
+
+       /* protected by ar->data_lock */
        struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
 };
 
@@ -234,6 +249,8 @@ struct ath10k_vif {
        struct sk_buff *beacon;
        /* protected by data_lock */
        bool beacon_sent;
+       void *beacon_buf;
+       dma_addr_t beacon_paddr;
 
        struct ath10k *ar;
        struct ieee80211_vif *vif;
@@ -273,6 +290,7 @@ struct ath10k_vif {
        u8 force_sgi;
        bool use_cts_prot;
        int num_legacy_stations;
+       int txpower;
 };
 
 struct ath10k_vif_iter {
@@ -292,17 +310,20 @@ struct ath10k_fw_crash_data {
 struct ath10k_debug {
        struct dentry *debugfs_phy;
 
-       struct ath10k_target_stats target_stats;
+       struct ath10k_fw_stats fw_stats;
+       struct completion fw_stats_complete;
+       bool fw_stats_done;
        DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_MAX);
 
-       struct completion event_stats_compl;
-
        unsigned long htt_stats_mask;
        struct delayed_work htt_stats_dwork;
        struct ath10k_dfs_stats dfs_stats;
        struct ath_dfs_pool_stats dfs_pool_stats;
 
+       /* protected by conf_mutex */
        u32 fw_dbglog_mask;
+       u32 pktlog_filter;
+       u32 reg_addr;
 
        u8 htt_max_amsdu;
        u8 htt_max_ampdu;
@@ -321,7 +342,7 @@ enum ath10k_state {
         * stopped in ath10k_core_restart() work holding conf_mutex. The state
         * RESTARTED means that the device is up and mac80211 has started hw
         * reconfiguration. Once mac80211 is done with the reconfiguration we
-        * set the state to STATE_ON in restart_complete(). */
+        * set the state to STATE_ON in reconfig_complete(). */
        ATH10K_STATE_RESTARTING,
        ATH10K_STATE_RESTARTED,
 
@@ -369,8 +390,30 @@ enum ath10k_dev_flags {
        /* Indicates that ath10k device is during CAC phase of DFS */
        ATH10K_CAC_RUNNING,
        ATH10K_FLAG_CORE_REGISTERED,
+
+       /* Device has crashed and needs to restart. This indicates any pending
+        * waiters should immediately cancel instead of waiting for a time out.
+        */
+       ATH10K_FLAG_CRASH_FLUSH,
 };
 
+enum ath10k_cal_mode {
+       ATH10K_CAL_MODE_FILE,
+       ATH10K_CAL_MODE_OTP,
+};
+
+static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
+{
+       switch (mode) {
+       case ATH10K_CAL_MODE_FILE:
+               return "file";
+       case ATH10K_CAL_MODE_OTP:
+               return "otp";
+       }
+
+       return "unknown";
+}
+
 enum ath10k_scan_state {
        ATH10K_SCAN_IDLE,
        ATH10K_SCAN_STARTING,
@@ -421,6 +464,7 @@ struct ath10k {
        bool p2p;
 
        struct {
+               enum ath10k_bus bus;
                const struct ath10k_hif_ops *ops;
        } hif;
 
@@ -456,7 +500,10 @@ struct ath10k {
        const void *firmware_data;
        size_t firmware_len;
 
+       const struct firmware *cal_file;
+
        int fw_api;
+       enum ath10k_cal_mode cal_mode;
 
        struct {
                struct completion started;
@@ -482,7 +529,7 @@ struct ath10k {
        /* current operating channel definition */
        struct cfg80211_chan_def chandef;
 
-       int free_vdev_map;
+       unsigned long long free_vdev_map;
        bool monitor;
        int monitor_vdev_id;
        bool monitor_started;
@@ -517,7 +564,7 @@ struct ath10k {
        struct list_head peers;
        wait_queue_head_t peer_mapping_wq;
 
-       /* number of created peers; protected by data_lock */
+       /* protected by conf_mutex */
        int num_peers;
 
        struct work_struct offchan_tx_work;
@@ -563,11 +610,19 @@ struct ath10k {
                bool utf_monitor;
        } testmode;
 
+       struct {
+               /* protected by data_lock */
+               u32 fw_crash_counter;
+               u32 fw_warm_reset_counter;
+               u32 fw_cold_reset_counter;
+       } stats;
+
        /* must be last */
        u8 drv_priv[0] __aligned(sizeof(void *));
 };
 
 struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
+                                 enum ath10k_bus bus,
                                  const struct ath10k_hif_ops *hif_ops);
 void ath10k_core_destroy(struct ath10k *ar);