sta_info.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __STA_INFO_H_
  21. #define __STA_INFO_H_
  22. #include <osdep_service.h>
  23. #include <drv_types.h>
  24. #include <wifi.h>
  25. #define IBSS_START_MAC_ID 2
  26. #define NUM_STA 32
  27. #define NUM_ACL 16
  28. /* if mode ==0, then the sta is allowed once the addr is hit. */
  29. /* if mode ==1, then the sta is rejected once the addr is non-hit. */
  30. struct rtw_wlan_acl_node {
  31. struct list_head list;
  32. u8 addr[ETH_ALEN];
  33. u8 valid;
  34. };
  35. /* mode=0, disable */
  36. /* mode=1, accept unless in deny list */
  37. /* mode=2, deny unless in accept list */
  38. struct wlan_acl_pool {
  39. int mode;
  40. int num;
  41. struct rtw_wlan_acl_node aclnode[NUM_ACL];
  42. struct __queue acl_node_q;
  43. };
  44. struct rssi_sta {
  45. s32 UndecoratedSmoothedPWDB;
  46. s32 UndecoratedSmoothedCCK;
  47. s32 UndecoratedSmoothedOFDM;
  48. u64 PacketMap;
  49. u8 ValidBit;
  50. };
  51. struct stainfo_stats {
  52. u64 rx_mgnt_pkts;
  53. u64 rx_beacon_pkts;
  54. u64 rx_probereq_pkts;
  55. u64 rx_probersp_pkts;
  56. u64 rx_probersp_bm_pkts;
  57. u64 rx_probersp_uo_pkts;
  58. u64 rx_ctrl_pkts;
  59. u64 rx_data_pkts;
  60. u64 last_rx_mgnt_pkts;
  61. u64 last_rx_beacon_pkts;
  62. u64 last_rx_probereq_pkts;
  63. u64 last_rx_probersp_pkts;
  64. u64 last_rx_probersp_bm_pkts;
  65. u64 last_rx_probersp_uo_pkts;
  66. u64 last_rx_ctrl_pkts;
  67. u64 last_rx_data_pkts;
  68. u64 rx_bytes;
  69. u64 rx_drops;
  70. u64 tx_pkts;
  71. u64 tx_bytes;
  72. u64 tx_drops;
  73. };
  74. struct sta_info {
  75. spinlock_t lock;
  76. struct list_head list; /* free_sta_queue */
  77. struct list_head hash_list; /* sta_hash */
  78. struct sta_xmit_priv sta_xmitpriv;
  79. struct sta_recv_priv sta_recvpriv;
  80. struct __queue sleep_q;
  81. unsigned int sleepq_len;
  82. uint state;
  83. uint aid;
  84. uint mac_id;
  85. uint qos_option;
  86. u8 hwaddr[ETH_ALEN];
  87. uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
  88. uint dot118021XPrivacy; /* aes, tkip... */
  89. union Keytype dot11tkiptxmickey;
  90. union Keytype dot11tkiprxmickey;
  91. union Keytype dot118021x_UncstKey;
  92. union pn48 dot11txpn; /* PN48 used for Unicast xmit. */
  93. union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
  94. u8 bssrateset[16];
  95. u32 bssratelen;
  96. s32 rssi;
  97. s32 signal_quality;
  98. u8 cts2self;
  99. u8 rtsen;
  100. u8 raid;
  101. u8 init_rate;
  102. u8 wireless_mode; /* NETWORK_TYPE */
  103. struct stainfo_stats sta_stats;
  104. /* for A-MPDU TX, ADDBA timeout check */
  105. struct timer_list addba_retry_timer;
  106. /* for A-MPDU Rx reordering buffer control */
  107. struct recv_reorder_ctrl recvreorder_ctrl[16];
  108. /* for A-MPDU Tx */
  109. /* unsigned char ampdu_txen_bitmap; */
  110. u16 BA_starting_seqctrl[16];
  111. struct ht_priv htpriv;
  112. /* Notes: */
  113. /* STA_Mode: */
  114. /* curr_network(mlme_priv/security_priv/qos/ht) +
  115. * sta_info: (STA & AP) CAP/INFO */
  116. /* scan_q: AP CAP/INFO */
  117. /* AP_Mode: */
  118. /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
  119. /* sta_info: (AP & STA) CAP/INFO */
  120. struct list_head asoc_list;
  121. #ifdef CONFIG_88EU_AP_MODE
  122. struct list_head auth_list;
  123. unsigned int expire_to;
  124. unsigned int auth_seq;
  125. unsigned int authalg;
  126. unsigned char chg_txt[128];
  127. u16 capability;
  128. int flags;
  129. int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
  130. int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
  131. int wpa_group_cipher;
  132. int wpa2_group_cipher;
  133. int wpa_pairwise_cipher;
  134. int wpa2_pairwise_cipher;
  135. u8 bpairwise_key_installed;
  136. u8 wpa_ie[32];
  137. u8 nonerp_set;
  138. u8 no_short_slot_time_set;
  139. u8 no_short_preamble_set;
  140. u8 no_ht_gf_set;
  141. u8 no_ht_set;
  142. u8 ht_20mhz_set;
  143. unsigned int tx_ra_bitmap;
  144. u8 qos_info;
  145. u8 max_sp_len;
  146. u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
  147. u8 uapsd_be;
  148. u8 uapsd_vi;
  149. u8 uapsd_vo;
  150. u8 has_legacy_ac;
  151. unsigned int sleepq_ac_len;
  152. #endif /* CONFIG_88EU_AP_MODE */
  153. u8 under_exist_checking;
  154. u8 keep_alive_trycnt;
  155. /* for DM */
  156. struct rssi_sta rssi_stat;
  157. /* ================ODM Relative Info======================= */
  158. /* Please be careful, don't declare too much structure here.
  159. * It will cost memory * STA support num. */
  160. /* 2011/10/20 MH Add for ODM STA info. */
  161. /* Driver Write */
  162. u8 bValid; /* record the sta status link or not? */
  163. u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
  164. u8 rssi_level; /* for Refresh RA mask */
  165. /* ODM Write */
  166. /* 1 PHY_STATUS_INFO */
  167. u8 RSSI_Path[4]; /* */
  168. u8 RSSI_Ave;
  169. u8 RXEVM[4];
  170. u8 RXSNR[4];
  171. /* ================ODM Relative Info======================= */
  172. /* */
  173. /* To store the sequence number of received management frame */
  174. u16 RxMgmtFrameSeqNum;
  175. };
  176. #define sta_rx_pkts(sta) \
  177. (sta->sta_stats.rx_mgnt_pkts \
  178. + sta->sta_stats.rx_ctrl_pkts \
  179. + sta->sta_stats.rx_data_pkts)
  180. #define sta_last_rx_pkts(sta) \
  181. (sta->sta_stats.last_rx_mgnt_pkts \
  182. + sta->sta_stats.last_rx_ctrl_pkts \
  183. + sta->sta_stats.last_rx_data_pkts)
  184. #define sta_rx_data_pkts(sta) \
  185. (sta->sta_stats.rx_data_pkts)
  186. #define sta_last_rx_data_pkts(sta) \
  187. (sta->sta_stats.last_rx_data_pkts)
  188. #define sta_rx_mgnt_pkts(sta) \
  189. (sta->sta_stats.rx_mgnt_pkts)
  190. #define sta_last_rx_mgnt_pkts(sta) \
  191. (sta->sta_stats.last_rx_mgnt_pkts)
  192. #define sta_rx_beacon_pkts(sta) \
  193. (sta->sta_stats.rx_beacon_pkts)
  194. #define sta_last_rx_beacon_pkts(sta) \
  195. (sta->sta_stats.last_rx_beacon_pkts)
  196. #define sta_rx_probereq_pkts(sta) \
  197. (sta->sta_stats.rx_probereq_pkts)
  198. #define sta_last_rx_probereq_pkts(sta) \
  199. (sta->sta_stats.last_rx_probereq_pkts)
  200. #define sta_rx_probersp_pkts(sta) \
  201. (sta->sta_stats.rx_probersp_pkts)
  202. #define sta_last_rx_probersp_pkts(sta) \
  203. (sta->sta_stats.last_rx_probersp_pkts)
  204. #define sta_rx_probersp_bm_pkts(sta) \
  205. (sta->sta_stats.rx_probersp_bm_pkts)
  206. #define sta_last_rx_probersp_bm_pkts(sta) \
  207. (sta->sta_stats.last_rx_probersp_bm_pkts)
  208. #define sta_rx_probersp_uo_pkts(sta) \
  209. (sta->sta_stats.rx_probersp_uo_pkts)
  210. #define sta_last_rx_probersp_uo_pkts(sta) \
  211. (sta->sta_stats.last_rx_probersp_uo_pkts)
  212. #define sta_update_last_rx_pkts(sta) \
  213. do { \
  214. sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
  215. sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
  216. sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
  217. sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
  218. sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
  219. sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
  220. sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
  221. sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
  222. } while (0)
  223. #define STA_RX_PKTS_ARG(sta) \
  224. sta->sta_stats.rx_mgnt_pkts \
  225. , sta->sta_stats.rx_ctrl_pkts \
  226. , sta->sta_stats.rx_data_pkts
  227. #define STA_LAST_RX_PKTS_ARG(sta) \
  228. sta->sta_stats.last_rx_mgnt_pkts \
  229. , sta->sta_stats.last_rx_ctrl_pkts \
  230. , sta->sta_stats.last_rx_data_pkts
  231. #define STA_RX_PKTS_DIFF_ARG(sta) \
  232. sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
  233. , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
  234. , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
  235. #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
  236. struct sta_priv {
  237. u8 *pallocated_stainfo_buf;
  238. u8 *pstainfo_buf;
  239. struct __queue free_sta_queue;
  240. spinlock_t sta_hash_lock;
  241. struct list_head sta_hash[NUM_STA];
  242. int asoc_sta_count;
  243. struct __queue sleep_q;
  244. struct __queue wakeup_q;
  245. struct adapter *padapter;
  246. spinlock_t asoc_list_lock;
  247. struct list_head asoc_list;
  248. #ifdef CONFIG_88EU_AP_MODE
  249. struct list_head auth_list;
  250. spinlock_t auth_list_lock;
  251. u8 asoc_list_cnt;
  252. u8 auth_list_cnt;
  253. unsigned int auth_to; /* sec, time to expire in authenticating. */
  254. unsigned int assoc_to; /* sec, time to expire before associating. */
  255. unsigned int expire_to; /* sec , time to expire after associated. */
  256. /* pointers to STA info; based on allocated AID or NULL if AID free
  257. * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
  258. * and so on
  259. */
  260. struct sta_info *sta_aid[NUM_STA];
  261. u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
  262. * for sleeping sta. */
  263. u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping
  264. * bit0~bit15 */
  265. u16 max_num_sta;
  266. struct wlan_acl_pool acl_list;
  267. #endif
  268. };
  269. static inline u32 wifi_mac_hash(u8 *mac)
  270. {
  271. u32 x;
  272. x = mac[0];
  273. x = (x << 2) ^ mac[1];
  274. x = (x << 2) ^ mac[2];
  275. x = (x << 2) ^ mac[3];
  276. x = (x << 2) ^ mac[4];
  277. x = (x << 2) ^ mac[5];
  278. x ^= x >> 8;
  279. x = x & (NUM_STA - 1);
  280. return x;
  281. }
  282. u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
  283. u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
  284. #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
  285. int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
  286. struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off);
  287. struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
  288. u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta);
  289. void rtw_free_all_stainfo(struct adapter *adapt);
  290. struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
  291. u32 rtw_init_bcmc_stainfo(struct adapter *adapt);
  292. struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
  293. u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
  294. #endif /* _STA_INFO_H_ */