cw1200.h 8.4 KB

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