rsi_main.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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. struct xtended_desc {
  164. u8 confirm_frame_type;
  165. u8 retry_cnt;
  166. u16 reserved;
  167. };
  168. enum rsi_dfs_regions {
  169. RSI_REGION_FCC = 0,
  170. RSI_REGION_ETSI,
  171. RSI_REGION_TELEC,
  172. RSI_REGION_WORLD
  173. };
  174. struct rsi_common {
  175. struct rsi_hw *priv;
  176. struct vif_priv vif_info[RSI_MAX_VIFS];
  177. void *coex_cb;
  178. bool mgmt_q_block;
  179. struct version_info lmac_ver;
  180. struct rsi_thread tx_thread;
  181. struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
  182. struct completion wlan_init_completion;
  183. /* Mutex declaration */
  184. struct mutex mutex;
  185. /* Mutex used for tx thread */
  186. struct mutex tx_lock;
  187. /* Mutex used for rx thread */
  188. struct mutex rx_lock;
  189. u8 endpoint;
  190. /* Channel/band related */
  191. u8 band;
  192. u8 num_supp_bands;
  193. u8 channel_width;
  194. u16 rts_threshold;
  195. u16 bitrate_mask[2];
  196. u32 fixedrate_mask[2];
  197. u8 rf_reset;
  198. struct transmit_q_stats tx_stats;
  199. struct security_info secinfo;
  200. struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
  201. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  202. u8 mac_addr[IEEE80211_ADDR_LEN];
  203. /* state related */
  204. u32 fsm_state;
  205. bool init_done;
  206. u8 bb_rf_prog_count;
  207. bool iface_down;
  208. /* Generic */
  209. u8 channel;
  210. u8 *rx_data_pkt;
  211. u8 mac_id;
  212. u8 radio_id;
  213. u16 rate_pwr[20];
  214. u16 min_rate;
  215. /* WMM algo related */
  216. u8 selected_qnum;
  217. u32 pkt_cnt;
  218. u8 min_weight;
  219. /* bgscan related */
  220. struct cqm_info cqm_info;
  221. bool hw_data_qs_blocked;
  222. u8 driver_mode;
  223. u8 coex_mode;
  224. u16 oper_mode;
  225. u8 lp_ps_handshake_mode;
  226. u8 ulp_ps_handshake_mode;
  227. u8 uapsd_bitmap;
  228. u8 rf_power_val;
  229. u8 wlan_rf_power_mode;
  230. u8 obm_ant_sel_val;
  231. int tx_power;
  232. u8 ant_in_use;
  233. /* Mutex used for writing packet to bus */
  234. struct mutex tx_bus_mutex;
  235. bool hibernate_resume;
  236. bool reinit_hw;
  237. u8 wow_flags;
  238. u16 beacon_interval;
  239. u8 dtim_cnt;
  240. /* AP mode parameters */
  241. u8 beacon_enabled;
  242. u16 beacon_cnt;
  243. struct rsi_sta stations[RSI_MAX_ASSOC_STAS + 1];
  244. int num_stations;
  245. int max_stations;
  246. struct ieee80211_key_conf *key;
  247. /* Wi-Fi direct mode related */
  248. bool p2p_enabled;
  249. struct timer_list roc_timer;
  250. struct ieee80211_vif *roc_vif;
  251. void *bt_adapter;
  252. };
  253. struct eepromrw_info {
  254. u32 offset;
  255. u32 length;
  256. u8 write;
  257. u16 eeprom_erase;
  258. u8 data[480];
  259. };
  260. struct eeprom_read {
  261. u16 length;
  262. u16 off_set;
  263. };
  264. struct rsi_hw {
  265. struct rsi_common *priv;
  266. u8 device_model;
  267. struct ieee80211_hw *hw;
  268. struct ieee80211_vif *vifs[RSI_MAX_VIFS];
  269. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  270. struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
  271. struct device *device;
  272. u8 sc_nvifs;
  273. enum rsi_host_intf rsi_host_intf;
  274. u16 block_size;
  275. enum ps_state ps_state;
  276. struct rsi_ps_info ps_info;
  277. spinlock_t ps_lock; /*To protect power save config*/
  278. u32 usb_buffer_status_reg;
  279. #ifdef CONFIG_RSI_DEBUGFS
  280. struct rsi_debugfs *dfsentry;
  281. u8 num_debugfs_entries;
  282. #endif
  283. char *fw_file_name;
  284. struct timer_list bl_cmd_timer;
  285. bool blcmd_timer_expired;
  286. u32 flash_capacity;
  287. struct eepromrw_info eeprom;
  288. u32 interrupt_status;
  289. u8 dfs_region;
  290. char country[2];
  291. void *rsi_dev;
  292. struct rsi_host_intf_ops *host_intf_ops;
  293. int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
  294. int (*determine_event_timeout)(struct rsi_hw *adapter);
  295. };
  296. void rsi_print_version(struct rsi_common *common);
  297. struct rsi_host_intf_ops {
  298. int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  299. int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  300. int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
  301. int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
  302. u8 *data, u16 count);
  303. int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
  304. u8 *data, u16 count);
  305. int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
  306. u32 *read_buf, u16 size);
  307. int (*master_reg_write)(struct rsi_hw *adapter,
  308. unsigned long addr, unsigned long data,
  309. u16 size);
  310. int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
  311. u32 instructions_size, u16 block_size,
  312. u8 *fw);
  313. int (*reinit_device)(struct rsi_hw *adapter);
  314. };
  315. enum rsi_host_intf rsi_get_host_intf(void *priv);
  316. void rsi_set_bt_context(void *priv, void *bt_context);
  317. #endif