1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
7 #include <osdep_service.h>
11 #define IBSS_START_MAC_ID 2
15 /* if mode ==0, then the sta is allowed once the addr is hit. */
16 /* if mode ==1, then the sta is rejected once the addr is non-hit. */
17 struct rtw_wlan_acl_node {
18 struct list_head list;
24 /* mode=1, accept unless in deny list */
25 /* mode=2, deny unless in accept list */
26 struct wlan_acl_pool {
29 struct rtw_wlan_acl_node aclnode[NUM_ACL];
30 struct __queue acl_node_q;
34 s32 UndecoratedSmoothedPWDB;
35 s32 UndecoratedSmoothedCCK;
36 s32 UndecoratedSmoothedOFDM;
41 struct stainfo_stats {
46 u64 rx_probersp_bm_pkts;
47 u64 rx_probersp_uo_pkts;
51 u64 last_rx_mgnt_pkts;
52 u64 last_rx_beacon_pkts;
53 u64 last_rx_probereq_pkts;
54 u64 last_rx_probersp_pkts;
55 u64 last_rx_probersp_bm_pkts;
56 u64 last_rx_probersp_uo_pkts;
57 u64 last_rx_ctrl_pkts;
58 u64 last_rx_data_pkts;
68 struct list_head list; /* free_sta_queue */
69 struct list_head hash_list; /* sta_hash */
71 struct sta_xmit_priv sta_xmitpriv;
72 struct sta_recv_priv sta_recvpriv;
74 struct __queue sleep_q;
75 unsigned int sleepq_len;
83 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
84 uint dot118021XPrivacy; /* aes, tkip... */
85 union Keytype dot11tkiptxmickey;
86 union Keytype dot11tkiprxmickey;
87 union Keytype dot118021x_UncstKey;
88 union pn48 dot11txpn; /* PN48 used for Unicast xmit. */
89 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
101 u8 wireless_mode; /* NETWORK_TYPE */
102 struct stainfo_stats sta_stats;
104 /* for A-MPDU TX, ADDBA timeout check */
105 struct timer_list addba_retry_timer;
107 /* for A-MPDU Rx reordering buffer control */
108 struct recv_reorder_ctrl recvreorder_ctrl[16];
111 /* unsigned char ampdu_txen_bitmap; */
112 u16 BA_starting_seqctrl[16];
114 struct ht_priv htpriv;
118 /* curr_network(mlme_priv/security_priv/qos/ht) +
119 * sta_info: (STA & AP) CAP/INFO */
120 /* scan_q: AP CAP/INFO */
123 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
124 /* sta_info: (AP & STA) CAP/INFO */
126 struct list_head asoc_list;
127 #ifdef CONFIG_88EU_AP_MODE
128 struct list_head auth_list;
130 unsigned int expire_to;
131 unsigned int auth_seq;
132 unsigned int authalg;
133 unsigned char chg_txt[128];
138 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
139 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
140 int wpa_group_cipher;
141 int wpa2_group_cipher;
142 int wpa_pairwise_cipher;
143 int wpa2_pairwise_cipher;
145 u8 bpairwise_key_installed;
150 u8 no_short_slot_time_set;
151 u8 no_short_preamble_set;
156 unsigned int tx_ra_bitmap;
160 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
166 unsigned int sleepq_ac_len;
167 #endif /* CONFIG_88EU_AP_MODE */
169 #ifdef CONFIG_88EU_P2P
174 /* p2p client info */
175 u8 dev_addr[ETH_ALEN];
178 u8 primary_dev_type[8];
179 u8 num_of_secdev_type;
180 u8 secdev_types_list[32];/* 32/8 == 4; */
183 #endif /* CONFIG_88EU_P2P */
184 u8 under_exist_checking;
185 u8 keep_alive_trycnt;
188 struct rssi_sta rssi_stat;
190 /* ================ODM Relative Info======================= */
191 /* Please be careful, don't declare too much structure here.
192 * It will cost memory * STA support num. */
193 /* 2011/10/20 MH Add for ODM STA info. */
195 u8 bValid; /* record the sta status link or not? */
196 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
197 u8 rssi_level; /* for Refresh RA mask */
199 /* 1 PHY_STATUS_INFO */
200 u8 RSSI_Path[4]; /* */
205 /* ================ODM Relative Info======================= */
208 /* To store the sequence number of received management frame */
209 u16 RxMgmtFrameSeqNum;
212 #define sta_rx_pkts(sta) \
213 (sta->sta_stats.rx_mgnt_pkts \
214 + sta->sta_stats.rx_ctrl_pkts \
215 + sta->sta_stats.rx_data_pkts)
217 #define sta_last_rx_pkts(sta) \
218 (sta->sta_stats.last_rx_mgnt_pkts \
219 + sta->sta_stats.last_rx_ctrl_pkts \
220 + sta->sta_stats.last_rx_data_pkts)
222 #define sta_rx_data_pkts(sta) \
223 (sta->sta_stats.rx_data_pkts)
225 #define sta_last_rx_data_pkts(sta) \
226 (sta->sta_stats.last_rx_data_pkts)
228 #define sta_rx_mgnt_pkts(sta) \
229 (sta->sta_stats.rx_mgnt_pkts)
231 #define sta_last_rx_mgnt_pkts(sta) \
232 (sta->sta_stats.last_rx_mgnt_pkts)
234 #define sta_rx_beacon_pkts(sta) \
235 (sta->sta_stats.rx_beacon_pkts)
237 #define sta_last_rx_beacon_pkts(sta) \
238 (sta->sta_stats.last_rx_beacon_pkts)
240 #define sta_rx_probereq_pkts(sta) \
241 (sta->sta_stats.rx_probereq_pkts)
243 #define sta_last_rx_probereq_pkts(sta) \
244 (sta->sta_stats.last_rx_probereq_pkts)
246 #define sta_rx_probersp_pkts(sta) \
247 (sta->sta_stats.rx_probersp_pkts)
249 #define sta_last_rx_probersp_pkts(sta) \
250 (sta->sta_stats.last_rx_probersp_pkts)
252 #define sta_rx_probersp_bm_pkts(sta) \
253 (sta->sta_stats.rx_probersp_bm_pkts)
255 #define sta_last_rx_probersp_bm_pkts(sta) \
256 (sta->sta_stats.last_rx_probersp_bm_pkts)
258 #define sta_rx_probersp_uo_pkts(sta) \
259 (sta->sta_stats.rx_probersp_uo_pkts)
261 #define sta_last_rx_probersp_uo_pkts(sta) \
262 (sta->sta_stats.last_rx_probersp_uo_pkts)
264 #define sta_update_last_rx_pkts(sta) \
266 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
267 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
268 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
269 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
270 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
271 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
272 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
273 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
276 #define STA_RX_PKTS_ARG(sta) \
277 sta->sta_stats.rx_mgnt_pkts \
278 , sta->sta_stats.rx_ctrl_pkts \
279 , sta->sta_stats.rx_data_pkts
281 #define STA_LAST_RX_PKTS_ARG(sta) \
282 sta->sta_stats.last_rx_mgnt_pkts \
283 , sta->sta_stats.last_rx_ctrl_pkts \
284 , sta->sta_stats.last_rx_data_pkts
286 #define STA_RX_PKTS_DIFF_ARG(sta) \
287 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
288 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
289 , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
291 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
294 u8 *pallocated_stainfo_buf;
296 struct __queue free_sta_queue;
298 spinlock_t sta_hash_lock;
299 struct list_head sta_hash[NUM_STA];
301 struct __queue sleep_q;
302 struct __queue wakeup_q;
304 struct adapter *padapter;
306 spinlock_t asoc_list_lock;
307 struct list_head asoc_list;
309 #ifdef CONFIG_88EU_AP_MODE
310 struct list_head auth_list;
311 spinlock_t auth_list_lock;
315 unsigned int auth_to; /* sec, time to expire in authenticating. */
316 unsigned int assoc_to; /* sec, time to expire before associating. */
317 unsigned int expire_to; /* sec , time to expire after associated. */
319 /* pointers to STA info; based on allocated AID or NULL if AID free
320 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
323 struct sta_info *sta_aid[NUM_STA];
325 u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
326 * for sleeping sta. */
327 u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping
332 struct wlan_acl_pool acl_list;
337 static inline u32 wifi_mac_hash(u8 *mac)
342 x = (x << 2) ^ mac[1];
343 x = (x << 2) ^ mac[2];
344 x = (x << 2) ^ mac[3];
345 x = (x << 2) ^ mac[4];
346 x = (x << 2) ^ mac[5];
349 x = x & (NUM_STA - 1);
353 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
354 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
356 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
357 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
358 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off);
360 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
361 extern u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta);
362 extern void rtw_free_all_stainfo(struct adapter *adapt);
363 extern struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
364 extern u32 rtw_init_bcmc_stainfo(struct adapter *adapt);
365 extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
366 extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
368 #endif /* _STA_INFO_H_ */