cw1200.h 8.2 KB

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