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