rsi_main.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. #define ERR_ZONE BIT(0) /* For Error Msgs */
  22. #define INFO_ZONE BIT(1) /* For General Status Msgs */
  23. #define INIT_ZONE BIT(2) /* For Driver Init Seq Msgs */
  24. #define MGMT_TX_ZONE BIT(3) /* For TX Mgmt Path Msgs */
  25. #define MGMT_RX_ZONE BIT(4) /* For RX Mgmt Path Msgs */
  26. #define DATA_TX_ZONE BIT(5) /* For TX Data Path Msgs */
  27. #define DATA_RX_ZONE BIT(6) /* For RX Data Path Msgs */
  28. #define FSM_ZONE BIT(7) /* For State Machine Msgs */
  29. #define ISR_ZONE BIT(8) /* For Interrupt Msgs */
  30. #define FSM_CARD_NOT_READY 0
  31. #define FSM_BOOT_PARAMS_SENT 1
  32. #define FSM_EEPROM_READ_MAC_ADDR 2
  33. #define FSM_RESET_MAC_SENT 3
  34. #define FSM_RADIO_CAPS_SENT 4
  35. #define FSM_BB_RF_PROG_SENT 5
  36. #define FSM_MAC_INIT_DONE 6
  37. extern u32 rsi_zone_enabled;
  38. extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
  39. #define RSI_MAX_VIFS 1
  40. #define NUM_EDCA_QUEUES 4
  41. #define IEEE80211_ADDR_LEN 6
  42. #define FRAME_DESC_SZ 16
  43. #define MIN_802_11_HDR_LEN 24
  44. #define DATA_QUEUE_WATER_MARK 400
  45. #define MIN_DATA_QUEUE_WATER_MARK 300
  46. #define MULTICAST_WATER_MARK 200
  47. #define MAC_80211_HDR_FRAME_CONTROL 0
  48. #define WME_NUM_AC 4
  49. #define NUM_SOFT_QUEUES 5
  50. #define MAX_HW_QUEUES 8
  51. #define INVALID_QUEUE 0xff
  52. #define MAX_CONTINUOUS_VO_PKTS 8
  53. #define MAX_CONTINUOUS_VI_PKTS 4
  54. /* Queue information */
  55. #define RSI_WIFI_MGMT_Q 0x4
  56. #define RSI_WIFI_DATA_Q 0x5
  57. #define IEEE80211_MGMT_FRAME 0x00
  58. #define IEEE80211_CTL_FRAME 0x04
  59. #define IEEE80211_QOS_TID 0x0f
  60. #define IEEE80211_NONQOS_TID 16
  61. #define MAX_DEBUGFS_ENTRIES 4
  62. #define TID_TO_WME_AC(_tid) ( \
  63. ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
  64. ((_tid) < 3) ? BK_Q : \
  65. ((_tid) < 6) ? VI_Q : \
  66. VO_Q)
  67. #define WME_AC(_q) ( \
  68. ((_q) == BK_Q) ? IEEE80211_AC_BK : \
  69. ((_q) == BE_Q) ? IEEE80211_AC_BE : \
  70. ((_q) == VI_Q) ? IEEE80211_AC_VI : \
  71. IEEE80211_AC_VO)
  72. struct version_info {
  73. u16 major;
  74. u16 minor;
  75. u16 release_num;
  76. u16 patch_num;
  77. } __packed;
  78. struct skb_info {
  79. s8 rssi;
  80. u32 flags;
  81. u16 channel;
  82. s8 tid;
  83. s8 sta_id;
  84. };
  85. enum edca_queue {
  86. BK_Q,
  87. BE_Q,
  88. VI_Q,
  89. VO_Q,
  90. MGMT_SOFT_Q
  91. };
  92. struct security_info {
  93. bool security_enable;
  94. u32 ptk_cipher;
  95. u32 gtk_cipher;
  96. };
  97. struct wmm_qinfo {
  98. s32 weight;
  99. s32 wme_params;
  100. s32 pkt_contended;
  101. s32 txop;
  102. };
  103. struct transmit_q_stats {
  104. u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 1];
  105. u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 1];
  106. };
  107. struct vif_priv {
  108. bool is_ht;
  109. bool sgi;
  110. u16 seq_start;
  111. };
  112. struct rsi_event {
  113. atomic_t event_condition;
  114. wait_queue_head_t event_queue;
  115. };
  116. struct rsi_thread {
  117. void (*thread_function)(void *);
  118. struct completion completion;
  119. struct task_struct *task;
  120. struct rsi_event event;
  121. atomic_t thread_done;
  122. };
  123. struct cqm_info {
  124. s8 last_cqm_event_rssi;
  125. int rssi_thold;
  126. u32 rssi_hyst;
  127. };
  128. struct rsi_hw;
  129. struct rsi_common {
  130. struct rsi_hw *priv;
  131. struct vif_priv vif_info[RSI_MAX_VIFS];
  132. bool mgmt_q_block;
  133. struct version_info driver_ver;
  134. struct version_info fw_ver;
  135. struct rsi_thread tx_thread;
  136. struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 1];
  137. /* Mutex declaration */
  138. struct mutex mutex;
  139. /* Mutex used between tx/rx threads */
  140. struct mutex tx_rxlock;
  141. u8 endpoint;
  142. /* Channel/band related */
  143. u8 band;
  144. u8 channel_width;
  145. u16 rts_threshold;
  146. u16 bitrate_mask[2];
  147. u32 fixedrate_mask[2];
  148. u8 rf_reset;
  149. struct transmit_q_stats tx_stats;
  150. struct security_info secinfo;
  151. struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
  152. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  153. u8 mac_addr[IEEE80211_ADDR_LEN];
  154. /* state related */
  155. u32 fsm_state;
  156. bool init_done;
  157. u8 bb_rf_prog_count;
  158. bool iface_down;
  159. /* Generic */
  160. u8 channel;
  161. u8 *rx_data_pkt;
  162. u8 mac_id;
  163. u8 radio_id;
  164. u16 rate_pwr[20];
  165. u16 min_rate;
  166. /* WMM algo related */
  167. u8 selected_qnum;
  168. u32 pkt_cnt;
  169. u8 min_weight;
  170. /* bgscan related */
  171. struct cqm_info cqm_info;
  172. bool hw_data_qs_blocked;
  173. };
  174. struct rsi_hw {
  175. struct rsi_common *priv;
  176. struct ieee80211_hw *hw;
  177. struct ieee80211_vif *vifs[RSI_MAX_VIFS];
  178. struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
  179. struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
  180. struct device *device;
  181. u8 sc_nvifs;
  182. #ifdef CONFIG_RSI_DEBUGFS
  183. struct rsi_debugfs *dfsentry;
  184. u8 num_debugfs_entries;
  185. #endif
  186. void *rsi_dev;
  187. int (*host_intf_read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  188. int (*host_intf_write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
  189. int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
  190. int (*rx_urb_submit)(struct rsi_hw *adapter);
  191. int (*determine_event_timeout)(struct rsi_hw *adapter);
  192. };
  193. #endif