xref: /wlan-dirver/qca-wifi-host-cmn/target_if/cfr/inc/target_if_cfr.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 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_pdev_set_param() - Function to set params for cfr config
99  * @pdev: pointer to pdev object
100  * @param_value: value of param being set
101  *
102  * Return: success/failure of setting param
103  */
104 int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev,
105 					   uint32_t param_value);
106 /**
107  * target_if_cfr_start_capture() - Function to start cfr capture for a peer
108  * @pdev: pointer to pdev object
109  * @peer: pointer to peer object
110  * @cfr_params: capture parameters for this peer
111  *
112  * Return: success/failure status of start capture
113  */
114 int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev,
115 				struct wlan_objmgr_peer *peer,
116 				struct cfr_capture_params *cfr_params);
117 /**
118  * target_if_cfr_stop_capture() - Function to stop cfr capture for a peer
119  * @pdev: pointer to pdev object
120  * @peer: pointer to peer object
121  *
122  * Return: success/failure status of stop capture
123  */
124 int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev,
125 			       struct wlan_objmgr_peer *peer);
126 
127 /**
128  * target_if_cfr_get_target_type() - Function to get target type
129  * @psoc: pointer to psoc object
130  *
131  * Return: target type of target
132  */
133 int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc);
134 
135 /**
136  * target_if_cfr_set_cfr_support() - Function to set cfr support
137  * @psoc: pointer to psoc object
138  * @value: value to be set
139  */
140 void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc,
141 				   uint8_t value);
142 
143 /**
144  * target_if_cfr_set_capture_count_support() - Function to set capture count
145  *					       support.
146  * @psoc: pointer to psoc object
147  * @value: value to be set
148  *
149  * Return: success/failure
150  */
151 QDF_STATUS
152 target_if_cfr_set_capture_count_support(struct wlan_objmgr_psoc *psoc,
153 					uint8_t value);
154 
155 /**
156  * target_if_cfr_set_mo_marking_support() - Function to set MO marking support
157  * @psoc: pointer to psoc object
158  * @value: value to be set
159  *
160  * Return: success/failure
161  */
162 QDF_STATUS
163 target_if_cfr_set_mo_marking_support(struct wlan_objmgr_psoc *psoc,
164 				     uint8_t value);
165 
166 /**
167  * target_if_cfr_set_aoa_for_rcc_support() - Function to set AoA for RCC
168  * @psoc: pointer to psoc object
169  * @value: value to be set
170  *
171  * Return: success/failure
172  */
173 QDF_STATUS
174 target_if_cfr_set_aoa_for_rcc_support(struct wlan_objmgr_psoc *psoc,
175 				      uint8_t value);
176 
177 /**
178  * target_if_cfr_info_send() - Function to send cfr info to upper layers
179  * @pdev: pointer to pdev object
180  * @head: pointer to cfr info head
181  * @hlen: head len
182  * @data: pointer to cfr info data
183  * @dlen: data len
184  * @tail: pointer to cfr info tail
185  * @tlen: tail len
186  */
187 void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head,
188 			     size_t hlen, void *data, size_t dlen, void *tail,
189 			     size_t tlen);
190 
191 /**
192  * target_if_cfr_fill_header() - Function to fill cfr header cmn section
193  * @hdr: pointer to the csi_cfr_header
194  * @is_wifi_2_0: flag to indicate legacy and non legacy radio
195  * @target_type: target type of the radio
196  * @is_rcc: flag to denote fill header request from periodic cfr/rcc
197  */
198 void target_if_cfr_fill_header(struct csi_cfr_header *hdr,
199 			       bool is_wifi_2_0,
200 			       uint32_t target_type,
201 			       bool is_rcc);
202 #endif
203