core.h 19 KB

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