Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1 | /* |
| 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 Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 25 | #include <linux/uuid.h> |
| 26 | #include <linux/time.h> |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 27 | |
Michal Kazior | edb8236 | 2013-07-05 16:15:14 +0300 | [diff] [blame] | 28 | #include "htt.h" |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 29 | #include "htc.h" |
| 30 | #include "hw.h" |
| 31 | #include "targaddrs.h" |
| 32 | #include "wmi.h" |
| 33 | #include "../ath.h" |
| 34 | #include "../regd.h" |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 35 | #include "../dfs_pattern_detector.h" |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 36 | #include "spectral.h" |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 37 | |
| 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 Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 45 | #define ATH10K_NUM_CHANS 38 |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 46 | |
| 47 | /* Antenna noise floor */ |
| 48 | #define ATH10K_DEFAULT_NOISE_FLOOR -95 |
| 49 | |
Bartosz Markowski | 7109861 | 2013-11-14 09:01:15 +0100 | [diff] [blame] | 50 | #define ATH10K_MAX_NUM_MGMT_PENDING 128 |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 51 | |
Kalle Valo | 5a13e76 | 2014-01-20 11:01:46 +0200 | [diff] [blame] | 52 | /* 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 Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 64 | struct ath10k; |
| 65 | |
Kalle Valo | e07db35 | 2014-10-13 09:40:47 +0300 | [diff] [blame] | 66 | enum ath10k_bus { |
| 67 | ATH10K_BUS_PCI, |
| 68 | }; |
| 69 | |
| 70 | static 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 Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 80 | struct ath10k_skb_cb { |
| 81 | dma_addr_t paddr; |
Michal Kazior | d84a512 | 2014-11-27 11:09:37 +0100 | [diff] [blame] | 82 | u8 eid; |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 83 | u8 vdev_id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 84 | |
| 85 | struct { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 86 | u8 tid; |
Michal Kazior | 8d6d362 | 2014-11-24 14:58:31 +0100 | [diff] [blame] | 87 | u16 freq; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 88 | bool is_offchan; |
Michal Kazior | a16942e | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 89 | struct ath10k_htt_txbuf *txbuf; |
| 90 | u32 txbuf_paddr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 91 | } __packed htt; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 92 | |
| 93 | struct { |
| 94 | bool dtim_zero; |
| 95 | bool deliver_cab; |
| 96 | } bcn; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 97 | } __packed; |
| 98 | |
| 99 | static 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 Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 106 | static inline u32 host_interest_item_address(u32 item_offset) |
| 107 | { |
| 108 | return QCA988X_HOST_INTEREST_ADDRESS + item_offset; |
| 109 | } |
| 110 | |
| 111 | struct ath10k_bmi { |
| 112 | bool done_sent; |
| 113 | }; |
| 114 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 115 | struct ath10k_mem_chunk { |
| 116 | void *vaddr; |
| 117 | dma_addr_t paddr; |
| 118 | u32 len; |
| 119 | u32 req_id; |
| 120 | }; |
| 121 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 122 | struct ath10k_wmi { |
| 123 | enum ath10k_htc_ep_id eid; |
| 124 | struct completion service_ready; |
| 125 | struct completion unified_ready; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 126 | wait_queue_head_t tx_credits_wq; |
Michal Kazior | acfe7ec | 2014-11-27 10:11:17 +0100 | [diff] [blame] | 127 | DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 128 | struct wmi_cmd_map *cmd; |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 129 | struct wmi_vdev_param_map *vdev_param; |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 130 | struct wmi_pdev_param_map *pdev_param; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 131 | |
| 132 | u32 num_mem_chunks; |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 133 | struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS]; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 134 | }; |
| 135 | |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 136 | struct ath10k_fw_stats_peer { |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 137 | struct list_head list; |
| 138 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 139 | u8 peer_macaddr[ETH_ALEN]; |
| 140 | u32 peer_rssi; |
| 141 | u32 peer_tx_rate; |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 142 | u32 peer_rx_rate; /* 10x only */ |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 143 | }; |
| 144 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 145 | struct ath10k_fw_stats_pdev { |
| 146 | struct list_head list; |
| 147 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 148 | /* PDEV stats */ |
| 149 | s32 ch_noise_floor; |
| 150 | u32 tx_frame_count; |
| 151 | u32 rx_frame_count; |
| 152 | u32 rx_clear_count; |
| 153 | u32 cycle_count; |
| 154 | u32 phy_err_count; |
| 155 | u32 chan_tx_power; |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 156 | u32 ack_rx_bad; |
| 157 | u32 rts_bad; |
| 158 | u32 rts_good; |
| 159 | u32 fcs_bad; |
| 160 | u32 no_beacons; |
| 161 | u32 mib_int_count; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 162 | |
| 163 | /* PDEV TX stats */ |
| 164 | s32 comp_queued; |
| 165 | s32 comp_delivered; |
| 166 | s32 msdu_enqued; |
| 167 | s32 mpdu_enqued; |
| 168 | s32 wmm_drop; |
| 169 | s32 local_enqued; |
| 170 | s32 local_freed; |
| 171 | s32 hw_queued; |
| 172 | s32 hw_reaped; |
| 173 | s32 underrun; |
| 174 | s32 tx_abort; |
| 175 | s32 mpdus_requed; |
| 176 | u32 tx_ko; |
| 177 | u32 data_rc; |
| 178 | u32 self_triggers; |
| 179 | u32 sw_retry_failure; |
| 180 | u32 illgl_rate_phy_err; |
| 181 | u32 pdev_cont_xretry; |
| 182 | u32 pdev_tx_timeout; |
| 183 | u32 pdev_resets; |
| 184 | u32 phy_underrun; |
| 185 | u32 txop_ovf; |
| 186 | |
| 187 | /* PDEV RX stats */ |
| 188 | s32 mid_ppdu_route_change; |
| 189 | s32 status_rcvd; |
| 190 | s32 r0_frags; |
| 191 | s32 r1_frags; |
| 192 | s32 r2_frags; |
| 193 | s32 r3_frags; |
| 194 | s32 htt_msdus; |
| 195 | s32 htt_mpdus; |
| 196 | s32 loc_msdus; |
| 197 | s32 loc_mpdus; |
| 198 | s32 oversize_amsdu; |
| 199 | s32 phy_errs; |
| 200 | s32 phy_err_drop; |
| 201 | s32 mpdu_errs; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 202 | }; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 203 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 204 | struct ath10k_fw_stats { |
| 205 | struct list_head pdevs; |
| 206 | struct list_head peers; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 207 | }; |
| 208 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 209 | struct ath10k_dfs_stats { |
| 210 | u32 phy_errors; |
| 211 | u32 pulses_total; |
| 212 | u32 pulses_detected; |
| 213 | u32 pulses_discarded; |
| 214 | u32 radar_detected; |
| 215 | }; |
| 216 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 217 | #define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */ |
| 218 | |
| 219 | struct ath10k_peer { |
| 220 | struct list_head list; |
| 221 | int vdev_id; |
| 222 | u8 addr[ETH_ALEN]; |
| 223 | DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS); |
Sujith Manoharan | ae16713 | 2014-11-25 11:46:59 +0530 | [diff] [blame] | 224 | |
| 225 | /* protected by ar->data_lock */ |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 226 | struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1]; |
| 227 | }; |
| 228 | |
Michal Kazior | 9797feb | 2014-02-14 14:49:48 +0100 | [diff] [blame] | 229 | struct ath10k_sta { |
| 230 | struct ath10k_vif *arvif; |
| 231 | |
| 232 | /* the following are protected by ar->data_lock */ |
| 233 | u32 changed; /* IEEE80211_RC_* */ |
| 234 | u32 bw; |
| 235 | u32 nss; |
| 236 | u32 smps; |
| 237 | |
| 238 | struct work_struct update_wk; |
| 239 | }; |
| 240 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 241 | #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ) |
| 242 | |
| 243 | struct ath10k_vif { |
Michal Kazior | 0579119 | 2013-10-16 15:44:45 +0300 | [diff] [blame] | 244 | struct list_head list; |
| 245 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 246 | u32 vdev_id; |
| 247 | enum wmi_vdev_type vdev_type; |
| 248 | enum wmi_vdev_subtype vdev_subtype; |
| 249 | u32 beacon_interval; |
| 250 | u32 dtim_period; |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 251 | struct sk_buff *beacon; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 252 | /* protected by data_lock */ |
| 253 | bool beacon_sent; |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 254 | void *beacon_buf; |
| 255 | dma_addr_t beacon_paddr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 256 | |
| 257 | struct ath10k *ar; |
| 258 | struct ieee80211_vif *vif; |
| 259 | |
Michal Kazior | c930f74 | 2014-01-23 11:38:25 +0100 | [diff] [blame] | 260 | bool is_started; |
| 261 | bool is_up; |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 262 | bool spectral_enabled; |
Michal Kazior | c930f74 | 2014-01-23 11:38:25 +0100 | [diff] [blame] | 263 | u32 aid; |
| 264 | u8 bssid[ETH_ALEN]; |
| 265 | |
Michal Kazior | cc4827b | 2013-10-16 15:44:45 +0300 | [diff] [blame] | 266 | struct work_struct wep_key_work; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 267 | struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1]; |
Michal Kazior | cc4827b | 2013-10-16 15:44:45 +0300 | [diff] [blame] | 268 | u8 def_wep_key_idx; |
| 269 | u8 def_wep_key_newidx; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 270 | |
| 271 | u16 tx_seq_no; |
| 272 | |
| 273 | union { |
| 274 | struct { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 275 | u32 uapsd; |
| 276 | } sta; |
| 277 | struct { |
| 278 | /* 127 stations; wmi limit */ |
| 279 | u8 tim_bitmap[16]; |
| 280 | u8 tim_len; |
| 281 | u32 ssid_len; |
| 282 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
| 283 | bool hidden_ssid; |
| 284 | /* P2P_IE with NoA attribute for P2P_GO case */ |
| 285 | u32 noa_len; |
| 286 | u8 *noa_data; |
| 287 | } ap; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 288 | } u; |
Janusz Dziedzic | 51ab1a0 | 2014-01-08 09:08:33 +0100 | [diff] [blame] | 289 | |
| 290 | u8 fixed_rate; |
| 291 | u8 fixed_nss; |
Janusz Dziedzic | 9f81f72 | 2014-01-17 20:04:14 +0100 | [diff] [blame] | 292 | u8 force_sgi; |
Marek Kwaczynski | e81bd10 | 2014-03-11 12:58:00 +0200 | [diff] [blame] | 293 | bool use_cts_prot; |
| 294 | int num_legacy_stations; |
Michal Kazior | 7d9d558 | 2014-10-21 10:40:15 +0300 | [diff] [blame] | 295 | int txpower; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | struct ath10k_vif_iter { |
| 299 | u32 vdev_id; |
| 300 | struct ath10k_vif *arvif; |
| 301 | }; |
| 302 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 303 | /* used for crash-dump storage, protected by data-lock */ |
| 304 | struct ath10k_fw_crash_data { |
| 305 | bool crashed_since_read; |
| 306 | |
| 307 | uuid_le uuid; |
| 308 | struct timespec timestamp; |
| 309 | __le32 registers[REG_DUMP_COUNT_QCA988X]; |
| 310 | }; |
| 311 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 312 | struct ath10k_debug { |
| 313 | struct dentry *debugfs_phy; |
| 314 | |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 315 | struct ath10k_fw_stats fw_stats; |
| 316 | struct completion fw_stats_complete; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 317 | bool fw_stats_done; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 318 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 319 | unsigned long htt_stats_mask; |
| 320 | struct delayed_work htt_stats_dwork; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 321 | struct ath10k_dfs_stats dfs_stats; |
| 322 | struct ath_dfs_pool_stats dfs_pool_stats; |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 323 | |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 324 | /* protected by conf_mutex */ |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 325 | u32 fw_dbglog_mask; |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 326 | u32 pktlog_filter; |
Yanbo Li | 077a380 | 2014-11-25 12:24:33 +0200 | [diff] [blame] | 327 | u32 reg_addr; |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 328 | |
| 329 | u8 htt_max_amsdu; |
| 330 | u8 htt_max_ampdu; |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 331 | |
| 332 | struct ath10k_fw_crash_data *fw_crash_data; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 333 | }; |
| 334 | |
Michal Kazior | f7843d7 | 2013-07-16 09:38:52 +0200 | [diff] [blame] | 335 | enum ath10k_state { |
| 336 | ATH10K_STATE_OFF = 0, |
| 337 | ATH10K_STATE_ON, |
Michal Kazior | affd321 | 2013-07-16 09:54:35 +0200 | [diff] [blame] | 338 | |
| 339 | /* When doing firmware recovery the device is first powered down. |
| 340 | * mac80211 is supposed to call in to start() hook later on. It is |
| 341 | * however possible that driver unloading and firmware crash overlap. |
| 342 | * mac80211 can wait on conf_mutex in stop() while the device is |
| 343 | * stopped in ath10k_core_restart() work holding conf_mutex. The state |
| 344 | * RESTARTED means that the device is up and mac80211 has started hw |
| 345 | * reconfiguration. Once mac80211 is done with the reconfiguration we |
Eliad Peller | cf2c92d | 2014-11-04 11:43:54 +0200 | [diff] [blame] | 346 | * set the state to STATE_ON in reconfig_complete(). */ |
Michal Kazior | affd321 | 2013-07-16 09:54:35 +0200 | [diff] [blame] | 347 | ATH10K_STATE_RESTARTING, |
| 348 | ATH10K_STATE_RESTARTED, |
| 349 | |
| 350 | /* The device has crashed while restarting hw. This state is like ON |
| 351 | * but commands are blocked in HTC and -ECOMM response is given. This |
| 352 | * prevents completion timeouts and makes the driver more responsive to |
| 353 | * userspace commands. This is also prevents recursive recovery. */ |
| 354 | ATH10K_STATE_WEDGED, |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 355 | |
| 356 | /* factory tests */ |
| 357 | ATH10K_STATE_UTF, |
| 358 | }; |
| 359 | |
| 360 | enum ath10k_firmware_mode { |
| 361 | /* the default mode, standard 802.11 functionality */ |
| 362 | ATH10K_FIRMWARE_MODE_NORMAL, |
| 363 | |
| 364 | /* factory tests etc */ |
| 365 | ATH10K_FIRMWARE_MODE_UTF, |
Michal Kazior | f7843d7 | 2013-07-16 09:38:52 +0200 | [diff] [blame] | 366 | }; |
| 367 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 368 | enum ath10k_fw_features { |
| 369 | /* wmi_mgmt_rx_hdr contains extra RSSI information */ |
| 370 | ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0, |
| 371 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 372 | /* firmware from 10X branch */ |
| 373 | ATH10K_FW_FEATURE_WMI_10X = 1, |
| 374 | |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 375 | /* firmware support tx frame management over WMI, otherwise it's HTT */ |
| 376 | ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2, |
| 377 | |
Bartosz Markowski | d354181 | 2013-12-10 16:20:40 +0100 | [diff] [blame] | 378 | /* Firmware does not support P2P */ |
| 379 | ATH10K_FW_FEATURE_NO_P2P = 3, |
| 380 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 381 | /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature bit |
| 382 | * is required to be set as well. |
| 383 | */ |
| 384 | ATH10K_FW_FEATURE_WMI_10_2 = 4, |
| 385 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 386 | /* keep last */ |
| 387 | ATH10K_FW_FEATURE_COUNT, |
| 388 | }; |
| 389 | |
Marek Puzyniak | e8a50f8 | 2013-11-20 09:59:47 +0200 | [diff] [blame] | 390 | enum ath10k_dev_flags { |
| 391 | /* Indicates that ath10k device is during CAC phase of DFS */ |
| 392 | ATH10K_CAC_RUNNING, |
Michal Kazior | 6782cb6 | 2014-05-23 12:28:47 +0200 | [diff] [blame] | 393 | ATH10K_FLAG_CORE_REGISTERED, |
Michal Kazior | 7962b0d | 2014-10-28 10:34:38 +0100 | [diff] [blame] | 394 | |
| 395 | /* Device has crashed and needs to restart. This indicates any pending |
| 396 | * waiters should immediately cancel instead of waiting for a time out. |
| 397 | */ |
| 398 | ATH10K_FLAG_CRASH_FLUSH, |
Marek Puzyniak | e8a50f8 | 2013-11-20 09:59:47 +0200 | [diff] [blame] | 399 | }; |
| 400 | |
Kalle Valo | a58227e | 2014-10-13 09:40:59 +0300 | [diff] [blame] | 401 | enum ath10k_cal_mode { |
| 402 | ATH10K_CAL_MODE_FILE, |
| 403 | ATH10K_CAL_MODE_OTP, |
Toshi Kikuchi | 5aabff0 | 2014-12-02 10:55:54 +0200 | [diff] [blame] | 404 | ATH10K_CAL_MODE_DT, |
Kalle Valo | a58227e | 2014-10-13 09:40:59 +0300 | [diff] [blame] | 405 | }; |
| 406 | |
| 407 | static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode) |
| 408 | { |
| 409 | switch (mode) { |
| 410 | case ATH10K_CAL_MODE_FILE: |
| 411 | return "file"; |
| 412 | case ATH10K_CAL_MODE_OTP: |
| 413 | return "otp"; |
Toshi Kikuchi | 5aabff0 | 2014-12-02 10:55:54 +0200 | [diff] [blame] | 414 | case ATH10K_CAL_MODE_DT: |
| 415 | return "dt"; |
Kalle Valo | a58227e | 2014-10-13 09:40:59 +0300 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | return "unknown"; |
| 419 | } |
| 420 | |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 421 | enum ath10k_scan_state { |
| 422 | ATH10K_SCAN_IDLE, |
| 423 | ATH10K_SCAN_STARTING, |
| 424 | ATH10K_SCAN_RUNNING, |
| 425 | ATH10K_SCAN_ABORTING, |
| 426 | }; |
| 427 | |
| 428 | static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state) |
| 429 | { |
| 430 | switch (state) { |
| 431 | case ATH10K_SCAN_IDLE: |
| 432 | return "idle"; |
| 433 | case ATH10K_SCAN_STARTING: |
| 434 | return "starting"; |
| 435 | case ATH10K_SCAN_RUNNING: |
| 436 | return "running"; |
| 437 | case ATH10K_SCAN_ABORTING: |
| 438 | return "aborting"; |
| 439 | } |
| 440 | |
| 441 | return "unknown"; |
| 442 | } |
| 443 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 444 | struct ath10k { |
| 445 | struct ath_common ath_common; |
| 446 | struct ieee80211_hw *hw; |
| 447 | struct device *dev; |
| 448 | u8 mac_addr[ETH_ALEN]; |
| 449 | |
Kalle Valo | e01ae68 | 2013-09-01 11:22:14 +0300 | [diff] [blame] | 450 | u32 chip_id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 451 | u32 target_version; |
| 452 | u8 fw_version_major; |
| 453 | u32 fw_version_minor; |
| 454 | u16 fw_version_release; |
| 455 | u16 fw_version_build; |
| 456 | u32 phy_capability; |
| 457 | u32 hw_min_tx_power; |
| 458 | u32 hw_max_tx_power; |
| 459 | u32 ht_cap_info; |
| 460 | u32 vht_cap_info; |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 461 | u32 num_rf_chains; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 462 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 463 | DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT); |
| 464 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 465 | struct targetdef *targetdef; |
| 466 | struct hostdef *hostdef; |
| 467 | |
| 468 | bool p2p; |
| 469 | |
| 470 | struct { |
Kalle Valo | e07db35 | 2014-10-13 09:40:47 +0300 | [diff] [blame] | 471 | enum ath10k_bus bus; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 472 | const struct ath10k_hif_ops *ops; |
| 473 | } hif; |
| 474 | |
Marek Puzyniak | 9042e17 | 2014-02-10 17:14:23 +0100 | [diff] [blame] | 475 | struct completion target_suspend; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 476 | |
| 477 | struct ath10k_bmi bmi; |
Michal Kazior | edb8236 | 2013-07-05 16:15:14 +0300 | [diff] [blame] | 478 | struct ath10k_wmi wmi; |
Michal Kazior | cd003fa | 2013-07-05 16:15:13 +0300 | [diff] [blame] | 479 | struct ath10k_htc htc; |
Michal Kazior | edb8236 | 2013-07-05 16:15:14 +0300 | [diff] [blame] | 480 | struct ath10k_htt htt; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 481 | |
| 482 | struct ath10k_hw_params { |
| 483 | u32 id; |
| 484 | const char *name; |
| 485 | u32 patch_load_addr; |
| 486 | |
| 487 | struct ath10k_hw_params_fw { |
| 488 | const char *dir; |
| 489 | const char *fw; |
| 490 | const char *otp; |
| 491 | const char *board; |
Michal Kazior | 9764a2a | 2014-12-02 10:55:54 +0200 | [diff] [blame^] | 492 | size_t board_size; |
| 493 | size_t board_ext_size; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 494 | } fw; |
| 495 | } hw_params; |
| 496 | |
Kalle Valo | 3652791 | 2013-09-27 19:54:55 +0300 | [diff] [blame] | 497 | const struct firmware *board; |
Kalle Valo | 958df3a | 2013-09-27 19:55:01 +0300 | [diff] [blame] | 498 | const void *board_data; |
| 499 | size_t board_len; |
| 500 | |
Michal Kazior | 2938505 | 2013-07-16 09:38:58 +0200 | [diff] [blame] | 501 | const struct firmware *otp; |
Kalle Valo | 958df3a | 2013-09-27 19:55:01 +0300 | [diff] [blame] | 502 | const void *otp_data; |
| 503 | size_t otp_len; |
| 504 | |
Michal Kazior | 2938505 | 2013-07-16 09:38:58 +0200 | [diff] [blame] | 505 | const struct firmware *firmware; |
Kalle Valo | 958df3a | 2013-09-27 19:55:01 +0300 | [diff] [blame] | 506 | const void *firmware_data; |
| 507 | size_t firmware_len; |
Michal Kazior | 2938505 | 2013-07-16 09:38:58 +0200 | [diff] [blame] | 508 | |
Kalle Valo | a58227e | 2014-10-13 09:40:59 +0300 | [diff] [blame] | 509 | const struct firmware *cal_file; |
| 510 | |
Kalle Valo | 1a22243 | 2013-09-27 19:55:07 +0300 | [diff] [blame] | 511 | int fw_api; |
Kalle Valo | a58227e | 2014-10-13 09:40:59 +0300 | [diff] [blame] | 512 | enum ath10k_cal_mode cal_mode; |
Kalle Valo | 1a22243 | 2013-09-27 19:55:07 +0300 | [diff] [blame] | 513 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 514 | struct { |
| 515 | struct completion started; |
| 516 | struct completion completed; |
| 517 | struct completion on_channel; |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 518 | struct delayed_work timeout; |
| 519 | enum ath10k_scan_state state; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 520 | bool is_roc; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 521 | int vdev_id; |
| 522 | int roc_freq; |
| 523 | } scan; |
| 524 | |
| 525 | struct { |
| 526 | struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; |
| 527 | } mac; |
| 528 | |
| 529 | /* should never be NULL; needed for regular htt rx */ |
| 530 | struct ieee80211_channel *rx_channel; |
| 531 | |
| 532 | /* valid during scan; needed for mgmt rx during scan */ |
| 533 | struct ieee80211_channel *scan_channel; |
| 534 | |
Michal Kazior | c930f74 | 2014-01-23 11:38:25 +0100 | [diff] [blame] | 535 | /* current operating channel definition */ |
| 536 | struct cfg80211_chan_def chandef; |
| 537 | |
Ben Greear | 16c1117 | 2014-09-23 14:17:16 -0700 | [diff] [blame] | 538 | unsigned long long free_vdev_map; |
Michal Kazior | 1bbc097 | 2014-04-08 09:45:47 +0300 | [diff] [blame] | 539 | bool monitor; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 540 | int monitor_vdev_id; |
Michal Kazior | 1bbc097 | 2014-04-08 09:45:47 +0300 | [diff] [blame] | 541 | bool monitor_started; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 542 | unsigned int filter_flags; |
Marek Puzyniak | e8a50f8 | 2013-11-20 09:59:47 +0200 | [diff] [blame] | 543 | unsigned long dev_flags; |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 544 | u32 dfs_block_radar_events; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 545 | |
Michal Kazior | d650097 | 2014-04-08 09:56:09 +0300 | [diff] [blame] | 546 | /* protected by conf_mutex */ |
| 547 | bool radar_enabled; |
| 548 | int num_started_vdevs; |
| 549 | |
Ben Greear | 46acf7b | 2014-05-16 17:15:38 +0300 | [diff] [blame] | 550 | /* Protected by conf-mutex */ |
| 551 | u8 supp_tx_chainmask; |
| 552 | u8 supp_rx_chainmask; |
| 553 | u8 cfg_tx_chainmask; |
| 554 | u8 cfg_rx_chainmask; |
| 555 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 556 | struct wmi_pdev_set_wmm_params_arg wmm_params; |
| 557 | struct completion install_key_done; |
| 558 | |
| 559 | struct completion vdev_setup_done; |
| 560 | |
| 561 | struct workqueue_struct *workqueue; |
| 562 | |
| 563 | /* prevents concurrent FW reconfiguration */ |
| 564 | struct mutex conf_mutex; |
| 565 | |
| 566 | /* protects shared structure data */ |
| 567 | spinlock_t data_lock; |
| 568 | |
Michal Kazior | 0579119 | 2013-10-16 15:44:45 +0300 | [diff] [blame] | 569 | struct list_head arvifs; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 570 | struct list_head peers; |
| 571 | wait_queue_head_t peer_mapping_wq; |
| 572 | |
Michal Kazior | 292a753 | 2014-11-25 15:16:04 +0100 | [diff] [blame] | 573 | /* protected by conf_mutex */ |
Bartosz Markowski | 0e759f3 | 2014-01-02 14:38:33 +0100 | [diff] [blame] | 574 | int num_peers; |
Michal Kazior | cfd1061 | 2014-11-25 15:16:05 +0100 | [diff] [blame] | 575 | int num_stations; |
| 576 | |
| 577 | int max_num_peers; |
| 578 | int max_num_stations; |
Bartosz Markowski | 0e759f3 | 2014-01-02 14:38:33 +0100 | [diff] [blame] | 579 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 580 | struct work_struct offchan_tx_work; |
| 581 | struct sk_buff_head offchan_tx_queue; |
| 582 | struct completion offchan_tx_completed; |
| 583 | struct sk_buff *offchan_tx_skb; |
| 584 | |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 585 | struct work_struct wmi_mgmt_tx_work; |
| 586 | struct sk_buff_head wmi_mgmt_tx_queue; |
| 587 | |
Michal Kazior | f7843d7 | 2013-07-16 09:38:52 +0200 | [diff] [blame] | 588 | enum ath10k_state state; |
| 589 | |
Michal Kazior | 6782cb6 | 2014-05-23 12:28:47 +0200 | [diff] [blame] | 590 | struct work_struct register_work; |
Michal Kazior | affd321 | 2013-07-16 09:54:35 +0200 | [diff] [blame] | 591 | struct work_struct restart_work; |
| 592 | |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 593 | /* cycle count is reported twice for each visited channel during scan. |
| 594 | * access protected by data_lock */ |
| 595 | u32 survey_last_rx_clear_count; |
| 596 | u32 survey_last_cycle_count; |
| 597 | struct survey_info survey[ATH10K_NUM_CHANS]; |
| 598 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 599 | struct dfs_pattern_detector *dfs_detector; |
| 600 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 601 | #ifdef CONFIG_ATH10K_DEBUGFS |
| 602 | struct ath10k_debug debug; |
| 603 | #endif |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 604 | |
| 605 | struct { |
| 606 | /* relay(fs) channel for spectral scan */ |
| 607 | struct rchan *rfs_chan_spec_scan; |
| 608 | |
| 609 | /* spectral_mode and spec_config are protected by conf_mutex */ |
| 610 | enum ath10k_spectral_mode mode; |
| 611 | struct ath10k_spec_scan config; |
| 612 | } spectral; |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 613 | |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 614 | struct { |
| 615 | /* protected by conf_mutex */ |
| 616 | const struct firmware *utf; |
| 617 | DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT); |
| 618 | |
| 619 | /* protected by data_lock */ |
| 620 | bool utf_monitor; |
| 621 | } testmode; |
| 622 | |
Ben Greear | f51dbe7 | 2014-09-29 14:41:46 +0300 | [diff] [blame] | 623 | struct { |
| 624 | /* protected by data_lock */ |
| 625 | u32 fw_crash_counter; |
| 626 | u32 fw_warm_reset_counter; |
| 627 | u32 fw_cold_reset_counter; |
| 628 | } stats; |
| 629 | |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 630 | /* must be last */ |
| 631 | u8 drv_priv[0] __aligned(sizeof(void *)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 632 | }; |
| 633 | |
Michal Kazior | e7b5419 | 2014-08-07 11:03:27 +0200 | [diff] [blame] | 634 | struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, |
Kalle Valo | e07db35 | 2014-10-13 09:40:47 +0300 | [diff] [blame] | 635 | enum ath10k_bus bus, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 636 | const struct ath10k_hif_ops *hif_ops); |
| 637 | void ath10k_core_destroy(struct ath10k *ar); |
| 638 | |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 639 | int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode); |
Marek Puzyniak | 00f5482 | 2014-02-10 17:14:24 +0100 | [diff] [blame] | 640 | int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt); |
Michal Kazior | dd30a36 | 2013-07-16 09:38:51 +0200 | [diff] [blame] | 641 | void ath10k_core_stop(struct ath10k *ar); |
Kalle Valo | e01ae68 | 2013-09-01 11:22:14 +0300 | [diff] [blame] | 642 | int ath10k_core_register(struct ath10k *ar, u32 chip_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 643 | void ath10k_core_unregister(struct ath10k *ar); |
| 644 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 645 | #endif /* _CORE_H_ */ |