1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2019 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 *****************************************************************************/
15 #ifndef __STA_INFO_H_
16 #define __STA_INFO_H_
17
18 #include <cmn_info/rtw_sta_info.h>
19
20 #define IBSS_START_MAC_ID 2
21 #define NUM_STA MACID_NUM_SW_LIMIT
22
23 #ifndef CONFIG_RTW_MACADDR_ACL
24 #define CONFIG_RTW_MACADDR_ACL 1
25 #endif
26
27 #ifndef CONFIG_RTW_PRE_LINK_STA
28 #define CONFIG_RTW_PRE_LINK_STA 0
29 #endif
30
31 #define NUM_ACL 16
32
33 #define RTW_ACL_PERIOD_DEV 0
34 #define RTW_ACL_PERIOD_BSS 1
35 #define RTW_ACL_PERIOD_NUM 2
36
37 #define RTW_ACL_MODE_DISABLED 0
38 #define RTW_ACL_MODE_ACCEPT_UNLESS_LISTED 1
39 #define RTW_ACL_MODE_DENY_UNLESS_LISTED 2
40 #define RTW_ACL_MODE_MAX 3
41
42 #if CONFIG_RTW_MACADDR_ACL
43 extern const char *const _acl_period_str[RTW_ACL_PERIOD_NUM];
44 #define acl_period_str(mode) (((mode) >= RTW_ACL_PERIOD_NUM) ? "INVALID" : _acl_period_str[(mode)])
45 extern const char *const _acl_mode_str[RTW_ACL_MODE_MAX];
46 #define acl_mode_str(mode) (((mode) >= RTW_ACL_MODE_MAX) ? "INVALID" : _acl_mode_str[(mode)])
47 #endif
48
49 #ifndef RTW_PRE_LINK_STA_NUM
50 #define RTW_PRE_LINK_STA_NUM 8
51 #endif
52
53 struct pre_link_sta_node_t {
54 u8 valid;
55 u8 addr[ETH_ALEN];
56 };
57
58 struct pre_link_sta_ctl_t {
59 _lock lock;
60 u8 num;
61 struct pre_link_sta_node_t node[RTW_PRE_LINK_STA_NUM];
62 };
63
64 #ifdef CONFIG_TDLS
65 #define MAX_ALLOWED_TDLS_STA_NUM 4
66 #endif
67
68 enum sta_info_update_type {
69 STA_INFO_UPDATE_NONE = 0,
70 STA_INFO_UPDATE_BW = BIT(0),
71 STA_INFO_UPDATE_RATE = BIT(1),
72 STA_INFO_UPDATE_PROTECTION_MODE = BIT(2),
73 STA_INFO_UPDATE_CAP = BIT(3),
74 STA_INFO_UPDATE_HT_CAP = BIT(4),
75 STA_INFO_UPDATE_VHT_CAP = BIT(5),
76 STA_INFO_UPDATE_ALL = STA_INFO_UPDATE_BW
77 | STA_INFO_UPDATE_RATE
78 | STA_INFO_UPDATE_PROTECTION_MODE
79 | STA_INFO_UPDATE_CAP
80 | STA_INFO_UPDATE_HT_CAP
81 | STA_INFO_UPDATE_VHT_CAP,
82 STA_INFO_UPDATE_MAX
83 };
84
85 struct rtw_wlan_acl_node {
86 _list list;
87 u8 addr[ETH_ALEN];
88 u8 valid;
89 };
90
91 struct wlan_acl_pool {
92 int mode;
93 int num;
94 struct rtw_wlan_acl_node aclnode[NUM_ACL];
95 _queue acl_node_q;
96 };
97
98 struct stainfo_stats {
99 systime last_rx_time;
100
101 u64 rx_mgnt_pkts;
102 u64 rx_beacon_pkts;
103 u64 rx_probereq_pkts;
104 u64 rx_probersp_pkts; /* unicast to self */
105 u64 rx_probersp_bm_pkts;
106 u64 rx_probersp_uo_pkts; /* unicast to others */
107 u64 rx_ctrl_pkts;
108 u64 rx_data_pkts;
109 u64 rx_data_bc_pkts;
110 u64 rx_data_mc_pkts;
111 u64 rx_data_qos_pkts[TID_NUM]; /* unicast only */
112
113 u64 last_rx_mgnt_pkts;
114 u64 last_rx_beacon_pkts;
115 u64 last_rx_probereq_pkts;
116 u64 last_rx_probersp_pkts; /* unicast to self */
117 u64 last_rx_probersp_bm_pkts;
118 u64 last_rx_probersp_uo_pkts; /* unicast to others */
119 u64 last_rx_ctrl_pkts;
120 u64 last_rx_data_pkts;
121 u64 last_rx_data_bc_pkts;
122 u64 last_rx_data_mc_pkts;
123 u64 last_rx_data_qos_pkts[TID_NUM]; /* unicast only */
124
125 #ifdef CONFIG_TDLS
126 u64 rx_tdls_disc_rsp_pkts;
127 u64 last_rx_tdls_disc_rsp_pkts;
128 #endif
129
130 u64 rx_bytes;
131 u64 rx_bc_bytes;
132 u64 rx_mc_bytes;
133 u64 last_rx_bytes;
134 u64 last_rx_bc_bytes;
135 u64 last_rx_mc_bytes;
136 u64 rx_drops; /* TBD */
137 u32 rx_tp_kbits;
138 u32 smooth_rx_tp_kbits;
139
140 u64 tx_pkts;
141 u64 last_tx_pkts;
142
143 u64 tx_bytes;
144 u64 last_tx_bytes;
145 u64 tx_drops; /* TBD */
146 u32 tx_tp_kbits;
147 u32 smooth_tx_tp_kbits;
148
149 #ifdef CONFIG_LPS_CHK_BY_TP
150 u64 acc_tx_bytes;
151 u64 acc_rx_bytes;
152 #endif
153
154 /* unicast only */
155 u64 last_rx_data_uc_pkts; /* For Read & Clear requirement in proc_get_rx_stat() */
156 u32 duplicate_cnt; /* Read & Clear, in proc_get_rx_stat() */
157 u32 rxratecnt[128]; /* Read & Clear, in proc_get_rx_stat() */
158 u32 tx_ok_cnt; /* Read & Clear, in proc_get_tx_stat() */
159 u32 tx_fail_cnt; /* Read & Clear, in proc_get_tx_stat() */
160 u32 tx_retry_cnt; /* Read & Clear, in proc_get_tx_stat() */
161 #ifdef CONFIG_RTW_MESH
162 u32 rx_hwmp_pkts;
163 u32 last_rx_hwmp_pkts;
164 #endif
165 };
166
167 #ifndef DBG_SESSION_TRACKER
168 #define DBG_SESSION_TRACKER 0
169 #endif
170
171 /* session tracker status */
172 #define ST_STATUS_NONE 0
173 #define ST_STATUS_CHECK BIT0
174 #define ST_STATUS_ESTABLISH BIT1
175 #define ST_STATUS_EXPIRE BIT2
176
177 #define ST_EXPIRE_MS (10 * 1000)
178
179 struct session_tracker {
180 _list list; /* session_tracker_queue */
181 u32 local_naddr;
182 u16 local_port;
183 u32 remote_naddr;
184 u16 remote_port;
185 systime set_time;
186 u8 status;
187 };
188
189 /* session tracker cmd */
190 #define ST_CMD_ADD 0
191 #define ST_CMD_DEL 1
192 #define ST_CMD_CHK 2
193
194 struct st_cmd_parm {
195 u8 cmd;
196 struct sta_info *sta;
197 u32 local_naddr; /* TODO: IPV6 */
198 u16 local_port;
199 u32 remote_naddr; /* TODO: IPV6 */
200 u16 remote_port;
201 };
202
203 typedef bool (*st_match_rule)(_adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
204
205 struct st_register {
206 u8 s_proto;
207 st_match_rule rule;
208 };
209
210 #define SESSION_TRACKER_REG_ID_WFD 0
211 #define SESSION_TRACKER_REG_ID_NUM 1
212
213 struct st_ctl_t {
214 struct st_register reg[SESSION_TRACKER_REG_ID_NUM];
215 _queue tracker_q;
216 };
217
218 void rtw_st_ctl_init(struct st_ctl_t *st_ctl);
219 void rtw_st_ctl_deinit(struct st_ctl_t *st_ctl);
220 void rtw_st_ctl_register(struct st_ctl_t *st_ctl, u8 st_reg_id, struct st_register *reg);
221 void rtw_st_ctl_unregister(struct st_ctl_t *st_ctl, u8 st_reg_id);
222 bool rtw_st_ctl_chk_reg_s_proto(struct st_ctl_t *st_ctl, u8 s_proto);
223 bool rtw_st_ctl_chk_reg_rule(struct st_ctl_t *st_ctl, _adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
224 void rtw_st_ctl_rx(struct sta_info *sta, u8 *ehdr_pos);
225 void dump_st_ctl(void *sel, struct st_ctl_t *st_ctl);
226
227 #ifdef CONFIG_TDLS
228 struct TDLS_PeerKey {
229 u8 kck[16]; /* TPK-KCK */
230 u8 tk[16]; /* TPK-TK; only CCMP will be used */
231 } ;
232 #endif /* CONFIG_TDLS */
233
234 #ifdef DBG_RX_DFRAME_RAW_DATA
235 struct sta_recv_dframe_info {
236
237 u8 sta_data_rate;
238 u8 sta_sgi;
239 u8 sta_bw_mode;
240 s8 sta_mimo_signal_strength[4];
241 s8 sta_RxPwr[4];
242 u8 sta_ofdm_snr[4];
243 };
244 #endif
245
246 #ifdef CONFIG_RTW_MESH
247 struct mesh_plink_ent;
248 struct rtw_ewma_err_rate {
249 unsigned long internal;
250 };
251
252 /* Mesh airtime link metrics parameters */
253 struct rtw_atlm_param {
254 struct rtw_ewma_err_rate err_rate; /* Now is PACKET error rate */
255 u16 data_rate; /* The unit is 100Kbps */
256 u16 total_pkt;
257 u16 overhead; /* Channel access overhead */
258 };
259 #endif
260
261 struct sta_info {
262
263 _lock lock;
264 _list list; /* free_sta_queue */
265 _list hash_list; /* sta_hash */
266 /* _list asoc_list; */ /* 20061114 */
267 /* _list sleep_list; */ /* sleep_q */
268 /* _list wakeup_list; */ /* wakeup_q */
269 _adapter *padapter;
270 struct cmn_sta_info cmn;
271
272 struct sta_xmit_priv sta_xmitpriv;
273 struct sta_recv_priv sta_recvpriv;
274
275 #ifdef DBG_RX_DFRAME_RAW_DATA
276 struct sta_recv_dframe_info sta_dframe_info;
277 struct sta_recv_dframe_info sta_dframe_info_bmc;
278 #endif
279 _queue sleep_q;
280 unsigned int sleepq_len;
281
282 uint state;
283 uint qos_option;
284 u16 hwseq;
285
286 #ifdef CONFIG_RTW_80211K
287 u8 rm_en_cap[5];
288 u8 rm_diag_token;
289 #endif /* CONFIG_RTW_80211K */
290
291 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
292 uint dot118021XPrivacy; /* aes, tkip... */
293 union Keytype dot11tkiptxmickey;
294 union Keytype dot11tkiprxmickey;
295 union Keytype dot118021x_UncstKey;
296 union pn48 dot11txpn; /* PN48 used for Unicast xmit */
297 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
298 #ifdef CONFIG_RTW_MESH
299 /* peer's GTK, RX only */
300 u8 group_privacy;
301 u8 gtk_bmp;
302 union Keytype gtk;
303 union pn48 gtk_pn;
304 #ifdef CONFIG_IEEE80211W
305 /* peer's IGTK, RX only */
306 u8 igtk_bmp;
307 u8 igtk_id;
308 union Keytype igtk;
309 union pn48 igtk_pn;
310 #endif /* CONFIG_IEEE80211W */
311 #endif /* CONFIG_RTW_MESH */
312 #ifdef CONFIG_GTK_OL
313 u8 kek[RTW_KEK_LEN];
314 u8 kck[RTW_KCK_LEN];
315 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
316 #endif /* CONFIG_GTK_OL */
317 #ifdef CONFIG_IEEE80211W
318 _timer dot11w_expire_timer;
319 #endif /* CONFIG_IEEE80211W */
320
321 u8 bssrateset[16];
322 u32 bssratelen;
323
324 u8 cts2self;
325 u8 rtsen;
326
327 u8 init_rate;
328 u8 wireless_mode; /* NETWORK_TYPE */
329
330 struct stainfo_stats sta_stats;
331
332 #ifdef CONFIG_TDLS
333 u32 tdls_sta_state;
334 u8 SNonce[32];
335 u8 ANonce[32];
336 u32 TDLS_PeerKey_Lifetime;
337 u32 TPK_count;
338 _timer TPK_timer;
339 struct TDLS_PeerKey tpk;
340 #ifdef CONFIG_TDLS_CH_SW
341 u16 ch_switch_time;
342 u16 ch_switch_timeout;
343 /* u8 option; */
344 _timer ch_sw_timer;
345 _timer delay_timer;
346 _timer stay_on_base_chnl_timer;
347 _timer ch_sw_monitor_timer;
348 #endif
349 _timer handshake_timer;
350 u8 alive_count;
351 _timer pti_timer;
352 u8 TDLS_RSNIE[20]; /* Save peer's RSNIE, used for sending TDLS_SETUP_RSP */
353 #endif /* CONFIG_TDLS */
354
355 /* for A-MPDU TX, ADDBA timeout check */
356 _timer addba_retry_timer;
357
358 /* for A-MPDU Rx reordering buffer control */
359 struct recv_reorder_ctrl recvreorder_ctrl[TID_NUM];
360 ATOMIC_T continual_no_rx_packet[TID_NUM];
361 /* for A-MPDU Tx */
362 /* unsigned char ampdu_txen_bitmap; */
363 u16 BA_starting_seqctrl[16];
364
365
366 #ifdef CONFIG_80211N_HT
367 struct ht_priv htpriv;
368 #endif
369
370 #ifdef CONFIG_80211AC_VHT
371 struct vht_priv vhtpriv;
372 #endif
373
374 /* Notes: */
375 /* STA_Mode: */
376 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
377 /* scan_q: AP CAP/INFO */
378
379 /* AP_Mode: */
380 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
381 /* sta_info: (AP & STA) CAP/INFO */
382
383 unsigned int expire_to;
384
385 #ifdef CONFIG_AP_MODE
386
387 _list asoc_list;
388 _list auth_list;
389
390 unsigned int auth_seq;
391 unsigned int authalg;
392 unsigned char chg_txt[128];
393
394 u16 capability;
395 int flags;
396
397 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
398 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
399 int wpa_group_cipher;
400 int wpa2_group_cipher;
401 int wpa_pairwise_cipher;
402 int wpa2_pairwise_cipher;
403
404 u32 akm_suite_type;
405
406 u8 bpairwise_key_installed;
407 #ifdef CONFIG_RTW_80211R
408 u8 ft_pairwise_key_installed;
409 #endif
410
411 #ifdef CONFIG_NATIVEAP_MLME
412 u8 wpa_ie[32];
413
414 u8 nonerp_set;
415 u8 no_short_slot_time_set;
416 u8 no_short_preamble_set;
417 u8 no_ht_gf_set;
418 u8 no_ht_set;
419 u8 ht_20mhz_set;
420 u8 ht_40mhz_intolerant;
421 #endif /* CONFIG_NATIVEAP_MLME */
422
423 #ifdef CONFIG_ATMEL_RC_PATCH
424 u8 flag_atmel_rc;
425 #endif
426
427 u8 qos_info;
428
429 u8 max_sp_len;
430 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
431 u8 uapsd_be;
432 u8 uapsd_vi;
433 u8 uapsd_vo;
434
435 u8 has_legacy_ac;
436 unsigned int sleepq_ac_len;
437
438 #ifdef CONFIG_P2P
439 /* p2p priv data */
440 u8 is_p2p_device;
441 u8 p2p_status_code;
442
443 /* p2p client info */
444 u8 dev_addr[ETH_ALEN];
445 /* u8 iface_addr[ETH_ALEN]; */ /* = hwaddr[ETH_ALEN] */
446 u8 dev_cap;
447 u16 config_methods;
448 u8 primary_dev_type[8];
449 u8 num_of_secdev_type;
450 u8 secdev_types_list[32];/* 32/8 == 4; */
451 u16 dev_name_len;
452 u8 dev_name[32];
453 #endif /* CONFIG_P2P */
454
455 #ifdef CONFIG_WFD
456 u8 op_wfd_mode;
457 #endif
458
459 #ifdef CONFIG_TX_MCAST2UNI
460 u8 under_exist_checking;
461 #endif /* CONFIG_TX_MCAST2UNI */
462
463 u8 keep_alive_trycnt;
464
465 #ifdef CONFIG_AUTO_AP_MODE
466 u8 isrc; /* this device is rc */
467 u16 pid; /* pairing id */
468 #endif
469
470 #endif /* CONFIG_AP_MODE */
471
472 #ifdef CONFIG_RTW_MESH
473 struct mesh_plink_ent *plink;
474
475 u8 local_mps;
476 u8 peer_mps;
477 u8 nonpeer_mps;
478
479 struct rtw_atlm_param metrics;
480 /* The reference for nexthop_lookup */
481 BOOLEAN alive;
482 #endif
483
484 #ifdef CONFIG_IOCTL_CFG80211
485 u8 *pauth_frame;
486 u32 auth_len;
487 u8 *passoc_req;
488 u32 assoc_req_len;
489 #endif
490
491 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
492 #ifdef CONFIG_LPS_PG
493 u8 lps_pg_rssi_lv;
494 #endif
495
496 /* To store the sequence number of received management frame */
497 u16 RxMgmtFrameSeqNum;
498
499 struct st_ctl_t st_ctl;
500 u8 max_agg_num_minimal_record; /*keep minimal tx desc max_agg_num setting*/
501 u8 curr_rx_rate;
502 u8 curr_rx_rate_bmc;
503 #ifdef CONFIG_RTS_FULL_BW
504 bool vendor_8812;
505 #endif
506
507 /*
508 * Vaiables for queuing TX pkt a short period of time
509 * to wait something ready.
510 */
511 u8 tx_q_enable;
512 struct __queue tx_queue;
513 _workitem tx_q_work;
514 };
515
516 #ifdef CONFIG_RTW_MESH
517 #define STA_SET_MESH_PLINK(sta, link) (sta)->plink = link
518 #else
519 #define STA_SET_MESH_PLINK(sta, link) do {} while (0)
520 #endif
521
522 #define sta_tx_pkts(sta) \
523 (sta->sta_stats.tx_pkts)
524
525 #define sta_last_tx_pkts(sta) \
526 (sta->sta_stats.last_tx_pkts)
527
528 #define sta_rx_pkts(sta) \
529 (sta->sta_stats.rx_mgnt_pkts \
530 + sta->sta_stats.rx_ctrl_pkts \
531 + sta->sta_stats.rx_data_pkts)
532
533 #define sta_last_rx_pkts(sta) \
534 (sta->sta_stats.last_rx_mgnt_pkts \
535 + sta->sta_stats.last_rx_ctrl_pkts \
536 + sta->sta_stats.last_rx_data_pkts)
537
538 #define sta_rx_data_pkts(sta) (sta->sta_stats.rx_data_pkts)
539 #define sta_last_rx_data_pkts(sta) (sta->sta_stats.last_rx_data_pkts)
540
541 #define sta_rx_data_uc_pkts(sta) (sta->sta_stats.rx_data_pkts - sta->sta_stats.rx_data_bc_pkts - sta->sta_stats.rx_data_mc_pkts)
542 #define sta_last_rx_data_uc_pkts(sta) (sta->sta_stats.last_rx_data_pkts - sta->sta_stats.last_rx_data_bc_pkts - sta->sta_stats.last_rx_data_mc_pkts)
543
544 #define sta_rx_data_qos_pkts(sta, i) \
545 (sta->sta_stats.rx_data_qos_pkts[i])
546
547 #define sta_last_rx_data_qos_pkts(sta, i) \
548 (sta->sta_stats.last_rx_data_qos_pkts[i])
549
550 #define sta_rx_mgnt_pkts(sta) \
551 (sta->sta_stats.rx_mgnt_pkts)
552
553 #define sta_last_rx_mgnt_pkts(sta) \
554 (sta->sta_stats.last_rx_mgnt_pkts)
555
556 #define sta_rx_beacon_pkts(sta) \
557 (sta->sta_stats.rx_beacon_pkts)
558
559 #define sta_last_rx_beacon_pkts(sta) \
560 (sta->sta_stats.last_rx_beacon_pkts)
561
562 #define sta_rx_probereq_pkts(sta) \
563 (sta->sta_stats.rx_probereq_pkts)
564
565 #define sta_last_rx_probereq_pkts(sta) \
566 (sta->sta_stats.last_rx_probereq_pkts)
567
568 #define sta_rx_probersp_pkts(sta) \
569 (sta->sta_stats.rx_probersp_pkts)
570
571 #define sta_last_rx_probersp_pkts(sta) \
572 (sta->sta_stats.last_rx_probersp_pkts)
573
574 #define sta_rx_probersp_bm_pkts(sta) \
575 (sta->sta_stats.rx_probersp_bm_pkts)
576
577 #define sta_last_rx_probersp_bm_pkts(sta) \
578 (sta->sta_stats.last_rx_probersp_bm_pkts)
579
580 #define sta_rx_probersp_uo_pkts(sta) \
581 (sta->sta_stats.rx_probersp_uo_pkts)
582
583 #define sta_last_rx_probersp_uo_pkts(sta) \
584 (sta->sta_stats.last_rx_probersp_uo_pkts)
585
586 #ifdef CONFIG_RTW_MESH
587 #define update_last_rx_hwmp_pkts(sta) \
588 do { \
589 sta->sta_stats.last_rx_hwmp_pkts = sta->sta_stats.rx_hwmp_pkts; \
590 } while(0)
591 #else
592 #define update_last_rx_hwmp_pkts(sta) do {} while(0)
593 #endif
594
595 #define sta_update_last_rx_pkts(sta) \
596 do { \
597 int __i; \
598 \
599 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
600 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
601 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
602 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
603 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
604 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
605 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
606 update_last_rx_hwmp_pkts(sta); \
607 \
608 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
609 sta->sta_stats.last_rx_data_bc_pkts = sta->sta_stats.rx_data_bc_pkts; \
610 sta->sta_stats.last_rx_data_mc_pkts = sta->sta_stats.rx_data_mc_pkts; \
611 for (__i = 0; __i < TID_NUM; __i++) \
612 sta->sta_stats.last_rx_data_qos_pkts[__i] = sta->sta_stats.rx_data_qos_pkts[__i]; \
613 } while (0)
614
615 #define STA_RX_PKTS_ARG(sta) \
616 sta->sta_stats.rx_mgnt_pkts \
617 , sta->sta_stats.rx_ctrl_pkts \
618 , sta->sta_stats.rx_data_pkts
619
620 #define STA_LAST_RX_PKTS_ARG(sta) \
621 sta->sta_stats.last_rx_mgnt_pkts \
622 , sta->sta_stats.last_rx_ctrl_pkts \
623 , sta->sta_stats.last_rx_data_pkts
624
625 #define STA_RX_PKTS_DIFF_ARG(sta) \
626 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
627 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
628 , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
629
630 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
631
632 #define sta_rx_uc_bytes(sta) (sta->sta_stats.rx_bytes - sta->sta_stats.rx_bc_bytes - sta->sta_stats.rx_mc_bytes)
633 #define sta_last_rx_uc_bytes(sta) (sta->sta_stats.last_rx_bytes - sta->sta_stats.last_rx_bc_bytes - sta->sta_stats.last_rx_mc_bytes)
634
635 #ifdef CONFIG_WFD
636 #define STA_OP_WFD_MODE(sta) (sta)->op_wfd_mode
637 #define STA_SET_OP_WFD_MODE(sta, mode) (sta)->op_wfd_mode = (mode)
638 #else
639 #define STA_OP_WFD_MODE(sta) 0
640 #define STA_SET_OP_WFD_MODE(sta, mode) do {} while (0)
641 #endif
642
643 #define AID_BMP_LEN(max_aid) ((max_aid + 1) / 8 + (((max_aid + 1) % 8) ? 1 : 0))
644
645 struct sta_priv {
646
647 u8 *pallocated_stainfo_buf;
648 u8 *pstainfo_buf;
649 _queue free_sta_queue;
650
651 _lock sta_hash_lock;
652 _list sta_hash[NUM_STA];
653 int asoc_sta_count;
654 _queue sleep_q;
655 _queue wakeup_q;
656
657 _adapter *padapter;
658
659 u32 adhoc_expire_to;
660
661 int rx_chk_limit;
662
663 #ifdef CONFIG_AP_MODE
664 _list asoc_list;
665 _list auth_list;
666 _lock asoc_list_lock;
667 _lock auth_list_lock;
668 u8 asoc_list_cnt;
669 u8 auth_list_cnt;
670
671 unsigned int auth_to; /* sec, time to expire in authenticating. */
672 unsigned int assoc_to; /* sec, time to expire before associating. */
673 unsigned int expire_to; /* sec , time to expire after associated. */
674
675 /*
676 * pointers to STA info; based on allocated AID or NULL if AID free
677 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
678 */
679 struct sta_info **sta_aid;
680 u16 max_aid;
681 u16 started_aid; /* started AID for allocation search */
682 bool rr_aid; /* round robin AID allocation, will modify started_aid */
683 u8 aid_bmp_len; /* in byte */
684 u8 *sta_dz_bitmap;
685 u8 *tim_bitmap;
686
687 u16 max_num_sta;
688
689 #if CONFIG_RTW_MACADDR_ACL
690 struct wlan_acl_pool acl_list[RTW_ACL_PERIOD_NUM];
691 #endif
692
693 #if CONFIG_RTW_PRE_LINK_STA
694 struct pre_link_sta_ctl_t pre_link_sta_ctl;
695 #endif
696
697 #endif /* CONFIG_AP_MODE */
698
699 #ifdef CONFIG_ATMEL_RC_PATCH
700 u8 atmel_rc_pattern[6];
701 #endif
702 u8 c2h_sta_mac[ETH_ALEN];
703 u8 c2h_adapter_id;
704 struct submit_ctx *gotc2h;
705 };
706
707
wifi_mac_hash(const u8 * mac)708 __inline static u32 wifi_mac_hash(const u8 *mac)
709 {
710 u32 x;
711
712 x = mac[0];
713 x = (x << 2) ^ mac[1];
714 x = (x << 2) ^ mac[2];
715 x = (x << 2) ^ mac[3];
716 x = (x << 2) ^ mac[4];
717 x = (x << 2) ^ mac[5];
718
719 x ^= x >> 8;
720 x = x & (NUM_STA - 1);
721
722 return x;
723 }
724
725
726 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
727 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
728
729 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
730 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
731 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
732
733 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
734 extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
735 extern void rtw_free_all_stainfo(_adapter *padapter);
736 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
737 extern u32 rtw_init_bcmc_stainfo(_adapter *padapter);
738 extern struct sta_info *rtw_get_bcmc_stainfo(_adapter *padapter);
739
740 #ifdef CONFIG_AP_MODE
741 u16 rtw_aid_alloc(_adapter *adapter, struct sta_info *sta);
742 void dump_aid_status(void *sel, _adapter *adapter);
743 #endif
744
745 #if CONFIG_RTW_MACADDR_ACL
746 extern u8 rtw_access_ctrl(_adapter *adapter, const u8 *mac_addr);
747 void dump_macaddr_acl(void *sel, _adapter *adapter);
748 #endif
749
750 bool rtw_is_pre_link_sta(struct sta_priv *stapriv, u8 *addr);
751 #if CONFIG_RTW_PRE_LINK_STA
752 struct sta_info *rtw_pre_link_sta_add(struct sta_priv *stapriv, u8 *hwaddr);
753 void rtw_pre_link_sta_del(struct sta_priv *stapriv, u8 *hwaddr);
754 void rtw_pre_link_sta_ctl_reset(struct sta_priv *stapriv);
755 void rtw_pre_link_sta_ctl_init(struct sta_priv *stapriv);
756 void rtw_pre_link_sta_ctl_deinit(struct sta_priv *stapriv);
757 void dump_pre_link_sta_ctl(void *sel, struct sta_priv *stapriv);
758 #endif /* CONFIG_RTW_PRE_LINK_STA */
759
760 #endif /* _STA_INFO_H_ */
761