xref: /wlan-driver/qca-wifi-host-cmn/os_if/linux/wlan_cfg80211.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 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: declares driver functions interfacing with linux kernel
22  */
23 
24 
25 #ifndef _WLAN_CFG80211_H_
26 #define _WLAN_CFG80211_H_
27 
28 #include <linux/version.h>
29 #include <linux/netdevice.h>
30 #include <net/netlink.h>
31 #include <net/cfg80211.h>
32 #include <qca_vendor.h>
33 #include <qdf_nbuf.h>
34 #include "qal_devcfg.h"
35 #include "wlan_osif_features.h"
36 
37 #define osif_alert(params...) \
38 	QDF_TRACE_FATAL(QDF_MODULE_ID_OS_IF, params)
39 #define osif_err(params...) \
40 	QDF_TRACE_ERROR(QDF_MODULE_ID_OS_IF, params)
41 #define osif_warn(params...) \
42 	QDF_TRACE_WARN(QDF_MODULE_ID_OS_IF, params)
43 #define osif_notice(params...) \
44 	QDF_TRACE_INFO(QDF_MODULE_ID_OS_IF, params)
45 #define osif_info(params...) \
46 	QDF_TRACE_INFO(QDF_MODULE_ID_OS_IF, params)
47 #define osif_debug(params...) \
48 	QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, params)
49 #define osif_rl_debug(params...) \
50 	QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_OS_IF, params)
51 #define osif_err_rl(params...) \
52 	QDF_TRACE_ERROR_RL(QDF_MODULE_ID_OS_IF, params)
53 
54 #define osif_nofl_alert(params...) \
55 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_OS_IF, params)
56 #define osif_nofl_err(params...) \
57 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_OS_IF, params)
58 #define osif_nofl_warn(params...) \
59 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_OS_IF, params)
60 #define osif_nofl_info(params...) \
61 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_OS_IF, params)
62 #define osif_nofl_debug(params...) \
63 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_OS_IF, params)
64 
65 #define osif_enter_dev(dev) \
66 	QDF_TRACE_ENTER(QDF_MODULE_ID_OS_IF, "enter(%s)", (dev)->name)
67 
68 /**
69  * enum qca_nl80211_vendor_subcmds_index - vendor sub commands index
70  *
71  * @QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX: Avoid frequency
72  * @QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX: Nan
73  * @QCA_NL80211_VENDOR_SUBCMD_STATS_EXT_INDEX: Ext stats
74  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX: Ext scan start
75  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX: Ext scan stop
76  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX: Ext scan get
77  *	capability
78  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX: Ext scan get
79  *	cached results
80  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX: Ext scan
81  *	results available
82  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX: Ext scan full
83  *	scan result
84  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX: Ext scan event
85  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX: Ext scan hot list
86  *	AP found
87  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX: Ext scan set
88  *	bssid hotlist
89  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX: Ext scan reset
90  *	bssid hotlist
91  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX: Ext scan
92  *	significant change
93  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX: Ext scan
94  *	set significant change
95  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX: Ext scan
96  *	reset significant change
97  * @QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET_INDEX: Set stats
98  * @QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET_INDEX: Get stats
99  * @QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR_INDEX: Clear stats
100  * @QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX: Radio stats
101  * @QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX: Iface stats
102  * @QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX: Peer info stats
103  * @QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT_INDEX: MAC layer counters
104  * @QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX: Ext tdls state change
105  * @QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX: ACS command
106  * @QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX: Pass Roam and Auth info
107  * @QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED_INDEX:
108  * @QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED_INDEX:
109  * @QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED_INDEX:
110  * @QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED_INDEX:
111  * @QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED_INDEX:
112  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX: hotlist ap lost
113  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND_INDEX:
114  *	pno network found index
115  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND_INDEX:
116  *	passpoint match found index
117  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST_INDEX:
118  *	set ssid hotlist index
119  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST_INDEX:
120  *	reset ssid hotlist index
121  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX:
122  *	hotlist ssid found index
123  * @QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX:
124  *	hotlist ssid lost index
125  * @QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_CONFIGURATION_INDEX:
126  * @QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX:
127  * @QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX:
128  * @QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT_INDEX:
129  *	dcc stats event index
130  * @QCA_NL80211_VENDOR_SUBCMD_SCAN_INDEX: vendor scan index
131  * @QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX:
132  *	vendor scan complete event  index
133  * @QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG_INDEX:
134  *	update gateway parameters index
135  * @QCA_NL80211_VENDOR_SUBCMD_INTEROP_ISSUES_AP_INDEX:
136  *	update aps info which has interop issues events index
137  * @QCA_NL80211_VENDOR_SUBCMD_TSF_INDEX: TSF response events index
138  * @QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX:
139  * @QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX:
140  *      P2P listen offload index
141  * @QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH_INDEX: SAP
142  *      conditional channel switch index
143  * @QCA_NL80211_VENDOR_SUBCMD_UPDATE_EXTERNAL_ACS_CONFIG:
144  * @QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX:
145  * @QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX: NUD DEBUG Stats index
146  * @QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX: hang event reason index
147  * @QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO_INDEX: MAC mode info index
148  * @QCA_NL80211_VENDOR_SUBCMD_NAN_EXT_INDEX: NAN Extended index
149  * @QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX:
150  * @QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX:
151  * @QCA_NL80211_VENDOR_SUBCMD_PEER_STATS_CACHE_FLUSH_INDEX:
152  * @QCA_NL80211_VENDOR_SUBCMD_BEACON_REPORTING_INDEX: Beacon reporting index
153  * @QCA_NL80211_VENDOR_SUBCMD_ROAM_INDEX:
154  * @QCA_NL80211_VENDOR_SUBCMD_OEM_DATA_INDEX:
155  * @QCA_NL80211_VENDOR_SUBCMD_REQUEST_SAR_LIMITS_INDEX: Request SAR limit index
156  * @QCA_NL80211_VENDOR_SUBCMD_UPDATE_STA_INFO_INDEX: Update STA info index
157  * @QCA_NL80211_VENDOR_SUBCMD_MEDIUM_ASSESS_INDEX:
158  * @QCA_NL80211_VENDOR_SUBCMD_UPDATE_SSID_INDEX: Update SSID index
159  * @QCA_NL80211_VENDOR_SUBCMD_WIFI_FW_STATS_INDEX: Wifi FW stats index
160  * @QCA_NL80211_VENDOR_SUBCMD_MBSSID_TX_VDEV_STATUS_INDEX:
161  *	MBSSID TX VDEV status index
162  * @QCA_NL80211_VENDOR_SUBCMD_THERMAL_INDEX: Report thermal event index
163  * @QCA_NL80211_VENDOR_SUBCMD_CONFIG_TWT_INDEX: TWT config index
164  * @QCA_NL80211_VENDOR_SUBCMD_PEER_CFR_CAPTURE_CFG_INDEX: CFR data event index
165  * @QCA_NL80211_VENDOR_SUBCMD_DIAG_EVENT_INDEX:
166  * @QCA_NL80211_VENDOR_SUBCMD_ROAM_EVENTS_INDEX:
167  * @QCA_NL80211_VENDOR_SUBCMD_MCC_QUOTA_INDEX:
168  * @QCA_NL80211_VENDOR_SUBCMD_PEER_FLUSH_PENDING_INDEX:
169  * @QCA_NL80211_VENDOR_SUBCMD_DRIVER_READY_INDEX: Driver Ready after SSR index
170  * @QCA_NL80211_VENDOR_SUBCMD_PASN_AUTH_STATUS_INDEX: PASN auth status index
171  * @QCA_NL80211_VENDOR_SUBCMD_SCS_RULE_CONFIG_INDEX: SCS rule config index
172  * @QCA_NL80211_VENDOR_SUBCMD_SR_INDEX: SR Event index
173  * @QCA_NL80211_VENDOR_SUBCMD_MLO_PEER_PRIM_NETDEV_EVENT_INDEX: primary netdev
174  *     event index
175  * @QCA_NL80211_VENDOR_SUBCMD_AFC_EVENT_INDEX: AFC Event index
176  * @QCA_NL80211_VENDOR_SUBCMD_DOZED_AP_INDEX: Dozed AP event index
177  * @QCA_NL80211_VENDOR_SUBCMD_ROAM_STATS_INDEX: Roam stats index index
178  * @QCA_NL80211_VENDOR_SUBCMD_CONNECTED_CHANNEL_STATS_INDEX: Connected channel
179  * stats index
180  * @QCA_NL80211_VENDOR_SUBCMD_DRIVER_DISCONNECT_REASON_INDEX:
181  *	Driver disconnect reason index
182  * @QCA_NL80211_VENDOR_SUBCMD_TID_TO_LINK_MAP_INDEX: TID-to-link map index
183  * @QCA_NL80211_VENDOR_SUBCMD_LINK_RECONFIG_INDEX: link reconfig event index
184  * @QCA_NL80211_VENDOR_SUBCMD_AUDIO_TRANSPORT_SWITCH_INDEX: Audio transport
185  * switch event index
186  * @QCA_NL80211_VENDOR_SUBCMD_TX_LATENCY_INDEX: event index for transmit
187  *	latency stats
188  * @QCA_NL80211_VENDOR_SUBCMD_RECONFIG_REMOVE_COMPLETE_EVENT_INDEX: ML Reconfig
189  * remove complete event index
190  * @QCA_NL80211_VENDOR_SUBCMD_FW_PAGE_FAULT_REPORT_INDEX: Pagefault report
191  * event index
192  */
193 
194 enum qca_nl80211_vendor_subcmds_index {
195 	QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX = 0,
196 
197 	QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
198 
199 #ifdef WLAN_FEATURE_STATS_EXT
200 	QCA_NL80211_VENDOR_SUBCMD_STATS_EXT_INDEX,
201 #endif /* WLAN_FEATURE_STATS_EXT */
202 
203 #ifdef FEATURE_WLAN_EXTSCAN
204 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
205 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
206 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
207 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
208 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
209 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
210 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
211 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
212 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
213 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
214 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
215 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
216 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
217 #endif /* FEATURE_WLAN_EXTSCAN */
218 
219 #ifdef WLAN_FEATURE_LINK_LAYER_STATS
220 	QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET_INDEX,
221 	QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET_INDEX,
222 	QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR_INDEX,
223 	QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
224 	QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
225 	QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
226 	QCA_NL80211_VENDOR_SUBCMD_LL_STATS_EXT_INDEX,
227 #endif /* WLAN_FEATURE_LINK_LAYER_STATS */
228 
229 	QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
230 	QCA_NL80211_VENDOR_SUBCMD_DO_ACS_INDEX,
231 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
232 	QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH_INDEX,
233 #endif
234 	/* DFS */
235 	QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_STARTED_INDEX,
236 	QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_FINISHED_INDEX,
237 	QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_ABORTED_INDEX,
238 	QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_CAC_NOP_FINISHED_INDEX,
239 	QCA_NL80211_VENDOR_SUBCMD_DFS_OFFLOAD_RADAR_DETECTED_INDEX,
240 #ifdef FEATURE_WLAN_EXTSCAN
241 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX,
242 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_NETWORK_FOUND_INDEX,
243 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_PNO_PASSPOINT_NETWORK_FOUND_INDEX,
244 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SSID_HOTLIST_INDEX,
245 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SSID_HOTLIST_INDEX,
246 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_FOUND_INDEX,
247 	QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_SSID_LOST_INDEX,
248 #endif /* FEATURE_WLAN_EXTSCAN */
249 	QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_CONFIGURATION_INDEX,
250 	QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX,
251 #ifdef WLAN_FEATURE_MEMDUMP
252 	QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX,
253 #endif /* WLAN_FEATURE_MEMDUMP */
254 	/* OCB events */
255 	QCA_NL80211_VENDOR_SUBCMD_DCC_STATS_EVENT_INDEX,
256 	QCA_NL80211_VENDOR_SUBCMD_SCAN_INDEX,
257 	QCA_NL80211_VENDOR_SUBCMD_SCAN_DONE_INDEX,
258 	QCA_NL80211_VENDOR_SUBCMD_GW_PARAM_CONFIG_INDEX,
259 	QCA_NL80211_VENDOR_SUBCMD_INTEROP_ISSUES_AP_INDEX,
260 #ifdef WLAN_FEATURE_TSF
261 	QCA_NL80211_VENDOR_SUBCMD_TSF_INDEX,
262 #endif
263 	QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX,
264 	QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX,
265 	QCA_NL80211_VENDOR_SUBCMD_SAP_CONDITIONAL_CHAN_SWITCH_INDEX,
266 	QCA_NL80211_VENDOR_SUBCMD_UPDATE_EXTERNAL_ACS_CONFIG,
267 	QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX,
268 	QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX,
269 	QCA_NL80211_VENDOR_SUBCMD_HANG_REASON_INDEX,
270 	QCA_NL80211_VENDOR_SUBCMD_WLAN_MAC_INFO_INDEX,
271 	QCA_NL80211_VENDOR_SUBCMD_NAN_EXT_INDEX,
272 	QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX,
273 	QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES_INDEX,
274 	QCA_NL80211_VENDOR_SUBCMD_PEER_STATS_CACHE_FLUSH_INDEX,
275 	QCA_NL80211_VENDOR_SUBCMD_BEACON_REPORTING_INDEX,
276 	QCA_NL80211_VENDOR_SUBCMD_ROAM_INDEX,
277 	QCA_NL80211_VENDOR_SUBCMD_OEM_DATA_INDEX,
278 	QCA_NL80211_VENDOR_SUBCMD_REQUEST_SAR_LIMITS_INDEX,
279 	QCA_NL80211_VENDOR_SUBCMD_UPDATE_STA_INFO_INDEX,
280 	QCA_NL80211_VENDOR_SUBCMD_MEDIUM_ASSESS_INDEX,
281 	QCA_NL80211_VENDOR_SUBCMD_UPDATE_SSID_INDEX,
282 	QCA_NL80211_VENDOR_SUBCMD_WIFI_FW_STATS_INDEX,
283 	QCA_NL80211_VENDOR_SUBCMD_MBSSID_TX_VDEV_STATUS_INDEX,
284 	QCA_NL80211_VENDOR_SUBCMD_THERMAL_INDEX,
285 	QCA_NL80211_VENDOR_SUBCMD_DRIVER_DISCONNECT_REASON_INDEX,
286 #ifdef WLAN_SUPPORT_TWT
287 	QCA_NL80211_VENDOR_SUBCMD_CONFIG_TWT_INDEX,
288 #endif
289 #ifdef WLAN_CFR_ENABLE
290 	QCA_NL80211_VENDOR_SUBCMD_PEER_CFR_CAPTURE_CFG_INDEX,
291 #endif
292 #ifdef WLAN_FEATURE_CONNECTIVITY_LOGGING
293 	QCA_NL80211_VENDOR_SUBCMD_DIAG_EVENT_INDEX,
294 #endif
295 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
296 	QCA_NL80211_VENDOR_SUBCMD_ROAM_EVENTS_INDEX,
297 #endif
298 	QCA_NL80211_VENDOR_SUBCMD_MCC_QUOTA_INDEX,
299 	QCA_NL80211_VENDOR_SUBCMD_PEER_FLUSH_PENDING_INDEX,
300 	QCA_NL80211_VENDOR_SUBCMD_DRIVER_READY_INDEX,
301 	QCA_NL80211_VENDOR_SUBCMD_PASN_AUTH_STATUS_INDEX,
302 	QCA_NL80211_VENDOR_SUBCMD_SCS_RULE_CONFIG_INDEX,
303 #ifdef WLAN_FEATURE_SR
304 	QCA_NL80211_VENDOR_SUBCMD_SR_INDEX,
305 #endif
306 	QCA_NL80211_VENDOR_SUBCMD_MLO_PEER_PRIM_NETDEV_EVENT_INDEX,
307 #ifdef CONFIG_AFC_SUPPORT
308 	QCA_NL80211_VENDOR_SUBCMD_AFC_EVENT_INDEX,
309 #endif
310 #ifdef WLAN_SUPPORT_GAP_LL_PS_MODE
311 	QCA_NL80211_VENDOR_SUBCMD_DOZED_AP_INDEX,
312 #endif
313 #ifdef WLAN_FEATURE_ROAM_INFO_STATS
314 	QCA_NL80211_VENDOR_SUBCMD_ROAM_STATS_INDEX,
315 #endif
316 	QCA_NL80211_VENDOR_SUBCMD_CONNECTED_CHANNEL_STATS_INDEX,
317 #ifdef WLAN_FEATURE_11BE_MLO
318 	QCA_NL80211_VENDOR_SUBCMD_TID_TO_LINK_MAP_INDEX,
319 #ifdef CONN_MGR_ADV_FEATURE
320 	QCA_NL80211_VENDOR_SUBCMD_LINK_RECONFIG_INDEX,
321 #endif
322 #endif
323 	QCA_NL80211_VENDOR_SUBCMD_AUDIO_TRANSPORT_SWITCH_INDEX,
324 #ifdef WLAN_FEATURE_TX_LATENCY_STATS
325 	QCA_NL80211_VENDOR_SUBCMD_TX_LATENCY_INDEX,
326 #endif
327 	QCA_NL80211_VENDOR_SUBCMD_RECONFIG_REMOVE_COMPLETE_EVENT_INDEX,
328 	QCA_NL80211_VENDOR_SUBCMD_FW_PAGE_FAULT_REPORT_INDEX,
329 };
330 
331 #if !defined(SUPPORT_WDEV_CFG80211_VENDOR_EVENT_ALLOC) && \
332 	(LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && \
333 	!defined(WITH_BACKPORTS)
334 
335 static inline struct sk_buff *
backported_cfg80211_vendor_event_alloc(struct wiphy * wiphy,struct wireless_dev * wdev,int approxlen,int event_idx,gfp_t gfp)336 backported_cfg80211_vendor_event_alloc(struct wiphy *wiphy,
337 				       struct wireless_dev *wdev,
338 				       int approxlen,
339 				       int event_idx, gfp_t gfp)
340 {
341 	struct sk_buff *skb;
342 
343 	skb = cfg80211_vendor_event_alloc(wiphy, approxlen, event_idx, gfp);
344 
345 	if (skb && wdev) {
346 		struct nlattr *attr;
347 		u32 ifindex = wdev->netdev->ifindex;
348 
349 		nla_nest_cancel(skb, ((void **)skb->cb)[2]);
350 		if (nla_put_u32(skb, NL80211_ATTR_IFINDEX, ifindex))
351 			goto nla_fail;
352 
353 		attr = nla_nest_start(skb, NL80211_ATTR_VENDOR_DATA);
354 		((void **)skb->cb)[2] = attr;
355 	}
356 
357 	return skb;
358 
359 nla_fail:
360 	kfree_skb(skb);
361 
362 	return NULL;
363 }
364 
365 #define cfg80211_vendor_event_alloc backported_cfg80211_vendor_event_alloc
366 #endif
367 
368 /* For kernel version >= 5.2, driver needs to provide policy */
369 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0))
370 #define vendor_command_policy(__policy, __maxattr) \
371 	.policy = __policy,                        \
372 	.maxattr = __maxattr
373 #define VENDOR_NLA_POLICY_NESTED(__policy) \
374 	NLA_POLICY_NESTED(__policy)
375 #define VENDOR_NLA_POLICY_NESTED_ARRAY(__policy) \
376 	NLA_POLICY_NESTED_ARRAY(__policy)
377 #else
378 #define vendor_command_policy(__policy, __maxattr)
379 #define VENDOR_NLA_POLICY_NESTED(__policy) {.type = NLA_NESTED}
380 #define VENDOR_NLA_POLICY_NESTED_ARRAY(__policy) \
381 	VENDOR_NLA_POLICY_NESTED(__policy)
382 #endif /*End of (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) */
383 
384 /* For kernel version <= 4.20, driver needs to provide policy */
385 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
386 #define VENDOR_NLA_POLICY_MAC_ADDR NLA_POLICY_ETH_ADDR
387 #define VENDOR_NLA_POLICY_IPV4_ADDR NLA_POLICY_EXACT_LEN(QDF_IPV4_ADDR_SIZE)
388 #define VENDOR_NLA_POLICY_IPV6_ADDR NLA_POLICY_EXACT_LEN(QDF_IPV6_ADDR_SIZE)
389 #else
390 #define VENDOR_NLA_POLICY_MAC_ADDR \
391 	{.type = NLA_UNSPEC, .len = QDF_MAC_ADDR_SIZE}
392 #define NLA_EXACT_LEN NLA_UNSPEC
393 #define VENDOR_NLA_POLICY_IPV4_ADDR \
394 	{.type = NLA_EXACT_LEN, .len = QDF_IPV4_ADDR_SIZE}
395 #define VENDOR_NLA_POLICY_IPV6_ADDR \
396 	{.type = NLA_EXACT_LEN, .len = QDF_IPV6_ADDR_SIZE}
397 #endif /*End of (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 20, 0) */
398 
399 #if defined(NBUF_MEMORY_DEBUG) && defined(NETLINK_BUF_TRACK)
400 #define wlan_cfg80211_vendor_free_skb(skb) \
401 	qdf_nbuf_free(skb)
402 
403 #define wlan_cfg80211_vendor_event(skb, gfp) \
404 { \
405 	qdf_nbuf_count_dec(skb); \
406 	qdf_net_buf_debug_release_skb(skb); \
407 	cfg80211_vendor_event(skb, gfp); \
408 }
409 
410 #define wlan_cfg80211_vendor_cmd_reply(skb) \
411 { \
412 	qdf_nbuf_count_dec(skb); \
413 	qdf_net_buf_debug_release_skb(skb); \
414 	cfg80211_vendor_cmd_reply(skb); \
415 }
416 
wlan_cfg80211_qal_devcfg_send_response(qdf_nbuf_t skb)417 static inline QDF_STATUS wlan_cfg80211_qal_devcfg_send_response(qdf_nbuf_t skb)
418 {
419 	qdf_nbuf_count_dec(skb);
420 	qdf_net_buf_debug_release_skb(skb);
421 	return qal_devcfg_send_response(skb);
422 }
423 
424 static inline struct sk_buff *
__cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy * wiphy,int len,const char * func,uint32_t line)425 __cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int len,
426 				      const char *func, uint32_t line)
427 {
428 	struct sk_buff *skb;
429 
430 	skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, len);
431 	if (skb) {
432 		qdf_nbuf_count_inc(skb);
433 		qdf_net_buf_debug_acquire_skb(skb, func, line);
434 	}
435 	return skb;
436 }
437 #define wlan_cfg80211_vendor_cmd_alloc_reply_skb(wiphy, len) \
438 	__cfg80211_vendor_cmd_alloc_reply_skb(wiphy, len, __func__, __LINE__)
439 
440 static inline struct sk_buff *
__cfg80211_vendor_event_alloc(struct wiphy * wiphy,struct wireless_dev * wdev,int approxlen,int event_idx,gfp_t gfp,const char * func,uint32_t line)441 __cfg80211_vendor_event_alloc(struct wiphy *wiphy,
442 			      struct wireless_dev *wdev,
443 			      int approxlen,
444 			      int event_idx,
445 			      gfp_t gfp,
446 			      const char *func,
447 			      uint32_t line)
448 {
449 	struct sk_buff *skb;
450 
451 	skb = cfg80211_vendor_event_alloc(wiphy, wdev,
452 					  approxlen,
453 					  event_idx,
454 					  gfp);
455 	if (skb) {
456 		qdf_nbuf_count_inc(skb);
457 		qdf_net_buf_debug_acquire_skb(skb, func, line);
458 	}
459 	return skb;
460 }
461 #define wlan_cfg80211_vendor_event_alloc(wiphy, wdev, len, idx, gfp) \
462 	__cfg80211_vendor_event_alloc(wiphy, wdev, len, \
463 				      idx, gfp, \
464 				      __func__, __LINE__)
465 #else /* NBUF_MEMORY_DEBUG && NETLINK_BUF_TRACK */
466 #define wlan_cfg80211_vendor_free_skb(skb) \
467 	kfree_skb(skb)
468 
469 #define wlan_cfg80211_vendor_event(skb, gfp) \
470 	cfg80211_vendor_event(skb, gfp)
471 
472 #define wlan_cfg80211_vendor_cmd_reply(skb) \
473 	cfg80211_vendor_cmd_reply(skb)
474 
475 #define wlan_cfg80211_vendor_cmd_alloc_reply_skb(wiphy, len) \
476 	cfg80211_vendor_cmd_alloc_reply_skb(wiphy, len)
477 
478 #define wlan_cfg80211_vendor_event_alloc(wiphy, wdev, len, idx, gfp) \
479 	cfg80211_vendor_event_alloc(wiphy, wdev, len, idx, gfp)
480 
wlan_cfg80211_qal_devcfg_send_response(qdf_nbuf_t skb)481 static inline QDF_STATUS wlan_cfg80211_qal_devcfg_send_response( qdf_nbuf_t skb)
482 {
483 	return qal_devcfg_send_response(skb);
484 }
485 #endif /* NBUF_MEMORY_DEBUG && NETLINK_BUF_TRACK */
486 
487 #undef nla_parse
488 #undef nla_parse_nested
489 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
wlan_cfg80211_nla_parse(struct nlattr ** tb,int maxtype,const struct nlattr * head,int len,const struct nla_policy * policy)490 static inline int wlan_cfg80211_nla_parse(struct nlattr **tb,
491 					  int maxtype,
492 					  const struct nlattr *head,
493 					  int len,
494 					  const struct nla_policy *policy)
495 {
496 	return nla_parse(tb, maxtype, head, len, policy);
497 }
498 
499 static inline int
wlan_cfg80211_nla_parse_nested(struct nlattr * tb[],int maxtype,const struct nlattr * nla,const struct nla_policy * policy)500 wlan_cfg80211_nla_parse_nested(struct nlattr *tb[],
501 			       int maxtype,
502 			       const struct nlattr *nla,
503 			       const struct nla_policy *policy)
504 {
505 	return nla_parse_nested(tb, maxtype, nla, policy);
506 }
507 #else
wlan_cfg80211_nla_parse(struct nlattr ** tb,int maxtype,const struct nlattr * head,int len,const struct nla_policy * policy)508 static inline int wlan_cfg80211_nla_parse(struct nlattr **tb,
509 					  int maxtype,
510 					  const struct nlattr *head,
511 					  int len,
512 					  const struct nla_policy *policy)
513 {
514 	return nla_parse(tb, maxtype, head, len, policy, NULL);
515 }
516 
517 static inline int
wlan_cfg80211_nla_parse_nested(struct nlattr * tb[],int maxtype,const struct nlattr * nla,const struct nla_policy * policy)518 wlan_cfg80211_nla_parse_nested(struct nlattr *tb[],
519 			       int maxtype,
520 			       const struct nlattr *nla,
521 			       const struct nla_policy *policy)
522 {
523 	return nla_parse_nested(tb, maxtype, nla, policy, NULL);
524 }
525 #endif
526 #define nla_parse(...) (obsolete, use wlan_cfg80211_nla_parse)
527 #define nla_parse_nested(...) (obsolete, use wlan_cfg80211_nla_parse_nested)
528 
529 /**
530  * wlan_cfg80211_nla_put_u64() - Add u64 attribute to an skb and align it
531  * @skb: SKB to add attribute(s) to
532  * @attrtype: u64 attribute id
533  * @value: u64 attribute value
534  *
535  * This function adds a u64 attribute, and optionally a pad attribute, to the
536  * skb. If this function adds a pad attribute, that pad attribute is defined
537  * in enum qca_wlan_vendor_attr, so only 64-bit attributes that are defined
538  * in enum qca_wlan_vendor_attr should use this interface. For other u64
539  * attributes, use function wlan_cfg80211_nla_put_u64_64bit() since that
540  * allows the pad attribute to be specified.
541  *
542  * Return: 0 if u64 attribute and optional pad attribute added to skb,
543  *         negative errno if operation fails
544  */
545 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
546 static inline int
wlan_cfg80211_nla_put_u64(struct sk_buff * skb,int attrtype,u64 value)547 wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
548 {
549 	return nla_put_u64(skb, attrtype, value);
550 }
551 #else
552 static inline int
wlan_cfg80211_nla_put_u64(struct sk_buff * skb,int attrtype,u64 value)553 wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
554 {
555 	return nla_put_u64_64bit(skb, attrtype, value, NL80211_ATTR_PAD);
556 }
557 #endif
558 
559 /**
560  * wlan_cfg80211_nla_put_u64_64bit() - Add u64 attribute to an skb and align it
561  * @skb: SKB to add attribute(s) to
562  * @attrtype: u64 attribute id
563  * @value: u64 attribute value
564  * @padattr: padding attribute id
565  *
566  * This function adds a u64 attribute, and optionally a pad attribute,
567  * to the skb. Unlike wlan_cfg80211_nla_put_u64() which can only be
568  * used with attributes defined in enum qca_wlan_vendor_attr, this
569  * function can be used with attributes defined in any enum, provided
570  * that the enum also defines a pad attribute.
571  *
572  * Return: 0 if u64 attribute and optional pad attribute added to skb,
573  *         negative errno if operation fails
574  */
575 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
576 static inline int
wlan_cfg80211_nla_put_u64_64bit(struct sk_buff * skb,int attrtype,u64 value,int padattr)577 wlan_cfg80211_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
578 				u64 value, int padattr)
579 {
580 	return nla_put_u64(skb, attrtype, value);
581 }
582 #else
583 static inline int
wlan_cfg80211_nla_put_u64_64bit(struct sk_buff * skb,int attrtype,u64 value,int padattr)584 wlan_cfg80211_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
585 				u64 value, int padattr)
586 {
587 	return nla_put_u64_64bit(skb, attrtype, value, padattr);
588 }
589 #endif
590 
591 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
592 static inline ssize_t
wlan_cfg80211_nla_strscpy(char * dst,const struct nlattr * nla,size_t dstsize)593 wlan_cfg80211_nla_strscpy(char *dst, const struct nlattr *nla, size_t dstsize)
594 {
595 	return nla_strlcpy(dst, nla, dstsize);
596 }
597 #else
598 static inline ssize_t
wlan_cfg80211_nla_strscpy(char * dst,const struct nlattr * nla,size_t dstsize)599 wlan_cfg80211_nla_strscpy(char *dst, const struct nlattr *nla, size_t dstsize)
600 {
601 	return nla_strscpy(dst, nla, dstsize);
602 }
603 #endif
604 
605 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) || \
606 	(defined CFG80211_CHANGE_NETDEV_REGISTRATION_SEMANTICS))
wlan_cfg80211_register_netdevice(struct net_device * dev)607 static inline int wlan_cfg80211_register_netdevice(struct net_device *dev)
608 {
609 	return cfg80211_register_netdevice(dev);
610 }
611 #else
wlan_cfg80211_register_netdevice(struct net_device * dev)612 static inline int wlan_cfg80211_register_netdevice(struct net_device *dev)
613 {
614 	return register_netdevice(dev);
615 }
616 #endif
617 
618 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) || \
619 	(defined CFG80211_CHANGE_NETDEV_REGISTRATION_SEMANTICS))
wlan_cfg80211_unregister_netdevice(struct net_device * dev)620 static inline void wlan_cfg80211_unregister_netdevice(struct net_device *dev)
621 {
622 	cfg80211_unregister_netdevice(dev);
623 }
624 #else
wlan_cfg80211_unregister_netdevice(struct net_device * dev)625 static inline void wlan_cfg80211_unregister_netdevice(struct net_device *dev)
626 {
627 	unregister_netdevice(dev);
628 }
629 #endif
630 
631 #ifdef CFG80211_SINGLE_NETDEV_MULTI_LINK_SUPPORT
632 #if defined(CFG80211_RU_PUNCT_NOTIFY) || \
633 	defined(CFG80211_PUNCTURING_SINGLE_NETDEV_API)
634 static inline
wlan_cfg80211_ch_switch_notify(struct net_device * dev,struct cfg80211_chan_def * chandef,unsigned int link_id,uint16_t puncture_bitmap)635 void wlan_cfg80211_ch_switch_notify(struct net_device *dev,
636 				    struct cfg80211_chan_def *chandef,
637 				    unsigned int link_id,
638 				    uint16_t puncture_bitmap)
639 {
640 	cfg80211_ch_switch_notify(dev, chandef, link_id,
641 				  puncture_bitmap);
642 }
643 #else
644 static inline
wlan_cfg80211_ch_switch_notify(struct net_device * dev,struct cfg80211_chan_def * chandef,unsigned int link_id,uint16_t puncture_bitmap)645 void wlan_cfg80211_ch_switch_notify(struct net_device *dev,
646 				    struct cfg80211_chan_def *chandef,
647 				    unsigned int link_id,
648 				    uint16_t puncture_bitmap)
649 {
650 	cfg80211_ch_switch_notify(dev, chandef, link_id);
651 }
652 #endif
653 #else
654 static inline
wlan_cfg80211_ch_switch_notify(struct net_device * dev,struct cfg80211_chan_def * chandef,unsigned int link_id,uint16_t puncture_bitmap)655 void wlan_cfg80211_ch_switch_notify(struct net_device *dev,
656 				    struct cfg80211_chan_def *chandef,
657 				    unsigned int link_id,
658 				    uint16_t puncture_bitmap)
659 {
660 	cfg80211_ch_switch_notify(dev, chandef);
661 }
662 #endif
663 
664 #endif
665