blob: 3998f1e33874d6abc8ce95d6a267feab3607a0b9 [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;
Michal Kaziord84a5122014-11-27 11:09:37 +010082 u8 eid;
Bartosz Markowski5e00d312013-09-26 17:47:12 +020083 u8 vdev_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +030084
85 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +030086 u8 tid;
Michal Kazior8d6d3622014-11-24 14:58:31 +010087 u16 freq;
Kalle Valo5e3dd152013-06-12 20:52:10 +030088 bool is_offchan;
Michal Kaziora16942e2014-02-27 18:50:04 +020089 struct ath10k_htt_txbuf *txbuf;
90 u32 txbuf_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +030091 } __packed htt;
Michal Kazior748afc42014-01-23 12:48:21 +010092
93 struct {
94 bool dtim_zero;
95 bool deliver_cab;
96 } bcn;
Kalle Valo5e3dd152013-06-12 20:52:10 +030097} __packed;
98
99static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
100{
101 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
102 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
103 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
104}
105
Kalle Valo5e3dd152013-06-12 20:52:10 +0300106static inline u32 host_interest_item_address(u32 item_offset)
107{
108 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
109}
110
111struct ath10k_bmi {
112 bool done_sent;
113};
114
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200115struct ath10k_mem_chunk {
116 void *vaddr;
117 dma_addr_t paddr;
118 u32 len;
119 u32 req_id;
120};
121
Kalle Valo5e3dd152013-06-12 20:52:10 +0300122struct ath10k_wmi {
Kalle Valo202e86e2014-12-03 10:10:08 +0200123 enum ath10k_fw_wmi_op_version op_version;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300124 enum ath10k_htc_ep_id eid;
125 struct completion service_ready;
126 struct completion unified_ready;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200127 wait_queue_head_t tx_credits_wq;
Michal Kazioracfe7ec2014-11-27 10:11:17 +0100128 DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX);
Bartosz Markowskice428702013-09-26 17:47:05 +0200129 struct wmi_cmd_map *cmd;
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200130 struct wmi_vdev_param_map *vdev_param;
Bartosz Markowski226a3392013-09-26 17:47:16 +0200131 struct wmi_pdev_param_map *pdev_param;
Michal Kaziord7579d12014-12-03 10:10:54 +0200132 const struct wmi_ops *ops;
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200133
134 u32 num_mem_chunks;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +0200135 struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300136};
137
Michal Kazior60ef4012014-09-25 12:33:48 +0200138struct ath10k_fw_stats_peer {
Michal Kazior53268492014-09-25 12:33:50 +0200139 struct list_head list;
140
Kalle Valo5e3dd152013-06-12 20:52:10 +0300141 u8 peer_macaddr[ETH_ALEN];
142 u32 peer_rssi;
143 u32 peer_tx_rate;
Ben Greear23c3aae2014-03-28 14:35:15 +0200144 u32 peer_rx_rate; /* 10x only */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300145};
146
Michal Kazior53268492014-09-25 12:33:50 +0200147struct ath10k_fw_stats_pdev {
148 struct list_head list;
149
Kalle Valo5e3dd152013-06-12 20:52:10 +0300150 /* PDEV stats */
151 s32 ch_noise_floor;
152 u32 tx_frame_count;
153 u32 rx_frame_count;
154 u32 rx_clear_count;
155 u32 cycle_count;
156 u32 phy_err_count;
157 u32 chan_tx_power;
Chun-Yeow Yeoh52e346d2014-03-28 14:35:16 +0200158 u32 ack_rx_bad;
159 u32 rts_bad;
160 u32 rts_good;
161 u32 fcs_bad;
162 u32 no_beacons;
163 u32 mib_int_count;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300164
165 /* PDEV TX stats */
166 s32 comp_queued;
167 s32 comp_delivered;
168 s32 msdu_enqued;
169 s32 mpdu_enqued;
170 s32 wmm_drop;
171 s32 local_enqued;
172 s32 local_freed;
173 s32 hw_queued;
174 s32 hw_reaped;
175 s32 underrun;
176 s32 tx_abort;
177 s32 mpdus_requed;
178 u32 tx_ko;
179 u32 data_rc;
180 u32 self_triggers;
181 u32 sw_retry_failure;
182 u32 illgl_rate_phy_err;
183 u32 pdev_cont_xretry;
184 u32 pdev_tx_timeout;
185 u32 pdev_resets;
186 u32 phy_underrun;
187 u32 txop_ovf;
188
189 /* PDEV RX stats */
190 s32 mid_ppdu_route_change;
191 s32 status_rcvd;
192 s32 r0_frags;
193 s32 r1_frags;
194 s32 r2_frags;
195 s32 r3_frags;
196 s32 htt_msdus;
197 s32 htt_mpdus;
198 s32 loc_msdus;
199 s32 loc_mpdus;
200 s32 oversize_amsdu;
201 s32 phy_errs;
202 s32 phy_err_drop;
203 s32 mpdu_errs;
Michal Kazior53268492014-09-25 12:33:50 +0200204};
Kalle Valo5e3dd152013-06-12 20:52:10 +0300205
Michal Kazior53268492014-09-25 12:33:50 +0200206struct ath10k_fw_stats {
207 struct list_head pdevs;
208 struct list_head peers;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300209};
210
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200211struct ath10k_dfs_stats {
212 u32 phy_errors;
213 u32 pulses_total;
214 u32 pulses_detected;
215 u32 pulses_discarded;
216 u32 radar_detected;
217};
218
Kalle Valo5e3dd152013-06-12 20:52:10 +0300219#define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
220
221struct ath10k_peer {
222 struct list_head list;
223 int vdev_id;
224 u8 addr[ETH_ALEN];
225 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
Sujith Manoharanae167132014-11-25 11:46:59 +0530226
227 /* protected by ar->data_lock */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300228 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
229};
230
Michal Kazior9797feb2014-02-14 14:49:48 +0100231struct ath10k_sta {
232 struct ath10k_vif *arvif;
233
234 /* the following are protected by ar->data_lock */
235 u32 changed; /* IEEE80211_RC_* */
236 u32 bw;
237 u32 nss;
238 u32 smps;
239
240 struct work_struct update_wk;
241};
242
Kalle Valo5e3dd152013-06-12 20:52:10 +0300243#define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
244
245struct ath10k_vif {
Michal Kazior05791192013-10-16 15:44:45 +0300246 struct list_head list;
247
Kalle Valo5e3dd152013-06-12 20:52:10 +0300248 u32 vdev_id;
249 enum wmi_vdev_type vdev_type;
250 enum wmi_vdev_subtype vdev_subtype;
251 u32 beacon_interval;
252 u32 dtim_period;
Michal Kaziored543882013-09-13 14:16:56 +0200253 struct sk_buff *beacon;
Michal Kazior748afc42014-01-23 12:48:21 +0100254 /* protected by data_lock */
255 bool beacon_sent;
Michal Kazior64badcb2014-09-18 11:18:02 +0300256 void *beacon_buf;
257 dma_addr_t beacon_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300258
259 struct ath10k *ar;
260 struct ieee80211_vif *vif;
261
Michal Kaziorc930f742014-01-23 11:38:25 +0100262 bool is_started;
263 bool is_up;
Simon Wunderlich855aed12014-08-02 09:12:54 +0300264 bool spectral_enabled;
Michal Kaziorc930f742014-01-23 11:38:25 +0100265 u32 aid;
266 u8 bssid[ETH_ALEN];
267
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300268 struct work_struct wep_key_work;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300269 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300270 u8 def_wep_key_idx;
271 u8 def_wep_key_newidx;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300272
273 u16 tx_seq_no;
274
275 union {
276 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +0300277 u32 uapsd;
278 } sta;
279 struct {
280 /* 127 stations; wmi limit */
281 u8 tim_bitmap[16];
282 u8 tim_len;
283 u32 ssid_len;
284 u8 ssid[IEEE80211_MAX_SSID_LEN];
285 bool hidden_ssid;
286 /* P2P_IE with NoA attribute for P2P_GO case */
287 u32 noa_len;
288 u8 *noa_data;
289 } ap;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300290 } u;
Janusz Dziedzic51ab1a02014-01-08 09:08:33 +0100291
292 u8 fixed_rate;
293 u8 fixed_nss;
Janusz Dziedzic9f81f722014-01-17 20:04:14 +0100294 u8 force_sgi;
Marek Kwaczynskie81bd102014-03-11 12:58:00 +0200295 bool use_cts_prot;
296 int num_legacy_stations;
Michal Kazior7d9d5582014-10-21 10:40:15 +0300297 int txpower;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300298};
299
300struct ath10k_vif_iter {
301 u32 vdev_id;
302 struct ath10k_vif *arvif;
303};
304
Ben Greear384914b2014-08-25 08:37:32 +0300305/* used for crash-dump storage, protected by data-lock */
306struct ath10k_fw_crash_data {
307 bool crashed_since_read;
308
309 uuid_le uuid;
310 struct timespec timestamp;
311 __le32 registers[REG_DUMP_COUNT_QCA988X];
312};
313
Kalle Valo5e3dd152013-06-12 20:52:10 +0300314struct ath10k_debug {
315 struct dentry *debugfs_phy;
316
Michal Kazior60ef4012014-09-25 12:33:48 +0200317 struct ath10k_fw_stats fw_stats;
318 struct completion fw_stats_complete;
Michal Kazior53268492014-09-25 12:33:50 +0200319 bool fw_stats_done;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300320
Kalle Valoa3d135e2013-09-03 11:44:10 +0300321 unsigned long htt_stats_mask;
322 struct delayed_work htt_stats_dwork;
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200323 struct ath10k_dfs_stats dfs_stats;
324 struct ath_dfs_pool_stats dfs_pool_stats;
Kalle Valof118a3e2014-01-03 12:59:31 +0200325
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300326 /* protected by conf_mutex */
Kalle Valof118a3e2014-01-03 12:59:31 +0200327 u32 fw_dbglog_mask;
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300328 u32 pktlog_filter;
Yanbo Li077a3802014-11-25 12:24:33 +0200329 u32 reg_addr;
Peter Oha7bd3e92014-12-02 13:07:14 +0200330 u32 nf_cal_period;
Janusz Dziedzicd3856232014-06-02 21:19:46 +0300331
332 u8 htt_max_amsdu;
333 u8 htt_max_ampdu;
Ben Greear384914b2014-08-25 08:37:32 +0300334
335 struct ath10k_fw_crash_data *fw_crash_data;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300336};
337
Michal Kaziorf7843d72013-07-16 09:38:52 +0200338enum ath10k_state {
339 ATH10K_STATE_OFF = 0,
340 ATH10K_STATE_ON,
Michal Kazioraffd3212013-07-16 09:54:35 +0200341
342 /* When doing firmware recovery the device is first powered down.
343 * mac80211 is supposed to call in to start() hook later on. It is
344 * however possible that driver unloading and firmware crash overlap.
345 * mac80211 can wait on conf_mutex in stop() while the device is
346 * stopped in ath10k_core_restart() work holding conf_mutex. The state
347 * RESTARTED means that the device is up and mac80211 has started hw
348 * reconfiguration. Once mac80211 is done with the reconfiguration we
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200349 * set the state to STATE_ON in reconfig_complete(). */
Michal Kazioraffd3212013-07-16 09:54:35 +0200350 ATH10K_STATE_RESTARTING,
351 ATH10K_STATE_RESTARTED,
352
353 /* The device has crashed while restarting hw. This state is like ON
354 * but commands are blocked in HTC and -ECOMM response is given. This
355 * prevents completion timeouts and makes the driver more responsive to
356 * userspace commands. This is also prevents recursive recovery. */
357 ATH10K_STATE_WEDGED,
Kalle Valo43d2a302014-09-10 18:23:30 +0300358
359 /* factory tests */
360 ATH10K_STATE_UTF,
361};
362
363enum ath10k_firmware_mode {
364 /* the default mode, standard 802.11 functionality */
365 ATH10K_FIRMWARE_MODE_NORMAL,
366
367 /* factory tests etc */
368 ATH10K_FIRMWARE_MODE_UTF,
Michal Kaziorf7843d72013-07-16 09:38:52 +0200369};
370
Michal Kazior0d9b0432013-08-09 10:13:33 +0200371enum ath10k_fw_features {
372 /* wmi_mgmt_rx_hdr contains extra RSSI information */
373 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
374
Kalle Valo202e86e2014-12-03 10:10:08 +0200375 /* Firmware from 10X branch. Deprecated, don't use in new code. */
Bartosz Markowskice428702013-09-26 17:47:05 +0200376 ATH10K_FW_FEATURE_WMI_10X = 1,
377
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200378 /* firmware support tx frame management over WMI, otherwise it's HTT */
379 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
380
Bartosz Markowskid3541812013-12-10 16:20:40 +0100381 /* Firmware does not support P2P */
382 ATH10K_FW_FEATURE_NO_P2P = 3,
383
Kalle Valo202e86e2014-12-03 10:10:08 +0200384 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
385 * bit is required to be set as well. Deprecated, don't use in new
386 * code.
Michal Kazior24c88f72014-07-25 13:32:17 +0200387 */
388 ATH10K_FW_FEATURE_WMI_10_2 = 4,
389
Michal Kazior0d9b0432013-08-09 10:13:33 +0200390 /* keep last */
391 ATH10K_FW_FEATURE_COUNT,
392};
393
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200394enum ath10k_dev_flags {
395 /* Indicates that ath10k device is during CAC phase of DFS */
396 ATH10K_CAC_RUNNING,
Michal Kazior6782cb62014-05-23 12:28:47 +0200397 ATH10K_FLAG_CORE_REGISTERED,
Michal Kazior7962b0d2014-10-28 10:34:38 +0100398
399 /* Device has crashed and needs to restart. This indicates any pending
400 * waiters should immediately cancel instead of waiting for a time out.
401 */
402 ATH10K_FLAG_CRASH_FLUSH,
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200403};
404
Kalle Valoa58227e2014-10-13 09:40:59 +0300405enum ath10k_cal_mode {
406 ATH10K_CAL_MODE_FILE,
407 ATH10K_CAL_MODE_OTP,
Toshi Kikuchi5aabff02014-12-02 10:55:54 +0200408 ATH10K_CAL_MODE_DT,
Kalle Valoa58227e2014-10-13 09:40:59 +0300409};
410
411static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
412{
413 switch (mode) {
414 case ATH10K_CAL_MODE_FILE:
415 return "file";
416 case ATH10K_CAL_MODE_OTP:
417 return "otp";
Toshi Kikuchi5aabff02014-12-02 10:55:54 +0200418 case ATH10K_CAL_MODE_DT:
419 return "dt";
Kalle Valoa58227e2014-10-13 09:40:59 +0300420 }
421
422 return "unknown";
423}
424
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200425enum ath10k_scan_state {
426 ATH10K_SCAN_IDLE,
427 ATH10K_SCAN_STARTING,
428 ATH10K_SCAN_RUNNING,
429 ATH10K_SCAN_ABORTING,
430};
431
432static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
433{
434 switch (state) {
435 case ATH10K_SCAN_IDLE:
436 return "idle";
437 case ATH10K_SCAN_STARTING:
438 return "starting";
439 case ATH10K_SCAN_RUNNING:
440 return "running";
441 case ATH10K_SCAN_ABORTING:
442 return "aborting";
443 }
444
445 return "unknown";
446}
447
Kalle Valo5e3dd152013-06-12 20:52:10 +0300448struct ath10k {
449 struct ath_common ath_common;
450 struct ieee80211_hw *hw;
451 struct device *dev;
452 u8 mac_addr[ETH_ALEN];
453
Kalle Valoe01ae682013-09-01 11:22:14 +0300454 u32 chip_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300455 u32 target_version;
456 u8 fw_version_major;
457 u32 fw_version_minor;
458 u16 fw_version_release;
459 u16 fw_version_build;
460 u32 phy_capability;
461 u32 hw_min_tx_power;
462 u32 hw_max_tx_power;
463 u32 ht_cap_info;
464 u32 vht_cap_info;
Michal Kazior8865bee42013-07-24 12:36:46 +0200465 u32 num_rf_chains;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300466
Michal Kazior0d9b0432013-08-09 10:13:33 +0200467 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
468
Kalle Valo5e3dd152013-06-12 20:52:10 +0300469 struct targetdef *targetdef;
470 struct hostdef *hostdef;
471
472 bool p2p;
473
474 struct {
Kalle Valoe07db352014-10-13 09:40:47 +0300475 enum ath10k_bus bus;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300476 const struct ath10k_hif_ops *ops;
477 } hif;
478
Marek Puzyniak9042e172014-02-10 17:14:23 +0100479 struct completion target_suspend;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300480
481 struct ath10k_bmi bmi;
Michal Kazioredb82362013-07-05 16:15:14 +0300482 struct ath10k_wmi wmi;
Michal Kaziorcd003fa2013-07-05 16:15:13 +0300483 struct ath10k_htc htc;
Michal Kazioredb82362013-07-05 16:15:14 +0300484 struct ath10k_htt htt;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300485
486 struct ath10k_hw_params {
487 u32 id;
488 const char *name;
489 u32 patch_load_addr;
Michal Kazior3a8200b2014-12-02 10:55:55 +0200490 int uart_pin;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300491
492 struct ath10k_hw_params_fw {
493 const char *dir;
494 const char *fw;
495 const char *otp;
496 const char *board;
Michal Kazior9764a2a2014-12-02 10:55:54 +0200497 size_t board_size;
498 size_t board_ext_size;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300499 } fw;
500 } hw_params;
501
Kalle Valo36527912013-09-27 19:54:55 +0300502 const struct firmware *board;
Kalle Valo958df3a2013-09-27 19:55:01 +0300503 const void *board_data;
504 size_t board_len;
505
Michal Kazior29385052013-07-16 09:38:58 +0200506 const struct firmware *otp;
Kalle Valo958df3a2013-09-27 19:55:01 +0300507 const void *otp_data;
508 size_t otp_len;
509
Michal Kazior29385052013-07-16 09:38:58 +0200510 const struct firmware *firmware;
Kalle Valo958df3a2013-09-27 19:55:01 +0300511 const void *firmware_data;
512 size_t firmware_len;
Michal Kazior29385052013-07-16 09:38:58 +0200513
Kalle Valoa58227e2014-10-13 09:40:59 +0300514 const struct firmware *cal_file;
515
Kalle Valo1a222432013-09-27 19:55:07 +0300516 int fw_api;
Kalle Valoa58227e2014-10-13 09:40:59 +0300517 enum ath10k_cal_mode cal_mode;
Kalle Valo1a222432013-09-27 19:55:07 +0300518
Kalle Valo5e3dd152013-06-12 20:52:10 +0300519 struct {
520 struct completion started;
521 struct completion completed;
522 struct completion on_channel;
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200523 struct delayed_work timeout;
524 enum ath10k_scan_state state;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300525 bool is_roc;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300526 int vdev_id;
527 int roc_freq;
528 } scan;
529
530 struct {
531 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
532 } mac;
533
534 /* should never be NULL; needed for regular htt rx */
535 struct ieee80211_channel *rx_channel;
536
537 /* valid during scan; needed for mgmt rx during scan */
538 struct ieee80211_channel *scan_channel;
539
Michal Kaziorc930f742014-01-23 11:38:25 +0100540 /* current operating channel definition */
541 struct cfg80211_chan_def chandef;
542
Ben Greear16c11172014-09-23 14:17:16 -0700543 unsigned long long free_vdev_map;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300544 bool monitor;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300545 int monitor_vdev_id;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300546 bool monitor_started;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300547 unsigned int filter_flags;
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200548 unsigned long dev_flags;
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +0200549 u32 dfs_block_radar_events;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300550
Michal Kaziord6500972014-04-08 09:56:09 +0300551 /* protected by conf_mutex */
552 bool radar_enabled;
553 int num_started_vdevs;
554
Ben Greear46acf7b2014-05-16 17:15:38 +0300555 /* Protected by conf-mutex */
556 u8 supp_tx_chainmask;
557 u8 supp_rx_chainmask;
558 u8 cfg_tx_chainmask;
559 u8 cfg_rx_chainmask;
560
Kalle Valo5e3dd152013-06-12 20:52:10 +0300561 struct wmi_pdev_set_wmm_params_arg wmm_params;
562 struct completion install_key_done;
563
564 struct completion vdev_setup_done;
565
566 struct workqueue_struct *workqueue;
567
568 /* prevents concurrent FW reconfiguration */
569 struct mutex conf_mutex;
570
571 /* protects shared structure data */
572 spinlock_t data_lock;
573
Michal Kazior05791192013-10-16 15:44:45 +0300574 struct list_head arvifs;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300575 struct list_head peers;
576 wait_queue_head_t peer_mapping_wq;
577
Michal Kazior292a7532014-11-25 15:16:04 +0100578 /* protected by conf_mutex */
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100579 int num_peers;
Michal Kaziorcfd10612014-11-25 15:16:05 +0100580 int num_stations;
581
582 int max_num_peers;
583 int max_num_stations;
Kalle Valo30c78162014-12-17 12:20:45 +0200584 int max_num_vdevs;
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100585
Kalle Valo5e3dd152013-06-12 20:52:10 +0300586 struct work_struct offchan_tx_work;
587 struct sk_buff_head offchan_tx_queue;
588 struct completion offchan_tx_completed;
589 struct sk_buff *offchan_tx_skb;
590
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200591 struct work_struct wmi_mgmt_tx_work;
592 struct sk_buff_head wmi_mgmt_tx_queue;
593
Michal Kaziorf7843d72013-07-16 09:38:52 +0200594 enum ath10k_state state;
595
Michal Kazior6782cb62014-05-23 12:28:47 +0200596 struct work_struct register_work;
Michal Kazioraffd3212013-07-16 09:54:35 +0200597 struct work_struct restart_work;
598
Michal Kazior2e1dea42013-07-31 10:32:40 +0200599 /* cycle count is reported twice for each visited channel during scan.
600 * access protected by data_lock */
601 u32 survey_last_rx_clear_count;
602 u32 survey_last_cycle_count;
603 struct survey_info survey[ATH10K_NUM_CHANS];
604
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200605 struct dfs_pattern_detector *dfs_detector;
606
Kalle Valo5e3dd152013-06-12 20:52:10 +0300607#ifdef CONFIG_ATH10K_DEBUGFS
608 struct ath10k_debug debug;
609#endif
Simon Wunderlich855aed12014-08-02 09:12:54 +0300610
611 struct {
612 /* relay(fs) channel for spectral scan */
613 struct rchan *rfs_chan_spec_scan;
614
615 /* spectral_mode and spec_config are protected by conf_mutex */
616 enum ath10k_spectral_mode mode;
617 struct ath10k_spec_scan config;
618 } spectral;
Michal Kaziore7b54192014-08-07 11:03:27 +0200619
Kalle Valo43d2a302014-09-10 18:23:30 +0300620 struct {
621 /* protected by conf_mutex */
622 const struct firmware *utf;
623 DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
Michal Kaziord7579d12014-12-03 10:10:54 +0200624 enum ath10k_fw_wmi_op_version orig_wmi_op_version;
Kalle Valo43d2a302014-09-10 18:23:30 +0300625
626 /* protected by data_lock */
627 bool utf_monitor;
628 } testmode;
629
Ben Greearf51dbe72014-09-29 14:41:46 +0300630 struct {
631 /* protected by data_lock */
632 u32 fw_crash_counter;
633 u32 fw_warm_reset_counter;
634 u32 fw_cold_reset_counter;
635 } stats;
636
Michal Kaziore7b54192014-08-07 11:03:27 +0200637 /* must be last */
638 u8 drv_priv[0] __aligned(sizeof(void *));
Kalle Valo5e3dd152013-06-12 20:52:10 +0300639};
640
Michal Kaziore7b54192014-08-07 11:03:27 +0200641struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
Kalle Valoe07db352014-10-13 09:40:47 +0300642 enum ath10k_bus bus,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300643 const struct ath10k_hif_ops *hif_ops);
644void ath10k_core_destroy(struct ath10k *ar);
645
Kalle Valo43d2a302014-09-10 18:23:30 +0300646int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
Marek Puzyniak00f54822014-02-10 17:14:24 +0100647int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
Michal Kaziordd30a362013-07-16 09:38:51 +0200648void ath10k_core_stop(struct ath10k *ar);
Kalle Valoe01ae682013-09-01 11:22:14 +0300649int ath10k_core_register(struct ath10k *ar, u32 chip_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300650void ath10k_core_unregister(struct ath10k *ar);
651
Kalle Valo5e3dd152013-06-12 20:52:10 +0300652#endif /* _CORE_H_ */