1/* SPDX-License-Identifier: GPL-2.0 */
2/******************************************************************************
3 *
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 *
6 ******************************************************************************/
7#ifndef __STA_INFO_H_
8#define __STA_INFO_H_
9
10
11#define IBSS_START_MAC_ID 2
12#define NUM_STA 32
13#define NUM_ACL 16
14
15
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. */
18struct rtw_wlan_acl_node {
19 struct list_head list;
20 u8 addr[ETH_ALEN];
21 u8 valid;
22};
23
24/* mode = 0, disable */
25/* mode = 1, accept unless in deny list */
26/* mode =2, deny unless in accept list */
27struct wlan_acl_pool {
28 int mode;
29 int num;
30 struct rtw_wlan_acl_node aclnode[NUM_ACL];
31 struct __queue acl_node_q;
32};
33
34struct rssi_sta {
35 s32 UndecoratedSmoothedPWDB;
36 s32 UndecoratedSmoothedCCK;
37 s32 UndecoratedSmoothedOFDM;
38 u64 PacketMap;
39 u8 ValidBit;
40};
41
42struct stainfo_stats {
43
44 u64 rx_mgnt_pkts;
45 u64 rx_beacon_pkts;
46 u64 rx_probereq_pkts;
47 u64 rx_probersp_pkts;
48 u64 rx_probersp_bm_pkts;
49 u64 rx_probersp_uo_pkts;
50 u64 rx_ctrl_pkts;
51 u64 rx_data_pkts;
52
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;
61
62 u64 rx_bytes;
63 u64 rx_drops;
64
65 u64 tx_pkts;
66 u64 tx_bytes;
67 u64 tx_drops;
68};
69
70struct sta_info {
71
72 spinlock_t lock;
73 struct list_head list; /* free_sta_queue */
74 struct list_head hash_list; /* sta_hash */
75 struct adapter *padapter;
76
77 struct sta_xmit_priv sta_xmitpriv;
78 struct sta_recv_priv sta_recvpriv;
79
80 struct __queue sleep_q;
81 unsigned int sleepq_len;
82
83 uint state;
84 uint aid;
85 uint mac_id;
86 uint qos_option;
87 u8 hwaddr[ETH_ALEN];
88
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. */
97
98
99 u8 bssrateset[16];
100 u32 bssratelen;
101 s32 rssi;
102 s32 signal_quality;
103
104 u8 cts2self;
105 u8 rtsen;
106
107 u8 raid;
108 u8 init_rate;
109 u32 ra_mask;
110 u8 wireless_mode; /* NETWORK_TYPE */
111 u8 bw_mode;
112
113 u8 ldpc;
114 u8 stbc;
115
116 struct stainfo_stats sta_stats;
117
118 /* for A-MPDU TX, ADDBA timeout check */
119 struct timer_list addba_retry_timer;
120
121 /* for A-MPDU Rx reordering buffer control */
122 struct recv_reorder_ctrl recvreorder_ctrl[16];
123
124 /* for A-MPDU Tx */
125 /* unsigned char ampdu_txen_bitmap; */
126 u16 BA_starting_seqctrl[16];
127
128
129 struct ht_priv htpriv;
130
131 /* Notes: */
132 /* STA_Mode: */
133 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
134 /* scan_q: AP CAP/INFO */
135
136 /* AP_Mode: */
137 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
138 /* sta_info: (AP & STA) CAP/INFO */
139
140 struct list_head asoc_list;
141 struct list_head auth_list;
142
143 unsigned int expire_to;
144 unsigned int auth_seq;
145 unsigned int authalg;
146 unsigned char chg_txt[128];
147
148 u16 capability;
149 int flags;
150
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;
157
158 u8 bpairwise_key_installed;
159
160 u8 wpa_ie[32];
161
162 u8 nonerp_set;
163 u8 no_short_slot_time_set;
164 u8 no_short_preamble_set;
165 u8 no_ht_gf_set;
166 u8 no_ht_set;
167 u8 ht_20mhz_set;
168
169 unsigned int tx_ra_bitmap;
170 u8 qos_info;
171
172 u8 max_sp_len;
173 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
174 u8 uapsd_be;
175 u8 uapsd_vi;
176 u8 uapsd_vo;
177
178 u8 has_legacy_ac;
179 unsigned int sleepq_ac_len;
180
181 u8 under_exist_checking;
182
183 u8 keep_alive_trycnt;
184
185 u8 *passoc_req;
186 u32 assoc_req_len;
187
188 /* for DM */
189 struct rssi_sta rssi_stat;
190
191 /* ODM_STA_INFO_T */
192 /* ================ODM Relative Info ======================= */
193 /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
194 /* */
195 /* */
196 /* 2011/10/20 MH Add for ODM STA info. */
197 /* */
198 /* Driver Write */
199 u8 bValid; /* record the sta status link or not? */
200 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
201 /* ODM Write */
202 /* 1 PHY_STATUS_INFO */
203 u8 RSSI_Path[4]; /* */
204 u8 RSSI_Ave;
205 u8 RXEVM[4];
206 u8 RXSNR[4];
207
208 u8 rssi_level; /* for Refresh RA mask */
209 /* ODM Write */
210 /* 1 TX_INFO (may changed by IC) */
211 /* TX_INFO_T pTxInfo; Define in IC folder. Move lower layer. */
212 /* */
213 /* ================ODM Relative Info ======================= */
214 /* */
215
216 /* To store the sequence number of received management frame */
217 u16 RxMgmtFrameSeqNum;
218};
219
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)
224
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)
229
230#define sta_rx_data_pkts(sta) \
231 (sta->sta_stats.rx_data_pkts)
232
233#define sta_last_rx_data_pkts(sta) \
234 (sta->sta_stats.last_rx_data_pkts)
235
236#define sta_rx_mgnt_pkts(sta) \
237 (sta->sta_stats.rx_mgnt_pkts)
238
239#define sta_last_rx_mgnt_pkts(sta) \
240 (sta->sta_stats.last_rx_mgnt_pkts)
241
242#define sta_rx_beacon_pkts(sta) \
243 (sta->sta_stats.rx_beacon_pkts)
244
245#define sta_last_rx_beacon_pkts(sta) \
246 (sta->sta_stats.last_rx_beacon_pkts)
247
248#define sta_rx_probereq_pkts(sta) \
249 (sta->sta_stats.rx_probereq_pkts)
250
251#define sta_last_rx_probereq_pkts(sta) \
252 (sta->sta_stats.last_rx_probereq_pkts)
253
254#define sta_rx_probersp_pkts(sta) \
255 (sta->sta_stats.rx_probersp_pkts)
256
257#define sta_last_rx_probersp_pkts(sta) \
258 (sta->sta_stats.last_rx_probersp_pkts)
259
260#define sta_rx_probersp_bm_pkts(sta) \
261 (sta->sta_stats.rx_probersp_bm_pkts)
262
263#define sta_last_rx_probersp_bm_pkts(sta) \
264 (sta->sta_stats.last_rx_probersp_bm_pkts)
265
266#define sta_rx_probersp_uo_pkts(sta) \
267 (sta->sta_stats.rx_probersp_uo_pkts)
268
269#define sta_last_rx_probersp_uo_pkts(sta) \
270 (sta->sta_stats.last_rx_probersp_uo_pkts)
271
272#define sta_update_last_rx_pkts(sta) \
273 do { \
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; \
282 } while (0)
283
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
288
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
293
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
298
299#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
300
301struct sta_priv {
302
303 u8 *pallocated_stainfo_buf;
304 u8 *pstainfo_buf;
305 struct __queue free_sta_queue;
306
307 spinlock_t sta_hash_lock;
308 struct list_head sta_hash[NUM_STA];
309 int asoc_sta_count;
310 struct __queue sleep_q;
311 struct __queue wakeup_q;
312
313 struct adapter *padapter;
314
315 struct list_head asoc_list;
316 struct list_head auth_list;
317 spinlock_t asoc_list_lock;
318 spinlock_t auth_list_lock;
319 u8 asoc_list_cnt;
320 u8 auth_list_cnt;
321
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. */
325
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
328 * and so on
329 */
330 struct sta_info *sta_aid[NUM_STA];
331
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 */
334
335 u16 max_num_sta;
336
337 struct wlan_acl_pool acl_list;
338};
339
340
341static inline u32 wifi_mac_hash(u8 *mac)
342{
343 u32 x;
344
345 x = mac[0];
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];
351
352 x ^= x >> 8;
353 x = x & (NUM_STA - 1);
354
355 return x;
356}
357
358
359extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
360extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
361
362#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
363int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
364struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
365
366extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
367extern u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta);
368extern void rtw_free_all_stainfo(struct adapter *padapter);
369extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
370extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter);
371extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
372extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
373
374#endif /* _STA_INFO_H_ */
375

source code of linux/drivers/staging/rtl8723bs/include/sta_info.h