blob: 770b0bcc3e6900cf2bb5192018ced9e796160472 [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 Valoe07db352014-10-13 09:40:47 +030066enum ath10k_bus {
67 ATH10K_BUS_PCI,
68};
69
70static inline const char *ath10k_bus_str(enum ath10k_bus bus)
71{
72 switch (bus) {
73 case ATH10K_BUS_PCI:
74 return "pci";
75 }
76
77 return "unknown";
78}
79
Kalle Valo5e3dd152013-06-12 20:52:10 +030080struct ath10k_skb_cb {
81 dma_addr_t paddr;
Bartosz Markowski5e00d312013-09-26 17:47:12 +020082 u8 vdev_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +030083
84 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +030085 u8 tid;
86 bool is_offchan;
Michal Kaziora16942e2014-02-27 18:50:04 +020087 struct ath10k_htt_txbuf *txbuf;
88 u32 txbuf_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +030089 } __packed htt;
Michal Kazior748afc42014-01-23 12:48:21 +010090
91 struct {
92 bool dtim_zero;
93 bool deliver_cab;
94 } bcn;
Kalle Valo5e3dd152013-06-12 20:52:10 +030095} __packed;
96
97static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
98{
99 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
100 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
101 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
102}
103
Kalle Valo5e3dd152013-06-12 20:52:10 +0300104static inline u32 host_interest_item_address(u32 item_offset)
105{
106 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
107}
108
109struct ath10k_bmi {
110 bool done_sent;
111};
112
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200113struct ath10k_mem_chunk {
114 void *vaddr;
115 dma_addr_t paddr;
116 u32 len;
117 u32 req_id;
118};
119
Kalle Valo5e3dd152013-06-12 20:52:10 +0300120struct ath10k_wmi {
121 enum ath10k_htc_ep_id eid;
122 struct completion service_ready;
123 struct completion unified_ready;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200124 wait_queue_head_t tx_credits_wq;
Bartosz Markowskice428702013-09-26 17:47:05 +0200125 struct wmi_cmd_map *cmd;
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200126 struct wmi_vdev_param_map *vdev_param;
Bartosz Markowski226a3392013-09-26 17:47:16 +0200127 struct wmi_pdev_param_map *pdev_param;
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200128
129 u32 num_mem_chunks;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +0200130 struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300131};
132
Michal Kazior60ef4012014-09-25 12:33:48 +0200133struct ath10k_fw_stats_peer {
Michal Kazior53268492014-09-25 12:33:50 +0200134 struct list_head list;
135
Kalle Valo5e3dd152013-06-12 20:52:10 +0300136 u8 peer_macaddr[ETH_ALEN];
137 u32 peer_rssi;
138 u32 peer_tx_rate;
Ben Greear23c3aae2014-03-28 14:35:15 +0200139 u32 peer_rx_rate; /* 10x only */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300140};
141
Michal Kazior53268492014-09-25 12:33:50 +0200142struct ath10k_fw_stats_pdev {
143 struct list_head list;
144
Kalle Valo5e3dd152013-06-12 20:52:10 +0300145 /* PDEV stats */
146 s32 ch_noise_floor;
147 u32 tx_frame_count;
148 u32 rx_frame_count;
149 u32 rx_clear_count;
150 u32 cycle_count;
151 u32 phy_err_count;
152 u32 chan_tx_power;
Chun-Yeow Yeoh52e346d2014-03-28 14:35:16 +0200153 u32 ack_rx_bad;
154 u32 rts_bad;
155 u32 rts_good;
156 u32 fcs_bad;
157 u32 no_beacons;
158 u32 mib_int_count;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300159
160 /* PDEV TX stats */
161 s32 comp_queued;
162 s32 comp_delivered;
163 s32 msdu_enqued;
164 s32 mpdu_enqued;
165 s32 wmm_drop;
166 s32 local_enqued;
167 s32 local_freed;
168 s32 hw_queued;
169 s32 hw_reaped;
170 s32 underrun;
171 s32 tx_abort;
172 s32 mpdus_requed;
173 u32 tx_ko;
174 u32 data_rc;
175 u32 self_triggers;
176 u32 sw_retry_failure;
177 u32 illgl_rate_phy_err;
178 u32 pdev_cont_xretry;
179 u32 pdev_tx_timeout;
180 u32 pdev_resets;
181 u32 phy_underrun;
182 u32 txop_ovf;
183
184 /* PDEV RX stats */
185 s32 mid_ppdu_route_change;
186 s32 status_rcvd;
187 s32 r0_frags;
188 s32 r1_frags;
189 s32 r2_frags;
190 s32 r3_frags;
191 s32 htt_msdus;
192 s32 htt_mpdus;
193 s32 loc_msdus;
194 s32 loc_mpdus;
195 s32 oversize_amsdu;
196 s32 phy_errs;
197 s32 phy_err_drop;
198 s32 mpdu_errs;
Michal Kazior53268492014-09-25 12:33:50 +0200199};
Kalle Valo5e3dd152013-06-12 20:52:10 +0300200
Michal Kazior53268492014-09-25 12:33:50 +0200201struct ath10k_fw_stats {
202 struct list_head pdevs;
203 struct list_head peers;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300204};
205
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200206struct ath10k_dfs_stats {
207 u32 phy_errors;
208 u32 pulses_total;
209 u32 pulses_detected;
210 u32 pulses_discarded;
211 u32 radar_detected;
212};
213
Kalle Valo5e3dd152013-06-12 20:52:10 +0300214#define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
215
216struct ath10k_peer {
217 struct list_head list;
218 int vdev_id;
219 u8 addr[ETH_ALEN];
220 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
221 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
222};
223
Michal Kazior9797feb2014-02-14 14:49:48 +0100224struct ath10k_sta {
225 struct ath10k_vif *arvif;
226
227 /* the following are protected by ar->data_lock */
228 u32 changed; /* IEEE80211_RC_* */
229 u32 bw;
230 u32 nss;
231 u32 smps;
232
233 struct work_struct update_wk;
234};
235
Kalle Valo5e3dd152013-06-12 20:52:10 +0300236#define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
237
238struct ath10k_vif {
Michal Kazior05791192013-10-16 15:44:45 +0300239 struct list_head list;
240
Kalle Valo5e3dd152013-06-12 20:52:10 +0300241 u32 vdev_id;
242 enum wmi_vdev_type vdev_type;
243 enum wmi_vdev_subtype vdev_subtype;
244 u32 beacon_interval;
245 u32 dtim_period;
Michal Kaziored543882013-09-13 14:16:56 +0200246 struct sk_buff *beacon;
Michal Kazior748afc42014-01-23 12:48:21 +0100247 /* protected by data_lock */
248 bool beacon_sent;
Michal Kazior64badcb2014-09-18 11:18:02 +0300249 void *beacon_buf;
250 dma_addr_t beacon_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300251
252 struct ath10k *ar;
253 struct ieee80211_vif *vif;
254
Michal Kaziorc930f742014-01-23 11:38:25 +0100255 bool is_started;
256 bool is_up;
Simon Wunderlich855aed12014-08-02 09:12:54 +0300257 bool spectral_enabled;
Michal Kaziorc930f742014-01-23 11:38:25 +0100258 u32 aid;
259 u8 bssid[ETH_ALEN];
260
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300261 struct work_struct wep_key_work;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300262 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300263 u8 def_wep_key_idx;
264 u8 def_wep_key_newidx;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300265
266 u16 tx_seq_no;
267
268 union {
269 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +0300270 u32 uapsd;
271 } sta;
272 struct {
273 /* 127 stations; wmi limit */
274 u8 tim_bitmap[16];
275 u8 tim_len;
276 u32 ssid_len;
277 u8 ssid[IEEE80211_MAX_SSID_LEN];
278 bool hidden_ssid;
279 /* P2P_IE with NoA attribute for P2P_GO case */
280 u32 noa_len;
281 u8 *noa_data;
282 } ap;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300283 } u;
Janusz Dziedzic51ab1a02014-01-08 09:08:33 +0100284
285 u8 fixed_rate;
286 u8 fixed_nss;
Janusz Dziedzic9f81f722014-01-17 20:04:14 +0100287 u8 force_sgi;
Marek Kwaczynskie81bd102014-03-11 12:58:00 +0200288 bool use_cts_prot;
289 int num_legacy_stations;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300290};
291
292struct ath10k_vif_iter {
293 u32 vdev_id;
294 struct ath10k_vif *arvif;
295};
296
Ben Greear384914b2014-08-25 08:37:32 +0300297/* used for crash-dump storage, protected by data-lock */
298struct ath10k_fw_crash_data {
299 bool crashed_since_read;
300
301 uuid_le uuid;
302 struct timespec timestamp;
303 __le32 registers[REG_DUMP_COUNT_QCA988X];
304};
305
Kalle Valo5e3dd152013-06-12 20:52:10 +0300306struct ath10k_debug {
307 struct dentry *debugfs_phy;
308
Michal Kazior60ef4012014-09-25 12:33:48 +0200309 struct ath10k_fw_stats fw_stats;
310 struct completion fw_stats_complete;
Michal Kazior53268492014-09-25 12:33:50 +0200311 bool fw_stats_done;
Michal Kaziorc4f8c832014-09-04 10:18:32 +0200312 DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_MAX);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300313
Kalle Valoa3d135e2013-09-03 11:44:10 +0300314 unsigned long htt_stats_mask;
315 struct delayed_work htt_stats_dwork;
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200316 struct ath10k_dfs_stats dfs_stats;
317 struct ath_dfs_pool_stats dfs_pool_stats;
Kalle Valof118a3e2014-01-03 12:59:31 +0200318
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300319 /* protected by conf_mutex */
Kalle Valof118a3e2014-01-03 12:59:31 +0200320 u32 fw_dbglog_mask;
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300321 u32 pktlog_filter;
Janusz Dziedzicd3856232014-06-02 21:19:46 +0300322
323 u8 htt_max_amsdu;
324 u8 htt_max_ampdu;
Ben Greear384914b2014-08-25 08:37:32 +0300325
326 struct ath10k_fw_crash_data *fw_crash_data;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300327};
328
Michal Kaziorf7843d72013-07-16 09:38:52 +0200329enum ath10k_state {
330 ATH10K_STATE_OFF = 0,
331 ATH10K_STATE_ON,
Michal Kazioraffd3212013-07-16 09:54:35 +0200332
333 /* When doing firmware recovery the device is first powered down.
334 * mac80211 is supposed to call in to start() hook later on. It is
335 * however possible that driver unloading and firmware crash overlap.
336 * mac80211 can wait on conf_mutex in stop() while the device is
337 * stopped in ath10k_core_restart() work holding conf_mutex. The state
338 * RESTARTED means that the device is up and mac80211 has started hw
339 * reconfiguration. Once mac80211 is done with the reconfiguration we
340 * set the state to STATE_ON in restart_complete(). */
341 ATH10K_STATE_RESTARTING,
342 ATH10K_STATE_RESTARTED,
343
344 /* The device has crashed while restarting hw. This state is like ON
345 * but commands are blocked in HTC and -ECOMM response is given. This
346 * prevents completion timeouts and makes the driver more responsive to
347 * userspace commands. This is also prevents recursive recovery. */
348 ATH10K_STATE_WEDGED,
Kalle Valo43d2a302014-09-10 18:23:30 +0300349
350 /* factory tests */
351 ATH10K_STATE_UTF,
352};
353
354enum ath10k_firmware_mode {
355 /* the default mode, standard 802.11 functionality */
356 ATH10K_FIRMWARE_MODE_NORMAL,
357
358 /* factory tests etc */
359 ATH10K_FIRMWARE_MODE_UTF,
Michal Kaziorf7843d72013-07-16 09:38:52 +0200360};
361
Michal Kazior0d9b0432013-08-09 10:13:33 +0200362enum ath10k_fw_features {
363 /* wmi_mgmt_rx_hdr contains extra RSSI information */
364 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
365
Bartosz Markowskice428702013-09-26 17:47:05 +0200366 /* firmware from 10X branch */
367 ATH10K_FW_FEATURE_WMI_10X = 1,
368
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200369 /* firmware support tx frame management over WMI, otherwise it's HTT */
370 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
371
Bartosz Markowskid3541812013-12-10 16:20:40 +0100372 /* Firmware does not support P2P */
373 ATH10K_FW_FEATURE_NO_P2P = 3,
374
Michal Kazior24c88f72014-07-25 13:32:17 +0200375 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature bit
376 * is required to be set as well.
377 */
378 ATH10K_FW_FEATURE_WMI_10_2 = 4,
379
Michal Kazior0d9b0432013-08-09 10:13:33 +0200380 /* keep last */
381 ATH10K_FW_FEATURE_COUNT,
382};
383
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200384enum ath10k_dev_flags {
385 /* Indicates that ath10k device is during CAC phase of DFS */
386 ATH10K_CAC_RUNNING,
Michal Kazior6782cb62014-05-23 12:28:47 +0200387 ATH10K_FLAG_CORE_REGISTERED,
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200388};
389
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200390enum ath10k_scan_state {
391 ATH10K_SCAN_IDLE,
392 ATH10K_SCAN_STARTING,
393 ATH10K_SCAN_RUNNING,
394 ATH10K_SCAN_ABORTING,
395};
396
397static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
398{
399 switch (state) {
400 case ATH10K_SCAN_IDLE:
401 return "idle";
402 case ATH10K_SCAN_STARTING:
403 return "starting";
404 case ATH10K_SCAN_RUNNING:
405 return "running";
406 case ATH10K_SCAN_ABORTING:
407 return "aborting";
408 }
409
410 return "unknown";
411}
412
Kalle Valo5e3dd152013-06-12 20:52:10 +0300413struct ath10k {
414 struct ath_common ath_common;
415 struct ieee80211_hw *hw;
416 struct device *dev;
417 u8 mac_addr[ETH_ALEN];
418
Kalle Valoe01ae682013-09-01 11:22:14 +0300419 u32 chip_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300420 u32 target_version;
421 u8 fw_version_major;
422 u32 fw_version_minor;
423 u16 fw_version_release;
424 u16 fw_version_build;
425 u32 phy_capability;
426 u32 hw_min_tx_power;
427 u32 hw_max_tx_power;
428 u32 ht_cap_info;
429 u32 vht_cap_info;
Michal Kazior8865bee42013-07-24 12:36:46 +0200430 u32 num_rf_chains;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300431
Michal Kazior0d9b0432013-08-09 10:13:33 +0200432 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
433
Kalle Valo5e3dd152013-06-12 20:52:10 +0300434 struct targetdef *targetdef;
435 struct hostdef *hostdef;
436
437 bool p2p;
438
439 struct {
Kalle Valoe07db352014-10-13 09:40:47 +0300440 enum ath10k_bus bus;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300441 const struct ath10k_hif_ops *ops;
442 } hif;
443
Marek Puzyniak9042e172014-02-10 17:14:23 +0100444 struct completion target_suspend;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300445
446 struct ath10k_bmi bmi;
Michal Kazioredb82362013-07-05 16:15:14 +0300447 struct ath10k_wmi wmi;
Michal Kaziorcd003fa2013-07-05 16:15:13 +0300448 struct ath10k_htc htc;
Michal Kazioredb82362013-07-05 16:15:14 +0300449 struct ath10k_htt htt;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300450
451 struct ath10k_hw_params {
452 u32 id;
453 const char *name;
454 u32 patch_load_addr;
455
456 struct ath10k_hw_params_fw {
457 const char *dir;
458 const char *fw;
459 const char *otp;
460 const char *board;
461 } fw;
462 } hw_params;
463
Kalle Valo36527912013-09-27 19:54:55 +0300464 const struct firmware *board;
Kalle Valo958df3a2013-09-27 19:55:01 +0300465 const void *board_data;
466 size_t board_len;
467
Michal Kazior29385052013-07-16 09:38:58 +0200468 const struct firmware *otp;
Kalle Valo958df3a2013-09-27 19:55:01 +0300469 const void *otp_data;
470 size_t otp_len;
471
Michal Kazior29385052013-07-16 09:38:58 +0200472 const struct firmware *firmware;
Kalle Valo958df3a2013-09-27 19:55:01 +0300473 const void *firmware_data;
474 size_t firmware_len;
Michal Kazior29385052013-07-16 09:38:58 +0200475
Kalle Valo1a222432013-09-27 19:55:07 +0300476 int fw_api;
477
Kalle Valo5e3dd152013-06-12 20:52:10 +0300478 struct {
479 struct completion started;
480 struct completion completed;
481 struct completion on_channel;
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200482 struct delayed_work timeout;
483 enum ath10k_scan_state state;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300484 bool is_roc;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300485 int vdev_id;
486 int roc_freq;
487 } scan;
488
489 struct {
490 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
491 } mac;
492
493 /* should never be NULL; needed for regular htt rx */
494 struct ieee80211_channel *rx_channel;
495
496 /* valid during scan; needed for mgmt rx during scan */
497 struct ieee80211_channel *scan_channel;
498
Michal Kaziorc930f742014-01-23 11:38:25 +0100499 /* current operating channel definition */
500 struct cfg80211_chan_def chandef;
501
Ben Greear16c11172014-09-23 14:17:16 -0700502 unsigned long long free_vdev_map;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300503 bool monitor;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300504 int monitor_vdev_id;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300505 bool monitor_started;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300506 unsigned int filter_flags;
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200507 unsigned long dev_flags;
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +0200508 u32 dfs_block_radar_events;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300509
Michal Kaziord6500972014-04-08 09:56:09 +0300510 /* protected by conf_mutex */
511 bool radar_enabled;
512 int num_started_vdevs;
513
Ben Greear46acf7b2014-05-16 17:15:38 +0300514 /* Protected by conf-mutex */
515 u8 supp_tx_chainmask;
516 u8 supp_rx_chainmask;
517 u8 cfg_tx_chainmask;
518 u8 cfg_rx_chainmask;
519
Kalle Valo5e3dd152013-06-12 20:52:10 +0300520 struct wmi_pdev_set_wmm_params_arg wmm_params;
521 struct completion install_key_done;
522
523 struct completion vdev_setup_done;
524
525 struct workqueue_struct *workqueue;
526
527 /* prevents concurrent FW reconfiguration */
528 struct mutex conf_mutex;
529
530 /* protects shared structure data */
531 spinlock_t data_lock;
532
Michal Kazior05791192013-10-16 15:44:45 +0300533 struct list_head arvifs;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300534 struct list_head peers;
535 wait_queue_head_t peer_mapping_wq;
536
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100537 /* number of created peers; protected by data_lock */
538 int num_peers;
539
Kalle Valo5e3dd152013-06-12 20:52:10 +0300540 struct work_struct offchan_tx_work;
541 struct sk_buff_head offchan_tx_queue;
542 struct completion offchan_tx_completed;
543 struct sk_buff *offchan_tx_skb;
544
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200545 struct work_struct wmi_mgmt_tx_work;
546 struct sk_buff_head wmi_mgmt_tx_queue;
547
Michal Kaziorf7843d72013-07-16 09:38:52 +0200548 enum ath10k_state state;
549
Michal Kazior6782cb62014-05-23 12:28:47 +0200550 struct work_struct register_work;
Michal Kazioraffd3212013-07-16 09:54:35 +0200551 struct work_struct restart_work;
552
Michal Kazior2e1dea42013-07-31 10:32:40 +0200553 /* cycle count is reported twice for each visited channel during scan.
554 * access protected by data_lock */
555 u32 survey_last_rx_clear_count;
556 u32 survey_last_cycle_count;
557 struct survey_info survey[ATH10K_NUM_CHANS];
558
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200559 struct dfs_pattern_detector *dfs_detector;
560
Kalle Valo5e3dd152013-06-12 20:52:10 +0300561#ifdef CONFIG_ATH10K_DEBUGFS
562 struct ath10k_debug debug;
563#endif
Simon Wunderlich855aed12014-08-02 09:12:54 +0300564
565 struct {
566 /* relay(fs) channel for spectral scan */
567 struct rchan *rfs_chan_spec_scan;
568
569 /* spectral_mode and spec_config are protected by conf_mutex */
570 enum ath10k_spectral_mode mode;
571 struct ath10k_spec_scan config;
572 } spectral;
Michal Kaziore7b54192014-08-07 11:03:27 +0200573
Kalle Valo43d2a302014-09-10 18:23:30 +0300574 struct {
575 /* protected by conf_mutex */
576 const struct firmware *utf;
577 DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
578
579 /* protected by data_lock */
580 bool utf_monitor;
581 } testmode;
582
Ben Greearf51dbe72014-09-29 14:41:46 +0300583 struct {
584 /* protected by data_lock */
585 u32 fw_crash_counter;
586 u32 fw_warm_reset_counter;
587 u32 fw_cold_reset_counter;
588 } stats;
589
Michal Kaziore7b54192014-08-07 11:03:27 +0200590 /* must be last */
591 u8 drv_priv[0] __aligned(sizeof(void *));
Kalle Valo5e3dd152013-06-12 20:52:10 +0300592};
593
Michal Kaziore7b54192014-08-07 11:03:27 +0200594struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
Kalle Valoe07db352014-10-13 09:40:47 +0300595 enum ath10k_bus bus,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300596 const struct ath10k_hif_ops *hif_ops);
597void ath10k_core_destroy(struct ath10k *ar);
598
Kalle Valo43d2a302014-09-10 18:23:30 +0300599int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
Marek Puzyniak00f54822014-02-10 17:14:24 +0100600int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
Michal Kaziordd30a362013-07-16 09:38:51 +0200601void ath10k_core_stop(struct ath10k *ar);
Kalle Valoe01ae682013-09-01 11:22:14 +0300602int ath10k_core_register(struct ath10k *ar, u32 chip_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300603void ath10k_core_unregister(struct ath10k *ar);
604
Kalle Valo5e3dd152013-06-12 20:52:10 +0300605#endif /* _CORE_H_ */