cw1200.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. * Common private data for ST-Ericsson CW1200 drivers
  3. *
  4. * Copyright (c) 2010, ST-Ericsson
  5. * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
  6. *
  7. * Based on the mac80211 Prism54 code, which is
  8. * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  9. *
  10. * Based on the islsm (softmac prism54) driver, which is:
  11. * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. */
  17. #ifndef CW1200_H
  18. #define CW1200_H
  19. #include <linux/wait.h>
  20. #include <linux/mutex.h>
  21. #include <linux/workqueue.h>
  22. #include <net/mac80211.h>
  23. #include "queue.h"
  24. #include "wsm.h"
  25. #include "scan.h"
  26. #include "txrx.h"
  27. #include "pm.h"
  28. /* Forward declarations */
  29. struct hwbus_ops;
  30. struct task_struct;
  31. struct cw1200_debug_priv;
  32. struct firmware;
  33. #ifdef CONFIG_CW1200_ETF
  34. extern int etf_mode;
  35. extern char *etf_firmware;
  36. #endif
  37. #define CW1200_MAX_CTRL_FRAME_LEN (0x1000)
  38. #define CW1200_MAX_STA_IN_AP_MODE (5)
  39. #define CW1200_LINK_ID_AFTER_DTIM (CW1200_MAX_STA_IN_AP_MODE + 1)
  40. #define CW1200_LINK_ID_UAPSD (CW1200_MAX_STA_IN_AP_MODE + 2)
  41. #define CW1200_LINK_ID_MAX (CW1200_MAX_STA_IN_AP_MODE + 3)
  42. #define CW1200_MAX_REQUEUE_ATTEMPTS (5)
  43. #define CW1200_MAX_TID (8)
  44. #define CW1200_BLOCK_ACK_CNT (30)
  45. #define CW1200_BLOCK_ACK_THLD (800)
  46. #define CW1200_BLOCK_ACK_HIST (3)
  47. #define CW1200_BLOCK_ACK_INTERVAL (1 * HZ / CW1200_BLOCK_ACK_HIST)
  48. #define CW1200_JOIN_TIMEOUT (1 * HZ)
  49. #define CW1200_AUTH_TIMEOUT (5 * HZ)
  50. struct cw1200_ht_info {
  51. struct ieee80211_sta_ht_cap ht_cap;
  52. enum nl80211_channel_type channel_type;
  53. u16 operation_mode;
  54. };
  55. /* Please keep order */
  56. enum cw1200_join_status {
  57. CW1200_JOIN_STATUS_PASSIVE = 0,
  58. CW1200_JOIN_STATUS_MONITOR,
  59. CW1200_JOIN_STATUS_JOINING,
  60. CW1200_JOIN_STATUS_PRE_STA,
  61. CW1200_JOIN_STATUS_STA,
  62. CW1200_JOIN_STATUS_IBSS,
  63. CW1200_JOIN_STATUS_AP,
  64. };
  65. enum cw1200_link_status {
  66. CW1200_LINK_OFF,
  67. CW1200_LINK_RESERVE,
  68. CW1200_LINK_SOFT,
  69. CW1200_LINK_HARD,
  70. CW1200_LINK_RESET,
  71. CW1200_LINK_RESET_REMAP,
  72. };
  73. extern int cw1200_power_mode;
  74. extern const char * const cw1200_fw_types[];
  75. struct cw1200_link_entry {
  76. unsigned long timestamp;
  77. enum cw1200_link_status status;
  78. enum cw1200_link_status prev_status;
  79. u8 mac[ETH_ALEN];
  80. u8 buffered[CW1200_MAX_TID];
  81. struct sk_buff_head rx_queue;
  82. };
  83. struct cw1200_common {
  84. /* interfaces to the rest of the stack */
  85. struct ieee80211_hw *hw;
  86. struct ieee80211_vif *vif;
  87. struct device *pdev;
  88. /* Statistics */
  89. struct ieee80211_low_level_stats stats;
  90. /* Our macaddr */
  91. u8 mac_addr[ETH_ALEN];
  92. /* Hardware interface */
  93. const struct hwbus_ops *hwbus_ops;
  94. struct hwbus_priv *hwbus_priv;
  95. /* Hardware information */
  96. enum {
  97. HIF_9000_SILICON_VERSATILE = 0,
  98. HIF_8601_VERSATILE,
  99. HIF_8601_SILICON,
  100. } hw_type;
  101. enum {
  102. CW1200_HW_REV_CUT10 = 10,
  103. CW1200_HW_REV_CUT11 = 11,
  104. CW1200_HW_REV_CUT20 = 20,
  105. CW1200_HW_REV_CUT22 = 22,
  106. CW1X60_HW_REV = 40,
  107. } hw_revision;
  108. int hw_refclk;
  109. bool hw_have_5ghz;
  110. const struct firmware *sdd;
  111. char *sdd_path;
  112. struct cw1200_debug_priv *debug;
  113. struct workqueue_struct *workqueue;
  114. struct mutex conf_mutex;
  115. struct cw1200_queue tx_queue[4];
  116. struct cw1200_queue_stats tx_queue_stats;
  117. int tx_burst_idx;
  118. /* firmware/hardware info */
  119. unsigned int tx_hdr_len;
  120. /* Radio data */
  121. int output_power;
  122. /* BBP/MAC state */
  123. struct ieee80211_rate *rates;
  124. struct ieee80211_rate *mcs_rates;
  125. struct ieee80211_channel *channel;
  126. struct wsm_edca_params edca;
  127. struct wsm_tx_queue_params tx_queue_params;
  128. struct wsm_mib_association_mode association_mode;
  129. struct wsm_set_bss_params bss_params;
  130. struct cw1200_ht_info ht_info;
  131. struct wsm_set_pm powersave_mode;
  132. struct wsm_set_pm firmware_ps_mode;
  133. int cqm_rssi_thold;
  134. unsigned cqm_rssi_hyst;
  135. bool cqm_use_rssi;
  136. int cqm_beacon_loss_count;
  137. int channel_switch_in_progress;
  138. wait_queue_head_t channel_switch_done;
  139. u8 long_frame_max_tx_count;
  140. u8 short_frame_max_tx_count;
  141. int mode;
  142. bool enable_beacon;
  143. int beacon_int;
  144. bool listening;
  145. struct wsm_rx_filter rx_filter;
  146. struct wsm_mib_multicast_filter multicast_filter;
  147. bool has_multicast_subscription;
  148. bool disable_beacon_filter;
  149. struct work_struct update_filtering_work;
  150. struct work_struct set_beacon_wakeup_period_work;
  151. u8 ba_rx_tid_mask;
  152. u8 ba_tx_tid_mask;
  153. struct cw1200_pm_state pm_state;
  154. struct wsm_p2p_ps_modeinfo p2p_ps_modeinfo;
  155. struct wsm_uapsd_info uapsd_info;
  156. bool setbssparams_done;
  157. bool bt_present;
  158. u8 conf_listen_interval;
  159. u32 listen_interval;
  160. u32 erp_info;
  161. u32 rts_threshold;
  162. /* BH */
  163. atomic_t bh_rx;
  164. atomic_t bh_tx;
  165. atomic_t bh_term;
  166. atomic_t bh_suspend;
  167. struct workqueue_struct *bh_workqueue;
  168. struct work_struct bh_work;
  169. int bh_error;
  170. wait_queue_head_t bh_wq;
  171. wait_queue_head_t bh_evt_wq;
  172. u8 buf_id_tx;
  173. u8 buf_id_rx;
  174. u8 wsm_rx_seq;
  175. u8 wsm_tx_seq;
  176. int hw_bufs_used;
  177. bool powersave_enabled;
  178. bool device_can_sleep;
  179. /* Scan status */
  180. struct cw1200_scan scan;
  181. /* Keep cw1200 awake (WUP = 1) 1 second after each scan to avoid
  182. * FW issue with sleeping/waking up. */
  183. atomic_t recent_scan;
  184. struct delayed_work clear_recent_scan_work;
  185. /* WSM */
  186. struct wsm_startup_ind wsm_caps;
  187. struct mutex wsm_cmd_mux;
  188. struct wsm_buf wsm_cmd_buf;
  189. struct wsm_cmd wsm_cmd;
  190. wait_queue_head_t wsm_cmd_wq;
  191. wait_queue_head_t wsm_startup_done;
  192. int firmware_ready;
  193. atomic_t tx_lock;
  194. /* WSM debug */
  195. int wsm_enable_wsm_dumps;
  196. /* WSM Join */
  197. enum cw1200_join_status join_status;
  198. u32 pending_frame_id;
  199. bool join_pending;
  200. struct delayed_work join_timeout;
  201. struct work_struct unjoin_work;
  202. struct work_struct join_complete_work;
  203. int join_complete_status;
  204. int join_dtim_period;
  205. bool delayed_unjoin;
  206. /* TX/RX and security */
  207. s8 wep_default_key_id;
  208. struct work_struct wep_key_work;
  209. u32 key_map;
  210. struct wsm_add_key keys[WSM_KEY_MAX_INDEX + 1];
  211. /* AP powersave */
  212. u32 link_id_map;
  213. struct cw1200_link_entry link_id_db[CW1200_MAX_STA_IN_AP_MODE];
  214. struct work_struct link_id_work;
  215. struct delayed_work link_id_gc_work;
  216. u32 sta_asleep_mask;
  217. u32 pspoll_mask;
  218. bool aid0_bit_set;
  219. spinlock_t ps_state_lock; /* Protect power save state */
  220. bool buffered_multicasts;
  221. bool tx_multicast;
  222. struct work_struct set_tim_work;
  223. struct work_struct set_cts_work;
  224. struct work_struct multicast_start_work;
  225. struct work_struct multicast_stop_work;
  226. struct timer_list mcast_timeout;
  227. /* WSM events and CQM implementation */
  228. spinlock_t event_queue_lock; /* Protect event queue */
  229. struct list_head event_queue;
  230. struct work_struct event_handler;
  231. struct delayed_work bss_loss_work;
  232. spinlock_t bss_loss_lock; /* Protect BSS loss state */
  233. int bss_loss_state;
  234. int bss_loss_confirm_id;
  235. int delayed_link_loss;
  236. struct work_struct bss_params_work;
  237. /* TX rate policy cache */
  238. struct tx_policy_cache tx_policy_cache;
  239. struct work_struct tx_policy_upload_work;
  240. /* legacy PS mode switch in suspend */
  241. int ps_mode_switch_in_progress;
  242. wait_queue_head_t ps_mode_switch_done;
  243. /* Workaround for WFD testcase 6.1.10*/
  244. struct work_struct linkid_reset_work;
  245. u8 action_frame_sa[ETH_ALEN];
  246. u8 action_linkid;
  247. #ifdef CONFIG_CW1200_ETF
  248. struct sk_buff_head etf_q;
  249. #endif
  250. };
  251. struct cw1200_sta_priv {
  252. int link_id;
  253. };
  254. /* interfaces for the drivers */
  255. int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
  256. struct hwbus_priv *hwbus,
  257. struct device *pdev,
  258. struct cw1200_common **pself,
  259. int ref_clk, const u8 *macaddr,
  260. const char *sdd_path, bool have_5ghz);
  261. void cw1200_core_release(struct cw1200_common *self);
  262. #define FWLOAD_BLOCK_SIZE (1024)
  263. static inline int cw1200_is_ht(const struct cw1200_ht_info *ht_info)
  264. {
  265. return ht_info->channel_type != NL80211_CHAN_NO_HT;
  266. }
  267. static inline int cw1200_ht_greenfield(const struct cw1200_ht_info *ht_info)
  268. {
  269. return cw1200_is_ht(ht_info) &&
  270. (ht_info->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) &&
  271. !(ht_info->operation_mode &
  272. IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  273. }
  274. static inline int cw1200_ht_ampdu_density(const struct cw1200_ht_info *ht_info)
  275. {
  276. if (!cw1200_is_ht(ht_info))
  277. return 0;
  278. return ht_info->ht_cap.ampdu_density;
  279. }
  280. #endif /* CW1200_H */