sta_info.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. #define IBSS_START_MAC_ID 2
  23. #define NUM_STA 32
  24. #define NUM_ACL 16
  25. //if mode ==0, then the sta is allowed once the addr is hit.
  26. //if mode ==1, then the sta is rejected once the addr is non-hit.
  27. struct rtw_wlan_acl_node {
  28. _list list;
  29. u8 addr[ETH_ALEN];
  30. u8 valid;
  31. };
  32. //mode=0, disable
  33. //mode=1, accept unless in deny list
  34. //mode=2, deny unless in accept list
  35. struct wlan_acl_pool {
  36. int mode;
  37. int num;
  38. struct rtw_wlan_acl_node aclnode[NUM_ACL];
  39. _queue acl_node_q;
  40. };
  41. typedef struct _RSSI_STA{
  42. s32 UndecoratedSmoothedPWDB;
  43. s32 UndecoratedSmoothedCCK;
  44. s32 UndecoratedSmoothedOFDM;
  45. u64 PacketMap;
  46. u8 ValidBit;
  47. }RSSI_STA, *PRSSI_STA;
  48. struct stainfo_stats {
  49. u64 rx_mgnt_pkts;
  50. u64 rx_beacon_pkts;
  51. u64 rx_probereq_pkts;
  52. u64 rx_probersp_pkts;
  53. u64 rx_probersp_bm_pkts;
  54. u64 rx_probersp_uo_pkts;
  55. u64 rx_ctrl_pkts;
  56. u64 rx_data_pkts;
  57. u64 last_rx_mgnt_pkts;
  58. u64 last_rx_beacon_pkts;
  59. u64 last_rx_probereq_pkts;
  60. u64 last_rx_probersp_pkts;
  61. u64 last_rx_probersp_bm_pkts;
  62. u64 last_rx_probersp_uo_pkts;
  63. u64 last_rx_ctrl_pkts;
  64. u64 last_rx_data_pkts;
  65. u64 rx_bytes;
  66. u64 rx_drops;
  67. u64 tx_pkts;
  68. u64 tx_bytes;
  69. u64 tx_drops;
  70. };
  71. #ifdef CONFIG_TDLS
  72. struct TDLS_PeerKey {
  73. u8 kck[16]; /* TPK-KCK */
  74. u8 tk[16]; /* TPK-TK; only CCMP will be used */
  75. } ;
  76. #endif //CONFIG_TDLS
  77. struct sta_info {
  78. _lock lock;
  79. _list list; //free_sta_queue
  80. _list hash_list; //sta_hash
  81. //_list asoc_list; //20061114
  82. //_list sleep_list;//sleep_q
  83. //_list wakeup_list;//wakeup_q
  84. _adapter *padapter;
  85. struct sta_xmit_priv sta_xmitpriv;
  86. struct sta_recv_priv sta_recvpriv;
  87. _queue sleep_q;
  88. unsigned int sleepq_len;
  89. uint state;
  90. uint aid;
  91. uint mac_id;
  92. uint qos_option;
  93. u8 hwaddr[ETH_ALEN];
  94. uint ieee8021x_blocked; //0: allowed, 1:blocked
  95. uint dot118021XPrivacy; //aes, tkip...
  96. union Keytype dot11tkiptxmickey;
  97. union Keytype dot11tkiprxmickey;
  98. union Keytype dot118021x_UncstKey;
  99. union pn48 dot11txpn; // PN48 used for Unicast xmit.
  100. union pn48 dot11rxpn; // PN48 used for Unicast recv.
  101. u8 bssrateset[16];
  102. u32 bssratelen;
  103. s32 rssi;
  104. s32 signal_quality;
  105. u8 cts2self;
  106. u8 rtsen;
  107. u8 raid;
  108. u8 init_rate;
  109. u32 ra_mask;
  110. u8 wireless_mode; // NETWORK_TYPE
  111. struct stainfo_stats sta_stats;
  112. #ifdef CONFIG_TDLS
  113. u32 tdls_sta_state;
  114. u8 dialog;
  115. u8 SNonce[32];
  116. u8 ANonce[32];
  117. u32 TDLS_PeerKey_Lifetime;
  118. u16 TPK_count;
  119. _timer TPK_timer;
  120. struct TDLS_PeerKey tpk;
  121. u16 stat_code;
  122. u8 off_ch;
  123. u16 ch_switch_time;
  124. u16 ch_switch_timeout;
  125. u8 option;
  126. _timer option_timer;
  127. _timer base_ch_timer;
  128. _timer off_ch_timer;
  129. _timer handshake_timer;
  130. _timer alive_timer1;
  131. _timer alive_timer2;
  132. u8 timer_flag;
  133. u8 alive_count;
  134. #endif //CONFIG_TDLS
  135. //for A-MPDU TX, ADDBA timeout check
  136. _timer addba_retry_timer;
  137. //for A-MPDU Rx reordering buffer control
  138. struct recv_reorder_ctrl recvreorder_ctrl[16];
  139. //for A-MPDU Tx
  140. //unsigned char ampdu_txen_bitmap;
  141. u16 BA_starting_seqctrl[16];
  142. #ifdef CONFIG_80211N_HT
  143. struct ht_priv htpriv;
  144. #endif
  145. #ifdef CONFIG_80211AC_VHT
  146. struct vht_priv vhtpriv;
  147. #endif
  148. //Notes:
  149. //STA_Mode:
  150. //curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO
  151. //scan_q: AP CAP/INFO
  152. //AP_Mode:
  153. //curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
  154. //sta_info: (AP & STA) CAP/INFO
  155. #ifdef CONFIG_AP_MODE
  156. _list asoc_list;
  157. _list auth_list;
  158. unsigned int expire_to;
  159. unsigned int auth_seq;
  160. unsigned int authalg;
  161. unsigned char chg_txt[128];
  162. u16 capability;
  163. int flags;
  164. int dot8021xalg;//0:disable, 1:psk, 2:802.1x
  165. int wpa_psk;//0:disable, bit(0): WPA, bit(1):WPA2
  166. int wpa_group_cipher;
  167. int wpa2_group_cipher;
  168. int wpa_pairwise_cipher;
  169. int wpa2_pairwise_cipher;
  170. u8 bpairwise_key_installed;
  171. #ifdef CONFIG_NATIVEAP_MLME
  172. u8 wpa_ie[32];
  173. u8 nonerp_set;
  174. u8 no_short_slot_time_set;
  175. u8 no_short_preamble_set;
  176. u8 no_ht_gf_set;
  177. u8 no_ht_set;
  178. u8 ht_20mhz_set;
  179. #endif // CONFIG_NATIVEAP_MLME
  180. unsigned int tx_ra_bitmap;
  181. u8 qos_info;
  182. u8 max_sp_len;
  183. u8 uapsd_bk;//BIT(0): Delivery enabled, BIT(1): Trigger enabled
  184. u8 uapsd_be;
  185. u8 uapsd_vi;
  186. u8 uapsd_vo;
  187. u8 has_legacy_ac;
  188. unsigned int sleepq_ac_len;
  189. #ifdef CONFIG_P2P
  190. //p2p priv data
  191. u8 is_p2p_device;
  192. u8 p2p_status_code;
  193. //p2p client info
  194. u8 dev_addr[ETH_ALEN];
  195. //u8 iface_addr[ETH_ALEN];//= hwaddr[ETH_ALEN]
  196. u8 dev_cap;
  197. u16 config_methods;
  198. u8 primary_dev_type[8];
  199. u8 num_of_secdev_type;
  200. u8 secdev_types_list[32];// 32/8 == 4;
  201. u16 dev_name_len;
  202. u8 dev_name[32];
  203. #endif //CONFIG_P2P
  204. #ifdef CONFIG_TX_MCAST2UNI
  205. u8 under_exist_checking;
  206. #endif // CONFIG_TX_MCAST2UNI
  207. u8 keep_alive_trycnt;
  208. #ifdef CONFIG_AUTO_AP_MODE
  209. u8 isrc; //this device is rc
  210. u16 pid; // pairing id
  211. #endif
  212. #endif // CONFIG_AP_MODE
  213. #ifdef CONFIG_IOCTL_CFG80211
  214. u8 *passoc_req;
  215. u32 assoc_req_len;
  216. #endif
  217. //for DM
  218. RSSI_STA rssi_stat;
  219. //
  220. // ================ODM Relative Info=======================
  221. // Please be care, dont declare too much structure here. It will cost memory * STA support num.
  222. //
  223. //
  224. // 2011/10/20 MH Add for ODM STA info.
  225. //
  226. // Driver Write
  227. u8 bValid; // record the sta status link or not?
  228. //u8 WirelessMode; //
  229. u8 IOTPeer; // Enum value. HT_IOT_PEER_E
  230. u8 rssi_level; //for Refresh RA mask
  231. // ODM Write
  232. //1 PHY_STATUS_INFO
  233. u8 RSSI_Path[4]; //
  234. u8 RSSI_Ave;
  235. u8 RXEVM[4];
  236. u8 RXSNR[4];
  237. // ODM Write
  238. //1 TX_INFO (may changed by IC)
  239. //TX_INFO_T pTxInfo; // Define in IC folder. Move lower layer.
  240. //
  241. // ================ODM Relative Info=======================
  242. //
  243. /* To store the sequence number of received management frame */
  244. u16 RxMgmtFrameSeqNum;
  245. };
  246. #define sta_rx_pkts(sta) \
  247. (sta->sta_stats.rx_mgnt_pkts \
  248. + sta->sta_stats.rx_ctrl_pkts \
  249. + sta->sta_stats.rx_data_pkts)
  250. #define sta_last_rx_pkts(sta) \
  251. (sta->sta_stats.last_rx_mgnt_pkts \
  252. + sta->sta_stats.last_rx_ctrl_pkts \
  253. + sta->sta_stats.last_rx_data_pkts)
  254. #define sta_rx_data_pkts(sta) \
  255. (sta->sta_stats.rx_data_pkts)
  256. #define sta_last_rx_data_pkts(sta) \
  257. (sta->sta_stats.last_rx_data_pkts)
  258. #define sta_rx_mgnt_pkts(sta) \
  259. (sta->sta_stats.rx_mgnt_pkts)
  260. #define sta_last_rx_mgnt_pkts(sta) \
  261. (sta->sta_stats.last_rx_mgnt_pkts)
  262. #define sta_rx_beacon_pkts(sta) \
  263. (sta->sta_stats.rx_beacon_pkts)
  264. #define sta_last_rx_beacon_pkts(sta) \
  265. (sta->sta_stats.last_rx_beacon_pkts)
  266. #define sta_rx_probereq_pkts(sta) \
  267. (sta->sta_stats.rx_probereq_pkts)
  268. #define sta_last_rx_probereq_pkts(sta) \
  269. (sta->sta_stats.last_rx_probereq_pkts)
  270. #define sta_rx_probersp_pkts(sta) \
  271. (sta->sta_stats.rx_probersp_pkts)
  272. #define sta_last_rx_probersp_pkts(sta) \
  273. (sta->sta_stats.last_rx_probersp_pkts)
  274. #define sta_rx_probersp_bm_pkts(sta) \
  275. (sta->sta_stats.rx_probersp_bm_pkts)
  276. #define sta_last_rx_probersp_bm_pkts(sta) \
  277. (sta->sta_stats.last_rx_probersp_bm_pkts)
  278. #define sta_rx_probersp_uo_pkts(sta) \
  279. (sta->sta_stats.rx_probersp_uo_pkts)
  280. #define sta_last_rx_probersp_uo_pkts(sta) \
  281. (sta->sta_stats.last_rx_probersp_uo_pkts)
  282. #define sta_update_last_rx_pkts(sta) \
  283. do { \
  284. sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
  285. sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
  286. sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
  287. sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
  288. sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
  289. sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
  290. sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
  291. sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
  292. } while(0)
  293. #define STA_RX_PKTS_ARG(sta) \
  294. sta->sta_stats.rx_mgnt_pkts \
  295. , sta->sta_stats.rx_ctrl_pkts \
  296. , sta->sta_stats.rx_data_pkts
  297. #define STA_LAST_RX_PKTS_ARG(sta) \
  298. sta->sta_stats.last_rx_mgnt_pkts \
  299. , sta->sta_stats.last_rx_ctrl_pkts \
  300. , sta->sta_stats.last_rx_data_pkts
  301. #define STA_RX_PKTS_DIFF_ARG(sta) \
  302. sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
  303. , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
  304. , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
  305. #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
  306. struct sta_priv {
  307. u8 *pallocated_stainfo_buf;
  308. u8 *pstainfo_buf;
  309. _queue free_sta_queue;
  310. _lock sta_hash_lock;
  311. _list sta_hash[NUM_STA];
  312. int asoc_sta_count;
  313. _queue sleep_q;
  314. _queue wakeup_q;
  315. _adapter *padapter;
  316. #ifdef CONFIG_AP_MODE
  317. _list asoc_list;
  318. _list auth_list;
  319. _lock asoc_list_lock;
  320. _lock auth_list_lock;
  321. u8 asoc_list_cnt;
  322. u8 auth_list_cnt;
  323. unsigned int auth_to; //sec, time to expire in authenticating.
  324. unsigned int assoc_to; //sec, time to expire before associating.
  325. unsigned int expire_to; //sec , time to expire after associated.
  326. /* pointers to STA info; based on allocated AID or NULL if AID free
  327. * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
  328. * and so on
  329. */
  330. struct sta_info *sta_aid[NUM_STA];
  331. u16 sta_dz_bitmap;//only support 15 stations, staion aid bitmap for sleeping sta.
  332. u16 tim_bitmap;//only support 15 stations, aid=0~15 mapping bit0~bit15
  333. u16 max_num_sta;
  334. struct wlan_acl_pool acl_list;
  335. #endif
  336. };
  337. __inline static u32 wifi_mac_hash(u8 *mac)
  338. {
  339. u32 x;
  340. x = mac[0];
  341. x = (x << 2) ^ mac[1];
  342. x = (x << 2) ^ mac[2];
  343. x = (x << 2) ^ mac[3];
  344. x = (x << 2) ^ mac[4];
  345. x = (x << 2) ^ mac[5];
  346. x ^= x >> 8;
  347. x = x & (NUM_STA - 1);
  348. return x;
  349. }
  350. extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
  351. extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
  352. #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
  353. int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
  354. struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
  355. extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
  356. extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
  357. extern void rtw_free_all_stainfo(_adapter *padapter);
  358. extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
  359. extern u32 rtw_init_bcmc_stainfo(_adapter* padapter);
  360. extern struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter);
  361. extern u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr);
  362. #endif //_STA_INFO_H_