1 /*
2 * Copyright (c) 2017-2020 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 /**
21 * DOC: wlan_hdd_spectralscan.h
22 *
23 * WLAN Host Device Driver spectral scan implementation
24 *
25 */
26
27 #if !defined(WLAN_HDD_SPECTRALSCAN_H)
28 #define WLAN_HDD_SPECTRALSCAN_H
29
30 #ifdef WLAN_CONV_SPECTRAL_ENABLE
31
32 /*
33 * enum spectral_scan_msg_type - spectral scan registration
34 * @SPECTRAL_SCAN_REGISTER_REQ: spectral scan app register request
35 * @SPECTRAL_SCAN_REGISTER_RSP: spectral scan app register response
36 */
37 enum spectral_scan_msg_type {
38 SPECTRAL_SCAN_REGISTER_REQ,
39 SPECTRAL_SCAN_REGISTER_RSP,
40 };
41
42 /*
43 * struct spectral_scan_msg - spectral scan request message
44 * @msg_type: message type
45 * @pid: process id
46 */
47 struct spectral_scan_msg {
48 uint32_t msg_type;
49 uint32_t pid;
50 };
51
52 /**
53 * struct spectral_scan_msg_v - spectral scan request message included version
54 * @msg_type: message type
55 * @pid: process id
56 * @version: version information
57 * @sub_version: sub version information
58 */
59 struct spectral_scan_msg_v {
60 uint32_t msg_type;
61 uint32_t pid;
62 uint32_t version;
63 uint32_t sub_version;
64 };
65
66 #define FEATURE_SPECTRAL_SCAN_VENDOR_COMMANDS \
67 { \
68 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
69 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SPECTRAL_SCAN_START, \
70 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
71 WIPHY_VENDOR_CMD_NEED_NETDEV, \
72 .doit = wlan_hdd_cfg80211_spectral_scan_start, \
73 vendor_command_policy(spectral_scan_policy, \
74 QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_CONFIG_MAX) \
75 }, \
76 { \
77 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
78 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SPECTRAL_SCAN_STOP, \
79 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
80 WIPHY_VENDOR_CMD_NEED_NETDEV, \
81 .doit = wlan_hdd_cfg80211_spectral_scan_stop, \
82 vendor_command_policy(spectral_scan_policy, \
83 QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_CONFIG_MAX) \
84 }, \
85 { \
86 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
87 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SPECTRAL_SCAN_GET_CONFIG, \
88 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
89 WIPHY_VENDOR_CMD_NEED_NETDEV, \
90 .doit = wlan_hdd_cfg80211_spectral_scan_get_config, \
91 vendor_command_policy(spectral_scan_policy, \
92 QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_CONFIG_MAX) \
93 }, \
94 { \
95 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
96 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SPECTRAL_SCAN_GET_DIAG_STATS, \
97 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
98 WIPHY_VENDOR_CMD_NEED_NETDEV, \
99 .doit = wlan_hdd_cfg80211_spectral_scan_get_diag_stats, \
100 vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) \
101 }, \
102 { \
103 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
104 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SPECTRAL_SCAN_GET_CAP_INFO, \
105 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
106 WIPHY_VENDOR_CMD_NEED_NETDEV, \
107 .doit = wlan_hdd_cfg80211_spectral_scan_get_cap_info, \
108 vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) \
109 }, \
110 { \
111 .info.vendor_id = QCA_NL80211_VENDOR_ID, \
112 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SPECTRAL_SCAN_GET_STATUS, \
113 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
114 WIPHY_VENDOR_CMD_NEED_NETDEV, \
115 .doit = wlan_hdd_cfg80211_spectral_scan_get_status, \
116 vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) \
117 },
118
119 /**
120 * wlan_hdd_cfg80211_spectral_scan_start() - start spectral scan
121 * @wiphy: WIPHY structure pointer
122 * @wdev: Wireless device structure pointer
123 * @data: Pointer to the data received
124 * @data_len: Length of the data received
125 *
126 * This function starts spectral scan
127 *
128 * Return: 0 on success and errno on failure
129 */
130 int wlan_hdd_cfg80211_spectral_scan_start(struct wiphy *wiphy,
131 struct wireless_dev *wdev,
132 const void *data,
133 int data_len);
134
135 /**
136 * wlan_hdd_cfg80211_spectral_scan_stop() - stop spectral scan
137 * @wiphy: WIPHY structure pointer
138 * @wdev: Wireless device structure pointer
139 * @data: Pointer to the data received
140 * @data_len: Length of the data received
141 *
142 * This function stops spectral scan
143 *
144 * Return: 0 on success and errno on failure
145 */
146 int wlan_hdd_cfg80211_spectral_scan_stop(struct wiphy *wiphy,
147 struct wireless_dev *wdev,
148 const void *data,
149 int data_len);
150
151 /**
152 * wlan_hdd_cfg80211_spectral_scan_get_config() - get spectral scan config
153 * @wiphy: WIPHY structure pointer
154 * @wdev: Wireless device structure pointer
155 * @data: Pointer to the data received
156 * @data_len: Length of the data received
157 *
158 * This function gets the spectral scan configuration
159 *
160 * Return: 0 on success and errno on failure
161 */
162 int wlan_hdd_cfg80211_spectral_scan_get_config(struct wiphy *wiphy,
163 struct wireless_dev *wdev,
164 const void *data,
165 int data_len);
166
167 /**
168 * wlan_hdd_cfg80211_spectral_scan_get_diag_stats() -
169 * get spectral scan diag stats
170 * @wiphy: WIPHY structure pointer
171 * @wdev: Wireless device structure pointer
172 * @data: Pointer to the data received
173 * @data_len: Length of the data received
174 *
175 * This function gets spectral scan diagnostic statistics
176 *
177 * Return: 0 on success and errno on failure
178 */
179 int wlan_hdd_cfg80211_spectral_scan_get_diag_stats(struct wiphy *wiphy,
180 struct wireless_dev *wdev,
181 const void *data,
182 int data_len);
183
184 /**
185 * wlan_hdd_cfg80211_spectral_scan_get_cap_info() - get spectral scan cpa
186 * @wiphy: WIPHY structure pointer
187 * @wdev: Wireless device structure pointer
188 * @data: Pointer to the data received
189 * @data_len: Length of the data received
190 *
191 * This function gets the spectral scan capabilities
192 *
193 * Return: 0 on success and errno on failure
194 */
195 int wlan_hdd_cfg80211_spectral_scan_get_cap_info(struct wiphy *wiphy,
196 struct wireless_dev *wdev,
197 const void *data,
198 int data_len);
199
200 /**
201 * wlan_hdd_cfg80211_spectral_scan_get_status() - get spectral scan status
202 * @wiphy: WIPHY structure pointer
203 * @wdev: Wireless device structure pointer
204 * @data: Pointer to the data received
205 * @data_len: Length of the data received
206 *
207 * This function gets the spectral scan status
208 *
209 * Return: 0 on success and errno on failure
210 */
211 int wlan_hdd_cfg80211_spectral_scan_get_status(struct wiphy *wiphy,
212 struct wireless_dev *wdev,
213 const void *data,
214 int data_len);
215
216 /**
217 * hdd_spectral_register_to_dbr() - Register spectral to DBR
218 * @hdd_ctx: pointer to hdd context
219 *
220 * This function registers spectral to Direct Buffer RX component.
221 *
222 * Return: None
223 */
224 void hdd_spectral_register_to_dbr(struct hdd_context *hdd_ctx);
225 #else
226 #define FEATURE_SPECTRAL_SCAN_VENDOR_COMMANDS
227 static inline void
hdd_spectral_register_to_dbr(struct hdd_context * hdd_ctx)228 hdd_spectral_register_to_dbr(struct hdd_context *hdd_ctx)
229 {
230 }
231 #endif
232
233 #if defined(CNSS_GENL) && defined(WLAN_CONV_SPECTRAL_ENABLE)
234 /**
235 * spectral_scan_activate_service() - Activate spectral scan message handler
236 * @hdd_ctx: callback context to use
237 *
238 * This function registers a handler to receive netlink message from
239 * the spectral scan application process.
240 *
241 * Return: None
242 */
243 void spectral_scan_activate_service(struct hdd_context *hdd_ctx);
244
245 /**
246 * spectral_scan_deactivate_service() - Deactivate spectral scan message handler
247 *
248 * This function deregisters a handler to receive netlink message from
249 * the spectral scan application process.
250 *
251 * Return: None
252 */
253 void spectral_scan_deactivate_service(void);
254
255 /**
256 * wlan_spectral_update_rx_chainmask() - API to update rx chainmask before
257 * start spectral gen3
258 * @link_info: Link info pointer in HDD adapter.
259 *
260 * API to update rx chainmask before start spectral gen3.
261 *
262 * Return: QDF_STATUS_SUCCESS or non-zero on failure
263 */
264 QDF_STATUS
265 wlan_spectral_update_rx_chainmask(struct wlan_hdd_link_info *link_info);
266 #else
spectral_scan_activate_service(struct hdd_context * hdd_ctx)267 static inline void spectral_scan_activate_service(struct hdd_context *hdd_ctx)
268 {
269 }
270
spectral_scan_deactivate_service(void)271 static inline void spectral_scan_deactivate_service(void)
272 {
273 }
274
275 #ifdef WLAN_CONV_SPECTRAL_ENABLE
276 static inline QDF_STATUS
wlan_spectral_update_rx_chainmask(struct wlan_hdd_link_info * link_info)277 wlan_spectral_update_rx_chainmask(struct wlan_hdd_link_info *link_info)
278 {
279 return QDF_STATUS_SUCCESS;
280 }
281 #endif /* WLAN_CONV_SPECTRAL_ENABLE */
282 #endif
283 #endif
284