1 /******************************************************************************
2 *
3 * Copyright(c) 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 _PHL_STA_H_
16 #define _PHL_STA_H_
17
18 /*********** macid ctrl section ***********/
19 enum rtw_phl_status
20 phl_macid_ctrl_init(struct phl_info_t *phl);
21
22 enum rtw_phl_status
23 phl_macid_ctrl_deinit(struct phl_info_t *phl);
24
25 u16 rtw_phl_get_macid_max_num(void *phl);
26
27 u16 rtw_phl_wrole_bcmc_id_get(void *phl, struct rtw_wifi_role_t *wrole);
28
29 u8 rtw_phl_macid_is_bmc(void *phl, u16 macid);
30
31 u8 rtw_phl_macid_is_used(void *phl, u16 macid);
32
33 static inline bool
phl_macid_is_valid(struct phl_info_t * phl_info,u16 macid)34 phl_macid_is_valid(struct phl_info_t *phl_info, u16 macid)
35 {
36 return (macid < phl_info->macid_ctrl.max_num) ? true : false;
37 }
38 u16 rtw_phl_get_macid_by_addr(void *phl, u8 *addr);
39
40 /*********** stainfo_ctrl section ***********/
41 enum rtw_phl_status
42 phl_stainfo_ctrl_init(struct phl_info_t *phl_info);
43
44 enum rtw_phl_status
45 phl_stainfo_ctrl_deinie(struct phl_info_t *phl_info);
46
47 void phl_clean_sta_bcn_info(struct phl_info_t *phl, struct rtw_phl_stainfo_t *sta);
48
49 struct rtw_bcn_offset * phl_get_sta_bcn_offset_info(struct phl_info_t *phl,
50 struct rtw_wifi_role_t *wrole);
51
52 void phl_bcn_watchdog(struct phl_info_t *phl);
53
54 bool phl_calc_offset_from_tbtt(struct phl_info_t *phl,
55 struct rtw_wifi_role_t *wrole, u64 cur_t, u16 *ofst);
56
57 enum rtw_phl_status rtw_phl_tbtt_sync(struct phl_info_t *phl,
58 struct rtw_wifi_role_t *src_role,
59 struct rtw_wifi_role_t *tgt_role,
60 u16 sync_ofst, bool sync_now_once, u16 *diff_t);
61
62 #ifdef DBG_PHL_STAINFO
63 void phl_dump_stactrl(const char *caller,
64 const int line,
65 bool show_caller,
66 struct phl_info_t *phl_info);
67 #define PHL_DUMP_STACTRL(_phl_info) phl_dump_stactrl(__FUNCTION__, __LINE__, false, _phl_info);
68 #define PHL_DUMP_STACTRL_EX(_phl_info) phl_dump_stactrl(__FUNCTION__, __LINE__, true, _phl_info);
69
70 void phl_dump_stainfo_all(const char *caller,
71 const int line, bool show_caller,
72 struct phl_info_t *phl_info);
73 #define PHL_DUMP_STAINFO(_phl_info) phl_dump_stainfo_all(__FUNCTION__, __LINE__, false, _phl_info);
74 #define PHL_DUMP_STAINFO_EX(_phl_info) phl_dump_stainfo_all(__FUNCTION__, __LINE__, true, _phl_info);
75
76 void phl_dump_stainfo_per_role(const char *caller,
77 const int line,
78 bool show_caller,
79 struct phl_info_t *phl_info,
80 struct rtw_wifi_role_t *wrole);
81 #define PHL_DUMP_ROLE_STAINFO(_phl_info, wrole) phl_dump_stainfo_per_role(__FUNCTION__, __LINE__, false, _phl_info, wrole);
82 #define PHL_DUMP_ROLE_STAINFO_EX(_phl_info, wrole) phl_dump_stainfo_per_role(__FUNCTION__, __LINE__, true, _phl_info, wrole);
83 #else
84 #define PHL_DUMP_STACTRL(_phl_info)
85 #define PHL_DUMP_STACTRL_EX(_phl_info)
86
87 #define PHL_DUMP_STAINFO(_phl_info)
88 #define PHL_DUMP_STAINFO_EX(_phl_info)
89
90 #define PHL_DUMP_ROLE_STAINFO(_phl_info, wrole)
91 #define PHL_DUMP_ROLE_STAINFO_EX(_phl_info, wrole)
92 #endif
93 /*********** phl stainfo section ***********/
94 /*WIFI sta_info management section*/
95 struct rtw_phl_stainfo_t *
96 phl_alloc_stainfo_sw(struct phl_info_t *phl_info,
97 u8 *sta_addr,
98 struct rtw_wifi_role_t *wrole);
99
100 enum rtw_phl_status
101 phl_alloc_stainfo_hw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta);
102
103 enum rtw_phl_status
104 phl_free_stainfo_sw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta);
105
106 enum rtw_phl_status
107 phl_free_stainfo_hw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta);
108
109 enum rtw_phl_status
110 rtw_phl_cmd_alloc_stainfo(void *phl,
111 struct rtw_phl_stainfo_t **sta,
112 u8 *sta_addr,
113 struct rtw_wifi_role_t *wrole,
114 bool alloc, bool only_hw,
115 enum phl_cmd_type cmd_type,
116 u32 cmd_timeout);
117
118 enum rtw_phl_status
119 phl_wifi_role_free_stainfo_hw(struct phl_info_t *phl_info,
120 struct rtw_wifi_role_t *wrole);
121 enum rtw_phl_status
122 phl_wifi_role_free_stainfo_sw(struct phl_info_t *phl_info,
123 struct rtw_wifi_role_t *role);
124 enum rtw_phl_status
125 phl_wifi_role_free_stainfo(struct phl_info_t *phl_info,
126 struct rtw_wifi_role_t *role);
127
128 #ifdef CONFIG_CMD_DISP
129 enum rtw_phl_status
130 phl_update_media_status_hdl(struct phl_info_t *phl_info, u8 *param);
131 #endif
132
133 struct rtw_phl_stainfo_t *
134 rtw_phl_get_stainfo_by_macid(void *phl, u16 macid);
135
136 struct rtw_phl_stainfo_t *
137 rtw_phl_get_stainfo_by_addr(void *phl, struct rtw_wifi_role_t *wrole, u8 *addr);
138
139 struct rtw_phl_stainfo_t *
140 rtw_phl_get_stainfo_by_addr_ex(void *phl, u8 *addr);
141
142 struct rtw_phl_stainfo_t *
143 rtw_phl_get_stainfo_self(void *phl, struct rtw_wifi_role_t *wrole);
144
145 u8 phl_get_min_rssi_bcn(struct phl_info_t *phl_info);
146
147 #ifdef CONFIG_CMD_DISP
148 enum rtw_phl_status
149 phl_cmd_change_stainfo_hdl(struct phl_info_t *phl_info, u8 *param);
150 #endif
151
152 enum rtw_phl_status
153 phl_change_stainfo(struct phl_info_t *phl_info,
154 struct rtw_phl_stainfo_t *sta,
155 enum phl_upd_mode mode);
156 void
157 phl_sta_trx_tfc_upd(struct phl_info_t *phl_info);
158
159 #ifdef CONFIG_CMD_DISP
160 enum rtw_phl_status
161 phl_cmd_set_key_hdl(struct phl_info_t *phl_info, u8 *param);
162 enum rtw_phl_status
163 phl_cmd_alloc_stainfo_hdl(struct phl_info_t *phl_info, u8 *param);
164 #endif /* CONFIG_CMD_DISP */
165
166 bool phl_self_stainfo_chk(struct phl_info_t *phl_info,
167 struct rtw_wifi_role_t *wrole,
168 struct rtw_phl_stainfo_t *sta);
169
170 #endif /*_PHL_STA_H_*/
171