1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun *
3*4882a593Smuzhiyun * Copyright(c) 2020 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 #include "phl_headers.h"
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #ifdef CONFIG_STA_CMD_DISPR
rtw_phl_connect_prepare(void * phl,struct rtw_wifi_role_t * wrole,u8 * addr)18*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_connect_prepare(void *phl,
19*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
20*4882a593Smuzhiyun u8 *addr)
21*4882a593Smuzhiyun {
22*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
23*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
24*4882a593Smuzhiyun struct phl_msg msg = {0};
25*4882a593Smuzhiyun struct phl_msg_attribute attr = {0};
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
28*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_CONNECT_START);
29*4882a593Smuzhiyun msg.band_idx = wrole->hw_band;
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
32*4882a593Smuzhiyun if(phl_status != RTW_PHL_STATUS_SUCCESS){
33*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
34*4882a593Smuzhiyun __FUNCTION__);
35*4882a593Smuzhiyun goto exit;
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun exit:
39*4882a593Smuzhiyun return phl_status;
40*4882a593Smuzhiyun }
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_connect_linked(void * phl,struct rtw_wifi_role_t * wrole,struct rtw_phl_stainfo_t * sta,u8 * sta_addr)43*4882a593Smuzhiyun rtw_phl_connect_linked(void *phl,
44*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
45*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta,
46*4882a593Smuzhiyun u8 *sta_addr)
47*4882a593Smuzhiyun {
48*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
49*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
50*4882a593Smuzhiyun struct phl_msg msg = {0};
51*4882a593Smuzhiyun struct phl_msg_attribute attr = {0};
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
54*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_CONNECT_LINKED);
55*4882a593Smuzhiyun msg.band_idx = wrole->hw_band;
56*4882a593Smuzhiyun msg.rsvd[0] = sta;
57*4882a593Smuzhiyun msg.rsvd[1] = sta_addr;
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
60*4882a593Smuzhiyun if(phl_status != RTW_PHL_STATUS_SUCCESS){
61*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
62*4882a593Smuzhiyun __FUNCTION__);
63*4882a593Smuzhiyun goto exit;
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun exit:
67*4882a593Smuzhiyun return phl_status;
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun
rtw_phl_connected(void * phl,struct rtw_wifi_role_t * wrole,struct rtw_phl_stainfo_t * sta)70*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_connected(void *phl,
71*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
72*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta)
73*4882a593Smuzhiyun {
74*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
75*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
76*4882a593Smuzhiyun struct phl_msg msg = {0};
77*4882a593Smuzhiyun struct phl_msg_attribute attr = {0};
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
80*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_CONNECT_END);
81*4882a593Smuzhiyun msg.band_idx = wrole->hw_band;
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
84*4882a593Smuzhiyun if(phl_status != RTW_PHL_STATUS_SUCCESS){
85*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
86*4882a593Smuzhiyun __FUNCTION__);
87*4882a593Smuzhiyun goto exit;
88*4882a593Smuzhiyun }
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun exit:
91*4882a593Smuzhiyun return phl_status;
92*4882a593Smuzhiyun }
93*4882a593Smuzhiyun
rtw_phl_disconnect(void * phl,struct rtw_wifi_role_t * wrole,bool is_disconnect)94*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_disconnect(void *phl,
95*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
96*4882a593Smuzhiyun bool is_disconnect)
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
99*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
100*4882a593Smuzhiyun struct phl_msg msg = {0};
101*4882a593Smuzhiyun struct phl_msg_attribute attr = {0};
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun if(is_disconnect) {
104*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_DISCONNECT);
105*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_DISCONNECT_PREPARE);
106*4882a593Smuzhiyun } else {
107*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
108*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_DISCONNECT);
109*4882a593Smuzhiyun }
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun msg.band_idx = wrole->hw_band;
112*4882a593Smuzhiyun msg.rsvd[0] = (u8*)wrole;
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
115*4882a593Smuzhiyun if(phl_status != RTW_PHL_STATUS_SUCCESS){
116*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
117*4882a593Smuzhiyun __FUNCTION__);
118*4882a593Smuzhiyun goto exit;
119*4882a593Smuzhiyun }
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun exit:
122*4882a593Smuzhiyun return phl_status;
123*4882a593Smuzhiyun }
124*4882a593Smuzhiyun #else /* CONFIG_STA_CMD_DISPR */
rtw_phl_connect_prepare(void * phl,struct rtw_wifi_role_t * wrole,u8 * addr)125*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_connect_prepare(void *phl,
126*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
127*4882a593Smuzhiyun u8 *addr)
128*4882a593Smuzhiyun {
129*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
130*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun FUNCIN();
133*4882a593Smuzhiyun wrole->mstate = MLME_LINKING;
134*4882a593Smuzhiyun psts = phl_role_notify(phl_info, wrole);
135*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
136*4882a593Smuzhiyun PHL_ERR("%s role notify failed\n", __func__);
137*4882a593Smuzhiyun goto _exit;
138*4882a593Smuzhiyun }
139*4882a593Smuzhiyun psts = phl_mr_info_upt(phl_info, wrole);
140*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
141*4882a593Smuzhiyun PHL_ERR("%s mr info upt failed\n", __func__);
142*4882a593Smuzhiyun goto _exit;
143*4882a593Smuzhiyun }
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun psts = rtw_phl_mr_rx_filter(phl, wrole);
146*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
147*4882a593Smuzhiyun PHL_ERR("%s set mr_rx_filter failed\n", __func__);
148*4882a593Smuzhiyun goto _exit;
149*4882a593Smuzhiyun }
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
152*4882a593Smuzhiyun /* pasue all NoA */
153*4882a593Smuzhiyun phl_p2pps_noa_all_role_pause(phl, wrole->hw_band);
154*4882a593Smuzhiyun #endif
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
157*4882a593Smuzhiyun _exit:
158*4882a593Smuzhiyun FUNCOUT();
159*4882a593Smuzhiyun return psts;
160*4882a593Smuzhiyun }
161*4882a593Smuzhiyun
rtw_phl_connected(void * phl,struct rtw_wifi_role_t * wrole,struct rtw_phl_stainfo_t * sta)162*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_connected(void *phl,
163*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole,
164*4882a593Smuzhiyun struct rtw_phl_stainfo_t *sta)
165*4882a593Smuzhiyun {
166*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
167*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun FUNCIN();
170*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION || wrole->type == PHL_RTYPE_P2P_GC) {
171*4882a593Smuzhiyun psts = phl_role_notify(phl_info, wrole);
172*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
173*4882a593Smuzhiyun PHL_ERR("%s role notify failed\n", __func__);
174*4882a593Smuzhiyun goto _exit;
175*4882a593Smuzhiyun }
176*4882a593Smuzhiyun }
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun psts = phl_mr_info_upt(phl_info, wrole);
179*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
180*4882a593Smuzhiyun PHL_ERR("%s mr info upt failed\n", __func__);
181*4882a593Smuzhiyun goto _exit;
182*4882a593Smuzhiyun }
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun psts = rtw_phl_mr_rx_filter(phl, wrole);
185*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
186*4882a593Smuzhiyun PHL_ERR("%s set mr_rx_filter failed\n", __func__);
187*4882a593Smuzhiyun goto _exit;
188*4882a593Smuzhiyun }
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun psts = phl_mr_tsf_sync(phl, wrole, PHL_ROLE_MSTS_STA_CONN_END);
191*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
192*4882a593Smuzhiyun PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
193*4882a593Smuzhiyun goto _exit;
194*4882a593Smuzhiyun }
195*4882a593Smuzhiyun #if 0
196*4882a593Smuzhiyun psts = phl_mr_state_upt(phl_info, wrole);
197*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
198*4882a593Smuzhiyun PHL_ERR("%s phl_mr_state_upt failed\n", __func__);
199*4882a593Smuzhiyun goto _exit;
200*4882a593Smuzhiyun }
201*4882a593Smuzhiyun #endif
202*4882a593Smuzhiyun
203*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
204*4882a593Smuzhiyun _exit:
205*4882a593Smuzhiyun FUNCOUT();
206*4882a593Smuzhiyun return psts;
207*4882a593Smuzhiyun }
rtw_phl_disconnect_prepare(void * phl,struct rtw_wifi_role_t * wrole)208*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_disconnect_prepare(void *phl,
209*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
210*4882a593Smuzhiyun {
211*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
212*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun FUNCIN();
215*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
216*4882a593Smuzhiyun /* disable NoA for this role */
217*4882a593Smuzhiyun phl_p2pps_noa_disable_all(phl_info, wrole);
218*4882a593Smuzhiyun /* pasue buddy NoA */
219*4882a593Smuzhiyun phl_p2pps_noa_all_role_pause(phl_info, wrole->hw_band);
220*4882a593Smuzhiyun #endif
221*4882a593Smuzhiyun FUNCOUT();
222*4882a593Smuzhiyun return psts;
223*4882a593Smuzhiyun }
224*4882a593Smuzhiyun
rtw_phl_disconnect(void * phl,struct rtw_wifi_role_t * wrole)225*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_disconnect(void *phl,
226*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
227*4882a593Smuzhiyun {
228*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
229*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun FUNCIN();
232*4882a593Smuzhiyun if (wrole->type == PHL_RTYPE_STATION || wrole->type == PHL_RTYPE_P2P_GC) {
233*4882a593Smuzhiyun psts = phl_role_notify(phl_info, wrole);
234*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
235*4882a593Smuzhiyun PHL_ERR("%s role notify failed\n", __func__);
236*4882a593Smuzhiyun goto _exit;
237*4882a593Smuzhiyun }
238*4882a593Smuzhiyun }
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun psts = phl_mr_info_upt(phl_info, wrole);
241*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
242*4882a593Smuzhiyun PHL_ERR("%s mr info upt failed\n", __func__);
243*4882a593Smuzhiyun goto _exit;
244*4882a593Smuzhiyun }
245*4882a593Smuzhiyun
246*4882a593Smuzhiyun psts = rtw_phl_mr_rx_filter(phl, wrole);
247*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
248*4882a593Smuzhiyun PHL_ERR("%s set mr_rx_filter failed\n", __func__);
249*4882a593Smuzhiyun goto _exit;
250*4882a593Smuzhiyun }
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun psts = phl_mr_tsf_sync(phl, wrole, PHL_ROLE_MSTS_STA_DIS_CONN);
253*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
254*4882a593Smuzhiyun PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
255*4882a593Smuzhiyun goto _exit;
256*4882a593Smuzhiyun }
257*4882a593Smuzhiyun psts = phl_mr_state_upt(phl_info, wrole);
258*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
259*4882a593Smuzhiyun PHL_ERR("%s phl_mr_state_upt failed\n", __func__);
260*4882a593Smuzhiyun goto _exit;
261*4882a593Smuzhiyun }
262*4882a593Smuzhiyun rtw_hal_disconnect_notify(phl_info->hal, &wrole->chandef);
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
265*4882a593Smuzhiyun /* resume buddy NoA */
266*4882a593Smuzhiyun phl_p2pps_noa_all_role_resume(phl, wrole->hw_band);
267*4882a593Smuzhiyun #endif
268*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
269*4882a593Smuzhiyun _exit:
270*4882a593Smuzhiyun FUNCOUT();
271*4882a593Smuzhiyun return psts;
272*4882a593Smuzhiyun }
273*4882a593Smuzhiyun #endif
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun #ifdef CONFIG_AP_CMD_DISPR
rtw_phl_ap_started(void * phl,struct rtw_wifi_role_t * wrole)276*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ap_started(void *phl, struct rtw_wifi_role_t *wrole)
277*4882a593Smuzhiyun {
278*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
279*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
280*4882a593Smuzhiyun struct phl_msg msg = {0};
281*4882a593Smuzhiyun struct phl_msg_attribute attr = {0};
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_START);
284*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_AP_START);
285*4882a593Smuzhiyun msg.band_idx = wrole->hw_band;
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
288*4882a593Smuzhiyun if(phl_status != RTW_PHL_STATUS_SUCCESS){
289*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
290*4882a593Smuzhiyun __FUNCTION__);
291*4882a593Smuzhiyun goto exit;
292*4882a593Smuzhiyun }
293*4882a593Smuzhiyun
294*4882a593Smuzhiyun exit:
295*4882a593Smuzhiyun return phl_status;
296*4882a593Smuzhiyun }
297*4882a593Smuzhiyun
rtw_phl_ap_stop(void * phl,struct rtw_wifi_role_t * wrole)298*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ap_stop(void *phl, struct rtw_wifi_role_t *wrole)
299*4882a593Smuzhiyun {
300*4882a593Smuzhiyun enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
301*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
302*4882a593Smuzhiyun struct phl_msg msg = {0};
303*4882a593Smuzhiyun struct phl_msg_attribute attr = {0};
304*4882a593Smuzhiyun
305*4882a593Smuzhiyun SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_STOP);
306*4882a593Smuzhiyun SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_AP_STOP_PREPARE);
307*4882a593Smuzhiyun msg.band_idx = wrole->hw_band;
308*4882a593Smuzhiyun msg.rsvd[0] = (u8*)wrole;
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
311*4882a593Smuzhiyun if(phl_status != RTW_PHL_STATUS_SUCCESS){
312*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
313*4882a593Smuzhiyun __FUNCTION__);
314*4882a593Smuzhiyun goto exit;
315*4882a593Smuzhiyun }
316*4882a593Smuzhiyun
317*4882a593Smuzhiyun exit:
318*4882a593Smuzhiyun return phl_status;
319*4882a593Smuzhiyun }
320*4882a593Smuzhiyun #else /* CONFIG_AP_CMD_DISPR */
rtw_phl_ap_start_prepare(void * phl,struct rtw_wifi_role_t * wrole)321*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ap_start_prepare(void *phl, struct rtw_wifi_role_t *wrole)
322*4882a593Smuzhiyun {
323*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun FUNCIN();
326*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
327*4882a593Smuzhiyun /* pasue all NoA */
328*4882a593Smuzhiyun phl_p2pps_noa_all_role_pause(phl, wrole->hw_band);
329*4882a593Smuzhiyun #endif
330*4882a593Smuzhiyun FUNCOUT();
331*4882a593Smuzhiyun return psts;
332*4882a593Smuzhiyun }
rtw_phl_ap_started(void * phl,struct rtw_wifi_role_t * wrole)333*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ap_started(void *phl, struct rtw_wifi_role_t *wrole)
334*4882a593Smuzhiyun {
335*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
336*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
337*4882a593Smuzhiyun
338*4882a593Smuzhiyun FUNCIN();
339*4882a593Smuzhiyun psts = phl_role_notify(phl_info, wrole);
340*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
341*4882a593Smuzhiyun PHL_ERR("%s role notify failed\n", __func__);
342*4882a593Smuzhiyun goto _exit;
343*4882a593Smuzhiyun }
344*4882a593Smuzhiyun psts = phl_mr_info_upt(phl_info, wrole);
345*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
346*4882a593Smuzhiyun PHL_ERR("%s mr info upt failed\n", __func__);
347*4882a593Smuzhiyun goto _exit;
348*4882a593Smuzhiyun }
349*4882a593Smuzhiyun psts = rtw_phl_mr_rx_filter(phl, wrole);
350*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
351*4882a593Smuzhiyun PHL_ERR("%s set mr_rx_filter failed\n", __func__);
352*4882a593Smuzhiyun goto _exit;
353*4882a593Smuzhiyun }
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun psts = phl_mr_tsf_sync(phl, wrole, PHL_ROLE_MSTS_AP_START);
356*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
357*4882a593Smuzhiyun PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
358*4882a593Smuzhiyun goto _exit;
359*4882a593Smuzhiyun }
360*4882a593Smuzhiyun psts = phl_mr_state_upt(phl_info, wrole);
361*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
362*4882a593Smuzhiyun PHL_ERR("%s phl_mr_state_upt failed\n", __func__);
363*4882a593Smuzhiyun goto _exit;
364*4882a593Smuzhiyun }
365*4882a593Smuzhiyun
366*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
367*4882a593Smuzhiyun
368*4882a593Smuzhiyun _exit:
369*4882a593Smuzhiyun FUNCOUT();
370*4882a593Smuzhiyun return psts;
371*4882a593Smuzhiyun }
372*4882a593Smuzhiyun
rtw_phl_ap_stop_prepare(void * phl,struct rtw_wifi_role_t * wrole)373*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ap_stop_prepare(void *phl, struct rtw_wifi_role_t *wrole)
374*4882a593Smuzhiyun {
375*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
376*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun FUNCIN();
379*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
380*4882a593Smuzhiyun /* disable NoA for this role */
381*4882a593Smuzhiyun phl_p2pps_noa_disable_all(phl_info, wrole);
382*4882a593Smuzhiyun /* pasue buddy NoA */
383*4882a593Smuzhiyun phl_p2pps_noa_all_role_pause(phl_info, wrole->hw_band);
384*4882a593Smuzhiyun #endif
385*4882a593Smuzhiyun FUNCOUT();
386*4882a593Smuzhiyun return psts;
387*4882a593Smuzhiyun }
388*4882a593Smuzhiyun
rtw_phl_ap_stop(void * phl,struct rtw_wifi_role_t * wrole)389*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ap_stop(void *phl, struct rtw_wifi_role_t *wrole)
390*4882a593Smuzhiyun {
391*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
392*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
393*4882a593Smuzhiyun
394*4882a593Smuzhiyun FUNCIN();
395*4882a593Smuzhiyun wrole->mstate = MLME_NO_LINK;
396*4882a593Smuzhiyun psts = phl_role_notify(phl_info, wrole);
397*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
398*4882a593Smuzhiyun PHL_ERR("%s role notify failed\n", __func__);
399*4882a593Smuzhiyun goto _exit;
400*4882a593Smuzhiyun }
401*4882a593Smuzhiyun
402*4882a593Smuzhiyun psts = phl_mr_info_upt(phl_info, wrole);
403*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
404*4882a593Smuzhiyun PHL_ERR("%s mr info upt failed\n", __func__);
405*4882a593Smuzhiyun goto _exit;
406*4882a593Smuzhiyun }
407*4882a593Smuzhiyun psts = rtw_phl_mr_rx_filter(phl, wrole);
408*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
409*4882a593Smuzhiyun PHL_ERR("%s set mr_rx_filter failed\n", __func__);
410*4882a593Smuzhiyun goto _exit;
411*4882a593Smuzhiyun }
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun psts = phl_mr_tsf_sync(phl, wrole, PHL_ROLE_MSTS_AP_STOP);
414*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
415*4882a593Smuzhiyun PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
416*4882a593Smuzhiyun goto _exit;
417*4882a593Smuzhiyun }
418*4882a593Smuzhiyun psts = phl_mr_state_upt(phl_info, wrole);
419*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
420*4882a593Smuzhiyun PHL_ERR("%s phl_mr_state_upt failed\n", __func__);
421*4882a593Smuzhiyun goto _exit;
422*4882a593Smuzhiyun }
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun #ifdef RTW_PHL_BCN
425*4882a593Smuzhiyun psts = rtw_phl_free_bcn_entry(phl_info, wrole);
426*4882a593Smuzhiyun if (psts != RTW_PHL_STATUS_SUCCESS) {
427*4882a593Smuzhiyun PHL_ERR("%s phl_free_bcn_entry failed\n", __func__);
428*4882a593Smuzhiyun goto _exit;
429*4882a593Smuzhiyun }
430*4882a593Smuzhiyun #endif
431*4882a593Smuzhiyun rtw_hal_disconnect_notify(phl_info->hal, &wrole->chandef);
432*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
433*4882a593Smuzhiyun /* resume buddy NoA */
434*4882a593Smuzhiyun phl_p2pps_noa_all_role_resume(phl, wrole->hw_band);
435*4882a593Smuzhiyun #endif
436*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
437*4882a593Smuzhiyun _exit:
438*4882a593Smuzhiyun FUNCOUT();
439*4882a593Smuzhiyun return psts;
440*4882a593Smuzhiyun }
441*4882a593Smuzhiyun #endif
442*4882a593Smuzhiyun
443*4882a593Smuzhiyun #ifdef CONFIG_IBSS_CMD_DISPR
rtw_phl_ibss_started(void * phl,struct rtw_wifi_role_t * wrole)444*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ibss_started(void *phl, struct rtw_wifi_role_t *wrole)
445*4882a593Smuzhiyun {
446*4882a593Smuzhiyun PHL_ERR("%s failed, cmd dispatcher not support\n", __func__);
447*4882a593Smuzhiyun return RTW_PHL_STATUS_FAILURE;
448*4882a593Smuzhiyun }
449*4882a593Smuzhiyun #else /* CONFIG_IBSS_CMD_DISPR */
rtw_phl_ibss_started(void * phl,struct rtw_wifi_role_t * wrole)450*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_ibss_started(void *phl, struct rtw_wifi_role_t *wrole)
451*4882a593Smuzhiyun {
452*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
453*4882a593Smuzhiyun
454*4882a593Smuzhiyun #ifdef RTW_WKARD_IBSS_SNIFFER_MODE
455*4882a593Smuzhiyun rtw_hal_set_rxfltr_by_mode(phl_info->hal, wrole->hw_band,
456*4882a593Smuzhiyun RX_FLTR_MODE_SNIFFER);
457*4882a593Smuzhiyun #endif
458*4882a593Smuzhiyun
459*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
460*4882a593Smuzhiyun }
461*4882a593Smuzhiyun
462*4882a593Smuzhiyun #endif
463*4882a593Smuzhiyun
464*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_disconnected_resume_hdlr(void * phl,struct rtw_wifi_role_t * wrole)465*4882a593Smuzhiyun rtw_phl_disconnected_resume_hdlr(void *phl,
466*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
467*4882a593Smuzhiyun {
468*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
469*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
470*4882a593Smuzhiyun
471*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_MCC, _PHL_INFO_, "%s wrole->id(%d)\n",
472*4882a593Smuzhiyun __func__, wrole->id);
473*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
474*4882a593Smuzhiyun /* resume buddy NoA */
475*4882a593Smuzhiyun phl_p2pps_noa_all_role_resume(phl_info, wrole->hw_band);
476*4882a593Smuzhiyun #endif
477*4882a593Smuzhiyun #ifdef CONFIG_MCC_SUPPORT
478*4882a593Smuzhiyun /* Enable MR coex mechanism(if needed) */
479*4882a593Smuzhiyun psts = phl_mr_coex_handle(phl_info, wrole, 0, wrole->hw_band,
480*4882a593Smuzhiyun MR_COEX_TRIG_BY_DIS_LINKING);
481*4882a593Smuzhiyun #endif
482*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
483*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_MCC, _PHL_INFO_, "%s psts(%d)\n",
484*4882a593Smuzhiyun __func__, psts);
485*4882a593Smuzhiyun return psts;
486*4882a593Smuzhiyun }
487*4882a593Smuzhiyun
488*4882a593Smuzhiyun enum rtw_phl_status
rtw_phl_ap_stop_resume_hdlr(void * phl,struct rtw_wifi_role_t * wrole)489*4882a593Smuzhiyun rtw_phl_ap_stop_resume_hdlr(void *phl,
490*4882a593Smuzhiyun struct rtw_wifi_role_t *wrole)
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun {
493*4882a593Smuzhiyun enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
494*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
495*4882a593Smuzhiyun
496*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_MCC, _PHL_INFO_, "%s wrole->id(%d)\n",
497*4882a593Smuzhiyun __func__, wrole->id);
498*4882a593Smuzhiyun #ifdef CONFIG_PHL_P2PPS
499*4882a593Smuzhiyun /* resume buddy NoA */
500*4882a593Smuzhiyun phl_p2pps_noa_all_role_resume(phl_info, wrole->hw_band);
501*4882a593Smuzhiyun #endif
502*4882a593Smuzhiyun #ifdef CONFIG_MCC_SUPPORT
503*4882a593Smuzhiyun /* Enable MR coex mechanism(if needed) */
504*4882a593Smuzhiyun psts = phl_mr_coex_handle(phl_info, wrole, 0, wrole->hw_band,
505*4882a593Smuzhiyun MR_COEX_TRIG_BY_DIS_LINKING);
506*4882a593Smuzhiyun #endif
507*4882a593Smuzhiyun PHL_DUMP_MR_EX(phl_info);
508*4882a593Smuzhiyun PHL_TRACE(COMP_PHL_MCC, _PHL_INFO_, "%s psts(%d)\n",
509*4882a593Smuzhiyun __func__, psts);
510*4882a593Smuzhiyun return psts;
511*4882a593Smuzhiyun }
512*4882a593Smuzhiyun
513*4882a593Smuzhiyun #ifdef RTW_WKARD_P2P_LISTEN
rtw_phl_p2p_listen_start(void * phl,struct rtw_wifi_role_t * wrole)514*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_p2p_listen_start(void *phl, struct rtw_wifi_role_t *wrole)
515*4882a593Smuzhiyun {
516*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
517*4882a593Smuzhiyun
518*4882a593Smuzhiyun rtw_hal_set_rxfltr_by_mode(phl_info->hal, wrole->hw_band,
519*4882a593Smuzhiyun RX_FLTR_MODE_SNIFFER);
520*4882a593Smuzhiyun
521*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
522*4882a593Smuzhiyun }
523*4882a593Smuzhiyun
rtw_phl_p2p_listen_end(void * phl,struct rtw_wifi_role_t * wrole)524*4882a593Smuzhiyun enum rtw_phl_status rtw_phl_p2p_listen_end(void *phl, struct rtw_wifi_role_t *wrole)
525*4882a593Smuzhiyun {
526*4882a593Smuzhiyun struct phl_info_t *phl_info = (struct phl_info_t *)phl;
527*4882a593Smuzhiyun
528*4882a593Smuzhiyun /* restore rx filter mode */
529*4882a593Smuzhiyun rtw_phl_mr_rx_filter(phl_info, wrole);
530*4882a593Smuzhiyun
531*4882a593Smuzhiyun return RTW_PHL_STATUS_SUCCESS;
532*4882a593Smuzhiyun }
533*4882a593Smuzhiyun #endif /* RTW_WKARD_P2P_LISTEN */
534