blob: d1ea936d14b7cec3109244b1a0288465dc376ad3 [file] [log] [blame]
Kalle Valo5e3dd152013-06-12 20:52:10 +03001/*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _CORE_H_
19#define _CORE_H_
20
21#include <linux/completion.h>
22#include <linux/if_ether.h>
23#include <linux/types.h>
24#include <linux/pci.h>
Ben Greear384914b2014-08-25 08:37:32 +030025#include <linux/uuid.h>
26#include <linux/time.h>
Kalle Valo5e3dd152013-06-12 20:52:10 +030027
Michal Kazioredb82362013-07-05 16:15:14 +030028#include "htt.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030029#include "htc.h"
30#include "hw.h"
31#include "targaddrs.h"
32#include "wmi.h"
33#include "../ath.h"
34#include "../regd.h"
Janusz Dziedzic9702c682013-11-20 09:59:41 +020035#include "../dfs_pattern_detector.h"
Simon Wunderlich855aed12014-08-02 09:12:54 +030036#include "spectral.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030037
38#define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
39#define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
40#define WO(_f) ((_f##_OFFSET) >> 2)
41
42#define ATH10K_SCAN_ID 0
43#define WMI_READY_TIMEOUT (5 * HZ)
44#define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)
Michal Kazior2e1dea42013-07-31 10:32:40 +020045#define ATH10K_NUM_CHANS 38
Kalle Valo5e3dd152013-06-12 20:52:10 +030046
47/* Antenna noise floor */
48#define ATH10K_DEFAULT_NOISE_FLOOR -95
49
Bartosz Markowski71098612013-11-14 09:01:15 +010050#define ATH10K_MAX_NUM_MGMT_PENDING 128
Bartosz Markowski5e00d312013-09-26 17:47:12 +020051
Kalle Valo5a13e762014-01-20 11:01:46 +020052/* number of failed packets */
53#define ATH10K_KICKOUT_THRESHOLD 50
54
55/*
56 * Use insanely high numbers to make sure that the firmware implementation
57 * won't start, we have the same functionality already in hostapd. Unit
58 * is seconds.
59 */
60#define ATH10K_KEEPALIVE_MIN_IDLE 3747
61#define ATH10K_KEEPALIVE_MAX_IDLE 3895
62#define ATH10K_KEEPALIVE_MAX_UNRESPONSIVE 3900
63
Kalle Valo5e3dd152013-06-12 20:52:10 +030064struct ath10k;
65
Kalle Valo5e3dd152013-06-12 20:52:10 +030066struct ath10k_skb_cb {
67 dma_addr_t paddr;
Bartosz Markowski5e00d312013-09-26 17:47:12 +020068 u8 vdev_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +030069
70 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +030071 u8 tid;
72 bool is_offchan;
Michal Kaziora16942e2014-02-27 18:50:04 +020073 struct ath10k_htt_txbuf *txbuf;
74 u32 txbuf_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +030075 } __packed htt;
Michal Kazior748afc42014-01-23 12:48:21 +010076
77 struct {
78 bool dtim_zero;
79 bool deliver_cab;
80 } bcn;
Kalle Valo5e3dd152013-06-12 20:52:10 +030081} __packed;
82
83static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
84{
85 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
86 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
87 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
88}
89
Kalle Valo5e3dd152013-06-12 20:52:10 +030090static inline u32 host_interest_item_address(u32 item_offset)
91{
92 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
93}
94
95struct ath10k_bmi {
96 bool done_sent;
97};
98
Bartosz Markowskib3effe62013-09-26 17:47:11 +020099#define ATH10K_MAX_MEM_REQS 16
100
101struct ath10k_mem_chunk {
102 void *vaddr;
103 dma_addr_t paddr;
104 u32 len;
105 u32 req_id;
106};
107
Kalle Valo5e3dd152013-06-12 20:52:10 +0300108struct ath10k_wmi {
109 enum ath10k_htc_ep_id eid;
110 struct completion service_ready;
111 struct completion unified_ready;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200112 wait_queue_head_t tx_credits_wq;
Bartosz Markowskice428702013-09-26 17:47:05 +0200113 struct wmi_cmd_map *cmd;
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200114 struct wmi_vdev_param_map *vdev_param;
Bartosz Markowski226a3392013-09-26 17:47:16 +0200115 struct wmi_pdev_param_map *pdev_param;
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200116
117 u32 num_mem_chunks;
118 struct ath10k_mem_chunk mem_chunks[ATH10K_MAX_MEM_REQS];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300119};
120
121struct ath10k_peer_stat {
122 u8 peer_macaddr[ETH_ALEN];
123 u32 peer_rssi;
124 u32 peer_tx_rate;
Ben Greear23c3aae2014-03-28 14:35:15 +0200125 u32 peer_rx_rate; /* 10x only */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300126};
127
128struct ath10k_target_stats {
129 /* PDEV stats */
130 s32 ch_noise_floor;
131 u32 tx_frame_count;
132 u32 rx_frame_count;
133 u32 rx_clear_count;
134 u32 cycle_count;
135 u32 phy_err_count;
136 u32 chan_tx_power;
Chun-Yeow Yeoh52e346d2014-03-28 14:35:16 +0200137 u32 ack_rx_bad;
138 u32 rts_bad;
139 u32 rts_good;
140 u32 fcs_bad;
141 u32 no_beacons;
142 u32 mib_int_count;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300143
144 /* PDEV TX stats */
145 s32 comp_queued;
146 s32 comp_delivered;
147 s32 msdu_enqued;
148 s32 mpdu_enqued;
149 s32 wmm_drop;
150 s32 local_enqued;
151 s32 local_freed;
152 s32 hw_queued;
153 s32 hw_reaped;
154 s32 underrun;
155 s32 tx_abort;
156 s32 mpdus_requed;
157 u32 tx_ko;
158 u32 data_rc;
159 u32 self_triggers;
160 u32 sw_retry_failure;
161 u32 illgl_rate_phy_err;
162 u32 pdev_cont_xretry;
163 u32 pdev_tx_timeout;
164 u32 pdev_resets;
165 u32 phy_underrun;
166 u32 txop_ovf;
167
168 /* PDEV RX stats */
169 s32 mid_ppdu_route_change;
170 s32 status_rcvd;
171 s32 r0_frags;
172 s32 r1_frags;
173 s32 r2_frags;
174 s32 r3_frags;
175 s32 htt_msdus;
176 s32 htt_mpdus;
177 s32 loc_msdus;
178 s32 loc_mpdus;
179 s32 oversize_amsdu;
180 s32 phy_errs;
181 s32 phy_err_drop;
182 s32 mpdu_errs;
183
184 /* VDEV STATS */
185
186 /* PEER STATS */
187 u8 peers;
188 struct ath10k_peer_stat peer_stat[TARGET_NUM_PEERS];
189
190 /* TODO: Beacon filter stats */
191
192};
193
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200194struct ath10k_dfs_stats {
195 u32 phy_errors;
196 u32 pulses_total;
197 u32 pulses_detected;
198 u32 pulses_discarded;
199 u32 radar_detected;
200};
201
Kalle Valo5e3dd152013-06-12 20:52:10 +0300202#define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
203
204struct ath10k_peer {
205 struct list_head list;
206 int vdev_id;
207 u8 addr[ETH_ALEN];
208 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
209 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
210};
211
Michal Kazior9797feb2014-02-14 14:49:48 +0100212struct ath10k_sta {
213 struct ath10k_vif *arvif;
214
215 /* the following are protected by ar->data_lock */
216 u32 changed; /* IEEE80211_RC_* */
217 u32 bw;
218 u32 nss;
219 u32 smps;
220
221 struct work_struct update_wk;
222};
223
Kalle Valo5e3dd152013-06-12 20:52:10 +0300224#define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
225
226struct ath10k_vif {
Michal Kazior05791192013-10-16 15:44:45 +0300227 struct list_head list;
228
Kalle Valo5e3dd152013-06-12 20:52:10 +0300229 u32 vdev_id;
230 enum wmi_vdev_type vdev_type;
231 enum wmi_vdev_subtype vdev_subtype;
232 u32 beacon_interval;
233 u32 dtim_period;
Michal Kaziored543882013-09-13 14:16:56 +0200234 struct sk_buff *beacon;
Michal Kazior748afc42014-01-23 12:48:21 +0100235 /* protected by data_lock */
236 bool beacon_sent;
Michal Kazior64badcb2014-09-18 11:18:02 +0300237 void *beacon_buf;
238 dma_addr_t beacon_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300239
240 struct ath10k *ar;
241 struct ieee80211_vif *vif;
242
Michal Kaziorc930f742014-01-23 11:38:25 +0100243 bool is_started;
244 bool is_up;
Simon Wunderlich855aed12014-08-02 09:12:54 +0300245 bool spectral_enabled;
Michal Kaziorc930f742014-01-23 11:38:25 +0100246 u32 aid;
247 u8 bssid[ETH_ALEN];
248
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300249 struct work_struct wep_key_work;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300250 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300251 u8 def_wep_key_idx;
252 u8 def_wep_key_newidx;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300253
254 u16 tx_seq_no;
255
256 union {
257 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +0300258 u32 uapsd;
259 } sta;
260 struct {
261 /* 127 stations; wmi limit */
262 u8 tim_bitmap[16];
263 u8 tim_len;
264 u32 ssid_len;
265 u8 ssid[IEEE80211_MAX_SSID_LEN];
266 bool hidden_ssid;
267 /* P2P_IE with NoA attribute for P2P_GO case */
268 u32 noa_len;
269 u8 *noa_data;
270 } ap;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300271 } u;
Janusz Dziedzic51ab1a02014-01-08 09:08:33 +0100272
273 u8 fixed_rate;
274 u8 fixed_nss;
Janusz Dziedzic9f81f722014-01-17 20:04:14 +0100275 u8 force_sgi;
Marek Kwaczynskie81bd102014-03-11 12:58:00 +0200276 bool use_cts_prot;
277 int num_legacy_stations;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300278};
279
280struct ath10k_vif_iter {
281 u32 vdev_id;
282 struct ath10k_vif *arvif;
283};
284
Ben Greear384914b2014-08-25 08:37:32 +0300285/* used for crash-dump storage, protected by data-lock */
286struct ath10k_fw_crash_data {
287 bool crashed_since_read;
288
289 uuid_le uuid;
290 struct timespec timestamp;
291 __le32 registers[REG_DUMP_COUNT_QCA988X];
292};
293
Kalle Valo5e3dd152013-06-12 20:52:10 +0300294struct ath10k_debug {
295 struct dentry *debugfs_phy;
296
297 struct ath10k_target_stats target_stats;
Michal Kaziorc4f8c832014-09-04 10:18:32 +0200298 DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_MAX);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300299
300 struct completion event_stats_compl;
Kalle Valoa3d135e2013-09-03 11:44:10 +0300301
302 unsigned long htt_stats_mask;
303 struct delayed_work htt_stats_dwork;
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200304 struct ath10k_dfs_stats dfs_stats;
305 struct ath_dfs_pool_stats dfs_pool_stats;
Kalle Valof118a3e2014-01-03 12:59:31 +0200306
307 u32 fw_dbglog_mask;
Janusz Dziedzicd3856232014-06-02 21:19:46 +0300308
309 u8 htt_max_amsdu;
310 u8 htt_max_ampdu;
Ben Greear384914b2014-08-25 08:37:32 +0300311
312 struct ath10k_fw_crash_data *fw_crash_data;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300313};
314
Michal Kaziorf7843d72013-07-16 09:38:52 +0200315enum ath10k_state {
316 ATH10K_STATE_OFF = 0,
317 ATH10K_STATE_ON,
Michal Kazioraffd3212013-07-16 09:54:35 +0200318
319 /* When doing firmware recovery the device is first powered down.
320 * mac80211 is supposed to call in to start() hook later on. It is
321 * however possible that driver unloading and firmware crash overlap.
322 * mac80211 can wait on conf_mutex in stop() while the device is
323 * stopped in ath10k_core_restart() work holding conf_mutex. The state
324 * RESTARTED means that the device is up and mac80211 has started hw
325 * reconfiguration. Once mac80211 is done with the reconfiguration we
326 * set the state to STATE_ON in restart_complete(). */
327 ATH10K_STATE_RESTARTING,
328 ATH10K_STATE_RESTARTED,
329
330 /* The device has crashed while restarting hw. This state is like ON
331 * but commands are blocked in HTC and -ECOMM response is given. This
332 * prevents completion timeouts and makes the driver more responsive to
333 * userspace commands. This is also prevents recursive recovery. */
334 ATH10K_STATE_WEDGED,
Kalle Valo43d2a302014-09-10 18:23:30 +0300335
336 /* factory tests */
337 ATH10K_STATE_UTF,
338};
339
340enum ath10k_firmware_mode {
341 /* the default mode, standard 802.11 functionality */
342 ATH10K_FIRMWARE_MODE_NORMAL,
343
344 /* factory tests etc */
345 ATH10K_FIRMWARE_MODE_UTF,
Michal Kaziorf7843d72013-07-16 09:38:52 +0200346};
347
Michal Kazior0d9b0432013-08-09 10:13:33 +0200348enum ath10k_fw_features {
349 /* wmi_mgmt_rx_hdr contains extra RSSI information */
350 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
351
Bartosz Markowskice428702013-09-26 17:47:05 +0200352 /* firmware from 10X branch */
353 ATH10K_FW_FEATURE_WMI_10X = 1,
354
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200355 /* firmware support tx frame management over WMI, otherwise it's HTT */
356 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
357
Bartosz Markowskid3541812013-12-10 16:20:40 +0100358 /* Firmware does not support P2P */
359 ATH10K_FW_FEATURE_NO_P2P = 3,
360
Michal Kazior24c88f72014-07-25 13:32:17 +0200361 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature bit
362 * is required to be set as well.
363 */
364 ATH10K_FW_FEATURE_WMI_10_2 = 4,
365
Michal Kazior0d9b0432013-08-09 10:13:33 +0200366 /* keep last */
367 ATH10K_FW_FEATURE_COUNT,
368};
369
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200370enum ath10k_dev_flags {
371 /* Indicates that ath10k device is during CAC phase of DFS */
372 ATH10K_CAC_RUNNING,
Michal Kazior6782cb62014-05-23 12:28:47 +0200373 ATH10K_FLAG_CORE_REGISTERED,
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200374};
375
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200376enum ath10k_scan_state {
377 ATH10K_SCAN_IDLE,
378 ATH10K_SCAN_STARTING,
379 ATH10K_SCAN_RUNNING,
380 ATH10K_SCAN_ABORTING,
381};
382
383static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
384{
385 switch (state) {
386 case ATH10K_SCAN_IDLE:
387 return "idle";
388 case ATH10K_SCAN_STARTING:
389 return "starting";
390 case ATH10K_SCAN_RUNNING:
391 return "running";
392 case ATH10K_SCAN_ABORTING:
393 return "aborting";
394 }
395
396 return "unknown";
397}
398
Kalle Valo5e3dd152013-06-12 20:52:10 +0300399struct ath10k {
400 struct ath_common ath_common;
401 struct ieee80211_hw *hw;
402 struct device *dev;
403 u8 mac_addr[ETH_ALEN];
404
Kalle Valoe01ae682013-09-01 11:22:14 +0300405 u32 chip_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300406 u32 target_version;
407 u8 fw_version_major;
408 u32 fw_version_minor;
409 u16 fw_version_release;
410 u16 fw_version_build;
411 u32 phy_capability;
412 u32 hw_min_tx_power;
413 u32 hw_max_tx_power;
414 u32 ht_cap_info;
415 u32 vht_cap_info;
Michal Kazior8865bee42013-07-24 12:36:46 +0200416 u32 num_rf_chains;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300417
Michal Kazior0d9b0432013-08-09 10:13:33 +0200418 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
419
Kalle Valo5e3dd152013-06-12 20:52:10 +0300420 struct targetdef *targetdef;
421 struct hostdef *hostdef;
422
423 bool p2p;
424
425 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +0300426 const struct ath10k_hif_ops *ops;
427 } hif;
428
Marek Puzyniak9042e172014-02-10 17:14:23 +0100429 struct completion target_suspend;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300430
431 struct ath10k_bmi bmi;
Michal Kazioredb82362013-07-05 16:15:14 +0300432 struct ath10k_wmi wmi;
Michal Kaziorcd003fa2013-07-05 16:15:13 +0300433 struct ath10k_htc htc;
Michal Kazioredb82362013-07-05 16:15:14 +0300434 struct ath10k_htt htt;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300435
436 struct ath10k_hw_params {
437 u32 id;
438 const char *name;
439 u32 patch_load_addr;
440
441 struct ath10k_hw_params_fw {
442 const char *dir;
443 const char *fw;
444 const char *otp;
445 const char *board;
446 } fw;
447 } hw_params;
448
Kalle Valo36527912013-09-27 19:54:55 +0300449 const struct firmware *board;
Kalle Valo958df3a2013-09-27 19:55:01 +0300450 const void *board_data;
451 size_t board_len;
452
Michal Kazior29385052013-07-16 09:38:58 +0200453 const struct firmware *otp;
Kalle Valo958df3a2013-09-27 19:55:01 +0300454 const void *otp_data;
455 size_t otp_len;
456
Michal Kazior29385052013-07-16 09:38:58 +0200457 const struct firmware *firmware;
Kalle Valo958df3a2013-09-27 19:55:01 +0300458 const void *firmware_data;
459 size_t firmware_len;
Michal Kazior29385052013-07-16 09:38:58 +0200460
Kalle Valo1a222432013-09-27 19:55:07 +0300461 int fw_api;
462
Kalle Valo5e3dd152013-06-12 20:52:10 +0300463 struct {
464 struct completion started;
465 struct completion completed;
466 struct completion on_channel;
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200467 struct delayed_work timeout;
468 enum ath10k_scan_state state;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300469 bool is_roc;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300470 int vdev_id;
471 int roc_freq;
472 } scan;
473
474 struct {
475 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
476 } mac;
477
478 /* should never be NULL; needed for regular htt rx */
479 struct ieee80211_channel *rx_channel;
480
481 /* valid during scan; needed for mgmt rx during scan */
482 struct ieee80211_channel *scan_channel;
483
Michal Kaziorc930f742014-01-23 11:38:25 +0100484 /* current operating channel definition */
485 struct cfg80211_chan_def chandef;
486
Kalle Valo5e3dd152013-06-12 20:52:10 +0300487 int free_vdev_map;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300488 bool monitor;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300489 int monitor_vdev_id;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300490 bool monitor_started;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300491 unsigned int filter_flags;
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200492 unsigned long dev_flags;
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +0200493 u32 dfs_block_radar_events;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300494
Michal Kaziord6500972014-04-08 09:56:09 +0300495 /* protected by conf_mutex */
496 bool radar_enabled;
497 int num_started_vdevs;
498
Ben Greear46acf7b2014-05-16 17:15:38 +0300499 /* Protected by conf-mutex */
500 u8 supp_tx_chainmask;
501 u8 supp_rx_chainmask;
502 u8 cfg_tx_chainmask;
503 u8 cfg_rx_chainmask;
504
Kalle Valo5e3dd152013-06-12 20:52:10 +0300505 struct wmi_pdev_set_wmm_params_arg wmm_params;
506 struct completion install_key_done;
507
508 struct completion vdev_setup_done;
509
510 struct workqueue_struct *workqueue;
511
512 /* prevents concurrent FW reconfiguration */
513 struct mutex conf_mutex;
514
515 /* protects shared structure data */
516 spinlock_t data_lock;
517
Michal Kazior05791192013-10-16 15:44:45 +0300518 struct list_head arvifs;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300519 struct list_head peers;
520 wait_queue_head_t peer_mapping_wq;
521
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100522 /* number of created peers; protected by data_lock */
523 int num_peers;
524
Kalle Valo5e3dd152013-06-12 20:52:10 +0300525 struct work_struct offchan_tx_work;
526 struct sk_buff_head offchan_tx_queue;
527 struct completion offchan_tx_completed;
528 struct sk_buff *offchan_tx_skb;
529
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200530 struct work_struct wmi_mgmt_tx_work;
531 struct sk_buff_head wmi_mgmt_tx_queue;
532
Michal Kaziorf7843d72013-07-16 09:38:52 +0200533 enum ath10k_state state;
534
Michal Kazior6782cb62014-05-23 12:28:47 +0200535 struct work_struct register_work;
Michal Kazioraffd3212013-07-16 09:54:35 +0200536 struct work_struct restart_work;
537
Michal Kazior2e1dea42013-07-31 10:32:40 +0200538 /* cycle count is reported twice for each visited channel during scan.
539 * access protected by data_lock */
540 u32 survey_last_rx_clear_count;
541 u32 survey_last_cycle_count;
542 struct survey_info survey[ATH10K_NUM_CHANS];
543
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200544 struct dfs_pattern_detector *dfs_detector;
545
Kalle Valo5e3dd152013-06-12 20:52:10 +0300546#ifdef CONFIG_ATH10K_DEBUGFS
547 struct ath10k_debug debug;
548#endif
Simon Wunderlich855aed12014-08-02 09:12:54 +0300549
550 struct {
551 /* relay(fs) channel for spectral scan */
552 struct rchan *rfs_chan_spec_scan;
553
554 /* spectral_mode and spec_config are protected by conf_mutex */
555 enum ath10k_spectral_mode mode;
556 struct ath10k_spec_scan config;
557 } spectral;
Michal Kaziore7b54192014-08-07 11:03:27 +0200558
Kalle Valo43d2a302014-09-10 18:23:30 +0300559 struct {
560 /* protected by conf_mutex */
561 const struct firmware *utf;
562 DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
563
564 /* protected by data_lock */
565 bool utf_monitor;
566 } testmode;
567
Michal Kaziore7b54192014-08-07 11:03:27 +0200568 /* must be last */
569 u8 drv_priv[0] __aligned(sizeof(void *));
Kalle Valo5e3dd152013-06-12 20:52:10 +0300570};
571
Michal Kaziore7b54192014-08-07 11:03:27 +0200572struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300573 const struct ath10k_hif_ops *hif_ops);
574void ath10k_core_destroy(struct ath10k *ar);
575
Kalle Valo43d2a302014-09-10 18:23:30 +0300576int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
Marek Puzyniak00f54822014-02-10 17:14:24 +0100577int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
Michal Kaziordd30a362013-07-16 09:38:51 +0200578void ath10k_core_stop(struct ath10k *ar);
Kalle Valoe01ae682013-09-01 11:22:14 +0300579int ath10k_core_register(struct ath10k *ar, u32 chip_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300580void ath10k_core_unregister(struct ath10k *ar);
581
Kalle Valo5e3dd152013-06-12 20:52:10 +0300582#endif /* _CORE_H_ */