1 /* 2 * 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 */ 18 19 /** 20 * DOC: offload lmac interface APIs definitions for scan 21 */ 22 23 #include <qdf_mem.h> 24 #include <qdf_status.h> 25 #include <wmi_unified_api.h> 26 #include <wmi_unified_priv.h> 27 #include <wmi_unified_param.h> 28 #include <wlan_objmgr_psoc_obj.h> 29 #include <wlan_scan_tgt_api.h> 30 #include <target_if.h> 31 32 static inline struct wlan_lmac_if_scan_rx_ops * 33 target_if_scan_get_rx_ops(struct wlan_objmgr_psoc *psoc) 34 { 35 return &psoc->soc_cb.rx_ops.scan; 36 } 37 38 static int 39 target_if_scan_event_handler(ol_scn_t scn, uint8_t *data, uint32_t datalen) 40 { 41 struct scan_event_info *event_info; 42 struct wlan_objmgr_psoc *psoc; 43 struct wmi_unified *wmi_handle; 44 struct wlan_lmac_if_scan_rx_ops *scan_rx_ops; 45 QDF_STATUS status; 46 47 if (!scn || !data) { 48 target_if_err("scn: 0x%p, data: 0x%p\n", scn, data); 49 return -EINVAL; 50 } 51 psoc = target_if_get_psoc_from_scn_hdl(scn); 52 if (!psoc) { 53 target_if_err("null psoc\n"); 54 return -EINVAL; 55 } 56 wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); 57 58 event_info = qdf_mem_malloc(sizeof(*event_info)); 59 60 if (!event_info) { 61 target_if_err("%s: unable to allocate scan_event\n", __func__); 62 return -ENOMEM; 63 } 64 65 if (wmi_extract_vdev_scan_ev_param(wmi_handle, data, 66 &(event_info->event))) { 67 target_if_err("%s: Failed to extract wmi scan event\n", 68 __func__); 69 qdf_mem_free(event_info); 70 return -EINVAL; 71 } 72 73 scan_rx_ops = target_if_scan_get_rx_ops(psoc); 74 if (scan_rx_ops->scan_ev_handler) { 75 status = scan_rx_ops->scan_ev_handler(psoc, event_info); 76 if (status != QDF_STATUS_SUCCESS) { 77 qdf_mem_free(event_info); 78 return -EINVAL; 79 } 80 } 81 82 return 0; 83 } 84 85 QDF_STATUS 86 target_if_scan_register_event_handler(struct wlan_objmgr_psoc *psoc, void *arg) 87 { 88 return wmi_unified_register_event_handler(psoc->tgt_if_handle, 89 wmi_scan_event_id, target_if_scan_event_handler, 90 WMI_RX_UMAC_CTX); 91 } 92 93 QDF_STATUS 94 target_if_scan_unregister_event_handler(struct wlan_objmgr_psoc *psoc, 95 void *arg) 96 { 97 return wmi_unified_unregister_event_handler(psoc->tgt_if_handle, 98 wmi_scan_event_id); 99 } 100 101 QDF_STATUS 102 target_if_scan_start(struct wlan_objmgr_psoc *psoc, 103 struct scan_start_request *req) 104 { 105 return wmi_unified_scan_start_cmd_send(psoc->tgt_if_handle, 106 &req->scan_req); 107 } 108 109 110 QDF_STATUS 111 target_if_scan_cancel(struct wlan_objmgr_psoc *psoc, 112 struct scan_cancel_param *req) 113 { 114 return wmi_unified_scan_stop_cmd_send(psoc->tgt_if_handle, req); 115 } 116