Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 | */ |
| 18 | |
| 19 | /** |
| 20 | * DOC: offload lmac interface APIs for ocb |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <qdf_mem.h> |
| 25 | #include <target_if.h> |
| 26 | #include <qdf_status.h> |
| 27 | #include <wmi_unified_api.h> |
| 28 | #include <wmi_unified_priv.h> |
| 29 | #include <wmi_unified_param.h> |
| 30 | #include <wlan_objmgr_psoc_obj.h> |
| 31 | #include <wlan_utility.h> |
| 32 | #include <wlan_defs.h> |
| 33 | #include <wlan_ocb_public_structs.h> |
| 34 | #include <wlan_ocb_main.h> |
| 35 | #include <target_if_ocb.h> |
| 36 | |
| 37 | /** |
| 38 | * target_if_ocb_get_rx_ops() - get target interface RX operations |
| 39 | * @pdev: pdev handle |
| 40 | * |
| 41 | * Return: fp to target interface RX operations |
| 42 | */ |
| 43 | static inline struct wlan_ocb_rx_ops * |
| 44 | target_if_ocb_get_rx_ops(struct wlan_objmgr_pdev *pdev) |
| 45 | { |
| 46 | struct ocb_pdev_obj *ocb_obj; |
| 47 | |
| 48 | ocb_obj = wlan_get_pdev_ocb_obj(pdev); |
| 49 | |
| 50 | return &ocb_obj->ocb_rxops; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * target_if_ocb_set_config() - send the OCB config to the FW |
| 55 | * @psoc: pointer to PSOC object |
| 56 | * @config: OCB channel configuration |
| 57 | * |
| 58 | * Return: QDF_STATUS_SUCCESS on success |
| 59 | */ |
| 60 | static QDF_STATUS target_if_ocb_set_config(struct wlan_objmgr_psoc *psoc, |
| 61 | struct ocb_config *config) |
| 62 | { |
| 63 | QDF_STATUS status; |
| 64 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 65 | status = wmi_unified_ocb_set_config(get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 66 | config); |
| 67 | if (status) |
| 68 | target_if_err("Failed to set OCB config %d", status); |
| 69 | |
| 70 | return status; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * target_if_ocb_set_utc_time() - send the UTC time to the firmware |
| 75 | * @psoc: pointer to PSOC object |
| 76 | * @utc: pointer to the UTC time structure |
| 77 | * |
| 78 | * Return: QDF_STATUS_SUCCESS on success |
| 79 | */ |
| 80 | static QDF_STATUS target_if_ocb_set_utc_time(struct wlan_objmgr_psoc *psoc, |
| 81 | struct ocb_utc_param *utc) |
| 82 | { |
| 83 | QDF_STATUS status; |
| 84 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 85 | status = wmi_unified_ocb_set_utc_time_cmd( |
| 86 | get_wmi_unified_hdl_from_psoc(psoc), utc); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 87 | if (status) |
| 88 | target_if_err("Failed to set OCB UTC time %d", status); |
| 89 | |
| 90 | return status; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * target_if_ocb_start_timing_advert() - start sending the timing |
| 95 | * advertisement frame on a channel |
| 96 | * @psoc: pointer to PSOC object |
| 97 | * @ta: pointer to the timing advertisement |
| 98 | * |
| 99 | * Return: QDF_STATUS_SUCCESS on success |
| 100 | */ |
| 101 | static QDF_STATUS |
| 102 | target_if_ocb_start_timing_advert(struct wlan_objmgr_psoc *psoc, |
| 103 | struct ocb_timing_advert_param *ta) |
| 104 | { |
| 105 | QDF_STATUS status; |
| 106 | |
| 107 | status = wmi_unified_ocb_start_timing_advert( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 108 | get_wmi_unified_hdl_from_psoc(psoc), ta); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 109 | if (status) |
| 110 | target_if_err("Failed to start OCB timing advert %d", status); |
| 111 | |
| 112 | return status; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * target_if_ocb_stop_timing_advert() - stop sending the timing |
| 117 | * advertisement frame on a channel |
| 118 | * @psoc: pointer to PSOC object |
| 119 | * @ta: pointer to the timing advertisement |
| 120 | * |
| 121 | * Return: QDF_STATUS_SUCCESS on success |
| 122 | */ |
| 123 | static QDF_STATUS |
| 124 | target_if_ocb_stop_timing_advert(struct wlan_objmgr_psoc *psoc, |
| 125 | struct ocb_timing_advert_param *ta) |
| 126 | { |
| 127 | QDF_STATUS status; |
| 128 | |
| 129 | status = |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 130 | wmi_unified_ocb_stop_timing_advert( |
| 131 | get_wmi_unified_hdl_from_psoc(psoc), ta); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 132 | if (status) |
| 133 | target_if_err("Failed to stop OCB timing advert %d", status); |
| 134 | |
| 135 | return status; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * target_if_ocb_get_tsf_timer() - get tsf timer |
| 140 | * @psoc: pointer to PSOC object |
| 141 | * @request: pointer to the request |
| 142 | * |
| 143 | * Return: QDF_STATUS_SUCCESS on success |
| 144 | */ |
| 145 | static QDF_STATUS |
| 146 | target_if_ocb_get_tsf_timer(struct wlan_objmgr_psoc *psoc, |
| 147 | struct ocb_get_tsf_timer_param *request) |
| 148 | { |
| 149 | QDF_STATUS status; |
| 150 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 151 | status = wmi_unified_ocb_get_tsf_timer( |
| 152 | get_wmi_unified_hdl_from_psoc(psoc), request); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 153 | if (status) |
| 154 | target_if_err("Failed to send get tsf timer cmd: %d", status); |
| 155 | |
| 156 | return status; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * target_if_dcc_get_stats() - get the DCC channel stats |
| 161 | * @psoc: pointer to PSOC object |
| 162 | * @get_stats_param: pointer to the dcc stats request |
| 163 | * |
| 164 | * Return: QDF_STATUS_SUCCESS on success |
| 165 | */ |
| 166 | static QDF_STATUS |
| 167 | target_if_dcc_get_stats(struct wlan_objmgr_psoc *psoc, |
| 168 | struct ocb_dcc_get_stats_param *get_stats_param) |
| 169 | { |
| 170 | QDF_STATUS status; |
| 171 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 172 | status = wmi_unified_dcc_get_stats_cmd( |
| 173 | get_wmi_unified_hdl_from_psoc(psoc), get_stats_param); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 174 | if (status) |
| 175 | target_if_err("Failed to send get DCC stats cmd: %d", status); |
| 176 | |
| 177 | return status; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * target_if_dcc_clear_stats() - send command to clear the DCC stats |
| 182 | * @psoc: pointer to PSOC object |
| 183 | * @clear_stats_param: parameters to the command |
| 184 | * |
| 185 | * Return: QDF_STATUS_SUCCESS on success |
| 186 | */ |
| 187 | static QDF_STATUS |
| 188 | target_if_dcc_clear_stats(struct wlan_objmgr_psoc *psoc, |
| 189 | struct ocb_dcc_clear_stats_param *clear_stats_param) |
| 190 | { |
| 191 | QDF_STATUS status; |
| 192 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 193 | status = wmi_unified_dcc_clear_stats( |
| 194 | get_wmi_unified_hdl_from_psoc(psoc), clear_stats_param); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 195 | if (status) |
| 196 | target_if_err("Failed to send clear DCC stats cmd: %d", status); |
| 197 | |
| 198 | return status; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * target_if_dcc_update_ndl() - command to update the NDL data |
| 203 | * @psoc: pointer to PSOC object |
| 204 | * @update_ndl_param: pointer to the request parameters |
| 205 | * |
| 206 | * Return: QDF_STATUS_SUCCESS on success |
| 207 | */ |
| 208 | static QDF_STATUS |
| 209 | target_if_dcc_update_ndl(struct wlan_objmgr_psoc *psoc, |
| 210 | struct ocb_dcc_update_ndl_param *update_ndl_param) |
| 211 | { |
| 212 | QDF_STATUS status; |
| 213 | |
| 214 | /* Send the WMI command */ |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 215 | status = wmi_unified_dcc_update_ndl(get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 216 | update_ndl_param); |
| 217 | if (status) |
| 218 | target_if_err("Failed to send NDL update cmd: %d", status); |
| 219 | |
| 220 | return status; |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * target_if_ocb_set_config_resp() - handler for channel config response |
| 225 | * @scn: scn handle |
| 226 | * @event_buf: pointer to the event buffer |
| 227 | * @len: length of the buffer |
| 228 | * |
| 229 | * Return: 0 on success |
| 230 | */ |
| 231 | static int |
| 232 | target_if_ocb_set_config_resp(ol_scn_t scn, uint8_t *event_buf, |
| 233 | uint32_t len) |
| 234 | { |
| 235 | int rc; |
| 236 | QDF_STATUS status; |
| 237 | uint32_t resp; |
| 238 | struct wlan_objmgr_pdev *pdev; |
| 239 | struct wlan_objmgr_psoc *psoc; |
| 240 | struct wlan_ocb_rx_ops *ocb_rx_ops; |
| 241 | |
| 242 | target_if_debug("scn:%pK, data:%pK, datalen:%d", |
| 243 | scn, event_buf, len); |
| 244 | if (!scn || !event_buf) { |
| 245 | target_if_err("scn: 0x%pK, data: 0x%pK", scn, event_buf); |
| 246 | return -EINVAL; |
| 247 | } |
| 248 | |
| 249 | psoc = target_if_get_psoc_from_scn_hdl(scn); |
| 250 | if (!psoc) { |
| 251 | target_if_err("null psoc"); |
| 252 | return -EINVAL; |
| 253 | } |
| 254 | |
| 255 | pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, |
| 256 | WLAN_OCB_SB_ID); |
| 257 | if (!pdev) { |
| 258 | target_if_err("pdev is NULL"); |
| 259 | return -EINVAL; |
| 260 | } |
| 261 | |
| 262 | ocb_rx_ops = target_if_ocb_get_rx_ops(pdev); |
| 263 | if (ocb_rx_ops->ocb_set_config_status) { |
| 264 | status = wmi_extract_ocb_set_channel_config_resp( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 265 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 266 | event_buf, &resp); |
| 267 | if (QDF_IS_STATUS_ERROR(status)) { |
| 268 | target_if_err("Failed to extract config status"); |
| 269 | rc = -EINVAL; |
| 270 | goto exit; |
| 271 | } |
| 272 | status = ocb_rx_ops->ocb_set_config_status(psoc, resp); |
| 273 | if (status != QDF_STATUS_SUCCESS) { |
| 274 | target_if_err("ocb_set_config_status failed."); |
| 275 | rc = -EINVAL; |
| 276 | goto exit; |
| 277 | } |
| 278 | rc = 0; |
| 279 | } else { |
| 280 | target_if_fatal("No ocb_set_config_status callback"); |
| 281 | rc = -EINVAL; |
| 282 | } |
| 283 | exit: |
| 284 | wlan_objmgr_pdev_release_ref(pdev, WLAN_OCB_SB_ID); |
| 285 | |
| 286 | return rc; |
| 287 | }; |
| 288 | |
| 289 | /** |
| 290 | * target_if_ocb_get_tsf_timer_resp() - handler for TSF timer response |
| 291 | * @scn: scn handle |
| 292 | * @event_buf: pointer to the event buffer |
| 293 | * @len: length of the buffer |
| 294 | * |
| 295 | * Return: 0 on success |
| 296 | */ |
| 297 | static int target_if_ocb_get_tsf_timer_resp(ol_scn_t scn, |
| 298 | uint8_t *event_buf, |
| 299 | uint32_t len) |
| 300 | { |
| 301 | int rc; |
| 302 | QDF_STATUS status; |
| 303 | struct wlan_objmgr_pdev *pdev; |
| 304 | struct wlan_objmgr_psoc *psoc; |
| 305 | struct ocb_get_tsf_timer_response response; |
| 306 | struct wlan_ocb_rx_ops *ocb_rx_ops; |
| 307 | |
| 308 | target_if_debug("scn:%pK, data:%pK, datalen:%d", |
| 309 | scn, event_buf, len); |
| 310 | |
| 311 | if (!scn || !event_buf) { |
| 312 | target_if_err("scn: 0x%pK, data: 0x%pK", scn, event_buf); |
| 313 | return -EINVAL; |
| 314 | } |
| 315 | |
| 316 | psoc = target_if_get_psoc_from_scn_hdl(scn); |
| 317 | if (!psoc) { |
| 318 | target_if_err("null psoc"); |
| 319 | return -EINVAL; |
| 320 | } |
| 321 | |
| 322 | pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, |
| 323 | WLAN_OCB_SB_ID); |
| 324 | if (!pdev) { |
| 325 | target_if_err("pdev is NULL"); |
| 326 | return -EINVAL; |
| 327 | } |
| 328 | |
| 329 | ocb_rx_ops = target_if_ocb_get_rx_ops(pdev); |
| 330 | if (ocb_rx_ops->ocb_tsf_timer) { |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 331 | status = wmi_extract_ocb_tsf_timer( |
| 332 | get_wmi_unified_hdl_from_psoc(psoc), |
| 333 | event_buf, &response); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 334 | if (QDF_IS_STATUS_ERROR(status)) { |
| 335 | target_if_err("Failed to extract tsf timer"); |
| 336 | rc = -EINVAL; |
| 337 | goto exit; |
| 338 | } |
| 339 | status = ocb_rx_ops->ocb_tsf_timer(psoc, &response); |
| 340 | if (status != QDF_STATUS_SUCCESS) { |
| 341 | target_if_err("ocb_tsf_timer failed."); |
| 342 | rc = -EINVAL; |
| 343 | goto exit; |
| 344 | } |
| 345 | rc = 0; |
| 346 | } else { |
| 347 | target_if_fatal("No ocb_tsf_timer callback"); |
| 348 | rc = -EINVAL; |
| 349 | } |
| 350 | exit: |
| 351 | wlan_objmgr_pdev_release_ref(pdev, WLAN_OCB_SB_ID); |
| 352 | |
| 353 | return rc; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * target_if_dcc_update_ndl_resp() - handler for update NDL response |
| 358 | * @scn: scn handle |
| 359 | * @event_buf: pointer to the event buffer |
| 360 | * @len: length of the buffer |
| 361 | * |
| 362 | * Return: 0 on success |
| 363 | */ |
| 364 | static int target_if_dcc_update_ndl_resp(ol_scn_t scn, |
| 365 | uint8_t *event_buf, |
| 366 | uint32_t len) |
| 367 | { |
| 368 | int rc; |
| 369 | QDF_STATUS status; |
| 370 | struct wlan_objmgr_pdev *pdev; |
| 371 | struct wlan_objmgr_psoc *psoc; |
| 372 | struct ocb_dcc_update_ndl_response *resp; |
| 373 | struct wlan_ocb_rx_ops *ocb_rx_ops; |
| 374 | |
| 375 | target_if_debug("scn:%pK, data:%pK, datalen:%d", |
| 376 | scn, event_buf, len); |
| 377 | |
| 378 | if (!scn || !event_buf) { |
| 379 | target_if_err("scn: 0x%pK, data: 0x%pK", scn, event_buf); |
| 380 | return -EINVAL; |
| 381 | } |
| 382 | |
| 383 | psoc = target_if_get_psoc_from_scn_hdl(scn); |
| 384 | if (!psoc) { |
| 385 | target_if_err("null psoc"); |
| 386 | return -EINVAL; |
| 387 | } |
| 388 | pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, |
| 389 | WLAN_OCB_SB_ID); |
| 390 | if (!pdev) { |
| 391 | target_if_err("pdev is NULL"); |
| 392 | return -EINVAL; |
| 393 | } |
| 394 | |
| 395 | /* Allocate and populate the response */ |
| 396 | resp = qdf_mem_malloc(sizeof(*resp)); |
| 397 | if (!resp) { |
| 398 | target_if_err("Error allocating memory for the response."); |
| 399 | rc = -ENOMEM; |
| 400 | goto exit; |
| 401 | } |
| 402 | |
| 403 | ocb_rx_ops = target_if_ocb_get_rx_ops(pdev); |
| 404 | if (ocb_rx_ops->ocb_dcc_ndl_update) { |
| 405 | status = wmi_extract_dcc_update_ndl_resp( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 406 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 407 | event_buf, resp); |
| 408 | if (QDF_IS_STATUS_ERROR(status)) { |
| 409 | target_if_err("Failed to extract ndl status"); |
| 410 | rc = -EINVAL; |
| 411 | goto exit; |
| 412 | } |
| 413 | status = ocb_rx_ops->ocb_dcc_ndl_update(psoc, resp); |
| 414 | if (status != QDF_STATUS_SUCCESS) { |
| 415 | target_if_err("dcc_ndl_update failed."); |
| 416 | rc = -EINVAL; |
| 417 | goto exit; |
| 418 | } |
| 419 | rc = 0; |
| 420 | } else { |
| 421 | target_if_fatal("No dcc_ndl_update callback"); |
| 422 | rc = -EINVAL; |
| 423 | } |
| 424 | exit: |
| 425 | wlan_objmgr_pdev_release_ref(pdev, WLAN_OCB_SB_ID); |
| 426 | if (resp) |
| 427 | qdf_mem_free(resp); |
| 428 | |
| 429 | return rc; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * target_if_dcc_get_stats_resp() - handler for get stats response |
| 434 | * @scn: scn handle |
| 435 | * @event_buf: pointer to the event buffer |
| 436 | * @len: length of the buffer |
| 437 | * |
| 438 | * Return: 0 on success |
| 439 | */ |
| 440 | static int target_if_dcc_get_stats_resp(ol_scn_t scn, |
| 441 | uint8_t *event_buf, |
| 442 | uint32_t len) |
| 443 | { |
| 444 | int rc; |
| 445 | QDF_STATUS status; |
| 446 | struct wlan_objmgr_pdev *pdev; |
| 447 | struct wlan_objmgr_psoc *psoc; |
| 448 | struct ocb_dcc_get_stats_response *response; |
| 449 | struct wlan_ocb_rx_ops *ocb_rx_ops; |
| 450 | |
| 451 | target_if_debug("scn:%pK, data:%pK, datalen:%d", |
| 452 | scn, event_buf, len); |
| 453 | |
| 454 | if (!scn || !event_buf) { |
| 455 | target_if_err("scn: 0x%pK, data: 0x%pK", scn, event_buf); |
| 456 | return -EINVAL; |
| 457 | } |
| 458 | |
| 459 | psoc = target_if_get_psoc_from_scn_hdl(scn); |
| 460 | if (!psoc) { |
| 461 | target_if_err("null psoc"); |
| 462 | return -EINVAL; |
| 463 | } |
| 464 | |
| 465 | pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, |
| 466 | WLAN_OCB_SB_ID); |
| 467 | if (!pdev) { |
| 468 | target_if_err("pdev is NULL"); |
| 469 | return -EINVAL; |
| 470 | } |
| 471 | |
| 472 | ocb_rx_ops = target_if_ocb_get_rx_ops(pdev); |
| 473 | if (ocb_rx_ops->ocb_dcc_stats_indicate) { |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 474 | status = wmi_extract_dcc_stats( |
| 475 | get_wmi_unified_hdl_from_psoc(psoc), |
| 476 | event_buf, &response); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 477 | if (!response || QDF_IS_STATUS_ERROR(status)) { |
| 478 | target_if_err("Cannot get DCC stats"); |
| 479 | rc = -ENOMEM; |
| 480 | goto exit; |
| 481 | } |
| 482 | |
| 483 | status = ocb_rx_ops->ocb_dcc_stats_indicate(psoc, |
| 484 | response, |
| 485 | true); |
| 486 | if (QDF_IS_STATUS_ERROR(status)) { |
| 487 | target_if_err("dcc_stats_indicate failed."); |
| 488 | rc = -EINVAL; |
| 489 | goto exit; |
| 490 | } |
| 491 | rc = 0; |
| 492 | } else { |
| 493 | target_if_fatal("No dcc_stats_indicate callback"); |
| 494 | rc = -EINVAL; |
| 495 | } |
| 496 | exit: |
| 497 | wlan_objmgr_pdev_release_ref(pdev, WLAN_OCB_SB_ID); |
| 498 | if (response) |
| 499 | qdf_mem_free(response); |
| 500 | |
| 501 | return rc; |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * target_if_dcc_stats_resp() - handler for DCC stats indication event |
| 506 | * @scn: scn handle |
| 507 | * @event_buf: pointer to the event buffer |
| 508 | * @len: length of the buffer |
| 509 | * |
| 510 | * Return: 0 on success |
| 511 | */ |
| 512 | static int target_if_dcc_stats_resp(ol_scn_t scn, uint8_t *event_buf, |
| 513 | uint32_t len) |
| 514 | { |
| 515 | int rc; |
| 516 | QDF_STATUS status; |
| 517 | struct wlan_objmgr_pdev *pdev; |
| 518 | struct wlan_objmgr_psoc *psoc; |
| 519 | struct ocb_dcc_get_stats_response *response; |
| 520 | struct wlan_ocb_rx_ops *ocb_rx_ops; |
| 521 | |
| 522 | target_if_debug("scn:%pK, data:%pK, datalen:%d", |
| 523 | scn, event_buf, len); |
| 524 | |
| 525 | if (!scn || !event_buf) { |
| 526 | target_if_err("scn: 0x%pK, data: 0x%pK", scn, event_buf); |
| 527 | return -EINVAL; |
| 528 | } |
| 529 | |
| 530 | psoc = target_if_get_psoc_from_scn_hdl(scn); |
| 531 | if (!psoc) { |
| 532 | target_if_err("null psoc"); |
| 533 | return -EINVAL; |
| 534 | } |
| 535 | |
| 536 | pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, |
| 537 | WLAN_OCB_SB_ID); |
| 538 | if (!pdev) { |
| 539 | target_if_err("pdev is NULL"); |
| 540 | return -EINVAL; |
| 541 | } |
| 542 | |
| 543 | ocb_rx_ops = target_if_ocb_get_rx_ops(pdev); |
| 544 | if (ocb_rx_ops->ocb_dcc_stats_indicate) { |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 545 | status = wmi_extract_dcc_stats( |
| 546 | get_wmi_unified_hdl_from_psoc(psoc), |
| 547 | event_buf, &response); |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 548 | if (!response || QDF_IS_STATUS_ERROR(status)) { |
| 549 | target_if_err("Cannot get DCC stats"); |
| 550 | rc = -ENOMEM; |
| 551 | goto exit; |
| 552 | } |
| 553 | status = ocb_rx_ops->ocb_dcc_stats_indicate(psoc, |
| 554 | response, |
| 555 | false); |
| 556 | if (QDF_IS_STATUS_ERROR(status)) { |
| 557 | target_if_err("dcc_stats_indicate failed."); |
| 558 | rc = -EINVAL; |
| 559 | goto exit; |
| 560 | } |
| 561 | rc = 0; |
| 562 | } else { |
| 563 | target_if_fatal("dcc_stats_indicate failed."); |
| 564 | response = NULL; |
| 565 | rc = -EINVAL; |
| 566 | } |
| 567 | exit: |
| 568 | wlan_objmgr_pdev_release_ref(pdev, WLAN_OCB_SB_ID); |
| 569 | if (response) |
| 570 | qdf_mem_free(response); |
| 571 | |
| 572 | return rc; |
| 573 | } |
| 574 | |
| 575 | QDF_STATUS target_if_ocb_register_event_handler(struct wlan_objmgr_psoc *psoc, |
| 576 | void *arg) |
| 577 | { |
| 578 | int rc; |
| 579 | |
| 580 | /* Initialize the members in WMA used by wma_ocb */ |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 581 | rc = wmi_unified_register_event(get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 582 | wmi_ocb_set_config_resp_event_id, |
| 583 | target_if_ocb_set_config_resp); |
| 584 | if (rc) { |
| 585 | target_if_err("Failed to register OCB config resp event cb"); |
| 586 | return QDF_STATUS_E_FAILURE; |
| 587 | } |
| 588 | |
| 589 | rc = wmi_unified_register_event( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 590 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 591 | wmi_ocb_get_tsf_timer_resp_event_id, |
| 592 | target_if_ocb_get_tsf_timer_resp); |
| 593 | if (rc) { |
| 594 | target_if_err("Failed to register OCB TSF resp event cb"); |
| 595 | goto unreg_set_config; |
| 596 | } |
| 597 | |
| 598 | rc = wmi_unified_register_event( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 599 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 600 | wmi_dcc_get_stats_resp_event_id, |
| 601 | target_if_dcc_get_stats_resp); |
| 602 | if (rc) { |
| 603 | target_if_err("Failed to register DCC get stats resp event cb"); |
| 604 | goto unreg_tsf_timer; |
| 605 | } |
| 606 | |
| 607 | rc = wmi_unified_register_event( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 608 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 609 | wmi_dcc_update_ndl_resp_event_id, |
| 610 | target_if_dcc_update_ndl_resp); |
| 611 | if (rc) { |
| 612 | target_if_err("Failed to register NDL update event cb"); |
| 613 | goto unreg_get_stats; |
| 614 | } |
| 615 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 616 | rc = wmi_unified_register_event(get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 617 | wmi_dcc_stats_event_id, |
| 618 | target_if_dcc_stats_resp); |
| 619 | if (rc) { |
| 620 | target_if_err("Failed to register DCC stats event cb"); |
| 621 | goto unreg_ndl; |
| 622 | } |
| 623 | |
| 624 | return QDF_STATUS_SUCCESS; |
| 625 | |
| 626 | unreg_ndl: |
| 627 | wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 628 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 629 | wmi_dcc_update_ndl_resp_event_id); |
| 630 | unreg_get_stats: |
| 631 | wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 632 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 633 | wmi_dcc_get_stats_resp_event_id); |
| 634 | unreg_tsf_timer: |
| 635 | wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 636 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 637 | wmi_ocb_get_tsf_timer_resp_event_id); |
| 638 | unreg_set_config: |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 639 | wmi_unified_unregister_event(get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 640 | wmi_ocb_set_config_resp_event_id); |
| 641 | |
| 642 | return QDF_STATUS_E_FAILURE; |
| 643 | } |
| 644 | |
| 645 | QDF_STATUS |
| 646 | target_if_ocb_unregister_event_handler(struct wlan_objmgr_psoc *psoc, |
| 647 | void *arg) |
| 648 | { |
| 649 | int rc; |
| 650 | |
| 651 | rc = wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 652 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 653 | wmi_dcc_stats_event_id); |
| 654 | if (rc) |
| 655 | target_if_err("Failed to unregister DCC stats event cb"); |
| 656 | |
| 657 | rc = wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 658 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 659 | wmi_dcc_update_ndl_resp_event_id); |
| 660 | if (rc) |
| 661 | target_if_err("Failed to unregister NDL update event cb"); |
| 662 | |
| 663 | rc = wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 664 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 665 | wmi_dcc_get_stats_resp_event_id); |
| 666 | if (rc) |
| 667 | target_if_err("Failed to unregister DCC get stats resp cb"); |
| 668 | |
| 669 | rc = wmi_unified_unregister_event_handler( |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 670 | get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 671 | wmi_ocb_get_tsf_timer_resp_event_id); |
| 672 | if (rc) |
| 673 | target_if_err("Failed to unregister OCB TSF resp event cb"); |
| 674 | |
Sourav Mohapatra | cf63257 | 2018-04-02 11:01:35 +0530 | [diff] [blame^] | 675 | rc = wmi_unified_unregister_event(get_wmi_unified_hdl_from_psoc(psoc), |
Zhang Qian | b94edce | 2018-01-04 20:34:08 +0800 | [diff] [blame] | 676 | wmi_ocb_set_config_resp_event_id); |
| 677 | if (rc) |
| 678 | target_if_err("Failed to unregister OCB config resp event cb"); |
| 679 | |
| 680 | return QDF_STATUS_SUCCESS; |
| 681 | } |
| 682 | |
| 683 | QDF_STATUS |
| 684 | target_if_ocb_register_tx_ops(struct wlan_ocb_tx_ops *ocb_txops) |
| 685 | { |
| 686 | ocb_txops->ocb_set_config = target_if_ocb_set_config; |
| 687 | ocb_txops->ocb_set_utc_time = target_if_ocb_set_utc_time; |
| 688 | ocb_txops->ocb_start_timing_advert = target_if_ocb_start_timing_advert; |
| 689 | ocb_txops->ocb_stop_timing_advert = target_if_ocb_stop_timing_advert; |
| 690 | ocb_txops->ocb_get_tsf_timer = target_if_ocb_get_tsf_timer; |
| 691 | ocb_txops->ocb_dcc_get_stats = target_if_dcc_get_stats; |
| 692 | ocb_txops->ocb_dcc_clear_stats = target_if_dcc_clear_stats; |
| 693 | ocb_txops->ocb_dcc_update_ndl = target_if_dcc_update_ndl; |
| 694 | ocb_txops->ocb_reg_ev_handler = target_if_ocb_register_event_handler; |
| 695 | ocb_txops->ocb_unreg_ev_handler = |
| 696 | target_if_ocb_unregister_event_handler; |
| 697 | |
| 698 | return QDF_STATUS_SUCCESS; |
| 699 | } |