blob: 7b6d9e4567a3c923ff1db4e776d7b52fa14a9762 [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"
Rajkumar Manoharanfe6f36d2014-12-17 12:22:07 +020037#include "thermal.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030038
39#define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
40#define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
41#define WO(_f) ((_f##_OFFSET) >> 2)
42
43#define ATH10K_SCAN_ID 0
44#define WMI_READY_TIMEOUT (5 * HZ)
45#define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)
Michal Kazior2e1dea42013-07-31 10:32:40 +020046#define ATH10K_NUM_CHANS 38
Kalle Valo5e3dd152013-06-12 20:52:10 +030047
48/* Antenna noise floor */
49#define ATH10K_DEFAULT_NOISE_FLOOR -95
50
Bartosz Markowski71098612013-11-14 09:01:15 +010051#define ATH10K_MAX_NUM_MGMT_PENDING 128
Bartosz Markowski5e00d312013-09-26 17:47:12 +020052
Kalle Valo5a13e762014-01-20 11:01:46 +020053/* number of failed packets */
54#define ATH10K_KICKOUT_THRESHOLD 50
55
56/*
57 * Use insanely high numbers to make sure that the firmware implementation
58 * won't start, we have the same functionality already in hostapd. Unit
59 * is seconds.
60 */
61#define ATH10K_KEEPALIVE_MIN_IDLE 3747
62#define ATH10K_KEEPALIVE_MAX_IDLE 3895
63#define ATH10K_KEEPALIVE_MAX_UNRESPONSIVE 3900
64
Kalle Valo5e3dd152013-06-12 20:52:10 +030065struct ath10k;
66
Kalle Valoe07db352014-10-13 09:40:47 +030067enum ath10k_bus {
68 ATH10K_BUS_PCI,
69};
70
71static inline const char *ath10k_bus_str(enum ath10k_bus bus)
72{
73 switch (bus) {
74 case ATH10K_BUS_PCI:
75 return "pci";
76 }
77
78 return "unknown";
79}
80
Kalle Valo5e3dd152013-06-12 20:52:10 +030081struct ath10k_skb_cb {
82 dma_addr_t paddr;
Michal Kaziord84a5122014-11-27 11:09:37 +010083 u8 eid;
Bartosz Markowski5e00d312013-09-26 17:47:12 +020084 u8 vdev_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +030085
86 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +030087 u8 tid;
Michal Kazior8d6d3622014-11-24 14:58:31 +010088 u16 freq;
Kalle Valo5e3dd152013-06-12 20:52:10 +030089 bool is_offchan;
Michal Kaziora16942e2014-02-27 18:50:04 +020090 struct ath10k_htt_txbuf *txbuf;
91 u32 txbuf_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +030092 } __packed htt;
Michal Kazior748afc42014-01-23 12:48:21 +010093
94 struct {
95 bool dtim_zero;
96 bool deliver_cab;
97 } bcn;
Kalle Valo5e3dd152013-06-12 20:52:10 +030098} __packed;
99
100static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
101{
102 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
103 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
104 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
105}
106
Kalle Valo5e3dd152013-06-12 20:52:10 +0300107static inline u32 host_interest_item_address(u32 item_offset)
108{
109 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
110}
111
112struct ath10k_bmi {
113 bool done_sent;
114};
115
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200116struct ath10k_mem_chunk {
117 void *vaddr;
118 dma_addr_t paddr;
119 u32 len;
120 u32 req_id;
121};
122
Kalle Valo5e3dd152013-06-12 20:52:10 +0300123struct ath10k_wmi {
Kalle Valo202e86e2014-12-03 10:10:08 +0200124 enum ath10k_fw_wmi_op_version op_version;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300125 enum ath10k_htc_ep_id eid;
126 struct completion service_ready;
127 struct completion unified_ready;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200128 wait_queue_head_t tx_credits_wq;
Michal Kazioracfe7ec2014-11-27 10:11:17 +0100129 DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX);
Bartosz Markowskice428702013-09-26 17:47:05 +0200130 struct wmi_cmd_map *cmd;
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200131 struct wmi_vdev_param_map *vdev_param;
Bartosz Markowski226a3392013-09-26 17:47:16 +0200132 struct wmi_pdev_param_map *pdev_param;
Michal Kaziord7579d12014-12-03 10:10:54 +0200133 const struct wmi_ops *ops;
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200134
135 u32 num_mem_chunks;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +0200136 struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300137};
138
Michal Kazior60ef4012014-09-25 12:33:48 +0200139struct ath10k_fw_stats_peer {
Michal Kazior53268492014-09-25 12:33:50 +0200140 struct list_head list;
141
Kalle Valo5e3dd152013-06-12 20:52:10 +0300142 u8 peer_macaddr[ETH_ALEN];
143 u32 peer_rssi;
144 u32 peer_tx_rate;
Ben Greear23c3aae2014-03-28 14:35:15 +0200145 u32 peer_rx_rate; /* 10x only */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300146};
147
Michal Kazior53268492014-09-25 12:33:50 +0200148struct ath10k_fw_stats_pdev {
149 struct list_head list;
150
Kalle Valo5e3dd152013-06-12 20:52:10 +0300151 /* PDEV stats */
152 s32 ch_noise_floor;
153 u32 tx_frame_count;
154 u32 rx_frame_count;
155 u32 rx_clear_count;
156 u32 cycle_count;
157 u32 phy_err_count;
158 u32 chan_tx_power;
Chun-Yeow Yeoh52e346d2014-03-28 14:35:16 +0200159 u32 ack_rx_bad;
160 u32 rts_bad;
161 u32 rts_good;
162 u32 fcs_bad;
163 u32 no_beacons;
164 u32 mib_int_count;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300165
166 /* PDEV TX stats */
167 s32 comp_queued;
168 s32 comp_delivered;
169 s32 msdu_enqued;
170 s32 mpdu_enqued;
171 s32 wmm_drop;
172 s32 local_enqued;
173 s32 local_freed;
174 s32 hw_queued;
175 s32 hw_reaped;
176 s32 underrun;
177 s32 tx_abort;
178 s32 mpdus_requed;
179 u32 tx_ko;
180 u32 data_rc;
181 u32 self_triggers;
182 u32 sw_retry_failure;
183 u32 illgl_rate_phy_err;
184 u32 pdev_cont_xretry;
185 u32 pdev_tx_timeout;
186 u32 pdev_resets;
187 u32 phy_underrun;
188 u32 txop_ovf;
189
190 /* PDEV RX stats */
191 s32 mid_ppdu_route_change;
192 s32 status_rcvd;
193 s32 r0_frags;
194 s32 r1_frags;
195 s32 r2_frags;
196 s32 r3_frags;
197 s32 htt_msdus;
198 s32 htt_mpdus;
199 s32 loc_msdus;
200 s32 loc_mpdus;
201 s32 oversize_amsdu;
202 s32 phy_errs;
203 s32 phy_err_drop;
204 s32 mpdu_errs;
Michal Kazior53268492014-09-25 12:33:50 +0200205};
Kalle Valo5e3dd152013-06-12 20:52:10 +0300206
Michal Kazior53268492014-09-25 12:33:50 +0200207struct ath10k_fw_stats {
208 struct list_head pdevs;
209 struct list_head peers;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300210};
211
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200212struct ath10k_dfs_stats {
213 u32 phy_errors;
214 u32 pulses_total;
215 u32 pulses_detected;
216 u32 pulses_discarded;
217 u32 radar_detected;
218};
219
Kalle Valo5e3dd152013-06-12 20:52:10 +0300220#define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
221
222struct ath10k_peer {
223 struct list_head list;
224 int vdev_id;
225 u8 addr[ETH_ALEN];
226 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
Sujith Manoharanae167132014-11-25 11:46:59 +0530227
228 /* protected by ar->data_lock */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300229 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
230};
231
Michal Kazior9797feb2014-02-14 14:49:48 +0100232struct ath10k_sta {
233 struct ath10k_vif *arvif;
234
235 /* the following are protected by ar->data_lock */
236 u32 changed; /* IEEE80211_RC_* */
237 u32 bw;
238 u32 nss;
239 u32 smps;
240
241 struct work_struct update_wk;
242};
243
Kalle Valo5e3dd152013-06-12 20:52:10 +0300244#define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
245
246struct ath10k_vif {
Michal Kazior05791192013-10-16 15:44:45 +0300247 struct list_head list;
248
Kalle Valo5e3dd152013-06-12 20:52:10 +0300249 u32 vdev_id;
250 enum wmi_vdev_type vdev_type;
251 enum wmi_vdev_subtype vdev_subtype;
252 u32 beacon_interval;
253 u32 dtim_period;
Michal Kaziored543882013-09-13 14:16:56 +0200254 struct sk_buff *beacon;
Michal Kazior748afc42014-01-23 12:48:21 +0100255 /* protected by data_lock */
256 bool beacon_sent;
Michal Kazior64badcb2014-09-18 11:18:02 +0300257 void *beacon_buf;
258 dma_addr_t beacon_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300259
260 struct ath10k *ar;
261 struct ieee80211_vif *vif;
262
Michal Kaziorc930f742014-01-23 11:38:25 +0100263 bool is_started;
264 bool is_up;
Simon Wunderlich855aed12014-08-02 09:12:54 +0300265 bool spectral_enabled;
Michal Kaziorc930f742014-01-23 11:38:25 +0100266 u32 aid;
267 u8 bssid[ETH_ALEN];
268
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300269 struct work_struct wep_key_work;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300270 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300271 u8 def_wep_key_idx;
272 u8 def_wep_key_newidx;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300273
274 u16 tx_seq_no;
275
276 union {
277 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +0300278 u32 uapsd;
279 } sta;
280 struct {
281 /* 127 stations; wmi limit */
282 u8 tim_bitmap[16];
283 u8 tim_len;
284 u32 ssid_len;
285 u8 ssid[IEEE80211_MAX_SSID_LEN];
286 bool hidden_ssid;
287 /* P2P_IE with NoA attribute for P2P_GO case */
288 u32 noa_len;
289 u8 *noa_data;
290 } ap;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300291 } u;
Janusz Dziedzic51ab1a02014-01-08 09:08:33 +0100292
293 u8 fixed_rate;
294 u8 fixed_nss;
Janusz Dziedzic9f81f722014-01-17 20:04:14 +0100295 u8 force_sgi;
Marek Kwaczynskie81bd102014-03-11 12:58:00 +0200296 bool use_cts_prot;
297 int num_legacy_stations;
Michal Kazior7d9d5582014-10-21 10:40:15 +0300298 int txpower;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300299};
300
301struct ath10k_vif_iter {
302 u32 vdev_id;
303 struct ath10k_vif *arvif;
304};
305
Ben Greear384914b2014-08-25 08:37:32 +0300306/* used for crash-dump storage, protected by data-lock */
307struct ath10k_fw_crash_data {
308 bool crashed_since_read;
309
310 uuid_le uuid;
311 struct timespec timestamp;
312 __le32 registers[REG_DUMP_COUNT_QCA988X];
313};
314
Kalle Valo5e3dd152013-06-12 20:52:10 +0300315struct ath10k_debug {
316 struct dentry *debugfs_phy;
317
Michal Kazior60ef4012014-09-25 12:33:48 +0200318 struct ath10k_fw_stats fw_stats;
319 struct completion fw_stats_complete;
Michal Kazior53268492014-09-25 12:33:50 +0200320 bool fw_stats_done;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300321
Kalle Valoa3d135e2013-09-03 11:44:10 +0300322 unsigned long htt_stats_mask;
323 struct delayed_work htt_stats_dwork;
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200324 struct ath10k_dfs_stats dfs_stats;
325 struct ath_dfs_pool_stats dfs_pool_stats;
Kalle Valof118a3e2014-01-03 12:59:31 +0200326
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300327 /* protected by conf_mutex */
Kalle Valof118a3e2014-01-03 12:59:31 +0200328 u32 fw_dbglog_mask;
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300329 u32 pktlog_filter;
Yanbo Li077a3802014-11-25 12:24:33 +0200330 u32 reg_addr;
Peter Oha7bd3e92014-12-02 13:07:14 +0200331 u32 nf_cal_period;
Janusz Dziedzicd3856232014-06-02 21:19:46 +0300332
333 u8 htt_max_amsdu;
334 u8 htt_max_ampdu;
Ben Greear384914b2014-08-25 08:37:32 +0300335
336 struct ath10k_fw_crash_data *fw_crash_data;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300337};
338
Michal Kaziorf7843d72013-07-16 09:38:52 +0200339enum ath10k_state {
340 ATH10K_STATE_OFF = 0,
341 ATH10K_STATE_ON,
Michal Kazioraffd3212013-07-16 09:54:35 +0200342
343 /* When doing firmware recovery the device is first powered down.
344 * mac80211 is supposed to call in to start() hook later on. It is
345 * however possible that driver unloading and firmware crash overlap.
346 * mac80211 can wait on conf_mutex in stop() while the device is
347 * stopped in ath10k_core_restart() work holding conf_mutex. The state
348 * RESTARTED means that the device is up and mac80211 has started hw
349 * reconfiguration. Once mac80211 is done with the reconfiguration we
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200350 * set the state to STATE_ON in reconfig_complete(). */
Michal Kazioraffd3212013-07-16 09:54:35 +0200351 ATH10K_STATE_RESTARTING,
352 ATH10K_STATE_RESTARTED,
353
354 /* The device has crashed while restarting hw. This state is like ON
355 * but commands are blocked in HTC and -ECOMM response is given. This
356 * prevents completion timeouts and makes the driver more responsive to
357 * userspace commands. This is also prevents recursive recovery. */
358 ATH10K_STATE_WEDGED,
Kalle Valo43d2a302014-09-10 18:23:30 +0300359
360 /* factory tests */
361 ATH10K_STATE_UTF,
362};
363
364enum ath10k_firmware_mode {
365 /* the default mode, standard 802.11 functionality */
366 ATH10K_FIRMWARE_MODE_NORMAL,
367
368 /* factory tests etc */
369 ATH10K_FIRMWARE_MODE_UTF,
Michal Kaziorf7843d72013-07-16 09:38:52 +0200370};
371
Michal Kazior0d9b0432013-08-09 10:13:33 +0200372enum ath10k_fw_features {
373 /* wmi_mgmt_rx_hdr contains extra RSSI information */
374 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
375
Kalle Valo202e86e2014-12-03 10:10:08 +0200376 /* Firmware from 10X branch. Deprecated, don't use in new code. */
Bartosz Markowskice428702013-09-26 17:47:05 +0200377 ATH10K_FW_FEATURE_WMI_10X = 1,
378
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200379 /* firmware support tx frame management over WMI, otherwise it's HTT */
380 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
381
Bartosz Markowskid3541812013-12-10 16:20:40 +0100382 /* Firmware does not support P2P */
383 ATH10K_FW_FEATURE_NO_P2P = 3,
384
Kalle Valo202e86e2014-12-03 10:10:08 +0200385 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
386 * bit is required to be set as well. Deprecated, don't use in new
387 * code.
Michal Kazior24c88f72014-07-25 13:32:17 +0200388 */
389 ATH10K_FW_FEATURE_WMI_10_2 = 4,
390
Michal Kazior0d9b0432013-08-09 10:13:33 +0200391 /* keep last */
392 ATH10K_FW_FEATURE_COUNT,
393};
394
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200395enum ath10k_dev_flags {
396 /* Indicates that ath10k device is during CAC phase of DFS */
397 ATH10K_CAC_RUNNING,
Michal Kazior6782cb62014-05-23 12:28:47 +0200398 ATH10K_FLAG_CORE_REGISTERED,
Michal Kazior7962b0d2014-10-28 10:34:38 +0100399
400 /* Device has crashed and needs to restart. This indicates any pending
401 * waiters should immediately cancel instead of waiting for a time out.
402 */
403 ATH10K_FLAG_CRASH_FLUSH,
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200404};
405
Kalle Valoa58227e2014-10-13 09:40:59 +0300406enum ath10k_cal_mode {
407 ATH10K_CAL_MODE_FILE,
408 ATH10K_CAL_MODE_OTP,
Toshi Kikuchi5aabff02014-12-02 10:55:54 +0200409 ATH10K_CAL_MODE_DT,
Kalle Valoa58227e2014-10-13 09:40:59 +0300410};
411
412static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
413{
414 switch (mode) {
415 case ATH10K_CAL_MODE_FILE:
416 return "file";
417 case ATH10K_CAL_MODE_OTP:
418 return "otp";
Toshi Kikuchi5aabff02014-12-02 10:55:54 +0200419 case ATH10K_CAL_MODE_DT:
420 return "dt";
Kalle Valoa58227e2014-10-13 09:40:59 +0300421 }
422
423 return "unknown";
424}
425
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200426enum ath10k_scan_state {
427 ATH10K_SCAN_IDLE,
428 ATH10K_SCAN_STARTING,
429 ATH10K_SCAN_RUNNING,
430 ATH10K_SCAN_ABORTING,
431};
432
433static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
434{
435 switch (state) {
436 case ATH10K_SCAN_IDLE:
437 return "idle";
438 case ATH10K_SCAN_STARTING:
439 return "starting";
440 case ATH10K_SCAN_RUNNING:
441 return "running";
442 case ATH10K_SCAN_ABORTING:
443 return "aborting";
444 }
445
446 return "unknown";
447}
448
Kalle Valo5e3dd152013-06-12 20:52:10 +0300449struct ath10k {
450 struct ath_common ath_common;
451 struct ieee80211_hw *hw;
452 struct device *dev;
453 u8 mac_addr[ETH_ALEN];
454
Kalle Valoe01ae682013-09-01 11:22:14 +0300455 u32 chip_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300456 u32 target_version;
457 u8 fw_version_major;
458 u32 fw_version_minor;
459 u16 fw_version_release;
460 u16 fw_version_build;
461 u32 phy_capability;
462 u32 hw_min_tx_power;
463 u32 hw_max_tx_power;
464 u32 ht_cap_info;
465 u32 vht_cap_info;
Michal Kazior8865bee42013-07-24 12:36:46 +0200466 u32 num_rf_chains;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300467
Michal Kazior0d9b0432013-08-09 10:13:33 +0200468 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
469
Kalle Valo5e3dd152013-06-12 20:52:10 +0300470 struct targetdef *targetdef;
471 struct hostdef *hostdef;
472
473 bool p2p;
474
475 struct {
Kalle Valoe07db352014-10-13 09:40:47 +0300476 enum ath10k_bus bus;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300477 const struct ath10k_hif_ops *ops;
478 } hif;
479
Marek Puzyniak9042e172014-02-10 17:14:23 +0100480 struct completion target_suspend;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300481
482 struct ath10k_bmi bmi;
Michal Kazioredb82362013-07-05 16:15:14 +0300483 struct ath10k_wmi wmi;
Michal Kaziorcd003fa2013-07-05 16:15:13 +0300484 struct ath10k_htc htc;
Michal Kazioredb82362013-07-05 16:15:14 +0300485 struct ath10k_htt htt;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300486
487 struct ath10k_hw_params {
488 u32 id;
489 const char *name;
490 u32 patch_load_addr;
Michal Kazior3a8200b2014-12-02 10:55:55 +0200491 int uart_pin;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300492
493 struct ath10k_hw_params_fw {
494 const char *dir;
495 const char *fw;
496 const char *otp;
497 const char *board;
Michal Kazior9764a2a2014-12-02 10:55:54 +0200498 size_t board_size;
499 size_t board_ext_size;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300500 } fw;
501 } hw_params;
502
Kalle Valo36527912013-09-27 19:54:55 +0300503 const struct firmware *board;
Kalle Valo958df3a2013-09-27 19:55:01 +0300504 const void *board_data;
505 size_t board_len;
506
Michal Kazior29385052013-07-16 09:38:58 +0200507 const struct firmware *otp;
Kalle Valo958df3a2013-09-27 19:55:01 +0300508 const void *otp_data;
509 size_t otp_len;
510
Michal Kazior29385052013-07-16 09:38:58 +0200511 const struct firmware *firmware;
Kalle Valo958df3a2013-09-27 19:55:01 +0300512 const void *firmware_data;
513 size_t firmware_len;
Michal Kazior29385052013-07-16 09:38:58 +0200514
Kalle Valoa58227e2014-10-13 09:40:59 +0300515 const struct firmware *cal_file;
516
Kalle Valo1a222432013-09-27 19:55:07 +0300517 int fw_api;
Kalle Valoa58227e2014-10-13 09:40:59 +0300518 enum ath10k_cal_mode cal_mode;
Kalle Valo1a222432013-09-27 19:55:07 +0300519
Kalle Valo5e3dd152013-06-12 20:52:10 +0300520 struct {
521 struct completion started;
522 struct completion completed;
523 struct completion on_channel;
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200524 struct delayed_work timeout;
525 enum ath10k_scan_state state;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300526 bool is_roc;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300527 int vdev_id;
528 int roc_freq;
529 } scan;
530
531 struct {
532 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
533 } mac;
534
535 /* should never be NULL; needed for regular htt rx */
536 struct ieee80211_channel *rx_channel;
537
538 /* valid during scan; needed for mgmt rx during scan */
539 struct ieee80211_channel *scan_channel;
540
Michal Kaziorc930f742014-01-23 11:38:25 +0100541 /* current operating channel definition */
542 struct cfg80211_chan_def chandef;
543
Ben Greear16c11172014-09-23 14:17:16 -0700544 unsigned long long free_vdev_map;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300545 bool monitor;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300546 int monitor_vdev_id;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300547 bool monitor_started;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300548 unsigned int filter_flags;
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200549 unsigned long dev_flags;
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +0200550 u32 dfs_block_radar_events;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300551
Michal Kaziord6500972014-04-08 09:56:09 +0300552 /* protected by conf_mutex */
553 bool radar_enabled;
554 int num_started_vdevs;
555
Ben Greear46acf7b2014-05-16 17:15:38 +0300556 /* Protected by conf-mutex */
557 u8 supp_tx_chainmask;
558 u8 supp_rx_chainmask;
559 u8 cfg_tx_chainmask;
560 u8 cfg_rx_chainmask;
561
Kalle Valo5e3dd152013-06-12 20:52:10 +0300562 struct wmi_pdev_set_wmm_params_arg wmm_params;
563 struct completion install_key_done;
564
565 struct completion vdev_setup_done;
566
567 struct workqueue_struct *workqueue;
568
569 /* prevents concurrent FW reconfiguration */
570 struct mutex conf_mutex;
571
572 /* protects shared structure data */
573 spinlock_t data_lock;
574
Michal Kazior05791192013-10-16 15:44:45 +0300575 struct list_head arvifs;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300576 struct list_head peers;
577 wait_queue_head_t peer_mapping_wq;
578
Michal Kazior292a7532014-11-25 15:16:04 +0100579 /* protected by conf_mutex */
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100580 int num_peers;
Michal Kaziorcfd10612014-11-25 15:16:05 +0100581 int num_stations;
582
583 int max_num_peers;
584 int max_num_stations;
Kalle Valo30c78162014-12-17 12:20:45 +0200585 int max_num_vdevs;
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100586
Kalle Valo5e3dd152013-06-12 20:52:10 +0300587 struct work_struct offchan_tx_work;
588 struct sk_buff_head offchan_tx_queue;
589 struct completion offchan_tx_completed;
590 struct sk_buff *offchan_tx_skb;
591
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200592 struct work_struct wmi_mgmt_tx_work;
593 struct sk_buff_head wmi_mgmt_tx_queue;
594
Michal Kaziorf7843d72013-07-16 09:38:52 +0200595 enum ath10k_state state;
596
Michal Kazior6782cb62014-05-23 12:28:47 +0200597 struct work_struct register_work;
Michal Kazioraffd3212013-07-16 09:54:35 +0200598 struct work_struct restart_work;
599
Michal Kazior2e1dea42013-07-31 10:32:40 +0200600 /* cycle count is reported twice for each visited channel during scan.
601 * access protected by data_lock */
602 u32 survey_last_rx_clear_count;
603 u32 survey_last_cycle_count;
604 struct survey_info survey[ATH10K_NUM_CHANS];
605
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200606 struct dfs_pattern_detector *dfs_detector;
607
Kalle Valo5e3dd152013-06-12 20:52:10 +0300608#ifdef CONFIG_ATH10K_DEBUGFS
609 struct ath10k_debug debug;
610#endif
Simon Wunderlich855aed12014-08-02 09:12:54 +0300611
612 struct {
613 /* relay(fs) channel for spectral scan */
614 struct rchan *rfs_chan_spec_scan;
615
616 /* spectral_mode and spec_config are protected by conf_mutex */
617 enum ath10k_spectral_mode mode;
618 struct ath10k_spec_scan config;
619 } spectral;
Michal Kaziore7b54192014-08-07 11:03:27 +0200620
Kalle Valo43d2a302014-09-10 18:23:30 +0300621 struct {
622 /* protected by conf_mutex */
623 const struct firmware *utf;
624 DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
Michal Kaziord7579d12014-12-03 10:10:54 +0200625 enum ath10k_fw_wmi_op_version orig_wmi_op_version;
Kalle Valo43d2a302014-09-10 18:23:30 +0300626
627 /* protected by data_lock */
628 bool utf_monitor;
629 } testmode;
630
Ben Greearf51dbe72014-09-29 14:41:46 +0300631 struct {
632 /* protected by data_lock */
633 u32 fw_crash_counter;
634 u32 fw_warm_reset_counter;
635 u32 fw_cold_reset_counter;
636 } stats;
637
Rajkumar Manoharanfe6f36d2014-12-17 12:22:07 +0200638 struct ath10k_thermal thermal;
639
Michal Kaziore7b54192014-08-07 11:03:27 +0200640 /* must be last */
641 u8 drv_priv[0] __aligned(sizeof(void *));
Kalle Valo5e3dd152013-06-12 20:52:10 +0300642};
643
Michal Kaziore7b54192014-08-07 11:03:27 +0200644struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
Kalle Valoe07db352014-10-13 09:40:47 +0300645 enum ath10k_bus bus,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300646 const struct ath10k_hif_ops *hif_ops);
647void ath10k_core_destroy(struct ath10k *ar);
648
Kalle Valo43d2a302014-09-10 18:23:30 +0300649int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
Marek Puzyniak00f54822014-02-10 17:14:24 +0100650int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
Michal Kaziordd30a362013-07-16 09:38:51 +0200651void ath10k_core_stop(struct ath10k *ar);
Kalle Valoe01ae682013-09-01 11:22:14 +0300652int ath10k_core_register(struct ath10k *ar, u32 chip_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300653void ath10k_core_unregister(struct ath10k *ar);
654
Kalle Valo5e3dd152013-06-12 20:52:10 +0300655#endif /* _CORE_H_ */