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