blob: 0108dfc97ea7b86a5a1039cf8585a39c83f4594c [file] [log] [blame]
Mukul Sharmad75a6672017-06-22 15:40:53 +05301/*
Jeff Johnsonb4c29962017-10-07 19:35:14 -07002 * Copyright (c) 2017 The Linux Foundation. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
Mukul Sharmad75a6672017-06-22 15:40:53 +053018/**
19 * DOC: Implements public API for pmo to interact with target/WMI
20 */
21
22#include "wlan_pmo_tgt_api.h"
23#include "wlan_pmo_wow.h"
24#include "wlan_pmo_obj_mgmt_public_struct.h"
25#include "wlan_pmo_main.h"
26
27QDF_STATUS pmo_tgt_vdev_update_param_req(struct wlan_objmgr_vdev *vdev,
28 enum pmo_vdev_param_id param_id, uint32_t param_value)
29{
30 QDF_STATUS status;
31 struct wlan_objmgr_psoc *psoc;
32 struct wlan_pmo_tx_ops pmo_tx_ops;
33
34 PMO_ENTER();
35
36 psoc = pmo_vdev_get_psoc(vdev);
37
38 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
39 if (!pmo_tx_ops.send_vdev_param_update_req) {
40 pmo_err("send_vdev_param_update_req is null");
41 status = QDF_STATUS_E_NULL_VALUE;
42 goto out;
43 }
44
45 status = pmo_tx_ops.send_vdev_param_update_req(vdev, param_id,
46 param_value);
47out:
48 PMO_EXIT();
49
50 return status;
51}
52
53QDF_STATUS pmo_tgt_send_vdev_sta_ps_param(struct wlan_objmgr_vdev *vdev,
54 enum pmo_sta_powersave_param ps_param, uint32_t param_value)
55{
56 QDF_STATUS status;
57 struct wlan_objmgr_psoc *psoc;
58 struct wlan_pmo_tx_ops pmo_tx_ops;
59
60 PMO_ENTER();
61
62 psoc = pmo_vdev_get_psoc(vdev);
63
64 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
65 if (!pmo_tx_ops.send_vdev_sta_ps_param_req) {
66 pmo_err("send_vdev_param_set_req is null");
67 status = QDF_STATUS_E_NULL_VALUE;
68 goto out;
69 }
70
71 status = pmo_tx_ops.send_vdev_sta_ps_param_req(vdev, ps_param,
72 param_value);
73out:
74 PMO_EXIT();
75
76 return status;
77}
78
79void pmo_tgt_psoc_update_wow_bus_suspend_state(struct wlan_objmgr_psoc *psoc,
80 uint8_t val)
81{
82 struct wlan_pmo_tx_ops pmo_tx_ops;
83
84 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
85 if (!pmo_tx_ops.psoc_update_wow_bus_suspend) {
86 pmo_err("psoc_update_wow_bus_suspend is null");
87 return;
88 }
89 pmo_tx_ops.psoc_update_wow_bus_suspend(psoc, val);
90}
91
92int pmo_tgt_psoc_get_host_credits(struct wlan_objmgr_psoc *psoc)
93{
94
95 struct wlan_pmo_tx_ops pmo_tx_ops;
96
97 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
98 if (!pmo_tx_ops.psoc_get_host_credits) {
99 pmo_err("psoc_get_host_credits is null");
100 return 0;
101 }
102
103 return pmo_tx_ops.psoc_get_host_credits(psoc);
104}
105
106int pmo_tgt_psoc_get_pending_cmnds(struct wlan_objmgr_psoc *psoc)
107{
108
109 struct wlan_pmo_tx_ops pmo_tx_ops;
110
111 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
112 if (!pmo_tx_ops.psoc_get_pending_cmnds) {
113 pmo_err("psoc_get_pending_cmnds is null");
114 return -EAGAIN;
115 }
116
117 return pmo_tx_ops.psoc_get_pending_cmnds(psoc);
118}
119
120void pmo_tgt_update_target_suspend_flag(struct wlan_objmgr_psoc *psoc,
121 uint8_t val)
122{
123 struct wlan_pmo_tx_ops pmo_tx_ops;
124
125 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
126 if (!pmo_tx_ops.update_target_suspend_flag) {
127 pmo_err("update_target_suspend_flag is null");
128 return;
129 }
130 pmo_tx_ops.update_target_suspend_flag(psoc, val);
131}
132
133QDF_STATUS pmo_tgt_psoc_send_wow_enable_req(struct wlan_objmgr_psoc *psoc,
134 struct pmo_wow_cmd_params *param)
135{
136 struct wlan_pmo_tx_ops pmo_tx_ops;
137
138 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
139 if (!pmo_tx_ops.psoc_send_wow_enable_req) {
140 pmo_err("psoc_send_wow_enable_req is null");
141 return QDF_STATUS_E_NULL_VALUE;
142 }
143
144 return pmo_tx_ops.psoc_send_wow_enable_req(psoc, param);
145}
146
147QDF_STATUS pmo_tgt_psoc_send_supend_req(struct wlan_objmgr_psoc *psoc,
148 struct pmo_suspend_params *param)
149{
150 struct wlan_pmo_tx_ops pmo_tx_ops;
151
152 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
153 if (!pmo_tx_ops.psoc_send_supend_req) {
154 pmo_err("psoc_send_supend_req is null");
155 return QDF_STATUS_E_NULL_VALUE;
156 }
157
158 return pmo_tx_ops.psoc_send_supend_req(psoc, param);
159}
160
161QDF_STATUS pmo_tgt_psoc_set_runtime_pm_inprogress(struct wlan_objmgr_psoc *psoc,
162 bool value)
163{
164 struct wlan_pmo_tx_ops pmo_tx_ops;
165
166 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
167 if (!pmo_tx_ops.psoc_set_runtime_pm_in_progress) {
168 pmo_err("pmo ops is null");
169 return QDF_STATUS_E_NULL_VALUE;
170 }
171
172 pmo_tx_ops.psoc_set_runtime_pm_in_progress(psoc, value);
173
174 return QDF_STATUS_SUCCESS;
175}
176
177bool pmo_tgt_psoc_get_runtime_pm_in_progress(struct wlan_objmgr_psoc *psoc)
178{
179 struct wlan_pmo_tx_ops pmo_tx_ops;
180
181 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
182 if (!pmo_tx_ops.psoc_get_runtime_pm_in_progress) {
183 pmo_err("psoc_get_runtime_pm_in_progress is null");
184 return QDF_STATUS_E_NULL_VALUE;
185 }
186
187 return pmo_tx_ops.psoc_get_runtime_pm_in_progress(psoc);
188}
189
190QDF_STATUS pmo_tgt_psoc_send_host_wakeup_ind(struct wlan_objmgr_psoc *psoc)
191{
192 struct wlan_pmo_tx_ops pmo_tx_ops;
193
194 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
195 if (!pmo_tx_ops.psoc_send_host_wakeup_ind) {
196 pmo_err("psoc_send_host_wakeup_ind is null");
197 return QDF_STATUS_E_NULL_VALUE;
198 }
199
200 return pmo_tx_ops.psoc_send_host_wakeup_ind(psoc);
201}
202
203QDF_STATUS pmo_tgt_psoc_send_target_resume_req(struct wlan_objmgr_psoc *psoc)
204{
205 struct wlan_pmo_tx_ops pmo_tx_ops;
206
207 pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc);
208 if (!pmo_tx_ops.psoc_send_target_resume_req) {
209 pmo_err("send_target_resume_req is null");
210 return QDF_STATUS_E_NULL_VALUE;
211 }
212
213 return pmo_tx_ops.psoc_send_target_resume_req(psoc);
214}
215