sta_info.h 19 KB

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