1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
11 #define IBSS_START_MAC_ID 2
16 /* if mode == 0, then the sta is allowed once the addr is hit. */
17 /* if mode == 1, then the sta is rejected once the addr is non-hit. */
18 struct rtw_wlan_acl_node {
19 struct list_head list;
24 /* mode = 0, disable */
25 /* mode = 1, accept unless in deny list */
26 /* mode =2, deny unless in accept list */
27 struct wlan_acl_pool {
30 struct rtw_wlan_acl_node aclnode[NUM_ACL];
31 struct __queue acl_node_q;
34 typedef struct _RSSI_STA{
35 s32 UndecoratedSmoothedPWDB;
36 s32 UndecoratedSmoothedCCK;
37 s32 UndecoratedSmoothedOFDM;
40 }RSSI_STA, *PRSSI_STA;
42 struct stainfo_stats {
48 u64 rx_probersp_bm_pkts;
49 u64 rx_probersp_uo_pkts;
53 u64 last_rx_mgnt_pkts;
54 u64 last_rx_beacon_pkts;
55 u64 last_rx_probereq_pkts;
56 u64 last_rx_probersp_pkts;
57 u64 last_rx_probersp_bm_pkts;
58 u64 last_rx_probersp_uo_pkts;
59 u64 last_rx_ctrl_pkts;
60 u64 last_rx_data_pkts;
73 struct list_head list; /* free_sta_queue */
74 struct list_head hash_list; /* sta_hash */
75 struct adapter *padapter;
77 struct sta_xmit_priv sta_xmitpriv;
78 struct sta_recv_priv sta_recvpriv;
80 struct __queue sleep_q;
81 unsigned int sleepq_len;
89 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
90 uint dot118021XPrivacy; /* aes, tkip... */
91 union Keytype dot11tkiptxmickey;
92 union Keytype dot11tkiprxmickey;
93 union Keytype dot118021x_UncstKey;
94 union pn48 dot11txpn; /* PN48 used for Unicast xmit */
98 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
99 #endif /* CONFIG_GTK_OL */
100 union pn48 dot11wtxpn; /* PN48 used for Unicast mgmt xmit. */
101 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
115 u8 wireless_mode; /* NETWORK_TYPE */
121 struct stainfo_stats sta_stats;
123 /* for A-MPDU TX, ADDBA timeout check */
124 _timer addba_retry_timer;
126 /* for A-MPDU Rx reordering buffer control */
127 struct recv_reorder_ctrl recvreorder_ctrl[16];
130 /* unsigned char ampdu_txen_bitmap; */
131 u16 BA_starting_seqctrl[16];
134 struct ht_priv htpriv;
138 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
139 /* scan_q: AP CAP/INFO */
142 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
143 /* sta_info: (AP & STA) CAP/INFO */
145 struct list_head asoc_list;
146 struct list_head auth_list;
148 unsigned int expire_to;
149 unsigned int auth_seq;
150 unsigned int authalg;
151 unsigned char chg_txt[128];
156 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
157 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
158 int wpa_group_cipher;
159 int wpa2_group_cipher;
160 int wpa_pairwise_cipher;
161 int wpa2_pairwise_cipher;
163 u8 bpairwise_key_installed;
168 u8 no_short_slot_time_set;
169 u8 no_short_preamble_set;
174 unsigned int tx_ra_bitmap;
178 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
184 unsigned int sleepq_ac_len;
186 u8 under_exist_checking;
188 u8 keep_alive_trycnt;
190 #ifdef CONFIG_AUTO_AP_MODE
191 u8 isrc; /* this device is rc */
192 u16 pid; /* pairing id */
202 /* ================ODM Relative Info ======================= */
203 /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
206 /* 2011/10/20 MH Add for ODM STA info. */
209 u8 bValid; /* record the sta status link or not? */
210 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
212 /* 1 PHY_STATUS_INFO */
213 u8 RSSI_Path[4]; /* */
218 u8 rssi_level; /* for Refresh RA mask */
220 /* 1 TX_INFO (may changed by IC) */
221 /* TX_INFO_T pTxInfo; Define in IC folder. Move lower layer. */
223 /* ================ODM Relative Info ======================= */
226 /* To store the sequence number of received management frame */
227 u16 RxMgmtFrameSeqNum;
230 #define sta_rx_pkts(sta) \
231 (sta->sta_stats.rx_mgnt_pkts \
232 + sta->sta_stats.rx_ctrl_pkts \
233 + sta->sta_stats.rx_data_pkts)
235 #define sta_last_rx_pkts(sta) \
236 (sta->sta_stats.last_rx_mgnt_pkts \
237 + sta->sta_stats.last_rx_ctrl_pkts \
238 + sta->sta_stats.last_rx_data_pkts)
240 #define sta_rx_data_pkts(sta) \
241 (sta->sta_stats.rx_data_pkts)
243 #define sta_last_rx_data_pkts(sta) \
244 (sta->sta_stats.last_rx_data_pkts)
246 #define sta_rx_mgnt_pkts(sta) \
247 (sta->sta_stats.rx_mgnt_pkts)
249 #define sta_last_rx_mgnt_pkts(sta) \
250 (sta->sta_stats.last_rx_mgnt_pkts)
252 #define sta_rx_beacon_pkts(sta) \
253 (sta->sta_stats.rx_beacon_pkts)
255 #define sta_last_rx_beacon_pkts(sta) \
256 (sta->sta_stats.last_rx_beacon_pkts)
258 #define sta_rx_probereq_pkts(sta) \
259 (sta->sta_stats.rx_probereq_pkts)
261 #define sta_last_rx_probereq_pkts(sta) \
262 (sta->sta_stats.last_rx_probereq_pkts)
264 #define sta_rx_probersp_pkts(sta) \
265 (sta->sta_stats.rx_probersp_pkts)
267 #define sta_last_rx_probersp_pkts(sta) \
268 (sta->sta_stats.last_rx_probersp_pkts)
270 #define sta_rx_probersp_bm_pkts(sta) \
271 (sta->sta_stats.rx_probersp_bm_pkts)
273 #define sta_last_rx_probersp_bm_pkts(sta) \
274 (sta->sta_stats.last_rx_probersp_bm_pkts)
276 #define sta_rx_probersp_uo_pkts(sta) \
277 (sta->sta_stats.rx_probersp_uo_pkts)
279 #define sta_last_rx_probersp_uo_pkts(sta) \
280 (sta->sta_stats.last_rx_probersp_uo_pkts)
282 #define sta_update_last_rx_pkts(sta) \
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; \
294 #define STA_RX_PKTS_ARG(sta) \
295 sta->sta_stats.rx_mgnt_pkts \
296 , sta->sta_stats.rx_ctrl_pkts \
297 , sta->sta_stats.rx_data_pkts
299 #define STA_LAST_RX_PKTS_ARG(sta) \
300 sta->sta_stats.last_rx_mgnt_pkts \
301 , sta->sta_stats.last_rx_ctrl_pkts \
302 , sta->sta_stats.last_rx_data_pkts
304 #define STA_RX_PKTS_DIFF_ARG(sta) \
305 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
306 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
307 , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
309 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
313 u8 *pallocated_stainfo_buf;
315 struct __queue free_sta_queue;
318 struct list_head sta_hash[NUM_STA];
320 struct __queue sleep_q;
321 struct __queue wakeup_q;
323 struct adapter *padapter;
325 struct list_head asoc_list;
326 struct list_head auth_list;
327 _lock asoc_list_lock;
328 _lock auth_list_lock;
332 unsigned int auth_to; /* sec, time to expire in authenticating. */
333 unsigned int assoc_to; /* sec, time to expire before associating. */
334 unsigned int expire_to; /* sec , time to expire after associated. */
336 /* pointers to STA info; based on allocated AID or NULL if AID free
337 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
340 struct sta_info *sta_aid[NUM_STA];
342 u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
343 u16 tim_bitmap;/* only support 15 stations, aid = 0~15 mapping bit0~bit15 */
347 struct wlan_acl_pool acl_list;
351 __inline static u32 wifi_mac_hash(u8 *mac)
356 x = (x << 2) ^ mac[1];
357 x = (x << 2) ^ mac[2];
358 x = (x << 2) ^ mac[3];
359 x = (x << 2) ^ mac[4];
360 x = (x << 2) ^ mac[5];
363 x = x & (NUM_STA - 1);
369 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
370 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
372 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
373 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
374 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
376 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
377 extern u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta);
378 extern void rtw_free_all_stainfo(struct adapter *padapter);
379 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
380 extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter);
381 extern struct sta_info* rtw_get_bcmc_stainfo(struct adapter *padapter);
382 extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
384 #endif /* _STA_INFO_H_ */