blob: 739d9d69cf1cc75e047d620371ee343a4c02a477 [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
Michal Kazior8582bf32015-01-24 12:14:47 +0200100struct ath10k_skb_rxcb {
101 dma_addr_t paddr;
102};
103
Kalle Valo5e3dd152013-06-12 20:52:10 +0300104static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
105{
106 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
107 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
108 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
109}
110
Michal Kazior8582bf32015-01-24 12:14:47 +0200111static inline struct ath10k_skb_rxcb *ATH10K_SKB_RXCB(struct sk_buff *skb)
112{
113 BUILD_BUG_ON(sizeof(struct ath10k_skb_rxcb) > sizeof(skb->cb));
114 return (struct ath10k_skb_rxcb *)skb->cb;
115}
116
Kalle Valo5e3dd152013-06-12 20:52:10 +0300117static inline u32 host_interest_item_address(u32 item_offset)
118{
119 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
120}
121
122struct ath10k_bmi {
123 bool done_sent;
124};
125
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200126struct ath10k_mem_chunk {
127 void *vaddr;
128 dma_addr_t paddr;
129 u32 len;
130 u32 req_id;
131};
132
Kalle Valo5e3dd152013-06-12 20:52:10 +0300133struct ath10k_wmi {
Kalle Valo202e86e2014-12-03 10:10:08 +0200134 enum ath10k_fw_wmi_op_version op_version;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300135 enum ath10k_htc_ep_id eid;
136 struct completion service_ready;
137 struct completion unified_ready;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200138 wait_queue_head_t tx_credits_wq;
Michal Kazioracfe7ec2014-11-27 10:11:17 +0100139 DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX);
Bartosz Markowskice428702013-09-26 17:47:05 +0200140 struct wmi_cmd_map *cmd;
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200141 struct wmi_vdev_param_map *vdev_param;
Bartosz Markowski226a3392013-09-26 17:47:16 +0200142 struct wmi_pdev_param_map *pdev_param;
Michal Kaziord7579d12014-12-03 10:10:54 +0200143 const struct wmi_ops *ops;
Bartosz Markowskib3effe62013-09-26 17:47:11 +0200144
145 u32 num_mem_chunks;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +0200146 struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300147};
148
Michal Kazior60ef4012014-09-25 12:33:48 +0200149struct ath10k_fw_stats_peer {
Michal Kazior53268492014-09-25 12:33:50 +0200150 struct list_head list;
151
Kalle Valo5e3dd152013-06-12 20:52:10 +0300152 u8 peer_macaddr[ETH_ALEN];
153 u32 peer_rssi;
154 u32 peer_tx_rate;
Ben Greear23c3aae2014-03-28 14:35:15 +0200155 u32 peer_rx_rate; /* 10x only */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300156};
157
Michal Kazior53268492014-09-25 12:33:50 +0200158struct ath10k_fw_stats_pdev {
159 struct list_head list;
160
Kalle Valo5e3dd152013-06-12 20:52:10 +0300161 /* PDEV stats */
162 s32 ch_noise_floor;
163 u32 tx_frame_count;
164 u32 rx_frame_count;
165 u32 rx_clear_count;
166 u32 cycle_count;
167 u32 phy_err_count;
168 u32 chan_tx_power;
Chun-Yeow Yeoh52e346d2014-03-28 14:35:16 +0200169 u32 ack_rx_bad;
170 u32 rts_bad;
171 u32 rts_good;
172 u32 fcs_bad;
173 u32 no_beacons;
174 u32 mib_int_count;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300175
176 /* PDEV TX stats */
177 s32 comp_queued;
178 s32 comp_delivered;
179 s32 msdu_enqued;
180 s32 mpdu_enqued;
181 s32 wmm_drop;
182 s32 local_enqued;
183 s32 local_freed;
184 s32 hw_queued;
185 s32 hw_reaped;
186 s32 underrun;
187 s32 tx_abort;
188 s32 mpdus_requed;
189 u32 tx_ko;
190 u32 data_rc;
191 u32 self_triggers;
192 u32 sw_retry_failure;
193 u32 illgl_rate_phy_err;
194 u32 pdev_cont_xretry;
195 u32 pdev_tx_timeout;
196 u32 pdev_resets;
197 u32 phy_underrun;
198 u32 txop_ovf;
199
200 /* PDEV RX stats */
201 s32 mid_ppdu_route_change;
202 s32 status_rcvd;
203 s32 r0_frags;
204 s32 r1_frags;
205 s32 r2_frags;
206 s32 r3_frags;
207 s32 htt_msdus;
208 s32 htt_mpdus;
209 s32 loc_msdus;
210 s32 loc_mpdus;
211 s32 oversize_amsdu;
212 s32 phy_errs;
213 s32 phy_err_drop;
214 s32 mpdu_errs;
Michal Kazior53268492014-09-25 12:33:50 +0200215};
Kalle Valo5e3dd152013-06-12 20:52:10 +0300216
Michal Kazior53268492014-09-25 12:33:50 +0200217struct ath10k_fw_stats {
218 struct list_head pdevs;
219 struct list_head peers;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300220};
221
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200222struct ath10k_dfs_stats {
223 u32 phy_errors;
224 u32 pulses_total;
225 u32 pulses_detected;
226 u32 pulses_discarded;
227 u32 radar_detected;
228};
229
Kalle Valo5e3dd152013-06-12 20:52:10 +0300230#define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
231
232struct ath10k_peer {
233 struct list_head list;
234 int vdev_id;
235 u8 addr[ETH_ALEN];
236 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
Sujith Manoharanae167132014-11-25 11:46:59 +0530237
238 /* protected by ar->data_lock */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300239 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
240};
241
Michal Kazior9797feb2014-02-14 14:49:48 +0100242struct ath10k_sta {
243 struct ath10k_vif *arvif;
244
245 /* the following are protected by ar->data_lock */
246 u32 changed; /* IEEE80211_RC_* */
247 u32 bw;
248 u32 nss;
249 u32 smps;
250
251 struct work_struct update_wk;
Rajkumar Manoharanf5045982015-01-12 14:07:27 +0200252
253#ifdef CONFIG_MAC80211_DEBUGFS
254 /* protected by conf_mutex */
255 bool aggr_mode;
256#endif
Michal Kazior9797feb2014-02-14 14:49:48 +0100257};
258
Kalle Valo5e3dd152013-06-12 20:52:10 +0300259#define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
260
261struct ath10k_vif {
Michal Kazior05791192013-10-16 15:44:45 +0300262 struct list_head list;
263
Kalle Valo5e3dd152013-06-12 20:52:10 +0300264 u32 vdev_id;
265 enum wmi_vdev_type vdev_type;
266 enum wmi_vdev_subtype vdev_subtype;
267 u32 beacon_interval;
268 u32 dtim_period;
Michal Kaziored543882013-09-13 14:16:56 +0200269 struct sk_buff *beacon;
Michal Kazior748afc42014-01-23 12:48:21 +0100270 /* protected by data_lock */
271 bool beacon_sent;
Michal Kazior64badcb2014-09-18 11:18:02 +0300272 void *beacon_buf;
273 dma_addr_t beacon_paddr;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300274
275 struct ath10k *ar;
276 struct ieee80211_vif *vif;
277
Michal Kaziorc930f742014-01-23 11:38:25 +0100278 bool is_started;
279 bool is_up;
Simon Wunderlich855aed12014-08-02 09:12:54 +0300280 bool spectral_enabled;
Michal Kaziorc930f742014-01-23 11:38:25 +0100281 u32 aid;
282 u8 bssid[ETH_ALEN];
283
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300284 struct work_struct wep_key_work;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300285 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
Michal Kaziorcc4827b2013-10-16 15:44:45 +0300286 u8 def_wep_key_idx;
287 u8 def_wep_key_newidx;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300288
289 u16 tx_seq_no;
290
291 union {
292 struct {
Kalle Valo5e3dd152013-06-12 20:52:10 +0300293 u32 uapsd;
294 } sta;
295 struct {
296 /* 127 stations; wmi limit */
297 u8 tim_bitmap[16];
298 u8 tim_len;
299 u32 ssid_len;
300 u8 ssid[IEEE80211_MAX_SSID_LEN];
301 bool hidden_ssid;
302 /* P2P_IE with NoA attribute for P2P_GO case */
303 u32 noa_len;
304 u8 *noa_data;
305 } ap;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300306 } u;
Janusz Dziedzic51ab1a02014-01-08 09:08:33 +0100307
308 u8 fixed_rate;
309 u8 fixed_nss;
Janusz Dziedzic9f81f722014-01-17 20:04:14 +0100310 u8 force_sgi;
Marek Kwaczynskie81bd102014-03-11 12:58:00 +0200311 bool use_cts_prot;
312 int num_legacy_stations;
Michal Kazior7d9d5582014-10-21 10:40:15 +0300313 int txpower;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300314};
315
316struct ath10k_vif_iter {
317 u32 vdev_id;
318 struct ath10k_vif *arvif;
319};
320
Ben Greear384914b2014-08-25 08:37:32 +0300321/* used for crash-dump storage, protected by data-lock */
322struct ath10k_fw_crash_data {
323 bool crashed_since_read;
324
325 uuid_le uuid;
326 struct timespec timestamp;
327 __le32 registers[REG_DUMP_COUNT_QCA988X];
328};
329
Kalle Valo5e3dd152013-06-12 20:52:10 +0300330struct ath10k_debug {
331 struct dentry *debugfs_phy;
332
Michal Kazior60ef4012014-09-25 12:33:48 +0200333 struct ath10k_fw_stats fw_stats;
334 struct completion fw_stats_complete;
Michal Kazior53268492014-09-25 12:33:50 +0200335 bool fw_stats_done;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300336
Kalle Valoa3d135e2013-09-03 11:44:10 +0300337 unsigned long htt_stats_mask;
338 struct delayed_work htt_stats_dwork;
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200339 struct ath10k_dfs_stats dfs_stats;
340 struct ath_dfs_pool_stats dfs_pool_stats;
Kalle Valof118a3e2014-01-03 12:59:31 +0200341
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300342 /* protected by conf_mutex */
Kalle Valof118a3e2014-01-03 12:59:31 +0200343 u32 fw_dbglog_mask;
Rajkumar Manoharan90174452014-10-03 08:02:33 +0300344 u32 pktlog_filter;
Yanbo Li077a3802014-11-25 12:24:33 +0200345 u32 reg_addr;
Peter Oha7bd3e92014-12-02 13:07:14 +0200346 u32 nf_cal_period;
Janusz Dziedzicd3856232014-06-02 21:19:46 +0300347
348 u8 htt_max_amsdu;
349 u8 htt_max_ampdu;
Ben Greear384914b2014-08-25 08:37:32 +0300350
351 struct ath10k_fw_crash_data *fw_crash_data;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300352};
353
Michal Kaziorf7843d72013-07-16 09:38:52 +0200354enum ath10k_state {
355 ATH10K_STATE_OFF = 0,
356 ATH10K_STATE_ON,
Michal Kazioraffd3212013-07-16 09:54:35 +0200357
358 /* When doing firmware recovery the device is first powered down.
359 * mac80211 is supposed to call in to start() hook later on. It is
360 * however possible that driver unloading and firmware crash overlap.
361 * mac80211 can wait on conf_mutex in stop() while the device is
362 * stopped in ath10k_core_restart() work holding conf_mutex. The state
363 * RESTARTED means that the device is up and mac80211 has started hw
364 * reconfiguration. Once mac80211 is done with the reconfiguration we
Eliad Pellercf2c92d2014-11-04 11:43:54 +0200365 * set the state to STATE_ON in reconfig_complete(). */
Michal Kazioraffd3212013-07-16 09:54:35 +0200366 ATH10K_STATE_RESTARTING,
367 ATH10K_STATE_RESTARTED,
368
369 /* The device has crashed while restarting hw. This state is like ON
370 * but commands are blocked in HTC and -ECOMM response is given. This
371 * prevents completion timeouts and makes the driver more responsive to
372 * userspace commands. This is also prevents recursive recovery. */
373 ATH10K_STATE_WEDGED,
Kalle Valo43d2a302014-09-10 18:23:30 +0300374
375 /* factory tests */
376 ATH10K_STATE_UTF,
377};
378
379enum ath10k_firmware_mode {
380 /* the default mode, standard 802.11 functionality */
381 ATH10K_FIRMWARE_MODE_NORMAL,
382
383 /* factory tests etc */
384 ATH10K_FIRMWARE_MODE_UTF,
Michal Kaziorf7843d72013-07-16 09:38:52 +0200385};
386
Michal Kazior0d9b0432013-08-09 10:13:33 +0200387enum ath10k_fw_features {
388 /* wmi_mgmt_rx_hdr contains extra RSSI information */
389 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
390
Kalle Valo202e86e2014-12-03 10:10:08 +0200391 /* Firmware from 10X branch. Deprecated, don't use in new code. */
Bartosz Markowskice428702013-09-26 17:47:05 +0200392 ATH10K_FW_FEATURE_WMI_10X = 1,
393
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200394 /* firmware support tx frame management over WMI, otherwise it's HTT */
395 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
396
Bartosz Markowskid3541812013-12-10 16:20:40 +0100397 /* Firmware does not support P2P */
398 ATH10K_FW_FEATURE_NO_P2P = 3,
399
Kalle Valo202e86e2014-12-03 10:10:08 +0200400 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
401 * bit is required to be set as well. Deprecated, don't use in new
402 * code.
Michal Kazior24c88f72014-07-25 13:32:17 +0200403 */
404 ATH10K_FW_FEATURE_WMI_10_2 = 4,
405
Michal Kazior0d9b0432013-08-09 10:13:33 +0200406 /* keep last */
407 ATH10K_FW_FEATURE_COUNT,
408};
409
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200410enum ath10k_dev_flags {
411 /* Indicates that ath10k device is during CAC phase of DFS */
412 ATH10K_CAC_RUNNING,
Michal Kazior6782cb62014-05-23 12:28:47 +0200413 ATH10K_FLAG_CORE_REGISTERED,
Michal Kazior7962b0d2014-10-28 10:34:38 +0100414
415 /* Device has crashed and needs to restart. This indicates any pending
416 * waiters should immediately cancel instead of waiting for a time out.
417 */
418 ATH10K_FLAG_CRASH_FLUSH,
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200419};
420
Kalle Valoa58227e2014-10-13 09:40:59 +0300421enum ath10k_cal_mode {
422 ATH10K_CAL_MODE_FILE,
423 ATH10K_CAL_MODE_OTP,
Toshi Kikuchi5aabff02014-12-02 10:55:54 +0200424 ATH10K_CAL_MODE_DT,
Kalle Valoa58227e2014-10-13 09:40:59 +0300425};
426
427static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
428{
429 switch (mode) {
430 case ATH10K_CAL_MODE_FILE:
431 return "file";
432 case ATH10K_CAL_MODE_OTP:
433 return "otp";
Toshi Kikuchi5aabff02014-12-02 10:55:54 +0200434 case ATH10K_CAL_MODE_DT:
435 return "dt";
Kalle Valoa58227e2014-10-13 09:40:59 +0300436 }
437
438 return "unknown";
439}
440
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200441enum ath10k_scan_state {
442 ATH10K_SCAN_IDLE,
443 ATH10K_SCAN_STARTING,
444 ATH10K_SCAN_RUNNING,
445 ATH10K_SCAN_ABORTING,
446};
447
448static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
449{
450 switch (state) {
451 case ATH10K_SCAN_IDLE:
452 return "idle";
453 case ATH10K_SCAN_STARTING:
454 return "starting";
455 case ATH10K_SCAN_RUNNING:
456 return "running";
457 case ATH10K_SCAN_ABORTING:
458 return "aborting";
459 }
460
461 return "unknown";
462}
463
Kalle Valo5e3dd152013-06-12 20:52:10 +0300464struct ath10k {
465 struct ath_common ath_common;
466 struct ieee80211_hw *hw;
467 struct device *dev;
468 u8 mac_addr[ETH_ALEN];
469
Kalle Valoe01ae682013-09-01 11:22:14 +0300470 u32 chip_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300471 u32 target_version;
472 u8 fw_version_major;
473 u32 fw_version_minor;
474 u16 fw_version_release;
475 u16 fw_version_build;
476 u32 phy_capability;
477 u32 hw_min_tx_power;
478 u32 hw_max_tx_power;
479 u32 ht_cap_info;
480 u32 vht_cap_info;
Michal Kazior8865bee42013-07-24 12:36:46 +0200481 u32 num_rf_chains;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300482
Michal Kazior0d9b0432013-08-09 10:13:33 +0200483 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
484
Kalle Valo5e3dd152013-06-12 20:52:10 +0300485 struct targetdef *targetdef;
486 struct hostdef *hostdef;
487
488 bool p2p;
489
490 struct {
Kalle Valoe07db352014-10-13 09:40:47 +0300491 enum ath10k_bus bus;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300492 const struct ath10k_hif_ops *ops;
493 } hif;
494
Marek Puzyniak9042e172014-02-10 17:14:23 +0100495 struct completion target_suspend;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300496
497 struct ath10k_bmi bmi;
Michal Kazioredb82362013-07-05 16:15:14 +0300498 struct ath10k_wmi wmi;
Michal Kaziorcd003fa2013-07-05 16:15:13 +0300499 struct ath10k_htc htc;
Michal Kazioredb82362013-07-05 16:15:14 +0300500 struct ath10k_htt htt;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300501
502 struct ath10k_hw_params {
503 u32 id;
504 const char *name;
505 u32 patch_load_addr;
Michal Kazior3a8200b2014-12-02 10:55:55 +0200506 int uart_pin;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300507
508 struct ath10k_hw_params_fw {
509 const char *dir;
510 const char *fw;
511 const char *otp;
512 const char *board;
Michal Kazior9764a2a2014-12-02 10:55:54 +0200513 size_t board_size;
514 size_t board_ext_size;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300515 } fw;
516 } hw_params;
517
Kalle Valo36527912013-09-27 19:54:55 +0300518 const struct firmware *board;
Kalle Valo958df3a2013-09-27 19:55:01 +0300519 const void *board_data;
520 size_t board_len;
521
Michal Kazior29385052013-07-16 09:38:58 +0200522 const struct firmware *otp;
Kalle Valo958df3a2013-09-27 19:55:01 +0300523 const void *otp_data;
524 size_t otp_len;
525
Michal Kazior29385052013-07-16 09:38:58 +0200526 const struct firmware *firmware;
Kalle Valo958df3a2013-09-27 19:55:01 +0300527 const void *firmware_data;
528 size_t firmware_len;
Michal Kazior29385052013-07-16 09:38:58 +0200529
Kalle Valoa58227e2014-10-13 09:40:59 +0300530 const struct firmware *cal_file;
531
Kalle Valo1a222432013-09-27 19:55:07 +0300532 int fw_api;
Kalle Valoa58227e2014-10-13 09:40:59 +0300533 enum ath10k_cal_mode cal_mode;
Kalle Valo1a222432013-09-27 19:55:07 +0300534
Kalle Valo5e3dd152013-06-12 20:52:10 +0300535 struct {
536 struct completion started;
537 struct completion completed;
538 struct completion on_channel;
Michal Kazior5c81c7f2014-08-05 14:54:44 +0200539 struct delayed_work timeout;
540 enum ath10k_scan_state state;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300541 bool is_roc;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300542 int vdev_id;
543 int roc_freq;
544 } scan;
545
546 struct {
547 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
548 } mac;
549
550 /* should never be NULL; needed for regular htt rx */
551 struct ieee80211_channel *rx_channel;
552
553 /* valid during scan; needed for mgmt rx during scan */
554 struct ieee80211_channel *scan_channel;
555
Michal Kaziorc930f742014-01-23 11:38:25 +0100556 /* current operating channel definition */
557 struct cfg80211_chan_def chandef;
558
Ben Greear16c11172014-09-23 14:17:16 -0700559 unsigned long long free_vdev_map;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300560 bool monitor;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300561 int monitor_vdev_id;
Michal Kazior1bbc0972014-04-08 09:45:47 +0300562 bool monitor_started;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300563 unsigned int filter_flags;
Marek Puzyniake8a50f82013-11-20 09:59:47 +0200564 unsigned long dev_flags;
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +0200565 u32 dfs_block_radar_events;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300566
Michal Kaziord6500972014-04-08 09:56:09 +0300567 /* protected by conf_mutex */
568 bool radar_enabled;
569 int num_started_vdevs;
570
Ben Greear46acf7b2014-05-16 17:15:38 +0300571 /* Protected by conf-mutex */
572 u8 supp_tx_chainmask;
573 u8 supp_rx_chainmask;
574 u8 cfg_tx_chainmask;
575 u8 cfg_rx_chainmask;
576
Kalle Valo5e3dd152013-06-12 20:52:10 +0300577 struct wmi_pdev_set_wmm_params_arg wmm_params;
578 struct completion install_key_done;
579
580 struct completion vdev_setup_done;
581
582 struct workqueue_struct *workqueue;
583
584 /* prevents concurrent FW reconfiguration */
585 struct mutex conf_mutex;
586
587 /* protects shared structure data */
588 spinlock_t data_lock;
589
Michal Kazior05791192013-10-16 15:44:45 +0300590 struct list_head arvifs;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300591 struct list_head peers;
592 wait_queue_head_t peer_mapping_wq;
593
Michal Kazior292a7532014-11-25 15:16:04 +0100594 /* protected by conf_mutex */
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100595 int num_peers;
Michal Kaziorcfd10612014-11-25 15:16:05 +0100596 int num_stations;
597
598 int max_num_peers;
599 int max_num_stations;
Kalle Valo30c78162014-12-17 12:20:45 +0200600 int max_num_vdevs;
Bartosz Markowski0e759f32014-01-02 14:38:33 +0100601
Kalle Valo5e3dd152013-06-12 20:52:10 +0300602 struct work_struct offchan_tx_work;
603 struct sk_buff_head offchan_tx_queue;
604 struct completion offchan_tx_completed;
605 struct sk_buff *offchan_tx_skb;
606
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200607 struct work_struct wmi_mgmt_tx_work;
608 struct sk_buff_head wmi_mgmt_tx_queue;
609
Michal Kaziorf7843d72013-07-16 09:38:52 +0200610 enum ath10k_state state;
611
Michal Kazior6782cb62014-05-23 12:28:47 +0200612 struct work_struct register_work;
Michal Kazioraffd3212013-07-16 09:54:35 +0200613 struct work_struct restart_work;
614
Michal Kazior2e1dea42013-07-31 10:32:40 +0200615 /* cycle count is reported twice for each visited channel during scan.
616 * access protected by data_lock */
617 u32 survey_last_rx_clear_count;
618 u32 survey_last_cycle_count;
619 struct survey_info survey[ATH10K_NUM_CHANS];
620
Janusz Dziedzic9702c682013-11-20 09:59:41 +0200621 struct dfs_pattern_detector *dfs_detector;
622
Kalle Valo5e3dd152013-06-12 20:52:10 +0300623#ifdef CONFIG_ATH10K_DEBUGFS
624 struct ath10k_debug debug;
625#endif
Simon Wunderlich855aed12014-08-02 09:12:54 +0300626
627 struct {
628 /* relay(fs) channel for spectral scan */
629 struct rchan *rfs_chan_spec_scan;
630
631 /* spectral_mode and spec_config are protected by conf_mutex */
632 enum ath10k_spectral_mode mode;
633 struct ath10k_spec_scan config;
634 } spectral;
Michal Kaziore7b54192014-08-07 11:03:27 +0200635
Kalle Valo43d2a302014-09-10 18:23:30 +0300636 struct {
637 /* protected by conf_mutex */
638 const struct firmware *utf;
639 DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
Michal Kaziord7579d12014-12-03 10:10:54 +0200640 enum ath10k_fw_wmi_op_version orig_wmi_op_version;
Kalle Valo43d2a302014-09-10 18:23:30 +0300641
642 /* protected by data_lock */
643 bool utf_monitor;
644 } testmode;
645
Ben Greearf51dbe72014-09-29 14:41:46 +0300646 struct {
647 /* protected by data_lock */
648 u32 fw_crash_counter;
649 u32 fw_warm_reset_counter;
650 u32 fw_cold_reset_counter;
651 } stats;
652
Rajkumar Manoharanfe6f36d2014-12-17 12:22:07 +0200653 struct ath10k_thermal thermal;
654
Michal Kaziore7b54192014-08-07 11:03:27 +0200655 /* must be last */
656 u8 drv_priv[0] __aligned(sizeof(void *));
Kalle Valo5e3dd152013-06-12 20:52:10 +0300657};
658
Michal Kaziore7b54192014-08-07 11:03:27 +0200659struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
Kalle Valoe07db352014-10-13 09:40:47 +0300660 enum ath10k_bus bus,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300661 const struct ath10k_hif_ops *hif_ops);
662void ath10k_core_destroy(struct ath10k *ar);
663
Kalle Valo43d2a302014-09-10 18:23:30 +0300664int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
Marek Puzyniak00f54822014-02-10 17:14:24 +0100665int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
Michal Kaziordd30a362013-07-16 09:38:51 +0200666void ath10k_core_stop(struct ath10k *ar);
Kalle Valoe01ae682013-09-01 11:22:14 +0300667int ath10k_core_register(struct ath10k *ar, u32 chip_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300668void ath10k_core_unregister(struct ath10k *ar);
669
Kalle Valo5e3dd152013-06-12 20:52:10 +0300670#endif /* _CORE_H_ */