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
27 #ifndef CONFIG_RTW_MACADDR_ACL
28 #define CONFIG_RTW_MACADDR_ACL 1
31 #define RTW_ACL_MODE_DISABLED 0
32 #define RTW_ACL_MODE_ACCEPT_UNLESS_LISTED 1
33 #define RTW_ACL_MODE_DENY_UNLESS_LISTED 2
36 #define MAX_ALLOWED_TDLS_STA_NUM 4
39 enum sta_info_update_type {
40 STA_INFO_UPDATE_NONE = 0,
41 STA_INFO_UPDATE_BW = BIT(0),
42 STA_INFO_UPDATE_RATE = BIT(1),
43 STA_INFO_UPDATE_PROTECTION_MODE = BIT(2),
44 STA_INFO_UPDATE_CAP = BIT(3),
45 STA_INFO_UPDATE_HT_CAP = BIT(4),
46 STA_INFO_UPDATE_VHT_CAP = BIT(5),
47 STA_INFO_UPDATE_ALL = STA_INFO_UPDATE_BW
48 | STA_INFO_UPDATE_RATE
49 | STA_INFO_UPDATE_PROTECTION_MODE
51 | STA_INFO_UPDATE_HT_CAP
52 | STA_INFO_UPDATE_VHT_CAP,
56 struct rtw_wlan_acl_node {
62 struct wlan_acl_pool {
65 struct rtw_wlan_acl_node aclnode[NUM_ACL];
69 typedef struct _RSSI_STA {
70 s32 UndecoratedSmoothedPWDB;
71 s32 UndecoratedSmoothedCCK;
72 s32 UndecoratedSmoothedOFDM;
79 } RSSI_STA, *PRSSI_STA;
81 struct stainfo_stats {
87 u64 rx_probersp_bm_pkts;
88 u64 rx_probersp_uo_pkts;
91 u64 rx_data_last_pkts; /* For Read & Clear requirement in proc_get_rx_stat() */
92 u64 rx_data_qos_pkts[TID_NUM];
93 u64 last_rx_mgnt_pkts;
94 u64 last_rx_beacon_pkts;
95 u64 last_rx_probereq_pkts;
96 u64 last_rx_probersp_pkts;
97 u64 last_rx_probersp_bm_pkts;
98 u64 last_rx_probersp_uo_pkts;
99 u64 last_rx_ctrl_pkts;
100 u64 last_rx_data_pkts;
101 u64 last_rx_data_qos_pkts[TID_NUM];
103 u64 rx_tdls_disc_rsp_pkts;
104 u64 last_rx_tdls_disc_rsp_pkts;
113 u32 duplicate_cnt; /* Read & Clear, in proc_get_rx_stat() */
114 u32 rxratecnt[128]; /* Read & Clear, in proc_get_rx_stat() */
115 u32 tx_ok_cnt; /* Read & Clear, in proc_get_tx_stat() */
116 u32 tx_fail_cnt; /* Read & Clear, in proc_get_tx_stat() */
117 u32 tx_retry_cnt; /* Read & Clear, in proc_get_tx_stat() */
120 #ifndef DBG_SESSION_TRACKER
121 #define DBG_SESSION_TRACKER 0
124 /* session tracker status */
125 #define ST_STATUS_NONE 0
126 #define ST_STATUS_CHECK BIT0
127 #define ST_STATUS_ESTABLISH BIT1
128 #define ST_STATUS_EXPIRE BIT2
130 #define ST_EXPIRE_MS (10 * 1000)
132 struct session_tracker {
133 _list list; /* session_tracker_queue */
142 /* session tracker cmd */
149 struct sta_info *sta;
150 u32 local_naddr; /* TODO: IPV6 */
152 u32 remote_naddr; /* TODO: IPV6 */
156 typedef bool (*st_match_rule)(_adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
163 #define SESSION_TRACKER_REG_ID_WFD 0
164 #define SESSION_TRACKER_REG_ID_NUM 1
167 struct st_register reg[SESSION_TRACKER_REG_ID_NUM];
171 void rtw_st_ctl_init(struct st_ctl_t *st_ctl);
172 void rtw_st_ctl_deinit(struct st_ctl_t *st_ctl);
173 void rtw_st_ctl_register(struct st_ctl_t *st_ctl, u8 st_reg_id, struct st_register *reg);
174 void rtw_st_ctl_unregister(struct st_ctl_t *st_ctl, u8 st_reg_id);
175 bool rtw_st_ctl_chk_reg_s_proto(struct st_ctl_t *st_ctl, u8 s_proto);
176 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);
177 void dump_st_ctl(void *sel, struct st_ctl_t *st_ctl);
180 struct TDLS_PeerKey {
181 u8 kck[16]; /* TPK-KCK */
182 u8 tk[16]; /* TPK-TK; only CCMP will be used */
184 #endif /* CONFIG_TDLS */
186 #ifdef DBG_RX_DFRAME_RAW_DATA
187 struct sta_recv_dframe_info {
192 s8 sta_mimo_signal_strength[4];
201 _list list; /* free_sta_queue */
202 _list hash_list; /* sta_hash */
203 /* _list asoc_list; */ /* 20061114 */
204 /* _list sleep_list; */ /* sleep_q */
205 /* _list wakeup_list; */ /* wakeup_q */
208 struct sta_xmit_priv sta_xmitpriv;
209 struct sta_recv_priv sta_recvpriv;
211 #ifdef DBG_RX_DFRAME_RAW_DATA
212 struct sta_recv_dframe_info sta_dframe_info;
215 unsigned int sleepq_len;
225 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
226 uint dot118021XPrivacy; /* aes, tkip... */
227 union Keytype dot11tkiptxmickey;
228 union Keytype dot11tkiprxmickey;
229 union Keytype dot118021x_UncstKey;
230 union pn48 dot11txpn; /* PN48 used for Unicast xmit */
234 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
235 #endif /* CONFIG_GTK_OL */
236 #ifdef CONFIG_IEEE80211W
237 union pn48 dot11wtxpn; /* PN48 used for Unicast mgmt xmit. */
238 _timer dot11w_expire_timer;
239 #endif /* CONFIG_IEEE80211W */
240 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
254 u8 wireless_mode; /* NETWORK_TYPE */
260 #ifdef CONFIG_BEAMFORMING
265 struct stainfo_stats sta_stats;
271 u32 TDLS_PeerKey_Lifetime;
274 struct TDLS_PeerKey tpk;
275 #ifdef CONFIG_TDLS_CH_SW
277 u16 ch_switch_timeout;
281 _timer stay_on_base_chnl_timer;
282 _timer ch_sw_monitor_timer;
284 _timer handshake_timer;
287 u8 TDLS_RSNIE[20]; /* Save peer's RSNIE, used for sending TDLS_SETUP_RSP */
288 #endif /* CONFIG_TDLS */
290 /* for A-MPDU TX, ADDBA timeout check */
291 _timer addba_retry_timer;
293 /* for A-MPDU Rx reordering buffer control */
294 struct recv_reorder_ctrl recvreorder_ctrl[TID_NUM];
295 ATOMIC_T continual_no_rx_packet[TID_NUM];
297 /* unsigned char ampdu_txen_bitmap; */
298 u16 BA_starting_seqctrl[16];
301 #ifdef CONFIG_80211N_HT
302 struct ht_priv htpriv;
305 #ifdef CONFIG_80211AC_VHT
306 struct vht_priv vhtpriv;
311 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
312 /* scan_q: AP CAP/INFO */
315 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
316 /* sta_info: (AP & STA) CAP/INFO */
318 unsigned int expire_to;
320 #ifdef CONFIG_AP_MODE
325 unsigned int auth_seq;
326 unsigned int authalg;
327 unsigned char chg_txt[128];
332 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
333 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
334 int wpa_group_cipher;
335 int wpa2_group_cipher;
336 int wpa_pairwise_cipher;
337 int wpa2_pairwise_cipher;
339 u8 bpairwise_key_installed;
341 #ifdef CONFIG_NATIVEAP_MLME
345 u8 no_short_slot_time_set;
346 u8 no_short_preamble_set;
350 u8 ht_40mhz_intolerant;
351 #endif /* CONFIG_NATIVEAP_MLME */
353 #ifdef CONFIG_ATMEL_RC_PATCH
360 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
366 unsigned int sleepq_ac_len;
373 /* p2p client info */
374 u8 dev_addr[ETH_ALEN];
375 /* u8 iface_addr[ETH_ALEN]; */ /* = hwaddr[ETH_ALEN] */
378 u8 primary_dev_type[8];
379 u8 num_of_secdev_type;
380 u8 secdev_types_list[32];/* 32/8 == 4; */
383 #endif /* CONFIG_P2P */
389 #ifdef CONFIG_TX_MCAST2UNI
390 u8 under_exist_checking;
391 #endif /* CONFIG_TX_MCAST2UNI */
393 u8 keep_alive_trycnt;
395 #ifdef CONFIG_AUTO_AP_MODE
396 u8 isrc; /* this device is rc */
397 u16 pid; /* pairing id */
400 #endif /* CONFIG_AP_MODE */
402 #ifdef CONFIG_IOCTL_CFG80211
411 /* ================ODM Relative Info======================= */
412 /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
415 /* 2011/10/20 MH Add for ODM STA info. */
418 u8 bValid; /* record the sta status link or not? */
419 /* u8 WirelessMode; */ /* */
420 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
422 /* 1 PHY_STATUS_INFO */
423 u8 RSSI_Path[4]; /* */
428 u8 rssi_level; /* for Refresh RA mask */
430 /* 1 TX_INFO (may changed by IC) */
431 /* TX_INFO_T pTxInfo; */ /* Define in IC folder. Move lower layer. */
433 /* ================ODM Relative Info======================= */
436 /* To store the sequence number of received management frame */
437 u16 RxMgmtFrameSeqNum;
439 struct st_ctl_t st_ctl;
442 #define sta_rx_pkts(sta) \
443 (sta->sta_stats.rx_mgnt_pkts \
444 + sta->sta_stats.rx_ctrl_pkts \
445 + sta->sta_stats.rx_data_pkts)
447 #define sta_last_rx_pkts(sta) \
448 (sta->sta_stats.last_rx_mgnt_pkts \
449 + sta->sta_stats.last_rx_ctrl_pkts \
450 + sta->sta_stats.last_rx_data_pkts)
452 #define sta_rx_data_pkts(sta) \
453 (sta->sta_stats.rx_data_pkts)
455 #define sta_rx_data_qos_pkts(sta, i) \
456 (sta->sta_stats.rx_data_qos_pkts[i])
458 #define sta_last_rx_data_pkts(sta) \
459 (sta->sta_stats.last_rx_data_pkts)
461 #define sta_last_rx_data_qos_pkts(sta, i) \
462 (sta->sta_stats.last_rx_data_qos_pkts[i])
464 #define sta_rx_mgnt_pkts(sta) \
465 (sta->sta_stats.rx_mgnt_pkts)
467 #define sta_last_rx_mgnt_pkts(sta) \
468 (sta->sta_stats.last_rx_mgnt_pkts)
470 #define sta_rx_beacon_pkts(sta) \
471 (sta->sta_stats.rx_beacon_pkts)
473 #define sta_last_rx_beacon_pkts(sta) \
474 (sta->sta_stats.last_rx_beacon_pkts)
476 #define sta_rx_probereq_pkts(sta) \
477 (sta->sta_stats.rx_probereq_pkts)
479 #define sta_last_rx_probereq_pkts(sta) \
480 (sta->sta_stats.last_rx_probereq_pkts)
482 #define sta_rx_probersp_pkts(sta) \
483 (sta->sta_stats.rx_probersp_pkts)
485 #define sta_last_rx_probersp_pkts(sta) \
486 (sta->sta_stats.last_rx_probersp_pkts)
488 #define sta_rx_probersp_bm_pkts(sta) \
489 (sta->sta_stats.rx_probersp_bm_pkts)
491 #define sta_last_rx_probersp_bm_pkts(sta) \
492 (sta->sta_stats.last_rx_probersp_bm_pkts)
494 #define sta_rx_probersp_uo_pkts(sta) \
495 (sta->sta_stats.rx_probersp_uo_pkts)
497 #define sta_last_rx_probersp_uo_pkts(sta) \
498 (sta->sta_stats.last_rx_probersp_uo_pkts)
500 #define sta_update_last_rx_pkts(sta) \
502 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
503 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
504 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
505 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
506 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
507 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
508 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
509 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
512 #define STA_RX_PKTS_ARG(sta) \
513 sta->sta_stats.rx_mgnt_pkts \
514 , sta->sta_stats.rx_ctrl_pkts \
515 , sta->sta_stats.rx_data_pkts
517 #define STA_LAST_RX_PKTS_ARG(sta) \
518 sta->sta_stats.last_rx_mgnt_pkts \
519 , sta->sta_stats.last_rx_ctrl_pkts \
520 , sta->sta_stats.last_rx_data_pkts
522 #define STA_RX_PKTS_DIFF_ARG(sta) \
523 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
524 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
525 , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
527 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
530 #define STA_OP_WFD_MODE(sta) (sta)->op_wfd_mode
531 #define STA_SET_OP_WFD_MODE(sta, mode) (sta)->op_wfd_mode = (mode)
533 #define STA_OP_WFD_MODE(sta) 0
534 #define STA_SET_OP_WFD_MODE(sta, mode) do {} while (0)
539 u8 *pallocated_stainfo_buf;
541 _queue free_sta_queue;
544 _list sta_hash[NUM_STA];
553 #ifdef CONFIG_AP_MODE
556 _lock asoc_list_lock;
557 _lock auth_list_lock;
561 unsigned int auth_to; /* sec, time to expire in authenticating. */
562 unsigned int assoc_to; /* sec, time to expire before associating. */
563 unsigned int expire_to; /* sec , time to expire after associated. */
565 /* pointers to STA info; based on allocated AID or NULL if AID free
566 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
569 struct sta_info *sta_aid[NUM_STA];
571 u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
572 u16 tim_bitmap;/* only support 15 stations, aid=0~15 mapping bit0~bit15 */
576 #if CONFIG_RTW_MACADDR_ACL
577 struct wlan_acl_pool acl_list;
582 #ifdef CONFIG_ATMEL_RC_PATCH
583 u8 atmel_rc_pattern[6];
585 struct sta_info *c2h_sta;
586 struct submit_ctx *gotc2h;
590 __inline static u32 wifi_mac_hash(u8 *mac)
595 x = (x << 2) ^ mac[1];
596 x = (x << 2) ^ mac[2];
597 x = (x << 2) ^ mac[3];
598 x = (x << 2) ^ mac[4];
599 x = (x << 2) ^ mac[5];
602 x = x & (NUM_STA - 1);
608 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
609 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
611 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
612 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
613 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
615 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
616 extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
617 extern void rtw_free_all_stainfo(_adapter *padapter);
618 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
619 extern u32 rtw_init_bcmc_stainfo(_adapter *padapter);
620 extern struct sta_info *rtw_get_bcmc_stainfo(_adapter *padapter);
622 #if CONFIG_RTW_MACADDR_ACL
623 extern u8 rtw_access_ctrl(_adapter *adapter, u8 *mac_addr);
626 #endif /* _STA_INFO_H_ */