xref: /wlan-driver/qcacld-3.0/components/pmo/dispatcher/src/wlan_pmo_tgt_suspend_resume.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name /**
21*5113495bSYour Name  * DOC: Implements public API for pmo to interact with target/WMI
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #include "wlan_pmo_tgt_api.h"
25*5113495bSYour Name #include "wlan_pmo_wow.h"
26*5113495bSYour Name #include "wlan_pmo_obj_mgmt_public_struct.h"
27*5113495bSYour Name #include "wlan_pmo_main.h"
28*5113495bSYour Name 
pmo_tgt_vdev_update_param_req(struct wlan_objmgr_vdev * vdev,enum pmo_vdev_param_id param_id,uint32_t param_value)29*5113495bSYour Name QDF_STATUS pmo_tgt_vdev_update_param_req(struct wlan_objmgr_vdev *vdev,
30*5113495bSYour Name 		enum pmo_vdev_param_id param_id, uint32_t param_value)
31*5113495bSYour Name {
32*5113495bSYour Name 	QDF_STATUS status;
33*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
34*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
35*5113495bSYour Name 
36*5113495bSYour Name 	pmo_enter();
37*5113495bSYour Name 
38*5113495bSYour Name 	psoc = pmo_vdev_get_psoc(vdev);
39*5113495bSYour Name 
40*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
41*5113495bSYour Name 	if (!pmo_tx_ops.send_vdev_param_update_req) {
42*5113495bSYour Name 		pmo_err("send_vdev_param_update_req is null");
43*5113495bSYour Name 		status = QDF_STATUS_E_NULL_VALUE;
44*5113495bSYour Name 		goto out;
45*5113495bSYour Name 	}
46*5113495bSYour Name 
47*5113495bSYour Name 	status = pmo_tx_ops.send_vdev_param_update_req(vdev, param_id,
48*5113495bSYour Name 			param_value);
49*5113495bSYour Name out:
50*5113495bSYour Name 	pmo_exit();
51*5113495bSYour Name 
52*5113495bSYour Name 	return status;
53*5113495bSYour Name }
54*5113495bSYour Name 
55*5113495bSYour Name #ifdef WLAN_FEATURE_IGMP_OFFLOAD
56*5113495bSYour Name QDF_STATUS
pmo_tgt_send_igmp_offload_req(struct wlan_objmgr_vdev * vdev,struct pmo_igmp_offload_req * pmo_igmp_req)57*5113495bSYour Name pmo_tgt_send_igmp_offload_req(struct wlan_objmgr_vdev *vdev,
58*5113495bSYour Name 			      struct pmo_igmp_offload_req *pmo_igmp_req)
59*5113495bSYour Name {
60*5113495bSYour Name 	QDF_STATUS status;
61*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
62*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
63*5113495bSYour Name 
64*5113495bSYour Name 	psoc = pmo_vdev_get_psoc(vdev);
65*5113495bSYour Name 
66*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
67*5113495bSYour Name 	if (!pmo_tx_ops.send_igmp_offload_req) {
68*5113495bSYour Name 		pmo_err("send_vdev_param_set_req is null");
69*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
70*5113495bSYour Name 	}
71*5113495bSYour Name 
72*5113495bSYour Name 	status = pmo_tx_ops.send_igmp_offload_req(vdev, pmo_igmp_req);
73*5113495bSYour Name 
74*5113495bSYour Name 	return status;
75*5113495bSYour Name }
76*5113495bSYour Name #endif
77*5113495bSYour Name 
pmo_tgt_send_vdev_sta_ps_param(struct wlan_objmgr_vdev * vdev,enum pmo_sta_powersave_param ps_param,uint32_t param_value)78*5113495bSYour Name QDF_STATUS pmo_tgt_send_vdev_sta_ps_param(struct wlan_objmgr_vdev *vdev,
79*5113495bSYour Name 		enum pmo_sta_powersave_param ps_param, uint32_t param_value)
80*5113495bSYour Name {
81*5113495bSYour Name 	QDF_STATUS status;
82*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
83*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
84*5113495bSYour Name 
85*5113495bSYour Name 	psoc = pmo_vdev_get_psoc(vdev);
86*5113495bSYour Name 
87*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
88*5113495bSYour Name 	if (!pmo_tx_ops.send_vdev_sta_ps_param_req) {
89*5113495bSYour Name 		pmo_err("send_vdev_param_set_req is null");
90*5113495bSYour Name 		status = QDF_STATUS_E_NULL_VALUE;
91*5113495bSYour Name 		goto out;
92*5113495bSYour Name 	}
93*5113495bSYour Name 
94*5113495bSYour Name 	status = pmo_tx_ops.send_vdev_sta_ps_param_req(vdev, ps_param,
95*5113495bSYour Name 			param_value);
96*5113495bSYour Name out:
97*5113495bSYour Name 	return status;
98*5113495bSYour Name }
99*5113495bSYour Name 
pmo_tgt_psoc_update_wow_bus_suspend_state(struct wlan_objmgr_psoc * psoc,uint8_t val)100*5113495bSYour Name void pmo_tgt_psoc_update_wow_bus_suspend_state(struct wlan_objmgr_psoc *psoc,
101*5113495bSYour Name 		uint8_t val)
102*5113495bSYour Name {
103*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
104*5113495bSYour Name 
105*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
106*5113495bSYour Name 	if (!pmo_tx_ops.psoc_update_wow_bus_suspend) {
107*5113495bSYour Name 		pmo_err("psoc_update_wow_bus_suspend is null");
108*5113495bSYour Name 		return;
109*5113495bSYour Name 	}
110*5113495bSYour Name 	pmo_tx_ops.psoc_update_wow_bus_suspend(psoc, val);
111*5113495bSYour Name }
112*5113495bSYour Name 
pmo_tgt_psoc_get_host_credits(struct wlan_objmgr_psoc * psoc)113*5113495bSYour Name int pmo_tgt_psoc_get_host_credits(struct wlan_objmgr_psoc *psoc)
114*5113495bSYour Name {
115*5113495bSYour Name 
116*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
117*5113495bSYour Name 
118*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
119*5113495bSYour Name 	if (!pmo_tx_ops.psoc_get_host_credits) {
120*5113495bSYour Name 		pmo_err("psoc_get_host_credits is null");
121*5113495bSYour Name 		return 0;
122*5113495bSYour Name 	}
123*5113495bSYour Name 
124*5113495bSYour Name 	return pmo_tx_ops.psoc_get_host_credits(psoc);
125*5113495bSYour Name }
126*5113495bSYour Name 
pmo_tgt_psoc_get_pending_cmnds(struct wlan_objmgr_psoc * psoc)127*5113495bSYour Name int pmo_tgt_psoc_get_pending_cmnds(struct wlan_objmgr_psoc *psoc)
128*5113495bSYour Name {
129*5113495bSYour Name 
130*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
131*5113495bSYour Name 
132*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
133*5113495bSYour Name 	if (!pmo_tx_ops.psoc_get_pending_cmnds) {
134*5113495bSYour Name 		pmo_err("psoc_get_pending_cmnds is null");
135*5113495bSYour Name 		return -EAGAIN;
136*5113495bSYour Name 	}
137*5113495bSYour Name 
138*5113495bSYour Name 	return pmo_tx_ops.psoc_get_pending_cmnds(psoc);
139*5113495bSYour Name }
140*5113495bSYour Name 
pmo_tgt_update_target_suspend_flag(struct wlan_objmgr_psoc * psoc,uint8_t val)141*5113495bSYour Name void pmo_tgt_update_target_suspend_flag(struct wlan_objmgr_psoc *psoc,
142*5113495bSYour Name 		uint8_t val)
143*5113495bSYour Name {
144*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
145*5113495bSYour Name 
146*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
147*5113495bSYour Name 	if (!pmo_tx_ops.update_target_suspend_flag) {
148*5113495bSYour Name 		pmo_err("update_target_suspend_flag is null");
149*5113495bSYour Name 		return;
150*5113495bSYour Name 	}
151*5113495bSYour Name 	pmo_tx_ops.update_target_suspend_flag(psoc, val);
152*5113495bSYour Name }
153*5113495bSYour Name 
pmo_tgt_update_target_suspend_acked_flag(struct wlan_objmgr_psoc * psoc,uint8_t val)154*5113495bSYour Name void pmo_tgt_update_target_suspend_acked_flag(struct wlan_objmgr_psoc *psoc,
155*5113495bSYour Name 					      uint8_t val)
156*5113495bSYour Name {
157*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
158*5113495bSYour Name 
159*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
160*5113495bSYour Name 	if (!pmo_tx_ops.update_target_suspend_acked_flag) {
161*5113495bSYour Name 		pmo_err("update_target_suspend_acked_flag is null");
162*5113495bSYour Name 		return;
163*5113495bSYour Name 	}
164*5113495bSYour Name 	pmo_tx_ops.update_target_suspend_acked_flag(psoc, val);
165*5113495bSYour Name }
166*5113495bSYour Name 
pmo_tgt_is_target_suspended(struct wlan_objmgr_psoc * psoc)167*5113495bSYour Name bool pmo_tgt_is_target_suspended(struct wlan_objmgr_psoc *psoc)
168*5113495bSYour Name {
169*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
170*5113495bSYour Name 
171*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
172*5113495bSYour Name 	if (!pmo_tx_ops.is_target_suspended) {
173*5113495bSYour Name 		pmo_err("is_target_suspended is null");
174*5113495bSYour Name 		return false;
175*5113495bSYour Name 	}
176*5113495bSYour Name 	return pmo_tx_ops.is_target_suspended(psoc);
177*5113495bSYour Name }
178*5113495bSYour Name 
pmo_tgt_psoc_send_wow_enable_req(struct wlan_objmgr_psoc * psoc,struct pmo_wow_cmd_params * param)179*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_send_wow_enable_req(struct wlan_objmgr_psoc *psoc,
180*5113495bSYour Name 	struct pmo_wow_cmd_params *param)
181*5113495bSYour Name {
182*5113495bSYour Name 	struct pmo_psoc_priv_obj *psoc_ctx;
183*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
184*5113495bSYour Name 
185*5113495bSYour Name 	psoc_ctx = pmo_psoc_get_priv(psoc);
186*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
187*5113495bSYour Name 
188*5113495bSYour Name 	if (psoc_ctx->wow.wow_state == pmo_wow_state_legacy_d0) {
189*5113495bSYour Name 		if (!pmo_tx_ops.psoc_send_d0wow_enable_req) {
190*5113495bSYour Name 			pmo_err("psoc_send_d0wow_enable_req is null");
191*5113495bSYour Name 			return QDF_STATUS_E_NULL_VALUE;
192*5113495bSYour Name 		}
193*5113495bSYour Name 		pmo_debug("Sending D0WOW enable command...");
194*5113495bSYour Name 		return pmo_tx_ops.psoc_send_d0wow_enable_req(psoc);
195*5113495bSYour Name 	}
196*5113495bSYour Name 
197*5113495bSYour Name 	if (!pmo_tx_ops.psoc_send_wow_enable_req) {
198*5113495bSYour Name 		pmo_err("psoc_send_wow_enable_req is null");
199*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
200*5113495bSYour Name 	}
201*5113495bSYour Name 	return pmo_tx_ops.psoc_send_wow_enable_req(psoc, param);
202*5113495bSYour Name }
203*5113495bSYour Name 
pmo_tgt_psoc_send_supend_req(struct wlan_objmgr_psoc * psoc,struct pmo_suspend_params * param)204*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_send_supend_req(struct wlan_objmgr_psoc *psoc,
205*5113495bSYour Name 		struct pmo_suspend_params *param)
206*5113495bSYour Name {
207*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
208*5113495bSYour Name 
209*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
210*5113495bSYour Name 	if (!pmo_tx_ops.psoc_send_supend_req) {
211*5113495bSYour Name 		pmo_err("psoc_send_supend_req is null");
212*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
213*5113495bSYour Name 	}
214*5113495bSYour Name 
215*5113495bSYour Name 	return pmo_tx_ops.psoc_send_supend_req(psoc, param);
216*5113495bSYour Name }
217*5113495bSYour Name 
pmo_tgt_psoc_set_runtime_pm_inprogress(struct wlan_objmgr_psoc * psoc,bool value)218*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_set_runtime_pm_inprogress(struct wlan_objmgr_psoc *psoc,
219*5113495bSYour Name 						  bool value)
220*5113495bSYour Name {
221*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
222*5113495bSYour Name 
223*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
224*5113495bSYour Name 	if (!pmo_tx_ops.psoc_set_runtime_pm_in_progress) {
225*5113495bSYour Name 		pmo_err("pmo ops is null");
226*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
227*5113495bSYour Name 	}
228*5113495bSYour Name 
229*5113495bSYour Name 	pmo_tx_ops.psoc_set_runtime_pm_in_progress(psoc, value);
230*5113495bSYour Name 
231*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
232*5113495bSYour Name }
233*5113495bSYour Name 
pmo_tgt_psoc_get_runtime_pm_in_progress(struct wlan_objmgr_psoc * psoc)234*5113495bSYour Name bool pmo_tgt_psoc_get_runtime_pm_in_progress(struct wlan_objmgr_psoc *psoc)
235*5113495bSYour Name {
236*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
237*5113495bSYour Name 
238*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
239*5113495bSYour Name 	if (!pmo_tx_ops.psoc_get_runtime_pm_in_progress) {
240*5113495bSYour Name 		pmo_err("psoc_get_runtime_pm_in_progress is null");
241*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
242*5113495bSYour Name 	}
243*5113495bSYour Name 
244*5113495bSYour Name 	return pmo_tx_ops.psoc_get_runtime_pm_in_progress(psoc);
245*5113495bSYour Name }
246*5113495bSYour Name 
pmo_tgt_psoc_send_host_wakeup_ind(struct wlan_objmgr_psoc * psoc)247*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_send_host_wakeup_ind(struct wlan_objmgr_psoc *psoc)
248*5113495bSYour Name {
249*5113495bSYour Name 	struct pmo_psoc_priv_obj *psoc_ctx;
250*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
251*5113495bSYour Name 
252*5113495bSYour Name 	psoc_ctx = pmo_psoc_get_priv(psoc);
253*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
254*5113495bSYour Name 
255*5113495bSYour Name 	if (psoc_ctx->psoc_cfg.d0_wow_supported &&
256*5113495bSYour Name 	    psoc_ctx->wow.wow_state == pmo_wow_state_legacy_d0) {
257*5113495bSYour Name 		if (!pmo_tx_ops.psoc_send_d0wow_disable_req) {
258*5113495bSYour Name 			pmo_err("psoc_send_d0wow_disable_req is null");
259*5113495bSYour Name 			return QDF_STATUS_E_NULL_VALUE;
260*5113495bSYour Name 		}
261*5113495bSYour Name 		pmo_debug("Sending D0WOW disable command...");
262*5113495bSYour Name 		return pmo_tx_ops.psoc_send_d0wow_disable_req(psoc);
263*5113495bSYour Name 	}
264*5113495bSYour Name 
265*5113495bSYour Name 	if (!pmo_tx_ops.psoc_send_host_wakeup_ind) {
266*5113495bSYour Name 		pmo_err("psoc_send_host_wakeup_ind is null");
267*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
268*5113495bSYour Name 	}
269*5113495bSYour Name 	return pmo_tx_ops.psoc_send_host_wakeup_ind(psoc);
270*5113495bSYour Name }
271*5113495bSYour Name 
pmo_tgt_psoc_send_target_resume_req(struct wlan_objmgr_psoc * psoc)272*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_send_target_resume_req(struct wlan_objmgr_psoc *psoc)
273*5113495bSYour Name {
274*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
275*5113495bSYour Name 
276*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
277*5113495bSYour Name 	if (!pmo_tx_ops.psoc_send_target_resume_req) {
278*5113495bSYour Name 		pmo_err("send_target_resume_req is null");
279*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
280*5113495bSYour Name 	}
281*5113495bSYour Name 
282*5113495bSYour Name 	return pmo_tx_ops.psoc_send_target_resume_req(psoc);
283*5113495bSYour Name }
284*5113495bSYour Name 
pmo_tgt_psoc_send_idle_roam_monitor(struct wlan_objmgr_psoc * psoc,uint8_t val)285*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_send_idle_roam_monitor(struct wlan_objmgr_psoc *psoc,
286*5113495bSYour Name 					       uint8_t val)
287*5113495bSYour Name {
288*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
289*5113495bSYour Name 
290*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
291*5113495bSYour Name 	if (!pmo_tx_ops.psoc_send_idle_roam_suspend_mode) {
292*5113495bSYour Name 		pmo_err("NULL fp");
293*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
294*5113495bSYour Name 	}
295*5113495bSYour Name 	return pmo_tx_ops.psoc_send_idle_roam_suspend_mode(psoc, val);
296*5113495bSYour Name }
297*5113495bSYour Name 
pmo_tgt_psoc_set_wow_enable_ack_failed(struct wlan_objmgr_psoc * psoc)298*5113495bSYour Name QDF_STATUS pmo_tgt_psoc_set_wow_enable_ack_failed(struct wlan_objmgr_psoc *psoc)
299*5113495bSYour Name {
300*5113495bSYour Name 	struct wlan_pmo_tx_ops pmo_tx_ops;
301*5113495bSYour Name 
302*5113495bSYour Name 	pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
303*5113495bSYour Name 	if (!pmo_tx_ops.psoc_set_wow_enable_ack_failed) {
304*5113495bSYour Name 		pmo_err("pmo ops is null");
305*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
306*5113495bSYour Name 	}
307*5113495bSYour Name 
308*5113495bSYour Name 	pmo_tx_ops.psoc_set_wow_enable_ack_failed(psoc);
309*5113495bSYour Name 
310*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
311*5113495bSYour Name }
312