2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
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.
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.
21 #include <linux/completion.h>
22 #include <linux/if_ether.h>
23 #include <linux/types.h>
24 #include <linux/pci.h>
28 #include "targaddrs.h"
33 #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
34 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
35 #define WO(_f) ((_f##_OFFSET) >> 2)
37 #define ATH10K_SCAN_ID 0
38 #define WMI_READY_TIMEOUT (5 * HZ)
39 #define ATH10K_FLUSH_TIMEOUT_HZ (5*HZ)
41 /* Antenna noise floor */
42 #define ATH10K_DEFAULT_NOISE_FLOOR -95
46 struct ath10k_skb_cb {
60 struct sk_buff *txfrag;
64 /* 4 bytes left on 64bit arch */
67 static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
69 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
70 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
71 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
74 static inline int ath10k_skb_map(struct device *dev, struct sk_buff *skb)
76 if (ATH10K_SKB_CB(skb)->is_mapped)
79 ATH10K_SKB_CB(skb)->paddr = dma_map_single(dev, skb->data, skb->len,
82 if (unlikely(dma_mapping_error(dev, ATH10K_SKB_CB(skb)->paddr)))
85 ATH10K_SKB_CB(skb)->is_mapped = true;
89 static inline int ath10k_skb_unmap(struct device *dev, struct sk_buff *skb)
91 if (!ATH10K_SKB_CB(skb)->is_mapped)
94 dma_unmap_single(dev, ATH10K_SKB_CB(skb)->paddr, skb->len,
96 ATH10K_SKB_CB(skb)->is_mapped = false;
100 static inline u32 host_interest_item_address(u32 item_offset)
102 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
110 enum ath10k_htc_ep_id eid;
111 struct completion service_ready;
112 struct completion unified_ready;
113 atomic_t pending_tx_count;
114 wait_queue_head_t wq;
116 struct sk_buff_head wmi_event_list;
117 struct work_struct wmi_event_work;
120 struct ath10k_peer_stat {
121 u8 peer_macaddr[ETH_ALEN];
126 struct ath10k_target_stats {
152 u32 sw_retry_failure;
153 u32 illgl_rate_phy_err;
154 u32 pdev_cont_xretry;
161 s32 mid_ppdu_route_change;
180 struct ath10k_peer_stat peer_stat[TARGET_NUM_PEERS];
182 /* TODO: Beacon filter stats */
186 #define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
189 struct list_head list;
192 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
193 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
196 #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ)
200 enum wmi_vdev_type vdev_type;
201 enum wmi_vdev_subtype vdev_subtype;
206 struct ieee80211_vif *vif;
208 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
209 u8 def_wep_key_index;
219 /* 127 stations; wmi limit */
223 u8 ssid[IEEE80211_MAX_SSID_LEN];
225 /* P2P_IE with NoA attribute for P2P_GO case */
235 struct ath10k_vif_iter {
237 struct ath10k_vif *arvif;
240 struct ath10k_debug {
241 struct dentry *debugfs_phy;
243 struct ath10k_target_stats target_stats;
244 u32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE];
246 struct completion event_stats_compl;
250 struct ath_common ath_common;
251 struct ieee80211_hw *hw;
253 u8 mac_addr[ETH_ALEN];
257 u32 fw_version_minor;
258 u16 fw_version_release;
259 u16 fw_version_build;
266 struct targetdef *targetdef;
267 struct hostdef *hostdef;
273 const struct ath10k_hif_ops *ops;
276 struct ath10k_wmi wmi;
278 wait_queue_head_t event_queue;
279 bool is_target_paused;
281 struct ath10k_bmi bmi;
282 struct ath10k_htc htc;
284 struct ath10k_htt *htt;
286 struct ath10k_hw_params {
291 struct ath10k_hw_params_fw {
300 struct completion started;
301 struct completion completed;
302 struct completion on_channel;
303 struct timer_list timeout;
312 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
315 /* should never be NULL; needed for regular htt rx */
316 struct ieee80211_channel *rx_channel;
318 /* valid during scan; needed for mgmt rx during scan */
319 struct ieee80211_channel *scan_channel;
323 bool monitor_enabled;
324 bool monitor_present;
325 unsigned int filter_flags;
327 struct wmi_pdev_set_wmm_params_arg wmm_params;
328 struct completion install_key_done;
330 struct completion vdev_setup_done;
332 struct workqueue_struct *workqueue;
334 /* prevents concurrent FW reconfiguration */
335 struct mutex conf_mutex;
337 /* protects shared structure data */
338 spinlock_t data_lock;
340 struct list_head peers;
341 wait_queue_head_t peer_mapping_wq;
343 struct work_struct offchan_tx_work;
344 struct sk_buff_head offchan_tx_queue;
345 struct completion offchan_tx_completed;
346 struct sk_buff *offchan_tx_skb;
348 #ifdef CONFIG_ATH10K_DEBUGFS
349 struct ath10k_debug debug;
353 struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
354 const struct ath10k_hif_ops *hif_ops);
355 void ath10k_core_destroy(struct ath10k *ar);
357 int ath10k_core_register(struct ath10k *ar);
358 void ath10k_core_unregister(struct ath10k *ar);
360 int ath10k_core_target_suspend(struct ath10k *ar);
361 int ath10k_core_target_resume(struct ath10k *ar);
363 #endif /* _CORE_H_ */