1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun *
3*4882a593Smuzhiyun * Copyright(c) 2019 Realtek Corporation.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or modify it
6*4882a593Smuzhiyun * under the terms of version 2 of the GNU General Public License as
7*4882a593Smuzhiyun * published by the Free Software Foundation.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, but WITHOUT
10*4882a593Smuzhiyun * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12*4882a593Smuzhiyun * more details.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun *****************************************************************************/
15*4882a593Smuzhiyun #define _PHL_STA_C_
16*4882a593Smuzhiyun #include "phl_headers.h"
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun /*********** macid ctrl section ***********/
19*4882a593Smuzhiyun enum rtw_phl_status
phl_macid_ctrl_init(struct phl_info_t * phl)20*4882a593Smuzhiyun phl_macid_ctrl_init(struct phl_info_t *phl)
21*4882a593Smuzhiyun {
22*4882a593Smuzhiyun struct rtw_phl_com_t *phl_com = phl->phl_com;
23*4882a593Smuzhiyun struct hal_spec_t *hal_spec = phl_get_ic_spec(phl_com);
24*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl);
25*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
26*4882a593Smuzhiyun u8 i = 0;
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /* check invalid value or not */
29*4882a593Smuzhiyun if (hal_spec->macid_num == 0) {
30*4882a593Smuzhiyun PHL_ERR("Cannot get macid_num of hal\n");
31*4882a593Smuzhiyun goto exit;
32*4882a593Smuzhiyun }
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun _os_spinlock_init(phl_to_drvpriv(phl), &macid_ctl->lock);
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun macid_ctl->max_num = MIN(hal_spec->macid_num, PHL_MACID_MAX_NUM);
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun PHL_INFO("%s macid max_num:%d\n", __func__, macid_ctl->max_num);
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun for (i = 0; i < MAX_WIFI_ROLE_NUMBER; i++)
41*4882a593Smuzhiyun macid_ctl->wrole_bmc[i] = macid_ctl->max_num;
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun phl_status = RTW_PHL_STATUS_SUCCESS;
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun exit:
46*4882a593Smuzhiyun return phl_status;
47*4882a593Smuzhiyun }
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun enum rtw_phl_status
phl_macid_ctrl_deinit(struct phl_info_t * phl)50*4882a593Smuzhiyun phl_macid_ctrl_deinit(struct phl_info_t *phl)
51*4882a593Smuzhiyun {
52*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl);
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun _os_spinlock_free(phl_to_drvpriv(phl), &macid_ctl->lock);
55*4882a593Smuzhiyun macid_ctl->max_num = 0;
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun static u8
_phl_macid_is_used(u32 * map,const u16 id)62*4882a593Smuzhiyun _phl_macid_is_used(u32 *map, const u16 id)
63*4882a593Smuzhiyun {
64*4882a593Smuzhiyun int map_idx = (int)id / 32;
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun if (map[map_idx] & BIT(id % 32))
67*4882a593Smuzhiyun return true;
68*4882a593Smuzhiyun else
69*4882a593Smuzhiyun return false;
70*4882a593Smuzhiyun }
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun static void
_phl_macid_map_set(u32 * map,const u16 id)73*4882a593Smuzhiyun _phl_macid_map_set(u32 *map, const u16 id)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun int map_idx = (int)id / 32;
76*4882a593Smuzhiyun map[map_idx] |= BIT(id % 32);
77*4882a593Smuzhiyun }
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun static void
_phl_macid_map_clr(u32 * map,const u16 id)80*4882a593Smuzhiyun _phl_macid_map_clr(u32 *map, const u16 id)
81*4882a593Smuzhiyun {
82*4882a593Smuzhiyun int map_idx = (int)id / 32;
83*4882a593Smuzhiyun map[map_idx] &= ~BIT(id % 32);
84*4882a593Smuzhiyun }
85*4882a593Smuzhiyun
_phl_wrole_bcmc_id_set(struct macid_ctl_t * macid_ctl,struct rtw_wifi_role_t * wrole,const u16 id)86*4882a593Smuzhiyun static void _phl_wrole_bcmc_id_set(struct macid_ctl_t *macid_ctl,
87*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole, const u16 id)
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun macid_ctl->wrole_bmc[wrole->id] = id;
90*4882a593Smuzhiyun }
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun static enum rtw_phl_status
_phl_alloc_macid(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * phl_sta)93*4882a593Smuzhiyun _phl_alloc_macid(struct phl_info_t *phl_info,
94*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun struct macid_ctl_t *mc = phl_to_mac_ctrl(phl_info);
97*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = phl_sta->wrole;
98*4882a593Smuzhiyun u8 bc_addr[MAC_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
99*4882a593Smuzhiyun u16 mid = 0;
100*4882a593Smuzhiyun u16 max_macid_num = 0;
101*4882a593Smuzhiyun bool bmc_sta = false;
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun if (wrole == NULL) {
104*4882a593Smuzhiyun PHL_ERR("%s wrole=NULL!\n", __func__);
105*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
106*4882a593Smuzhiyun }
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun if (_os_mem_cmp(phl_to_drvpriv(phl_info),
109*4882a593Smuzhiyun bc_addr, phl_sta->mac_addr, MAC_ALEN) == 0)
110*4882a593Smuzhiyun bmc_sta = true;
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun /* TODO
113*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION)
114*4882a593Smuzhiyun else if (wrole->type == PHL_RTYPE_AP)*/
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun /*TODO - struct mac_ax_hw_info-> u16 macid_num; need to check */
117*4882a593Smuzhiyun max_macid_num = mc->max_num;
118*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &mc->lock, _bh, NULL);
119*4882a593Smuzhiyun for(mid = 0; mid < max_macid_num; mid++) {
120*4882a593Smuzhiyun if (!_phl_macid_is_used(mc->used_map, mid)) {
121*4882a593Smuzhiyun _phl_macid_map_set(mc->used_map, mid);
122*4882a593Smuzhiyun _phl_macid_map_set(&mc->wifi_role_usedmap[wrole->id][0], mid);
123*4882a593Smuzhiyun mc->sta[mid] = phl_sta;
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun if (bmc_sta) {
126*4882a593Smuzhiyun _phl_macid_map_set(mc->bmc_map, mid);
127*4882a593Smuzhiyun _phl_wrole_bcmc_id_set(mc, wrole, mid);
128*4882a593Smuzhiyun }
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun break;
131*4882a593Smuzhiyun }
132*4882a593Smuzhiyun }
133*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &mc->lock, _bh, NULL);
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun if (mid == max_macid_num) {
136*4882a593Smuzhiyun phl_sta->macid = max_macid_num;
137*4882a593Smuzhiyun PHL_ERR("%s cannot get macid\n", __func__);
138*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
139*4882a593Smuzhiyun }
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun phl_sta->macid = mid;
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun PHL_INFO("%s allocate %02x:%02x:%02x:%02x:%02x:%02x for macid:%u\n", __func__,
144*4882a593Smuzhiyun phl_sta->mac_addr[0], phl_sta->mac_addr[1], phl_sta->mac_addr[2],
145*4882a593Smuzhiyun phl_sta->mac_addr[3], phl_sta->mac_addr[4], phl_sta->mac_addr[5],
146*4882a593Smuzhiyun phl_sta->macid);
147*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
148*4882a593Smuzhiyun }
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun static enum rtw_phl_status
_phl_release_macid(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * phl_sta)151*4882a593Smuzhiyun _phl_release_macid(struct phl_info_t *phl_info,
152*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta)
153*4882a593Smuzhiyun {
154*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
155*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
156*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = phl_sta->wrole;
157*4882a593Smuzhiyun u8 bc_addr[MAC_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
158*4882a593Smuzhiyun u16 invalid_macid = macid_ctl->max_num;
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun if (phl_sta->macid >= invalid_macid) {
161*4882a593Smuzhiyun PHL_ERR("_phl_release_macid macid error (%d\n)", phl_sta->macid);
162*4882a593Smuzhiyun phl_status = RTW_PHL_STATUS_FAILURE;
163*4882a593Smuzhiyun goto exit;
164*4882a593Smuzhiyun }
165*4882a593Smuzhiyun
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun if (!_phl_macid_is_used(macid_ctl->used_map, phl_sta->macid)) {
170*4882a593Smuzhiyun PHL_WARN("_phl_release_macid macid unused (%d\n)", phl_sta->macid);
171*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
172*4882a593Smuzhiyun phl_status = RTW_PHL_STATUS_FAILURE;
173*4882a593Smuzhiyun goto exit;
174*4882a593Smuzhiyun }
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun _phl_macid_map_clr(macid_ctl->used_map, phl_sta->macid);
178*4882a593Smuzhiyun _phl_macid_map_clr(&macid_ctl->wifi_role_usedmap[wrole->id][0], phl_sta->macid);
179*4882a593Smuzhiyun macid_ctl->sta[phl_sta->macid] = NULL;
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun if (_os_mem_cmp(phl_to_drvpriv(phl_info),
182*4882a593Smuzhiyun bc_addr, phl_sta->mac_addr, MAC_ALEN) == 0)
183*4882a593Smuzhiyun _phl_macid_map_clr(macid_ctl->bmc_map, phl_sta->macid);
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun phl_status = RTW_PHL_STATUS_SUCCESS;
186*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun exit:
189*4882a593Smuzhiyun PHL_INFO("%s release macid:%d - %02x:%02x:%02x:%02x:%02x:%02x \n",
190*4882a593Smuzhiyun __func__,
191*4882a593Smuzhiyun phl_sta->macid,
192*4882a593Smuzhiyun phl_sta->mac_addr[0], phl_sta->mac_addr[1], phl_sta->mac_addr[2],
193*4882a593Smuzhiyun phl_sta->mac_addr[3], phl_sta->mac_addr[4], phl_sta->mac_addr[5]);
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun phl_sta->macid = invalid_macid;
196*4882a593Smuzhiyun return phl_status;
197*4882a593Smuzhiyun }
198*4882a593Smuzhiyun
_phl_get_macid(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * phl_sta)199*4882a593Smuzhiyun u16 _phl_get_macid(struct phl_info_t *phl_info,
200*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta)
201*4882a593Smuzhiyun {
202*4882a593Smuzhiyun /* TODO: macid management */
203*4882a593Smuzhiyun return phl_sta->macid;
204*4882a593Smuzhiyun }
205*4882a593Smuzhiyun
206*4882a593Smuzhiyun /**
207*4882a593Smuzhiyun * This function export to core layer use
208*4882a593Smuzhiyun * to get phl role bmc macid
209*4882a593Smuzhiyun * @phl: see phl_info_t
210*4882a593Smuzhiyun * @wrole: wifi role
211*4882a593Smuzhiyun */
212*4882a593Smuzhiyun u16
rtw_phl_wrole_bcmc_id_get(void * phl,struct rtw_wifi_role_t * wrole)213*4882a593Smuzhiyun rtw_phl_wrole_bcmc_id_get(void *phl, struct rtw_wifi_role_t *wrole)
214*4882a593Smuzhiyun {
215*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
216*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun return macid_ctl->wrole_bmc[wrole->id];
219*4882a593Smuzhiyun }
220*4882a593Smuzhiyun
221*4882a593Smuzhiyun /**
222*4882a593Smuzhiyun * This function export to core layer use
223*4882a593Smuzhiyun * to get maximum macid number
224*4882a593Smuzhiyun * @phl: see phl_info_t
225*4882a593Smuzhiyun */
226*4882a593Smuzhiyun u16
rtw_phl_get_macid_max_num(void * phl)227*4882a593Smuzhiyun rtw_phl_get_macid_max_num(void *phl)
228*4882a593Smuzhiyun {
229*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
230*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun return macid_ctl->max_num;
233*4882a593Smuzhiyun }
234*4882a593Smuzhiyun
235*4882a593Smuzhiyun /**
236*4882a593Smuzhiyun * This function export to core layer use
237*4882a593Smuzhiyun * to check macid is bmc or not
238*4882a593Smuzhiyun * @phl: see phl_info_t
239*4882a593Smuzhiyun * @macid: macid
240*4882a593Smuzhiyun */
241*4882a593Smuzhiyun u8
rtw_phl_macid_is_bmc(void * phl,u16 macid)242*4882a593Smuzhiyun rtw_phl_macid_is_bmc(void *phl, u16 macid)
243*4882a593Smuzhiyun {
244*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
245*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun if (macid >= macid_ctl->max_num) {
248*4882a593Smuzhiyun PHL_ERR("%s macid(%d) is invalid\n", __func__, macid);
249*4882a593Smuzhiyun return true;
250*4882a593Smuzhiyun }
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun return _phl_macid_is_used(macid_ctl->bmc_map, macid);
253*4882a593Smuzhiyun }
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun /**
257*4882a593Smuzhiyun * This function export to core layer use
258*4882a593Smuzhiyun * to check macid is used or not
259*4882a593Smuzhiyun * @phl: see phl_info_t
260*4882a593Smuzhiyun * @macid: macid
261*4882a593Smuzhiyun */
262*4882a593Smuzhiyun u8
rtw_phl_macid_is_used(void * phl,u16 macid)263*4882a593Smuzhiyun rtw_phl_macid_is_used(void *phl, u16 macid)
264*4882a593Smuzhiyun {
265*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
266*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
267*4882a593Smuzhiyun
268*4882a593Smuzhiyun if (macid >= macid_ctl->max_num) {
269*4882a593Smuzhiyun PHL_ERR("%s macid(%d) is invalid\n", __func__, macid);
270*4882a593Smuzhiyun return true;
271*4882a593Smuzhiyun }
272*4882a593Smuzhiyun
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun return _phl_macid_is_used(macid_ctl->used_map, macid);
275*4882a593Smuzhiyun }
276*4882a593Smuzhiyun
277*4882a593Smuzhiyun /**
278*4882a593Smuzhiyun * This function is used to
279*4882a593Smuzhiyun * check macid shared by all wifi role
280*4882a593Smuzhiyun * @phl: see phl_info_t
281*4882a593Smuzhiyun * @macid: macid
282*4882a593Smuzhiyun */
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun u8
rtw_phl_macid_is_wrole_shared(void * phl,u16 macid)285*4882a593Smuzhiyun rtw_phl_macid_is_wrole_shared(void *phl, u16 macid)
286*4882a593Smuzhiyun {
287*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
288*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
289*4882a593Smuzhiyun int i = 0;
290*4882a593Smuzhiyun u8 iface_bmp = 0;
291*4882a593Smuzhiyun
292*4882a593Smuzhiyun if (macid >= macid_ctl->max_num) {
293*4882a593Smuzhiyun PHL_ERR("%s macid(%d) is invalid\n", __func__, macid);
294*4882a593Smuzhiyun return false;
295*4882a593Smuzhiyun }
296*4882a593Smuzhiyun
297*4882a593Smuzhiyun for (i = 0; i < MAX_WIFI_ROLE_NUMBER; i++) {
298*4882a593Smuzhiyun if (_phl_macid_is_used(&macid_ctl->wifi_role_usedmap[i][0], macid)) {
299*4882a593Smuzhiyun if (iface_bmp)
300*4882a593Smuzhiyun return true;
301*4882a593Smuzhiyun iface_bmp |= BIT(i);
302*4882a593Smuzhiyun }
303*4882a593Smuzhiyun }
304*4882a593Smuzhiyun return false;
305*4882a593Smuzhiyun }
306*4882a593Smuzhiyun
307*4882a593Smuzhiyun /**
308*4882a593Smuzhiyun * This function is used to
309*4882a593Smuzhiyun * check macid not shared by all wifi role
310*4882a593Smuzhiyun * and belong to wifi role
311*4882a593Smuzhiyun * @phl: see phl_info_t
312*4882a593Smuzhiyun * @macid: macid
313*4882a593Smuzhiyun * @wrole: check id belong to this wifi role
314*4882a593Smuzhiyun */
315*4882a593Smuzhiyun u8
rtw_phl_macid_is_wrole_specific(void * phl,u16 macid,struct rtw_wifi_role_t * wrole)316*4882a593Smuzhiyun rtw_phl_macid_is_wrole_specific(void *phl,
317*4882a593Smuzhiyun u16 macid, struct rtw_wifi_role_t *wrole)
318*4882a593Smuzhiyun {
319*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
320*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
321*4882a593Smuzhiyun int i = 0;
322*4882a593Smuzhiyun u8 iface_bmp = 0;
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun if (macid >= macid_ctl->max_num) {
325*4882a593Smuzhiyun PHL_ERR("%s macid(%d) invalid\n", __func__, macid);
326*4882a593Smuzhiyun return false;
327*4882a593Smuzhiyun }
328*4882a593Smuzhiyun
329*4882a593Smuzhiyun for (i = 0; i < MAX_WIFI_ROLE_NUMBER; i++) {
330*4882a593Smuzhiyun if (_phl_macid_is_used(&macid_ctl->wifi_role_usedmap[i][0], macid)) {
331*4882a593Smuzhiyun if (iface_bmp || i != wrole->id)
332*4882a593Smuzhiyun return false;
333*4882a593Smuzhiyun iface_bmp |= BIT(i);
334*4882a593Smuzhiyun }
335*4882a593Smuzhiyun }
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun return iface_bmp ? true : false;
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun
341*4882a593Smuzhiyun /*********** stainfo_ctrl section ***********/
342*4882a593Smuzhiyun static enum rtw_phl_status
_phl_stainfo_init(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * phl_sta)343*4882a593Smuzhiyun _phl_stainfo_init(struct phl_info_t *phl_info,
344*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta)
345*4882a593Smuzhiyun {
346*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
347*4882a593Smuzhiyun
348*4882a593Smuzhiyun INIT_LIST_HEAD(&phl_sta->list);
349*4882a593Smuzhiyun _os_spinlock_init(drv, &phl_sta->tid_rx_lock);
350*4882a593Smuzhiyun _os_mem_set(drv, phl_sta->tid_rx, 0, sizeof(phl_sta->tid_rx));
351*4882a593Smuzhiyun _os_event_init(drv, &phl_sta->comp_sync);
352*4882a593Smuzhiyun _os_init_timer(drv, &phl_sta->reorder_timer,
353*4882a593Smuzhiyun phl_sta_rx_reorder_timer_expired, phl_sta, "reorder_timer");
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun _os_atomic_set(drv, &phl_sta->ps_sta, 0);
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun if (rtw_hal_stainfo_init(phl_info->hal, phl_sta) !=
358*4882a593Smuzhiyun RTW_HAL_STATUS_SUCCESS) {
359*4882a593Smuzhiyun PHL_ERR("hal_stainfo_init failed\n");
360*4882a593Smuzhiyun FUNCOUT();
361*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
362*4882a593Smuzhiyun }
363*4882a593Smuzhiyun phl_sta->active = false;
364*4882a593Smuzhiyun #ifdef RTW_WKARD_CHECK_STAINFO_DOUBLE_DEL
365*4882a593Smuzhiyun phl_sta->allocated = false;
366*4882a593Smuzhiyun #endif
367*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
368*4882a593Smuzhiyun }
369*4882a593Smuzhiyun
370*4882a593Smuzhiyun enum rtw_phl_status
_phl_stainfo_deinit(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * phl_sta)371*4882a593Smuzhiyun _phl_stainfo_deinit(struct phl_info_t *phl_info,
372*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta)
373*4882a593Smuzhiyun {
374*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
375*4882a593Smuzhiyun
376*4882a593Smuzhiyun _os_release_timer(drv, &phl_sta->reorder_timer);
377*4882a593Smuzhiyun _os_spinlock_free(phl_to_drvpriv(phl_info), &phl_sta->tid_rx_lock);
378*4882a593Smuzhiyun _os_event_free(drv, &phl_sta->comp_sync);
379*4882a593Smuzhiyun
380*4882a593Smuzhiyun if (rtw_hal_stainfo_deinit(phl_info->hal, phl_sta)!=
381*4882a593Smuzhiyun RTW_HAL_STATUS_SUCCESS) {
382*4882a593Smuzhiyun PHL_ERR("hal_stainfo_deinit failed\n");
383*4882a593Smuzhiyun FUNCOUT();
384*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
385*4882a593Smuzhiyun }
386*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
387*4882a593Smuzhiyun }
388*4882a593Smuzhiyun
389*4882a593Smuzhiyun enum rtw_phl_status
phl_stainfo_enqueue(struct phl_info_t * phl_info,struct phl_queue * sta_queue,struct rtw_phl_stainfo_t * psta)390*4882a593Smuzhiyun phl_stainfo_enqueue(struct phl_info_t *phl_info,
391*4882a593Smuzhiyun struct phl_queue *sta_queue,
392*4882a593Smuzhiyun struct rtw_phl_stainfo_t *psta)
393*4882a593Smuzhiyun {
394*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
395*4882a593Smuzhiyun
396*4882a593Smuzhiyun if (!psta)
397*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun _os_spinlock(drv, &sta_queue->lock, _bh, NULL);
400*4882a593Smuzhiyun list_add_tail(&psta->list, &sta_queue->queue);
401*4882a593Smuzhiyun sta_queue->cnt++;
402*4882a593Smuzhiyun _os_spinunlock(drv, &sta_queue->lock, _bh, NULL);
403*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
404*4882a593Smuzhiyun }
405*4882a593Smuzhiyun
406*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
phl_stainfo_dequeue(struct phl_info_t * phl_info,struct phl_queue * sta_queue)407*4882a593Smuzhiyun phl_stainfo_dequeue(struct phl_info_t *phl_info,
408*4882a593Smuzhiyun struct phl_queue *sta_queue)
409*4882a593Smuzhiyun {
410*4882a593Smuzhiyun struct rtw_phl_stainfo_t *psta = NULL;
411*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun _os_spinlock(drv, &sta_queue->lock, _bh, NULL);
414*4882a593Smuzhiyun if (list_empty(&sta_queue->queue)) {
415*4882a593Smuzhiyun psta = NULL;
416*4882a593Smuzhiyun } else {
417*4882a593Smuzhiyun psta = list_first_entry(&sta_queue->queue,
418*4882a593Smuzhiyun struct rtw_phl_stainfo_t, list);
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun list_del(&psta->list);
421*4882a593Smuzhiyun sta_queue->cnt--;
422*4882a593Smuzhiyun }
423*4882a593Smuzhiyun _os_spinunlock(drv, &sta_queue->lock, _bh, NULL);
424*4882a593Smuzhiyun
425*4882a593Smuzhiyun return psta;
426*4882a593Smuzhiyun }
427*4882a593Smuzhiyun
428*4882a593Smuzhiyun enum rtw_phl_status
phl_stainfo_queue_del(struct phl_info_t * phl_info,struct phl_queue * sta_queue,struct rtw_phl_stainfo_t * psta)429*4882a593Smuzhiyun phl_stainfo_queue_del(struct phl_info_t *phl_info,
430*4882a593Smuzhiyun struct phl_queue *sta_queue,
431*4882a593Smuzhiyun struct rtw_phl_stainfo_t *psta)
432*4882a593Smuzhiyun {
433*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun if (!psta)
436*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
437*4882a593Smuzhiyun
438*4882a593Smuzhiyun _os_spinlock(drv, &sta_queue->lock, _bh, NULL);
439*4882a593Smuzhiyun if (sta_queue->cnt) {
440*4882a593Smuzhiyun list_del(&psta->list);
441*4882a593Smuzhiyun sta_queue->cnt--;
442*4882a593Smuzhiyun }
443*4882a593Smuzhiyun _os_spinunlock(drv, &sta_queue->lock, _bh, NULL);
444*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
445*4882a593Smuzhiyun }
446*4882a593Smuzhiyun
447*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
phl_stainfo_queue_search(struct phl_info_t * phl_info,struct phl_queue * sta_queue,u8 * addr)448*4882a593Smuzhiyun phl_stainfo_queue_search(struct phl_info_t *phl_info,
449*4882a593Smuzhiyun struct phl_queue *sta_queue,
450*4882a593Smuzhiyun u8 *addr)
451*4882a593Smuzhiyun {
452*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
453*4882a593Smuzhiyun _os_list *sta_list = &sta_queue->queue;
454*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
455*4882a593Smuzhiyun bool sta_found = false;
456*4882a593Smuzhiyun
457*4882a593Smuzhiyun _os_spinlock(drv, &sta_queue->lock, _bh, NULL);
458*4882a593Smuzhiyun if (list_empty(sta_list) == true)
459*4882a593Smuzhiyun goto _exit;
460*4882a593Smuzhiyun
461*4882a593Smuzhiyun phl_list_for_loop(sta, struct rtw_phl_stainfo_t, sta_list, list) {
462*4882a593Smuzhiyun if (_os_mem_cmp(phl_to_drvpriv(phl_info),
463*4882a593Smuzhiyun sta->mac_addr, addr, MAC_ALEN) == 0) {
464*4882a593Smuzhiyun sta_found = true;
465*4882a593Smuzhiyun break;
466*4882a593Smuzhiyun }
467*4882a593Smuzhiyun }
468*4882a593Smuzhiyun _exit:
469*4882a593Smuzhiyun _os_spinunlock(drv, &sta_queue->lock, _bh, NULL);
470*4882a593Smuzhiyun
471*4882a593Smuzhiyun if (sta_found == false)
472*4882a593Smuzhiyun sta = NULL;
473*4882a593Smuzhiyun
474*4882a593Smuzhiyun return sta;
475*4882a593Smuzhiyun }
476*4882a593Smuzhiyun
477*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
phl_stainfo_queue_get_first(struct phl_info_t * phl_info,struct phl_queue * sta_queue)478*4882a593Smuzhiyun phl_stainfo_queue_get_first(struct phl_info_t *phl_info,
479*4882a593Smuzhiyun struct phl_queue *sta_queue)
480*4882a593Smuzhiyun {
481*4882a593Smuzhiyun
482*4882a593Smuzhiyun _os_list *sta_list = &sta_queue->queue;
483*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
484*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
485*4882a593Smuzhiyun
486*4882a593Smuzhiyun /* first sta info in assoc_sta_queu is self sta info */
487*4882a593Smuzhiyun _os_spinlock(drv, &sta_queue->lock, _bh, NULL);
488*4882a593Smuzhiyun if (list_empty(sta_list) == true)
489*4882a593Smuzhiyun goto _exit;
490*4882a593Smuzhiyun
491*4882a593Smuzhiyun sta = list_first_entry(sta_list, struct rtw_phl_stainfo_t, list);
492*4882a593Smuzhiyun _exit :
493*4882a593Smuzhiyun _os_spinunlock(drv, &sta_queue->lock, _bh, NULL);
494*4882a593Smuzhiyun
495*4882a593Smuzhiyun return sta;
496*4882a593Smuzhiyun }
497*4882a593Smuzhiyun
498*4882a593Smuzhiyun enum rtw_phl_status
phl_stainfo_ctrl_deinie(struct phl_info_t * phl_info)499*4882a593Smuzhiyun phl_stainfo_ctrl_deinie(struct phl_info_t *phl_info)
500*4882a593Smuzhiyun {
501*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = phl_to_sta_ctrl(phl_info);
502*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
503*4882a593Smuzhiyun struct rtw_phl_stainfo_t *psta = NULL;
504*4882a593Smuzhiyun struct phl_queue *fsta_queue = &sta_ctrl->free_sta_queue;
505*4882a593Smuzhiyun
506*4882a593Smuzhiyun FUNCIN();
507*4882a593Smuzhiyun do {
508*4882a593Smuzhiyun psta = phl_stainfo_dequeue(phl_info, fsta_queue);
509*4882a593Smuzhiyun if (psta)
510*4882a593Smuzhiyun _phl_stainfo_deinit(phl_info, psta);
511*4882a593Smuzhiyun
512*4882a593Smuzhiyun }while (psta != NULL);
513*4882a593Smuzhiyun
514*4882a593Smuzhiyun pq_deinit(drv, fsta_queue);
515*4882a593Smuzhiyun
516*4882a593Smuzhiyun if (sta_ctrl->allocated_stainfo_buf)
517*4882a593Smuzhiyun _os_mem_free(drv, sta_ctrl->allocated_stainfo_buf,
518*4882a593Smuzhiyun sta_ctrl->allocated_stainfo_sz);
519*4882a593Smuzhiyun FUNCOUT();
520*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
521*4882a593Smuzhiyun }
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun enum rtw_phl_status
phl_stainfo_ctrl_init(struct phl_info_t * phl_info)524*4882a593Smuzhiyun phl_stainfo_ctrl_init(struct phl_info_t *phl_info)
525*4882a593Smuzhiyun {
526*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = phl_to_sta_ctrl(phl_info);
527*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
528*4882a593Smuzhiyun struct rtw_phl_stainfo_t *psta = NULL;
529*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
530*4882a593Smuzhiyun struct phl_queue *fsta_queue = NULL;
531*4882a593Smuzhiyun
532*4882a593Smuzhiyun u16 i;
533*4882a593Smuzhiyun bool sta_init_fail = false;
534*4882a593Smuzhiyun
535*4882a593Smuzhiyun FUNCIN();
536*4882a593Smuzhiyun sta_ctrl->phl_info = phl_info;
537*4882a593Smuzhiyun
538*4882a593Smuzhiyun sta_ctrl->allocated_stainfo_sz = sizeof(struct rtw_phl_stainfo_t) * PHL_MAX_STA_NUM;
539*4882a593Smuzhiyun
540*4882a593Smuzhiyun #ifdef MEM_ALIGNMENT
541*4882a593Smuzhiyun sta_ctrl->allocated_stainfo_sz += MEM_ALIGNMENT_OFFSET;
542*4882a593Smuzhiyun #endif
543*4882a593Smuzhiyun
544*4882a593Smuzhiyun sta_ctrl->allocated_stainfo_buf =
545*4882a593Smuzhiyun _os_mem_alloc(drv, sta_ctrl->allocated_stainfo_sz);
546*4882a593Smuzhiyun
547*4882a593Smuzhiyun if (!sta_ctrl->allocated_stainfo_buf) {
548*4882a593Smuzhiyun PHL_ERR("allocate stainfo buf failed\n");
549*4882a593Smuzhiyun goto _exit;
550*4882a593Smuzhiyun }
551*4882a593Smuzhiyun sta_ctrl->stainfo_buf = sta_ctrl->allocated_stainfo_buf;
552*4882a593Smuzhiyun
553*4882a593Smuzhiyun #ifdef MEM_ALIGNMENT
554*4882a593Smuzhiyun if (sta_ctrl->stainfo_buf & MEM_ALIGNMENT_PADDING)
555*4882a593Smuzhiyun sta_ctrl->stainfo_buf += MEM_ALIGNMENT_OFFSET -
556*4882a593Smuzhiyun (sta_ctrl->stainfo_buf & MEM_ALIGNMENT_PADDING);
557*4882a593Smuzhiyun #endif
558*4882a593Smuzhiyun
559*4882a593Smuzhiyun fsta_queue = &sta_ctrl->free_sta_queue;
560*4882a593Smuzhiyun
561*4882a593Smuzhiyun pq_init(drv, fsta_queue);
562*4882a593Smuzhiyun psta = (struct rtw_phl_stainfo_t *)(sta_ctrl->stainfo_buf);
563*4882a593Smuzhiyun
564*4882a593Smuzhiyun for (i = 0; i < PHL_MAX_STA_NUM; i++) {
565*4882a593Smuzhiyun if (_phl_stainfo_init(phl_info, psta) != RTW_PHL_STATUS_SUCCESS) {
566*4882a593Smuzhiyun sta_init_fail = true;
567*4882a593Smuzhiyun break;
568*4882a593Smuzhiyun }
569*4882a593Smuzhiyun phl_stainfo_enqueue(phl_info, fsta_queue, psta);
570*4882a593Smuzhiyun psta++;
571*4882a593Smuzhiyun }
572*4882a593Smuzhiyun
573*4882a593Smuzhiyun if (sta_init_fail == true) {
574*4882a593Smuzhiyun PHL_ERR("sta_init failed\n");
575*4882a593Smuzhiyun phl_stainfo_ctrl_deinie(phl_info);
576*4882a593Smuzhiyun goto _exit;
577*4882a593Smuzhiyun }
578*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun pstatus = RTW_PHL_STATUS_SUCCESS;
581*4882a593Smuzhiyun _exit:
582*4882a593Smuzhiyun FUNCOUT();
583*4882a593Smuzhiyun return pstatus;
584*4882a593Smuzhiyun }
585*4882a593Smuzhiyun
586*4882a593Smuzhiyun /*********** phl stainfo section ***********/
587*4882a593Smuzhiyun #ifdef DBG_PHL_STAINFO
588*4882a593Smuzhiyun void
phl_dump_stactrl(const char * caller,const int line,bool show_caller,struct phl_info_t * phl_info)589*4882a593Smuzhiyun phl_dump_stactrl(const char *caller, const int line, bool show_caller,
590*4882a593Smuzhiyun struct phl_info_t *phl_info)
591*4882a593Smuzhiyun {
592*4882a593Smuzhiyun struct rtw_phl_com_t *phl_com = phl_info->phl_com;
593*4882a593Smuzhiyun u8 ridx = MAX_WIFI_ROLE_NUMBER;
594*4882a593Smuzhiyun struct rtw_wifi_role_t *role;
595*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = NULL;
596*4882a593Smuzhiyun
597*4882a593Smuzhiyun sta_ctrl = phl_to_sta_ctrl(phl_info);
598*4882a593Smuzhiyun
599*4882a593Smuzhiyun if (show_caller)
600*4882a593Smuzhiyun PHL_INFO("[PSTA] ###### FUN - %s LINE - %d #######\n", caller, line);
601*4882a593Smuzhiyun PHL_INFO("[PSTA] PHL_MAX_STA_NUM:%d\n", PHL_MAX_STA_NUM);
602*4882a593Smuzhiyun PHL_INFO("[PSTA] sta_ctrl - q_cnt :%d\n", sta_ctrl->free_sta_queue.cnt);
603*4882a593Smuzhiyun for (ridx = 0; ridx < MAX_WIFI_ROLE_NUMBER; ridx++) {
604*4882a593Smuzhiyun role = &(phl_com->wifi_roles[ridx]);
605*4882a593Smuzhiyun PHL_INFO("[PSTA] wrole_%d asoc_q cnt :%d\n",
606*4882a593Smuzhiyun ridx, role->assoc_sta_queue.cnt);
607*4882a593Smuzhiyun }
608*4882a593Smuzhiyun if (show_caller)
609*4882a593Smuzhiyun PHL_INFO("#################################\n");
610*4882a593Smuzhiyun }
611*4882a593Smuzhiyun
_phl_dump_stainfo(struct rtw_phl_stainfo_t * phl_sta)612*4882a593Smuzhiyun static void _phl_dump_stainfo(struct rtw_phl_stainfo_t *phl_sta)
613*4882a593Smuzhiyun {
614*4882a593Smuzhiyun PHL_INFO("\t[STA] MAC-ID:%d, AID:%d, MAC-ADDR:%02x-%02x-%02x-%02x-%02x-%02x, Active:%s\n",
615*4882a593Smuzhiyun phl_sta->macid, phl_sta->aid,
616*4882a593Smuzhiyun phl_sta->mac_addr[0],phl_sta->mac_addr[1],phl_sta->mac_addr[2],
617*4882a593Smuzhiyun phl_sta->mac_addr[3],phl_sta->mac_addr[4],phl_sta->mac_addr[5],
618*4882a593Smuzhiyun (phl_sta->active) ? "Y" : "N");
619*4882a593Smuzhiyun PHL_INFO("\t[STA] WROLE-IDX:%d wlan_mode:0x%02x\n", phl_sta->wrole->id, phl_sta->wmode);
620*4882a593Smuzhiyun PHL_DUMP_CHAN_DEF(&phl_sta->chandef);
621*4882a593Smuzhiyun
622*4882a593Smuzhiyun /****** statistic ******/
623*4882a593Smuzhiyun PHL_INFO("\t[STA] TP -[Tx:%d Rx :%d BI:N/A] (KBits)\n",
624*4882a593Smuzhiyun phl_sta->stats.tx_tp_kbits, phl_sta->stats.rx_tp_kbits);
625*4882a593Smuzhiyun PHL_INFO("\t[STA] Total -[Tx:%llu Rx :%llu BI:N/A] (Bytes)\n",
626*4882a593Smuzhiyun phl_sta->stats.tx_byte_total, phl_sta->stats.rx_byte_total);
627*4882a593Smuzhiyun /****** asoc_cap ******/
628*4882a593Smuzhiyun /****** protect ******/
629*4882a593Smuzhiyun /****** sec_mode ******/
630*4882a593Smuzhiyun /****** rssi_stat ******/
631*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] rssi:%d assoc_rssi:%d, ofdm:%d, cck:%d, rssi_ma:%d, ma_rssi:%d\n",
632*4882a593Smuzhiyun (phl_sta->hal_sta->rssi_stat.rssi >> 1), phl_sta->hal_sta->rssi_stat.assoc_rssi,
633*4882a593Smuzhiyun (phl_sta->hal_sta->rssi_stat.rssi_ofdm >> 1), (phl_sta->hal_sta->rssi_stat.rssi_cck >> 1),
634*4882a593Smuzhiyun (phl_sta->hal_sta->rssi_stat.rssi_ma >> 5), phl_sta->hal_sta->rssi_stat.ma_rssi);
635*4882a593Smuzhiyun
636*4882a593Smuzhiyun /****** ra_info ******/
637*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] - RA info\n");
638*4882a593Smuzhiyun
639*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] Tx rate:0x%04x ra_bw_mode:%d, curr_tx_bw:%d\n",
640*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.curr_tx_rate,
641*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.ra_bw_mode,
642*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.curr_tx_bw);
643*4882a593Smuzhiyun
644*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] dis_ra:%s ra_registered:%s\n",
645*4882a593Smuzhiyun (phl_sta->hal_sta->ra_info.dis_ra) ? "Y" : "N",
646*4882a593Smuzhiyun (phl_sta->hal_sta->ra_info.ra_registered) ? "Y" : "N");
647*4882a593Smuzhiyun
648*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] ra_mask:0x%08llx cur_ra_mask:0x%08llx, retry_ratio:%d\n",
649*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.ra_mask,
650*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.cur_ra_mask,
651*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.curr_retry_ratio);
652*4882a593Smuzhiyun /****** ra_info - Report ******/
653*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] RA Report: gi_ltf:%d rate_mode:%d, bw:%d, mcs_ss_idx:%d\n",
654*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.rpt_rt_i.gi_ltf,
655*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.rpt_rt_i.mode,
656*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.rpt_rt_i.bw,
657*4882a593Smuzhiyun phl_sta->hal_sta->ra_info.rpt_rt_i.mcs_ss_idx);
658*4882a593Smuzhiyun
659*4882a593Smuzhiyun PHL_INFO("\t\t[HAL STA] HAL rx_ok_cnt:%d rx_err_cnt:%d, rx_rate_plurality:%d\n\n",
660*4882a593Smuzhiyun phl_sta->hal_sta->trx_stat.rx_ok_cnt,
661*4882a593Smuzhiyun phl_sta->hal_sta->trx_stat.rx_err_cnt,
662*4882a593Smuzhiyun phl_sta->hal_sta->trx_stat.rx_rate_plurality);
663*4882a593Smuzhiyun
664*4882a593Smuzhiyun }
phl_dump_stainfo_all(const char * caller,const int line,bool show_caller,struct phl_info_t * phl_info)665*4882a593Smuzhiyun void phl_dump_stainfo_all(const char *caller, const int line, bool show_caller,
666*4882a593Smuzhiyun struct phl_info_t *phl_info)
667*4882a593Smuzhiyun {
668*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
669*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta = NULL;
670*4882a593Smuzhiyun u16 max_macid_num = 0;
671*4882a593Smuzhiyun u16 mid = 0;
672*4882a593Smuzhiyun
673*4882a593Smuzhiyun if (show_caller)
674*4882a593Smuzhiyun PHL_INFO("###### FUN - %s LINE - %d #######\n", caller, line);
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun max_macid_num = macid_ctl->max_num;
677*4882a593Smuzhiyun PHL_INFO("max_macid_num:%d\n", max_macid_num);
678*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
679*4882a593Smuzhiyun for(mid = 0; mid < max_macid_num; mid++) {
680*4882a593Smuzhiyun if (_phl_macid_is_used(macid_ctl->used_map, mid)) {
681*4882a593Smuzhiyun phl_sta = macid_ctl->sta[mid];
682*4882a593Smuzhiyun if (phl_sta)
683*4882a593Smuzhiyun _phl_dump_stainfo(phl_sta);
684*4882a593Smuzhiyun }
685*4882a593Smuzhiyun }
686*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
687*4882a593Smuzhiyun
688*4882a593Smuzhiyun if (show_caller)
689*4882a593Smuzhiyun PHL_INFO("#################################\n");
690*4882a593Smuzhiyun }
691*4882a593Smuzhiyun
692*4882a593Smuzhiyun const char *const _rtype_str[] = {
693*4882a593Smuzhiyun "NONE",
694*4882a593Smuzhiyun "STA",
695*4882a593Smuzhiyun "AP",
696*4882a593Smuzhiyun "VAP",
697*4882a593Smuzhiyun "ADHOC",
698*4882a593Smuzhiyun "MASTER",
699*4882a593Smuzhiyun "MESH",
700*4882a593Smuzhiyun "MONITOR",
701*4882a593Smuzhiyun "PD",
702*4882a593Smuzhiyun "GC",
703*4882a593Smuzhiyun "GO",
704*4882a593Smuzhiyun "TDLS",
705*4882a593Smuzhiyun "NAN",
706*4882a593Smuzhiyun "NONE"
707*4882a593Smuzhiyun };
708*4882a593Smuzhiyun
phl_dump_stainfo_per_role(const char * caller,const int line,bool show_caller,struct phl_info_t * phl_info,struct rtw_wifi_role_t * wrole)709*4882a593Smuzhiyun void phl_dump_stainfo_per_role(const char *caller, const int line, bool show_caller,
710*4882a593Smuzhiyun struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole)
711*4882a593Smuzhiyun {
712*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
713*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
714*4882a593Smuzhiyun int sta_cnt = 0;
715*4882a593Smuzhiyun
716*4882a593Smuzhiyun if (show_caller)
717*4882a593Smuzhiyun PHL_INFO("[STA] ###### FUN - %s LINE - %d #######\n", caller, line);
718*4882a593Smuzhiyun
719*4882a593Smuzhiyun PHL_INFO("WR_IDX:%d RTYPE:%s, mac-addr:%02x-%02x-%02x-%02x-%02x-%02x\n",
720*4882a593Smuzhiyun wrole->id,
721*4882a593Smuzhiyun _rtype_str[wrole->type],
722*4882a593Smuzhiyun wrole->mac_addr[0], wrole->mac_addr[1], wrole->mac_addr[2],
723*4882a593Smuzhiyun wrole->mac_addr[3], wrole->mac_addr[4], wrole->mac_addr[5]);
724*4882a593Smuzhiyun
725*4882a593Smuzhiyun _os_spinlock(drv, &wrole->assoc_sta_queue.lock, _bh, NULL);
726*4882a593Smuzhiyun
727*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION && wrole->mstate == MLME_LINKED)
728*4882a593Smuzhiyun sta_cnt = 1;
729*4882a593Smuzhiyun else if (wrole->type == PHL_RTYPE_TDLS)
730*4882a593Smuzhiyun sta_cnt = wrole->assoc_sta_queue.cnt;
731*4882a593Smuzhiyun else
732*4882a593Smuzhiyun sta_cnt = wrole->assoc_sta_queue.cnt - 1;
733*4882a593Smuzhiyun
734*4882a593Smuzhiyun PHL_INFO("assoced STA num: %d\n", sta_cnt);
735*4882a593Smuzhiyun phl_list_for_loop(sta, struct rtw_phl_stainfo_t, &wrole->assoc_sta_queue.queue, list) {
736*4882a593Smuzhiyun if (sta)
737*4882a593Smuzhiyun _phl_dump_stainfo(sta);
738*4882a593Smuzhiyun }
739*4882a593Smuzhiyun _os_spinunlock(drv, &wrole->assoc_sta_queue.lock, _bh, NULL);
740*4882a593Smuzhiyun
741*4882a593Smuzhiyun if (show_caller)
742*4882a593Smuzhiyun PHL_INFO("#################################\n");
743*4882a593Smuzhiyun }
744*4882a593Smuzhiyun
rtw_phl_sta_dump_info(void * phl,bool show_caller,struct rtw_wifi_role_t * wr,u8 mode)745*4882a593Smuzhiyun void rtw_phl_sta_dump_info(void *phl, bool show_caller, struct rtw_wifi_role_t *wr, u8 mode)
746*4882a593Smuzhiyun {
747*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
748*4882a593Smuzhiyun
749*4882a593Smuzhiyun if (mode == 1) {
750*4882a593Smuzhiyun if (show_caller) {
751*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
752*4882a593Smuzhiyun } else {
753*4882a593Smuzhiyun PHL_DUMP_STACTRL(phl_info);
754*4882a593Smuzhiyun }
755*4882a593Smuzhiyun } else if (mode == 2) {
756*4882a593Smuzhiyun if (show_caller) {
757*4882a593Smuzhiyun PHL_DUMP_STAINFO_EX(phl_info);
758*4882a593Smuzhiyun } else {
759*4882a593Smuzhiyun PHL_DUMP_STAINFO(phl_info);
760*4882a593Smuzhiyun }
761*4882a593Smuzhiyun } else if (mode == 3) {
762*4882a593Smuzhiyun if (show_caller) {
763*4882a593Smuzhiyun PHL_DUMP_ROLE_STAINFO_EX(phl_info, wr);
764*4882a593Smuzhiyun } else {
765*4882a593Smuzhiyun PHL_DUMP_ROLE_STAINFO(phl_info, wr);
766*4882a593Smuzhiyun }
767*4882a593Smuzhiyun } else {
768*4882a593Smuzhiyun if (show_caller) {
769*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
770*4882a593Smuzhiyun PHL_DUMP_STAINFO_EX(phl_info);
771*4882a593Smuzhiyun PHL_DUMP_ROLE_STAINFO_EX(phl_info, wr);
772*4882a593Smuzhiyun }
773*4882a593Smuzhiyun else {
774*4882a593Smuzhiyun PHL_DUMP_STACTRL(phl_info);
775*4882a593Smuzhiyun PHL_DUMP_STAINFO(phl_info);
776*4882a593Smuzhiyun PHL_DUMP_ROLE_STAINFO(phl_info, wr);
777*4882a593Smuzhiyun }
778*4882a593Smuzhiyun }
779*4882a593Smuzhiyun }
780*4882a593Smuzhiyun #endif /*DBG_PHL_STAINFO*/
781*4882a593Smuzhiyun
_phl_self_stainfo_chk(struct phl_info_t * phl_info,struct rtw_wifi_role_t * wrole,struct rtw_phl_stainfo_t * sta)782*4882a593Smuzhiyun static bool _phl_self_stainfo_chk(struct phl_info_t *phl_info,
783*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole, struct rtw_phl_stainfo_t *sta)
784*4882a593Smuzhiyun {
785*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
786*4882a593Smuzhiyun bool is_self = false;
787*4882a593Smuzhiyun
788*4882a593Smuzhiyun switch (wrole->type) {
789*4882a593Smuzhiyun case PHL_RTYPE_STATION:
790*4882a593Smuzhiyun case PHL_RTYPE_P2P_GC:
791*4882a593Smuzhiyun _os_mem_cpy(drv, sta->mac_addr, wrole->mac_addr, MAC_ALEN);
792*4882a593Smuzhiyun is_self = true;
793*4882a593Smuzhiyun break;
794*4882a593Smuzhiyun
795*4882a593Smuzhiyun case PHL_RTYPE_AP:
796*4882a593Smuzhiyun case PHL_RTYPE_MESH:
797*4882a593Smuzhiyun case PHL_RTYPE_P2P_GO:
798*4882a593Smuzhiyun case PHL_RTYPE_TDLS:
799*4882a593Smuzhiyun if (_os_mem_cmp(drv, wrole->mac_addr, sta->mac_addr, MAC_ALEN) == 0)
800*4882a593Smuzhiyun is_self = true;
801*4882a593Smuzhiyun break;
802*4882a593Smuzhiyun
803*4882a593Smuzhiyun case PHL_RTYPE_NONE:
804*4882a593Smuzhiyun case PHL_RTYPE_VAP:
805*4882a593Smuzhiyun case PHL_RTYPE_ADHOC:
806*4882a593Smuzhiyun case PHL_RTYPE_ADHOC_MASTER:
807*4882a593Smuzhiyun case PHL_RTYPE_MONITOR:
808*4882a593Smuzhiyun case PHL_RTYPE_P2P_DEVICE:
809*4882a593Smuzhiyun case PHL_RTYPE_NAN:
810*4882a593Smuzhiyun case PHL_MLME_MAX:
811*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "_phl_self_stainfo_chk(): Unsupported case:%d, please check it\n",
812*4882a593Smuzhiyun wrole->type);
813*4882a593Smuzhiyun break;
814*4882a593Smuzhiyun default:
815*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "_phl_self_stainfo_chk(): role-type(%d) not recognize\n",
816*4882a593Smuzhiyun wrole->type);
817*4882a593Smuzhiyun break;
818*4882a593Smuzhiyun }
819*4882a593Smuzhiyun return is_self;
820*4882a593Smuzhiyun }
821*4882a593Smuzhiyun
822*4882a593Smuzhiyun enum rtw_phl_status
phl_free_stainfo_sw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)823*4882a593Smuzhiyun phl_free_stainfo_sw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta)
824*4882a593Smuzhiyun {
825*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
826*4882a593Smuzhiyun
827*4882a593Smuzhiyun if(sta == NULL) {
828*4882a593Smuzhiyun PHL_ERR("%s sta is NULL\n", __func__);
829*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
830*4882a593Smuzhiyun }
831*4882a593Smuzhiyun
832*4882a593Smuzhiyun phl_free_rx_reorder(phl_info, sta);
833*4882a593Smuzhiyun
834*4882a593Smuzhiyun pstatus = phl_deregister_tx_ring((void *)phl_info, sta->macid);
835*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS) {
836*4882a593Smuzhiyun PHL_ERR("macid(%d) phl_deregister_tx_ring failed\n", sta->macid);
837*4882a593Smuzhiyun }
838*4882a593Smuzhiyun
839*4882a593Smuzhiyun /* release macid for used_map */
840*4882a593Smuzhiyun pstatus = _phl_release_macid(phl_info, sta);
841*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS)
842*4882a593Smuzhiyun PHL_ERR("_phl_release_macid failed\n");
843*4882a593Smuzhiyun
844*4882a593Smuzhiyun return pstatus;
845*4882a593Smuzhiyun }
846*4882a593Smuzhiyun
847*4882a593Smuzhiyun enum rtw_phl_status
__phl_free_stainfo_sw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)848*4882a593Smuzhiyun __phl_free_stainfo_sw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta)
849*4882a593Smuzhiyun {
850*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
851*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = phl_to_sta_ctrl(phl_info);
852*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = NULL;
853*4882a593Smuzhiyun
854*4882a593Smuzhiyun FUNCIN();
855*4882a593Smuzhiyun if(sta == NULL) {
856*4882a593Smuzhiyun PHL_ERR("%s sta is NULL\n", __func__);
857*4882a593Smuzhiyun goto _exit;
858*4882a593Smuzhiyun }
859*4882a593Smuzhiyun
860*4882a593Smuzhiyun #ifdef RTW_WKARD_CHECK_STAINFO_DOUBLE_DEL
861*4882a593Smuzhiyun if (!sta->allocated) {
862*4882a593Smuzhiyun PHL_INFO("%s sta has not been allocated\n", __func__);
863*4882a593Smuzhiyun goto _exit;
864*4882a593Smuzhiyun }
865*4882a593Smuzhiyun #endif
866*4882a593Smuzhiyun
867*4882a593Smuzhiyun wrole = sta->wrole;
868*4882a593Smuzhiyun
869*4882a593Smuzhiyun if (!is_broadcast_mac_addr(sta->mac_addr)) {
870*4882a593Smuzhiyun if (_phl_self_stainfo_chk(phl_info, wrole, sta) == true) {
871*4882a593Smuzhiyun pstatus = RTW_PHL_STATUS_SUCCESS;
872*4882a593Smuzhiyun goto _exit;
873*4882a593Smuzhiyun }
874*4882a593Smuzhiyun }
875*4882a593Smuzhiyun
876*4882a593Smuzhiyun pstatus = phl_stainfo_queue_del(phl_info, &wrole->assoc_sta_queue, sta);
877*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS) {
878*4882a593Smuzhiyun PHL_ERR("phl_stainfo_queue_del failed\n");
879*4882a593Smuzhiyun }
880*4882a593Smuzhiyun
881*4882a593Smuzhiyun #ifdef RTW_WKARD_CHECK_STAINFO_DOUBLE_DEL
882*4882a593Smuzhiyun sta->allocated = false;
883*4882a593Smuzhiyun #endif
884*4882a593Smuzhiyun
885*4882a593Smuzhiyun pstatus = phl_free_stainfo_sw(phl_info, sta);
886*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS) {
887*4882a593Smuzhiyun PHL_ERR("macid(%d) _phl_free_stainfo_sw failed\n", sta->macid);
888*4882a593Smuzhiyun }
889*4882a593Smuzhiyun
890*4882a593Smuzhiyun pstatus = phl_stainfo_enqueue(phl_info, &sta_ctrl->free_sta_queue, sta);
891*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS)
892*4882a593Smuzhiyun PHL_ERR("phl_stainfo_enqueue to free queue failed\n");
893*4882a593Smuzhiyun
894*4882a593Smuzhiyun #ifdef RTW_WKARD_AP_CLIENT_ADD_DEL_NTY
895*4882a593Smuzhiyun if ((wrole->type == PHL_RTYPE_AP) ||
896*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_VAP) ||
897*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_MESH) ||
898*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_P2P_GO))
899*4882a593Smuzhiyun phl_role_ap_client_notify(phl_info, wrole, MLME_NO_LINK);
900*4882a593Smuzhiyun #endif
901*4882a593Smuzhiyun
902*4882a593Smuzhiyun _exit:
903*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
904*4882a593Smuzhiyun FUNCOUT();
905*4882a593Smuzhiyun return pstatus;
906*4882a593Smuzhiyun }
907*4882a593Smuzhiyun
908*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_free_stainfo_sw(void * phl,struct rtw_phl_stainfo_t * sta)909*4882a593Smuzhiyun rtw_phl_free_stainfo_sw(void *phl, struct rtw_phl_stainfo_t *sta)
910*4882a593Smuzhiyun {
911*4882a593Smuzhiyun return __phl_free_stainfo_sw((struct phl_info_t *)phl, sta);
912*4882a593Smuzhiyun }
913*4882a593Smuzhiyun
914*4882a593Smuzhiyun enum rtw_phl_status
phl_free_stainfo_hw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)915*4882a593Smuzhiyun phl_free_stainfo_hw(struct phl_info_t *phl_info,
916*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta)
917*4882a593Smuzhiyun {
918*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
919*4882a593Smuzhiyun
920*4882a593Smuzhiyun if (sta == NULL) {
921*4882a593Smuzhiyun PHL_ERR("%s sta == NULL\n", __func__);
922*4882a593Smuzhiyun goto _exit;
923*4882a593Smuzhiyun }
924*4882a593Smuzhiyun
925*4882a593Smuzhiyun phl_pkt_ofld_del_entry(phl_info, sta->macid);
926*4882a593Smuzhiyun
927*4882a593Smuzhiyun sta->active = false;
928*4882a593Smuzhiyun if (rtw_hal_del_sta_entry(phl_info->hal, sta) == RTW_HAL_STATUS_SUCCESS)
929*4882a593Smuzhiyun pstatus = RTW_PHL_STATUS_SUCCESS;
930*4882a593Smuzhiyun else
931*4882a593Smuzhiyun PHL_ERR("rtw_hal_del_sta_entry failed\n");
932*4882a593Smuzhiyun _exit:
933*4882a593Smuzhiyun return pstatus;
934*4882a593Smuzhiyun }
935*4882a593Smuzhiyun
936*4882a593Smuzhiyun enum rtw_phl_status
__phl_free_stainfo_hw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)937*4882a593Smuzhiyun __phl_free_stainfo_hw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta)
938*4882a593Smuzhiyun {
939*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = sta->wrole;
940*4882a593Smuzhiyun
941*4882a593Smuzhiyun if (!is_broadcast_mac_addr(sta->mac_addr)) {
942*4882a593Smuzhiyun if (_phl_self_stainfo_chk(phl_info, wrole, sta) == true)
943*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
944*4882a593Smuzhiyun }
945*4882a593Smuzhiyun return phl_free_stainfo_hw(phl_info, sta);
946*4882a593Smuzhiyun }
947*4882a593Smuzhiyun
948*4882a593Smuzhiyun static enum rtw_phl_status
__phl_free_stainfo(struct phl_info_t * phl,struct rtw_phl_stainfo_t * sta)949*4882a593Smuzhiyun __phl_free_stainfo(struct phl_info_t *phl, struct rtw_phl_stainfo_t *sta)
950*4882a593Smuzhiyun {
951*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
952*4882a593Smuzhiyun
953*4882a593Smuzhiyun pstatus = __phl_free_stainfo_hw(phl, sta);
954*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS)
955*4882a593Smuzhiyun PHL_ERR("__phl_free_stainfo_hw failed\n");
956*4882a593Smuzhiyun
957*4882a593Smuzhiyun pstatus = __phl_free_stainfo_sw(phl, sta);
958*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS)
959*4882a593Smuzhiyun PHL_ERR("__phl_free_stainfo_sw failed\n");
960*4882a593Smuzhiyun return pstatus;
961*4882a593Smuzhiyun }
962*4882a593Smuzhiyun
963*4882a593Smuzhiyun
964*4882a593Smuzhiyun static enum rtw_phl_status
_phl_alloc_stainfo_sw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)965*4882a593Smuzhiyun _phl_alloc_stainfo_sw(struct phl_info_t *phl_info,struct rtw_phl_stainfo_t *sta)
966*4882a593Smuzhiyun {
967*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
968*4882a593Smuzhiyun
969*4882a593Smuzhiyun pstatus = _phl_alloc_macid(phl_info, sta);
970*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS) {
971*4882a593Smuzhiyun PHL_ERR("%s allocate macid failure!\n", __func__);
972*4882a593Smuzhiyun goto error_alloc_macid;
973*4882a593Smuzhiyun }
974*4882a593Smuzhiyun
975*4882a593Smuzhiyun if (phl_register_tx_ring(phl_info, sta->macid,
976*4882a593Smuzhiyun sta->wrole->hw_band, sta->wrole->hw_wmm, sta->wrole->hw_port) !=
977*4882a593Smuzhiyun RTW_PHL_STATUS_SUCCESS) {
978*4882a593Smuzhiyun PHL_ERR("%s register_tx_ring failure!\n", __func__);
979*4882a593Smuzhiyun goto error_register_tx_ring;
980*4882a593Smuzhiyun }
981*4882a593Smuzhiyun pstatus = RTW_PHL_STATUS_SUCCESS;
982*4882a593Smuzhiyun return pstatus;
983*4882a593Smuzhiyun
984*4882a593Smuzhiyun error_register_tx_ring:
985*4882a593Smuzhiyun _phl_release_macid(phl_info, sta);
986*4882a593Smuzhiyun error_alloc_macid:
987*4882a593Smuzhiyun return pstatus;
988*4882a593Smuzhiyun }
989*4882a593Smuzhiyun
_phl_sta_set_default_value(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * phl_sta)990*4882a593Smuzhiyun static void _phl_sta_set_default_value(struct phl_info_t *phl_info,
991*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta)
992*4882a593Smuzhiyun {
993*4882a593Smuzhiyun phl_sta->bcn_hit_cond = 0; /* beacon:A3 probersp: A1 & A3 */
994*4882a593Smuzhiyun
995*4882a593Smuzhiyun /* fit rule
996*4882a593Smuzhiyun * 0: A1 & A2
997*4882a593Smuzhiyun * 1: A1 & A3
998*4882a593Smuzhiyun *
999*4882a593Smuzhiyun * Rule 0 should be used for both AP and STA modes.
1000*4882a593Smuzhiyun *
1001*4882a593Smuzhiyun * For STA, A3 is source address(SA) which can be any peer on the LAN.
1002*4882a593Smuzhiyun *
1003*4882a593Smuzhiyun * For AP, A3 is destination address(DA) which can also be any node
1004*4882a593Smuzhiyun * on the LAN. A1 & A2 match find the address CAM entry that contains the
1005*4882a593Smuzhiyun * correct security CAM ID and MAC ID.
1006*4882a593Smuzhiyun */
1007*4882a593Smuzhiyun phl_sta->hit_rule = 0;
1008*4882a593Smuzhiyun }
1009*4882a593Smuzhiyun
1010*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
phl_alloc_stainfo_sw(struct phl_info_t * phl_info,u8 * sta_addr,struct rtw_wifi_role_t * wrole)1011*4882a593Smuzhiyun phl_alloc_stainfo_sw(struct phl_info_t *phl_info,
1012*4882a593Smuzhiyun u8 *sta_addr,
1013*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
1014*4882a593Smuzhiyun {
1015*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = phl_to_sta_ctrl(phl_info);
1016*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta = NULL;
1017*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
1018*4882a593Smuzhiyun bool bmc_sta = false;
1019*4882a593Smuzhiyun
1020*4882a593Smuzhiyun FUNCIN();
1021*4882a593Smuzhiyun if (is_broadcast_mac_addr(sta_addr))
1022*4882a593Smuzhiyun bmc_sta = true;
1023*4882a593Smuzhiyun
1024*4882a593Smuzhiyun /* if sta_addr is bmc addr, allocate new sta_info */
1025*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION && !bmc_sta) {
1026*4882a593Smuzhiyun phl_sta = rtw_phl_get_stainfo_self(phl_info, wrole);
1027*4882a593Smuzhiyun if (phl_sta) {
1028*4882a593Smuzhiyun _os_mem_cpy(drv, phl_sta->mac_addr, sta_addr, MAC_ALEN);
1029*4882a593Smuzhiyun goto _exit;
1030*4882a593Smuzhiyun }
1031*4882a593Smuzhiyun }
1032*4882a593Smuzhiyun
1033*4882a593Smuzhiyun /* check station info exist */
1034*4882a593Smuzhiyun phl_sta = rtw_phl_get_stainfo_by_addr(phl_info, wrole, sta_addr);
1035*4882a593Smuzhiyun if (phl_sta) {
1036*4882a593Smuzhiyun PHL_INFO("%s phl_sta(%02x:%02x:%02x:%02x:%02x:%02x) exist\n",
1037*4882a593Smuzhiyun __func__, sta_addr[0], sta_addr[1], sta_addr[2],
1038*4882a593Smuzhiyun sta_addr[3], sta_addr[4], sta_addr[5]);
1039*4882a593Smuzhiyun goto _exit;
1040*4882a593Smuzhiyun }
1041*4882a593Smuzhiyun
1042*4882a593Smuzhiyun phl_sta = phl_stainfo_dequeue(phl_info, &sta_ctrl->free_sta_queue);
1043*4882a593Smuzhiyun if (phl_sta == NULL) {
1044*4882a593Smuzhiyun PHL_ERR("allocate phl_sta failure!\n");
1045*4882a593Smuzhiyun goto _exit;
1046*4882a593Smuzhiyun }
1047*4882a593Smuzhiyun
1048*4882a593Smuzhiyun _os_mem_cpy(drv, phl_sta->mac_addr, sta_addr, MAC_ALEN);
1049*4882a593Smuzhiyun phl_sta->wrole = wrole;
1050*4882a593Smuzhiyun
1051*4882a593Smuzhiyun if (_phl_alloc_stainfo_sw(phl_info, phl_sta) != RTW_PHL_STATUS_SUCCESS) {
1052*4882a593Smuzhiyun PHL_ERR("_phl_alloc_stainfo_sw failed\n");
1053*4882a593Smuzhiyun goto error_alloc_sta;
1054*4882a593Smuzhiyun }
1055*4882a593Smuzhiyun _phl_sta_set_default_value(phl_info, phl_sta);
1056*4882a593Smuzhiyun
1057*4882a593Smuzhiyun phl_stainfo_enqueue(phl_info, &wrole->assoc_sta_queue, phl_sta);
1058*4882a593Smuzhiyun #ifdef RTW_WKARD_CHECK_STAINFO_DOUBLE_DEL
1059*4882a593Smuzhiyun phl_sta->allocated = true;
1060*4882a593Smuzhiyun #endif
1061*4882a593Smuzhiyun
1062*4882a593Smuzhiyun #ifdef RTW_WKARD_AP_CLIENT_ADD_DEL_NTY
1063*4882a593Smuzhiyun if (_phl_self_stainfo_chk(phl_info, wrole, phl_sta) == false) {
1064*4882a593Smuzhiyun if ((wrole->type == PHL_RTYPE_AP) ||
1065*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_VAP) ||
1066*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_MESH) ||
1067*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_P2P_GO)) {
1068*4882a593Smuzhiyun phl_role_ap_client_notify(phl_info, wrole, MLME_LINKING);
1069*4882a593Smuzhiyun }
1070*4882a593Smuzhiyun }
1071*4882a593Smuzhiyun #endif
1072*4882a593Smuzhiyun _exit:
1073*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
1074*4882a593Smuzhiyun FUNCOUT();
1075*4882a593Smuzhiyun
1076*4882a593Smuzhiyun return phl_sta;
1077*4882a593Smuzhiyun
1078*4882a593Smuzhiyun error_alloc_sta:
1079*4882a593Smuzhiyun phl_stainfo_enqueue(phl_info, &sta_ctrl->free_sta_queue, phl_sta);
1080*4882a593Smuzhiyun phl_sta = NULL;
1081*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
1082*4882a593Smuzhiyun FUNCOUT();
1083*4882a593Smuzhiyun return phl_sta;
1084*4882a593Smuzhiyun }
1085*4882a593Smuzhiyun
1086*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
rtw_phl_alloc_stainfo_sw(void * phl,u8 * sta_addr,struct rtw_wifi_role_t * wrole)1087*4882a593Smuzhiyun rtw_phl_alloc_stainfo_sw(void *phl, u8 *sta_addr,
1088*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
1089*4882a593Smuzhiyun {
1090*4882a593Smuzhiyun return phl_alloc_stainfo_sw((struct phl_info_t *)phl, sta_addr, wrole);
1091*4882a593Smuzhiyun }
1092*4882a593Smuzhiyun
1093*4882a593Smuzhiyun enum rtw_phl_status
phl_alloc_stainfo_hw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)1094*4882a593Smuzhiyun phl_alloc_stainfo_hw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta)
1095*4882a593Smuzhiyun {
1096*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
1097*4882a593Smuzhiyun
1098*4882a593Smuzhiyun if (sta == NULL) {
1099*4882a593Smuzhiyun PHL_ERR("%s sta == NULL\n", __func__);
1100*4882a593Smuzhiyun goto _exit;
1101*4882a593Smuzhiyun }
1102*4882a593Smuzhiyun
1103*4882a593Smuzhiyun if (rtw_hal_add_sta_entry(phl_info->hal, sta) != RTW_HAL_STATUS_SUCCESS) {
1104*4882a593Smuzhiyun PHL_ERR("%s rtw_hal_add_sta_entry failure!\n", __func__);
1105*4882a593Smuzhiyun goto _exit;
1106*4882a593Smuzhiyun }
1107*4882a593Smuzhiyun
1108*4882a593Smuzhiyun sta->active = true;
1109*4882a593Smuzhiyun
1110*4882a593Smuzhiyun pstatus = phl_pkt_ofld_add_entry(phl_info, sta->macid);
1111*4882a593Smuzhiyun if (RTW_PHL_STATUS_SUCCESS != pstatus)
1112*4882a593Smuzhiyun PHL_ERR("%s phl_pkt_ofld_add_entry failure!\n", __func__);
1113*4882a593Smuzhiyun
1114*4882a593Smuzhiyun _exit:
1115*4882a593Smuzhiyun return pstatus;
1116*4882a593Smuzhiyun }
1117*4882a593Smuzhiyun
1118*4882a593Smuzhiyun enum rtw_phl_status
__phl_alloc_stainfo_hw(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)1119*4882a593Smuzhiyun __phl_alloc_stainfo_hw(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta)
1120*4882a593Smuzhiyun {
1121*4882a593Smuzhiyun return phl_alloc_stainfo_hw(phl_info, sta);
1122*4882a593Smuzhiyun }
1123*4882a593Smuzhiyun
1124*4882a593Smuzhiyun static enum rtw_phl_status
__phl_alloc_stainfo(struct phl_info_t * phl,struct rtw_phl_stainfo_t ** sta,u8 * sta_addr,struct rtw_wifi_role_t * wrole)1125*4882a593Smuzhiyun __phl_alloc_stainfo(struct phl_info_t *phl,
1126*4882a593Smuzhiyun struct rtw_phl_stainfo_t **sta,
1127*4882a593Smuzhiyun u8 *sta_addr,
1128*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
1129*4882a593Smuzhiyun {
1130*4882a593Smuzhiyun struct rtw_phl_stainfo_t *alloc_sta = NULL;
1131*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
1132*4882a593Smuzhiyun
1133*4882a593Smuzhiyun alloc_sta = phl_alloc_stainfo_sw(phl, sta_addr, wrole);
1134*4882a593Smuzhiyun if (alloc_sta == NULL) {
1135*4882a593Smuzhiyun PHL_ERR("%s can't alloc stainfo\n", __func__);
1136*4882a593Smuzhiyun *sta = alloc_sta;
1137*4882a593Smuzhiyun goto _exit;
1138*4882a593Smuzhiyun }
1139*4882a593Smuzhiyun
1140*4882a593Smuzhiyun if (alloc_sta->active == false) {
1141*4882a593Smuzhiyun pstatus = __phl_alloc_stainfo_hw(phl, alloc_sta);
1142*4882a593Smuzhiyun if (pstatus != RTW_PHL_STATUS_SUCCESS) {
1143*4882a593Smuzhiyun PHL_ERR("__phl_alloc_stainfo_hw failed\n");
1144*4882a593Smuzhiyun goto _err_alloc_sta_hw;
1145*4882a593Smuzhiyun }
1146*4882a593Smuzhiyun }
1147*4882a593Smuzhiyun
1148*4882a593Smuzhiyun PHL_INFO("%s success - macid:%u %02x:%02x:%02x:%02x:%02x:%02x\n",
1149*4882a593Smuzhiyun __func__, alloc_sta->macid,
1150*4882a593Smuzhiyun alloc_sta->mac_addr[0], alloc_sta->mac_addr[1], alloc_sta->mac_addr[2],
1151*4882a593Smuzhiyun alloc_sta->mac_addr[3], alloc_sta->mac_addr[4], alloc_sta->mac_addr[5]);
1152*4882a593Smuzhiyun
1153*4882a593Smuzhiyun *sta = alloc_sta;
1154*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
1155*4882a593Smuzhiyun
1156*4882a593Smuzhiyun _err_alloc_sta_hw:
1157*4882a593Smuzhiyun __phl_free_stainfo_sw(phl, alloc_sta);
1158*4882a593Smuzhiyun *sta = alloc_sta = NULL;
1159*4882a593Smuzhiyun _exit:
1160*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
1161*4882a593Smuzhiyun }
1162*4882a593Smuzhiyun
1163*4882a593Smuzhiyun static enum rtw_phl_status
_phl_alloc_stainfo(struct phl_info_t * phl,struct rtw_phl_stainfo_t ** sta,u8 * sta_addr,struct rtw_wifi_role_t * wrole,bool alloc,bool only_hw)1164*4882a593Smuzhiyun _phl_alloc_stainfo(struct phl_info_t *phl,
1165*4882a593Smuzhiyun struct rtw_phl_stainfo_t **sta,
1166*4882a593Smuzhiyun u8 *sta_addr,
1167*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
1168*4882a593Smuzhiyun bool alloc,
1169*4882a593Smuzhiyun bool only_hw)
1170*4882a593Smuzhiyun {
1171*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
1172*4882a593Smuzhiyun
1173*4882a593Smuzhiyun if (alloc) {
1174*4882a593Smuzhiyun if (only_hw)
1175*4882a593Smuzhiyun pstatus = __phl_alloc_stainfo_hw(phl, *sta);
1176*4882a593Smuzhiyun else
1177*4882a593Smuzhiyun pstatus = __phl_alloc_stainfo(phl, sta, sta_addr, wrole);
1178*4882a593Smuzhiyun } else {
1179*4882a593Smuzhiyun if (only_hw)
1180*4882a593Smuzhiyun pstatus = __phl_free_stainfo_hw(phl, *sta);
1181*4882a593Smuzhiyun else
1182*4882a593Smuzhiyun pstatus = __phl_free_stainfo(phl, *sta);
1183*4882a593Smuzhiyun }
1184*4882a593Smuzhiyun return pstatus;
1185*4882a593Smuzhiyun }
1186*4882a593Smuzhiyun
1187*4882a593Smuzhiyun #ifdef CONFIG_CMD_DISP
1188*4882a593Smuzhiyun struct cmd_stainfo_param {
1189*4882a593Smuzhiyun struct rtw_phl_stainfo_t **sta;
1190*4882a593Smuzhiyun u8 sta_addr[MAC_ALEN];
1191*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole;
1192*4882a593Smuzhiyun bool alloc;
1193*4882a593Smuzhiyun bool only_hw;
1194*4882a593Smuzhiyun };
1195*4882a593Smuzhiyun
1196*4882a593Smuzhiyun static void
_phl_cmd_alloc_stainfo_done(void * drv_priv,u8 * cmd,u32 cmd_len,enum rtw_phl_status status)1197*4882a593Smuzhiyun _phl_cmd_alloc_stainfo_done(void *drv_priv,
1198*4882a593Smuzhiyun u8 *cmd,
1199*4882a593Smuzhiyun u32 cmd_len,
1200*4882a593Smuzhiyun enum rtw_phl_status status)
1201*4882a593Smuzhiyun {
1202*4882a593Smuzhiyun if (cmd)
1203*4882a593Smuzhiyun _os_kmem_free(drv_priv, cmd, cmd_len);
1204*4882a593Smuzhiyun }
1205*4882a593Smuzhiyun
1206*4882a593Smuzhiyun static enum rtw_phl_status
_phl_cmd_alloc_stainfo(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t ** sta,u8 * sta_addr,struct rtw_wifi_role_t * wrole,bool alloc,bool only_hw,enum phl_cmd_type cmd_type,u32 cmd_timeout)1207*4882a593Smuzhiyun _phl_cmd_alloc_stainfo(struct phl_info_t *phl_info,
1208*4882a593Smuzhiyun struct rtw_phl_stainfo_t **sta,
1209*4882a593Smuzhiyun u8 *sta_addr,
1210*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
1211*4882a593Smuzhiyun bool alloc, bool only_hw,
1212*4882a593Smuzhiyun enum phl_cmd_type cmd_type,
1213*4882a593Smuzhiyun u32 cmd_timeout)
1214*4882a593Smuzhiyun {
1215*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
1216*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
1217*4882a593Smuzhiyun struct cmd_stainfo_param *param = NULL;
1218*4882a593Smuzhiyun u32 param_len = 0;
1219*4882a593Smuzhiyun
1220*4882a593Smuzhiyun if (cmd_type == PHL_CMD_DIRECTLY) {
1221*4882a593Smuzhiyun psts = _phl_alloc_stainfo(phl_info, sta, sta_addr, wrole, alloc, only_hw);
1222*4882a593Smuzhiyun goto _exit;
1223*4882a593Smuzhiyun }
1224*4882a593Smuzhiyun
1225*4882a593Smuzhiyun param_len = sizeof(struct cmd_stainfo_param);
1226*4882a593Smuzhiyun param = _os_kmem_alloc(drv, param_len);
1227*4882a593Smuzhiyun if (param == NULL) {
1228*4882a593Smuzhiyun PHL_ERR("%s: alloc param failed!\n", __func__);
1229*4882a593Smuzhiyun psts = RTW_PHL_STATUS_RESOURCE;
1230*4882a593Smuzhiyun goto _exit;
1231*4882a593Smuzhiyun }
1232*4882a593Smuzhiyun
1233*4882a593Smuzhiyun _os_mem_set(drv, param, 0, param_len);
1234*4882a593Smuzhiyun param->sta = sta;
1235*4882a593Smuzhiyun _os_mem_cpy(drv, param->sta_addr, sta_addr, MAC_ALEN);
1236*4882a593Smuzhiyun param->wrole = wrole;
1237*4882a593Smuzhiyun param->alloc = alloc;
1238*4882a593Smuzhiyun param->only_hw = only_hw;
1239*4882a593Smuzhiyun
1240*4882a593Smuzhiyun psts = phl_cmd_enqueue(phl_info,
1241*4882a593Smuzhiyun wrole->hw_band,
1242*4882a593Smuzhiyun MSG_EVT_STA_INFO_CTRL,
1243*4882a593Smuzhiyun (u8 *)param,
1244*4882a593Smuzhiyun param_len,
1245*4882a593Smuzhiyun _phl_cmd_alloc_stainfo_done,
1246*4882a593Smuzhiyun cmd_type,
1247*4882a593Smuzhiyun cmd_timeout);
1248*4882a593Smuzhiyun
1249*4882a593Smuzhiyun if (is_cmd_failure(psts)) {
1250*4882a593Smuzhiyun /* Send cmd success, but wait cmd fail*/
1251*4882a593Smuzhiyun psts = RTW_PHL_STATUS_FAILURE;
1252*4882a593Smuzhiyun } else if (psts != RTW_PHL_STATUS_SUCCESS) {
1253*4882a593Smuzhiyun /* Send cmd fail */
1254*4882a593Smuzhiyun psts = RTW_PHL_STATUS_FAILURE;
1255*4882a593Smuzhiyun _os_kmem_free(drv, param, param_len);
1256*4882a593Smuzhiyun }
1257*4882a593Smuzhiyun _exit:
1258*4882a593Smuzhiyun return psts;
1259*4882a593Smuzhiyun }
1260*4882a593Smuzhiyun
1261*4882a593Smuzhiyun enum rtw_phl_status
phl_cmd_alloc_stainfo_hdl(struct phl_info_t * phl_info,u8 * param)1262*4882a593Smuzhiyun phl_cmd_alloc_stainfo_hdl(struct phl_info_t *phl_info, u8 *param)
1263*4882a593Smuzhiyun {
1264*4882a593Smuzhiyun struct cmd_stainfo_param *cmd_sta_param = (struct cmd_stainfo_param *)param;
1265*4882a593Smuzhiyun
1266*4882a593Smuzhiyun return _phl_alloc_stainfo(phl_info,
1267*4882a593Smuzhiyun cmd_sta_param->sta,
1268*4882a593Smuzhiyun cmd_sta_param->sta_addr,
1269*4882a593Smuzhiyun cmd_sta_param->wrole,
1270*4882a593Smuzhiyun cmd_sta_param->alloc,
1271*4882a593Smuzhiyun cmd_sta_param->only_hw);
1272*4882a593Smuzhiyun }
1273*4882a593Smuzhiyun
1274*4882a593Smuzhiyun #endif /* CONFIG_CMD_DISP */
1275*4882a593Smuzhiyun
1276*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_cmd_alloc_stainfo(void * phl,struct rtw_phl_stainfo_t ** sta,u8 * sta_addr,struct rtw_wifi_role_t * wrole,bool alloc,bool only_hw,enum phl_cmd_type cmd_type,u32 cmd_timeout)1277*4882a593Smuzhiyun rtw_phl_cmd_alloc_stainfo(void *phl,
1278*4882a593Smuzhiyun struct rtw_phl_stainfo_t **sta,
1279*4882a593Smuzhiyun u8 *sta_addr,
1280*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
1281*4882a593Smuzhiyun bool alloc, bool only_hw,
1282*4882a593Smuzhiyun enum phl_cmd_type cmd_type,
1283*4882a593Smuzhiyun u32 cmd_timeout)
1284*4882a593Smuzhiyun {
1285*4882a593Smuzhiyun #ifdef CONFIG_CMD_DISP
1286*4882a593Smuzhiyun return _phl_cmd_alloc_stainfo(phl, sta, sta_addr, wrole, alloc, only_hw, cmd_type, cmd_timeout);
1287*4882a593Smuzhiyun #else
1288*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "%s: not support alloc stainfo cmd\n",
1289*4882a593Smuzhiyun __func__);
1290*4882a593Smuzhiyun
1291*4882a593Smuzhiyun return _phl_alloc_stainfo((struct phl_info_t *)phl, sta, sta_addr, wrole, alloc, only_hw);
1292*4882a593Smuzhiyun #endif /* CONFIG_CMD_DISP */
1293*4882a593Smuzhiyun }
1294*4882a593Smuzhiyun
1295*4882a593Smuzhiyun enum rtw_phl_status
phl_wifi_role_free_stainfo_hw(struct phl_info_t * phl_info,struct rtw_wifi_role_t * wrole)1296*4882a593Smuzhiyun phl_wifi_role_free_stainfo_hw(struct phl_info_t *phl_info,
1297*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
1298*4882a593Smuzhiyun {
1299*4882a593Smuzhiyun struct macid_ctl_t *mc = phl_to_mac_ctrl(phl_info);
1300*4882a593Smuzhiyun u16 max_macid_num = mc->max_num;
1301*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
1302*4882a593Smuzhiyun u32 *used_map;
1303*4882a593Smuzhiyun u16 mid;
1304*4882a593Smuzhiyun
1305*4882a593Smuzhiyun used_map = &mc->wifi_role_usedmap[wrole->id][0];
1306*4882a593Smuzhiyun
1307*4882a593Smuzhiyun for(mid = 0; mid < max_macid_num; mid++) {
1308*4882a593Smuzhiyun if (_phl_macid_is_used(used_map, mid)) {
1309*4882a593Smuzhiyun sta = mc->sta[mid];
1310*4882a593Smuzhiyun if (sta) {
1311*4882a593Smuzhiyun PHL_INFO("%s [WR-%d] free sta_info(MID:%d)\n",
1312*4882a593Smuzhiyun __func__, wrole->id, sta->macid);
1313*4882a593Smuzhiyun phl_free_stainfo_hw(phl_info, sta);
1314*4882a593Smuzhiyun }
1315*4882a593Smuzhiyun }
1316*4882a593Smuzhiyun }
1317*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
1318*4882a593Smuzhiyun }
1319*4882a593Smuzhiyun
1320*4882a593Smuzhiyun enum rtw_phl_status
phl_wifi_role_free_stainfo_sw(struct phl_info_t * phl_info,struct rtw_wifi_role_t * role)1321*4882a593Smuzhiyun phl_wifi_role_free_stainfo_sw(struct phl_info_t *phl_info,
1322*4882a593Smuzhiyun struct rtw_wifi_role_t *role)
1323*4882a593Smuzhiyun {
1324*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta = NULL;
1325*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = phl_to_sta_ctrl(phl_info);
1326*4882a593Smuzhiyun
1327*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
1328*4882a593Smuzhiyun do {
1329*4882a593Smuzhiyun phl_sta = phl_stainfo_dequeue(phl_info, &role->assoc_sta_queue);
1330*4882a593Smuzhiyun
1331*4882a593Smuzhiyun if (phl_sta) {
1332*4882a593Smuzhiyun #ifdef RTW_WKARD_CHECK_STAINFO_DOUBLE_DEL
1333*4882a593Smuzhiyun phl_sta->allocated = false;
1334*4882a593Smuzhiyun #endif
1335*4882a593Smuzhiyun phl_free_stainfo_sw(phl_info, phl_sta);
1336*4882a593Smuzhiyun phl_stainfo_enqueue(phl_info,
1337*4882a593Smuzhiyun &sta_ctrl->free_sta_queue, phl_sta);
1338*4882a593Smuzhiyun }
1339*4882a593Smuzhiyun } while(phl_sta != NULL);
1340*4882a593Smuzhiyun
1341*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
1342*4882a593Smuzhiyun }
1343*4882a593Smuzhiyun
1344*4882a593Smuzhiyun enum rtw_phl_status
phl_wifi_role_free_stainfo(struct phl_info_t * phl_info,struct rtw_wifi_role_t * role)1345*4882a593Smuzhiyun phl_wifi_role_free_stainfo(struct phl_info_t *phl_info,
1346*4882a593Smuzhiyun struct rtw_wifi_role_t *role)
1347*4882a593Smuzhiyun {
1348*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta = NULL;
1349*4882a593Smuzhiyun struct stainfo_ctl_t *sta_ctrl = phl_to_sta_ctrl(phl_info);
1350*4882a593Smuzhiyun
1351*4882a593Smuzhiyun PHL_DUMP_STACTRL_EX(phl_info);
1352*4882a593Smuzhiyun do {
1353*4882a593Smuzhiyun phl_sta = phl_stainfo_dequeue(phl_info, &role->assoc_sta_queue);
1354*4882a593Smuzhiyun
1355*4882a593Smuzhiyun if (phl_sta) {
1356*4882a593Smuzhiyun #ifdef RTW_WKARD_CHECK_STAINFO_DOUBLE_DEL
1357*4882a593Smuzhiyun phl_sta->allocated = false;
1358*4882a593Smuzhiyun #endif
1359*4882a593Smuzhiyun phl_free_stainfo_hw(phl_info, phl_sta);
1360*4882a593Smuzhiyun phl_free_stainfo_sw(phl_info, phl_sta);
1361*4882a593Smuzhiyun phl_stainfo_enqueue(phl_info,
1362*4882a593Smuzhiyun &sta_ctrl->free_sta_queue,
1363*4882a593Smuzhiyun phl_sta);
1364*4882a593Smuzhiyun }
1365*4882a593Smuzhiyun } while(phl_sta != NULL);
1366*4882a593Smuzhiyun
1367*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
1368*4882a593Smuzhiyun }
1369*4882a593Smuzhiyun
1370*4882a593Smuzhiyun /**
1371*4882a593Smuzhiyun * According to 802.11 spec 26.5.2.3.2
1372*4882a593Smuzhiyun * We shall not transmit HE TB PPDU with RU-26 on DFS channel
1373*4882a593Smuzhiyun */
1374*4882a593Smuzhiyun static void
_phl_set_dfs_tb_ctrl(struct phl_info_t * phl_info,struct rtw_wifi_role_t * wrole)1375*4882a593Smuzhiyun _phl_set_dfs_tb_ctrl(struct phl_info_t *phl_info,
1376*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
1377*4882a593Smuzhiyun {
1378*4882a593Smuzhiyun struct rtw_regulation_channel reg_ch = {0};
1379*4882a593Smuzhiyun enum band_type band = wrole->chandef.band;
1380*4882a593Smuzhiyun u8 channel = wrole->chandef.chan;
1381*4882a593Smuzhiyun bool is_dfs = false;
1382*4882a593Smuzhiyun
1383*4882a593Smuzhiyun
1384*4882a593Smuzhiyun if (rtw_phl_regulation_query_ch(phl_info, band, channel, ®_ch)) {
1385*4882a593Smuzhiyun if (reg_ch.property & CH_DFS)
1386*4882a593Smuzhiyun is_dfs = true;
1387*4882a593Smuzhiyun
1388*4882a593Smuzhiyun rtw_hal_set_dfs_tb_ctrl(phl_info->hal, is_dfs);
1389*4882a593Smuzhiyun }
1390*4882a593Smuzhiyun }
1391*4882a593Smuzhiyun
1392*4882a593Smuzhiyun static void
_phl_no_link_reset_sta_info(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta)1393*4882a593Smuzhiyun _phl_no_link_reset_sta_info(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta)
1394*4882a593Smuzhiyun {
1395*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
1396*4882a593Smuzhiyun
1397*4882a593Smuzhiyun /* asoc cap */
1398*4882a593Smuzhiyun _os_mem_set(drv, &sta->asoc_cap, 0, sizeof(struct protocol_cap_t));
1399*4882a593Smuzhiyun
1400*4882a593Smuzhiyun /* other capabilities under stainfo need to reset with default value */
1401*4882a593Smuzhiyun sta->tf_trs = 0;
1402*4882a593Smuzhiyun
1403*4882a593Smuzhiyun /* protection mode */
1404*4882a593Smuzhiyun sta->protect = RTW_PROTECT_DISABLE;
1405*4882a593Smuzhiyun }
1406*4882a593Smuzhiyun
1407*4882a593Smuzhiyun /**
1408*4882a593Smuzhiyun * This function is called once station associated with AP
1409*4882a593Smuzhiyun * or incoming station got associated under AP mode.
1410*4882a593Smuzhiyun * Before calling this function, update address / net_type / ...
1411*4882a593Smuzhiyun * information of stainfo
1412*4882a593Smuzhiyun * It will configure some hw register, ex
1413*4882a593Smuzhiyun * address cam
1414*4882a593Smuzhiyun * @phl: see phl_info_t
1415*4882a593Smuzhiyun * @stainfo: information is updated through phl_station_info
1416*4882a593Smuzhiyun */
1417*4882a593Smuzhiyun static enum rtw_phl_status
phl_update_media_status(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta,u8 * sta_addr,bool is_connect)1418*4882a593Smuzhiyun phl_update_media_status(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta,
1419*4882a593Smuzhiyun u8 *sta_addr, bool is_connect)
1420*4882a593Smuzhiyun {
1421*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = sta->wrole;
1422*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
1423*4882a593Smuzhiyun enum rtw_hal_status hstatus = RTW_HAL_STATUS_FAILURE;
1424*4882a593Smuzhiyun enum rtw_phl_status pstatus = RTW_PHL_STATUS_FAILURE;
1425*4882a593Smuzhiyun bool is_sta_linked = false;
1426*4882a593Smuzhiyun
1427*4882a593Smuzhiyun is_sta_linked = rtw_hal_is_sta_linked(phl_info->hal, sta);
1428*4882a593Smuzhiyun if (is_connect == true && is_sta_linked == true) {
1429*4882a593Smuzhiyun PHL_ERR("%s STA (MAC_ID:%d) had connected\n", __func__, sta->macid);
1430*4882a593Smuzhiyun goto _exit;
1431*4882a593Smuzhiyun }
1432*4882a593Smuzhiyun if (is_connect == false && is_sta_linked == false) {
1433*4882a593Smuzhiyun /* handle connect abort case */
1434*4882a593Smuzhiyun if (wrole->mstate == MLME_LINKING) {
1435*4882a593Smuzhiyun PHL_INFO("%s MAC_ID(%d) connect abort\n", __func__, sta->macid);
1436*4882a593Smuzhiyun pstatus = RTW_PHL_STATUS_SUCCESS;
1437*4882a593Smuzhiyun } else {
1438*4882a593Smuzhiyun PHL_ERR("%s MAC_ID(%d) had disconnected\n", __func__, sta->macid);
1439*4882a593Smuzhiyun }
1440*4882a593Smuzhiyun
1441*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION || wrole->type == PHL_RTYPE_P2P_GC)
1442*4882a593Smuzhiyun wrole->mstate = MLME_NO_LINK;
1443*4882a593Smuzhiyun goto _exit;
1444*4882a593Smuzhiyun }
1445*4882a593Smuzhiyun
1446*4882a593Smuzhiyun /* reset trx statistics */
1447*4882a593Smuzhiyun if (is_connect == false) {
1448*4882a593Smuzhiyun phl_reset_tx_stats(&sta->stats);
1449*4882a593Smuzhiyun phl_reset_rx_stats(&sta->stats);
1450*4882a593Smuzhiyun _phl_no_link_reset_sta_info(phl_info, sta);
1451*4882a593Smuzhiyun CLEAR_STATUS_FLAG(wrole->status, WR_STATUS_TSF_SYNC);
1452*4882a593Smuzhiyun } else {
1453*4882a593Smuzhiyun phl_clean_sta_bcn_info(phl_info, sta);
1454*4882a593Smuzhiyun }
1455*4882a593Smuzhiyun
1456*4882a593Smuzhiyun /* Configure address cam, including net_type and sync_tsf */
1457*4882a593Smuzhiyun if ((wrole->type == PHL_RTYPE_STATION) || (wrole->type == PHL_RTYPE_P2P_GC)
1458*4882a593Smuzhiyun #ifdef CONFIG_PHL_TDLS
1459*4882a593Smuzhiyun /* STA disconnects with the associated AP before tearing down with TDLS peers */
1460*4882a593Smuzhiyun || ((wrole->type == PHL_RTYPE_TDLS) && (!sta_addr))
1461*4882a593Smuzhiyun #endif
1462*4882a593Smuzhiyun ) {
1463*4882a593Smuzhiyun if (is_connect) {
1464*4882a593Smuzhiyun wrole->mstate = MLME_LINKED;
1465*4882a593Smuzhiyun _os_mem_cpy(drv, sta->mac_addr, sta_addr, MAC_ALEN);
1466*4882a593Smuzhiyun _phl_set_dfs_tb_ctrl(phl_info, wrole);
1467*4882a593Smuzhiyun } else {
1468*4882a593Smuzhiyun wrole->mstate = MLME_NO_LINK;
1469*4882a593Smuzhiyun }
1470*4882a593Smuzhiyun }
1471*4882a593Smuzhiyun #ifdef RTW_WKARD_AP_CLIENT_ADD_DEL_NTY
1472*4882a593Smuzhiyun else if ((wrole->type == PHL_RTYPE_AP) ||
1473*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_VAP) ||
1474*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_MESH) ||
1475*4882a593Smuzhiyun (wrole->type == PHL_RTYPE_P2P_GO)) {
1476*4882a593Smuzhiyun if (is_connect)
1477*4882a593Smuzhiyun phl_role_ap_client_notify(phl_info, wrole, MLME_LINKED);
1478*4882a593Smuzhiyun }
1479*4882a593Smuzhiyun #endif
1480*4882a593Smuzhiyun hstatus = rtw_hal_update_sta_entry(phl_info->hal, sta, is_connect);
1481*4882a593Smuzhiyun if (hstatus != RTW_HAL_STATUS_SUCCESS) {
1482*4882a593Smuzhiyun PHL_ERR("rtw_hal_update_sta_entry failure!\n");
1483*4882a593Smuzhiyun goto _exit;
1484*4882a593Smuzhiyun }
1485*4882a593Smuzhiyun
1486*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION
1487*4882a593Smuzhiyun #ifdef CONFIG_PHL_TDLS
1488*4882a593Smuzhiyun /* STA disconnects with the associated AP before tearing down with TDLS peers */
1489*4882a593Smuzhiyun || ((wrole->type == PHL_RTYPE_TDLS) && (!sta_addr))
1490*4882a593Smuzhiyun #endif
1491*4882a593Smuzhiyun ) {
1492*4882a593Smuzhiyun hstatus = rtw_hal_role_cfg(phl_info->hal, wrole);
1493*4882a593Smuzhiyun if (hstatus != RTW_HAL_STATUS_SUCCESS) {
1494*4882a593Smuzhiyun PHL_ERR("rtw_hal_role_cfg failure!\n");
1495*4882a593Smuzhiyun goto _exit;
1496*4882a593Smuzhiyun }
1497*4882a593Smuzhiyun }
1498*4882a593Smuzhiyun
1499*4882a593Smuzhiyun pstatus = RTW_PHL_STATUS_SUCCESS;
1500*4882a593Smuzhiyun
1501*4882a593Smuzhiyun /* TODO: Configure RCR */
1502*4882a593Smuzhiyun _exit:
1503*4882a593Smuzhiyun return pstatus;
1504*4882a593Smuzhiyun }
1505*4882a593Smuzhiyun
1506*4882a593Smuzhiyun #ifdef CONFIG_CMD_DISP
1507*4882a593Smuzhiyun struct sta_media_param {
1508*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta;
1509*4882a593Smuzhiyun u8 sta_addr[MAC_ALEN];
1510*4882a593Smuzhiyun bool is_connect;
1511*4882a593Smuzhiyun };
1512*4882a593Smuzhiyun
1513*4882a593Smuzhiyun enum rtw_phl_status
phl_update_media_status_hdl(struct phl_info_t * phl_info,u8 * param)1514*4882a593Smuzhiyun phl_update_media_status_hdl(struct phl_info_t *phl_info, u8 *param)
1515*4882a593Smuzhiyun {
1516*4882a593Smuzhiyun struct sta_media_param *media_sts = (struct sta_media_param *)param;
1517*4882a593Smuzhiyun
1518*4882a593Smuzhiyun return phl_update_media_status(phl_info,
1519*4882a593Smuzhiyun media_sts->sta, media_sts->sta_addr, media_sts->is_connect);
1520*4882a593Smuzhiyun }
1521*4882a593Smuzhiyun
phl_update_media_status_done(void * drv_priv,u8 * cmd,u32 cmd_len,enum rtw_phl_status status)1522*4882a593Smuzhiyun void phl_update_media_status_done(void *drv_priv, u8 *cmd, u32 cmd_len,
1523*4882a593Smuzhiyun enum rtw_phl_status status)
1524*4882a593Smuzhiyun {
1525*4882a593Smuzhiyun if (cmd) {
1526*4882a593Smuzhiyun _os_kmem_free(drv_priv, cmd, cmd_len);
1527*4882a593Smuzhiyun cmd = NULL;
1528*4882a593Smuzhiyun }
1529*4882a593Smuzhiyun }
1530*4882a593Smuzhiyun #endif
1531*4882a593Smuzhiyun
1532*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_cmd_update_media_status(void * phl,struct rtw_phl_stainfo_t * sta,u8 * sta_addr,bool is_connect,enum phl_cmd_type cmd_type,u32 cmd_timeout)1533*4882a593Smuzhiyun rtw_phl_cmd_update_media_status(void *phl,
1534*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta,
1535*4882a593Smuzhiyun u8 *sta_addr,
1536*4882a593Smuzhiyun bool is_connect,
1537*4882a593Smuzhiyun enum phl_cmd_type cmd_type,
1538*4882a593Smuzhiyun u32 cmd_timeout)
1539*4882a593Smuzhiyun {
1540*4882a593Smuzhiyun #ifdef CONFIG_CMD_DISP
1541*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
1542*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1543*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
1544*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = NULL;
1545*4882a593Smuzhiyun struct sta_media_param *sta_ms = NULL;
1546*4882a593Smuzhiyun u32 sta_ms_len = 0;
1547*4882a593Smuzhiyun
1548*4882a593Smuzhiyun if (cmd_type == PHL_CMD_DIRECTLY) {
1549*4882a593Smuzhiyun psts = phl_update_media_status(phl_info, sta, sta_addr, is_connect);
1550*4882a593Smuzhiyun goto _exit;
1551*4882a593Smuzhiyun }
1552*4882a593Smuzhiyun
1553*4882a593Smuzhiyun sta_ms_len = sizeof(struct sta_media_param);
1554*4882a593Smuzhiyun sta_ms = _os_kmem_alloc(drv, sta_ms_len);
1555*4882a593Smuzhiyun if (sta_ms == NULL) {
1556*4882a593Smuzhiyun PHL_ERR("%s: alloc sta media status param failed!\n", __func__);
1557*4882a593Smuzhiyun psts = RTW_PHL_STATUS_RESOURCE;
1558*4882a593Smuzhiyun goto _exit;
1559*4882a593Smuzhiyun }
1560*4882a593Smuzhiyun _os_mem_set(drv, sta_ms, 0, sta_ms_len);
1561*4882a593Smuzhiyun sta_ms->sta = sta;
1562*4882a593Smuzhiyun sta_ms->is_connect = is_connect;
1563*4882a593Smuzhiyun if (is_connect && sta_addr)
1564*4882a593Smuzhiyun _os_mem_cpy(drv, sta_ms->sta_addr, sta_addr, MAC_ALEN);
1565*4882a593Smuzhiyun
1566*4882a593Smuzhiyun wrole = sta->wrole;
1567*4882a593Smuzhiyun
1568*4882a593Smuzhiyun psts = phl_cmd_enqueue(phl_info,
1569*4882a593Smuzhiyun wrole->hw_band,
1570*4882a593Smuzhiyun MSG_EVT_STA_MEDIA_STATUS_UPT,
1571*4882a593Smuzhiyun (u8*)sta_ms,
1572*4882a593Smuzhiyun sta_ms_len,
1573*4882a593Smuzhiyun phl_update_media_status_done,
1574*4882a593Smuzhiyun cmd_type,
1575*4882a593Smuzhiyun cmd_timeout);
1576*4882a593Smuzhiyun
1577*4882a593Smuzhiyun if (is_cmd_failure(psts)) {
1578*4882a593Smuzhiyun /* Send cmd success, but wait cmd fail*/
1579*4882a593Smuzhiyun psts = RTW_PHL_STATUS_FAILURE;
1580*4882a593Smuzhiyun } else if (psts != RTW_PHL_STATUS_SUCCESS) {
1581*4882a593Smuzhiyun /* Send cmd fail */
1582*4882a593Smuzhiyun psts = RTW_PHL_STATUS_FAILURE;
1583*4882a593Smuzhiyun _os_kmem_free(drv, sta_ms, sta_ms_len);
1584*4882a593Smuzhiyun }
1585*4882a593Smuzhiyun _exit:
1586*4882a593Smuzhiyun return psts;
1587*4882a593Smuzhiyun #else
1588*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "%s: not support cmd to update media status\n",
1589*4882a593Smuzhiyun __func__);
1590*4882a593Smuzhiyun
1591*4882a593Smuzhiyun return phl_update_media_status((struct phl_info_t *)phl, sta, sta_addr, is_connect);
1592*4882a593Smuzhiyun #endif
1593*4882a593Smuzhiyun }
1594*4882a593Smuzhiyun
1595*4882a593Smuzhiyun /**
1596*4882a593Smuzhiyun * This function is called once station info changed
1597*4882a593Smuzhiyun * (BW/NSS/RAMASK/SEC/ROLE/MACADDR........)
1598*4882a593Smuzhiyun * @phl: see phl_info_t
1599*4882a593Smuzhiyun * @stainfo: information is updated through phl_station_info
1600*4882a593Smuzhiyun * @mode: see phl_upd_mode
1601*4882a593Smuzhiyun */
1602*4882a593Smuzhiyun enum rtw_phl_status
phl_change_stainfo(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta,enum phl_upd_mode mode)1603*4882a593Smuzhiyun phl_change_stainfo(struct phl_info_t *phl_info, struct rtw_phl_stainfo_t *sta,
1604*4882a593Smuzhiyun enum phl_upd_mode mode)
1605*4882a593Smuzhiyun {
1606*4882a593Smuzhiyun enum rtw_hal_status hstatus = RTW_HAL_STATUS_FAILURE;
1607*4882a593Smuzhiyun
1608*4882a593Smuzhiyun hstatus = rtw_hal_change_sta_entry(phl_info->hal, sta, mode);
1609*4882a593Smuzhiyun if (hstatus != RTW_HAL_STATUS_SUCCESS) {
1610*4882a593Smuzhiyun PHL_ERR("rtw_hal_change_sta_entry failure!\n");
1611*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
1612*4882a593Smuzhiyun }
1613*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
1614*4882a593Smuzhiyun }
1615*4882a593Smuzhiyun
1616*4882a593Smuzhiyun static enum rtw_phl_status
_change_stainfo(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta,enum sta_chg_id chg_id,u8 * chg_info,u8 chg_info_len)1617*4882a593Smuzhiyun _change_stainfo(struct phl_info_t *phl_info,
1618*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta, enum sta_chg_id chg_id, u8 *chg_info, u8 chg_info_len)
1619*4882a593Smuzhiyun {
1620*4882a593Smuzhiyun enum phl_upd_mode mode = PHL_UPD_STA_INFO_CHANGE;
1621*4882a593Smuzhiyun
1622*4882a593Smuzhiyun switch (chg_id) {
1623*4882a593Smuzhiyun case STA_CHG_BW:
1624*4882a593Smuzhiyun case STA_CHG_NSS:
1625*4882a593Smuzhiyun case STA_CHG_RAMASK:
1626*4882a593Smuzhiyun {
1627*4882a593Smuzhiyun PHL_INFO("%s MACID:%d %02x:%02x:%02x:%02x:%02x:%02x update bw\n",
1628*4882a593Smuzhiyun __func__, sta->macid,
1629*4882a593Smuzhiyun sta->mac_addr[0], sta->mac_addr[1], sta->mac_addr[2],
1630*4882a593Smuzhiyun sta->mac_addr[3], sta->mac_addr[4], sta->mac_addr[5]);
1631*4882a593Smuzhiyun }
1632*4882a593Smuzhiyun break;
1633*4882a593Smuzhiyun case STA_CHG_SEC_MODE:
1634*4882a593Smuzhiyun sta->sec_mode = *((u8*)chg_info);
1635*4882a593Smuzhiyun break;
1636*4882a593Smuzhiyun case STA_CHG_MBSSID:
1637*4882a593Smuzhiyun sta->addr_sel = 1;
1638*4882a593Smuzhiyun sta->addr_msk = *((u8*)chg_info);
1639*4882a593Smuzhiyun break;
1640*4882a593Smuzhiyun case STA_CHG_RA_GILTF:
1641*4882a593Smuzhiyun sta->hal_sta->ra_info.cal_giltf = *((u8*)chg_info);
1642*4882a593Smuzhiyun sta->hal_sta->ra_info.fix_giltf_en = true;
1643*4882a593Smuzhiyun PHL_INFO("%s: Config RA GI LTF = %d\n", __FUNCTION__, *((u8*)chg_info));
1644*4882a593Smuzhiyun break;
1645*4882a593Smuzhiyun case STA_CHG_MAX:
1646*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_DEBUG_, "rtw_phl_change_stainfo(): Unsupported case:%d, please check it\n",
1647*4882a593Smuzhiyun chg_id);
1648*4882a593Smuzhiyun break;
1649*4882a593Smuzhiyun default:
1650*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_DEBUG_, "rtw_phl_change_stainfo(): Unrecognize case:%d, please check it\n",
1651*4882a593Smuzhiyun chg_id);
1652*4882a593Smuzhiyun break;
1653*4882a593Smuzhiyun }
1654*4882a593Smuzhiyun
1655*4882a593Smuzhiyun return phl_change_stainfo(phl_info, sta, mode);
1656*4882a593Smuzhiyun }
1657*4882a593Smuzhiyun
1658*4882a593Smuzhiyun #ifdef CONFIG_CMD_DISP
1659*4882a593Smuzhiyun struct sta_chg_param {
1660*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta;
1661*4882a593Smuzhiyun enum sta_chg_id id;
1662*4882a593Smuzhiyun u8 *info;
1663*4882a593Smuzhiyun u8 info_len;
1664*4882a593Smuzhiyun };
1665*4882a593Smuzhiyun
1666*4882a593Smuzhiyun enum rtw_phl_status
phl_cmd_change_stainfo_hdl(struct phl_info_t * phl_info,u8 * param)1667*4882a593Smuzhiyun phl_cmd_change_stainfo_hdl(struct phl_info_t *phl_info, u8 *param)
1668*4882a593Smuzhiyun {
1669*4882a593Smuzhiyun struct sta_chg_param *sta_param = (struct sta_chg_param *)param;
1670*4882a593Smuzhiyun
1671*4882a593Smuzhiyun return _change_stainfo(phl_info,
1672*4882a593Smuzhiyun sta_param->sta, sta_param->id,
1673*4882a593Smuzhiyun sta_param->info, sta_param->info_len);
1674*4882a593Smuzhiyun }
1675*4882a593Smuzhiyun
1676*4882a593Smuzhiyun static void
_phl_cmd_change_stainfo_done(void * drv_priv,u8 * cmd,u32 cmd_len,enum rtw_phl_status status)1677*4882a593Smuzhiyun _phl_cmd_change_stainfo_done(void *drv_priv, u8 *cmd, u32 cmd_len,
1678*4882a593Smuzhiyun enum rtw_phl_status status)
1679*4882a593Smuzhiyun {
1680*4882a593Smuzhiyun struct sta_chg_param *sta_chg_info = NULL;
1681*4882a593Smuzhiyun
1682*4882a593Smuzhiyun if (cmd == NULL || cmd_len == 0) {
1683*4882a593Smuzhiyun PHL_ERR("%s buf == NULL || buf_len == 0\n", __func__);
1684*4882a593Smuzhiyun _os_warn_on(1);
1685*4882a593Smuzhiyun return;
1686*4882a593Smuzhiyun }
1687*4882a593Smuzhiyun
1688*4882a593Smuzhiyun sta_chg_info = (struct sta_chg_param *)cmd;
1689*4882a593Smuzhiyun PHL_INFO("%s - id:%d .....\n", __func__, sta_chg_info->id);
1690*4882a593Smuzhiyun
1691*4882a593Smuzhiyun if (sta_chg_info->info && sta_chg_info->info_len > 0)
1692*4882a593Smuzhiyun _os_kmem_free(drv_priv, sta_chg_info->info, sta_chg_info->info_len);
1693*4882a593Smuzhiyun
1694*4882a593Smuzhiyun _os_kmem_free(drv_priv, cmd, cmd_len);
1695*4882a593Smuzhiyun cmd = NULL;
1696*4882a593Smuzhiyun }
1697*4882a593Smuzhiyun
1698*4882a593Smuzhiyun static enum rtw_phl_status
_phl_cmd_change_stainfo(struct phl_info_t * phl_info,struct rtw_phl_stainfo_t * sta,enum sta_chg_id chg_id,u8 * chg_info,u8 chg_info_len,enum phl_cmd_type cmd_type,u32 cmd_timeout)1699*4882a593Smuzhiyun _phl_cmd_change_stainfo(struct phl_info_t *phl_info,
1700*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta, enum sta_chg_id chg_id,
1701*4882a593Smuzhiyun u8 *chg_info, u8 chg_info_len,
1702*4882a593Smuzhiyun enum phl_cmd_type cmd_type, u32 cmd_timeout)
1703*4882a593Smuzhiyun {
1704*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
1705*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
1706*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = sta->wrole;
1707*4882a593Smuzhiyun struct sta_chg_param *param = NULL;
1708*4882a593Smuzhiyun u8 param_len = 0;
1709*4882a593Smuzhiyun
1710*4882a593Smuzhiyun if (cmd_type == PHL_CMD_DIRECTLY) {
1711*4882a593Smuzhiyun psts = _change_stainfo(phl_info, sta, chg_id, chg_info, chg_info_len);
1712*4882a593Smuzhiyun goto _exit;
1713*4882a593Smuzhiyun }
1714*4882a593Smuzhiyun
1715*4882a593Smuzhiyun param_len = sizeof(struct sta_chg_param);
1716*4882a593Smuzhiyun param = _os_kmem_alloc(drv, param_len);
1717*4882a593Smuzhiyun if (param == NULL) {
1718*4882a593Smuzhiyun PHL_ERR("%s: alloc param failed!\n", __func__);
1719*4882a593Smuzhiyun psts = RTW_PHL_STATUS_RESOURCE;
1720*4882a593Smuzhiyun goto _exit;
1721*4882a593Smuzhiyun }
1722*4882a593Smuzhiyun
1723*4882a593Smuzhiyun _os_mem_set(drv, param, 0, param_len);
1724*4882a593Smuzhiyun param->sta = sta;
1725*4882a593Smuzhiyun param->id = chg_id;
1726*4882a593Smuzhiyun param->info_len = chg_info_len;
1727*4882a593Smuzhiyun
1728*4882a593Smuzhiyun if (chg_info_len > 0) {
1729*4882a593Smuzhiyun param->info = _os_kmem_alloc(drv, chg_info_len);
1730*4882a593Smuzhiyun if (param->info == NULL) {
1731*4882a593Smuzhiyun PHL_ERR("%s: alloc param->info failed!\n", __func__);
1732*4882a593Smuzhiyun psts = RTW_PHL_STATUS_RESOURCE;
1733*4882a593Smuzhiyun goto _err_info;
1734*4882a593Smuzhiyun }
1735*4882a593Smuzhiyun
1736*4882a593Smuzhiyun _os_mem_set(drv, param->info, 0, chg_info_len);
1737*4882a593Smuzhiyun _os_mem_cpy(drv, param->info, chg_info, chg_info_len);
1738*4882a593Smuzhiyun } else {
1739*4882a593Smuzhiyun param->info = NULL;
1740*4882a593Smuzhiyun }
1741*4882a593Smuzhiyun
1742*4882a593Smuzhiyun psts = phl_cmd_enqueue(phl_info,
1743*4882a593Smuzhiyun wrole->hw_band,
1744*4882a593Smuzhiyun MSG_EVT_STA_CHG_STAINFO,
1745*4882a593Smuzhiyun (u8 *)param,
1746*4882a593Smuzhiyun param_len,
1747*4882a593Smuzhiyun _phl_cmd_change_stainfo_done,
1748*4882a593Smuzhiyun cmd_type,
1749*4882a593Smuzhiyun cmd_timeout);
1750*4882a593Smuzhiyun
1751*4882a593Smuzhiyun if (is_cmd_failure(psts)) {
1752*4882a593Smuzhiyun /* Send cmd success, but wait cmd fail*/
1753*4882a593Smuzhiyun psts = RTW_PHL_STATUS_FAILURE;
1754*4882a593Smuzhiyun } else if (psts != RTW_PHL_STATUS_SUCCESS) {
1755*4882a593Smuzhiyun /* Send cmd fail */
1756*4882a593Smuzhiyun psts = RTW_PHL_STATUS_FAILURE;
1757*4882a593Smuzhiyun goto _err_cmd;
1758*4882a593Smuzhiyun }
1759*4882a593Smuzhiyun
1760*4882a593Smuzhiyun return psts;
1761*4882a593Smuzhiyun
1762*4882a593Smuzhiyun _err_cmd:
1763*4882a593Smuzhiyun if (param->info)
1764*4882a593Smuzhiyun _os_kmem_free(drv, param->info, param->info_len);
1765*4882a593Smuzhiyun _err_info:
1766*4882a593Smuzhiyun if (param)
1767*4882a593Smuzhiyun _os_kmem_free(drv, param, param_len);
1768*4882a593Smuzhiyun _exit:
1769*4882a593Smuzhiyun return psts;
1770*4882a593Smuzhiyun }
1771*4882a593Smuzhiyun #endif
1772*4882a593Smuzhiyun
1773*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_cmd_change_stainfo(void * phl,struct rtw_phl_stainfo_t * sta,enum sta_chg_id chg_id,u8 * chg_info,u8 chg_info_len,enum phl_cmd_type cmd_type,u32 cmd_timeout)1774*4882a593Smuzhiyun rtw_phl_cmd_change_stainfo(void *phl,
1775*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta, enum sta_chg_id chg_id,
1776*4882a593Smuzhiyun u8 *chg_info, u8 chg_info_len,
1777*4882a593Smuzhiyun enum phl_cmd_type cmd_type, u32 cmd_timeout)
1778*4882a593Smuzhiyun {
1779*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1780*4882a593Smuzhiyun
1781*4882a593Smuzhiyun #ifdef CONFIG_CMD_DISP
1782*4882a593Smuzhiyun return _phl_cmd_change_stainfo(phl_info, sta, chg_id, chg_info, chg_info_len,
1783*4882a593Smuzhiyun cmd_type, cmd_timeout);
1784*4882a593Smuzhiyun #else
1785*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "%s: not support alloc stainfo cmd\n",
1786*4882a593Smuzhiyun __func__);
1787*4882a593Smuzhiyun
1788*4882a593Smuzhiyun return _change_stainfo(phl_info, sta, chg_id, chg_info, chg_info_len);
1789*4882a593Smuzhiyun #endif /* CONFIG_CMD_DISP */
1790*4882a593Smuzhiyun }
1791*4882a593Smuzhiyun /**
1792*4882a593Smuzhiyun * This function updates tx/rx traffic status of each active station info
1793*4882a593Smuzhiyun */
1794*4882a593Smuzhiyun void
phl_sta_trx_tfc_upd(struct phl_info_t * phl_info)1795*4882a593Smuzhiyun phl_sta_trx_tfc_upd(struct phl_info_t *phl_info)
1796*4882a593Smuzhiyun {
1797*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
1798*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta = NULL;
1799*4882a593Smuzhiyun struct rtw_stats *sta_stats = NULL;
1800*4882a593Smuzhiyun u16 max_macid_num = 0;
1801*4882a593Smuzhiyun u16 mid = 0;
1802*4882a593Smuzhiyun
1803*4882a593Smuzhiyun max_macid_num = macid_ctl->max_num;
1804*4882a593Smuzhiyun
1805*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
1806*4882a593Smuzhiyun for(mid = 0; mid < max_macid_num; mid++) {
1807*4882a593Smuzhiyun if (_phl_macid_is_used(macid_ctl->used_map, mid)) {
1808*4882a593Smuzhiyun phl_sta = macid_ctl->sta[mid];
1809*4882a593Smuzhiyun if (phl_sta) {
1810*4882a593Smuzhiyun #ifdef CONFIG_PHL_RA_TXSTS_DBG
1811*4882a593Smuzhiyun /* issue H2C to get ra txsts report */
1812*4882a593Smuzhiyun rtw_phl_txsts_rpt_config(phl_info, phl_sta);
1813*4882a593Smuzhiyun #endif
1814*4882a593Smuzhiyun sta_stats = &phl_sta->stats;
1815*4882a593Smuzhiyun phl_tx_traffic_upd(sta_stats);
1816*4882a593Smuzhiyun phl_rx_traffic_upd(sta_stats);
1817*4882a593Smuzhiyun }
1818*4882a593Smuzhiyun }
1819*4882a593Smuzhiyun }
1820*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
1821*4882a593Smuzhiyun }
1822*4882a593Smuzhiyun
1823*4882a593Smuzhiyun
1824*4882a593Smuzhiyun /**
1825*4882a593Smuzhiyun * This function is used to get phl sta info
1826*4882a593Smuzhiyun * by macid
1827*4882a593Smuzhiyun * @phl: see phl_info_t
1828*4882a593Smuzhiyun * @macid: macid
1829*4882a593Smuzhiyun */
1830*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
rtw_phl_get_stainfo_by_macid(void * phl,u16 macid)1831*4882a593Smuzhiyun rtw_phl_get_stainfo_by_macid(void *phl, u16 macid)
1832*4882a593Smuzhiyun {
1833*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1834*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
1835*4882a593Smuzhiyun struct rtw_phl_stainfo_t *phl_sta = NULL;
1836*4882a593Smuzhiyun
1837*4882a593Smuzhiyun if (macid >= macid_ctl->max_num) {
1838*4882a593Smuzhiyun PHL_ERR("%s macid(%d) is invalid\n", __func__, macid);
1839*4882a593Smuzhiyun return NULL;
1840*4882a593Smuzhiyun }
1841*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
1842*4882a593Smuzhiyun if (_phl_macid_is_used(macid_ctl->used_map, macid))
1843*4882a593Smuzhiyun phl_sta = macid_ctl->sta[macid];
1844*4882a593Smuzhiyun
1845*4882a593Smuzhiyun if (phl_sta == NULL) {
1846*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_DEBUG_,"%s sta info (macid:%d) is NULL\n", __func__, macid);
1847*4882a593Smuzhiyun #ifdef CONFIG_PHL_RELEASE_RPT_ENABLE
1848*4882a593Smuzhiyun /* comment temporarily since release report may report unused macid */
1849*4882a593Smuzhiyun /* and trigger call tracing */
1850*4882a593Smuzhiyun /* _os_warn_on(1); */
1851*4882a593Smuzhiyun #else
1852*4882a593Smuzhiyun _os_warn_on(1);
1853*4882a593Smuzhiyun #endif /* CONFIG_PHL_RELEASE_RPT_ENABLE */
1854*4882a593Smuzhiyun }
1855*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &macid_ctl->lock, _bh, NULL);
1856*4882a593Smuzhiyun
1857*4882a593Smuzhiyun return phl_sta;
1858*4882a593Smuzhiyun }
1859*4882a593Smuzhiyun
1860*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
rtw_phl_get_stainfo_by_addr_ex(void * phl,u8 * addr)1861*4882a593Smuzhiyun rtw_phl_get_stainfo_by_addr_ex(void *phl, u8 *addr)
1862*4882a593Smuzhiyun {
1863*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1864*4882a593Smuzhiyun struct macid_ctl_t *mc = phl_to_mac_ctrl(phl_info);
1865*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
1866*4882a593Smuzhiyun u16 mid = 0;
1867*4882a593Smuzhiyun u16 max_macid_num = mc->max_num;
1868*4882a593Smuzhiyun bool sta_found = false;
1869*4882a593Smuzhiyun
1870*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &mc->lock, _bh, NULL);
1871*4882a593Smuzhiyun for(mid = 0; mid < max_macid_num; mid++) {
1872*4882a593Smuzhiyun if (_phl_macid_is_used(mc->used_map, mid)) {
1873*4882a593Smuzhiyun sta = mc->sta[mid];
1874*4882a593Smuzhiyun if (_os_mem_cmp(phl_to_drvpriv(phl_info),
1875*4882a593Smuzhiyun sta->mac_addr, addr, MAC_ALEN) == 0) {
1876*4882a593Smuzhiyun sta_found = true;
1877*4882a593Smuzhiyun break;
1878*4882a593Smuzhiyun }
1879*4882a593Smuzhiyun }
1880*4882a593Smuzhiyun }
1881*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &mc->lock, _bh, NULL);
1882*4882a593Smuzhiyun
1883*4882a593Smuzhiyun if (sta_found == false)
1884*4882a593Smuzhiyun sta = NULL;
1885*4882a593Smuzhiyun return sta;
1886*4882a593Smuzhiyun }
1887*4882a593Smuzhiyun
rtw_phl_get_macid_by_addr(void * phl,u8 * addr)1888*4882a593Smuzhiyun u16 rtw_phl_get_macid_by_addr(void *phl, u8 *addr)
1889*4882a593Smuzhiyun {
1890*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1891*4882a593Smuzhiyun struct macid_ctl_t *mc = phl_to_mac_ctrl(phl_info);
1892*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
1893*4882a593Smuzhiyun
1894*4882a593Smuzhiyun sta = rtw_phl_get_stainfo_by_addr_ex(phl, addr);
1895*4882a593Smuzhiyun if (sta)
1896*4882a593Smuzhiyun return sta->macid;
1897*4882a593Smuzhiyun return mc->max_num;
1898*4882a593Smuzhiyun }
1899*4882a593Smuzhiyun
1900*4882a593Smuzhiyun /**
1901*4882a593Smuzhiyun * This function is called to create phl_station_info
1902*4882a593Smuzhiyun * return pointer to rtw_phl_stainfo_t
1903*4882a593Smuzhiyun * @phl: see phl_info_t
1904*4882a593Smuzhiyun * @roleidx: index of wifi role(linux) port nubmer(windows)
1905*4882a593Smuzhiyun * @addr: current address of this station
1906*4882a593Smuzhiyun */
1907*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
rtw_phl_get_stainfo_by_addr(void * phl,struct rtw_wifi_role_t * wrole,u8 * addr)1908*4882a593Smuzhiyun rtw_phl_get_stainfo_by_addr(void *phl, struct rtw_wifi_role_t *wrole, u8 *addr)
1909*4882a593Smuzhiyun {
1910*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1911*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
1912*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
1913*4882a593Smuzhiyun
1914*4882a593Smuzhiyun if (is_broadcast_mac_addr(addr)) {
1915*4882a593Smuzhiyun u16 macid = macid_ctl->wrole_bmc[wrole->id];
1916*4882a593Smuzhiyun
1917*4882a593Smuzhiyun if (macid >= macid_ctl->max_num)
1918*4882a593Smuzhiyun sta = NULL;
1919*4882a593Smuzhiyun else
1920*4882a593Smuzhiyun sta = macid_ctl->sta[macid];
1921*4882a593Smuzhiyun goto _exit;
1922*4882a593Smuzhiyun }
1923*4882a593Smuzhiyun
1924*4882a593Smuzhiyun sta = phl_stainfo_queue_search(phl_info,
1925*4882a593Smuzhiyun &wrole->assoc_sta_queue, addr);
1926*4882a593Smuzhiyun _exit:
1927*4882a593Smuzhiyun return sta;
1928*4882a593Smuzhiyun }
1929*4882a593Smuzhiyun
1930*4882a593Smuzhiyun struct rtw_phl_stainfo_t *
rtw_phl_get_stainfo_self(void * phl,struct rtw_wifi_role_t * wrole)1931*4882a593Smuzhiyun rtw_phl_get_stainfo_self(void *phl, struct rtw_wifi_role_t *wrole)
1932*4882a593Smuzhiyun {
1933*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1934*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
1935*4882a593Smuzhiyun
1936*4882a593Smuzhiyun #if 0
1937*4882a593Smuzhiyun if ((wrole->type == PHL_RTYPE_STATION) &&
1938*4882a593Smuzhiyun (wrole->mstate == MLME_LINKED))
1939*4882a593Smuzhiyun //????
1940*4882a593Smuzhiyun else
1941*4882a593Smuzhiyun sta = phl_stainfo_queue_search(phl_info,
1942*4882a593Smuzhiyun &wrole->assoc_sta_queue, wrole->mac_addr);
1943*4882a593Smuzhiyun }
1944*4882a593Smuzhiyun #else
1945*4882a593Smuzhiyun sta = phl_stainfo_queue_get_first(phl_info, &wrole->assoc_sta_queue);
1946*4882a593Smuzhiyun if (sta == NULL)
1947*4882a593Smuzhiyun PHL_ERR("%s sta == NULL\n", __func__);
1948*4882a593Smuzhiyun #endif
1949*4882a593Smuzhiyun return sta;
1950*4882a593Smuzhiyun }
1951*4882a593Smuzhiyun
1952*4882a593Smuzhiyun u8
rtw_phl_get_sta_rssi(struct rtw_phl_stainfo_t * sta)1953*4882a593Smuzhiyun rtw_phl_get_sta_rssi(struct rtw_phl_stainfo_t *sta)
1954*4882a593Smuzhiyun {
1955*4882a593Smuzhiyun u8 rssi = rtw_hal_get_sta_rssi(sta);
1956*4882a593Smuzhiyun
1957*4882a593Smuzhiyun return rssi;
1958*4882a593Smuzhiyun }
1959*4882a593Smuzhiyun
phl_get_min_rssi_bcn(struct phl_info_t * phl_info)1960*4882a593Smuzhiyun u8 phl_get_min_rssi_bcn(struct phl_info_t *phl_info)
1961*4882a593Smuzhiyun {
1962*4882a593Smuzhiyun struct macid_ctl_t *macid_ctl = phl_to_mac_ctrl(phl_info);
1963*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = NULL;
1964*4882a593Smuzhiyun u8 rssi_bcn_min = 0xFF;
1965*4882a593Smuzhiyun u16 i = 0;
1966*4882a593Smuzhiyun u8 rssi = 0;
1967*4882a593Smuzhiyun
1968*4882a593Smuzhiyun for (i = 0; i < macid_ctl->max_num; i++) {
1969*4882a593Smuzhiyun if (!_phl_macid_is_used(macid_ctl->used_map, i))
1970*4882a593Smuzhiyun continue;
1971*4882a593Smuzhiyun
1972*4882a593Smuzhiyun sta = rtw_phl_get_stainfo_by_macid(phl_info, i);
1973*4882a593Smuzhiyun
1974*4882a593Smuzhiyun if (NULL == sta)
1975*4882a593Smuzhiyun continue;
1976*4882a593Smuzhiyun
1977*4882a593Smuzhiyun rssi = rtw_hal_get_sta_rssi_bcn(sta);
1978*4882a593Smuzhiyun
1979*4882a593Smuzhiyun PHL_DBG("%s macid(%d) with rssi_bcn = %d\n",
1980*4882a593Smuzhiyun __func__, i, rssi);
1981*4882a593Smuzhiyun
1982*4882a593Smuzhiyun if (rssi == 0)
1983*4882a593Smuzhiyun continue;
1984*4882a593Smuzhiyun
1985*4882a593Smuzhiyun rssi_bcn_min = MIN(rssi, rssi_bcn_min);
1986*4882a593Smuzhiyun }
1987*4882a593Smuzhiyun
1988*4882a593Smuzhiyun return rssi_bcn_min;
1989*4882a593Smuzhiyun }
1990*4882a593Smuzhiyun
1991*4882a593Smuzhiyun
1992*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_query_rainfo(void * phl,struct rtw_phl_stainfo_t * phl_sta,struct rtw_phl_rainfo * ra_info)1993*4882a593Smuzhiyun rtw_phl_query_rainfo(void *phl, struct rtw_phl_stainfo_t *phl_sta,
1994*4882a593Smuzhiyun struct rtw_phl_rainfo *ra_info)
1995*4882a593Smuzhiyun {
1996*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
1997*4882a593Smuzhiyun enum rtw_phl_status phl_sts = RTW_PHL_STATUS_FAILURE;
1998*4882a593Smuzhiyun
1999*4882a593Smuzhiyun do {
2000*4882a593Smuzhiyun if (NULL == phl_sta) {
2001*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_XMIT, _PHL_ERR_,
2002*4882a593Smuzhiyun "%s : phl_sta is NULL\n",
2003*4882a593Smuzhiyun __func__);
2004*4882a593Smuzhiyun break;
2005*4882a593Smuzhiyun }
2006*4882a593Smuzhiyun
2007*4882a593Smuzhiyun if (NULL == ra_info) {
2008*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_XMIT, _PHL_ERR_,
2009*4882a593Smuzhiyun "%s : Input parameter is NULL\n",
2010*4882a593Smuzhiyun __func__);
2011*4882a593Smuzhiyun break;
2012*4882a593Smuzhiyun }
2013*4882a593Smuzhiyun
2014*4882a593Smuzhiyun if (RTW_HAL_STATUS_SUCCESS ==
2015*4882a593Smuzhiyun rtw_hal_query_rainfo(phl_info->hal, phl_sta->hal_sta,
2016*4882a593Smuzhiyun ra_info)) {
2017*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_SUCCESS;
2018*4882a593Smuzhiyun break;
2019*4882a593Smuzhiyun } else {
2020*4882a593Smuzhiyun break;
2021*4882a593Smuzhiyun }
2022*4882a593Smuzhiyun } while (false);
2023*4882a593Smuzhiyun
2024*4882a593Smuzhiyun return phl_sts;
2025*4882a593Smuzhiyun }
2026*4882a593Smuzhiyun
2027*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_get_rx_stat(void * phl,struct rtw_phl_stainfo_t * phl_sta,u16 * rx_rate,u8 * bw,u8 * gi_ltf)2028*4882a593Smuzhiyun rtw_phl_get_rx_stat(void *phl, struct rtw_phl_stainfo_t *phl_sta,
2029*4882a593Smuzhiyun u16 *rx_rate, u8 *bw, u8 *gi_ltf)
2030*4882a593Smuzhiyun {
2031*4882a593Smuzhiyun enum rtw_phl_status phl_sts = RTW_PHL_STATUS_FAILURE;
2032*4882a593Smuzhiyun struct rtw_hal_stainfo_t *hal_sta;
2033*4882a593Smuzhiyun
2034*4882a593Smuzhiyun if(phl_sta) {
2035*4882a593Smuzhiyun hal_sta = phl_sta->hal_sta;
2036*4882a593Smuzhiyun *rx_rate = hal_sta->trx_stat.rx_rate;
2037*4882a593Smuzhiyun *gi_ltf = hal_sta->trx_stat.rx_gi_ltf;
2038*4882a593Smuzhiyun *bw = hal_sta->trx_stat.rx_bw;
2039*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_SUCCESS;
2040*4882a593Smuzhiyun }
2041*4882a593Smuzhiyun
2042*4882a593Smuzhiyun return phl_sts;
2043*4882a593Smuzhiyun }
2044*4882a593Smuzhiyun
2045*4882a593Smuzhiyun /**
2046*4882a593Smuzhiyun * rtw_phl_txsts_rpt_config() - issue h2c for txok and tx retry info
2047*4882a593Smuzhiyun * @phl: struct phl_info_t *
2048*4882a593Smuzhiyun * @phl_sta: indicate the first macid that you want to query.
2049*4882a593Smuzhiyun * Return rtw_phl_txsts_rpt_config's return value in enum rtw_phl_status type.
2050*4882a593Smuzhiyun */
2051*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_txsts_rpt_config(void * phl,struct rtw_phl_stainfo_t * phl_sta)2052*4882a593Smuzhiyun rtw_phl_txsts_rpt_config(void *phl, struct rtw_phl_stainfo_t *phl_sta)
2053*4882a593Smuzhiyun {
2054*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
2055*4882a593Smuzhiyun enum rtw_phl_status phl_sts = RTW_PHL_STATUS_FAILURE;
2056*4882a593Smuzhiyun
2057*4882a593Smuzhiyun if (phl_sta) {
2058*4882a593Smuzhiyun if (RTW_HAL_STATUS_SUCCESS == rtw_hal_query_txsts_rpt(phl_info->hal, phl_sta->macid))
2059*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_SUCCESS;
2060*4882a593Smuzhiyun }
2061*4882a593Smuzhiyun return phl_sts;
2062*4882a593Smuzhiyun }
2063*4882a593Smuzhiyun
2064*4882a593Smuzhiyun #if defined(CONFIG_USB_HCI) || defined(CONFIG_PCI_HCI)
2065*4882a593Smuzhiyun /**
2066*4882a593Smuzhiyun * rtw_phl_get_tx_ok_rpt() - get txok info.
2067*4882a593Smuzhiyun * @phl: struct phl_info_t *
2068*4882a593Smuzhiyun * @phl_sta: information is updated through phl_station_info.
2069*4882a593Smuzhiyun * @tx_ok_cnt: buffer address that we used to store tx ok statistics.
2070*4882a593Smuzhiyun * @qsel indicate which AC queue, or fetch all by PHL_AC_QUEUE_TOTAL
2071*4882a593Smuzhiyun *
2072*4882a593Smuzhiyun * Return rtw_phl_get_tx_ok_rpt's return value in enum rtw_phl_status type.
2073*4882a593Smuzhiyun */
2074*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_get_tx_ok_rpt(void * phl,struct rtw_phl_stainfo_t * phl_sta,u32 * tx_ok_cnt,enum phl_ac_queue qsel)2075*4882a593Smuzhiyun rtw_phl_get_tx_ok_rpt(void *phl, struct rtw_phl_stainfo_t *phl_sta, u32 *tx_ok_cnt,
2076*4882a593Smuzhiyun enum phl_ac_queue qsel)
2077*4882a593Smuzhiyun {
2078*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
2079*4882a593Smuzhiyun enum rtw_phl_status phl_sts = RTW_PHL_STATUS_SUCCESS;
2080*4882a593Smuzhiyun struct rtw_hal_stainfo_t *hal_sta;
2081*4882a593Smuzhiyun
2082*4882a593Smuzhiyun if(phl_sta) {
2083*4882a593Smuzhiyun hal_sta = phl_sta->hal_sta;
2084*4882a593Smuzhiyun
2085*4882a593Smuzhiyun if (tx_ok_cnt && qsel <= PHL_AC_QUEUE_TOTAL) {
2086*4882a593Smuzhiyun if (qsel == PHL_AC_QUEUE_TOTAL) {
2087*4882a593Smuzhiyun /* copy all AC counter */
2088*4882a593Smuzhiyun tx_ok_cnt[PHL_BE_QUEUE_SEL] = hal_sta->trx_stat.wp_rpt_stats[PHL_BE_QUEUE_SEL].tx_ok_cnt;
2089*4882a593Smuzhiyun tx_ok_cnt[PHL_BK_QUEUE_SEL] = hal_sta->trx_stat.wp_rpt_stats[PHL_BK_QUEUE_SEL].tx_ok_cnt;
2090*4882a593Smuzhiyun tx_ok_cnt[PHL_VI_QUEUE_SEL] = hal_sta->trx_stat.wp_rpt_stats[PHL_VI_QUEUE_SEL].tx_ok_cnt;
2091*4882a593Smuzhiyun tx_ok_cnt[PHL_VO_QUEUE_SEL] = hal_sta->trx_stat.wp_rpt_stats[PHL_VO_QUEUE_SEL].tx_ok_cnt;
2092*4882a593Smuzhiyun
2093*4882a593Smuzhiyun /* reset all counter */
2094*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &hal_sta->trx_stat.tx_sts_lock, _bh, NULL);
2095*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[PHL_BE_QUEUE_SEL].tx_ok_cnt = 0;
2096*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[PHL_BK_QUEUE_SEL].tx_ok_cnt = 0;
2097*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[PHL_VI_QUEUE_SEL].tx_ok_cnt = 0;
2098*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[PHL_VO_QUEUE_SEL].tx_ok_cnt = 0;
2099*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &hal_sta->trx_stat.tx_sts_lock, _bh, NULL);
2100*4882a593Smuzhiyun } else {
2101*4882a593Smuzhiyun /*copy target AC queue counter*/
2102*4882a593Smuzhiyun *tx_ok_cnt = hal_sta->trx_stat.wp_rpt_stats[qsel].tx_ok_cnt;
2103*4882a593Smuzhiyun /* reset target AC queue counter */
2104*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &hal_sta->trx_stat.tx_sts_lock, _bh, NULL);
2105*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[qsel].tx_ok_cnt = 0;
2106*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &hal_sta->trx_stat.tx_sts_lock, _bh, NULL);
2107*4882a593Smuzhiyun }
2108*4882a593Smuzhiyun } else {
2109*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_FAILURE;
2110*4882a593Smuzhiyun PHL_ERR("tx_ok_cnt = %p, qsel = %d\n", tx_ok_cnt, qsel);
2111*4882a593Smuzhiyun }
2112*4882a593Smuzhiyun
2113*4882a593Smuzhiyun } else {
2114*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_FAILURE;
2115*4882a593Smuzhiyun PHL_ERR("PHL STA NULL.\n");
2116*4882a593Smuzhiyun }
2117*4882a593Smuzhiyun return phl_sts;
2118*4882a593Smuzhiyun }
2119*4882a593Smuzhiyun
rtw_phl_get_hw_tx_fail_cnt(struct rtw_hal_stainfo_t * hal_sta,enum phl_ac_queue qsel)2120*4882a593Smuzhiyun static u32 rtw_phl_get_hw_tx_fail_cnt(struct rtw_hal_stainfo_t *hal_sta,
2121*4882a593Smuzhiyun enum phl_ac_queue qsel) {
2122*4882a593Smuzhiyun u32 total = 0;
2123*4882a593Smuzhiyun
2124*4882a593Smuzhiyun if (hal_sta) {
2125*4882a593Smuzhiyun total = hal_sta->trx_stat.wp_rpt_stats[qsel].rty_fail_cnt\
2126*4882a593Smuzhiyun + hal_sta->trx_stat.wp_rpt_stats[qsel].lifetime_drop_cnt \
2127*4882a593Smuzhiyun + hal_sta->trx_stat.wp_rpt_stats[qsel].macid_drop_cnt;
2128*4882a593Smuzhiyun }
2129*4882a593Smuzhiyun
2130*4882a593Smuzhiyun return total;
2131*4882a593Smuzhiyun }
2132*4882a593Smuzhiyun
rtw_phl_reset_tx_fail_cnt(struct phl_info_t * phl_info,struct rtw_hal_stainfo_t * hal_sta,enum phl_ac_queue qsel)2133*4882a593Smuzhiyun static void rtw_phl_reset_tx_fail_cnt(struct phl_info_t *phl_info,
2134*4882a593Smuzhiyun struct rtw_hal_stainfo_t *hal_sta, enum phl_ac_queue qsel) {
2135*4882a593Smuzhiyun
2136*4882a593Smuzhiyun if (hal_sta) {
2137*4882a593Smuzhiyun _os_spinlock(phl_to_drvpriv(phl_info), &hal_sta->trx_stat.tx_sts_lock, _bh, NULL);
2138*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[qsel].rty_fail_cnt = 0;
2139*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[qsel].lifetime_drop_cnt = 0;
2140*4882a593Smuzhiyun hal_sta->trx_stat.wp_rpt_stats[qsel].macid_drop_cnt = 0;
2141*4882a593Smuzhiyun _os_spinunlock(phl_to_drvpriv(phl_info), &hal_sta->trx_stat.tx_sts_lock, _bh, NULL);
2142*4882a593Smuzhiyun }
2143*4882a593Smuzhiyun }
2144*4882a593Smuzhiyun
2145*4882a593Smuzhiyun /**
2146*4882a593Smuzhiyun * rtw_phl_get_tx_fail_rpt() - get tx fail info.
2147*4882a593Smuzhiyun * @phl: struct phl_info_t *
2148*4882a593Smuzhiyun * @phl_sta: information is updated through phl_station_info.
2149*4882a593Smuzhiyun * @tx_fail_cnt: buffer address that we used to store tx fail statistics.
2150*4882a593Smuzhiyun * @qsel indicate which AC queue, or fetch all by PHL_AC_QUEUE_TOTAL
2151*4882a593Smuzhiyun *
2152*4882a593Smuzhiyun * Return rtw_phl_get_tx_fail_rpt's return value in enum rtw_phl_status type.
2153*4882a593Smuzhiyun */
2154*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_get_tx_fail_rpt(void * phl,struct rtw_phl_stainfo_t * phl_sta,u32 * tx_fail_cnt,enum phl_ac_queue qsel)2155*4882a593Smuzhiyun rtw_phl_get_tx_fail_rpt(void *phl, struct rtw_phl_stainfo_t *phl_sta, u32 *tx_fail_cnt,
2156*4882a593Smuzhiyun enum phl_ac_queue qsel)
2157*4882a593Smuzhiyun {
2158*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
2159*4882a593Smuzhiyun enum rtw_phl_status phl_sts = RTW_PHL_STATUS_SUCCESS;
2160*4882a593Smuzhiyun struct rtw_hal_stainfo_t *hal_sta;
2161*4882a593Smuzhiyun
2162*4882a593Smuzhiyun if(phl_sta) {
2163*4882a593Smuzhiyun hal_sta = phl_sta->hal_sta;
2164*4882a593Smuzhiyun
2165*4882a593Smuzhiyun if (tx_fail_cnt && qsel <= PHL_AC_QUEUE_TOTAL) {
2166*4882a593Smuzhiyun if (qsel == PHL_AC_QUEUE_TOTAL) {
2167*4882a593Smuzhiyun /* copy all AC counter */
2168*4882a593Smuzhiyun tx_fail_cnt[PHL_BE_QUEUE_SEL] = rtw_phl_get_hw_tx_fail_cnt(hal_sta, PHL_BE_QUEUE_SEL);
2169*4882a593Smuzhiyun tx_fail_cnt[PHL_BK_QUEUE_SEL] = rtw_phl_get_hw_tx_fail_cnt(hal_sta, PHL_BK_QUEUE_SEL);
2170*4882a593Smuzhiyun tx_fail_cnt[PHL_VI_QUEUE_SEL] = rtw_phl_get_hw_tx_fail_cnt(hal_sta, PHL_VI_QUEUE_SEL);
2171*4882a593Smuzhiyun tx_fail_cnt[PHL_VO_QUEUE_SEL] = rtw_phl_get_hw_tx_fail_cnt(hal_sta, PHL_VO_QUEUE_SEL);
2172*4882a593Smuzhiyun /* reset all counter */
2173*4882a593Smuzhiyun rtw_phl_reset_tx_fail_cnt(phl_info, hal_sta, PHL_BE_QUEUE_SEL);
2174*4882a593Smuzhiyun rtw_phl_reset_tx_fail_cnt(phl_info, hal_sta, PHL_BK_QUEUE_SEL);
2175*4882a593Smuzhiyun rtw_phl_reset_tx_fail_cnt(phl_info, hal_sta, PHL_VI_QUEUE_SEL);
2176*4882a593Smuzhiyun rtw_phl_reset_tx_fail_cnt(phl_info, hal_sta, PHL_VO_QUEUE_SEL);
2177*4882a593Smuzhiyun } else {
2178*4882a593Smuzhiyun /*copy target AC queue counter*/
2179*4882a593Smuzhiyun tx_fail_cnt[qsel] = rtw_phl_get_hw_tx_fail_cnt(hal_sta, qsel);
2180*4882a593Smuzhiyun /* reset target AC queue counter */
2181*4882a593Smuzhiyun rtw_phl_reset_tx_fail_cnt(phl_info, hal_sta, qsel);
2182*4882a593Smuzhiyun }
2183*4882a593Smuzhiyun } else {
2184*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_FAILURE;
2185*4882a593Smuzhiyun PHL_ERR("tx_fail_cnt = %p, qsel = %d\n", tx_fail_cnt, qsel);
2186*4882a593Smuzhiyun }
2187*4882a593Smuzhiyun } else {
2188*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_FAILURE;
2189*4882a593Smuzhiyun PHL_ERR("PHL STA NULL.\n");
2190*4882a593Smuzhiyun }
2191*4882a593Smuzhiyun return phl_sts;
2192*4882a593Smuzhiyun }
2193*4882a593Smuzhiyun
2194*4882a593Smuzhiyun /**
2195*4882a593Smuzhiyun * rtw_phl_get_tx_retry_rpt() - get tx retry info.
2196*4882a593Smuzhiyun * @phl: struct phl_info_t *
2197*4882a593Smuzhiyun * @phl_sta: information is updated through phl_station_info.
2198*4882a593Smuzhiyun * @tx_retry_cnt: buffer address that we used to store tx fail statistics.
2199*4882a593Smuzhiyun * @qsel indicate which AC queue, or fetch all by PHL_AC_QUEUE_TOTAL
2200*4882a593Smuzhiyun *
2201*4882a593Smuzhiyun * Return rtw_phl_get_tx_retry_rpt's return value in enum rtw_phl_status type.
2202*4882a593Smuzhiyun */
2203*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_get_tx_retry_rpt(void * phl,struct rtw_phl_stainfo_t * phl_sta,u32 * tx_retry_cnt,enum phl_ac_queue qsel)2204*4882a593Smuzhiyun rtw_phl_get_tx_retry_rpt(void *phl, struct rtw_phl_stainfo_t *phl_sta, u32 *tx_retry_cnt,
2205*4882a593Smuzhiyun enum phl_ac_queue qsel)
2206*4882a593Smuzhiyun {
2207*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
2208*4882a593Smuzhiyun void *drv = phl_to_drvpriv(phl_info);
2209*4882a593Smuzhiyun enum rtw_phl_status phl_sts = RTW_PHL_STATUS_SUCCESS;
2210*4882a593Smuzhiyun struct rtw_hal_stainfo_t *hal_sta;
2211*4882a593Smuzhiyun
2212*4882a593Smuzhiyun if(phl_sta) {
2213*4882a593Smuzhiyun hal_sta = phl_sta->hal_sta;
2214*4882a593Smuzhiyun
2215*4882a593Smuzhiyun if (tx_retry_cnt && qsel <= PHL_AC_QUEUE_TOTAL) {
2216*4882a593Smuzhiyun if (qsel == PHL_AC_QUEUE_TOTAL) {
2217*4882a593Smuzhiyun /* copy all AC counter */
2218*4882a593Smuzhiyun _os_mem_cpy(drv, tx_retry_cnt, hal_sta->ra_info.tx_retry_cnt,
2219*4882a593Smuzhiyun sizeof(u32)*PHL_AC_QUEUE_TOTAL);
2220*4882a593Smuzhiyun /* reset all counter */
2221*4882a593Smuzhiyun /* TODO: Here needs lock, and so does halbb_get_txsts_rpt */
2222*4882a593Smuzhiyun _os_mem_set(drv, hal_sta->ra_info.tx_retry_cnt, 0, sizeof(u32)*PHL_AC_QUEUE_TOTAL);
2223*4882a593Smuzhiyun } else {
2224*4882a593Smuzhiyun /*copy target AC queue counter*/
2225*4882a593Smuzhiyun *tx_retry_cnt = hal_sta->ra_info.tx_retry_cnt[qsel];
2226*4882a593Smuzhiyun /* reset target AC queue counter */
2227*4882a593Smuzhiyun /* TODO: Here needs lock, and so does halbb_get_txsts_rpt */
2228*4882a593Smuzhiyun hal_sta->ra_info.tx_retry_cnt[qsel] = 0;
2229*4882a593Smuzhiyun }
2230*4882a593Smuzhiyun } else {
2231*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_FAILURE;
2232*4882a593Smuzhiyun PHL_ERR("tx_retry_cnt = %p, qsel = %d\n", tx_retry_cnt, qsel);
2233*4882a593Smuzhiyun }
2234*4882a593Smuzhiyun } else {
2235*4882a593Smuzhiyun phl_sts = RTW_PHL_STATUS_FAILURE;
2236*4882a593Smuzhiyun PHL_ERR("PHL STA NULL.\n");
2237*4882a593Smuzhiyun }
2238*4882a593Smuzhiyun return phl_sts;
2239*4882a593Smuzhiyun }
2240*4882a593Smuzhiyun #endif /* defined(CONFIG_USB_HCI) || defined(CONFIG_PCI_HCI) */
2241*4882a593Smuzhiyun
2242*4882a593Smuzhiyun /*
2243*4882a593Smuzhiyun * Get next idx
2244*4882a593Smuzhiyun */
_get_fidx(u8 num,u8 cur_idx)2245*4882a593Smuzhiyun u8 _get_fidx(u8 num, u8 cur_idx)
2246*4882a593Smuzhiyun {
2247*4882a593Smuzhiyun u8 idx = 0;
2248*4882a593Smuzhiyun
2249*4882a593Smuzhiyun if (num == 0)
2250*4882a593Smuzhiyun idx = cur_idx;
2251*4882a593Smuzhiyun else {
2252*4882a593Smuzhiyun idx = cur_idx + 1;
2253*4882a593Smuzhiyun if (idx >= MAX_STORE_BCN_NUM)
2254*4882a593Smuzhiyun idx = 0;
2255*4882a593Smuzhiyun }
2256*4882a593Smuzhiyun return idx;
2257*4882a593Smuzhiyun }
2258*4882a593Smuzhiyun
2259*4882a593Smuzhiyun /*
2260*4882a593Smuzhiyun * Get previous idx
2261*4882a593Smuzhiyun */
_get_bidx(u8 num,u8 cur_idx)2262*4882a593Smuzhiyun u8 _get_bidx(u8 num, u8 cur_idx)
2263*4882a593Smuzhiyun {
2264*4882a593Smuzhiyun u8 idx = 0;
2265*4882a593Smuzhiyun
2266*4882a593Smuzhiyun if (cur_idx == 0) {
2267*4882a593Smuzhiyun idx = num - 1;
2268*4882a593Smuzhiyun } else {
2269*4882a593Smuzhiyun idx = cur_idx - 1;
2270*4882a593Smuzhiyun }
2271*4882a593Smuzhiyun return idx;
2272*4882a593Smuzhiyun }
2273*4882a593Smuzhiyun
_phl_sta_up_bcn_offset_info(struct phl_info_t * phl,struct rtw_rx_bcn_info * bcn_i,u16 bcn_intvl)2274*4882a593Smuzhiyun void _phl_sta_up_bcn_offset_info(struct phl_info_t *phl,
2275*4882a593Smuzhiyun struct rtw_rx_bcn_info *bcn_i, u16 bcn_intvl)
2276*4882a593Smuzhiyun {
2277*4882a593Smuzhiyun struct rtw_bcn_offset *offset_i = &bcn_i->offset_i;
2278*4882a593Smuzhiyun u16 offset = bcn_intvl;
2279*4882a593Smuzhiyun u16 similar_th = 2;/*Unit: TU*/
2280*4882a593Smuzhiyun u64 diff = 0;
2281*4882a593Smuzhiyun u8 idx = 0, jdx = 0, cur_idx = 0, bidx = 0, start_idx = 0;
2282*4882a593Smuzhiyun
2283*4882a593Smuzhiyun if (bcn_i->num == 1) {
2284*4882a593Smuzhiyun offset_i->offset = (u16)bcn_i->info[1][bcn_i->idx];
2285*4882a593Smuzhiyun offset_i->conf_lvl = CONF_LVL_LOW;
2286*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_WARNING_, "_phl_sta_up_bcn_offset_info(): bcn_i->num ==1, conf_lvl = CONF_LVL_LOW, offset(%d)\n",
2287*4882a593Smuzhiyun offset_i->offset);
2288*4882a593Smuzhiyun goto exit;
2289*4882a593Smuzhiyun }
2290*4882a593Smuzhiyun cur_idx = bcn_i->idx;
2291*4882a593Smuzhiyun start_idx = cur_idx;
2292*4882a593Smuzhiyun for (idx = 0; idx < bcn_i->num; idx++) {
2293*4882a593Smuzhiyun bidx = cur_idx;
2294*4882a593Smuzhiyun for (jdx = 1; jdx < bcn_i->num; jdx++) {
2295*4882a593Smuzhiyun bidx = _get_bidx(bcn_i->num, bidx);
2296*4882a593Smuzhiyun if (start_idx == bidx)
2297*4882a593Smuzhiyun break;
2298*4882a593Smuzhiyun diff = bcn_i->info[0][cur_idx] - bcn_i->info[0][bidx];
2299*4882a593Smuzhiyun diff = _os_division64(
2300*4882a593Smuzhiyun _os_modular64(diff, bcn_intvl * TU), TU);
2301*4882a593Smuzhiyun /*ex: diff = 99, BcnIntvl = 100, It's similar case
2302*4882a593Smuzhiyun * diff = 2, BcnIntvl = 100, It's similar case
2303*4882a593Smuzhiyun */
2304*4882a593Smuzhiyun if (!((diff < similar_th) ||
2305*4882a593Smuzhiyun ((bcn_intvl - diff) < similar_th))) {
2306*4882a593Smuzhiyun continue;
2307*4882a593Smuzhiyun }
2308*4882a593Smuzhiyun if (offset > bcn_i->info[1][cur_idx])
2309*4882a593Smuzhiyun offset = (u16)bcn_i->info[1][cur_idx];
2310*4882a593Smuzhiyun if (offset > bcn_i->info[1][bidx])
2311*4882a593Smuzhiyun offset = (u16)bcn_i->info[1][bidx];
2312*4882a593Smuzhiyun }
2313*4882a593Smuzhiyun cur_idx = _get_bidx(bcn_i->num, cur_idx);
2314*4882a593Smuzhiyun }
2315*4882a593Smuzhiyun if (offset != bcn_intvl) {
2316*4882a593Smuzhiyun offset_i->conf_lvl = CONF_LVL_HIGH;
2317*4882a593Smuzhiyun if (offset < offset_i->offset) {
2318*4882a593Smuzhiyun offset_i->offset = offset;
2319*4882a593Smuzhiyun }
2320*4882a593Smuzhiyun goto exit;
2321*4882a593Smuzhiyun }
2322*4882a593Smuzhiyun for (idx = 0; idx < bcn_i->num; idx++) {
2323*4882a593Smuzhiyun if (bcn_i->info[1][idx] < offset_i->offset) {
2324*4882a593Smuzhiyun offset_i->offset = (u16)bcn_i->info[1][idx];
2325*4882a593Smuzhiyun offset_i->conf_lvl = CONF_LVL_MID;
2326*4882a593Smuzhiyun }
2327*4882a593Smuzhiyun }
2328*4882a593Smuzhiyun exit:
2329*4882a593Smuzhiyun /*
2330*4882a593Smuzhiyun if offset is small, maybe impact by environment, offset < 5% bcn_intvl, we consider offset is 0
2331*4882a593Smuzhiyun */
2332*4882a593Smuzhiyun if ((offset_i->offset != 0) &&
2333*4882a593Smuzhiyun (offset_i->offset < ((bcn_intvl * 5) / 100))) {
2334*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_MCC, _PHL_WARNING_, "_phl_sta_up_bcn_offset_info(): offset(%d) < (%d), set offset = 0\n",
2335*4882a593Smuzhiyun offset_i->offset, (bcn_intvl * 5) / 100);
2336*4882a593Smuzhiyun offset_i->offset = 0;
2337*4882a593Smuzhiyun }
2338*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_DEBUG_, "_phl_sta_up_bcn_offset_info(): bcn num(%d), offset(%d), conf_lvl(%d), current CR(%d)\n",
2339*4882a593Smuzhiyun bcn_i->num, offset_i->offset, offset_i->conf_lvl, offset_i->cr_tbtt_shift);
2340*4882a593Smuzhiyun return;
2341*4882a593Smuzhiyun }
2342*4882a593Smuzhiyun
rtw_phl_sta_up_rx_bcn(void * phl,struct rtw_bcn_pkt_info * info)2343*4882a593Smuzhiyun void rtw_phl_sta_up_rx_bcn(void *phl, struct rtw_bcn_pkt_info *info)
2344*4882a593Smuzhiyun {
2345*4882a593Smuzhiyun struct rtw_rx_bcn_info *bcn_i = &info->sta->bcn_i;
2346*4882a593Smuzhiyun u16 bcn_intvl = info->sta->asoc_cap.bcn_interval;
2347*4882a593Smuzhiyun
2348*4882a593Smuzhiyun if (bcn_intvl == 0) {
2349*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_WARNING_, "bcn_intvl == 0");
2350*4882a593Smuzhiyun return;
2351*4882a593Smuzhiyun }
2352*4882a593Smuzhiyun
2353*4882a593Smuzhiyun bcn_i->idx = _get_fidx(bcn_i->num, bcn_i->idx);
2354*4882a593Smuzhiyun if (bcn_i->num < MAX_STORE_BCN_NUM)
2355*4882a593Smuzhiyun bcn_i->num++;
2356*4882a593Smuzhiyun bcn_i->info[0][bcn_i->idx] = info->tsf;
2357*4882a593Smuzhiyun bcn_i->info[1][bcn_i->idx] = _os_division64(
2358*4882a593Smuzhiyun _os_modular64(info->tsf, bcn_intvl * TU), TU);
2359*4882a593Smuzhiyun bcn_i->info[2][bcn_i->idx] = info->hw_tsf;
2360*4882a593Smuzhiyun _phl_sta_up_bcn_offset_info(phl, bcn_i, bcn_intvl);
2361*4882a593Smuzhiyun }
2362*4882a593Smuzhiyun
phl_clean_sta_bcn_info(struct phl_info_t * phl,struct rtw_phl_stainfo_t * sta)2363*4882a593Smuzhiyun void phl_clean_sta_bcn_info(struct phl_info_t *phl, struct rtw_phl_stainfo_t *sta)
2364*4882a593Smuzhiyun {
2365*4882a593Smuzhiyun void *priv = phl_to_drvpriv(phl);
2366*4882a593Smuzhiyun struct rtw_rx_bcn_info *bcn_i = &sta->bcn_i;
2367*4882a593Smuzhiyun
2368*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "phl_clean_sta_bcn_info(): sta->wrole->id(%d)\n",
2369*4882a593Smuzhiyun sta->wrole->id);
2370*4882a593Smuzhiyun _os_mem_set(priv, bcn_i, 0, sizeof(struct rtw_rx_bcn_info));
2371*4882a593Smuzhiyun }
2372*4882a593Smuzhiyun
phl_get_sta_bcn_offset_info(struct phl_info_t * phl,struct rtw_wifi_role_t * wrole)2373*4882a593Smuzhiyun struct rtw_bcn_offset * phl_get_sta_bcn_offset_info(struct phl_info_t *phl,
2374*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
2375*4882a593Smuzhiyun {
2376*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = rtw_phl_get_stainfo_self(phl, wrole);
2377*4882a593Smuzhiyun struct rtw_bcn_offset *offset_i = &sta->bcn_i.offset_i;
2378*4882a593Smuzhiyun
2379*4882a593Smuzhiyun return offset_i;
2380*4882a593Smuzhiyun }
2381*4882a593Smuzhiyun
phl_bcn_watchdog(struct phl_info_t * phl)2382*4882a593Smuzhiyun void phl_bcn_watchdog(struct phl_info_t *phl)
2383*4882a593Smuzhiyun {
2384*4882a593Smuzhiyun u8 ridx = MAX_WIFI_ROLE_NUMBER;
2385*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole = NULL;
2386*4882a593Smuzhiyun struct rtw_bcn_offset *b_ofst_i = NULL;
2387*4882a593Smuzhiyun enum rtw_hal_status hstatus = RTW_HAL_STATUS_SUCCESS;
2388*4882a593Smuzhiyun
2389*4882a593Smuzhiyun for (ridx = 0; ridx < MAX_WIFI_ROLE_NUMBER; ridx++) {
2390*4882a593Smuzhiyun wrole = rtw_phl_get_wrole_by_ridx(phl->phl_com, ridx);
2391*4882a593Smuzhiyun if (wrole->active == false)
2392*4882a593Smuzhiyun continue;
2393*4882a593Smuzhiyun
2394*4882a593Smuzhiyun if (rtw_phl_role_is_client_category(wrole) && wrole->mstate == MLME_LINKED) {
2395*4882a593Smuzhiyun b_ofst_i = phl_get_sta_bcn_offset_info(phl, wrole);
2396*4882a593Smuzhiyun
2397*4882a593Smuzhiyun if (b_ofst_i->conf_lvl >= CONF_LVL_MID &&
2398*4882a593Smuzhiyun b_ofst_i->offset != b_ofst_i->cr_tbtt_shift) {
2399*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "%s(): update bcn offset to %d TU\n",
2400*4882a593Smuzhiyun __func__, b_ofst_i->offset);
2401*4882a593Smuzhiyun hstatus = rtw_hal_role_cfg_ex(phl->hal, wrole, PCFG_TBTT_SHIFT, &(b_ofst_i->offset));
2402*4882a593Smuzhiyun if (hstatus == RTW_HAL_STATUS_SUCCESS)
2403*4882a593Smuzhiyun b_ofst_i->cr_tbtt_shift = b_ofst_i->offset;
2404*4882a593Smuzhiyun else
2405*4882a593Smuzhiyun PHL_ERR("%s(): role cfg fail, status: %d\n", __func__, hstatus);
2406*4882a593Smuzhiyun }
2407*4882a593Smuzhiyun }
2408*4882a593Smuzhiyun }
2409*4882a593Smuzhiyun }
2410*4882a593Smuzhiyun
2411*4882a593Smuzhiyun /*
2412*4882a593Smuzhiyun * calculate the value between current TSF and TBTT
2413*4882a593Smuzhiyun * TSF 0 50 180 150 250
2414*4882a593Smuzhiyun * TBTT ^ ^ ^
2415*4882a593Smuzhiyun * Curr T |
2416*4882a593Smuzhiyun * | 30 |
2417*4882a593Smuzhiyun *
2418*4882a593Smuzhiyun * TSF 0 80 120 180 280
2419*4882a593Smuzhiyun * TBTT ^ ^ ^
2420*4882a593Smuzhiyun * Curr T |
2421*4882a593Smuzhiyun * | 40 |
2422*4882a593Smuzhiyun * @wrole: specific role, we get bcn offset info from the role.
2423*4882a593Smuzhiyun * @cur_t: current TSF
2424*4882a593Smuzhiyun * @ofst: output value, unit: TU
2425*4882a593Smuzhiyun */
phl_calc_offset_from_tbtt(struct phl_info_t * phl,struct rtw_wifi_role_t * wrole,u64 cur_t,u16 * ofst)2426*4882a593Smuzhiyun bool phl_calc_offset_from_tbtt(struct phl_info_t *phl,
2427*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole, u64 cur_t, u16 *ofst)
2428*4882a593Smuzhiyun {
2429*4882a593Smuzhiyun struct rtw_bcn_offset *b_ofst_i = phl_get_sta_bcn_offset_info(phl, wrole);
2430*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta = rtw_phl_get_stainfo_self(phl, wrole);
2431*4882a593Smuzhiyun u64 b_ofst = b_ofst_i->offset;
2432*4882a593Smuzhiyun u64 b_intvl = 0;
2433*4882a593Smuzhiyun u32 mod = 0; /*TU*/
2434*4882a593Smuzhiyun
2435*4882a593Smuzhiyun #ifdef RTW_PHL_BCN
2436*4882a593Smuzhiyun if (phl_role_is_ap_category(wrole))
2437*4882a593Smuzhiyun b_intvl = (u16)wrole->bcn_cmn.bcn_interval;
2438*4882a593Smuzhiyun else
2439*4882a593Smuzhiyun #endif
2440*4882a593Smuzhiyun b_intvl = sta->asoc_cap.bcn_interval;
2441*4882a593Smuzhiyun if (0 == b_intvl) {
2442*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "phl_calc_offset_from_tbtt(): Fail, b_intvl ==0, wrole->id(%d), type(%d)\n",
2443*4882a593Smuzhiyun wrole->id, wrole->type);
2444*4882a593Smuzhiyun return false;
2445*4882a593Smuzhiyun }
2446*4882a593Smuzhiyun mod = (u32)_os_division64(_os_modular64(cur_t, b_intvl * TU), TU);
2447*4882a593Smuzhiyun if (mod < b_ofst) {
2448*4882a593Smuzhiyun *ofst = (u16)(mod + (b_intvl - b_ofst));
2449*4882a593Smuzhiyun } else {
2450*4882a593Smuzhiyun *ofst = (u16)(mod - b_ofst);
2451*4882a593Smuzhiyun }
2452*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "phl_calc_offset_from_tbtt(): wrole->id(%d), ofst(%d), cur_t: 0x%08x %08x modular(%d, TU), Bcn offset: conf_lvl(%d), offset(%d)\n",
2453*4882a593Smuzhiyun wrole->id, *ofst, (u32)(cur_t >> 32), (u32)cur_t, mod,
2454*4882a593Smuzhiyun b_ofst_i->conf_lvl, (u32)b_ofst);
2455*4882a593Smuzhiyun return true;
2456*4882a593Smuzhiyun }
2457*4882a593Smuzhiyun
2458*4882a593Smuzhiyun /*
2459*4882a593Smuzhiyun * Synchronize TBTT of target role with TBTT of sourec role
2460*4882a593Smuzhiyun * Assume TBTT of target role is locate in Mod(Tgt Tsf) = 0
2461*4882a593Smuzhiyun * @sync_ofst: Offset between TBTT of target role and TBTT of sourec role. Unit: TU
2462*4882a593Smuzhiyun * @sync_now_once: Sync once time right now.
2463*4882a593Smuzhiyun * @*diff_t : output diff_tsf. Unit: TU
2464*4882a593Smuzhiyun */
rtw_phl_tbtt_sync(struct phl_info_t * phl,struct rtw_wifi_role_t * src_role,struct rtw_wifi_role_t * tgt_role,u16 sync_ofst,bool sync_now_once,u16 * diff_t)2465*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_tbtt_sync(struct phl_info_t *phl,
2466*4882a593Smuzhiyun struct rtw_wifi_role_t *src_role,
2467*4882a593Smuzhiyun struct rtw_wifi_role_t *tgt_role,
2468*4882a593Smuzhiyun u16 sync_ofst, bool sync_now_once, u16 *diff_t)
2469*4882a593Smuzhiyun {
2470*4882a593Smuzhiyun enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
2471*4882a593Smuzhiyun u32 tsf_h = 0, tsf_l = 0;
2472*4882a593Smuzhiyun u64 tsf = 0, tgt_tsf = 0, bcn_intvl = 0;
2473*4882a593Smuzhiyun u16 ofst = 0;
2474*4882a593Smuzhiyun u64 diff_tsf = 0;
2475*4882a593Smuzhiyun enum hal_tsf_sync_act act = sync_now_once ? HAL_TSF_SYNC_NOW_ONCE :
2476*4882a593Smuzhiyun HAL_TSF_EN_SYNC_AUTO;
2477*4882a593Smuzhiyun
2478*4882a593Smuzhiyun if (RTW_HAL_STATUS_SUCCESS != rtw_hal_get_tsf(phl->hal,
2479*4882a593Smuzhiyun src_role->hw_port, &tsf_h, &tsf_l)) {
2480*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "rtw_phl_tbtt_sync(): Get tsf fail, src_role->id(%d)\n",
2481*4882a593Smuzhiyun src_role->id);
2482*4882a593Smuzhiyun goto exit;
2483*4882a593Smuzhiyun }
2484*4882a593Smuzhiyun bcn_intvl = phl_role_get_bcn_intvl(phl, tgt_role);
2485*4882a593Smuzhiyun if (bcn_intvl == 0) {
2486*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "rtw_phl_tbtt_sync(): bcn_intvl == 0, tgt_role->id(%d)\n",
2487*4882a593Smuzhiyun tgt_role->id);
2488*4882a593Smuzhiyun goto exit;
2489*4882a593Smuzhiyun }
2490*4882a593Smuzhiyun tsf = tsf_h;
2491*4882a593Smuzhiyun tsf = tsf << 32;
2492*4882a593Smuzhiyun tsf |= tsf_l;
2493*4882a593Smuzhiyun /*calculate the value between current TSF and TBTT*/
2494*4882a593Smuzhiyun phl_calc_offset_from_tbtt(phl, src_role, tsf, &ofst);
2495*4882a593Smuzhiyun tgt_tsf = (tsf + sync_ofst * TU) - ofst * TU;
2496*4882a593Smuzhiyun /*Find diff_tsf, let Mod((tgt_tsf + diff_tsf), bcn_intvl) = 0*/
2497*4882a593Smuzhiyun diff_tsf = bcn_intvl * TU - _os_modular64(tgt_tsf, bcn_intvl * TU);
2498*4882a593Smuzhiyun diff_tsf = _os_division64(diff_tsf, TU);
2499*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "rtw_phl_tbtt_sync(): diff_tsf(%d), sync_ofst(%d), ofst(%d)\n",
2500*4882a593Smuzhiyun (u32)diff_tsf, sync_ofst, (u32)ofst);
2501*4882a593Smuzhiyun if (RTW_HAL_STATUS_SUCCESS != rtw_hal_tsf_sync(phl->hal,
2502*4882a593Smuzhiyun src_role->hw_port, tgt_role->hw_port,
2503*4882a593Smuzhiyun src_role->hw_band, (s32)diff_tsf,
2504*4882a593Smuzhiyun act)) {
2505*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "rtw_phl_tbtt_sync(): Sync tsf fail\n");
2506*4882a593Smuzhiyun goto exit;
2507*4882a593Smuzhiyun }
2508*4882a593Smuzhiyun if (RTW_HAL_STATUS_SUCCESS == rtw_hal_get_tsf(phl->hal,
2509*4882a593Smuzhiyun src_role->hw_port, &tsf_h, &tsf_l)) {
2510*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "rtw_phl_tbtt_sync(): tsf_src(0x%08x %08x)\n",
2511*4882a593Smuzhiyun tsf_h, tsf_l);
2512*4882a593Smuzhiyun }
2513*4882a593Smuzhiyun if (RTW_HAL_STATUS_SUCCESS == rtw_hal_get_tsf(phl->hal,
2514*4882a593Smuzhiyun tgt_role->hw_port, &tsf_h, &tsf_l)) {
2515*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "rtw_phl_tbtt_sync(): tsf_tgt(0x%08x %08x)\n",
2516*4882a593Smuzhiyun tsf_h, tsf_l);
2517*4882a593Smuzhiyun }
2518*4882a593Smuzhiyun *diff_t = (u16)diff_tsf;
2519*4882a593Smuzhiyun status = RTW_PHL_STATUS_SUCCESS;
2520*4882a593Smuzhiyun exit:
2521*4882a593Smuzhiyun return status;
2522*4882a593Smuzhiyun
2523*4882a593Smuzhiyun }
2524*4882a593Smuzhiyun
phl_self_stainfo_chk(struct phl_info_t * phl_info,struct rtw_wifi_role_t * wrole,struct rtw_phl_stainfo_t * sta)2525*4882a593Smuzhiyun bool phl_self_stainfo_chk(struct phl_info_t *phl_info,
2526*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
2527*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta)
2528*4882a593Smuzhiyun {
2529*4882a593Smuzhiyun return _phl_self_stainfo_chk(phl_info, wrole, sta);
2530*4882a593Smuzhiyun }
2531