xref: /wlan-dirver/qca-wifi-host-cmn/spectral/dispatcher/inc/wlan_spectral_utils_api.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
1 /*
2  * Copyright (c) 2017-2019 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 #ifndef _WLAN_SPECTRAL_UTILS_API_H_
21 #define _WLAN_SPECTRAL_UTILS_API_H_
22 
23 #include <wlan_objmgr_cmn.h>
24 #include <wlan_lmac_if_def.h>
25 
26 /* Forward declaration */
27 struct direct_buf_rx_data;
28 struct wmi_spectral_cmd_ops;
29 
30 /**
31  * wlan_spectral_is_feature_disabled() - Check if spectral feature is disabled
32  * @psoc - the physical device object.
33  *
34  * Return : true if spectral is disabled, else false.
35  */
36 bool wlan_spectral_is_feature_disabled(struct wlan_objmgr_psoc *psoc);
37 
38 /**
39  * wlan_spectral_init() - API to init spectral component
40  *
41  * This API is invoked from dispatcher init during all component init.
42  * This API will register all required handlers for pdev and peer object
43  * create/delete notification.
44  *
45  * Return: SUCCESS,
46  *         Failure
47  */
48 QDF_STATUS wlan_spectral_init(void);
49 
50 /**
51  * wlan_spectral_deinit() - API to deinit spectral component
52  *
53  * This API is invoked from dispatcher deinit during all component deinit.
54  * This API will unregister all registered handlers for pdev and peer object
55  * create/delete notification.
56  *
57  * Return: SUCCESS,
58  *         Failure
59  */
60 QDF_STATUS wlan_spectral_deinit(void);
61 
62 /**
63  * wlan_lmac_if_sptrl_register_rx_ops() - Register lmac interface Rx operations
64  * @rx_ops: Pointer to lmac interface Rx operations structure
65  *
66  * API to register spectral related lmac interface Rx operations
67  *
68  * Return: None
69  */
70 void
71 wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops);
72 
73 /**
74 * wlan_register_wmi_spectral_cmd_ops() - Register operations related to wmi
75 * commands on spectral parameters
76 * @pdev    - the physical device object
77 * @cmd_ops - pointer to the structure holding the operations
78 *	     related to wmi commands on spectral parameters
79 *
80 * API to register operations related to wmi commands on spectral parameters
81 *
82 * Return: None
83 */
84 void
85 wlan_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev,
86 				   struct wmi_spectral_cmd_ops *cmd_ops);
87 
88 /**
89  * struct spectral_legacy_cbacks - Spectral legacy callbacks
90  * @vdev_get_chan_freq:          Get channel frequency
91  * @vdev_get_ch_width:           Get channel width
92  * @vdev_get_sec20chan_freq_mhz: Get seconadry 20 frequency
93  */
94 struct spectral_legacy_cbacks {
95 	int16_t (*vdev_get_chan_freq)(struct wlan_objmgr_vdev *vdev);
96 	enum phy_ch_width (*vdev_get_ch_width)(struct wlan_objmgr_vdev *vdev);
97 	int (*vdev_get_sec20chan_freq_mhz)(struct wlan_objmgr_vdev *vdev,
98 					   uint16_t *sec20chan_freq);
99 };
100 
101 /**
102  * spectral_vdev_get_chan_freq - Get vdev channel frequency
103  * @vdev:          vdev object
104  *
105  * Return: vdev operating frequency
106  */
107 int16_t spectral_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev);
108 
109 /**
110  * spectral_vdev_get_sec20chan_freq_mhz - Get vdev secondary channel frequency
111  * @vdev:   vdev object
112  * @sec20chan_freq: secondary channel frequency
113  *
114  * Return: secondary channel freq
115  */
116 int spectral_vdev_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
117 					uint16_t *sec20chan_freq);
118 
119 /**
120  * spectral_register_legacy_cb() - Register spectral legacy callbacks
121  * commands on spectral parameters
122  * @psoc    - the physical device object
123  * @legacy_cbacks - Reference to struct spectral_legacy_cbacks from which
124  * function pointers need to be copied
125  *
126  * API to register spectral related legacy callbacks
127  *
128  * Return: QDF_STATUS_SUCCESS upon successful registration,
129  *         QDF_STATUS_E_FAILURE upon failure
130  */
131 QDF_STATUS spectral_register_legacy_cb(
132 	struct wlan_objmgr_psoc *psoc,
133 	struct spectral_legacy_cbacks *legacy_cbacks);
134 
135 /**
136  * spectral_vdev_get_ch_width() - Get the channel bandwidth
137  * @vdev    - Pointer to vdev
138  *
139  * API to get the channel bandwidth of a given vdev
140  *
141  * Return: Enumeration corresponding to the channel bandwidth
142  */
143 enum phy_ch_width
144 spectral_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev);
145 
146 /**
147  * spectral_pdev_open() - Spectral pdev open handler
148  * @pdev:  pointer to pdev object
149  *
150  * API to execute operations on pdev open
151  *
152  * Return: QDF_STATUS_SUCCESS upon successful registration,
153  *         QDF_STATUS_E_FAILURE upon failure
154  */
155 QDF_STATUS spectral_pdev_open(struct wlan_objmgr_pdev *pdev);
156 
157 /**
158  * spectral_register_dbr() - register Spectral event handler with DDMA
159  * @pdev:  pointer to pdev object
160  *
161  * API to register event handler with Direct DMA
162  *
163  * Return: QDF_STATUS_SUCCESS upon successful registration,
164  *         QDF_STATUS_E_FAILURE upon failure
165  */
166 
167 QDF_STATUS spectral_register_dbr(struct wlan_objmgr_pdev *pdev);
168 
169 /**
170  * spectral_unregister_dbr() - unregister Spectral event handler with DDMA
171  * @pdev:  pointer to pdev object
172  *
173  * API to unregister event handler with Direct DMA
174  *
175  * Return: QDF_STATUS_SUCCESS upon successful unregistration,
176  *         QDF_STATUS_E_FAILURE upon failure
177  */
178 QDF_STATUS spectral_unregister_dbr(struct wlan_objmgr_pdev *pdev);
179 
180 #ifdef DIRECT_BUF_RX_ENABLE
181 /**
182  * spectral_dbr_event_handler() - Spectral dbr event handler
183  * @pdev:  pointer to pdev object
184  * @payload: dbr event buffer
185  *
186  * API to handle spectral dbr event
187  *
188  * Return: true to release buf
189  */
190 bool spectral_dbr_event_handler(struct wlan_objmgr_pdev *pdev,
191 				struct direct_buf_rx_data *payload);
192 #endif
193 #endif /* _WLAN_SPECTRAL_UTILS_API_H_*/
194