cw1200.h 8.1 KB

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