rsi_main.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. /**
  2. * Copyright (c) 2014 Redpine Signals Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __RSI_MAIN_H__
  17. #define __RSI_MAIN_H__
  18. #include <linux/string.h>
  19. #include <linux/skbuff.h>
  20. #include <net/mac80211.h>
  21. #include <net/rsi_91x.h>
  22. struct rsi_sta {
  23. struct ieee80211_sta *sta;
  24. s16 sta_id;
  25. u16 seq_start[IEEE80211_NUM_TIDS];
  26. bool start_tx_aggr[IEEE80211_NUM_TIDS];
  27. };
  28. struct rsi_hw;
  29. #include "rsi_ps.h"
  30. #define ERR_ZONE BIT(0) /* For Error Msgs */
  31. #define INFO_ZONE BIT(1) /* For General Status Msgs */
  32. #define INIT_ZONE BIT(2) /* For Driver Init Seq Msgs */
  33. #define MGMT_TX_ZONE BIT(3) /* For TX Mgmt Path Msgs */
  34. #define MGMT_RX_ZONE BIT(4) /* For RX Mgmt Path Msgs */
  35. #define DATA_TX_ZONE BIT(5) /* For TX Data Path Msgs */
  36. #define DATA_RX_ZONE BIT(6) /* For RX Data Path Msgs */
  37. #define FSM_ZONE BIT(7) /* For State Machine Msgs */
  38. #define ISR_ZONE BIT(8) /* For Interrupt Msgs */
  39. enum RSI_FSM_STATES {
  40. FSM_FW_NOT_LOADED,
  41. FSM_CARD_NOT_READY,
  42. FSM_COMMON_DEV_PARAMS_SENT,
  43. FSM_BOOT_PARAMS_SENT,
  44. FSM_EEPROM_READ_MAC_ADDR,
  45. FSM_EEPROM_READ_RF_TYPE,
  46. FSM_RESET_MAC_SENT,
  47. FSM_RADIO_CAPS_SENT,
  48. FSM_BB_RF_PROG_SENT,
  49. FSM_MAC_INIT_DONE,
  50. NUM_FSM_STATES
  51. };
  52. extern u32 rsi_zone_enabled;
  53. extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
  54. #define RSI_MAX_VIFS 3
  55. #define NUM_EDCA_QUEUES 4
  56. #define IEEE80211_ADDR_LEN 6
  57. #define FRAME_DESC_SZ 16
  58. #define MIN_802_11_HDR_LEN 24
  59. #define RSI_DEF_KEEPALIVE 90
  60. #define RSI_WOW_KEEPALIVE 5
  61. #define RSI_BCN_MISS_THRESHOLD 24
  62. #define DATA_QUEUE_WATER_MARK 400
  63. #define MIN_DATA_QUEUE_WATER_MARK 300
  64. #define MULTICAST_WATER_MARK 200
  65. #define MAC_80211_HDR_FRAME_CONTROL 0
  66. #define WME_NUM_AC 4
  67. #define NUM_SOFT_QUEUES 6
  68. #define MAX_HW_QUEUES 12
  69. #define INVALID_QUEUE 0xff
  70. #define MAX_CONTINUOUS_VO_PKTS 8
  71. #define MAX_CONTINUOUS_VI_PKTS 4
  72. /* Hardware queue info */
  73. #define BROADCAST_HW_Q 9
  74. #define MGMT_HW_Q 10
  75. #define BEACON_HW_Q 11
  76. #define IEEE80211_MGMT_FRAME 0x00
  77. #define IEEE80211_CTL_FRAME 0x04
  78. #define RSI_MAX_ASSOC_STAS 32
  79. #define IEEE80211_QOS_TID 0x0f
  80. #define IEEE80211_NONQOS_TID 16
  81. #define MAX_DEBUGFS_ENTRIES 4
  82. #define TID_TO_WME_AC(_tid) ( \
  83. ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
  84. ((_tid) < 3) ? BK_Q : \
  85. ((_tid) < 6) ? VI_Q : \
  86. VO_Q)
  87. #define WME_AC(_q) ( \
  88. ((_q) == BK_Q) ? IEEE80211_AC_BK : \
  89. ((_q) == BE_Q) ? IEEE80211_AC_BE : \
  90. ((_q) == VI_Q) ? IEEE80211_AC_VI : \
  91. IEEE80211_AC_VO)
  92. /* WoWLAN flags */
  93. #define RSI_WOW_ENABLED BIT(0)
  94. #define RSI_WOW_NO_CONNECTION BIT(1)
  95. #define RSI_MAX_RX_PKTS 64
  96. enum rsi_dev_model {
  97. RSI_DEV_9113 = 0,
  98. RSI_DEV_9116
  99. };
  100. struct version_info {
  101. u16 major;
  102. u16 minor;
  103. u8 release_num;
  104. u8 patch_num;
  105. union {
  106. struct {
  107. u8 fw_ver[8];
  108. } info;
  109. } ver;
  110. } __packed;
  111. struct skb_info {
  112. s8 rssi;
  113. u32 flags;
  114. u16 channel;
  115. s8 tid;
  116. s8 sta_id;
  117. u8 internal_hdr_size;
  118. struct ieee80211_vif *vif;
  119. u8 vap_id;
  120. };
  121. enum edca_queue {
  122. BK_Q,
  123. BE_Q,
  124. VI_Q,
  125. VO_Q,
  126. MGMT_SOFT_Q,
  127. MGMT_BEACON_Q
  128. };
  129. struct security_info {
  130. u32 ptk_cipher;
  131. u32 gtk_cipher;
  132. };
  133. struct wmm_qinfo {
  134. s32 weight;
  135. s32 wme_params;
  136. s32 pkt_contended;
  137. s32 txop;
  138. };
  139. struct transmit_q_stats {
  140. u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 2];
  141. u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2];
  142. };
  143. #define MAX_BGSCAN_CHANNELS_DUAL_BAND 38
  144. #define MAX_BGSCAN_PROBE_REQ_LEN 0x64
  145. #define RSI_DEF_BGSCAN_THRLD 0x0
  146. #define RSI_DEF_ROAM_THRLD 0xa
  147. #define RSI_BGSCAN_PERIODICITY 0x1e
  148. #define RSI_ACTIVE_SCAN_TIME 0x14
  149. #define RSI_PASSIVE_SCAN_TIME 0x46
  150. #define RSI_CHANNEL_SCAN_TIME 20
  151. struct rsi_bgscan_params {
  152. u16 bgscan_threshold;
  153. u16 roam_threshold;
  154. u16 bgscan_periodicity;
  155. u8 num_bgscan_channels;
  156. u8 two_probe;
  157. u16 active_scan_duration;
  158. u16 passive_scan_duration;
  159. };
  160. struct vif_priv {
  161. bool is_ht;
  162. bool sgi;
  163. u16 seq_start;
  164. int vap_id;
  165. };
  166. struct rsi_event {
  167. atomic_t event_condition;
  168. wait_queue_head_t event_queue;
  169. };
  170. struct rsi_thread {
  171. void (*thread_function)(void *);
  172. struct completion completion;
  173. struct task_struct *task;
  174. struct rsi_event event;
  175. atomic_t thread_done;
  176. };
  177. struct cqm_info {
  178. s8 last_cqm_event_rssi;
  179. int rssi_thold;
  180. u32 rssi_hyst;
  181. };
  182. enum rsi_dfs_regions {
  183. RSI_REGION_FCC = 0,
  184. RSI_REGION_ETSI,
  185. RSI_REGION_TELEC,
  186. RSI_REGION_WORLD
  187. };
  188. struct rsi_9116_features {
  189. u8 pll_mode;
  190. u8 rf_type;
  191. u8 wireless_mode;
  192. u8 afe_type;
  193. u8 enable_ppe;
  194. u8 dpd;
  195. u32 sifs_tx_enable;
  196. u32 ps_options;
  197. };
  198. struct rsi_common {
  199. struct rsi_hw *priv;
  200. struct vif_priv vif_info[RSI_MAX_VIFS];
  201. void *coex_cb;
  202. bool mgmt_q_block;
  203. struct version_info lmac_ver;
  204. struct rsi_thread tx_thread;
  205. struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
  206. struct completion wlan_init_completion;
  207. /* Mutex declaration */
  208. struct mutex mutex;
  209. /* Mutex used for tx thread */
  210. struct mutex tx_lock;
  211. /* Mutex used for rx thread */
  212. struct mutex rx_lock;
  213. u8 endpoint;
  214. /* Channel/band related */
  215. u8 band;
  216. u8 num_supp_bands;
  217. u8 channel_width;
  218. u16 rts_threshold;
  219. u16 bitrate_mask[2];
  220. u32 fixedrate_mask[2];
  221. u8 rf_reset;
  222. struct transmit_q_stats tx_stats;
  223. struct security_info secinfo;
  224. struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
  225. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  226. u8 mac_addr[IEEE80211_ADDR_LEN];
  227. /* state related */
  228. u32 fsm_state;
  229. bool init_done;
  230. u8 bb_rf_prog_count;
  231. bool iface_down;
  232. /* Generic */
  233. u8 channel;
  234. u8 *rx_data_pkt;
  235. u8 mac_id;
  236. u8 radio_id;
  237. u16 rate_pwr[20];
  238. u16 min_rate;
  239. /* WMM algo related */
  240. u8 selected_qnum;
  241. u32 pkt_cnt;
  242. u8 min_weight;
  243. /* bgscan related */
  244. struct cqm_info cqm_info;
  245. bool hw_data_qs_blocked;
  246. u8 driver_mode;
  247. u8 coex_mode;
  248. u16 oper_mode;
  249. u8 lp_ps_handshake_mode;
  250. u8 ulp_ps_handshake_mode;
  251. u8 uapsd_bitmap;
  252. u8 rf_power_val;
  253. u8 wlan_rf_power_mode;
  254. u8 obm_ant_sel_val;
  255. int tx_power;
  256. u8 ant_in_use;
  257. /* Mutex used for writing packet to bus */
  258. struct mutex tx_bus_mutex;
  259. bool hibernate_resume;
  260. bool reinit_hw;
  261. u8 wow_flags;
  262. u16 beacon_interval;
  263. u8 dtim_cnt;
  264. /* AP mode parameters */
  265. u8 beacon_enabled;
  266. u16 beacon_cnt;
  267. struct rsi_sta stations[RSI_MAX_ASSOC_STAS + 1];
  268. int num_stations;
  269. int max_stations;
  270. struct ieee80211_key_conf *key;
  271. /* Wi-Fi direct mode related */
  272. bool p2p_enabled;
  273. struct timer_list roc_timer;
  274. struct ieee80211_vif *roc_vif;
  275. bool eapol4_confirm;
  276. void *bt_adapter;
  277. struct cfg80211_scan_request *hwscan;
  278. struct rsi_bgscan_params bgscan;
  279. struct rsi_9116_features w9116_features;
  280. u8 bgscan_en;
  281. u8 mac_ops_resumed;
  282. };
  283. struct eepromrw_info {
  284. u32 offset;
  285. u32 length;
  286. u8 write;
  287. u16 eeprom_erase;
  288. u8 data[480];
  289. };
  290. struct eeprom_read {
  291. u16 length;
  292. u16 off_set;
  293. };
  294. struct rsi_hw {
  295. struct rsi_common *priv;
  296. enum rsi_dev_model device_model;
  297. struct ieee80211_hw *hw;
  298. struct ieee80211_vif *vifs[RSI_MAX_VIFS];
  299. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  300. struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
  301. struct device *device;
  302. u8 sc_nvifs;
  303. enum rsi_host_intf rsi_host_intf;
  304. u16 block_size;
  305. enum ps_state ps_state;
  306. struct rsi_ps_info ps_info;
  307. spinlock_t ps_lock; /*To protect power save config*/
  308. u32 usb_buffer_status_reg;
  309. #ifdef CONFIG_RSI_DEBUGFS
  310. struct rsi_debugfs *dfsentry;
  311. u8 num_debugfs_entries;
  312. #endif
  313. char *fw_file_name;
  314. struct timer_list bl_cmd_timer;
  315. bool blcmd_timer_expired;
  316. u32 flash_capacity;
  317. struct eepromrw_info eeprom;
  318. u32 interrupt_status;
  319. u8 dfs_region;
  320. char country[2];
  321. void *rsi_dev;
  322. struct rsi_host_intf_ops *host_intf_ops;
  323. int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
  324. int (*determine_event_timeout)(struct rsi_hw *adapter);
  325. };
  326. void rsi_print_version(struct rsi_common *common);
  327. struct rsi_host_intf_ops {
  328. int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  329. int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  330. int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
  331. int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
  332. u8 *data, u16 count);
  333. int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
  334. u8 *data, u16 count);
  335. int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
  336. u32 *read_buf, u16 size);
  337. int (*master_reg_write)(struct rsi_hw *adapter,
  338. unsigned long addr, unsigned long data,
  339. u16 size);
  340. int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
  341. u32 instructions_size, u16 block_size,
  342. u8 *fw);
  343. int (*reinit_device)(struct rsi_hw *adapter);
  344. int (*ta_reset)(struct rsi_hw *adapter);
  345. };
  346. enum rsi_host_intf rsi_get_host_intf(void *priv);
  347. void rsi_set_bt_context(void *priv, void *bt_context);
  348. #endif