1 /* 2 * Copyright (c) 2016-2018 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 bool lmac_is_mode_offload(struct wlan_objmgr_pdev *pdev) 105 { 106 struct wlan_objmgr_psoc *psoc; 107 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 108 bool is_offload = false; 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_is_mode_offload) 115 dfs_tx_ops->dfs_is_mode_offload(pdev, &is_offload); 116 117 return is_offload; 118 } 119 120 uint16_t lmac_get_ah_devid(struct wlan_objmgr_pdev *pdev) 121 { 122 struct wlan_objmgr_psoc *psoc; 123 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 124 uint16_t devid = 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_ah_devid) 131 dfs_tx_ops->dfs_get_ah_devid(pdev, &devid); 132 133 return devid; 134 } 135 136 bool lmac_is_mode_dfs_offload(struct wlan_objmgr_psoc *psoc) 137 { 138 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 139 bool is_offload = false; 140 141 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 142 143 if (dfs_tx_ops->dfs_is_tgt_offload) 144 dfs_tx_ops->dfs_is_tgt_offload(psoc, &is_offload); 145 146 return is_offload; 147 } 148 149 uint32_t lmac_get_ext_busy(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 ext_chan_busy = 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_ext_busy) 160 dfs_tx_ops->dfs_get_ext_busy(pdev, &ext_chan_busy); 161 162 return ext_chan_busy; 163 } 164 165 void lmac_set_use_cac_prssi(struct wlan_objmgr_pdev *pdev) 166 { 167 struct wlan_objmgr_psoc *psoc; 168 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 169 170 psoc = wlan_pdev_get_psoc(pdev); 171 172 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 173 174 if (dfs_tx_ops->dfs_set_use_cac_prssi) 175 dfs_tx_ops->dfs_set_use_cac_prssi(pdev); 176 } 177 178 uint32_t lmac_get_target_type(struct wlan_objmgr_pdev *pdev) 179 { 180 struct wlan_objmgr_psoc *psoc; 181 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 182 uint32_t target_type = 0; 183 184 psoc = wlan_pdev_get_psoc(pdev); 185 186 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 187 188 if (dfs_tx_ops->dfs_get_target_type) 189 dfs_tx_ops->dfs_get_target_type(pdev, &target_type); 190 191 return target_type; 192 } 193 194 uint32_t lmac_get_phymode_info(struct wlan_objmgr_pdev *pdev, 195 uint32_t chan_mode) 196 { 197 struct wlan_objmgr_psoc *psoc; 198 struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops; 199 uint32_t mode_info = 0; 200 201 psoc = wlan_pdev_get_psoc(pdev); 202 203 dfs_tx_ops = &psoc->soc_cb.tx_ops.dfs_tx_ops; 204 205 if (dfs_tx_ops->dfs_get_phymode_info) 206 dfs_tx_ops->dfs_get_phymode_info(pdev, chan_mode, &mode_info); 207 208 return mode_info; 209 } 210