1 /* 2 * Copyright (c) 2019-2021 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 #ifndef _TARGET_IF_CFR_H_ 20 #define _TARGET_IF_CFR_H_ 21 22 #include <wlan_objmgr_cmn.h> 23 #include <wlan_objmgr_psoc_obj.h> 24 #include <wlan_objmgr_pdev_obj.h> 25 #include <wlan_objmgr_vdev_obj.h> 26 #include <wlan_objmgr_peer_obj.h> 27 28 #include "wmi_unified_cfr_api.h" 29 #include "wmi_unified_param.h" 30 #include "wmi_unified_cfr_param.h" 31 #define PEER_CFR_CAPTURE_ENABLE 1 32 #define PEER_CFR_CAPTURE_DISABLE 0 33 34 #define PEER_CFR_CAPTURE_EVT_STATUS_MASK 0x80000000 35 #define PEER_CFR_CAPTURE_EVT_PS_STATUS_MASK 0x40000000 36 #define CFR_TX_EVT_STATUS_MASK 0x00000003 37 38 /* Status codes used by correlate and relay function */ 39 #define STATUS_STREAM_AND_RELEASE 0 40 #define STATUS_HOLD 1 41 #define STATUS_ERROR -1 42 43 /* Module IDs using corrlation function */ 44 #define CORRELATE_DBR_MODULE_ID 0 45 /* 46 * HKV2 - Tx completion event for one-shot capture 47 * Cypress - Tx completion event for one-shot capture (or) RXTLV event for RCC 48 */ 49 #define CORRELATE_TX_EV_MODULE_ID 1 50 51 #define get_u16_lsb(value) (uint16_t)(value) 52 #define get_u16_msb(value) (uint16_t)(((uint32_t)value) >> 16) 53 #define get_gain_db(value) ((value) & 0xFF) 54 #define get_gain_table_idx(value) (((value) >> 8) & 0x3) 55 56 #define INVALID_PHASE_DELTA 0xFFFF 57 58 /** 59 * target_if_cfr_init_pdev() - Inits cfr pdev and registers necessary handlers. 60 * @psoc: pointer to psoc object 61 * @pdev: pointer to pdev object 62 * 63 * Return: Registration status for necessary handlers 64 */ 65 QDF_STATUS 66 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc, 67 struct wlan_objmgr_pdev *pdev); 68 69 /** 70 * target_if_cfr_deinit_pdev() - De-inits corresponding pdev and handlers. 71 * @psoc: pointer to psoc object 72 * @pdev: pointer to pdev object 73 * 74 * Return: De-registration status for necessary handlers 75 */ 76 QDF_STATUS 77 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc, 78 struct wlan_objmgr_pdev *pdev); 79 80 /** 81 * target_if_cfr_tx_ops_register() - Registers tx ops for cfr module 82 * @tx_ops - pointer to tx_ops structure. 83 */ 84 void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops); 85 86 /** 87 * target_if_cfr_enable_cfr_timer() - Enables cfr timer 88 * @pdev: pointer to pdev object 89 * @cfr_timer: Amount of time this timer has to run 90 * 91 * Return: status of timer 92 */ 93 int target_if_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev, 94 uint32_t cfr_timer); 95 96 /** 97 * target_if_cfr_pdev_set_param() - Function to set params for cfr config 98 * @pdev: pointer to pdev object 99 * @param_value: value of param being set 100 * 101 * Return: success/failure of setting param 102 */ 103 int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev, 104 uint32_t param_value); 105 /** 106 * target_if_cfr_start_capture() - Function to start cfr capture for a peer 107 * @pdev: pointer to pdev object 108 * @peer: pointer to peer object 109 * @cfr_params: capture parameters for this peer 110 * 111 * Return: success/failure status of start capture 112 */ 113 int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev, 114 struct wlan_objmgr_peer *peer, 115 struct cfr_capture_params *cfr_params); 116 /** 117 * target_if_cfr_stop_capture() - Function to stop cfr capture for a peer 118 * @pdev: pointer to pdev object 119 * @peer: pointer to peer object 120 * 121 * Return: success/failure status of stop capture 122 */ 123 int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev, 124 struct wlan_objmgr_peer *peer); 125 126 /** 127 * target_if_cfr_get_target_type() - Function to get target type 128 * @psoc: pointer to psoc object 129 * 130 * Return: target type of target 131 */ 132 int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc); 133 134 /** 135 * target_if_cfr_set_cfr_support() - Function to set cfr support 136 * @psoc: pointer to psoc object 137 * @value: value to be set 138 */ 139 void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc, 140 uint8_t value); 141 142 /** 143 * target_if_cfr_set_capture_count_support() - Function to set capture count 144 * support. 145 * @psoc: pointer to psoc object 146 * @value: value to be set 147 * 148 * Return: success/failure 149 */ 150 QDF_STATUS 151 target_if_cfr_set_capture_count_support(struct wlan_objmgr_psoc *psoc, 152 uint8_t value); 153 154 /** 155 * target_if_cfr_set_mo_marking_support() - Function to set MO marking support 156 * @psoc: pointer to psoc object 157 * @value: value to be set 158 * 159 * Return: success/failure 160 */ 161 QDF_STATUS 162 target_if_cfr_set_mo_marking_support(struct wlan_objmgr_psoc *psoc, 163 uint8_t value); 164 165 /** 166 * target_if_cfr_set_aoa_for_rcc_support() - Function to set AoA for RCC 167 * @psoc: pointer to psoc object 168 * @value: value to be set 169 * 170 * Return: success/failure 171 */ 172 QDF_STATUS 173 target_if_cfr_set_aoa_for_rcc_support(struct wlan_objmgr_psoc *psoc, 174 uint8_t value); 175 176 /** 177 * target_if_cfr_info_send() - Function to send cfr info to upper layers 178 * @pdev: pointer to pdev object 179 * @head: pointer to cfr info head 180 * @hlen: head len 181 * @data: pointer to cfr info data 182 * @dlen: data len 183 * @tail: pointer to cfr info tail 184 * @tlen: tail len 185 */ 186 void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head, 187 size_t hlen, void *data, size_t dlen, void *tail, 188 size_t tlen); 189 190 /** 191 * target_if_cfr_fill_header() - Function to fill cfr header cmn section 192 * @hdr: pointer to the csi_cfr_header 193 * @is_wifi_2_0: flag to indicate legacy and non legacy radio 194 * @target_type: target type of the radio 195 * @is_rcc: flag to denote fill header request from periodic cfr/rcc 196 */ 197 void target_if_cfr_fill_header(struct csi_cfr_header *hdr, 198 bool is_wifi_2_0, 199 uint32_t target_type, 200 bool is_rcc); 201 #ifdef WIFI_TARGET_TYPE_2_0 202 /** 203 * cfr_wifi2_0_init_pdev() - Function to init legacy pdev 204 * @psoc: pointer to psoc object 205 * @pdev: pointer to pdev object 206 * 207 * Return: success/failure status of init 208 */ 209 QDF_STATUS cfr_wifi2_0_init_pdev(struct wlan_objmgr_psoc *psoc, 210 struct wlan_objmgr_pdev *pdev); 211 212 /** 213 * cfr_wifi2_0_deinit_pdev() - Function to deinit legacy pdev 214 * @psoc: pointer to psoc object 215 * @pdev: pointer to pdev object 216 * 217 * Return: success/failure status of deinit 218 */ 219 QDF_STATUS cfr_wifi2_0_deinit_pdev(struct wlan_objmgr_psoc *psoc, 220 struct wlan_objmgr_pdev *pdev); 221 222 #else 223 #ifndef CFR_USE_FIXED_FOLDER 224 static QDF_STATUS cfr_wifi2_0_init_pdev(struct wlan_objmgr_psoc *psoc, 225 struct wlan_objmgr_pdev *pdev) 226 { 227 return QDF_STATUS_SUCCESS; 228 } 229 230 static QDF_STATUS cfr_wifi2_0_deinit_pdev(struct wlan_objmgr_psoc *psoc, 231 struct wlan_objmgr_pdev *pdev) 232 { 233 return QDF_STATUS_SUCCESS; 234 } 235 #endif 236 #endif 237 #endif 238