1
2 /*
3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 #include <wma_coex.h>
21 #include <wma.h>
22 #include "wmi_unified.h"
23
24 /**
25 * wma_mws_coex_state_host_event_handler - Coex state Event Handler
26 * @handle: pointer to scn handle
27 * @event: Coex state event
28 * @len: Length of cmd
29 *
30 * Return: 0 on success, else error on failure
31 */
wma_mws_coex_state_host_event_handler(void * handle,uint8_t * event,uint32_t len)32 static int wma_mws_coex_state_host_event_handler(void *handle, uint8_t *event,
33 uint32_t len)
34 {
35 WMI_VDEV_GET_MWS_COEX_STATE_EVENTID_param_tlvs *param_tlvs;
36 wmi_vdev_get_mws_coex_state_fixed_param *param_buf;
37 struct mws_coex_state coex_state;
38 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
39
40 wma_debug("Enter");
41 param_tlvs =
42 (WMI_VDEV_GET_MWS_COEX_STATE_EVENTID_param_tlvs *)event;
43 if (!param_tlvs) {
44 wma_err("Invalid stats event");
45 return -EINVAL;
46 }
47
48 param_buf = param_tlvs->fixed_param;
49 if (!param_buf || !mac || !mac->sme.mws_coex_info_state_resp_callback) {
50 wma_debug("NULL mac ptr or HDD callback is null");
51 return -EINVAL;
52 }
53
54 if (!param_buf) {
55 wma_debug("NULL mws coes state event fixed param");
56 return -EINVAL;
57 }
58
59 coex_state.vdev_id = param_buf->vdev_id;
60 coex_state.coex_scheme_bitmap = param_buf->coex_scheme_bitmap;
61 coex_state.active_conflict_count = param_buf->active_conflict_count;
62 coex_state.potential_conflict_count =
63 param_buf->potential_conflict_count;
64 coex_state.chavd_group0_bitmap = param_buf->chavd_group0_bitmap;
65 coex_state.chavd_group1_bitmap = param_buf->chavd_group1_bitmap;
66 coex_state.chavd_group2_bitmap = param_buf->chavd_group2_bitmap;
67 coex_state.chavd_group3_bitmap = param_buf->chavd_group3_bitmap;
68 mac->sme.mws_coex_info_state_resp_callback(&coex_state,
69 mac->sme.mws_coex_info_ctx,
70 WMI_MWS_COEX_STATE);
71 wma_debug("vdev_id = %u coex_scheme_bitmap = %u active_conflict_count = %u potential_conflict_count = %u chavd_group0_bitmap = %u chavd_group1_bitmap = %u chavd_group2_bitmap = %u chavd_group3_bitmap = %u",
72 param_buf->vdev_id, param_buf->coex_scheme_bitmap,
73 param_buf->active_conflict_count,
74 param_buf->potential_conflict_count,
75 param_buf->chavd_group0_bitmap,
76 param_buf->chavd_group1_bitmap,
77 param_buf->chavd_group2_bitmap,
78 param_buf->chavd_group3_bitmap);
79
80 wma_debug("Exit");
81 return 0;
82 }
83
84 /**
85 * wma_mws_coex_state_dpwb_event_handler - DPWB state Event Handler
86 * @handle: handle to scn
87 * @event: DPWB state event
88 * @len: Length of cmd
89 *
90 * Return: 0 on success, else error on failure
91 */
wma_mws_coex_state_dpwb_event_handler(void * handle,uint8_t * event,uint32_t len)92 static int wma_mws_coex_state_dpwb_event_handler(void *handle, uint8_t *event,
93 uint32_t len)
94 {
95 WMI_VDEV_GET_MWS_COEX_DPWB_STATE_EVENTID_param_tlvs *param_tlvs;
96 wmi_vdev_get_mws_coex_dpwb_state_fixed_param *param_buf;
97 struct mws_coex_dpwb_state coex_dpwb;
98 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
99
100 wma_debug("Enter");
101 param_tlvs =
102 (WMI_VDEV_GET_MWS_COEX_DPWB_STATE_EVENTID_param_tlvs *)event;
103 if (!param_tlvs) {
104 wma_err("Invalid coex mws event");
105 return -EINVAL;
106 }
107
108 param_buf = param_tlvs->fixed_param;
109 if (!param_buf || !mac || !mac->sme.mws_coex_info_state_resp_callback) {
110 wma_debug("NULL mac ptr or HDD callback is null");
111 return -EINVAL;
112 }
113
114 if (!param_buf) {
115 wma_err("NULL mws dpwb info event fixed param");
116 return -EINVAL;
117 }
118
119 coex_dpwb.vdev_id = param_buf->vdev_id;
120 coex_dpwb.current_dpwb_state = param_buf->current_dpwb_state;
121 coex_dpwb.pnp1_value = param_buf->pnp1_value;
122 coex_dpwb.lte_dutycycle = param_buf->lte_dutycycle;
123 coex_dpwb.sinr_wlan_on = param_buf->sinr_wlan_on;
124 coex_dpwb.sinr_wlan_off = param_buf->sinr_wlan_off;
125 coex_dpwb.bler_count = param_buf->bler_count;
126 coex_dpwb.block_count = param_buf->block_count;
127 coex_dpwb.wlan_rssi_level = param_buf->wlan_rssi_level;
128 coex_dpwb.wlan_rssi = param_buf->wlan_rssi;
129 coex_dpwb.is_tdm_running = param_buf->is_tdm_running;
130 mac->sme.mws_coex_info_state_resp_callback(&coex_dpwb,
131 mac->sme.mws_coex_info_ctx,
132 WMI_MWS_COEX_DPWB_STATE);
133 wma_debug("vdev_id = %u current_dpwb_state = %d pnp1_value = %d lte_dutycycle = %d sinr_wlan_on = %d sinr_wlan_off = %d bler_count = %u block_count = %u wlan_rssi_level = %u wlan_rssi = %d is_tdm_running = %u",
134 param_buf->vdev_id, param_buf->current_dpwb_state,
135 param_buf->pnp1_value,
136 param_buf->lte_dutycycle, param_buf->sinr_wlan_on,
137 param_buf->sinr_wlan_off, param_buf->bler_count,
138 param_buf->block_count, param_buf->wlan_rssi_level,
139 param_buf->wlan_rssi, param_buf->is_tdm_running);
140
141 wma_debug("Exit");
142 return 0;
143 }
144
145 /**
146 * wma_mws_coex_tdm_event_handler - TDM state Event Handler
147 * @handle: handle to scn
148 * @event: TDM state event
149 * @len: Length of cmd
150 *
151 * Return: 0 on success, else error on failure
152 */
wma_mws_coex_tdm_event_handler(void * handle,uint8_t * event,uint32_t len)153 static int wma_mws_coex_tdm_event_handler(void *handle, uint8_t *event,
154 uint32_t len)
155 {
156 WMI_VDEV_GET_MWS_COEX_TDM_STATE_EVENTID_param_tlvs *param_tlvs;
157 wmi_vdev_get_mws_coex_tdm_state_fixed_param *param_buf;
158 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
159 struct mws_coex_tdm_state coex_tdm;
160
161 wma_debug("Enter");
162 param_tlvs =
163 (WMI_VDEV_GET_MWS_COEX_TDM_STATE_EVENTID_param_tlvs *)event;
164 if (!param_tlvs) {
165 wma_err("Invalid MWS coex event");
166 return -EINVAL;
167 }
168
169 param_buf = param_tlvs->fixed_param;
170 if (!param_buf || !mac || !mac->sme.mws_coex_info_state_resp_callback) {
171 wma_debug("NULL mac ptr or HDD callback is null");
172 return -EINVAL;
173 }
174
175 if (!param_buf) {
176 wma_debug("NULL mws tdm info event fixed param");
177 return -EINVAL;
178 }
179
180 coex_tdm.vdev_id = param_buf->vdev_id;
181 coex_tdm.tdm_policy_bitmap = param_buf->tdm_policy_bitmap;
182 coex_tdm.tdm_sf_bitmap = param_buf->tdm_sf_bitmap;
183
184 mac->sme.mws_coex_info_state_resp_callback(&coex_tdm,
185 mac->sme.mws_coex_info_ctx,
186 WMI_MWS_COEX_TDM_STATE);
187 wma_debug("vdev_id = %u tdm_policy_bitmap = %u tdm_sf_bitmap = %u",
188 param_buf->vdev_id, param_buf->tdm_policy_bitmap,
189 param_buf->tdm_sf_bitmap);
190
191 wma_debug("Exit");
192 return 0;
193 }
194
195 /**
196 * wma_mws_coex_idrx_event_handler - IDRX state Event Handler
197 * @handle: handle to scn
198 * @event: IDRX state event
199 * @len: Length of cmd
200 *
201 * Return: 0 on success, else error on failure
202 */
wma_mws_coex_idrx_event_handler(void * handle,uint8_t * event,uint32_t len)203 static int wma_mws_coex_idrx_event_handler(void *handle, uint8_t *event,
204 uint32_t len)
205 {
206 WMI_VDEV_GET_MWS_COEX_IDRX_STATE_EVENTID_param_tlvs *param_tlvs;
207 wmi_vdev_get_mws_coex_idrx_state_fixed_param *param_buf;
208 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
209 struct mws_coex_idrx_state coex_idrx;
210
211 wma_debug("Enter");
212 param_tlvs =
213 (WMI_VDEV_GET_MWS_COEX_IDRX_STATE_EVENTID_param_tlvs *)event;
214 if (!param_tlvs) {
215 wma_err("Invalid stats event");
216 return -EINVAL;
217 }
218
219 param_buf = param_tlvs->fixed_param;
220 if (!param_buf || !mac || !mac->sme.mws_coex_info_state_resp_callback) {
221 wma_debug("NULL mac ptr or HDD callback is null");
222 return -EINVAL;
223 }
224
225 if (!param_buf) {
226 wma_debug("NULL MWS Coex event fixed param");
227 return -EINVAL;
228 }
229
230 coex_idrx.vdev_id = param_buf->vdev_id;
231 coex_idrx.sub0_techid = param_buf->sub0_techid;
232 coex_idrx.sub0_policy = param_buf->sub0_policy;
233 coex_idrx.sub0_is_link_critical = param_buf->sub0_is_link_critical;
234 coex_idrx.sub0_static_power = param_buf->sub0_static_power;
235 coex_idrx.sub0_rssi = param_buf->sub0_rssi;
236 coex_idrx.sub1_techid = param_buf->sub1_techid;
237 coex_idrx.sub1_policy = param_buf->sub1_policy;
238 coex_idrx.sub1_is_link_critical = param_buf->sub1_is_link_critical;
239 coex_idrx.sub1_static_power = param_buf->sub1_static_power;
240 coex_idrx.sub1_rssi = param_buf->sub1_rssi;
241 mac->sme.mws_coex_info_state_resp_callback(&coex_idrx,
242 mac->sme.mws_coex_info_ctx,
243 WMI_MWS_COEX_IDRX_STATE);
244
245 wma_debug("vdev_id = %u sub0_techid = %u sub0_policy = %u sub0_is_link_critical = %u sub0_static_power = %u sub0_rssi = %d sub1_techid = %d sub1_policy = %d sub1_is_link_critical = %d sub1_static_power = %u sub1_rssi= %d",
246 param_buf->vdev_id, param_buf->sub0_techid,
247 param_buf->sub0_policy, param_buf->sub0_is_link_critical,
248 param_buf->sub0_static_power, param_buf->sub0_rssi,
249 param_buf->sub1_techid, param_buf->sub1_policy,
250 param_buf->sub1_is_link_critical,
251 param_buf->sub1_static_power, param_buf->sub1_rssi);
252
253 wma_debug("EXIT");
254 return 0;
255 }
256
257 /**
258 * wma_mws_coex_antenna_sharing_event_handler - Antenna sharing Event Handler
259 * @handle: handle to scn
260 * @event: Antenna sharing state event
261 * @len: Length of cmd
262 *
263 * Return: 0 on success, else error on failure
264 */
wma_mws_coex_antenna_sharing_event_handler(void * handle,uint8_t * event,uint32_t len)265 static int wma_mws_coex_antenna_sharing_event_handler(void *handle,
266 uint8_t *event,
267 uint32_t len)
268 {
269 WMI_VDEV_GET_MWS_COEX_ANTENNA_SHARING_STATE_EVENTID_param_tlvs
270 *param_tlvs =
271 (WMI_VDEV_GET_MWS_COEX_ANTENNA_SHARING_STATE_EVENTID_param_tlvs *)event;
272 wmi_vdev_get_mws_coex_antenna_sharing_state_fixed_param *param_buf;
273 struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
274 struct mws_antenna_sharing_info *antenna_sharing;
275
276 wma_debug("Enter");
277 if (!param_tlvs) {
278 wma_err("Invalid stats event");
279 return -EINVAL;
280 }
281
282 param_buf = param_tlvs->fixed_param;
283 if (!param_buf || !mac || !mac->sme.mws_coex_info_state_resp_callback) {
284 wma_debug("NULL mac ptr or HDD callback is null");
285 return -EINVAL;
286 }
287
288 if (!param_buf) {
289 wma_debug("NULL MWS event fixed param");
290 return -EINVAL;
291 }
292
293 antenna_sharing = qdf_mem_malloc(sizeof(*antenna_sharing));
294 if (!antenna_sharing)
295 return -ENOMEM;
296
297 antenna_sharing->vdev_id = param_buf->vdev_id;
298 antenna_sharing->coex_flags = param_buf->coex_flags;
299 antenna_sharing->coex_config = param_buf->coex_config;
300 antenna_sharing->tx_chain_mask = param_buf->tx_chain_mask;
301 antenna_sharing->rx_chain_mask = param_buf->rx_chain_mask;
302 antenna_sharing->rx_nss = param_buf->rx_nss;
303 antenna_sharing->force_mrc = param_buf->force_mrc;
304 antenna_sharing->rssi_type = param_buf->rssi_type;
305 antenna_sharing->chain0_rssi = param_buf->chain0_rssi;
306 antenna_sharing->chain1_rssi = param_buf->chain1_rssi;
307 antenna_sharing->combined_rssi = param_buf->combined_rssi;
308 antenna_sharing->imbalance = param_buf->imbalance;
309 antenna_sharing->mrc_threshold = param_buf->mrc_threshold;
310 antenna_sharing->grant_duration = param_buf->grant_duration;
311
312 mac->sme.mws_coex_info_state_resp_callback(antenna_sharing,
313 mac->sme.mws_coex_info_ctx,
314 WMI_MWS_COEX_ANTENNA_SHARING_STATE);
315 wma_debug("vdev_id = %u coex_flags = %u coex_config = %u tx_chain_mask = %u rx_chain_mask = %u rx_nss = %u force_mrc = %u rssi_type = %u chain0_rssi = %d chain1_rssi = %d chain0_rssi = %d imbalance = %u mrc_threshold = %d grant_duration = %u",
316 param_buf->vdev_id, param_buf->coex_flags,
317 param_buf->coex_config, param_buf->tx_chain_mask,
318 param_buf->rx_chain_mask,
319 param_buf->rx_nss, param_buf->force_mrc,
320 param_buf->rssi_type, param_buf->chain0_rssi,
321 param_buf->chain1_rssi, param_buf->combined_rssi,
322 param_buf->imbalance, param_buf->mrc_threshold,
323 param_buf->grant_duration);
324
325 qdf_mem_free(antenna_sharing);
326 wma_debug("EXIT");
327 return 0;
328 }
329
wma_get_mws_coex_info_req(tp_wma_handle wma_handle,struct sir_get_mws_coex_info * req)330 void wma_get_mws_coex_info_req(tp_wma_handle wma_handle,
331 struct sir_get_mws_coex_info *req)
332 {
333 QDF_STATUS status;
334
335 status = wmi_unified_send_mws_coex_req_cmd(wma_handle->wmi_handle,
336 req->vdev_id, req->cmd_id);
337
338 if (QDF_IS_STATUS_ERROR(status))
339 wma_err("Failed to send mws coex info");
340 }
341
wma_register_mws_coex_events(tp_wma_handle wma_handle)342 void wma_register_mws_coex_events(tp_wma_handle wma_handle)
343 {
344 if (wma_validate_handle(wma_handle))
345 return;
346
347 wmi_unified_register_event_handler(wma_handle->wmi_handle,
348 wmi_vdev_get_mws_coex_state_eventid,
349 wma_mws_coex_state_host_event_handler,
350 WMA_RX_SERIALIZER_CTX);
351
352 wmi_unified_register_event_handler(
353 wma_handle->wmi_handle,
354 wmi_vdev_get_mws_coex_dpwb_state_eventid,
355 wma_mws_coex_state_dpwb_event_handler,
356 WMA_RX_SERIALIZER_CTX);
357
358 wmi_unified_register_event_handler(
359 wma_handle->wmi_handle,
360 wmi_vdev_get_mws_coex_tdm_state_eventid,
361 wma_mws_coex_tdm_event_handler,
362 WMA_RX_SERIALIZER_CTX);
363
364 wmi_unified_register_event_handler(
365 wma_handle->wmi_handle,
366 wmi_vdev_get_mws_coex_idrx_state_eventid,
367 wma_mws_coex_idrx_event_handler,
368 WMA_RX_SERIALIZER_CTX);
369
370 wmi_unified_register_event_handler(
371 wma_handle->wmi_handle,
372 wmi_vdev_get_mws_coex_antenna_sharing_state_eventid,
373 wma_mws_coex_antenna_sharing_event_handler,
374 WMA_RX_SERIALIZER_CTX);
375 }
376