core.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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. #ifndef _CORE_H_
  18. #define _CORE_H_
  19. #include <linux/completion.h>
  20. #include <linux/if_ether.h>
  21. #include <linux/types.h>
  22. #include <linux/pci.h>
  23. #include <linux/uuid.h>
  24. #include <linux/time.h>
  25. #include "htt.h"
  26. #include "htc.h"
  27. #include "hw.h"
  28. #include "targaddrs.h"
  29. #include "wmi.h"
  30. #include "../ath.h"
  31. #include "../regd.h"
  32. #include "../dfs_pattern_detector.h"
  33. #include "spectral.h"
  34. #include "thermal.h"
  35. #include "wow.h"
  36. #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
  37. #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
  38. #define WO(_f) ((_f##_OFFSET) >> 2)
  39. #define ATH10K_SCAN_ID 0
  40. #define WMI_READY_TIMEOUT (5 * HZ)
  41. #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)
  42. #define ATH10K_CONNECTION_LOSS_HZ (3*HZ)
  43. #define ATH10K_NUM_CHANS 39
  44. /* Antenna noise floor */
  45. #define ATH10K_DEFAULT_NOISE_FLOOR -95
  46. #define ATH10K_MAX_NUM_MGMT_PENDING 128
  47. /* number of failed packets (20 packets with 16 sw reties each) */
  48. #define ATH10K_KICKOUT_THRESHOLD (20 * 16)
  49. /*
  50. * Use insanely high numbers to make sure that the firmware implementation
  51. * won't start, we have the same functionality already in hostapd. Unit
  52. * is seconds.
  53. */
  54. #define ATH10K_KEEPALIVE_MIN_IDLE 3747
  55. #define ATH10K_KEEPALIVE_MAX_IDLE 3895
  56. #define ATH10K_KEEPALIVE_MAX_UNRESPONSIVE 3900
  57. struct ath10k;
  58. enum ath10k_bus {
  59. ATH10K_BUS_PCI,
  60. };
  61. static inline const char *ath10k_bus_str(enum ath10k_bus bus)
  62. {
  63. switch (bus) {
  64. case ATH10K_BUS_PCI:
  65. return "pci";
  66. }
  67. return "unknown";
  68. }
  69. struct ath10k_skb_cb {
  70. dma_addr_t paddr;
  71. u8 eid;
  72. u8 vdev_id;
  73. enum ath10k_hw_txrx_mode txmode;
  74. bool is_protected;
  75. struct {
  76. u8 tid;
  77. u16 freq;
  78. bool is_offchan;
  79. struct ath10k_htt_txbuf *txbuf;
  80. u32 txbuf_paddr;
  81. } __packed htt;
  82. struct {
  83. bool dtim_zero;
  84. bool deliver_cab;
  85. } bcn;
  86. } __packed;
  87. struct ath10k_skb_rxcb {
  88. dma_addr_t paddr;
  89. struct hlist_node hlist;
  90. };
  91. static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
  92. {
  93. BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
  94. IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
  95. return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
  96. }
  97. static inline struct ath10k_skb_rxcb *ATH10K_SKB_RXCB(struct sk_buff *skb)
  98. {
  99. BUILD_BUG_ON(sizeof(struct ath10k_skb_rxcb) > sizeof(skb->cb));
  100. return (struct ath10k_skb_rxcb *)skb->cb;
  101. }
  102. #define ATH10K_RXCB_SKB(rxcb) \
  103. container_of((void *)rxcb, struct sk_buff, cb)
  104. static inline u32 host_interest_item_address(u32 item_offset)
  105. {
  106. return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
  107. }
  108. struct ath10k_bmi {
  109. bool done_sent;
  110. };
  111. struct ath10k_mem_chunk {
  112. void *vaddr;
  113. dma_addr_t paddr;
  114. u32 len;
  115. u32 req_id;
  116. };
  117. struct ath10k_wmi {
  118. enum ath10k_fw_wmi_op_version op_version;
  119. enum ath10k_htc_ep_id eid;
  120. struct completion service_ready;
  121. struct completion unified_ready;
  122. wait_queue_head_t tx_credits_wq;
  123. DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX);
  124. struct wmi_cmd_map *cmd;
  125. struct wmi_vdev_param_map *vdev_param;
  126. struct wmi_pdev_param_map *pdev_param;
  127. const struct wmi_ops *ops;
  128. u32 num_mem_chunks;
  129. struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
  130. };
  131. struct ath10k_fw_stats_peer {
  132. struct list_head list;
  133. u8 peer_macaddr[ETH_ALEN];
  134. u32 peer_rssi;
  135. u32 peer_tx_rate;
  136. u32 peer_rx_rate; /* 10x only */
  137. };
  138. struct ath10k_fw_stats_vdev {
  139. struct list_head list;
  140. u32 vdev_id;
  141. u32 beacon_snr;
  142. u32 data_snr;
  143. u32 num_tx_frames[4];
  144. u32 num_rx_frames;
  145. u32 num_tx_frames_retries[4];
  146. u32 num_tx_frames_failures[4];
  147. u32 num_rts_fail;
  148. u32 num_rts_success;
  149. u32 num_rx_err;
  150. u32 num_rx_discard;
  151. u32 num_tx_not_acked;
  152. u32 tx_rate_history[10];
  153. u32 beacon_rssi_history[10];
  154. };
  155. struct ath10k_fw_stats_pdev {
  156. struct list_head list;
  157. /* PDEV stats */
  158. s32 ch_noise_floor;
  159. u32 tx_frame_count;
  160. u32 rx_frame_count;
  161. u32 rx_clear_count;
  162. u32 cycle_count;
  163. u32 phy_err_count;
  164. u32 chan_tx_power;
  165. u32 ack_rx_bad;
  166. u32 rts_bad;
  167. u32 rts_good;
  168. u32 fcs_bad;
  169. u32 no_beacons;
  170. u32 mib_int_count;
  171. /* PDEV TX stats */
  172. s32 comp_queued;
  173. s32 comp_delivered;
  174. s32 msdu_enqued;
  175. s32 mpdu_enqued;
  176. s32 wmm_drop;
  177. s32 local_enqued;
  178. s32 local_freed;
  179. s32 hw_queued;
  180. s32 hw_reaped;
  181. s32 underrun;
  182. s32 tx_abort;
  183. s32 mpdus_requed;
  184. u32 tx_ko;
  185. u32 data_rc;
  186. u32 self_triggers;
  187. u32 sw_retry_failure;
  188. u32 illgl_rate_phy_err;
  189. u32 pdev_cont_xretry;
  190. u32 pdev_tx_timeout;
  191. u32 pdev_resets;
  192. u32 phy_underrun;
  193. u32 txop_ovf;
  194. /* PDEV RX stats */
  195. s32 mid_ppdu_route_change;
  196. s32 status_rcvd;
  197. s32 r0_frags;
  198. s32 r1_frags;
  199. s32 r2_frags;
  200. s32 r3_frags;
  201. s32 htt_msdus;
  202. s32 htt_mpdus;
  203. s32 loc_msdus;
  204. s32 loc_mpdus;
  205. s32 oversize_amsdu;
  206. s32 phy_errs;
  207. s32 phy_err_drop;
  208. s32 mpdu_errs;
  209. };
  210. struct ath10k_fw_stats {
  211. struct list_head pdevs;
  212. struct list_head vdevs;
  213. struct list_head peers;
  214. };
  215. struct ath10k_dfs_stats {
  216. u32 phy_errors;
  217. u32 pulses_total;
  218. u32 pulses_detected;
  219. u32 pulses_discarded;
  220. u32 radar_detected;
  221. };
  222. #define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
  223. struct ath10k_peer {
  224. struct list_head list;
  225. int vdev_id;
  226. u8 addr[ETH_ALEN];
  227. DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
  228. /* protected by ar->data_lock */
  229. struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
  230. };
  231. struct ath10k_sta {
  232. struct ath10k_vif *arvif;
  233. /* the following are protected by ar->data_lock */
  234. u32 changed; /* IEEE80211_RC_* */
  235. u32 bw;
  236. u32 nss;
  237. u32 smps;
  238. struct work_struct update_wk;
  239. #ifdef CONFIG_MAC80211_DEBUGFS
  240. /* protected by conf_mutex */
  241. bool aggr_mode;
  242. #endif
  243. };
  244. #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
  245. enum ath10k_beacon_state {
  246. ATH10K_BEACON_SCHEDULED = 0,
  247. ATH10K_BEACON_SENDING,
  248. ATH10K_BEACON_SENT,
  249. };
  250. struct ath10k_vif {
  251. struct list_head list;
  252. u32 vdev_id;
  253. enum wmi_vdev_type vdev_type;
  254. enum wmi_vdev_subtype vdev_subtype;
  255. u32 beacon_interval;
  256. u32 dtim_period;
  257. struct sk_buff *beacon;
  258. /* protected by data_lock */
  259. enum ath10k_beacon_state beacon_state;
  260. void *beacon_buf;
  261. dma_addr_t beacon_paddr;
  262. unsigned long tx_paused; /* arbitrary values defined by target */
  263. struct ath10k *ar;
  264. struct ieee80211_vif *vif;
  265. bool is_started;
  266. bool is_up;
  267. bool spectral_enabled;
  268. bool ps;
  269. u32 aid;
  270. u8 bssid[ETH_ALEN];
  271. struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
  272. s8 def_wep_key_idx;
  273. u16 tx_seq_no;
  274. union {
  275. struct {
  276. u32 uapsd;
  277. } sta;
  278. struct {
  279. /* 127 stations; wmi limit */
  280. u8 tim_bitmap[16];
  281. u8 tim_len;
  282. u32 ssid_len;
  283. u8 ssid[IEEE80211_MAX_SSID_LEN];
  284. bool hidden_ssid;
  285. /* P2P_IE with NoA attribute for P2P_GO case */
  286. u32 noa_len;
  287. u8 *noa_data;
  288. } ap;
  289. } u;
  290. bool use_cts_prot;
  291. int num_legacy_stations;
  292. int txpower;
  293. struct wmi_wmm_params_all_arg wmm_params;
  294. struct work_struct ap_csa_work;
  295. struct delayed_work connection_loss_work;
  296. struct cfg80211_bitrate_mask bitrate_mask;
  297. };
  298. struct ath10k_vif_iter {
  299. u32 vdev_id;
  300. struct ath10k_vif *arvif;
  301. };
  302. /* used for crash-dump storage, protected by data-lock */
  303. struct ath10k_fw_crash_data {
  304. bool crashed_since_read;
  305. uuid_le uuid;
  306. struct timespec timestamp;
  307. __le32 registers[REG_DUMP_COUNT_QCA988X];
  308. };
  309. struct ath10k_debug {
  310. struct dentry *debugfs_phy;
  311. struct ath10k_fw_stats fw_stats;
  312. struct completion fw_stats_complete;
  313. bool fw_stats_done;
  314. unsigned long htt_stats_mask;
  315. struct delayed_work htt_stats_dwork;
  316. struct ath10k_dfs_stats dfs_stats;
  317. struct ath_dfs_pool_stats dfs_pool_stats;
  318. /* protected by conf_mutex */
  319. u32 fw_dbglog_mask;
  320. u32 fw_dbglog_level;
  321. u32 pktlog_filter;
  322. u32 reg_addr;
  323. u32 nf_cal_period;
  324. u8 htt_max_amsdu;
  325. u8 htt_max_ampdu;
  326. struct ath10k_fw_crash_data *fw_crash_data;
  327. };
  328. enum ath10k_state {
  329. ATH10K_STATE_OFF = 0,
  330. ATH10K_STATE_ON,
  331. /* When doing firmware recovery the device is first powered down.
  332. * mac80211 is supposed to call in to start() hook later on. It is
  333. * however possible that driver unloading and firmware crash overlap.
  334. * mac80211 can wait on conf_mutex in stop() while the device is
  335. * stopped in ath10k_core_restart() work holding conf_mutex. The state
  336. * RESTARTED means that the device is up and mac80211 has started hw
  337. * reconfiguration. Once mac80211 is done with the reconfiguration we
  338. * set the state to STATE_ON in reconfig_complete(). */
  339. ATH10K_STATE_RESTARTING,
  340. ATH10K_STATE_RESTARTED,
  341. /* The device has crashed while restarting hw. This state is like ON
  342. * but commands are blocked in HTC and -ECOMM response is given. This
  343. * prevents completion timeouts and makes the driver more responsive to
  344. * userspace commands. This is also prevents recursive recovery. */
  345. ATH10K_STATE_WEDGED,
  346. /* factory tests */
  347. ATH10K_STATE_UTF,
  348. };
  349. enum ath10k_firmware_mode {
  350. /* the default mode, standard 802.11 functionality */
  351. ATH10K_FIRMWARE_MODE_NORMAL,
  352. /* factory tests etc */
  353. ATH10K_FIRMWARE_MODE_UTF,
  354. };
  355. enum ath10k_fw_features {
  356. /* wmi_mgmt_rx_hdr contains extra RSSI information */
  357. ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
  358. /* Firmware from 10X branch. Deprecated, don't use in new code. */
  359. ATH10K_FW_FEATURE_WMI_10X = 1,
  360. /* firmware support tx frame management over WMI, otherwise it's HTT */
  361. ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
  362. /* Firmware does not support P2P */
  363. ATH10K_FW_FEATURE_NO_P2P = 3,
  364. /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
  365. * bit is required to be set as well. Deprecated, don't use in new
  366. * code.
  367. */
  368. ATH10K_FW_FEATURE_WMI_10_2 = 4,
  369. /* Some firmware revisions lack proper multi-interface client powersave
  370. * implementation. Enabling PS could result in connection drops,
  371. * traffic stalls, etc.
  372. */
  373. ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT = 5,
  374. /* Some firmware revisions have an incomplete WoWLAN implementation
  375. * despite WMI service bit being advertised. This feature flag is used
  376. * to distinguish whether WoWLAN is really supported or not.
  377. */
  378. ATH10K_FW_FEATURE_WOWLAN_SUPPORT = 6,
  379. /* Don't trust error code from otp.bin */
  380. ATH10K_FW_FEATURE_IGNORE_OTP_RESULT,
  381. /* Some firmware revisions pad 4th hw address to 4 byte boundary making
  382. * it 8 bytes long in Native Wifi Rx decap.
  383. */
  384. ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING,
  385. /* Firmware supports bypassing PLL setting on init. */
  386. ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT = 9,
  387. /* keep last */
  388. ATH10K_FW_FEATURE_COUNT,
  389. };
  390. enum ath10k_dev_flags {
  391. /* Indicates that ath10k device is during CAC phase of DFS */
  392. ATH10K_CAC_RUNNING,
  393. ATH10K_FLAG_CORE_REGISTERED,
  394. /* Device has crashed and needs to restart. This indicates any pending
  395. * waiters should immediately cancel instead of waiting for a time out.
  396. */
  397. ATH10K_FLAG_CRASH_FLUSH,
  398. };
  399. enum ath10k_cal_mode {
  400. ATH10K_CAL_MODE_FILE,
  401. ATH10K_CAL_MODE_OTP,
  402. ATH10K_CAL_MODE_DT,
  403. };
  404. static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
  405. {
  406. switch (mode) {
  407. case ATH10K_CAL_MODE_FILE:
  408. return "file";
  409. case ATH10K_CAL_MODE_OTP:
  410. return "otp";
  411. case ATH10K_CAL_MODE_DT:
  412. return "dt";
  413. }
  414. return "unknown";
  415. }
  416. enum ath10k_scan_state {
  417. ATH10K_SCAN_IDLE,
  418. ATH10K_SCAN_STARTING,
  419. ATH10K_SCAN_RUNNING,
  420. ATH10K_SCAN_ABORTING,
  421. };
  422. static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
  423. {
  424. switch (state) {
  425. case ATH10K_SCAN_IDLE:
  426. return "idle";
  427. case ATH10K_SCAN_STARTING:
  428. return "starting";
  429. case ATH10K_SCAN_RUNNING:
  430. return "running";
  431. case ATH10K_SCAN_ABORTING:
  432. return "aborting";
  433. }
  434. return "unknown";
  435. }
  436. enum ath10k_tx_pause_reason {
  437. ATH10K_TX_PAUSE_Q_FULL,
  438. ATH10K_TX_PAUSE_MAX,
  439. };
  440. struct ath10k {
  441. struct ath_common ath_common;
  442. struct ieee80211_hw *hw;
  443. struct device *dev;
  444. u8 mac_addr[ETH_ALEN];
  445. enum ath10k_hw_rev hw_rev;
  446. u32 chip_id;
  447. u32 target_version;
  448. u8 fw_version_major;
  449. u32 fw_version_minor;
  450. u16 fw_version_release;
  451. u16 fw_version_build;
  452. u32 fw_stats_req_mask;
  453. u32 phy_capability;
  454. u32 hw_min_tx_power;
  455. u32 hw_max_tx_power;
  456. u32 ht_cap_info;
  457. u32 vht_cap_info;
  458. u32 num_rf_chains;
  459. /* protected by conf_mutex */
  460. bool ani_enabled;
  461. DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
  462. bool p2p;
  463. struct {
  464. enum ath10k_bus bus;
  465. const struct ath10k_hif_ops *ops;
  466. } hif;
  467. struct completion target_suspend;
  468. const struct ath10k_hw_regs *regs;
  469. struct ath10k_bmi bmi;
  470. struct ath10k_wmi wmi;
  471. struct ath10k_htc htc;
  472. struct ath10k_htt htt;
  473. struct ath10k_hw_params {
  474. u32 id;
  475. const char *name;
  476. u32 patch_load_addr;
  477. int uart_pin;
  478. /* This is true if given HW chip has a quirky Cycle Counter
  479. * wraparound which resets to 0x7fffffff instead of 0. All
  480. * other CC related counters (e.g. Rx Clear Count) are divided
  481. * by 2 so they never wraparound themselves.
  482. */
  483. bool has_shifted_cc_wraparound;
  484. struct ath10k_hw_params_fw {
  485. const char *dir;
  486. const char *fw;
  487. const char *otp;
  488. const char *board;
  489. size_t board_size;
  490. size_t board_ext_size;
  491. } fw;
  492. } hw_params;
  493. const struct firmware *board;
  494. const void *board_data;
  495. size_t board_len;
  496. const struct firmware *otp;
  497. const void *otp_data;
  498. size_t otp_len;
  499. const struct firmware *firmware;
  500. const void *firmware_data;
  501. size_t firmware_len;
  502. const struct firmware *cal_file;
  503. char spec_board_id[100];
  504. bool spec_board_loaded;
  505. int fw_api;
  506. enum ath10k_cal_mode cal_mode;
  507. struct {
  508. struct completion started;
  509. struct completion completed;
  510. struct completion on_channel;
  511. struct delayed_work timeout;
  512. enum ath10k_scan_state state;
  513. bool is_roc;
  514. int vdev_id;
  515. int roc_freq;
  516. } scan;
  517. struct {
  518. struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
  519. } mac;
  520. /* should never be NULL; needed for regular htt rx */
  521. struct ieee80211_channel *rx_channel;
  522. /* valid during scan; needed for mgmt rx during scan */
  523. struct ieee80211_channel *scan_channel;
  524. /* current operating channel definition */
  525. struct cfg80211_chan_def chandef;
  526. unsigned long long free_vdev_map;
  527. struct ath10k_vif *monitor_arvif;
  528. bool monitor;
  529. int monitor_vdev_id;
  530. bool monitor_started;
  531. unsigned int filter_flags;
  532. unsigned long dev_flags;
  533. u32 dfs_block_radar_events;
  534. /* protected by conf_mutex */
  535. bool radar_enabled;
  536. int num_started_vdevs;
  537. /* Protected by conf-mutex */
  538. u8 supp_tx_chainmask;
  539. u8 supp_rx_chainmask;
  540. u8 cfg_tx_chainmask;
  541. u8 cfg_rx_chainmask;
  542. struct completion install_key_done;
  543. struct completion vdev_setup_done;
  544. struct workqueue_struct *workqueue;
  545. /* prevents concurrent FW reconfiguration */
  546. struct mutex conf_mutex;
  547. /* protects shared structure data */
  548. spinlock_t data_lock;
  549. struct list_head arvifs;
  550. struct list_head peers;
  551. wait_queue_head_t peer_mapping_wq;
  552. /* protected by conf_mutex */
  553. int num_peers;
  554. int num_stations;
  555. int max_num_peers;
  556. int max_num_stations;
  557. int max_num_vdevs;
  558. int max_num_tdls_vdevs;
  559. struct work_struct offchan_tx_work;
  560. struct sk_buff_head offchan_tx_queue;
  561. struct completion offchan_tx_completed;
  562. struct sk_buff *offchan_tx_skb;
  563. struct work_struct wmi_mgmt_tx_work;
  564. struct sk_buff_head wmi_mgmt_tx_queue;
  565. enum ath10k_state state;
  566. struct work_struct register_work;
  567. struct work_struct restart_work;
  568. /* cycle count is reported twice for each visited channel during scan.
  569. * access protected by data_lock */
  570. u32 survey_last_rx_clear_count;
  571. u32 survey_last_cycle_count;
  572. struct survey_info survey[ATH10K_NUM_CHANS];
  573. /* Channel info events are expected to come in pairs without and with
  574. * COMPLETE flag set respectively for each channel visit during scan.
  575. *
  576. * However there are deviations from this rule. This flag is used to
  577. * avoid reporting garbage data.
  578. */
  579. bool ch_info_can_report_survey;
  580. struct dfs_pattern_detector *dfs_detector;
  581. unsigned long tx_paused; /* see ATH10K_TX_PAUSE_ */
  582. #ifdef CONFIG_ATH10K_DEBUGFS
  583. struct ath10k_debug debug;
  584. #endif
  585. struct {
  586. /* relay(fs) channel for spectral scan */
  587. struct rchan *rfs_chan_spec_scan;
  588. /* spectral_mode and spec_config are protected by conf_mutex */
  589. enum ath10k_spectral_mode mode;
  590. struct ath10k_spec_scan config;
  591. } spectral;
  592. struct {
  593. /* protected by conf_mutex */
  594. const struct firmware *utf;
  595. DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);
  596. enum ath10k_fw_wmi_op_version orig_wmi_op_version;
  597. /* protected by data_lock */
  598. bool utf_monitor;
  599. } testmode;
  600. struct {
  601. /* protected by data_lock */
  602. u32 fw_crash_counter;
  603. u32 fw_warm_reset_counter;
  604. u32 fw_cold_reset_counter;
  605. } stats;
  606. struct ath10k_thermal thermal;
  607. struct ath10k_wow wow;
  608. /* must be last */
  609. u8 drv_priv[0] __aligned(sizeof(void *));
  610. };
  611. struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
  612. enum ath10k_bus bus,
  613. enum ath10k_hw_rev hw_rev,
  614. const struct ath10k_hif_ops *hif_ops);
  615. void ath10k_core_destroy(struct ath10k *ar);
  616. int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
  617. int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
  618. void ath10k_core_stop(struct ath10k *ar);
  619. int ath10k_core_register(struct ath10k *ar, u32 chip_id);
  620. void ath10k_core_unregister(struct ath10k *ar);
  621. #endif /* _CORE_H_ */