1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
24 #define IBSS_START_MAC_ID 2
29 //if mode ==0, then the sta is allowed once the addr is hit.
30 //if mode ==1, then the sta is rejected once the addr is non-hit.
31 struct rtw_wlan_acl_node {
38 //mode=1, accept unless in deny list
39 //mode=2, deny unless in accept list
40 struct wlan_acl_pool {
43 struct rtw_wlan_acl_node aclnode[NUM_ACL];
47 typedef struct _RSSI_STA{
48 s32 UndecoratedSmoothedPWDB;
49 s32 UndecoratedSmoothedCCK;
50 s32 UndecoratedSmoothedOFDM;
53 }RSSI_STA, *PRSSI_STA;
55 struct stainfo_stats {
61 u64 rx_probersp_bm_pkts;
62 u64 rx_probersp_uo_pkts;
66 u64 last_rx_mgnt_pkts;
67 u64 last_rx_beacon_pkts;
68 u64 last_rx_probereq_pkts;
69 u64 last_rx_probersp_pkts;
70 u64 last_rx_probersp_bm_pkts;
71 u64 last_rx_probersp_uo_pkts;
72 u64 last_rx_ctrl_pkts;
73 u64 last_rx_data_pkts;
85 u8 kck[16]; /* TPK-KCK */
86 u8 tk[16]; /* TPK-TK; only CCMP will be used */
93 _list list; //free_sta_queue
94 _list hash_list; //sta_hash
95 //_list asoc_list; //20061114
96 //_list sleep_list;//sleep_q
97 //_list wakeup_list;//wakeup_q
100 struct sta_xmit_priv sta_xmitpriv;
101 struct sta_recv_priv sta_recvpriv;
104 unsigned int sleepq_len;
112 uint ieee8021x_blocked; //0: allowed, 1:blocked
113 uint dot118021XPrivacy; //aes, tkip...
114 union Keytype dot11tkiptxmickey;
115 union Keytype dot11tkiprxmickey;
116 union Keytype dot118021x_UncstKey;
117 union pn48 dot11txpn; // PN48 used for Unicast xmit
121 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
122 #endif //CONFIG_GTK_OL
123 #ifdef CONFIG_IEEE80211W
124 union pn48 dot11wtxpn; // PN48 used for Unicast mgmt xmit.
125 #endif //CONFIG_IEEE80211W
126 union pn48 dot11rxpn; // PN48 used for Unicast recv.
140 u8 wireless_mode; // NETWORK_TYPE
146 struct stainfo_stats sta_stats;
153 u32 TDLS_PeerKey_Lifetime;
156 struct TDLS_PeerKey tpk;
160 u16 ch_switch_timeout;
163 _timer base_ch_timer;
165 _timer handshake_timer;
169 u8 TDLS_RSNIE[20]; //Save peer's RSNIE, use for sending TDLS_SETUP_RSP
172 //for A-MPDU TX, ADDBA timeout check
173 _timer addba_retry_timer;
175 //for A-MPDU Rx reordering buffer control
176 struct recv_reorder_ctrl recvreorder_ctrl[16];
179 //unsigned char ampdu_txen_bitmap;
180 u16 BA_starting_seqctrl[16];
183 #ifdef CONFIG_80211N_HT
184 struct ht_priv htpriv;
187 #ifdef CONFIG_80211AC_VHT
188 struct vht_priv vhtpriv;
193 //curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO
194 //scan_q: AP CAP/INFO
197 //curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
198 //sta_info: (AP & STA) CAP/INFO
200 #ifdef CONFIG_AP_MODE
205 unsigned int expire_to;
206 unsigned int auth_seq;
207 unsigned int authalg;
208 unsigned char chg_txt[128];
213 int dot8021xalg;//0:disable, 1:psk, 2:802.1x
214 int wpa_psk;//0:disable, bit(0): WPA, bit(1):WPA2
215 int wpa_group_cipher;
216 int wpa2_group_cipher;
217 int wpa_pairwise_cipher;
218 int wpa2_pairwise_cipher;
220 u8 bpairwise_key_installed;
222 #ifdef CONFIG_NATIVEAP_MLME
226 u8 no_short_slot_time_set;
227 u8 no_short_preamble_set;
231 #endif // CONFIG_NATIVEAP_MLME
233 #ifdef CONFIG_ATMEL_RC_PATCH
237 unsigned int tx_ra_bitmap;
241 u8 uapsd_bk;//BIT(0): Delivery enabled, BIT(1): Trigger enabled
247 unsigned int sleepq_ac_len;
255 u8 dev_addr[ETH_ALEN];
256 //u8 iface_addr[ETH_ALEN];//= hwaddr[ETH_ALEN]
259 u8 primary_dev_type[8];
260 u8 num_of_secdev_type;
261 u8 secdev_types_list[32];// 32/8 == 4;
266 #ifdef CONFIG_TX_MCAST2UNI
267 u8 under_exist_checking;
268 #endif // CONFIG_TX_MCAST2UNI
270 u8 keep_alive_trycnt;
272 #ifdef CONFIG_AUTO_AP_MODE
273 u8 isrc; //this device is rc
274 u16 pid; // pairing id
277 #endif // CONFIG_AP_MODE
279 #ifdef CONFIG_IOCTL_CFG80211
288 // ================ODM Relative Info=======================
289 // Please be care, dont declare too much structure here. It will cost memory * STA support num.
292 // 2011/10/20 MH Add for ODM STA info.
295 u8 bValid; // record the sta status link or not?
296 //u8 WirelessMode; //
297 u8 IOTPeer; // Enum value. HT_IOT_PEER_E
305 u8 rssi_level; //for Refresh RA mask
307 //1 TX_INFO (may changed by IC)
308 //TX_INFO_T pTxInfo; // Define in IC folder. Move lower layer.
310 // ================ODM Relative Info=======================
313 /* To store the sequence number of received management frame */
314 u16 RxMgmtFrameSeqNum;
317 #define sta_rx_pkts(sta) \
318 (sta->sta_stats.rx_mgnt_pkts \
319 + sta->sta_stats.rx_ctrl_pkts \
320 + sta->sta_stats.rx_data_pkts)
322 #define sta_last_rx_pkts(sta) \
323 (sta->sta_stats.last_rx_mgnt_pkts \
324 + sta->sta_stats.last_rx_ctrl_pkts \
325 + sta->sta_stats.last_rx_data_pkts)
327 #define sta_rx_data_pkts(sta) \
328 (sta->sta_stats.rx_data_pkts)
330 #define sta_last_rx_data_pkts(sta) \
331 (sta->sta_stats.last_rx_data_pkts)
333 #define sta_rx_mgnt_pkts(sta) \
334 (sta->sta_stats.rx_mgnt_pkts)
336 #define sta_last_rx_mgnt_pkts(sta) \
337 (sta->sta_stats.last_rx_mgnt_pkts)
339 #define sta_rx_beacon_pkts(sta) \
340 (sta->sta_stats.rx_beacon_pkts)
342 #define sta_last_rx_beacon_pkts(sta) \
343 (sta->sta_stats.last_rx_beacon_pkts)
345 #define sta_rx_probereq_pkts(sta) \
346 (sta->sta_stats.rx_probereq_pkts)
348 #define sta_last_rx_probereq_pkts(sta) \
349 (sta->sta_stats.last_rx_probereq_pkts)
351 #define sta_rx_probersp_pkts(sta) \
352 (sta->sta_stats.rx_probersp_pkts)
354 #define sta_last_rx_probersp_pkts(sta) \
355 (sta->sta_stats.last_rx_probersp_pkts)
357 #define sta_rx_probersp_bm_pkts(sta) \
358 (sta->sta_stats.rx_probersp_bm_pkts)
360 #define sta_last_rx_probersp_bm_pkts(sta) \
361 (sta->sta_stats.last_rx_probersp_bm_pkts)
363 #define sta_rx_probersp_uo_pkts(sta) \
364 (sta->sta_stats.rx_probersp_uo_pkts)
366 #define sta_last_rx_probersp_uo_pkts(sta) \
367 (sta->sta_stats.last_rx_probersp_uo_pkts)
369 #define sta_update_last_rx_pkts(sta) \
371 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
372 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
373 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
374 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
375 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
376 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
377 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
378 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
381 #define STA_RX_PKTS_ARG(sta) \
382 sta->sta_stats.rx_mgnt_pkts \
383 , sta->sta_stats.rx_ctrl_pkts \
384 , sta->sta_stats.rx_data_pkts
386 #define STA_LAST_RX_PKTS_ARG(sta) \
387 sta->sta_stats.last_rx_mgnt_pkts \
388 , sta->sta_stats.last_rx_ctrl_pkts \
389 , sta->sta_stats.last_rx_data_pkts
391 #define STA_RX_PKTS_DIFF_ARG(sta) \
392 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
393 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
394 , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
396 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
400 u8 *pallocated_stainfo_buf;
402 _queue free_sta_queue;
405 _list sta_hash[NUM_STA];
413 #ifdef CONFIG_AP_MODE
416 _lock asoc_list_lock;
417 _lock auth_list_lock;
421 unsigned int auth_to; //sec, time to expire in authenticating.
422 unsigned int assoc_to; //sec, time to expire before associating.
423 unsigned int expire_to; //sec , time to expire after associated.
425 /* pointers to STA info; based on allocated AID or NULL if AID free
426 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
429 struct sta_info *sta_aid[NUM_STA];
431 u16 sta_dz_bitmap;//only support 15 stations, staion aid bitmap for sleeping sta.
432 u16 tim_bitmap;//only support 15 stations, aid=0~15 mapping bit0~bit15
436 struct wlan_acl_pool acl_list;
439 #ifdef CONFIG_ATMEL_RC_PATCH
440 u8 atmel_rc_pattern [6];
446 __inline static u32 wifi_mac_hash(u8 *mac)
451 x = (x << 2) ^ mac[1];
452 x = (x << 2) ^ mac[2];
453 x = (x << 2) ^ mac[3];
454 x = (x << 2) ^ mac[4];
455 x = (x << 2) ^ mac[5];
458 x = x & (NUM_STA - 1);
464 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
465 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
467 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
468 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
469 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
471 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
472 extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
473 extern void rtw_free_all_stainfo(_adapter *padapter);
474 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
475 extern u32 rtw_init_bcmc_stainfo(_adapter* padapter);
476 extern struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter);
477 extern u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr);
479 #endif //_STA_INFO_H_