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