core.h 20 KB

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