1 /* 2 * Copyright (c) 2016-2020 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: Functions to call lmac/offload functions from DFS component. 22 */ 23 24 #include "wlan_dfs_lmac_api.h" 25 #include "../../core/src/dfs_internal.h" 26 #include <wlan_reg_services_api.h> 27 28 void lmac_get_caps(struct wlan_objmgr_pdev *pdev, 29 struct wlan_dfs_caps *dfs_caps) 30 { 31 struct wlan_objmgr_psoc *psoc; 32 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 33 34 psoc = wlan_pdev_get_psoc(pdev); 35 36 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 37 38 if (dfs_tx_ops->dfs_get_caps) 39 dfs_tx_ops->dfs_get_caps(pdev, dfs_caps); 40 } 41 42 uint64_t lmac_get_tsf64(struct wlan_objmgr_pdev *pdev) 43 { 44 struct wlan_objmgr_psoc *psoc; 45 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 46 uint64_t tsf64 = 0; 47 48 psoc = wlan_pdev_get_psoc(pdev); 49 50 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 51 52 if (dfs_tx_ops->dfs_gettsf64) 53 dfs_tx_ops->dfs_gettsf64(pdev, &tsf64); 54 55 return tsf64; 56 } 57 58 void lmac_dfs_disable(struct wlan_objmgr_pdev *pdev, int no_cac) 59 { 60 struct wlan_objmgr_psoc *psoc; 61 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 62 63 psoc = wlan_pdev_get_psoc(pdev); 64 65 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 66 67 if (dfs_tx_ops->dfs_disable) 68 dfs_tx_ops->dfs_disable(pdev, no_cac); 69 } 70 71 void lmac_dfs_enable(struct wlan_objmgr_pdev *pdev, 72 int *is_fastclk, 73 struct wlan_dfs_phyerr_param *param, 74 int dfsdomain) 75 { 76 struct wlan_objmgr_psoc *psoc; 77 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 78 79 psoc = wlan_pdev_get_psoc(pdev); 80 81 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 82 83 if (dfs_tx_ops->dfs_enable) 84 dfs_tx_ops->dfs_enable(pdev, 85 is_fastclk, 86 param, 87 dfsdomain); 88 } 89 90 void lmac_dfs_get_thresholds(struct wlan_objmgr_pdev *pdev, 91 struct wlan_dfs_phyerr_param *param) 92 { 93 struct wlan_objmgr_psoc *psoc; 94 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 95 96 psoc = wlan_pdev_get_psoc(pdev); 97 98 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 99 100 if (dfs_tx_ops->dfs_get_thresholds) 101 dfs_tx_ops->dfs_get_thresholds(pdev, param); 102 } 103 104 uint16_t lmac_get_ah_devid(struct wlan_objmgr_pdev *pdev) 105 { 106 struct wlan_objmgr_psoc *psoc; 107 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 108 uint16_t devid = 0; 109 110 psoc = wlan_pdev_get_psoc(pdev); 111 112 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 113 114 if (dfs_tx_ops->dfs_get_ah_devid) 115 dfs_tx_ops->dfs_get_ah_devid(pdev, &devid); 116 117 return devid; 118 } 119 120 uint32_t lmac_get_ext_busy(struct wlan_objmgr_pdev *pdev) 121 { 122 struct wlan_objmgr_psoc *psoc; 123 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 124 uint32_t ext_chan_busy = 0; 125 126 psoc = wlan_pdev_get_psoc(pdev); 127 128 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 129 130 if (dfs_tx_ops->dfs_get_ext_busy) 131 dfs_tx_ops->dfs_get_ext_busy(pdev, &ext_chan_busy); 132 133 return ext_chan_busy; 134 } 135 136 void lmac_set_use_cac_prssi(struct wlan_objmgr_pdev *pdev) 137 { 138 struct wlan_objmgr_psoc *psoc; 139 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 140 141 psoc = wlan_pdev_get_psoc(pdev); 142 143 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 144 145 if (dfs_tx_ops->dfs_set_use_cac_prssi) 146 dfs_tx_ops->dfs_set_use_cac_prssi(pdev); 147 } 148 149 uint32_t lmac_get_target_type(struct wlan_objmgr_pdev *pdev) 150 { 151 struct wlan_objmgr_psoc *psoc; 152 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 153 uint32_t target_type = 0; 154 155 psoc = wlan_pdev_get_psoc(pdev); 156 157 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 158 159 if (dfs_tx_ops->dfs_get_target_type) 160 dfs_tx_ops->dfs_get_target_type(pdev, &target_type); 161 162 return target_type; 163 } 164 165 uint32_t lmac_get_phymode_info(struct wlan_objmgr_pdev *pdev, 166 uint32_t chan_mode) 167 { 168 struct wlan_objmgr_psoc *psoc; 169 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 170 uint32_t mode_info = 0; 171 172 psoc = wlan_pdev_get_psoc(pdev); 173 174 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 175 176 /* since dfs never comes into 2G, hardcode is_2gvht_en flag to false */ 177 if (dfs_tx_ops->dfs_get_phymode_info) 178 dfs_tx_ops->dfs_get_phymode_info(pdev, chan_mode, &mode_info, 179 false); 180 181 return mode_info; 182 } 183 184 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 185 bool lmac_is_host_dfs_check_support_enabled(struct wlan_objmgr_pdev *pdev) 186 { 187 struct wlan_objmgr_psoc *psoc; 188 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 189 bool enabled = false; 190 191 psoc = wlan_pdev_get_psoc(pdev); 192 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 193 194 if (dfs_tx_ops->dfs_host_dfs_check_support) 195 dfs_tx_ops->dfs_host_dfs_check_support(pdev, &enabled); 196 197 return enabled; 198 } 199 #endif 200 201 bool lmac_dfs_is_hw_mode_switch_in_progress(struct wlan_objmgr_pdev *pdev) 202 { 203 struct wlan_objmgr_psoc *psoc; 204 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 205 bool is_hw_mode_switch_in_progress = false; 206 207 psoc = wlan_pdev_get_psoc(pdev); 208 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 209 210 if (dfs_tx_ops->dfs_check_mode_switch_state) 211 dfs_tx_ops->dfs_check_mode_switch_state( 212 pdev, 213 &is_hw_mode_switch_in_progress); 214 215 return is_hw_mode_switch_in_progress; 216 } 217