sta_info.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  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. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __STA_INFO_H_
  21. #define __STA_INFO_H_
  22. #define IBSS_START_MAC_ID 2
  23. #define NUM_STA MACID_NUM_SW_LIMIT
  24. #ifndef CONFIG_RTW_MACADDR_ACL
  25. #define CONFIG_RTW_MACADDR_ACL 1
  26. #endif
  27. #ifndef CONFIG_RTW_PRE_LINK_STA
  28. #define CONFIG_RTW_PRE_LINK_STA 0
  29. #endif
  30. #define NUM_ACL 16
  31. #define RTW_ACL_MODE_DISABLED 0
  32. #define RTW_ACL_MODE_ACCEPT_UNLESS_LISTED 1
  33. #define RTW_ACL_MODE_DENY_UNLESS_LISTED 2
  34. #define RTW_ACL_MODE_MAX 3
  35. #if CONFIG_RTW_MACADDR_ACL
  36. extern const char *const _acl_mode_str[];
  37. #define acl_mode_str(mode) (((mode) >= RTW_ACL_MODE_MAX) ? _acl_mode_str[RTW_ACL_MODE_DISABLED] : _acl_mode_str[(mode)])
  38. #endif
  39. #ifndef RTW_PRE_LINK_STA_NUM
  40. #define RTW_PRE_LINK_STA_NUM 8
  41. #endif
  42. struct pre_link_sta_node_t {
  43. u8 valid;
  44. u8 addr[ETH_ALEN];
  45. };
  46. struct pre_link_sta_ctl_t {
  47. _lock lock;
  48. u8 num;
  49. struct pre_link_sta_node_t node[RTW_PRE_LINK_STA_NUM];
  50. };
  51. #ifdef CONFIG_TDLS
  52. #define MAX_ALLOWED_TDLS_STA_NUM 4
  53. #endif
  54. enum sta_info_update_type {
  55. STA_INFO_UPDATE_NONE = 0,
  56. STA_INFO_UPDATE_BW = BIT(0),
  57. STA_INFO_UPDATE_RATE = BIT(1),
  58. STA_INFO_UPDATE_PROTECTION_MODE = BIT(2),
  59. STA_INFO_UPDATE_CAP = BIT(3),
  60. STA_INFO_UPDATE_HT_CAP = BIT(4),
  61. STA_INFO_UPDATE_VHT_CAP = BIT(5),
  62. STA_INFO_UPDATE_ALL = STA_INFO_UPDATE_BW
  63. | STA_INFO_UPDATE_RATE
  64. | STA_INFO_UPDATE_PROTECTION_MODE
  65. | STA_INFO_UPDATE_CAP
  66. | STA_INFO_UPDATE_HT_CAP
  67. | STA_INFO_UPDATE_VHT_CAP,
  68. STA_INFO_UPDATE_MAX
  69. };
  70. struct rtw_wlan_acl_node {
  71. _list list;
  72. u8 addr[ETH_ALEN];
  73. u8 valid;
  74. };
  75. struct wlan_acl_pool {
  76. int mode;
  77. int num;
  78. struct rtw_wlan_acl_node aclnode[NUM_ACL];
  79. _queue acl_node_q;
  80. };
  81. typedef struct _RSSI_STA {
  82. s32 undecorated_smoothed_pwdb;
  83. s32 undecorated_smoothed_cck;
  84. s32 undecorated_smoothed_ofdm;
  85. u8 ofdm_pkt;
  86. u8 cck_pkt;
  87. u16 cck_sum_power;
  88. u8 is_send_rssi;
  89. u64 packet_map;
  90. u8 valid_bit;
  91. } RSSI_STA, *PRSSI_STA;
  92. struct stainfo_stats {
  93. u64 rx_mgnt_pkts;
  94. u64 rx_beacon_pkts;
  95. u64 rx_probereq_pkts;
  96. u64 rx_probersp_pkts;
  97. u64 rx_probersp_bm_pkts;
  98. u64 rx_probersp_uo_pkts;
  99. u64 rx_ctrl_pkts;
  100. u64 rx_data_pkts;
  101. u64 rx_data_last_pkts; /* For Read & Clear requirement in proc_get_rx_stat() */
  102. u64 rx_data_qos_pkts[TID_NUM];
  103. u64 last_rx_mgnt_pkts;
  104. u64 last_rx_beacon_pkts;
  105. u64 last_rx_probereq_pkts;
  106. u64 last_rx_probersp_pkts;
  107. u64 last_rx_probersp_bm_pkts;
  108. u64 last_rx_probersp_uo_pkts;
  109. u64 last_rx_ctrl_pkts;
  110. u64 last_rx_data_pkts;
  111. u64 last_rx_data_qos_pkts[TID_NUM];
  112. #ifdef CONFIG_TDLS
  113. u64 rx_tdls_disc_rsp_pkts;
  114. u64 last_rx_tdls_disc_rsp_pkts;
  115. #endif
  116. u64 rx_bytes;
  117. u64 rx_drops;
  118. u64 tx_pkts;
  119. u64 tx_bytes;
  120. u64 tx_drops;
  121. u32 duplicate_cnt; /* Read & Clear, in proc_get_rx_stat() */
  122. u32 rxratecnt[128]; /* Read & Clear, in proc_get_rx_stat() */
  123. u32 tx_ok_cnt; /* Read & Clear, in proc_get_tx_stat() */
  124. u32 tx_fail_cnt; /* Read & Clear, in proc_get_tx_stat() */
  125. u32 tx_retry_cnt; /* Read & Clear, in proc_get_tx_stat() */
  126. };
  127. #ifndef DBG_SESSION_TRACKER
  128. #define DBG_SESSION_TRACKER 0
  129. #endif
  130. /* session tracker status */
  131. #define ST_STATUS_NONE 0
  132. #define ST_STATUS_CHECK BIT0
  133. #define ST_STATUS_ESTABLISH BIT1
  134. #define ST_STATUS_EXPIRE BIT2
  135. #define ST_EXPIRE_MS (10 * 1000)
  136. struct session_tracker {
  137. _list list; /* session_tracker_queue */
  138. u32 local_naddr;
  139. u16 local_port;
  140. u32 remote_naddr;
  141. u16 remote_port;
  142. u32 set_time;
  143. u8 status;
  144. };
  145. /* session tracker cmd */
  146. #define ST_CMD_ADD 0
  147. #define ST_CMD_DEL 1
  148. #define ST_CMD_CHK 2
  149. struct st_cmd_parm {
  150. u8 cmd;
  151. struct sta_info *sta;
  152. u32 local_naddr; /* TODO: IPV6 */
  153. u16 local_port;
  154. u32 remote_naddr; /* TODO: IPV6 */
  155. u16 remote_port;
  156. };
  157. typedef bool (*st_match_rule)(_adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
  158. struct st_register {
  159. u8 s_proto;
  160. st_match_rule rule;
  161. };
  162. #define SESSION_TRACKER_REG_ID_WFD 0
  163. #define SESSION_TRACKER_REG_ID_NUM 1
  164. struct st_ctl_t {
  165. struct st_register reg[SESSION_TRACKER_REG_ID_NUM];
  166. _queue tracker_q;
  167. };
  168. void rtw_st_ctl_init(struct st_ctl_t *st_ctl);
  169. void rtw_st_ctl_deinit(struct st_ctl_t *st_ctl);
  170. void rtw_st_ctl_register(struct st_ctl_t *st_ctl, u8 st_reg_id, struct st_register *reg);
  171. void rtw_st_ctl_unregister(struct st_ctl_t *st_ctl, u8 st_reg_id);
  172. bool rtw_st_ctl_chk_reg_s_proto(struct st_ctl_t *st_ctl, u8 s_proto);
  173. 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);
  174. void dump_st_ctl(void *sel, struct st_ctl_t *st_ctl);
  175. #ifdef CONFIG_TDLS
  176. struct TDLS_PeerKey {
  177. u8 kck[16]; /* TPK-KCK */
  178. u8 tk[16]; /* TPK-TK; only CCMP will be used */
  179. } ;
  180. #endif /* CONFIG_TDLS */
  181. #ifdef DBG_RX_DFRAME_RAW_DATA
  182. struct sta_recv_dframe_info {
  183. u8 sta_data_rate;
  184. u8 sta_sgi;
  185. u8 sta_bw_mode;
  186. s8 sta_mimo_signal_strength[4];
  187. s8 sta_RxPwr[4];
  188. u8 sta_ofdm_snr[4];
  189. };
  190. #endif
  191. struct sta_info {
  192. _lock lock;
  193. _list list; /* free_sta_queue */
  194. _list hash_list; /* sta_hash */
  195. /* _list asoc_list; */ /* 20061114 */
  196. /* _list sleep_list; */ /* sleep_q */
  197. /* _list wakeup_list; */ /* wakeup_q */
  198. _adapter *padapter;
  199. struct sta_xmit_priv sta_xmitpriv;
  200. struct sta_recv_priv sta_recvpriv;
  201. #ifdef DBG_RX_DFRAME_RAW_DATA
  202. struct sta_recv_dframe_info sta_dframe_info;
  203. #endif
  204. _queue sleep_q;
  205. unsigned int sleepq_len;
  206. uint state;
  207. uint aid;
  208. uint mac_id;
  209. uint qos_option;
  210. u8 hwaddr[ETH_ALEN];
  211. u16 hwseq;
  212. u8 ra_rpt_linked;
  213. uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
  214. uint dot118021XPrivacy; /* aes, tkip... */
  215. union Keytype dot11tkiptxmickey;
  216. union Keytype dot11tkiprxmickey;
  217. union Keytype dot118021x_UncstKey;
  218. union pn48 dot11txpn; /* PN48 used for Unicast xmit */
  219. #ifdef CONFIG_GTK_OL
  220. u8 kek[RTW_KEK_LEN];
  221. u8 kck[RTW_KCK_LEN];
  222. u8 replay_ctr[RTW_REPLAY_CTR_LEN];
  223. #endif /* CONFIG_GTK_OL */
  224. #ifdef CONFIG_IEEE80211W
  225. union pn48 dot11wtxpn; /* PN48 used for Unicast mgmt xmit. */
  226. _timer dot11w_expire_timer;
  227. #endif /* CONFIG_IEEE80211W */
  228. union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
  229. u8 bssrateset[16];
  230. u32 bssratelen;
  231. s32 rssi;
  232. s32 signal_quality;
  233. u8 cts2self;
  234. u8 rtsen;
  235. u8 raid;
  236. u8 init_rate;
  237. u64 ra_mask;
  238. u8 wireless_mode; /* NETWORK_TYPE */
  239. u8 bw_mode;
  240. u8 ldpc;
  241. u8 stbc;
  242. #ifdef CONFIG_BEAMFORMING
  243. u16 txbf_paid;
  244. u16 txbf_gid;
  245. #endif
  246. struct stainfo_stats sta_stats;
  247. #ifdef CONFIG_TDLS
  248. u32 tdls_sta_state;
  249. u8 SNonce[32];
  250. u8 ANonce[32];
  251. u32 TDLS_PeerKey_Lifetime;
  252. u32 TPK_count;
  253. _timer TPK_timer;
  254. struct TDLS_PeerKey tpk;
  255. #ifdef CONFIG_TDLS_CH_SW
  256. u16 ch_switch_time;
  257. u16 ch_switch_timeout;
  258. /* u8 option; */
  259. _timer ch_sw_timer;
  260. _timer delay_timer;
  261. _timer stay_on_base_chnl_timer;
  262. _timer ch_sw_monitor_timer;
  263. #endif
  264. _timer handshake_timer;
  265. u8 alive_count;
  266. _timer pti_timer;
  267. u8 TDLS_RSNIE[20]; /* Save peer's RSNIE, used for sending TDLS_SETUP_RSP */
  268. #endif /* CONFIG_TDLS */
  269. /* for A-MPDU TX, ADDBA timeout check */
  270. _timer addba_retry_timer;
  271. /* for A-MPDU Rx reordering buffer control */
  272. struct recv_reorder_ctrl recvreorder_ctrl[TID_NUM];
  273. ATOMIC_T continual_no_rx_packet[TID_NUM];
  274. /* for A-MPDU Tx */
  275. /* unsigned char ampdu_txen_bitmap; */
  276. u16 BA_starting_seqctrl[16];
  277. #ifdef CONFIG_80211N_HT
  278. struct ht_priv htpriv;
  279. #endif
  280. #ifdef CONFIG_80211AC_VHT
  281. struct vht_priv vhtpriv;
  282. #endif
  283. /* Notes: */
  284. /* STA_Mode: */
  285. /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
  286. /* scan_q: AP CAP/INFO */
  287. /* AP_Mode: */
  288. /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
  289. /* sta_info: (AP & STA) CAP/INFO */
  290. unsigned int expire_to;
  291. #ifdef CONFIG_AP_MODE
  292. _list asoc_list;
  293. _list auth_list;
  294. unsigned int auth_seq;
  295. unsigned int authalg;
  296. unsigned char chg_txt[128];
  297. u16 capability;
  298. int flags;
  299. int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
  300. int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
  301. int wpa_group_cipher;
  302. int wpa2_group_cipher;
  303. int wpa_pairwise_cipher;
  304. int wpa2_pairwise_cipher;
  305. u8 bpairwise_key_installed;
  306. #ifdef CONFIG_RTW_80211R
  307. u8 ft_pairwise_key_installed;
  308. #endif
  309. #ifdef CONFIG_NATIVEAP_MLME
  310. u8 wpa_ie[32];
  311. u8 nonerp_set;
  312. u8 no_short_slot_time_set;
  313. u8 no_short_preamble_set;
  314. u8 no_ht_gf_set;
  315. u8 no_ht_set;
  316. u8 ht_20mhz_set;
  317. u8 ht_40mhz_intolerant;
  318. #endif /* CONFIG_NATIVEAP_MLME */
  319. #ifdef CONFIG_ATMEL_RC_PATCH
  320. u8 flag_atmel_rc;
  321. #endif
  322. u8 qos_info;
  323. u8 max_sp_len;
  324. u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
  325. u8 uapsd_be;
  326. u8 uapsd_vi;
  327. u8 uapsd_vo;
  328. u8 has_legacy_ac;
  329. unsigned int sleepq_ac_len;
  330. #ifdef CONFIG_P2P
  331. /* p2p priv data */
  332. u8 is_p2p_device;
  333. u8 p2p_status_code;
  334. /* p2p client info */
  335. u8 dev_addr[ETH_ALEN];
  336. /* u8 iface_addr[ETH_ALEN]; */ /* = hwaddr[ETH_ALEN] */
  337. u8 dev_cap;
  338. u16 config_methods;
  339. u8 primary_dev_type[8];
  340. u8 num_of_secdev_type;
  341. u8 secdev_types_list[32];/* 32/8 == 4; */
  342. u16 dev_name_len;
  343. u8 dev_name[32];
  344. #endif /* CONFIG_P2P */
  345. #ifdef CONFIG_WFD
  346. u8 op_wfd_mode;
  347. #endif
  348. #ifdef CONFIG_TX_MCAST2UNI
  349. u8 under_exist_checking;
  350. #endif /* CONFIG_TX_MCAST2UNI */
  351. u8 keep_alive_trycnt;
  352. #ifdef CONFIG_AUTO_AP_MODE
  353. u8 isrc; /* this device is rc */
  354. u16 pid; /* pairing id */
  355. #endif
  356. #endif /* CONFIG_AP_MODE */
  357. #ifdef CONFIG_IOCTL_CFG80211
  358. u8 *passoc_req;
  359. u32 assoc_req_len;
  360. #endif
  361. /* for DM */
  362. RSSI_STA rssi_stat;
  363. /* ODM_STA_INFO_T */
  364. /* ================ODM Relative Info======================= */
  365. /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
  366. /* */
  367. /* */
  368. /* 2011/10/20 MH Add for ODM STA info. */
  369. /* */
  370. /* Driver Write */
  371. u8 bValid; /* record the sta status link or not? */
  372. /* u8 WirelessMode; */ /* */
  373. u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
  374. /* ODM Write */
  375. /* 1 PHY_STATUS_INFO */
  376. u8 RSSI_Path[4]; /* */
  377. u8 RSSI_Ave;
  378. u8 RXEVM[4];
  379. u8 RXSNR[4];
  380. u8 rssi_level; /* for Refresh RA mask */
  381. #ifdef CONFIG_LPS_PG
  382. u8 lps_pg_rssi_lv;
  383. #endif
  384. /* ODM Write */
  385. /* 1 TX_INFO (may changed by IC) */
  386. /* TX_INFO_T pTxInfo; */ /* Define in IC folder. Move lower layer. */
  387. /* */
  388. /* ================ODM Relative Info======================= */
  389. /* */
  390. /* To store the sequence number of received management frame */
  391. u16 RxMgmtFrameSeqNum;
  392. struct st_ctl_t st_ctl;
  393. u8 max_agg_num_minimal_record; /*keep minimal tx desc max_agg_num setting*/
  394. };
  395. #define sta_rx_pkts(sta) \
  396. (sta->sta_stats.rx_mgnt_pkts \
  397. + sta->sta_stats.rx_ctrl_pkts \
  398. + sta->sta_stats.rx_data_pkts)
  399. #define sta_last_rx_pkts(sta) \
  400. (sta->sta_stats.last_rx_mgnt_pkts \
  401. + sta->sta_stats.last_rx_ctrl_pkts \
  402. + sta->sta_stats.last_rx_data_pkts)
  403. #define sta_rx_data_pkts(sta) \
  404. (sta->sta_stats.rx_data_pkts)
  405. #define sta_rx_data_qos_pkts(sta, i) \
  406. (sta->sta_stats.rx_data_qos_pkts[i])
  407. #define sta_last_rx_data_pkts(sta) \
  408. (sta->sta_stats.last_rx_data_pkts)
  409. #define sta_last_rx_data_qos_pkts(sta, i) \
  410. (sta->sta_stats.last_rx_data_qos_pkts[i])
  411. #define sta_rx_mgnt_pkts(sta) \
  412. (sta->sta_stats.rx_mgnt_pkts)
  413. #define sta_last_rx_mgnt_pkts(sta) \
  414. (sta->sta_stats.last_rx_mgnt_pkts)
  415. #define sta_rx_beacon_pkts(sta) \
  416. (sta->sta_stats.rx_beacon_pkts)
  417. #define sta_last_rx_beacon_pkts(sta) \
  418. (sta->sta_stats.last_rx_beacon_pkts)
  419. #define sta_rx_probereq_pkts(sta) \
  420. (sta->sta_stats.rx_probereq_pkts)
  421. #define sta_last_rx_probereq_pkts(sta) \
  422. (sta->sta_stats.last_rx_probereq_pkts)
  423. #define sta_rx_probersp_pkts(sta) \
  424. (sta->sta_stats.rx_probersp_pkts)
  425. #define sta_last_rx_probersp_pkts(sta) \
  426. (sta->sta_stats.last_rx_probersp_pkts)
  427. #define sta_rx_probersp_bm_pkts(sta) \
  428. (sta->sta_stats.rx_probersp_bm_pkts)
  429. #define sta_last_rx_probersp_bm_pkts(sta) \
  430. (sta->sta_stats.last_rx_probersp_bm_pkts)
  431. #define sta_rx_probersp_uo_pkts(sta) \
  432. (sta->sta_stats.rx_probersp_uo_pkts)
  433. #define sta_last_rx_probersp_uo_pkts(sta) \
  434. (sta->sta_stats.last_rx_probersp_uo_pkts)
  435. #define sta_update_last_rx_pkts(sta) \
  436. do { \
  437. sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
  438. sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
  439. sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
  440. sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
  441. sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
  442. sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
  443. sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
  444. sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
  445. } while (0)
  446. #define STA_RX_PKTS_ARG(sta) \
  447. sta->sta_stats.rx_mgnt_pkts \
  448. , sta->sta_stats.rx_ctrl_pkts \
  449. , sta->sta_stats.rx_data_pkts
  450. #define STA_LAST_RX_PKTS_ARG(sta) \
  451. sta->sta_stats.last_rx_mgnt_pkts \
  452. , sta->sta_stats.last_rx_ctrl_pkts \
  453. , sta->sta_stats.last_rx_data_pkts
  454. #define STA_RX_PKTS_DIFF_ARG(sta) \
  455. sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
  456. , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
  457. , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
  458. #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
  459. #ifdef CONFIG_WFD
  460. #define STA_OP_WFD_MODE(sta) (sta)->op_wfd_mode
  461. #define STA_SET_OP_WFD_MODE(sta, mode) (sta)->op_wfd_mode = (mode)
  462. #else
  463. #define STA_OP_WFD_MODE(sta) 0
  464. #define STA_SET_OP_WFD_MODE(sta, mode) do {} while (0)
  465. #endif
  466. struct sta_priv {
  467. u8 *pallocated_stainfo_buf;
  468. u8 *pstainfo_buf;
  469. _queue free_sta_queue;
  470. _lock sta_hash_lock;
  471. _list sta_hash[NUM_STA];
  472. int asoc_sta_count;
  473. _queue sleep_q;
  474. _queue wakeup_q;
  475. _adapter *padapter;
  476. u32 adhoc_expire_to;
  477. #ifdef CONFIG_AP_MODE
  478. _list asoc_list;
  479. _list auth_list;
  480. _lock asoc_list_lock;
  481. _lock auth_list_lock;
  482. u8 asoc_list_cnt;
  483. u8 auth_list_cnt;
  484. unsigned int auth_to; /* sec, time to expire in authenticating. */
  485. unsigned int assoc_to; /* sec, time to expire before associating. */
  486. unsigned int expire_to; /* sec , time to expire after associated. */
  487. /* pointers to STA info; based on allocated AID or NULL if AID free
  488. * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
  489. * and so on
  490. */
  491. struct sta_info *sta_aid[NUM_STA];
  492. u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
  493. u16 tim_bitmap;/* only support 15 stations, aid=0~15 mapping bit0~bit15 */
  494. u16 max_num_sta;
  495. #if CONFIG_RTW_MACADDR_ACL
  496. struct wlan_acl_pool acl_list;
  497. #endif
  498. #if CONFIG_RTW_PRE_LINK_STA
  499. struct pre_link_sta_ctl_t pre_link_sta_ctl;
  500. #endif
  501. #endif /* CONFIG_AP_MODE */
  502. #ifdef CONFIG_ATMEL_RC_PATCH
  503. u8 atmel_rc_pattern[6];
  504. #endif
  505. struct sta_info *c2h_sta;
  506. struct submit_ctx *gotc2h;
  507. };
  508. __inline static u32 wifi_mac_hash(u8 *mac)
  509. {
  510. u32 x;
  511. x = mac[0];
  512. x = (x << 2) ^ mac[1];
  513. x = (x << 2) ^ mac[2];
  514. x = (x << 2) ^ mac[3];
  515. x = (x << 2) ^ mac[4];
  516. x = (x << 2) ^ mac[5];
  517. x ^= x >> 8;
  518. x = x & (NUM_STA - 1);
  519. return x;
  520. }
  521. extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
  522. extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
  523. #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
  524. int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
  525. struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
  526. extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
  527. extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
  528. extern void rtw_free_all_stainfo(_adapter *padapter);
  529. extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
  530. extern u32 rtw_init_bcmc_stainfo(_adapter *padapter);
  531. extern struct sta_info *rtw_get_bcmc_stainfo(_adapter *padapter);
  532. #if CONFIG_RTW_MACADDR_ACL
  533. extern u8 rtw_access_ctrl(_adapter *adapter, u8 *mac_addr);
  534. void dump_macaddr_acl(void *sel, _adapter *adapter);
  535. #endif
  536. bool rtw_is_pre_link_sta(struct sta_priv *stapriv, u8 *addr);
  537. #if CONFIG_RTW_PRE_LINK_STA
  538. struct sta_info *rtw_pre_link_sta_add(struct sta_priv *stapriv, u8 *hwaddr);
  539. void rtw_pre_link_sta_del(struct sta_priv *stapriv, u8 *hwaddr);
  540. void rtw_pre_link_sta_ctl_reset(struct sta_priv *stapriv);
  541. void rtw_pre_link_sta_ctl_init(struct sta_priv *stapriv);
  542. void rtw_pre_link_sta_ctl_deinit(struct sta_priv *stapriv);
  543. void dump_pre_link_sta_ctl(void *sel, struct sta_priv *stapriv);
  544. #endif /* CONFIG_RTW_PRE_LINK_STA */
  545. #endif /* _STA_INFO_H_ */