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