1 /* 2 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. 3 * 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 /** 21 * DOC: target_if_reg_11d.c 22 * This file contains regulatory target interface 23 */ 24 25 #include "target_if_reg_11d.h" 26 27 #ifdef HOST_11D_SCAN 28 bool tgt_if_regulatory_is_11d_offloaded(struct wlan_objmgr_psoc *psoc) 29 { 30 wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 31 32 if (!wmi_handle) 33 return false; 34 35 return wmi_service_enabled(wmi_handle, wmi_service_11d_offload); 36 } 37 38 /** 39 * tgt_reg_11d_new_cc_handler() - 11d country code event handler 40 * @handle: scn handle 41 * @event_buf: event buffer 42 * @len: legth of @event_buf 43 * 44 * Return: 0 on success 45 */ 46 static int tgt_reg_11d_new_cc_handler(ol_scn_t handle, uint8_t *event_buf, 47 uint32_t len) 48 { 49 struct wlan_objmgr_psoc *psoc; 50 struct wlan_lmac_if_reg_rx_ops *reg_rx_ops; 51 struct reg_11d_new_country reg_11d_new_cc; 52 QDF_STATUS status; 53 struct wmi_unified *wmi_handle; 54 55 TARGET_IF_ENTER(); 56 57 psoc = target_if_get_psoc_from_scn_hdl(handle); 58 if (!psoc) { 59 target_if_err("psoc ptr is NULL"); 60 return -EINVAL; 61 } 62 63 reg_rx_ops = target_if_regulatory_get_rx_ops(psoc); 64 65 if (!reg_rx_ops->reg_11d_new_cc_handler) { 66 target_if_err("reg_11d_new_cc_handler is NULL"); 67 return -EINVAL; 68 } 69 70 wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 71 if (!wmi_handle) { 72 target_if_err("Invalid WMI handle"); 73 return -EINVAL; 74 } 75 if (wmi_extract_reg_11d_new_cc_event(wmi_handle, event_buf, 76 ®_11d_new_cc, len) 77 != QDF_STATUS_SUCCESS) { 78 target_if_err("Extraction of new country event failed"); 79 return -EFAULT; 80 } 81 82 status = reg_rx_ops->reg_11d_new_cc_handler(psoc, ®_11d_new_cc); 83 if (status != QDF_STATUS_SUCCESS) { 84 target_if_err("Failed to process new country code event"); 85 return -EFAULT; 86 } 87 88 target_if_debug("processed 11d new country code event"); 89 90 return 0; 91 } 92 93 QDF_STATUS tgt_if_regulatory_register_11d_new_cc_handler( 94 struct wlan_objmgr_psoc *psoc, void *arg) 95 { 96 wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 97 98 if (!wmi_handle) 99 return QDF_STATUS_E_FAILURE; 100 101 return wmi_unified_register_event(wmi_handle, 102 wmi_11d_new_country_event_id, 103 tgt_reg_11d_new_cc_handler); 104 } 105 106 QDF_STATUS tgt_if_regulatory_unregister_11d_new_cc_handler( 107 struct wlan_objmgr_psoc *psoc, void *arg) 108 { 109 wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 110 111 if (!wmi_handle) 112 return QDF_STATUS_E_FAILURE; 113 114 return wmi_unified_unregister_event(wmi_handle, 115 wmi_11d_new_country_event_id); 116 } 117 118 QDF_STATUS tgt_if_regulatory_start_11d_scan( 119 struct wlan_objmgr_psoc *psoc, 120 struct reg_start_11d_scan_req *reg_start_11d_scan_req) 121 { 122 wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 123 124 if (!wmi_handle) 125 return QDF_STATUS_E_FAILURE; 126 127 return wmi_unified_send_start_11d_scan_cmd(wmi_handle, 128 reg_start_11d_scan_req); 129 } 130 131 QDF_STATUS tgt_if_regulatory_stop_11d_scan( 132 struct wlan_objmgr_psoc *psoc, 133 struct reg_stop_11d_scan_req *reg_stop_11d_scan_req) 134 { 135 wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 136 137 if (!wmi_handle) 138 return QDF_STATUS_E_FAILURE; 139 140 return wmi_unified_send_stop_11d_scan_cmd(wmi_handle, 141 reg_stop_11d_scan_req); 142 } 143 #endif 144