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
25 #define NUM_STA MACID_NUM_SW_LIMIT
29 #define MAX_ALLOWED_TDLS_STA_NUM 4
32 enum sta_info_update_type {
33 STA_INFO_UPDATE_NONE = 0,
34 STA_INFO_UPDATE_BW = BIT(0),
35 STA_INFO_UPDATE_RATE = BIT(1),
36 STA_INFO_UPDATE_PROTECTION_MODE = BIT(2),
37 STA_INFO_UPDATE_CAP = BIT(3),
38 STA_INFO_UPDATE_HT_CAP = BIT(4),
39 STA_INFO_UPDATE_VHT_CAP = BIT(5),
40 STA_INFO_UPDATE_ALL = STA_INFO_UPDATE_BW
42 |STA_INFO_UPDATE_PROTECTION_MODE
44 |STA_INFO_UPDATE_HT_CAP
45 |STA_INFO_UPDATE_VHT_CAP,
49 //if mode ==0, then the sta is allowed once the addr is hit.
50 //if mode ==1, then the sta is rejected once the addr is non-hit.
51 struct rtw_wlan_acl_node {
58 //mode=1, accept unless in deny list
59 //mode=2, deny unless in accept list
60 struct wlan_acl_pool {
63 struct rtw_wlan_acl_node aclnode[NUM_ACL];
67 typedef struct _RSSI_STA{
68 s32 UndecoratedSmoothedPWDB;
69 s32 UndecoratedSmoothedCCK;
70 s32 UndecoratedSmoothedOFDM;
74 }RSSI_STA, *PRSSI_STA;
76 struct stainfo_stats {
82 u64 rx_probersp_bm_pkts;
83 u64 rx_probersp_uo_pkts;
86 u64 rx_data_qos_pkts[TID_NUM];
87 u64 last_rx_mgnt_pkts;
88 u64 last_rx_beacon_pkts;
89 u64 last_rx_probereq_pkts;
90 u64 last_rx_probersp_pkts;
91 u64 last_rx_probersp_bm_pkts;
92 u64 last_rx_probersp_uo_pkts;
93 u64 last_rx_ctrl_pkts;
94 u64 last_rx_data_pkts;
95 u64 last_rx_data_qos_pkts[TID_NUM];
97 u64 rx_tdls_disc_rsp_pkts;
98 u64 last_rx_tdls_disc_rsp_pkts;
108 #ifndef DBG_SESSION_TRACKER
109 #define DBG_SESSION_TRACKER 0
112 /* session tracker status */
113 #define ST_STATUS_NONE 0
114 #define ST_STATUS_CHECK BIT0
115 #define ST_STATUS_ESTABLISH BIT1
116 #define ST_STATUS_EXPIRE BIT2
118 #define ST_EXPIRE_MS (10 * 1000)
120 struct session_tracker {
121 _list list; /* session_tracker_queue */
130 /* session tracker cmd */
137 struct sta_info *sta;
138 u32 local_naddr; /* TODO: IPV6 */
140 u32 remote_naddr; /* TODO: IPV6 */
144 typedef bool (*st_match_rule)(_adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
151 #define SESSION_TRACKER_REG_ID_WFD 0
152 #define SESSION_TRACKER_REG_ID_NUM 1
155 struct st_register reg[SESSION_TRACKER_REG_ID_NUM];
159 void rtw_st_ctl_init(struct st_ctl_t *st_ctl);
160 void rtw_st_ctl_deinit(struct st_ctl_t *st_ctl);
161 void rtw_st_ctl_register(struct st_ctl_t *st_ctl, u8 st_reg_id, struct st_register *reg);
162 void rtw_st_ctl_unregister(struct st_ctl_t *st_ctl, u8 st_reg_id);
163 bool rtw_st_ctl_chk_reg_s_proto(struct st_ctl_t *st_ctl, u8 s_proto);
164 bool rtw_st_ctl_chk_reg_rule(struct st_ctl_t *st_ctl, _adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
165 void dump_st_ctl(void *sel, struct st_ctl_t *st_ctl);
168 struct TDLS_PeerKey {
169 u8 kck[16]; /* TPK-KCK */
170 u8 tk[16]; /* TPK-TK; only CCMP will be used */
177 _list list; //free_sta_queue
178 _list hash_list; //sta_hash
179 //_list asoc_list; //20061114
180 //_list sleep_list;//sleep_q
181 //_list wakeup_list;//wakeup_q
184 struct sta_xmit_priv sta_xmitpriv;
185 struct sta_recv_priv sta_recvpriv;
188 unsigned int sleepq_len;
198 uint ieee8021x_blocked; //0: allowed, 1:blocked
199 uint dot118021XPrivacy; //aes, tkip...
200 union Keytype dot11tkiptxmickey;
201 union Keytype dot11tkiprxmickey;
202 union Keytype dot118021x_UncstKey;
203 union pn48 dot11txpn; // PN48 used for Unicast xmit
207 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
208 #endif //CONFIG_GTK_OL
209 #ifdef CONFIG_IEEE80211W
210 union pn48 dot11wtxpn; // PN48 used for Unicast mgmt xmit.
211 _timer dot11w_expire_timer;
212 #endif //CONFIG_IEEE80211W
213 union pn48 dot11rxpn; // PN48 used for Unicast recv.
227 u8 wireless_mode; // NETWORK_TYPE
233 #ifdef CONFIG_BEAMFORMING
238 struct stainfo_stats sta_stats;
244 u32 TDLS_PeerKey_Lifetime;
247 struct TDLS_PeerKey tpk;
248 #ifdef CONFIG_TDLS_CH_SW
250 u16 ch_switch_timeout;
254 _timer stay_on_base_chnl_timer;
255 _timer ch_sw_monitor_timer;
257 _timer handshake_timer;
260 u8 TDLS_RSNIE[20]; /* Save peer's RSNIE, used for sending TDLS_SETUP_RSP */
261 #endif /* CONFIG_TDLS */
263 //for A-MPDU TX, ADDBA timeout check
264 _timer addba_retry_timer;
266 //for A-MPDU Rx reordering buffer control
267 struct recv_reorder_ctrl recvreorder_ctrl[TID_NUM];
268 ATOMIC_T continual_no_rx_packet[TID_NUM];
270 //unsigned char ampdu_txen_bitmap;
271 u16 BA_starting_seqctrl[16];
274 #ifdef CONFIG_80211N_HT
275 struct ht_priv htpriv;
278 #ifdef CONFIG_80211AC_VHT
279 struct vht_priv vhtpriv;
284 //curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO
285 //scan_q: AP CAP/INFO
288 //curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
289 //sta_info: (AP & STA) CAP/INFO
291 unsigned int expire_to;
293 #ifdef CONFIG_AP_MODE
298 unsigned int auth_seq;
299 unsigned int authalg;
300 unsigned char chg_txt[128];
305 int dot8021xalg;//0:disable, 1:psk, 2:802.1x
306 int wpa_psk;//0:disable, bit(0): WPA, bit(1):WPA2
307 int wpa_group_cipher;
308 int wpa2_group_cipher;
309 int wpa_pairwise_cipher;
310 int wpa2_pairwise_cipher;
312 u8 bpairwise_key_installed;
314 #ifdef CONFIG_NATIVEAP_MLME
318 u8 no_short_slot_time_set;
319 u8 no_short_preamble_set;
323 u8 ht_40mhz_intolerant;
324 #endif // CONFIG_NATIVEAP_MLME
326 #ifdef CONFIG_ATMEL_RC_PATCH
333 u8 uapsd_bk;//BIT(0): Delivery enabled, BIT(1): Trigger enabled
339 unsigned int sleepq_ac_len;
347 u8 dev_addr[ETH_ALEN];
348 //u8 iface_addr[ETH_ALEN];//= hwaddr[ETH_ALEN]
351 u8 primary_dev_type[8];
352 u8 num_of_secdev_type;
353 u8 secdev_types_list[32];// 32/8 == 4;
362 #ifdef CONFIG_TX_MCAST2UNI
363 u8 under_exist_checking;
364 #endif // CONFIG_TX_MCAST2UNI
366 u8 keep_alive_trycnt;
368 #ifdef CONFIG_AUTO_AP_MODE
369 u8 isrc; //this device is rc
370 u16 pid; // pairing id
373 #endif // CONFIG_AP_MODE
375 #ifdef CONFIG_IOCTL_CFG80211
384 // ================ODM Relative Info=======================
385 // Please be care, dont declare too much structure here. It will cost memory * STA support num.
388 // 2011/10/20 MH Add for ODM STA info.
391 u8 bValid; // record the sta status link or not?
392 //u8 WirelessMode; //
393 u8 IOTPeer; // Enum value. HT_IOT_PEER_E
401 u8 rssi_level; //for Refresh RA mask
403 //1 TX_INFO (may changed by IC)
404 //TX_INFO_T pTxInfo; // Define in IC folder. Move lower layer.
406 // ================ODM Relative Info=======================
409 /* To store the sequence number of received management frame */
410 u16 RxMgmtFrameSeqNum;
412 struct st_ctl_t st_ctl;
415 #define sta_rx_pkts(sta) \
416 (sta->sta_stats.rx_mgnt_pkts \
417 + sta->sta_stats.rx_ctrl_pkts \
418 + sta->sta_stats.rx_data_pkts)
420 #define sta_last_rx_pkts(sta) \
421 (sta->sta_stats.last_rx_mgnt_pkts \
422 + sta->sta_stats.last_rx_ctrl_pkts \
423 + sta->sta_stats.last_rx_data_pkts)
425 #define sta_rx_data_pkts(sta) \
426 (sta->sta_stats.rx_data_pkts)
428 #define sta_rx_data_qos_pkts(sta, i) \
429 (sta->sta_stats.rx_data_qos_pkts[i])
431 #define sta_last_rx_data_pkts(sta) \
432 (sta->sta_stats.last_rx_data_pkts)
434 #define sta_last_rx_data_qos_pkts(sta, i) \
435 (sta->sta_stats.last_rx_data_qos_pkts[i])
437 #define sta_rx_mgnt_pkts(sta) \
438 (sta->sta_stats.rx_mgnt_pkts)
440 #define sta_last_rx_mgnt_pkts(sta) \
441 (sta->sta_stats.last_rx_mgnt_pkts)
443 #define sta_rx_beacon_pkts(sta) \
444 (sta->sta_stats.rx_beacon_pkts)
446 #define sta_last_rx_beacon_pkts(sta) \
447 (sta->sta_stats.last_rx_beacon_pkts)
449 #define sta_rx_probereq_pkts(sta) \
450 (sta->sta_stats.rx_probereq_pkts)
452 #define sta_last_rx_probereq_pkts(sta) \
453 (sta->sta_stats.last_rx_probereq_pkts)
455 #define sta_rx_probersp_pkts(sta) \
456 (sta->sta_stats.rx_probersp_pkts)
458 #define sta_last_rx_probersp_pkts(sta) \
459 (sta->sta_stats.last_rx_probersp_pkts)
461 #define sta_rx_probersp_bm_pkts(sta) \
462 (sta->sta_stats.rx_probersp_bm_pkts)
464 #define sta_last_rx_probersp_bm_pkts(sta) \
465 (sta->sta_stats.last_rx_probersp_bm_pkts)
467 #define sta_rx_probersp_uo_pkts(sta) \
468 (sta->sta_stats.rx_probersp_uo_pkts)
470 #define sta_last_rx_probersp_uo_pkts(sta) \
471 (sta->sta_stats.last_rx_probersp_uo_pkts)
473 #define sta_update_last_rx_pkts(sta) \
475 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
476 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
477 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
478 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
479 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
480 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
481 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
482 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
485 #define STA_RX_PKTS_ARG(sta) \
486 sta->sta_stats.rx_mgnt_pkts \
487 , sta->sta_stats.rx_ctrl_pkts \
488 , sta->sta_stats.rx_data_pkts
490 #define STA_LAST_RX_PKTS_ARG(sta) \
491 sta->sta_stats.last_rx_mgnt_pkts \
492 , sta->sta_stats.last_rx_ctrl_pkts \
493 , sta->sta_stats.last_rx_data_pkts
495 #define STA_RX_PKTS_DIFF_ARG(sta) \
496 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
497 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
498 , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
500 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
503 #define STA_OP_WFD_MODE(sta) (sta)->op_wfd_mode
504 #define STA_SET_OP_WFD_MODE(sta, mode) (sta)->op_wfd_mode = (mode)
506 #define STA_OP_WFD_MODE(sta) 0
507 #define STA_SET_OP_WFD_MODE(sta, mode) do {} while (0)
512 u8 *pallocated_stainfo_buf;
514 _queue free_sta_queue;
517 _list sta_hash[NUM_STA];
526 #ifdef CONFIG_AP_MODE
529 _lock asoc_list_lock;
530 _lock auth_list_lock;
534 unsigned int auth_to; //sec, time to expire in authenticating.
535 unsigned int assoc_to; //sec, time to expire before associating.
536 unsigned int expire_to; //sec , time to expire after associated.
538 /* pointers to STA info; based on allocated AID or NULL if AID free
539 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
542 struct sta_info *sta_aid[NUM_STA];
544 u16 sta_dz_bitmap;//only support 15 stations, staion aid bitmap for sleeping sta.
545 u16 tim_bitmap;//only support 15 stations, aid=0~15 mapping bit0~bit15
549 struct wlan_acl_pool acl_list;
552 #ifdef CONFIG_ATMEL_RC_PATCH
553 u8 atmel_rc_pattern [6];
559 static u32 wifi_mac_hash(const u8 *mac)
564 x = (x << 2) ^ mac[1];
565 x = (x << 2) ^ mac[2];
566 x = (x << 2) ^ mac[3];
567 x = (x << 2) ^ mac[4];
568 x = (x << 2) ^ mac[5];
571 x = x & (NUM_STA - 1);
577 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
578 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
580 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
581 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
582 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
584 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
585 extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
586 extern void rtw_free_all_stainfo(_adapter *padapter);
587 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
588 extern u32 rtw_init_bcmc_stainfo(_adapter* padapter);
589 extern struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter);
590 extern u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr);
592 #endif //_STA_INFO_H_