1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef __STA_INFO_H_
16#define __STA_INFO_H_
17
18
19#define IBSS_START_MAC_ID 2
20#define NUM_STA 32
21#define NUM_ACL 16
22
23
24
25
26struct rtw_wlan_acl_node {
27 struct list_head list;
28 u8 addr[ETH_ALEN];
29 u8 valid;
30};
31
32
33
34
35struct wlan_acl_pool {
36 int mode;
37 int num;
38 struct rtw_wlan_acl_node aclnode[NUM_ACL];
39 struct __queue acl_node_q;
40};
41
42typedef struct _RSSI_STA{
43 s32 UndecoratedSmoothedPWDB;
44 s32 UndecoratedSmoothedCCK;
45 s32 UndecoratedSmoothedOFDM;
46 u64 PacketMap;
47 u8 ValidBit;
48}RSSI_STA, *PRSSI_STA;
49
50struct stainfo_stats {
51
52 u64 rx_mgnt_pkts;
53 u64 rx_beacon_pkts;
54 u64 rx_probereq_pkts;
55 u64 rx_probersp_pkts;
56 u64 rx_probersp_bm_pkts;
57 u64 rx_probersp_uo_pkts;
58 u64 rx_ctrl_pkts;
59 u64 rx_data_pkts;
60
61 u64 last_rx_mgnt_pkts;
62 u64 last_rx_beacon_pkts;
63 u64 last_rx_probereq_pkts;
64 u64 last_rx_probersp_pkts;
65 u64 last_rx_probersp_bm_pkts;
66 u64 last_rx_probersp_uo_pkts;
67 u64 last_rx_ctrl_pkts;
68 u64 last_rx_data_pkts;
69
70 u64 rx_bytes;
71 u64 rx_drops;
72
73 u64 tx_pkts;
74 u64 tx_bytes;
75 u64 tx_drops;
76};
77
78struct sta_info {
79
80 _lock lock;
81 struct list_head list;
82 struct list_head hash_list;
83 struct adapter *padapter;
84
85 struct sta_xmit_priv sta_xmitpriv;
86 struct sta_recv_priv sta_recvpriv;
87
88 struct __queue sleep_q;
89 unsigned int sleepq_len;
90
91 uint state;
92 uint aid;
93 uint mac_id;
94 uint qos_option;
95 u8 hwaddr[ETH_ALEN];
96
97 uint ieee8021x_blocked;
98 uint dot118021XPrivacy;
99 union Keytype dot11tkiptxmickey;
100 union Keytype dot11tkiprxmickey;
101 union Keytype dot118021x_UncstKey;
102 union pn48 dot11txpn;
103#ifdef CONFIG_GTK_OL
104 u8 kek[RTW_KEK_LEN];
105 u8 kck[RTW_KCK_LEN];
106 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
107#endif
108 union pn48 dot11wtxpn;
109 union pn48 dot11rxpn;
110
111
112 u8 bssrateset[16];
113 u32 bssratelen;
114 s32 rssi;
115 s32 signal_quality;
116
117 u8 cts2self;
118 u8 rtsen;
119
120 u8 raid;
121 u8 init_rate;
122 u32 ra_mask;
123 u8 wireless_mode;
124 u8 bw_mode;
125
126 u8 ldpc;
127 u8 stbc;
128
129 struct stainfo_stats sta_stats;
130
131
132 _timer addba_retry_timer;
133
134
135 struct recv_reorder_ctrl recvreorder_ctrl[16];
136
137
138
139 u16 BA_starting_seqctrl[16];
140
141
142 struct ht_priv htpriv;
143
144
145
146
147
148
149
150
151
152
153 struct list_head asoc_list;
154 struct list_head auth_list;
155
156 unsigned int expire_to;
157 unsigned int auth_seq;
158 unsigned int authalg;
159 unsigned char chg_txt[128];
160
161 u16 capability;
162 int flags;
163
164 int dot8021xalg;
165 int wpa_psk;
166 int wpa_group_cipher;
167 int wpa2_group_cipher;
168 int wpa_pairwise_cipher;
169 int wpa2_pairwise_cipher;
170
171 u8 bpairwise_key_installed;
172
173 u8 wpa_ie[32];
174
175 u8 nonerp_set;
176 u8 no_short_slot_time_set;
177 u8 no_short_preamble_set;
178 u8 no_ht_gf_set;
179 u8 no_ht_set;
180 u8 ht_20mhz_set;
181
182 unsigned int tx_ra_bitmap;
183 u8 qos_info;
184
185 u8 max_sp_len;
186 u8 uapsd_bk;
187 u8 uapsd_be;
188 u8 uapsd_vi;
189 u8 uapsd_vo;
190
191 u8 has_legacy_ac;
192 unsigned int sleepq_ac_len;
193
194 u8 under_exist_checking;
195
196 u8 keep_alive_trycnt;
197
198#ifdef CONFIG_AUTO_AP_MODE
199 u8 isrc;
200 u16 pid;
201#endif
202
203 u8 *passoc_req;
204 u32 assoc_req_len;
205
206
207 RSSI_STA rssi_stat;
208
209
210
211
212
213
214
215
216
217 u8 bValid;
218 u8 IOTPeer;
219
220
221 u8 RSSI_Path[4];
222 u8 RSSI_Ave;
223 u8 RXEVM[4];
224 u8 RXSNR[4];
225
226 u8 rssi_level;
227
228
229
230
231
232
233
234
235 u16 RxMgmtFrameSeqNum;
236};
237
238#define sta_rx_pkts(sta) \
239 (sta->sta_stats.rx_mgnt_pkts \
240 + sta->sta_stats.rx_ctrl_pkts \
241 + sta->sta_stats.rx_data_pkts)
242
243#define sta_last_rx_pkts(sta) \
244 (sta->sta_stats.last_rx_mgnt_pkts \
245 + sta->sta_stats.last_rx_ctrl_pkts \
246 + sta->sta_stats.last_rx_data_pkts)
247
248#define sta_rx_data_pkts(sta) \
249 (sta->sta_stats.rx_data_pkts)
250
251#define sta_last_rx_data_pkts(sta) \
252 (sta->sta_stats.last_rx_data_pkts)
253
254#define sta_rx_mgnt_pkts(sta) \
255 (sta->sta_stats.rx_mgnt_pkts)
256
257#define sta_last_rx_mgnt_pkts(sta) \
258 (sta->sta_stats.last_rx_mgnt_pkts)
259
260#define sta_rx_beacon_pkts(sta) \
261 (sta->sta_stats.rx_beacon_pkts)
262
263#define sta_last_rx_beacon_pkts(sta) \
264 (sta->sta_stats.last_rx_beacon_pkts)
265
266#define sta_rx_probereq_pkts(sta) \
267 (sta->sta_stats.rx_probereq_pkts)
268
269#define sta_last_rx_probereq_pkts(sta) \
270 (sta->sta_stats.last_rx_probereq_pkts)
271
272#define sta_rx_probersp_pkts(sta) \
273 (sta->sta_stats.rx_probersp_pkts)
274
275#define sta_last_rx_probersp_pkts(sta) \
276 (sta->sta_stats.last_rx_probersp_pkts)
277
278#define sta_rx_probersp_bm_pkts(sta) \
279 (sta->sta_stats.rx_probersp_bm_pkts)
280
281#define sta_last_rx_probersp_bm_pkts(sta) \
282 (sta->sta_stats.last_rx_probersp_bm_pkts)
283
284#define sta_rx_probersp_uo_pkts(sta) \
285 (sta->sta_stats.rx_probersp_uo_pkts)
286
287#define sta_last_rx_probersp_uo_pkts(sta) \
288 (sta->sta_stats.last_rx_probersp_uo_pkts)
289
290#define sta_update_last_rx_pkts(sta) \
291 do { \
292 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
293 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
294 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
295 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
296 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
297 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
298 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
299 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
300 } while (0)
301
302#define STA_RX_PKTS_ARG(sta) \
303 sta->sta_stats.rx_mgnt_pkts \
304 , sta->sta_stats.rx_ctrl_pkts \
305 , sta->sta_stats.rx_data_pkts
306
307#define STA_LAST_RX_PKTS_ARG(sta) \
308 sta->sta_stats.last_rx_mgnt_pkts \
309 , sta->sta_stats.last_rx_ctrl_pkts \
310 , sta->sta_stats.last_rx_data_pkts
311
312#define STA_RX_PKTS_DIFF_ARG(sta) \
313 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
314 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
315 , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
316
317#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
318
319struct sta_priv {
320
321 u8 *pallocated_stainfo_buf;
322 u8 *pstainfo_buf;
323 struct __queue free_sta_queue;
324
325 _lock sta_hash_lock;
326 struct list_head sta_hash[NUM_STA];
327 int asoc_sta_count;
328 struct __queue sleep_q;
329 struct __queue wakeup_q;
330
331 struct adapter *padapter;
332
333 struct list_head asoc_list;
334 struct list_head auth_list;
335 _lock asoc_list_lock;
336 _lock auth_list_lock;
337 u8 asoc_list_cnt;
338 u8 auth_list_cnt;
339
340 unsigned int auth_to;
341 unsigned int assoc_to;
342 unsigned int expire_to;
343
344
345
346
347
348 struct sta_info *sta_aid[NUM_STA];
349
350 u16 sta_dz_bitmap;
351 u16 tim_bitmap;
352
353 u16 max_num_sta;
354
355 struct wlan_acl_pool acl_list;
356};
357
358
359__inline static u32 wifi_mac_hash(u8 *mac)
360{
361 u32 x;
362
363 x = mac[0];
364 x = (x << 2) ^ mac[1];
365 x = (x << 2) ^ mac[2];
366 x = (x << 2) ^ mac[3];
367 x = (x << 2) ^ mac[4];
368 x = (x << 2) ^ mac[5];
369
370 x ^= x >> 8;
371 x = x & (NUM_STA - 1);
372
373 return x;
374}
375
376
377extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
378extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
379
380#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
381int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
382struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
383
384extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
385extern u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta);
386extern void rtw_free_all_stainfo(struct adapter *padapter);
387extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
388extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter);
389extern struct sta_info* rtw_get_bcmc_stainfo(struct adapter *padapter);
390extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
391
392#endif
393