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;
35 s32 UndecoratedSmoothedPWDB;
36 s32 UndecoratedSmoothedCCK;
37 s32 UndecoratedSmoothedOFDM;
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 */
95 union pn48 dot11wtxpn; /* PN48 used for Unicast mgmt xmit. */
96 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
110 u8 wireless_mode; /* NETWORK_TYPE */
116 struct stainfo_stats sta_stats;
118 /* for A-MPDU TX, ADDBA timeout check */
119 struct timer_list addba_retry_timer;
121 /* for A-MPDU Rx reordering buffer control */
122 struct recv_reorder_ctrl recvreorder_ctrl[16];
125 /* unsigned char ampdu_txen_bitmap; */
126 u16 BA_starting_seqctrl[16];
129 struct ht_priv htpriv;
133 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
134 /* scan_q: AP CAP/INFO */
137 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
138 /* sta_info: (AP & STA) CAP/INFO */
140 struct list_head asoc_list;
141 struct list_head auth_list;
143 unsigned int expire_to;
144 unsigned int auth_seq;
145 unsigned int authalg;
146 unsigned char chg_txt[128];
151 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
152 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
153 int wpa_group_cipher;
154 int wpa2_group_cipher;
155 int wpa_pairwise_cipher;
156 int wpa2_pairwise_cipher;
158 u8 bpairwise_key_installed;
163 u8 no_short_slot_time_set;
164 u8 no_short_preamble_set;
169 unsigned int tx_ra_bitmap;
173 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
179 unsigned int sleepq_ac_len;
181 u8 under_exist_checking;
183 u8 keep_alive_trycnt;
189 struct rssi_sta rssi_stat;
192 /* ================ODM Relative Info ======================= */
193 /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
196 /* 2011/10/20 MH Add for ODM STA info. */
199 u8 bValid; /* record the sta status link or not? */
200 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
202 /* 1 PHY_STATUS_INFO */
203 u8 RSSI_Path[4]; /* */
208 u8 rssi_level; /* for Refresh RA mask */
210 /* 1 TX_INFO (may changed by IC) */
211 /* TX_INFO_T pTxInfo; Define in IC folder. Move lower layer. */
213 /* ================ODM Relative Info ======================= */
216 /* To store the sequence number of received management frame */
217 u16 RxMgmtFrameSeqNum;
220 #define sta_rx_pkts(sta) \
221 (sta->sta_stats.rx_mgnt_pkts \
222 + sta->sta_stats.rx_ctrl_pkts \
223 + sta->sta_stats.rx_data_pkts)
225 #define sta_last_rx_pkts(sta) \
226 (sta->sta_stats.last_rx_mgnt_pkts \
227 + sta->sta_stats.last_rx_ctrl_pkts \
228 + sta->sta_stats.last_rx_data_pkts)
230 #define sta_rx_data_pkts(sta) \
231 (sta->sta_stats.rx_data_pkts)
233 #define sta_last_rx_data_pkts(sta) \
234 (sta->sta_stats.last_rx_data_pkts)
236 #define sta_rx_mgnt_pkts(sta) \
237 (sta->sta_stats.rx_mgnt_pkts)
239 #define sta_last_rx_mgnt_pkts(sta) \
240 (sta->sta_stats.last_rx_mgnt_pkts)
242 #define sta_rx_beacon_pkts(sta) \
243 (sta->sta_stats.rx_beacon_pkts)
245 #define sta_last_rx_beacon_pkts(sta) \
246 (sta->sta_stats.last_rx_beacon_pkts)
248 #define sta_rx_probereq_pkts(sta) \
249 (sta->sta_stats.rx_probereq_pkts)
251 #define sta_last_rx_probereq_pkts(sta) \
252 (sta->sta_stats.last_rx_probereq_pkts)
254 #define sta_rx_probersp_pkts(sta) \
255 (sta->sta_stats.rx_probersp_pkts)
257 #define sta_last_rx_probersp_pkts(sta) \
258 (sta->sta_stats.last_rx_probersp_pkts)
260 #define sta_rx_probersp_bm_pkts(sta) \
261 (sta->sta_stats.rx_probersp_bm_pkts)
263 #define sta_last_rx_probersp_bm_pkts(sta) \
264 (sta->sta_stats.last_rx_probersp_bm_pkts)
266 #define sta_rx_probersp_uo_pkts(sta) \
267 (sta->sta_stats.rx_probersp_uo_pkts)
269 #define sta_last_rx_probersp_uo_pkts(sta) \
270 (sta->sta_stats.last_rx_probersp_uo_pkts)
272 #define sta_update_last_rx_pkts(sta) \
274 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
275 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
276 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
277 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
278 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
279 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
280 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
281 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
284 #define STA_RX_PKTS_ARG(sta) \
285 sta->sta_stats.rx_mgnt_pkts \
286 , sta->sta_stats.rx_ctrl_pkts \
287 , sta->sta_stats.rx_data_pkts
289 #define STA_LAST_RX_PKTS_ARG(sta) \
290 sta->sta_stats.last_rx_mgnt_pkts \
291 , sta->sta_stats.last_rx_ctrl_pkts \
292 , sta->sta_stats.last_rx_data_pkts
294 #define STA_RX_PKTS_DIFF_ARG(sta) \
295 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
296 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
297 , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
299 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
303 u8 *pallocated_stainfo_buf;
305 struct __queue free_sta_queue;
307 spinlock_t sta_hash_lock;
308 struct list_head sta_hash[NUM_STA];
310 struct __queue sleep_q;
311 struct __queue wakeup_q;
313 struct adapter *padapter;
315 struct list_head asoc_list;
316 struct list_head auth_list;
317 spinlock_t asoc_list_lock;
318 spinlock_t auth_list_lock;
322 unsigned int auth_to; /* sec, time to expire in authenticating. */
323 unsigned int assoc_to; /* sec, time to expire before associating. */
324 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
330 struct sta_info *sta_aid[NUM_STA];
332 u16 sta_dz_bitmap;/* only support for 15 stations, aid bitmap for sleeping stations. */
333 u16 tim_bitmap;/* only support 15 stations, aid = 0~15 mapping bit0~bit15 */
337 struct wlan_acl_pool acl_list;
341 static inline u32 wifi_mac_hash(u8 *mac)
346 x = (x << 2) ^ mac[1];
347 x = (x << 2) ^ mac[2];
348 x = (x << 2) ^ mac[3];
349 x = (x << 2) ^ mac[4];
350 x = (x << 2) ^ mac[5];
353 x = x & (NUM_STA - 1);
359 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
360 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
362 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
363 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
364 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
366 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
367 extern u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta);
368 extern void rtw_free_all_stainfo(struct adapter *padapter);
369 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
370 extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter);
371 extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
372 extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
374 #endif /* _STA_INFO_H_ */