rsi_main.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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_DEV_9113 1
  96. #define RSI_MAX_RX_PKTS 64
  97. struct version_info {
  98. u16 major;
  99. u16 minor;
  100. u8 release_num;
  101. u8 patch_num;
  102. union {
  103. struct {
  104. u8 fw_ver[8];
  105. } info;
  106. } ver;
  107. } __packed;
  108. struct skb_info {
  109. s8 rssi;
  110. u32 flags;
  111. u16 channel;
  112. s8 tid;
  113. s8 sta_id;
  114. u8 internal_hdr_size;
  115. struct ieee80211_vif *vif;
  116. u8 vap_id;
  117. };
  118. enum edca_queue {
  119. BK_Q,
  120. BE_Q,
  121. VI_Q,
  122. VO_Q,
  123. MGMT_SOFT_Q,
  124. MGMT_BEACON_Q
  125. };
  126. struct security_info {
  127. bool security_enable;
  128. u32 ptk_cipher;
  129. u32 gtk_cipher;
  130. };
  131. struct wmm_qinfo {
  132. s32 weight;
  133. s32 wme_params;
  134. s32 pkt_contended;
  135. s32 txop;
  136. };
  137. struct transmit_q_stats {
  138. u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 2];
  139. u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2];
  140. };
  141. struct vif_priv {
  142. bool is_ht;
  143. bool sgi;
  144. u16 seq_start;
  145. int vap_id;
  146. };
  147. struct rsi_event {
  148. atomic_t event_condition;
  149. wait_queue_head_t event_queue;
  150. };
  151. struct rsi_thread {
  152. void (*thread_function)(void *);
  153. struct completion completion;
  154. struct task_struct *task;
  155. struct rsi_event event;
  156. atomic_t thread_done;
  157. };
  158. struct cqm_info {
  159. s8 last_cqm_event_rssi;
  160. int rssi_thold;
  161. u32 rssi_hyst;
  162. };
  163. enum rsi_dfs_regions {
  164. RSI_REGION_FCC = 0,
  165. RSI_REGION_ETSI,
  166. RSI_REGION_TELEC,
  167. RSI_REGION_WORLD
  168. };
  169. struct rsi_common {
  170. struct rsi_hw *priv;
  171. struct vif_priv vif_info[RSI_MAX_VIFS];
  172. void *coex_cb;
  173. bool mgmt_q_block;
  174. struct version_info lmac_ver;
  175. struct rsi_thread tx_thread;
  176. struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
  177. struct completion wlan_init_completion;
  178. /* Mutex declaration */
  179. struct mutex mutex;
  180. /* Mutex used for tx thread */
  181. struct mutex tx_lock;
  182. /* Mutex used for rx thread */
  183. struct mutex rx_lock;
  184. u8 endpoint;
  185. /* Channel/band related */
  186. u8 band;
  187. u8 num_supp_bands;
  188. u8 channel_width;
  189. u16 rts_threshold;
  190. u16 bitrate_mask[2];
  191. u32 fixedrate_mask[2];
  192. u8 rf_reset;
  193. struct transmit_q_stats tx_stats;
  194. struct security_info secinfo;
  195. struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
  196. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  197. u8 mac_addr[IEEE80211_ADDR_LEN];
  198. /* state related */
  199. u32 fsm_state;
  200. bool init_done;
  201. u8 bb_rf_prog_count;
  202. bool iface_down;
  203. /* Generic */
  204. u8 channel;
  205. u8 *rx_data_pkt;
  206. u8 mac_id;
  207. u8 radio_id;
  208. u16 rate_pwr[20];
  209. u16 min_rate;
  210. /* WMM algo related */
  211. u8 selected_qnum;
  212. u32 pkt_cnt;
  213. u8 min_weight;
  214. /* bgscan related */
  215. struct cqm_info cqm_info;
  216. bool hw_data_qs_blocked;
  217. u8 driver_mode;
  218. u8 coex_mode;
  219. u16 oper_mode;
  220. u8 lp_ps_handshake_mode;
  221. u8 ulp_ps_handshake_mode;
  222. u8 uapsd_bitmap;
  223. u8 rf_power_val;
  224. u8 wlan_rf_power_mode;
  225. u8 obm_ant_sel_val;
  226. int tx_power;
  227. u8 ant_in_use;
  228. /* Mutex used for writing packet to bus */
  229. struct mutex tx_bus_mutex;
  230. bool hibernate_resume;
  231. bool reinit_hw;
  232. u8 wow_flags;
  233. u16 beacon_interval;
  234. u8 dtim_cnt;
  235. /* AP mode parameters */
  236. u8 beacon_enabled;
  237. u16 beacon_cnt;
  238. struct rsi_sta stations[RSI_MAX_ASSOC_STAS + 1];
  239. int num_stations;
  240. int max_stations;
  241. struct ieee80211_key_conf *key;
  242. /* Wi-Fi direct mode related */
  243. bool p2p_enabled;
  244. struct timer_list roc_timer;
  245. struct ieee80211_vif *roc_vif;
  246. bool eapol4_confirm;
  247. void *bt_adapter;
  248. };
  249. struct eepromrw_info {
  250. u32 offset;
  251. u32 length;
  252. u8 write;
  253. u16 eeprom_erase;
  254. u8 data[480];
  255. };
  256. struct eeprom_read {
  257. u16 length;
  258. u16 off_set;
  259. };
  260. struct rsi_hw {
  261. struct rsi_common *priv;
  262. u8 device_model;
  263. struct ieee80211_hw *hw;
  264. struct ieee80211_vif *vifs[RSI_MAX_VIFS];
  265. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  266. struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
  267. struct device *device;
  268. u8 sc_nvifs;
  269. enum rsi_host_intf rsi_host_intf;
  270. u16 block_size;
  271. enum ps_state ps_state;
  272. struct rsi_ps_info ps_info;
  273. spinlock_t ps_lock; /*To protect power save config*/
  274. u32 usb_buffer_status_reg;
  275. #ifdef CONFIG_RSI_DEBUGFS
  276. struct rsi_debugfs *dfsentry;
  277. u8 num_debugfs_entries;
  278. #endif
  279. char *fw_file_name;
  280. struct timer_list bl_cmd_timer;
  281. bool blcmd_timer_expired;
  282. u32 flash_capacity;
  283. struct eepromrw_info eeprom;
  284. u32 interrupt_status;
  285. u8 dfs_region;
  286. char country[2];
  287. void *rsi_dev;
  288. struct rsi_host_intf_ops *host_intf_ops;
  289. int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
  290. int (*determine_event_timeout)(struct rsi_hw *adapter);
  291. };
  292. void rsi_print_version(struct rsi_common *common);
  293. struct rsi_host_intf_ops {
  294. int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  295. int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  296. int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
  297. int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
  298. u8 *data, u16 count);
  299. int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
  300. u8 *data, u16 count);
  301. int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
  302. u32 *read_buf, u16 size);
  303. int (*master_reg_write)(struct rsi_hw *adapter,
  304. unsigned long addr, unsigned long data,
  305. u16 size);
  306. int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
  307. u32 instructions_size, u16 block_size,
  308. u8 *fw);
  309. int (*reinit_device)(struct rsi_hw *adapter);
  310. };
  311. enum rsi_host_intf rsi_get_host_intf(void *priv);
  312. void rsi_set_bt_context(void *priv, void *bt_context);
  313. #endif