xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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 #if !defined(WLAN_HDD_MAIN_H)
21 #define WLAN_HDD_MAIN_H
22 /**
23  * DOC: wlan_hdd_main.h
24  *
25  * Linux HDD Adapter Type
26  */
27 
28 /*
29  * The following terms were in use in prior versions of the driver but
30  * have now been replaced with terms that are aligned with the Linux
31  * Coding style. Macros are defined to hopefully prevent new instances
32  * from being introduced, primarily by code propagation.
33  */
34 #define pHddCtx
35 #define pAdapter
36 #define pHostapdAdapter
37 #define pHddApCtx
38 #define pHddStaCtx
39 #define pHostapdState
40 #define pRoamInfo
41 #define pScanInfo
42 #define pBeaconIes
43 
44 /*
45  * Include files
46  */
47 
48 #include <linux/netdevice.h>
49 #include <linux/skbuff.h>
50 #include <net/cfg80211.h>
51 #include <linux/ieee80211.h>
52 #include <qdf_delayed_work.h>
53 #include <qdf_list.h>
54 #include <qdf_types.h>
55 #include "sir_mac_prot_def.h"
56 #include "csr_api.h"
57 #include "wlan_dsc.h"
58 #include <wlan_hdd_assoc.h>
59 #include <wlan_hdd_wmm.h>
60 #include <wlan_hdd_cfg.h>
61 #include <linux/spinlock.h>
62 #include <ani_system_defs.h>
63 #if defined(CONFIG_HAS_WAKELOCK)
64 #include <linux/wakelock.h>
65 #endif
66 #ifdef WLAN_FEATURE_TSF_PTP
67 #include <linux/ptp_classify.h>
68 #include <linux/ptp_clock_kernel.h>
69 #endif
70 #include <wlan_hdd_ftm.h>
71 #include "wlan_hdd_tdls.h"
72 #include "wlan_hdd_tsf.h"
73 #include "wlan_hdd_cfg80211.h"
74 #include "wlan_hdd_debugfs.h"
75 #include <qdf_defer.h>
76 #include "sap_api.h"
77 #include "cdp_txrx_flow_ctrl_legacy.h"
78 #include <cdp_txrx_peer_ops.h>
79 #include <cdp_txrx_misc.h>
80 #include "wlan_hdd_nan_datapath.h"
81 #if defined(CONFIG_HL_SUPPORT)
82 #include "wlan_tgt_def_config_hl.h"
83 #else
84 #include "wlan_tgt_def_config.h"
85 #endif
86 #include <wlan_objmgr_cmn.h>
87 #include <wlan_objmgr_global_obj.h>
88 #include <wlan_objmgr_psoc_obj.h>
89 #include <wlan_objmgr_pdev_obj.h>
90 #include <wlan_objmgr_vdev_obj.h>
91 #include <wlan_objmgr_peer_obj.h>
92 #include "wlan_pmo_ucfg_api.h"
93 #ifdef WIFI_POS_CONVERGED
94 #include "os_if_wifi_pos.h"
95 #include "wifi_pos_api.h"
96 #else
97 #include "wlan_hdd_oemdata.h"
98 #endif
99 #include "wlan_hdd_he.h"
100 
101 #include <net/neighbour.h>
102 #include <net/netevent.h>
103 #include "wlan_hdd_twt.h"
104 #include "wma_sar_public_structs.h"
105 #include "wlan_mlme_ucfg_api.h"
106 #include "pld_common.h"
107 #include "wlan_cm_roam_public_struct.h"
108 
109 #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH
110 #include "qdf_periodic_work.h"
111 #endif
112 
113 #if defined(CLD_PM_QOS) || defined(FEATURE_RUNTIME_PM)
114 #include <linux/pm_qos.h>
115 #endif
116 
117 #include "wlan_hdd_sta_info.h"
118 #include <wlan_hdd_cm_api.h>
119 #include "wlan_hdd_mlo.h"
120 #include "wlan_osif_features.h"
121 #include "wlan_dp_public_struct.h"
122 
123 /*
124  * Preprocessor definitions and constants
125  */
126 
127 /* Milli seconds to delay SSR thread when an packet is getting processed */
128 #define SSR_WAIT_SLEEP_TIME 200
129 /* MAX iteration count to wait for dp tx to complete */
130 #define MAX_SSR_WAIT_ITERATIONS 100
131 #define MAX_SSR_PROTECT_LOG (16)
132 
133 #define HDD_MAX_OEM_DATA_LEN 1024
134 #define HDD_MAX_FILE_NAME_LEN 64
135 #ifdef FEATURE_WLAN_APF
136 /**
137  * struct hdd_apf_context - hdd Context for apf
138  * @magic: magic number
139  * @qdf_apf_event: Completion variable for APF get operations
140  * @capability_response: capabilities response received from fw
141  * @apf_enabled: True: APF Interpreter enabled, False: Disabled
142  * @cmd_in_progress: Flag that indicates an APF command is in progress
143  * @buf: Buffer to accumulate read memory chunks
144  * @buf_len: Length of the read memory requested
145  * @offset: APF work memory offset to fetch from
146  * @lock: APF Context lock
147  */
148 struct hdd_apf_context {
149 	unsigned int magic;
150 	qdf_event_t qdf_apf_event;
151 	bool apf_enabled;
152 	bool cmd_in_progress;
153 	uint8_t *buf;
154 	uint32_t buf_len;
155 	uint32_t offset;
156 	qdf_spinlock_t lock;
157 };
158 #endif /* FEATURE_WLAN_APF */
159 
160 #ifdef TX_MULTIQ_PER_AC
161 #define TX_GET_QUEUE_IDX(ac, off) (((ac) * TX_QUEUES_PER_AC) + (off))
162 #define TX_QUEUES_PER_AC 4
163 #else
164 #define TX_GET_QUEUE_IDX(ac, off) (ac)
165 #define TX_QUEUES_PER_AC 1
166 #endif
167 
168 /** Number of Tx Queues */
169 #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || \
170 	defined(QCA_HL_NETDEV_FLOW_CONTROL) || \
171 	defined(QCA_LL_PDEV_TX_FLOW_CONTROL)
172 /* Only one HI_PRIO queue */
173 #define NUM_TX_QUEUES (4 * TX_QUEUES_PER_AC + 1)
174 #else
175 #define NUM_TX_QUEUES (4 * TX_QUEUES_PER_AC)
176 #endif
177 
178 #define NUM_RX_QUEUES 5
179 
180 /*
181  * Number of DPTRACE records to dump when a cfg80211 disconnect with reason
182  * WLAN_REASON_DEAUTH_LEAVING DEAUTH is received from user-space.
183  */
184 #define WLAN_DEAUTH_DPTRACE_DUMP_COUNT 100
185 
186 /* HDD_IS_RATE_LIMIT_REQ: Macro helper to implement rate limiting
187  * @flag: The flag to determine if limiting is required or not
188  * @rate: The number of seconds within which if multiple commands come, the
189  *	  flag will be set to true
190  *
191  * If the function in which this macro is used is called multiple times within
192  * "rate" number of seconds, the "flag" will be set to true which can be used
193  * to reject/take appropriate action.
194  */
195 #define HDD_IS_RATE_LIMIT_REQ(flag, rate)\
196 	do {\
197 		static ulong __last_ticks;\
198 		ulong __ticks = jiffies;\
199 		flag = false; \
200 		if (!time_after(__ticks,\
201 		    __last_ticks + rate * HZ)) {\
202 			flag = true; \
203 		} \
204 		else { \
205 			__last_ticks = __ticks;\
206 		} \
207 	} while (0)
208 
209 /*
210  * API in_compat_syscall() is introduced in 4.6 kernel to check whether we're
211  * in a compat syscall or not. It is a new way to query the syscall type, which
212  * works properly on all architectures.
213  *
214  */
215 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0))
in_compat_syscall(void)216 static inline bool in_compat_syscall(void) { return is_compat_task(); }
217 #endif
218 
219 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) || \
220 	defined(CFG80211_REMOVE_IEEE80211_BACKPORT)
221 #define HDD_NL80211_BAND_2GHZ   NL80211_BAND_2GHZ
222 #define HDD_NL80211_BAND_5GHZ   NL80211_BAND_5GHZ
223 #define HDD_NUM_NL80211_BANDS   NUM_NL80211_BANDS
224 #else
225 #define HDD_NL80211_BAND_2GHZ   IEEE80211_BAND_2GHZ
226 #define HDD_NL80211_BAND_5GHZ   IEEE80211_BAND_5GHZ
227 #define HDD_NUM_NL80211_BANDS   ((enum nl80211_band)IEEE80211_NUM_BANDS)
228 #endif
229 
230 #if defined(CONFIG_BAND_6GHZ) && (defined(CFG80211_6GHZ_BAND_SUPPORTED) || \
231 	(KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE))
232 #define HDD_NL80211_BAND_6GHZ   NL80211_BAND_6GHZ
233 #endif
234 
235 #define TSF_GPIO_PIN_INVALID 255
236 
237 /** Length of the TX queue for the netdev */
238 #define HDD_NETDEV_TX_QUEUE_LEN (3000)
239 
240 /** Hdd Tx Time out value */
241 #define HDD_TX_TIMEOUT          msecs_to_jiffies(5000)
242 
243 #define HDD_TX_STALL_THRESHOLD 4
244 
245 /** Hdd Default MTU */
246 #define HDD_DEFAULT_MTU         (1500)
247 
248 #ifdef QCA_CONFIG_SMP
249 #define NUM_CPUS NR_CPUS
250 #else
251 #define NUM_CPUS 1
252 #endif
253 
254 #define ACS_COMPLETE_TIMEOUT 3000
255 
256 #define HDD_PSOC_IDLE_SHUTDOWN_SUSPEND_DELAY (1000)
257 /**
258  * enum hdd_adapter_flags - event bitmap flags registered net device
259  * @NET_DEVICE_REGISTERED: Adapter is registered with the kernel
260  * @WMM_INIT_DONE: Adapter is initialized
261  * @DEVICE_IFACE_OPENED: Adapter has been "opened" via the kernel
262  * @WDEV_ONLY_REGISTERED: Only WDEV is registered
263  */
264 enum hdd_adapter_flags {
265 	NET_DEVICE_REGISTERED,
266 	WMM_INIT_DONE,
267 	DEVICE_IFACE_OPENED,
268 	WDEV_ONLY_REGISTERED,
269 };
270 
271 /**
272  * enum hdd_link_flags - Event bitmap flags specific to per link
273  * @SME_SESSION_OPENED: Firmware vdev has been created
274  * @SOFTAP_BSS_STARTED: Software Access Point (SAP) is running
275  * @SOFTAP_INIT_DONE: Software Access Point (SAP) is initialized
276  * @VENDOR_ACS_RESPONSE_PENDING: Waiting for event for vendor acs
277  */
278 enum hdd_link_flags {
279 	SME_SESSION_OPENED,
280 	SOFTAP_BSS_STARTED,
281 	SOFTAP_INIT_DONE,
282 	VENDOR_ACS_RESPONSE_PENDING,
283 };
284 
285 /**
286  * enum hdd_nb_cmd_id - North bound command IDs received during SSR
287  * @NO_COMMAND: No NB command received during SSR
288  * @INTERFACE_DOWN: Received interface down during SSR
289  */
290 enum hdd_nb_cmd_id {
291 	NO_COMMAND,
292 	INTERFACE_DOWN
293 };
294 
295 #define WLAN_WAIT_TIME_STATS       800
296 #define WLAN_WAIT_TIME_LINK_STATUS 800
297 
298 /** Maximum time(ms) to wait for mc thread suspend **/
299 #define WLAN_WAIT_TIME_MCTHREAD_SUSPEND  1200
300 
301 /** Maximum time(ms) to wait for target to be ready for suspend **/
302 #define WLAN_WAIT_TIME_READY_TO_SUSPEND  2000
303 
304 /* Scan Req Timeout */
305 #define WLAN_WAIT_TIME_SCAN_REQ 100
306 
307 #define WLAN_WAIT_TIME_APF     1000
308 
309 #define WLAN_WAIT_TIME_FW_ROAM_STATS 1000
310 
311 #define WLAN_WAIT_TIME_ANTENNA_ISOLATION 8000
312 
313 /* Maximum time(ms) to wait for RSO CMD status event */
314 #define WAIT_TIME_RSO_CMD_STATUS 2000
315 
316 /* rcpi request timeout in milli seconds */
317 #define WLAN_WAIT_TIME_RCPI 500
318 
319 #define WLAN_WAIT_PEER_CLEANUP 5000
320 
321 #define MAX_CFG_STRING_LEN  255
322 
323 /* Maximum time(ms) to wait for external acs response */
324 #define WLAN_VENDOR_ACS_WAIT_TIME 1000
325 
326 /* Maximum time(ms) to wait for monitor mode vdev up event completion*/
327 #define WLAN_MONITOR_MODE_VDEV_UP_EVT      SME_CMD_VDEV_START_BSS_TIMEOUT
328 
329 /* Mac Address string length */
330 #define MAC_ADDRESS_STR_LEN 18  /* Including null terminator */
331 /* Max and min IEs length in bytes */
332 #define MAX_GENIE_LEN (512)
333 #define MIN_GENIE_LEN (2)
334 
335 #define WPS_OUI_TYPE   "\x00\x50\xf2\x04"
336 #define WPS_OUI_TYPE_SIZE  4
337 
338 #define P2P_OUI_TYPE   "\x50\x6f\x9a\x09"
339 #define P2P_OUI_TYPE_SIZE  4
340 
341 #define OSEN_OUI_TYPE   "\x50\x6f\x9a\x12"
342 #define OSEN_OUI_TYPE_SIZE  4
343 
344 #ifdef WLAN_FEATURE_WFD
345 #define WFD_OUI_TYPE   "\x50\x6f\x9a\x0a"
346 #define WFD_OUI_TYPE_SIZE  4
347 #endif
348 
349 #define MBO_OUI_TYPE   "\x50\x6f\x9a\x16"
350 #define MBO_OUI_TYPE_SIZE  4
351 
352 #define QCN_OUI_TYPE   "\x8c\xfd\xf0\x01"
353 #define QCN_OUI_TYPE_SIZE  4
354 
355 #define wlan_hdd_get_wps_ie_ptr(ie, ie_len) \
356 	wlan_get_vendor_ie_ptr_from_oui(WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE, \
357 	ie, ie_len)
358 
359 #define hdd_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_HDD, params)
360 #define hdd_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_HDD, params)
361 #define hdd_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_HDD, params)
362 #define hdd_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_HDD, params)
363 #define hdd_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_HDD, params)
364 
365 #define hdd_nofl_alert(params...) \
366 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_HDD, params)
367 #define hdd_nofl_err(params...) \
368 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_HDD, params)
369 #define hdd_nofl_warn(params...) \
370 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_HDD, params)
371 #define hdd_nofl_info(params...) \
372 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_HDD, params)
373 #define hdd_nofl_debug(params...) \
374 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_HDD, params)
375 
376 #define hdd_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_HDD, params)
377 #define hdd_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_HDD, params)
378 #define hdd_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_HDD, params)
379 #define hdd_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_HDD, params)
380 #define hdd_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_HDD, params)
381 
382 #define hdd_enter() QDF_TRACE_ENTER(QDF_MODULE_ID_HDD, "enter")
383 #define hdd_enter_dev(dev) \
384 	QDF_TRACE_ENTER(QDF_MODULE_ID_HDD, "enter(%s)", (dev)->name)
385 #define hdd_exit() QDF_TRACE_EXIT(QDF_MODULE_ID_HDD, "exit")
386 
387 #define WLAN_HDD_GET_PRIV_PTR(__dev__) \
388 		(struct hdd_adapter *)(netdev_priv((__dev__)))
389 
390 #define MAX_NO_OF_2_4_CHANNELS 14
391 
392 #define WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET 24
393 
394 #define WLAN_HDD_IS_SOCIAL_CHANNEL(center_freq)	\
395 	(((center_freq) == 2412) || ((center_freq) == 2437) || \
396 	((center_freq) == 2462))
397 
398 #define WLAN_HDD_QOS_ACTION_FRAME 1
399 #define WLAN_HDD_QOS_MAP_CONFIGURE 4
400 #define HDD_SAP_WAKE_LOCK_DURATION WAKELOCK_DURATION_RECOMMENDED
401 
402 /* SAP client disconnect wake lock duration in milli seconds */
403 #define HDD_SAP_CLIENT_DISCONNECT_WAKE_LOCK_DURATION \
404 	WAKELOCK_DURATION_RECOMMENDED
405 
406 #define HDD_CFG_REQUEST_FIRMWARE_RETRIES (3)
407 #define HDD_CFG_REQUEST_FIRMWARE_DELAY (20)
408 
409 #define MAX_USER_COMMAND_SIZE 4096
410 #define DNS_DOMAIN_NAME_MAX_LEN 255
411 #define ICMPv6_ADDR_LEN 16
412 
413 
414 #define HDD_MIN_TX_POWER (-100) /* minimum tx power */
415 #define HDD_MAX_TX_POWER (+100) /* maximum tx power */
416 
417 /* If IPA UC data path is enabled, target should reserve extra tx descriptors
418  * for IPA data path.
419  * Then host data path should allow less TX packet pumping in case
420  * IPA data path enabled
421  */
422 #define WLAN_TFC_IPAUC_TX_DESC_RESERVE   100
423 
424 /*
425  * NET_NAME_UNKNOWN is only introduced after Kernel 3.17, to have a macro
426  * here if the Kernel version is less than 3.17 to avoid the interleave
427  * conditional compilation.
428  */
429 #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) ||\
430 	defined(WITH_BACKPORTS))
431 #define NET_NAME_UNKNOWN	0
432 #endif
433 
434 #define PRE_CAC_SSID "pre_cac_ssid"
435 
436 #define SCAN_REJECT_THRESHOLD_TIME 300000 /* Time is in msec, equal to 5 mins */
437 #define SCAN_REJECT_THRESHOLD 15
438 
439 /* Default Psoc id */
440 #define DEFAULT_PSOC_ID 1
441 
442 /* wait time for nud stats in milliseconds */
443 #define WLAN_WAIT_TIME_NUD_STATS 800
444 /* nud stats skb max length */
445 #define WLAN_NUD_STATS_LEN 800
446 /* ARP packet type for NUD debug stats */
447 #define WLAN_NUD_STATS_ARP_PKT_TYPE 1
448 /* Assigned size of driver memory dump is 4096 bytes */
449 #define DRIVER_MEM_DUMP_SIZE    4096
450 
451 /* MAX OS Q block time value in msec
452  * Prevent from permanent stall, resume OS Q if timer expired
453  */
454 #define WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME 1000
455 #define WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME 100
456 #define WLAN_HDD_TX_FLOW_CONTROL_MAX_24BAND_CH   14
457 
458 #ifndef NUM_TX_RX_HISTOGRAM
459 #define NUM_TX_RX_HISTOGRAM 128
460 #endif
461 
462 #define NUM_TX_RX_HISTOGRAM_MASK (NUM_TX_RX_HISTOGRAM - 1)
463 
464 #define HDD_NOISE_FLOOR_DBM (-96)
465 
466 #define INTF_MACADDR_MASK       0x7
467 
468 /**
469  * typedef wlan_net_dev_ref_dbgid - Debug IDs to detect net device reference
470  *                                  leaks.
471  * NOTE: New values added to the enum must also be reflected in function
472  * net_dev_ref_debug_string_from_id()
473  */
474 typedef enum {
475 	NET_DEV_HOLD_ID_RESERVED = 0,
476 	NET_DEV_HOLD_GET_STA_CONNECTION_IN_PROGRESS = 1,
477 	NET_DEV_HOLD_CHECK_DFS_CHANNEL_FOR_ADAPTER = 2,
478 	NET_DEV_HOLD_GET_SAP_OPERATING_BAND = 3,
479 	NET_DEV_HOLD_RECOVERY_NOTIFIER_CALL = 4,
480 	NET_DEV_HOLD_IS_ANY_STA_CONNECTING = 5,
481 	NET_DEV_HOLD_SAP_DESTROY_CTX_ALL = 6,
482 	NET_DEV_HOLD_DRV_CMD_MAX_TX_POWER = 7,
483 	NET_DEV_HOLD_IPA_SET_TX_FLOW_INFO = 8,
484 	NET_DEV_HOLD_SET_RPS_CPU_MASK = 9,
485 	NET_DEV_HOLD_DFS_INDICATE_RADAR = 10,
486 	NET_DEV_HOLD_MAX_STA_INTERFACE_UP_COUNT_REACHED = 11,
487 	NET_DEV_HOLD_IS_CHAN_SWITCH_IN_PROGRESS = 12,
488 	NET_DEV_HOLD_STA_DESTROY_CTX_ALL = 13,
489 	NET_DEV_HOLD_CHECK_FOR_EXISTING_MACADDR = 14,
490 	NET_DEV_HOLD_DEINIT_ALL_ADAPTERS = 15,
491 	NET_DEV_HOLD_STOP_ALL_ADAPTERS = 16,
492 	NET_DEV_HOLD_RESET_ALL_ADAPTERS = 17,
493 	NET_DEV_HOLD_IS_ANY_INTERFACE_OPEN = 18,
494 	NET_DEV_HOLD_START_ALL_ADAPTERS = 19,
495 	NET_DEV_HOLD_GET_ADAPTER_BY_RAND_MACADDR = 20,
496 	NET_DEV_HOLD_GET_ADAPTER_BY_MACADDR = 21,
497 	NET_DEV_HOLD_GET_ADAPTER_BY_VDEV = 22,
498 	NET_DEV_HOLD_ADAPTER_GET_BY_REFERENCE = 23,
499 	NET_DEV_HOLD_GET_ADAPTER_BY_IFACE_NAME = 24,
500 	NET_DEV_HOLD_GET_ADAPTER = 25,
501 	NET_DEV_HOLD_GET_OPERATING_CHAN_FREQ = 26,
502 	NET_DEV_HOLD_UNREGISTER_WEXT_ALL_ADAPTERS = 27,
503 	NET_DEV_HOLD_ABORT_MAC_SCAN_ALL_ADAPTERS = 28,
504 	NET_DEV_HOLD_ABORT_SCHED_SCAN_ALL_ADAPTERS = 29,
505 	NET_DEV_HOLD_GET_FIRST_VALID_ADAPTER = 30,
506 	NET_DEV_HOLD_CLEAR_RPS_CPU_MASK = 31,
507 	NET_DEV_HOLD_BUS_BW_WORK_HANDLER = 32,
508 	NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY_COMPACT = 33,
509 	NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY = 34,
510 	NET_DEV_HOLD_CLEAR_NETIF_QUEUE_HISTORY = 35,
511 	NET_DEV_HOLD_UNSAFE_CHANNEL_RESTART_SAP = 36,
512 	NET_DEV_HOLD_INDICATE_MGMT_FRAME = 37,
513 	NET_DEV_HOLD_STATE_INFO_DUMP = 38,
514 	NET_DEV_HOLD_DISABLE_ROAMING = 39,
515 	NET_DEV_HOLD_ENABLE_ROAMING = 40,
516 	NET_DEV_HOLD_AUTO_SHUTDOWN_ENABLE = 41,
517 	NET_DEV_HOLD_GET_CON_SAP_ADAPTER = 42,
518 	NET_DEV_HOLD_IS_ANY_ADAPTER_CONNECTED = 43,
519 	NET_DEV_HOLD_IS_ROAMING_IN_PROGRESS = 44,
520 	NET_DEV_HOLD_DEL_P2P_INTERFACE = 45,
521 	NET_DEV_HOLD_IS_NDP_ALLOWED = 46,
522 	NET_DEV_HOLD_NDI_OPEN = 47,
523 	NET_DEV_HOLD_SEND_OEM_REG_RSP_NLINK_MSG = 48,
524 	NET_DEV_HOLD_PERIODIC_STA_STATS_DISPLAY = 49,
525 	NET_DEV_HOLD_SUSPEND_WLAN = 50,
526 	NET_DEV_HOLD_RESUME_WLAN = 51,
527 	NET_DEV_HOLD_SSR_RESTART_SAP = 52,
528 	NET_DEV_HOLD_SEND_DEFAULT_SCAN_IES = 53,
529 	NET_DEV_HOLD_CFG80211_SUSPEND_WLAN = 54,
530 	NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_STA = 55,
531 	NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_SAP = 56,
532 	NET_DEV_HOLD_CACHE_STATION_STATS_CB = 57,
533 	NET_DEV_HOLD_DISPLAY_TXRX_STATS = 58,
534 	NET_DEV_HOLD_BUS_BW_MGR = 59,
535 	NET_DEV_HOLD_START_PRE_CAC_TRANS = 60,
536 	NET_DEV_HOLD_IS_ANY_STA_CONNECTED = 61,
537 	NET_DEV_HOLD_GET_ADAPTER_BY_BSSID = 62,
538 	NET_DEV_HOLD_ALLOW_NEW_INTF = 63,
539 
540 	/* Keep it at the end */
541 	NET_DEV_HOLD_ID_MAX
542 } wlan_net_dev_ref_dbgid;
543 
544 struct hdd_tx_rx_stats {
545 	struct {
546 		/* start_xmit stats */
547 		__u32    tx_classified_ac[WLAN_MAX_AC];
548 		__u32    tx_dropped_ac[WLAN_MAX_AC];
549 #ifdef TX_MULTIQ_PER_AC
550 		/* Neither valid socket nor skb->hash */
551 		uint32_t inv_sk_and_skb_hash;
552 		/* skb->hash already calculated */
553 		uint32_t qselect_existing_skb_hash;
554 		/* valid tx queue id in socket */
555 		uint32_t qselect_sk_tx_map;
556 		/* skb->hash calculated in select queue */
557 		uint32_t qselect_skb_hash_calc;
558 #endif
559 	} per_cpu[NUM_CPUS];
560 
561 	/* txflow stats */
562 	bool     is_txflow_paused;
563 	__u32    txflow_pause_cnt;
564 	__u32    txflow_unpause_cnt;
565 	__u32    txflow_timer_cnt;
566 
567 };
568 
569 /**
570  * struct hdd_pmf_stats - Protected Management Frame statistics
571  * @num_unprot_deauth_rx: Number of unprotected deauth frames received
572  * @num_unprot_disassoc_rx: Number of unprotected disassoc frames received
573  */
574 struct hdd_pmf_stats {
575 	uint8_t num_unprot_deauth_rx;
576 	uint8_t num_unprot_disassoc_rx;
577 };
578 
579 /**
580  * struct hdd_peer_stats - Peer stats at HDD level
581  * @rx_count: RX count
582  * @rx_bytes: RX bytes
583  * @fcs_count: FCS err count
584  */
585 struct hdd_peer_stats {
586 	uint32_t rx_count;
587 	uint64_t rx_bytes;
588 	uint32_t fcs_count;
589 };
590 
591 #define HDD_MAX_PER_PEER_RATES 16
592 #if defined(WLAN_FEATURE_11BE_MLO)
593 /**
594  * struct wlan_hdd_station_stats_info - Station stats info
595  * @signal: Signal strength of last received PPDU
596  * @signal_avg: Average signal strength
597  * @chain_signal_avg: Per-chain signal strength average
598  * @rxrate: Last unicast data frame rx rate
599  * @txrate: Current unicasr tx rate
600  * @rx_bytes: Total received bytes (MPDU length)
601  * @tx_bytes: Total transmitted bytes (MPDU length)
602  * @rx_packets: Total received packets (MSDUs and MMPDUs)
603  * @tx_packets: Total transmitted packets (MSDUs and MMPDUs)
604  * @tx_retries: Cumulative retry count (MPDU)
605  * @tx_failed: Number of failed transmissions (MPDUs)
606  * @rx_mpdu_count: Number of MPDUs received from this station
607  * @fcs_err_count: Number of MPDUs received from this station with an FCS error
608  */
609 struct wlan_hdd_station_stats_info {
610 	int8_t signal;
611 	int8_t signal_avg;
612 	int8_t chain_signal_avg[IEEE80211_MAX_CHAINS];
613 	struct rate_info txrate;
614 	struct rate_info rxrate;
615 	uint64_t rx_bytes;
616 	uint64_t tx_bytes;
617 	uint32_t rx_packets;
618 	uint32_t tx_packets;
619 	uint32_t tx_retries;
620 	uint32_t tx_failed;
621 	uint32_t rx_mpdu_count;
622 	uint32_t fcs_err_count;
623 };
624 
625 /**
626  * struct wlan_hdd_mlo_iface_stats_info - mlo iface stats info
627  * @link_id: mlo link_id
628  * @freq: frequency of the mlo link
629  * @radio_id: radio id of the mlo link
630  */
631 struct wlan_hdd_mlo_iface_stats_info {
632 	uint8_t link_id;
633 	uint32_t freq;
634 	uint32_t radio_id;
635 };
636 
637 /**
638  * struct wlan_hdd_peer_info - hdd per peer info
639  * @type: peer type (AP, TDLS, GO etc.)
640  * @peer_mac: peer mac address
641  * @capabilities: peer WIFI_CAPABILITY_XXX
642  * @power_saving: peer power saving mode
643  * @num_rate: number of rates
644  * @rate_stats: per rate statistics, num entries = HDD_MAX_PER_PEER_RATES
645  * @stats_cached: whether peer stats cached into link_info struct
646  * @link_id: IEEE link id for the link
647  */
648 struct wlan_hdd_peer_info {
649 	enum wmi_peer_type type;
650 	struct qdf_mac_addr peer_mac;
651 	uint32_t capabilities;
652 	union {
653 		uint32_t power_saving;
654 		uint32_t num_rate;
655 	};
656 	struct wifi_rate_stat rate_stats[HDD_MAX_PER_PEER_RATES];
657 	bool stats_cached;
658 	uint32_t link_id;
659 };
660 #endif
661 
662 #define MAX_SUBTYPES_TRACKED	4
663 
664 struct hdd_stats {
665 	tCsrSummaryStatsInfo summary_stat;
666 	tCsrGlobalClassAStatsInfo class_a_stat;
667 	tCsrGlobalClassDStatsInfo class_d_stat;
668 	struct csr_per_chain_rssi_stats_info  per_chain_rssi_stats;
669 	struct hdd_tx_rx_stats tx_rx_stats;
670 	struct hdd_peer_stats peer_stats;
671 	struct hdd_pmf_stats hdd_pmf_stats;
672 	struct pmf_bcn_protect_stats bcn_protect_stats;
673 };
674 
675 /**
676  * struct hdd_roaming_info - HDD Internal Roaming Information
677  * @bssid: BSSID to which we are connected
678  * @peer_mac: Peer MAC address for IBSS connection
679  * @roam_id: Unique identifier for a roaming instance
680  * @roam_status: Current roam command status
681  */
682 struct hdd_roaming_info {
683 	tSirMacAddr bssid;
684 	tSirMacAddr peer_mac;
685 	uint32_t roam_id;
686 	eRoamCmdStatus roam_status;
687 };
688 
689 #ifdef FEATURE_WLAN_WAPI
690 /* Define WAPI macros for Length, BKID count etc*/
691 #define MAX_NUM_AKM_SUITES    16
692 
693 /** WAPI AUTH mode definition */
694 enum wapi_auth_mode {
695 	WAPI_AUTH_MODE_OPEN = 0,
696 	WAPI_AUTH_MODE_PSK = 1,
697 	WAPI_AUTH_MODE_CERT
698 } __packed;
699 
700 #define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
701 #define WPA_GET_BE24(a) ((u32) ((a[0] << 16) | (a[1] << 8) | a[2]))
702 #define WAPI_PSK_AKM_SUITE  0x02721400
703 #define WAPI_CERT_AKM_SUITE 0x01721400
704 
705 /**
706  * struct hdd_wapi_info - WAPI Information structure definition
707  * @wapi_mode: Is WAPI enabled on this adapter?
708  * @is_wapi_sta: Is the STA associated with WAPI?
709  * @wapi_auth_mode: WAPI authentication mode used by this adapter
710  */
711 struct hdd_wapi_info {
712 	bool wapi_mode;
713 	bool is_wapi_sta;
714 	enum wapi_auth_mode wapi_auth_mode;
715 };
716 #endif /* FEATURE_WLAN_WAPI */
717 
718 struct hdd_beacon_data {
719 	u8 *head;
720 	u8 *tail;
721 	u8 *proberesp_ies;
722 	u8 *assocresp_ies;
723 	int head_len;
724 	int tail_len;
725 	int proberesp_ies_len;
726 	int assocresp_ies_len;
727 	int dtim_period;
728 };
729 
730 /**
731  * struct hdd_mon_set_ch_info - Holds monitor mode channel switch params
732  * @freq: Channel frequency.
733  * @cb_mode: Channel bonding
734  * @channel_width: Channel width 0/1/2 for 20/40/80MHz respectively.
735  * @phy_mode: PHY mode
736  */
737 struct hdd_mon_set_ch_info {
738 	uint32_t freq;
739 	uint8_t cb_mode;
740 	uint32_t channel_width;
741 	eCsrPhyMode phy_mode;
742 };
743 
744 /**
745  * struct hdd_station_ctx -- STA-specific information
746  * @roam_profile: current roaming profile
747  * @conn_info: current connection information
748  * @cache_conn_info: prev connection info
749  * @reg_phymode: reg phymode
750  * @ch_info: monitor mode channel information
751  * @ap_supports_immediate_power_save: Does the current AP allow our STA
752  *    to immediately go into power save?
753  * @user_cfg_chn_width: max channel bandwidth set by user space
754  */
755 struct hdd_station_ctx {
756 	uint32_t reg_phymode;
757 	struct csr_roam_profile roam_profile;
758 	struct hdd_connection_info conn_info;
759 	struct hdd_connection_info cache_conn_info;
760 	struct hdd_mon_set_ch_info ch_info;
761 	bool ap_supports_immediate_power_save;
762 	uint8_t user_cfg_chn_width;
763 };
764 
765 /**
766  * enum bss_state - current state of the BSS
767  * @BSS_STOP: BSS is stopped
768  * @BSS_START: BSS is started
769  */
770 enum bss_state {
771 	BSS_STOP,
772 	BSS_START,
773 };
774 
775 /**
776  * struct hdd_hostapd_state - hostapd-related state information
777  * @bss_state: Current state of the BSS
778  * @qdf_event: Event to synchronize actions between hostapd thread and
779  *    internal callback threads
780  * @qdf_stop_bss_event: Event to synchronize Stop BSS. When Stop BSS
781  *    is issued userspace thread can wait on this event. The event will
782  *    be set when the Stop BSS processing in UMAC has completed.
783  * @qdf_sta_disassoc_event: Event to synchronize STA Disassociation.
784  *    When a STA is disassociated userspace thread can wait on this
785  *    event. The event will be set when the STA Disassociation
786  *    processing in UMAC has completed.
787  * @qdf_sta_eap_frm_done_event: Event to synchronize P2P GO disassoc
788  *    frame and EAP frame.
789  * @qdf_status: Used to communicate state from other threads to the
790  *    userspace thread.
791  */
792 struct hdd_hostapd_state {
793 	enum bss_state bss_state;
794 	qdf_event_t qdf_event;
795 	qdf_event_t qdf_stop_bss_event;
796 	qdf_event_t qdf_sta_disassoc_event;
797 	qdf_event_t qdf_sta_eap_frm_done_event;
798 	QDF_STATUS qdf_status;
799 };
800 
801 /**
802  * enum bss_stop_reason - reasons why a BSS is stopped.
803  * @BSS_STOP_REASON_INVALID: no reason specified explicitly.
804  * @BSS_STOP_DUE_TO_MCC_SCC_SWITCH: BSS stopped due to host
805  *  driver is trying to switch AP role to a different channel
806  *  to maintain SCC mode with the STA role on the same card.
807  *  this usually happens when STA is connected to an external
808  *  AP that runs on a different channel
809  * @BSS_STOP_DUE_TO_VENDOR_CONFIG_CHAN: BSS stopped due to
810  *  vendor subcmd set sap config channel
811  */
812 enum bss_stop_reason {
813 	BSS_STOP_REASON_INVALID = 0,
814 	BSS_STOP_DUE_TO_MCC_SCC_SWITCH = 1,
815 	BSS_STOP_DUE_TO_VENDOR_CONFIG_CHAN = 2,
816 };
817 
818 /**
819  * struct hdd_rate_info - rate_info in HDD
820  * @rate: tx/rx rate (kbps)
821  * @mode: 0->11abg legacy, 1->HT, 2->VHT (refer to sir_sme_phy_mode)
822  * @nss: number of streams
823  * @mcs: mcs index for HT/VHT mode
824  * @rate_flags: rate flags for last tx/rx
825  *
826  * rate info in HDD
827  */
828 struct hdd_rate_info {
829 	uint32_t rate;
830 	uint8_t mode;
831 	uint8_t nss;
832 	uint8_t mcs;
833 	enum tx_rate_info rate_flags;
834 };
835 
836 enum hdd_work_status {
837 	HDD_WORK_UNINITIALIZED,
838 	HDD_WORK_INITIALIZED,
839 };
840 
841 /**
842  * struct hdd_fw_txrx_stats - fw txrx status in HDD
843  *                            (refer to station_info struct in Kernel)
844  * @tx_packets: packets transmitted to this station
845  * @tx_bytes: bytes transmitted to this station
846  * @rx_packets: packets received from this station
847  * @rx_bytes: bytes received from this station
848  * @tx_retries: cumulative retry counts
849  * @tx_failed: the number of failed frames
850  * @tx_succeed: the number of succeed frames
851  * @rssi: The signal strength (dbm)
852  * @tx_rate: last used tx rate info
853  * @rx_rate: last used rx rate info
854  *
855  * fw txrx status in HDD
856  */
857 struct hdd_fw_txrx_stats {
858 	uint32_t tx_packets;
859 	uint64_t tx_bytes;
860 	uint32_t rx_packets;
861 	uint64_t rx_bytes;
862 	uint32_t tx_retries;
863 	uint32_t tx_failed;
864 	uint32_t tx_succeed;
865 	int8_t rssi;
866 	struct hdd_rate_info tx_rate;
867 	struct hdd_rate_info rx_rate;
868 };
869 
870 /**
871  * struct hdd_ap_ctx - SAP/P2PGO specific information
872  * @hostapd_state: state control information
873  * @dfs_cac_block_tx: Is data tramsmission blocked due to DFS CAC?
874  * @ap_active: Are any stations active?
875  * @disable_intrabss_fwd: Prevent forwarding between stations
876  * @broadcast_sta_id: Station ID assigned after BSS starts
877  * @privacy: The privacy bits of configuration
878  * @encryption_type: The encryption being used
879  * @group_key: Group Encryption Key
880  * @wep_key: WEP key array
881  * @wep_def_key_idx: WEP default key index
882  * @sap_context: Pointer to context maintained by SAP (opaque to HDD)
883  * @sap_config: SAP configuration
884  * @operating_chan_freq: channel upon which the SAP is operating
885  * @beacon: Beacon information
886  * @vendor_acs_timer: Timer for ACS
887  * @vendor_acs_timer_initialized: Is @vendor_acs_timer initialized?
888  * @bss_stop_reason: Reason why the BSS was stopped
889  * @acs_in_progress: In progress acs flag for an adapter
890  * @ch_switch_in_progress: channel change in progress or not
891  * @client_count: client count per dot11_mode
892  * @country_ie_updated: country ie is updated or not by hdd hostapd
893  * @during_auth_offload: auth mgmt frame is offloading to hostapd
894  * @reg_punc_bitmap: puncturing bitmap
895  */
896 struct hdd_ap_ctx {
897 	struct hdd_hostapd_state hostapd_state;
898 	bool dfs_cac_block_tx;
899 	bool ap_active;
900 	bool disable_intrabss_fwd;
901 	uint8_t broadcast_sta_id;
902 	uint8_t privacy;
903 	eCsrEncryptionType encryption_type;
904 	uint8_t wep_def_key_idx;
905 	struct sap_context *sap_context;
906 	struct sap_config sap_config;
907 	uint32_t operating_chan_freq;
908 	struct hdd_beacon_data *beacon;
909 	qdf_mc_timer_t vendor_acs_timer;
910 	bool vendor_acs_timer_initialized;
911 	enum bss_stop_reason bss_stop_reason;
912 	qdf_atomic_t acs_in_progress;
913 	qdf_atomic_t ch_switch_in_progress;
914 	uint16_t client_count[QCA_WLAN_802_11_MODE_INVALID];
915 	bool country_ie_updated;
916 	bool during_auth_offload;
917 #ifdef WLAN_FEATURE_11BE
918 	uint16_t reg_punc_bitmap;
919 #endif
920 };
921 
922 /**
923  * struct hdd_scan_info - Per-adapter scan information
924  * @scan_add_ie: Additional IE for scan
925  * @default_scan_ies: Default scan IEs
926  * @default_scan_ies_len: Length of @default_scan_ies
927  * @scan_mode: Scan mode
928  */
929 struct hdd_scan_info {
930 	tSirAddie scan_add_ie;
931 	uint8_t *default_scan_ies;
932 	uint16_t default_scan_ies_len;
933 	tSirScanType scan_mode;
934 };
935 
936 #define WLAN_HDD_MAX_MC_ADDR_LIST CFG_TGT_MAX_MULTICAST_FILTER_ENTRIES
937 
938 struct hdd_multicast_addr_list {
939 	uint8_t mc_cnt;
940 	uint8_t addr[WLAN_HDD_MAX_MC_ADDR_LIST][ETH_ALEN];
941 };
942 
943 #define WLAN_HDD_MAX_HISTORY_ENTRY 25
944 
945 /**
946  * struct hdd_netif_queue_stats - netif queue operation statistics
947  * @pause_count: pause counter
948  * @unpause_count: unpause counter
949  * @total_pause_time: amount of time in paused state
950  */
951 struct hdd_netif_queue_stats {
952 	u32 pause_count;
953 	u32 unpause_count;
954 	qdf_time_t total_pause_time;
955 };
956 
957 /**
958  * struct hdd_netif_queue_history - netif queue operation history
959  * @time: timestamp
960  * @netif_action: action type
961  * @netif_reason: reason type
962  * @pause_map: pause map
963  * @tx_q_state: state of the netdev TX queues
964  */
965 struct hdd_netif_queue_history {
966 	qdf_time_t time;
967 	uint16_t netif_action;
968 	uint16_t netif_reason;
969 	uint32_t pause_map;
970 	unsigned long tx_q_state[NUM_TX_QUEUES];
971 };
972 
973 /**
974  * struct hdd_chan_change_params - channel related information
975  * @chan_freq: operating channel frequency
976  * @chan_params: channel parameters
977  */
978 struct hdd_chan_change_params {
979 	uint32_t chan_freq;
980 	struct ch_params chan_params;
981 };
982 
983 /**
984  * struct hdd_runtime_pm_context - context to prevent/allow runtime pm
985  * @dfs: dfs context to prevent/allow runtime pm
986  * @connect: connect context to prevent/allow runtime pm
987  * @user: user context to prevent/allow runtime pm
988  * @is_user_wakelock_acquired: boolean to check if user wakelock status
989  * @monitor_mode: monitor mode context to prevent/allow runtime pm
990  * @wow_unit_test: wow unit test mode context to prevent/allow runtime pm
991  * @system_suspend: system suspend context to prevent/allow runtime pm
992  * @dyn_mac_addr_update: update mac addr context to prevent/allow runtime pm
993  * @vdev_destroy: vdev destroy context to prevent/allow runtime pm
994  * @oem_data_cmd: OEM data context to prevent/allow runtime pm
995  *
996  * Runtime PM control for underlying activities
997  */
998 struct hdd_runtime_pm_context {
999 	qdf_runtime_lock_t dfs;
1000 	qdf_runtime_lock_t connect;
1001 	qdf_runtime_lock_t user;
1002 	bool is_user_wakelock_acquired;
1003 	qdf_runtime_lock_t monitor_mode;
1004 	qdf_runtime_lock_t wow_unit_test;
1005 	qdf_runtime_lock_t system_suspend;
1006 	qdf_runtime_lock_t dyn_mac_addr_update;
1007 	qdf_runtime_lock_t vdev_destroy;
1008 	qdf_runtime_lock_t oem_data_cmd;
1009 };
1010 
1011 /*
1012  * WLAN_HDD_ADAPTER_MAGIC is a magic number used to identify net devices
1013  * belonging to this driver from net devices belonging to other devices.
1014  * Therefore, the magic number must be unique relative to the numbers for
1015  * other drivers in the system. If WLAN_HDD_ADAPTER_MAGIC is already defined
1016  * (e.g. by compiler argument), then use that. If it's not already defined,
1017  * then use the first 4 characters of MULTI_IF_NAME to construct the magic
1018  * number. If MULTI_IF_NAME is not defined, then use a default magic number.
1019  */
1020 #ifndef WLAN_HDD_ADAPTER_MAGIC
1021 #ifdef MULTI_IF_NAME
1022 #define WLAN_HDD_ADAPTER_MAGIC                                          \
1023 	(MULTI_IF_NAME[0] == 0 ? 0x574c414e :                           \
1024 	(MULTI_IF_NAME[1] == 0 ? (MULTI_IF_NAME[0] << 24) :             \
1025 	(MULTI_IF_NAME[2] == 0 ? (MULTI_IF_NAME[0] << 24) |             \
1026 		(MULTI_IF_NAME[1] << 16) :                              \
1027 	(MULTI_IF_NAME[0] << 24) | (MULTI_IF_NAME[1] << 16) |           \
1028 	(MULTI_IF_NAME[2] << 8) | MULTI_IF_NAME[3])))
1029 #else
1030 #define WLAN_HDD_ADAPTER_MAGIC 0x574c414e       /* ASCII "WLAN" */
1031 #endif
1032 #endif
1033 
1034 /**
1035  * struct rcpi_info - rcpi info
1036  * @rcpi: computed value in dB
1037  * @mac_addr: peer mac addr for which rcpi is computed
1038  */
1039 struct rcpi_info {
1040 	int32_t rcpi;
1041 	struct qdf_mac_addr mac_addr;
1042 };
1043 
1044 struct hdd_context;
1045 
1046 #ifdef MULTI_CLIENT_LL_SUPPORT
1047 /* Max host clients which can request the FW arbiter with the latency level */
1048 #define WLM_MAX_HOST_CLIENT 5
1049 
1050 /**
1051  * struct wlm_multi_client_info_table - To store multi client id information
1052  * @client_id: host id for a client
1053  * @port_id: client id coming from upper layer
1054  * @in_use: set true for a client when host receives vendor cmd for that client
1055  */
1056 struct wlm_multi_client_info_table {
1057 	uint32_t client_id;
1058 	uint32_t port_id;
1059 	bool in_use;
1060 };
1061 #endif
1062 
1063 /**
1064  * enum udp_qos_upgrade - Enumeration of the various User priority (UP) types
1065  *			  UDP QoS upgrade request
1066  * @UDP_QOS_UPGRADE_NONE: Do not upgrade UDP QoS AC
1067  * @UDP_QOS_UPGRADE_BK_BE: Upgrade UDP QoS for BK/BE only
1068  * @UDP_QOS_UPGRADE_ALL: Upgrade UDP QoS for all packets
1069  * @UDP_QOS_UPGRADE_MAX: Max enum limit, not to add new beyond this
1070  */
1071 enum udp_qos_upgrade {
1072 	UDP_QOS_UPGRADE_NONE,
1073 	UDP_QOS_UPGRADE_BK_BE,
1074 	UDP_QOS_UPGRADE_ALL,
1075 	UDP_QOS_UPGRADE_MAX
1076 };
1077 
1078 #define WLAN_HDD_DEFLINK_IDX	0
1079 
1080 /**
1081  * struct wlan_hdd_link_info - Data structure to store the link specific info
1082  * @adapter: Reverse pointer to HDD adapter
1083  * @vdev_id: Unique value to identify VDEV. Equal to WLAN_UMAC_VDEV_ID_MAX
1084  *           for invalid VDEVs.
1085  * @vdev_lock: Lock to protect VDEV pointer access.
1086  * @vdev: Pointer to VDEV objmgr.
1087  * @vdev_destroy_event: vdev_destroy_event is moved from the qdf_event
1088  *                      to linux event consciously, Lets take example
1089  *                      when sap interface is waiting on the
1090  *                      session_close event and then there is a SSR
1091  *                      the wait event is completed the interface down
1092  *                      is returned and the next command to the driver
1093  *                      will be hdd_hostapd_uinit-->
1094  *                      hdd_deinit_ap_mode-->
1095  *                      hdd_hostapd_deinit_sap_session where in the
1096  *                      sap_ctx would be freed.  During the SSR if the
1097  *                      same sap context is used it would result in
1098  *                      null pointer de-reference.
1099  * @link_addr: Link MAC address
1100  * @session: union of @ap and @station specific structs
1101  * @session.station: station mode information
1102  * @session.ap: ap mode specific information
1103  * @acs_complete_event: acs complete event
1104  * @rssi: The signal strength (dBm)
1105  * @snr: SNR measured from @rssi
1106  * @rssi_on_disconnect: Rssi at disconnection time in STA mode
1107  * @rssi_send: Notify RSSI over lpass
1108  * @is_mlo_vdev_active: is the mlo vdev currently active
1109  * @estimated_linkspeed: estimated link speed
1110  * @hdd_stats: HDD statistics
1111  * @big_data_stats: Big data stats
1112  * @ll_iface_stats: Link Layer interface stats
1113  * @hdd_sinfo: hdd vdev station stats that will be sent to userspace
1114  * @mlo_peer_info: mlo peer stats info
1115  * @mscs_prev_tx_vo_pkts: count of prev VO AC packets transmitted
1116  * @mscs_counter: Counter on MSCS action frames sent
1117  * @link_flags: a bitmap of hdd_link_flags
1118  * @chan_change_notify_work: Channel change notify work
1119  */
1120 struct wlan_hdd_link_info {
1121 	struct hdd_adapter *adapter;
1122 	uint8_t vdev_id;
1123 	qdf_spinlock_t vdev_lock;
1124 	struct wlan_objmgr_vdev *vdev;
1125 	struct completion vdev_destroy_event;
1126 	struct qdf_mac_addr link_addr;
1127 
1128 	union {
1129 		struct hdd_station_ctx station;
1130 		struct hdd_ap_ctx ap;
1131 	} session;
1132 
1133 	qdf_event_t acs_complete_event;
1134 
1135 	int8_t rssi;
1136 	uint8_t snr;
1137 	int32_t rssi_on_disconnect;
1138 #ifdef WLAN_FEATURE_LPSS
1139 	bool rssi_send;
1140 #endif
1141 	bool is_mlo_vdev_active;
1142 	uint32_t estimated_linkspeed;
1143 	struct hdd_stats hdd_stats;
1144 #ifdef WLAN_FEATURE_BIG_DATA_STATS
1145 	struct big_data_stats_event big_data_stats;
1146 #endif
1147 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC)
1148 	struct wifi_interface_stats ll_iface_stats;
1149 	struct wlan_hdd_station_stats_info hdd_sinfo;
1150 	struct wlan_hdd_peer_info mlo_peer_info;
1151 #endif
1152 
1153 #ifdef WLAN_FEATURE_MSCS
1154 	unsigned long mscs_prev_tx_vo_pkts;
1155 	uint32_t mscs_counter;
1156 #endif /* WLAN_FEATURE_MSCS */
1157 
1158 	unsigned long link_flags;
1159 	qdf_work_t chan_change_notify_work;
1160 };
1161 
1162 /**
1163  * struct wlan_hdd_tx_power - Structure to store connection tx power info
1164  * @tx_pwr: connection tx power sent by firmware
1165  * @tx_pwr_cached_timestamp: timestamp when tx_pwr is cached into adapter
1166  */
1167 struct wlan_hdd_tx_power {
1168 	int tx_pwr;
1169 	uint32_t tx_pwr_cached_timestamp;
1170 };
1171 
1172 /**
1173  * struct hdd_adapter - hdd vdev/net_device context
1174  * @magic: Magic cookie for adapter sanity verification.  Note that this
1175  *         needs to be at the beginning of the private data structure so
1176  *         that it will exist at the beginning of dev->priv and hence
1177  *         will always be in mapped memory
1178  * @node: list node for membership in the adapter list
1179  * @hdd_ctx:
1180  * @dev: Handle to the network device
1181  * @device_mode:
1182  * @ipv4_notifier_work: IPv4 notifier callback for handling ARP offload on
1183  *                      change in IP
1184  * @ipv6_notifier_work: IPv6 notifier callback for handling NS offload on
1185  *                      change in IP
1186  * @wdev: TODO Move this to sta Ctx
1187  * @ops: ops checks if Opportunistic Power Save is Enable or Not
1188  * @ctw: stores CT Window value once we receive Opps command from
1189  *       wpa_supplicant then using CT Window value we need to Enable
1190  *       Opportunistic Power Save
1191  * @allow_power_save: STA/CLI powersave enable/disable from userspace
1192  * @mac_addr: Current MAC Address for the adapter
1193  * @mld_addr: MLD address for adapter
1194  * @event_flags: a bitmap of hdd_adapter_flags
1195  * @curr_link_info_map: Current mapping of link info in adapter array
1196  * @active_links: a bitmap of active links in @link_info array
1197  * @num_links_on_create: No of active links set on initial hdd_open_adapter().
1198  * @is_ll_stats_req_pending: atomic variable to check active stats req
1199  * @sta_stats_cached_timestamp: last updated stats timestamp
1200  * @qdf_monitor_mode_vdev_up_event: QDF event for monitor mode vdev up
1201  * @disconnect_comp_var: completion variable for disconnect callback
1202  * @linkup_event_var: completion variable for Linkup Event
1203  * @is_link_up_service_needed: Track whether the linkup handling is needed
1204  * @hdd_wmm_status: WMM Status
1205  * @sta_info:
1206  * @cache_sta_info:
1207  * @sta_info_list:
1208  * @cache_sta_info_list:
1209  * @cache_sta_count: number of currently cached stations
1210  * @wapi_info:
1211  * @sap_stop_bss_work:
1212  * @tsf: structure containing tsf related information
1213  * @mc_addr_list: multicast address list
1214  * @mc_list_lock: spin lock for multicast list
1215  * @addr_filter_pattern:
1216  * @scan_info:
1217  * @psb_changed: Flag to ensure PSB is configured through framework
1218  * @configured_psb: UAPSD psb value configured through framework
1219  * @scan_block_work:
1220  * @blocked_scan_request_q:
1221  * @blocked_scan_request_q_lock:
1222  * @tx_flow_control_timer:
1223  * @tx_flow_timer_initialized:
1224  * @tx_flow_low_watermark:
1225  * @tx_flow_hi_watermark_offset:
1226  * @dscp_to_up_map: DSCP to UP QoS Mapping
1227  * @is_link_layer_stats_set:
1228  * @ll_stats_failure_count:
1229  * @link_status:
1230  * @upgrade_udp_qos_threshold: The threshold for user priority upgrade for
1231  *			       any UDP packet.
1232  * @udp_qos_upgrade_type: UDP QoS packet upgrade request type
1233  * @temperature: variable for temperature in Celsius
1234  * @ocb_mac_address: MAC addresses used for OCB interfaces
1235  * @ocb_mac_addr_count:
1236  * @pause_map: BITMAP indicating pause reason
1237  * @subqueue_pause_map:
1238  * @pause_map_lock:
1239  * @start_time:
1240  * @last_time:
1241  * @total_pause_time:
1242  * @total_unpause_time:
1243  * @history_index:
1244  * @queue_oper_history:
1245  * @queue_oper_stats:
1246  * @debugfs_phy: debugfs entry
1247  * @lfr_fw_status:
1248  * @active_ac:
1249  * @mon_chan_freq:
1250  * @mon_bandwidth:
1251  * @latency_level: 0 - normal, 1 - xr, 2 - low, 3 - ultralow
1252  * @multi_client_ll_support: to check multi client ll support in driver
1253  * @client_info: To store multi client id information
1254  * @multi_ll_response_cookie: cookie for multi client ll command
1255  * @multi_ll_req_in_progress: to check multi client ll request in progress
1256  * @multi_ll_resp_expected: to decide whether host will wait for multi client
1257  *                          event or not
1258  * @monitor_mode_vdev_up_in_progress:
1259  * @rcpi: rcpi information
1260  * @send_mode_change:
1261  * @apf_context:
1262  * @csr_file:
1263  * @motion_detection_mode:
1264  * @motion_det_cfg:
1265  * @motion_det_in_progress:
1266  * @motion_det_baseline_value:
1267  * @last_disconnect_reason: Last disconnected internal reason code
1268  * as per enum qca_disconnect_reason_codes
1269  * @connect_req_status: Last disconnected internal status code
1270  *                          as per enum qca_sta_connect_fail_reason_codes
1271  * @peer_cleanup_done:
1272  * @oem_data_in_progress:
1273  * @cookie:
1274  * @response_expected:
1275  * @handle_feature_update: Handle feature update only if it is triggered
1276  *			   by hdd_netdev_feature_update
1277  * @tso_csum_feature_enabled: Indicate if TSO and checksum offload features
1278  *                            are enabled or not
1279  * @netdev_features_update_work: work for handling the netdev features update
1280  * for the adapter.
1281  * @netdev_features_update_work_status: status for netdev_features_update_work
1282  * @net_dev_hold_ref_count:
1283  * @delete_in_progress: Flag to indicate that the adapter delete is in
1284  * progress, and any operation using rtnl lock inside
1285  * the driver can be avoided/skipped.
1286  * @is_virtual_iface: Indicates that netdev is called from virtual interface
1287  * @mon_adapter: hdd_adapter of monitor mode.
1288  * @mlo_adapter_info:
1289  * @set_mac_addr_req_ctx: Set MAC address command request context
1290  * @delta_qtime: delta between host qtime and monotonic time
1291  * @traffic_end_ind_en: traffic end indication feature enable/disable
1292  * @is_dbam_configured:
1293  * @user_phy_mode: phy mode is set per vdev
1294  * @deflink: Default link pointing to the 0th index of the linkinfo array
1295  * @link_info: Data structure to hold link specific information
1296  * @tx_power: Structure to hold connection tx Power info
1297  * @tx_latency_cfg: configuration for per-link transmit latency statistics
1298  * @link_state_cached_timestamp: link state cached timestamp
1299  * @keep_alive_interval: user configured STA keep alive interval
1300  */
1301 struct hdd_adapter {
1302 	uint32_t magic;
1303 	qdf_list_node_t node;
1304 
1305 	struct hdd_context *hdd_ctx;
1306 
1307 	struct net_device *dev;
1308 
1309 	enum QDF_OPMODE device_mode;
1310 
1311 	struct work_struct ipv4_notifier_work;
1312 #ifdef WLAN_NS_OFFLOAD
1313 	/* IPv6 notifier callback for handling NS offload on change in IP */
1314 	struct work_struct ipv6_notifier_work;
1315 #endif
1316 
1317 	/* TODO Move this to sta Ctx */
1318 	struct wireless_dev wdev;
1319 
1320 	uint8_t ops;
1321 	uint32_t ctw;
1322 	bool allow_power_save;
1323 
1324 	struct qdf_mac_addr mac_addr;
1325 #ifndef WLAN_HDD_MULTI_VDEV_SINGLE_NDEV
1326 	struct qdf_mac_addr mld_addr;
1327 #endif
1328 	unsigned long event_flags;
1329 	uint8_t curr_link_info_map[WLAN_MAX_ML_BSS_LINKS];
1330 	unsigned long active_links;
1331 	uint8_t num_links_on_create;
1332 
1333 	qdf_atomic_t is_ll_stats_req_pending;
1334 
1335 #ifdef FEATURE_CLUB_LL_STATS_AND_GET_STATION
1336 	uint32_t sta_stats_cached_timestamp;
1337 #endif
1338 
1339 #ifdef FEATURE_MONITOR_MODE_SUPPORT
1340 	qdf_event_t qdf_monitor_mode_vdev_up_event;
1341 #endif
1342 
1343 	/* TODO: move these to sta ctx. These may not be used in AP */
1344 	struct completion disconnect_comp_var;
1345 	struct completion linkup_event_var;
1346 
1347 	bool is_link_up_service_needed;
1348 
1349 	struct hdd_wmm_status hdd_wmm_status;
1350 
1351 	/* TODO: Will be removed as a part of next phase of clean up */
1352 	struct hdd_station_info sta_info[WLAN_MAX_STA_COUNT];
1353 	struct hdd_station_info cache_sta_info[WLAN_MAX_STA_COUNT];
1354 
1355 	/* TODO: _list from name will be removed after clean up */
1356 	struct hdd_sta_info_obj sta_info_list;
1357 	struct hdd_sta_info_obj cache_sta_info_list;
1358 	qdf_atomic_t cache_sta_count;
1359 
1360 #ifdef FEATURE_WLAN_WAPI
1361 	struct hdd_wapi_info wapi_info;
1362 #endif
1363 
1364 	struct work_struct  sap_stop_bss_work;
1365 
1366 #ifdef WLAN_FEATURE_TSF
1367 	struct hdd_vdev_tsf tsf;
1368 #endif
1369 	struct hdd_multicast_addr_list mc_addr_list;
1370 	qdf_spinlock_t mc_list_lock;
1371 	uint8_t addr_filter_pattern;
1372 
1373 	struct hdd_scan_info scan_info;
1374 
1375 	uint8_t psb_changed;
1376 	uint8_t configured_psb;
1377 
1378 	struct work_struct scan_block_work;
1379 	qdf_list_t blocked_scan_request_q;
1380 	qdf_mutex_t blocked_scan_request_q_lock;
1381 
1382 #if  defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || \
1383 				defined(QCA_HL_NETDEV_FLOW_CONTROL)
1384 	qdf_mc_timer_t tx_flow_control_timer;
1385 	bool tx_flow_timer_initialized;
1386 #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL || QCA_HL_NETDEV_FLOW_CONTROL */
1387 #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1388 	unsigned int tx_flow_low_watermark;
1389 	unsigned int tx_flow_hi_watermark_offset;
1390 #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
1391 
1392 	enum sme_qos_wmmuptype dscp_to_up_map[WLAN_MAX_DSCP + 1];
1393 
1394 #ifdef WLAN_FEATURE_LINK_LAYER_STATS
1395 	bool is_link_layer_stats_set;
1396 	uint8_t ll_stats_failure_count;
1397 #endif
1398 	uint8_t link_status;
1399 	uint8_t upgrade_udp_qos_threshold;
1400 	enum udp_qos_upgrade udp_qos_upgrade_type;
1401 
1402 	int temperature;
1403 
1404 #ifdef WLAN_FEATURE_DSRC
1405 	struct qdf_mac_addr ocb_mac_address[QDF_MAX_CONCURRENCY_PERSONA];
1406 	int ocb_mac_addr_count;
1407 #endif
1408 
1409 	uint32_t pause_map;
1410 	uint32_t subqueue_pause_map;
1411 	spinlock_t pause_map_lock;
1412 	qdf_time_t start_time;
1413 	qdf_time_t last_time;
1414 	qdf_time_t total_pause_time;
1415 	qdf_time_t total_unpause_time;
1416 	uint8_t history_index;
1417 	struct hdd_netif_queue_history
1418 		 queue_oper_history[WLAN_HDD_MAX_HISTORY_ENTRY];
1419 	struct hdd_netif_queue_stats queue_oper_stats[WLAN_REASON_TYPE_MAX];
1420 
1421 	struct dentry *debugfs_phy;
1422 	struct lfr_firmware_status lfr_fw_status;
1423 	uint8_t active_ac;
1424 	uint32_t mon_chan_freq;
1425 	uint32_t mon_bandwidth;
1426 	uint16_t latency_level;
1427 #ifdef MULTI_CLIENT_LL_SUPPORT
1428 	bool multi_client_ll_support;
1429 	struct wlm_multi_client_info_table client_info[WLM_MAX_HOST_CLIENT];
1430 	void *multi_ll_response_cookie;
1431 	bool multi_ll_req_in_progress;
1432 	bool multi_ll_resp_expected;
1433 #endif
1434 #ifdef FEATURE_MONITOR_MODE_SUPPORT
1435 	bool monitor_mode_vdev_up_in_progress;
1436 #endif
1437 
1438 	struct rcpi_info rcpi;
1439 	bool send_mode_change;
1440 #ifdef FEATURE_WLAN_APF
1441 	struct hdd_apf_context apf_context;
1442 #endif /* FEATURE_WLAN_APF */
1443 
1444 #ifdef WLAN_DEBUGFS
1445 	struct hdd_debugfs_file_info csr_file[HDD_DEBUGFS_FILE_ID_MAX];
1446 #endif /* WLAN_DEBUGFS */
1447 
1448 #ifdef WLAN_FEATURE_MOTION_DETECTION
1449 	bool motion_detection_mode;
1450 	bool motion_det_cfg;
1451 	bool motion_det_in_progress;
1452 	uint32_t motion_det_baseline_value;
1453 #endif /* WLAN_FEATURE_MOTION_DETECTION */
1454 	enum qca_disconnect_reason_codes last_disconnect_reason;
1455 	enum wlan_status_code connect_req_status;
1456 	qdf_event_t peer_cleanup_done;
1457 #ifdef FEATURE_OEM_DATA
1458 	bool oem_data_in_progress;
1459 	void *cookie;
1460 	bool response_expected;
1461 #endif
1462 	bool handle_feature_update;
1463 
1464 	bool tso_csum_feature_enabled;
1465 
1466 	qdf_work_t netdev_features_update_work;
1467 	enum hdd_work_status netdev_features_update_work_status;
1468 	qdf_atomic_t net_dev_hold_ref_count[NET_DEV_HOLD_ID_MAX];
1469 	bool delete_in_progress;
1470 	bool is_virtual_iface;
1471 #ifdef WLAN_FEATURE_PKT_CAPTURE
1472 	struct hdd_adapter *mon_adapter;
1473 #endif
1474 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC)
1475 	struct hdd_mlo_adapter_info mlo_adapter_info;
1476 #endif
1477 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
1478 	void *set_mac_addr_req_ctx;
1479 #endif
1480 	int64_t delta_qtime;
1481 #ifdef DP_TRAFFIC_END_INDICATION
1482 	bool traffic_end_ind_en;
1483 #endif
1484 #ifdef WLAN_FEATURE_DBAM_CONFIG
1485 	bool is_dbam_configured;
1486 #endif
1487 	enum qca_wlan_vendor_phy_mode user_phy_mode;
1488 	struct wlan_hdd_link_info *deflink;
1489 	struct wlan_hdd_link_info link_info[WLAN_MAX_ML_BSS_LINKS];
1490 	struct wlan_hdd_tx_power tx_power;
1491 #ifdef WLAN_FEATURE_TX_LATENCY_STATS
1492 	struct cdp_tx_latency_config tx_latency_cfg;
1493 #endif
1494 #ifdef WLAN_FEATURE_11BE_MLO
1495 	qdf_time_t link_state_cached_timestamp;
1496 #endif
1497 	uint16_t keep_alive_interval;
1498 };
1499 
1500 #define WLAN_HDD_GET_STATION_CTX_PTR(link_info) (&(link_info)->session.station)
1501 #define WLAN_HDD_GET_AP_CTX_PTR(link_info) (&(link_info)->session.ap)
1502 #define WLAN_HDD_GET_CTX(adapter) ((adapter)->hdd_ctx)
1503 #define WLAN_HDD_GET_HOSTAP_STATE_PTR(link_info) \
1504 		(&(WLAN_HDD_GET_AP_CTX_PTR((link_info))->hostapd_state))
1505 #define WLAN_HDD_GET_SAP_CTX_PTR(link_info) \
1506 		(WLAN_HDD_GET_AP_CTX_PTR((link_info))->sap_context)
1507 
1508 #ifdef WLAN_FEATURE_NAN
1509 #define WLAN_HDD_IS_NDP_ENABLED(hdd_ctx) ((hdd_ctx)->nan_datapath_enabled)
1510 #else
1511 /* WLAN_HDD_GET_NDP_CTX_PTR and WLAN_HDD_GET_NDP_WEXT_STATE_PTR are not defined
1512  * intentionally so that all references to these must be within NDP code.
1513  * non-NDP code can call WLAN_HDD_IS_NDP_ENABLED(), and when it is enabled,
1514  * invoke NDP code to do all work.
1515  */
1516 #define WLAN_HDD_IS_NDP_ENABLED(hdd_ctx) (false)
1517 #endif
1518 
1519 /* Set mac address locally administered bit */
1520 #define WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macaddr) (macaddr[0] &= 0xFD)
1521 
1522 #define HDD_DEFAULT_MCC_P2P_QUOTA    70
1523 #define HDD_RESET_MCC_P2P_QUOTA      50
1524 
1525 /*
1526  * struct hdd_priv_data - driver ioctl private data payload
1527  * @buf: pointer to command buffer (may be in userspace)
1528  * @used_len: length of the command/data currently in @buf
1529  * @total_len: total length of the @buf memory allocation
1530  */
1531 struct hdd_priv_data {
1532 	uint8_t *buf;
1533 	int used_len;
1534 	int total_len;
1535 };
1536 
1537 #define  MAX_MOD_LOGLEVEL 10
1538 struct fw_log_info {
1539 	uint8_t enable;
1540 	uint8_t dl_type;
1541 	uint8_t dl_report;
1542 	uint8_t dl_loglevel;
1543 	uint8_t index;
1544 	uint32_t dl_mod_loglevel[MAX_MOD_LOGLEVEL];
1545 
1546 };
1547 
1548 /**
1549  * enum antenna_mode - number of TX/RX chains
1550  * @HDD_ANTENNA_MODE_INVALID: Invalid mode place holder
1551  * @HDD_ANTENNA_MODE_1X1: Number of TX/RX chains equals 1
1552  * @HDD_ANTENNA_MODE_2X2: Number of TX/RX chains equals 2
1553  * @HDD_ANTENNA_MODE_MAX: Place holder for max mode
1554  */
1555 enum antenna_mode {
1556 	HDD_ANTENNA_MODE_INVALID,
1557 	HDD_ANTENNA_MODE_1X1,
1558 	HDD_ANTENNA_MODE_2X2,
1559 	HDD_ANTENNA_MODE_MAX
1560 };
1561 
1562 /**
1563  * enum smps_mode - SM power save mode
1564  * @HDD_SMPS_MODE_STATIC: Static power save
1565  * @HDD_SMPS_MODE_DYNAMIC: Dynamic power save
1566  * @HDD_SMPS_MODE_RESERVED: Reserved
1567  * @HDD_SMPS_MODE_DISABLED: Disable power save
1568  * @HDD_SMPS_MODE_MAX: Place holder for max mode
1569  */
1570 enum smps_mode {
1571 	HDD_SMPS_MODE_STATIC,
1572 	HDD_SMPS_MODE_DYNAMIC,
1573 	HDD_SMPS_MODE_RESERVED,
1574 	HDD_SMPS_MODE_DISABLED,
1575 	HDD_SMPS_MODE_MAX
1576 };
1577 
1578 #ifdef WLAN_FEATURE_OFFLOAD_PACKETS
1579 /**
1580  * struct hdd_offloaded_packets - request id to pattern id mapping
1581  * @request_id: request id
1582  * @pattern_id: pattern id
1583  *
1584  */
1585 struct hdd_offloaded_packets {
1586 	uint32_t request_id;
1587 	uint8_t  pattern_id;
1588 };
1589 
1590 /**
1591  * struct hdd_offloaded_packets_ctx - offloaded packets context
1592  * @op_table: request id to pattern id table
1593  * @op_lock: mutex lock
1594  */
1595 struct hdd_offloaded_packets_ctx {
1596 	struct hdd_offloaded_packets op_table[MAXNUM_PERIODIC_TX_PTRNS];
1597 	struct mutex op_lock;
1598 };
1599 #endif
1600 
1601 /**
1602  * enum driver_modules_status - Driver Modules status
1603  * @DRIVER_MODULES_UNINITIALIZED: Driver CDS modules uninitialized
1604  * @DRIVER_MODULES_ENABLED: Driver CDS modules opened
1605  * @DRIVER_MODULES_CLOSED: Driver CDS modules closed
1606  */
1607 enum driver_modules_status {
1608 	DRIVER_MODULES_UNINITIALIZED,
1609 	DRIVER_MODULES_ENABLED,
1610 	DRIVER_MODULES_CLOSED
1611 };
1612 
1613 /**
1614  * struct acs_dfs_policy - Define ACS policies
1615  * @acs_dfs_mode: Dfs mode enabled/disabled.
1616  * @acs_chan_freq: pre defined channel frequency to avoid ACS.
1617  */
1618 struct acs_dfs_policy {
1619 	enum dfs_mode acs_dfs_mode;
1620 	uint32_t acs_chan_freq;
1621 };
1622 
1623 /**
1624  * enum suspend_fail_reason - Reasons a WLAN suspend might fail
1625  * @SUSPEND_FAIL_IPA: IPA in progress
1626  * @SUSPEND_FAIL_RADAR: radar scan in progress
1627  * @SUSPEND_FAIL_ROAM: roaming in progress
1628  * @SUSPEND_FAIL_SCAN: scan in progress
1629  * @SUSPEND_FAIL_INITIAL_WAKEUP: received initial wakeup from firmware
1630  * @SUSPEND_FAIL_MAX_COUNT: the number of wakeup reasons, always at the end
1631  */
1632 enum suspend_fail_reason {
1633 	SUSPEND_FAIL_IPA,
1634 	SUSPEND_FAIL_RADAR,
1635 	SUSPEND_FAIL_ROAM,
1636 	SUSPEND_FAIL_SCAN,
1637 	SUSPEND_FAIL_INITIAL_WAKEUP,
1638 	SUSPEND_FAIL_MAX_COUNT
1639 };
1640 
1641 /**
1642  * struct suspend_resume_stats - counters for suspend/resume events
1643  * @suspends: number of suspends completed
1644  * @resumes: number of resumes completed
1645  * @suspend_fail: counters for failed suspend reasons
1646  */
1647 struct suspend_resume_stats {
1648 	uint32_t suspends;
1649 	uint32_t resumes;
1650 	uint32_t suspend_fail[SUSPEND_FAIL_MAX_COUNT];
1651 };
1652 
1653 /**
1654  * enum hdd_sta_smps_param - SMPS parameters to configure from hdd
1655  * @HDD_STA_SMPS_PARAM_UPPER_RSSI_THRESH: RSSI threshold to enter Dynamic SMPS
1656  * mode from inactive mode
1657  * @HDD_STA_SMPS_PARAM_STALL_RSSI_THRESH:  RSSI threshold to enter
1658  * Stalled-D-SMPS mode from D-SMPS mode or to enter D-SMPS mode from
1659  * Stalled-D-SMPS mode
1660  * @HDD_STA_SMPS_PARAM_LOWER_RSSI_THRESH:  RSSI threshold to disable SMPS modes
1661  * @HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH: Upper threshold for beacon-RSSI.
1662  * Used to reduce RX chainmask.
1663  * @HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH:  Lower threshold for beacon-RSSI.
1664  * Used to increase RX chainmask.
1665  * @HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE: Enable/Disable DTIM 1chRx feature
1666  */
1667 enum hdd_sta_smps_param {
1668 	HDD_STA_SMPS_PARAM_UPPER_RSSI_THRESH = 0,
1669 	HDD_STA_SMPS_PARAM_STALL_RSSI_THRESH = 1,
1670 	HDD_STA_SMPS_PARAM_LOWER_RSSI_THRESH = 2,
1671 	HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH = 3,
1672 	HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH = 4,
1673 	HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE = 5
1674 };
1675 
1676 /**
1677  * enum RX_OFFLOAD - Receive offload modes
1678  * @CFG_LRO_ENABLED: Large Rx offload
1679  * @CFG_GRO_ENABLED: Generic Rx Offload
1680  */
1681 enum RX_OFFLOAD {
1682 	CFG_LRO_ENABLED = 1,
1683 	CFG_GRO_ENABLED,
1684 };
1685 
1686 /* One per STA: 1 for BCMC_STA_ID, 1 for each SAP_SELF_STA_ID,
1687  * 1 for WDS_STAID
1688  */
1689 #define HDD_MAX_ADAPTERS (WLAN_MAX_STA_COUNT + QDF_MAX_NO_OF_SAP_MODE + 2)
1690 
1691 #ifdef DISABLE_CHANNEL_LIST
1692 
1693 /**
1694  * struct hdd_cache_channel_info - Structure of the channel info
1695  * which needs to be cached
1696  * @freq: frequency
1697  * @reg_status: Current regulatory status of the channel
1698  * Enable
1699  * Disable
1700  * DFS
1701  * Invalid
1702  * @wiphy_status: Current wiphy status
1703  */
1704 struct hdd_cache_channel_info {
1705 	qdf_freq_t freq;
1706 	enum channel_state reg_status;
1707 	uint32_t wiphy_status;
1708 };
1709 
1710 /**
1711  * struct hdd_cache_channels - Structure of the channels to be cached
1712  * @num_channels: Number of channels to be cached
1713  * @channel_info: Structure of the channel info
1714  */
1715 struct hdd_cache_channels {
1716 	uint32_t num_channels;
1717 	struct hdd_cache_channel_info *channel_info;
1718 };
1719 #endif
1720 
1721 /**
1722  * struct hdd_dynamic_mac - hdd structure to handle dynamic mac address changes
1723  * @dynamic_mac: Dynamically configured mac, this contains the mac on which
1724  * current interface is up
1725  * @is_provisioned_mac: is this mac from provisioned list
1726  * @bit_position: holds the bit mask position from where this mac is assigned,
1727  * if mac is assigned from provisioned this field contains the position from
1728  * provisioned_intf_addr_mask else contains the position from
1729  * derived_intf_addr_mask
1730  */
1731 struct hdd_dynamic_mac {
1732 	struct qdf_mac_addr dynamic_mac;
1733 	bool is_provisioned_mac;
1734 	uint8_t bit_position;
1735 };
1736 
1737 /**
1738  * struct hdd_fw_ver_info - FW version info structure
1739  * @major_spid: FW version - major spid.
1740  * @minor_spid: FW version - minor spid
1741  * @siid:       FW version - siid
1742  * @sub_id:     FW version - sub id
1743  * @rel_id:     FW version - release id
1744  * @crmid:      FW version - crmid
1745  */
1746 
1747 struct hdd_fw_ver_info {
1748 	uint32_t major_spid;
1749 	uint32_t minor_spid;
1750 	uint32_t siid;
1751 	uint32_t sub_id;
1752 	uint32_t rel_id;
1753 	uint32_t crmid;
1754 };
1755 
1756 /*
1757  * The logic for get current index of history is dependent on this
1758  * value being power of 2.
1759  */
1760 #define WLAN_HDD_ADAPTER_OPS_HISTORY_MAX 4
1761 QDF_COMPILE_TIME_ASSERT(adapter_ops_history_size,
1762 			(WLAN_HDD_ADAPTER_OPS_HISTORY_MAX &
1763 			 (WLAN_HDD_ADAPTER_OPS_HISTORY_MAX - 1)) == 0);
1764 
1765 /**
1766  * enum hdd_adapter_ops_event - events for adapter ops history
1767  * @WLAN_HDD_ADAPTER_OPS_WORK_POST: adapter ops work posted
1768  * @WLAN_HDD_ADAPTER_OPS_WORK_SCHED: adapter ops work scheduled
1769  */
1770 enum hdd_adapter_ops_event {
1771 	WLAN_HDD_ADAPTER_OPS_WORK_POST,
1772 	WLAN_HDD_ADAPTER_OPS_WORK_SCHED,
1773 };
1774 
1775 /**
1776  * struct hdd_adapter_ops_record - record of adapter ops history
1777  * @timestamp: time of the occurrence of event
1778  * @event: event
1779  * @vdev_id: vdev id corresponding to the event
1780  */
1781 struct hdd_adapter_ops_record {
1782 	uint64_t timestamp;
1783 	enum hdd_adapter_ops_event event;
1784 	int vdev_id;
1785 };
1786 
1787 /**
1788  * struct hdd_adapter_ops_history - history of adapter ops
1789  * @index: index to store the next event
1790  * @entry: array of events
1791  */
1792 struct hdd_adapter_ops_history {
1793 	qdf_atomic_t index;
1794 	struct hdd_adapter_ops_record entry[WLAN_HDD_ADAPTER_OPS_HISTORY_MAX];
1795 };
1796 
1797 /**
1798  * struct hdd_dual_sta_policy - Concurrent STA policy configuration
1799  * @dual_sta_policy: Possible values are defined in enum
1800  * qca_wlan_concurrent_sta_policy_config
1801  * @primary_vdev_id: specified iface is the primary STA iface, say 0 means
1802  * vdev 0 is acting as primary interface
1803  */
1804 struct hdd_dual_sta_policy {
1805 	uint8_t dual_sta_policy;
1806 	uint8_t primary_vdev_id;
1807 };
1808 
1809 #ifdef FEATURE_CNSS_HW_SECURE_DISABLE
1810 /**
1811  * hdd_get_wlan_driver_status() - get status of soft driver unload
1812  *
1813  * Return: true if wifi is disabled by soft driver unload, else false
1814  */
1815 bool hdd_get_wlan_driver_status(void);
1816 #else
hdd_get_wlan_driver_status(void)1817 static inline bool hdd_get_wlan_driver_status(void)
1818 {
1819 	return false;
1820 }
1821 #endif
1822 
1823 /**
1824  * struct hdd_lpc_info - Local packet capture information
1825  * @lpc_wk: local packet capture work
1826  * @lpc_wk_scheduled: flag to indicate if lpc work is scheduled or not
1827  * @mon_adapter: monitor adapter
1828  */
1829 struct hdd_lpc_info {
1830 	qdf_work_t lpc_wk;
1831 	bool lpc_wk_scheduled;
1832 	struct hdd_adapter *mon_adapter;
1833 };
1834 
1835 /**
1836  * enum wlan_state_ctrl_str_id - state control param string id
1837  * @WLAN_OFF_STR: Turn OFF WiFi
1838  * @WLAN_ON_STR: Turn ON WiFi
1839  * @WLAN_ENABLE_STR: Enable WiFi
1840  * @WLAN_DISABLE_STR: Disable Wifi
1841  * @WLAN_WAIT_FOR_READY_STR: Driver should wait for ongoing recovery
1842  * @WLAN_FORCE_DISABLE_STR: Disable Wifi by soft driver unload
1843  */
1844 enum wlan_state_ctrl_str_id {
1845 	WLAN_OFF_STR   = 0,
1846 	WLAN_ON_STR,
1847 	WLAN_ENABLE_STR,
1848 	WLAN_DISABLE_STR,
1849 	WLAN_WAIT_FOR_READY_STR,
1850 	WLAN_FORCE_DISABLE_STR
1851 };
1852 
1853 #define MAX_TGT_HW_NAME_LEN 32
1854 
1855 /**
1856  * struct hdd_context - hdd shared driver and psoc/device context
1857  * @psoc: object manager psoc context
1858  * @pdev: object manager pdev context
1859  * @mac_handle: opaque handle to MAC context
1860  * @wiphy: Linux wiphy
1861  * @hdd_adapter_lock: lock for @hdd_adapters
1862  * @hdd_adapters: list of all instantiated adapters
1863  * @is_therm_cmd_supp: get temperature command enable or disable
1864  * @fw: pointer to firmware image data
1865  * @cfg: pointer to configuration data
1866  * @parent_dev: pointer to parent device
1867  * @config: Config values read from qcom_cfg.ini file
1868  * @channels_2ghz: pointer for wiphy 2 GHz channels
1869  * @channels_5ghz: pointer for wiphy 5 GHz channels
1870  * @iftype_data_2g: Interface data for 2 GHz band
1871  * @iftype_data_5g: Interface data for 5 GHz band
1872  * @iftype_data_6g: Interface data for 6 GHz band
1873  * @mc_sus_event_var: Completion variable to indicate Mc Thread Suspended
1874  * @is_scheduler_suspended: true if the MC Thread is suspended
1875  * @is_ol_rx_thread_suspended: true if the RX Thread is suspended
1876  * @hdd_wlan_suspended: true if the HDD is suspended
1877  * @suspended: unused???
1878  * @is_pktlog_enabled: true if pktlog is enabled, used to start pktlog after
1879  *                     SSR/PDR if previously enabled
1880  * @sap_lock: Lock to avoid race condition during start/stop bss
1881  * @oem_app_registered: OEM App registered or not
1882  * @oem_pid: OEM App Process ID when registered
1883  * @concurrency_mode: Concurrency Parameters
1884  * @no_of_open_sessions: number of open sessions per operating mode
1885  * @no_of_active_sessions: number of active sessions per operating mode
1886  * @p2p_device_address: P2P Device MAC Address for the adapter
1887  * @sap_wake_lock: Soft AP wakelock
1888  * @is_wiphy_suspended: Flag keeps track of wiphy suspend/resume
1889  * @ready_to_suspend: completed when ready to suspend
1890  * @target_type: defining the solution type
1891  * @target_fw_version: firmware version
1892  * @target_fw_vers_ext: firmware version extension
1893  * @fw_version_info: detailed firmware version information
1894  * @target_hw_version:  the chip/rom version
1895  * @target_hw_revision: the chip/rom revision
1896  * @target_hw_name: chip/rom name
1897  * @reg: regulatory information
1898  * @unsafe_channel_count: number of unsafe channels
1899  * @unsafe_channel_list: list of unsafe channels
1900  * @restriction_mask: channel avoidance restrictions mask
1901  * @max_intf_count: maximum number of supported interfaces
1902  * @lpss_support: Is LPSS offload supported
1903  * @ap_arpns_support: Is AP ARP/NS offload supported
1904  * @ioctl_scan_mode: scan mode
1905  * @sta_ap_intf_check_work: workqueue for interface check
1906  * @dev_dfs_cac_status: DFS CAC status
1907  * @bt_coex_mode_set: Has BT coex mode been set
1908  * @skip_acs_scan_timer: timer used to skip ACS scan
1909  * @skip_acs_scan_status: status of skip ACS scan
1910  * @last_acs_freq_list: ACS frequency list
1911  * @num_of_channels: number of channels in @last_acs_freq_list
1912  * @acs_skip_lock: use to synchronize "skip ACS scan" feature
1913  * @sap_dfs_wakelock : SAP DFS wakelock
1914  * @sap_dfs_ref_cnt: SAP DFS reference count
1915  * @is_extwow_app_type1_param_set: is extwow app type1 param set
1916  * @is_extwow_app_type2_param_set: is extwow app type2 param set
1917  * @ext_scan_start_since_boot: Time since boot up to extscan start (in micro
1918  *                             seconds)
1919  * @miracast_value: value of driver miracast command
1920  * @ipv6_notifier: IPv6 notifier callback for handling NS offload on change
1921  *                 in IP
1922  * @ns_offload_enable: Is NS offload enabled
1923  * @ipv4_notifier: IPv4 notifier callback for handling ARP offload on change
1924  *                 in IP
1925  * @pm_qos_notifier: Device PM QoS notifier
1926  * @runtime_pm_prevented: Is PM prevented
1927  * @pm_qos_lock: Lock for PM QoS data
1928  * @num_rf_chains: number of rf chains supported by target
1929  * @ht_tx_stbc_supported: Is HT Tx STBC supported by target
1930  * @op_ctx: Offloaded packets context
1931  * @mcc_mode: Is Multi-channel Concurrency enabled
1932  * @memdump_lock: Lock for memdump data
1933  * @driver_dump_size: Size of the memdump data buffer
1934  * @driver_dump_mem: memdump data buffer
1935  * @connection_in_progress: Is connection in progress
1936  * @connection_status_lock: Lock for connection status
1937  * @fine_time_meas_cap_target: place to store FTM capab of target. This
1938  *                             allows changing of FTM capab at runtime
1939  *                             and intersecting it with target capab before
1940  *                             updating.
1941  * @current_antenna_mode: Current number of TX X RX chains being used
1942  * @radio_index: the radio index assigned by cnss_logger
1943  * @hbw_requested: Has high bandwidth been requested
1944  * @pm_qos_request: Is PM QoS requested
1945  * @nan_datapath_enabled: Is NAN datapath enabled
1946  * @driver_status: Present state of driver cds modules
1947  * @psoc_idle_timeout_work: delayed work for psoc idle shutdown
1948  * @pm_notifier: PM notifier of hdd modules
1949  * @acs_policy: ACS DFS policy
1950  * @wmi_max_len: MTU of the WMI interface
1951  * @suspend_resume_stats: Suspend/Resume statistics
1952  * @runtime_context: Runtime PM context
1953  * @chan_info: scan channel information
1954  * @chan_info_lock: lock for @chan_info
1955  * @tdls_source_bitmap: bit map to set/reset TDLS by different sources
1956  * @tdls_umac_comp_active: Is the TDLS component active
1957  * @tdls_nap_active: Is napier specific tdls data path enabled
1958  * @beacon_probe_rsp_cnt_per_scan:
1959  * @last_scan_reject_vdev_id:
1960  * @last_scan_reject_reason:
1961  * @last_scan_reject_timestamp:
1962  * @scan_reject_cnt:
1963  * @dfs_cac_offload:
1964  * @reg_offload:
1965  * @rcpi_enabled:
1966  * @coex_avoid_freq_list:
1967  * @dnbs_avoid_freq_list:
1968  * @avoid_freq_lock:  Lock to control access to dnbs and coex avoid freq list
1969  * @tsf: structure containing tsf related information
1970  * @bt_a2dp_active:
1971  * @bt_vo_active:
1972  * @bt_profile_con:
1973  * @curr_band:
1974  * @imps_enabled:
1975  * @user_configured_pkt_filter_rules:
1976  * @is_fils_roaming_supported:
1977  * @receive_offload_cb:
1978  * @vendor_disable_lro_flag:
1979  * @force_rsne_override:
1980  * @monitor_mode_wakelock:
1981  * @lte_coex_ant_share:
1982  * @obss_scan_offload:
1983  * @sscan_pid:
1984  * @track_arp_ip:
1985  * @hw_bd_id: defining the board related information
1986  * @hw_bd_info:
1987  * @twt_state:
1988  * @twt_disable_comp_evt:
1989  * @twt_enable_comp_evt:
1990  * @apf_version:
1991  * @apf_enabled_v2:
1992  * @original_channels:
1993  * @cache_channel_lock:
1994  * @sar_version:
1995  * @dynamic_mac_list:
1996  * @dynamic_nss_chains_support: Per vdev dynamic nss chains update capability
1997  * @hw_macaddr:
1998  * @provisioned_mac_addr:
1999  * @derived_mac_addr:
2000  * @num_provisioned_addr:
2001  * @num_derived_addr:
2002  * @provisioned_intf_addr_mask:
2003  * @derived_intf_addr_mask:
2004  * @sar_cmd_params: SAR command params to be configured to the FW
2005  * @sar_safety_timer:
2006  * @sar_safety_unsolicited_work:
2007  * @sar_safety_req_resp_event:
2008  * @sar_safety_req_resp_event_in_progress:
2009  * @runtime_resume_start_time_stamp:
2010  * @runtime_suspend_done_time_stamp:
2011  * @pm_qos_req:
2012  * @qos_cpu_mask: voted cpu core mask
2013  * @pm_qos_req: pm_qos request for all cpu cores
2014  * @roam_ch_from_fw_supported:
2015  * @dutycycle_off_percent:
2016  * @pm_qos_request_flags:
2017  * @country_change_work: work for updating vdev when country changes
2018  * @current_pcie_gen_speed: current pcie gen speed
2019  * @adapter_ops_wq: High priority workqueue for handling adapter operations
2020  * @adapter_ops_history:
2021  * @ll_stats_per_chan_rx_tx_time:
2022  * @is_get_station_clubbed_in_ll_stats_req:
2023  * @multi_client_thermal_mitigation: Multi client thermal mitigation by fw
2024  * @is_dual_mac_cfg_updated: indicate whether dual mac cfg has been updated
2025  * @is_regulatory_update_in_progress:
2026  * @regulatory_update_event:
2027  * @regulatory_status_lock:
2028  * @is_fw_dbg_log_levels_configured:
2029  * @twt_en_dis_work: work to send twt enable/disable cmd on MCC/SCC concurrency
2030  * @is_wifi3_0_target:
2031  * @dump_in_progress: Stores value of dump in progress
2032  * @dual_sta_policy: Concurrent STA policy configuration
2033  * @is_therm_stats_in_progress:
2034  * @is_vdev_macaddr_dynamic_update_supported:
2035  * @power_type:
2036  * @is_wlan_disabled: if wlan is disabled by userspace
2037  * @oem_data:
2038  * @oem_data_len:
2039  * @file_name:
2040  * @dbam_mode:
2041  * @last_pagefault_ssr_time: Time when last recovery was triggered because of
2042  * @host wakeup from fw with reason as pagefault
2043  * @bridgeaddr: Bridge MAC address
2044  * @is_mlo_per_link_stats_supported: Per link mlo stats is supported or not
2045  * @num_mlo_peers: Total number of MLO peers
2046  * @more_peer_data: more mlo peer data in peer stats
2047  * @lpc_info: Local packet capture info
2048  */
2049 struct hdd_context {
2050 	struct wlan_objmgr_psoc *psoc;
2051 	struct wlan_objmgr_pdev *pdev;
2052 	mac_handle_t mac_handle;
2053 	struct wiphy *wiphy;
2054 	qdf_spinlock_t hdd_adapter_lock;
2055 	qdf_list_t hdd_adapters;
2056 	bool is_therm_cmd_supp;
2057 	const struct firmware *fw;
2058 	const struct firmware *cfg;
2059 	struct device *parent_dev;
2060 	struct hdd_config *config;
2061 
2062 	/* Pointer for wiphy 2G/5G band channels */
2063 	struct ieee80211_channel *channels_2ghz;
2064 	struct ieee80211_channel *channels_5ghz;
2065 
2066 #if defined(WLAN_FEATURE_11AX) && \
2067 	(defined(CFG80211_SBAND_IFTYPE_DATA_BACKPORT) || \
2068 	 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)))
2069 	struct ieee80211_sband_iftype_data *iftype_data_2g;
2070 	struct ieee80211_sband_iftype_data *iftype_data_5g;
2071 #if defined(CONFIG_BAND_6GHZ) && (defined(CFG80211_6GHZ_BAND_SUPPORTED) || \
2072 		(KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE))
2073 	struct ieee80211_sband_iftype_data *iftype_data_6g;
2074 #endif
2075 #endif
2076 	struct completion mc_sus_event_var;
2077 	bool is_scheduler_suspended;
2078 
2079 #ifdef WLAN_DP_LEGACY_OL_RX_THREAD
2080 	bool is_ol_rx_thread_suspended;
2081 #endif
2082 
2083 	bool hdd_wlan_suspended;
2084 	bool suspended;
2085 	bool is_pktlog_enabled;
2086 	struct mutex sap_lock;
2087 
2088 #ifdef FEATURE_OEM_DATA_SUPPORT
2089 	bool oem_app_registered;
2090 	int32_t oem_pid;
2091 #endif
2092 
2093 	uint32_t concurrency_mode;
2094 
2095 	uint8_t no_of_open_sessions[QDF_MAX_NO_OF_MODE];
2096 	uint8_t no_of_active_sessions[QDF_MAX_NO_OF_MODE];
2097 	struct qdf_mac_addr p2p_device_address;
2098 	qdf_wake_lock_t sap_wake_lock;
2099 	bool is_wiphy_suspended;
2100 	struct completion ready_to_suspend;
2101 	uint32_t target_type;
2102 	uint32_t target_fw_version;
2103 	uint32_t target_fw_vers_ext;
2104 	struct hdd_fw_ver_info fw_version_info;
2105 	uint32_t target_hw_version;
2106 	uint32_t target_hw_revision;
2107 	char target_hw_name[MAX_TGT_HW_NAME_LEN];
2108 	struct regulatory reg;
2109 #ifdef FEATURE_WLAN_CH_AVOID
2110 	uint16_t unsafe_channel_count;
2111 	uint16_t unsafe_channel_list[NUM_CHANNELS];
2112 #endif /* FEATURE_WLAN_CH_AVOID */
2113 #ifdef FEATURE_WLAN_CH_AVOID_EXT
2114 	uint32_t restriction_mask;
2115 #endif
2116 
2117 	uint8_t max_intf_count;
2118 #ifdef WLAN_FEATURE_LPSS
2119 	uint8_t lpss_support;
2120 #endif
2121 	uint8_t ap_arpns_support;
2122 	tSirScanType ioctl_scan_mode;
2123 
2124 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2125 	qdf_work_t sta_ap_intf_check_work;
2126 #endif
2127 
2128 	uint8_t dev_dfs_cac_status;
2129 
2130 	bool bt_coex_mode_set;
2131 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
2132 	qdf_mc_timer_t skip_acs_scan_timer;
2133 	uint8_t skip_acs_scan_status;
2134 	uint32_t *last_acs_freq_list;
2135 	uint8_t num_of_channels;
2136 	qdf_spinlock_t acs_skip_lock;
2137 #endif
2138 
2139 	qdf_wake_lock_t sap_dfs_wakelock;
2140 	atomic_t sap_dfs_ref_cnt;
2141 
2142 #ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2143 	bool is_extwow_app_type1_param_set;
2144 	bool is_extwow_app_type2_param_set;
2145 #endif
2146 
2147 	uint64_t ext_scan_start_since_boot;
2148 	uint8_t miracast_value;
2149 
2150 #ifdef WLAN_NS_OFFLOAD
2151 	/* IPv6 notifier callback for handling NS offload on change in IP */
2152 	struct notifier_block ipv6_notifier;
2153 #endif
2154 	bool ns_offload_enable;
2155 	/* IPv4 notifier callback for handling ARP offload on change in IP */
2156 	struct notifier_block ipv4_notifier;
2157 
2158 #ifdef FEATURE_RUNTIME_PM
2159 	struct notifier_block pm_qos_notifier;
2160 	bool runtime_pm_prevented;
2161 	qdf_spinlock_t pm_qos_lock;
2162 #endif
2163 	uint32_t  num_rf_chains;
2164 	uint8_t   ht_tx_stbc_supported;
2165 #ifdef WLAN_FEATURE_OFFLOAD_PACKETS
2166 	struct hdd_offloaded_packets_ctx op_ctx;
2167 #endif
2168 	bool mcc_mode;
2169 	struct mutex memdump_lock;
2170 	uint16_t driver_dump_size;
2171 	uint8_t *driver_dump_mem;
2172 
2173 	bool connection_in_progress;
2174 	qdf_spinlock_t connection_status_lock;
2175 
2176 	uint32_t fine_time_meas_cap_target;
2177 	enum antenna_mode current_antenna_mode;
2178 
2179 	int radio_index;
2180 	bool hbw_requested;
2181 	bool pm_qos_request;
2182 #ifdef WLAN_FEATURE_NAN
2183 	bool nan_datapath_enabled;
2184 #endif
2185 	enum driver_modules_status driver_status;
2186 	struct qdf_delayed_work psoc_idle_timeout_work;
2187 	struct notifier_block pm_notifier;
2188 	struct acs_dfs_policy acs_policy;
2189 	uint16_t wmi_max_len;
2190 	struct suspend_resume_stats suspend_resume_stats;
2191 	struct hdd_runtime_pm_context runtime_context;
2192 	struct scan_chan_info *chan_info;
2193 	struct mutex chan_info_lock;
2194 	unsigned long tdls_source_bitmap;
2195 	bool tdls_umac_comp_active;
2196 	bool tdls_nap_active;
2197 	uint8_t beacon_probe_rsp_cnt_per_scan;
2198 	uint8_t last_scan_reject_vdev_id;
2199 	enum scan_reject_states last_scan_reject_reason;
2200 	unsigned long last_scan_reject_timestamp;
2201 	uint8_t scan_reject_cnt;
2202 	bool dfs_cac_offload;
2203 	bool reg_offload;
2204 	bool rcpi_enabled;
2205 #ifdef FEATURE_WLAN_CH_AVOID
2206 	struct ch_avoid_ind_type coex_avoid_freq_list;
2207 	struct ch_avoid_ind_type dnbs_avoid_freq_list;
2208 	/* Lock to control access to dnbs and coex avoid freq list */
2209 	struct mutex avoid_freq_lock;
2210 #endif
2211 #ifdef WLAN_FEATURE_TSF
2212 	struct hdd_ctx_tsf tsf;
2213 #endif
2214 
2215 	uint8_t bt_a2dp_active:1;
2216 	uint8_t bt_vo_active:1;
2217 	uint8_t bt_profile_con:1;
2218 	enum band_info curr_band;
2219 	bool imps_enabled;
2220 #ifdef WLAN_FEATURE_PACKET_FILTERING
2221 	int user_configured_pkt_filter_rules;
2222 #endif
2223 	bool is_fils_roaming_supported;
2224 	QDF_STATUS (*receive_offload_cb)(struct hdd_adapter *,
2225 					 struct sk_buff *);
2226 	qdf_atomic_t vendor_disable_lro_flag;
2227 	bool force_rsne_override;
2228 	qdf_wake_lock_t monitor_mode_wakelock;
2229 	bool lte_coex_ant_share;
2230 	bool obss_scan_offload;
2231 	int sscan_pid;
2232 	uint32_t track_arp_ip;
2233 
2234 	/* defining the board related information */
2235 	uint32_t hw_bd_id;
2236 	struct board_info hw_bd_info;
2237 #ifdef WLAN_SUPPORT_TWT
2238 	enum twt_status twt_state;
2239 	qdf_event_t twt_disable_comp_evt;
2240 	qdf_event_t twt_enable_comp_evt;
2241 #endif
2242 #ifdef FEATURE_WLAN_APF
2243 	uint32_t apf_version;
2244 	bool apf_enabled_v2;
2245 #endif
2246 
2247 #ifdef DISABLE_CHANNEL_LIST
2248 	struct hdd_cache_channels *original_channels;
2249 	qdf_mutex_t cache_channel_lock;
2250 #endif
2251 	enum sar_version sar_version;
2252 	struct hdd_dynamic_mac dynamic_mac_list[QDF_MAX_CONCURRENCY_PERSONA];
2253 	bool dynamic_nss_chains_support;
2254 	struct qdf_mac_addr hw_macaddr;
2255 	struct qdf_mac_addr provisioned_mac_addr[QDF_MAX_CONCURRENCY_PERSONA];
2256 	struct qdf_mac_addr derived_mac_addr[QDF_MAX_CONCURRENCY_PERSONA];
2257 	uint32_t num_provisioned_addr;
2258 	uint32_t num_derived_addr;
2259 	unsigned long provisioned_intf_addr_mask;
2260 	unsigned long derived_intf_addr_mask;
2261 
2262 	struct sar_limit_cmd_params *sar_cmd_params;
2263 #ifdef SAR_SAFETY_FEATURE
2264 	qdf_mc_timer_t sar_safety_timer;
2265 	struct qdf_delayed_work sar_safety_unsolicited_work;
2266 	qdf_event_t sar_safety_req_resp_event;
2267 	qdf_atomic_t sar_safety_req_resp_event_in_progress;
2268 #endif
2269 
2270 	qdf_time_t runtime_resume_start_time_stamp;
2271 	qdf_time_t runtime_suspend_done_time_stamp;
2272 #if defined(CLD_PM_QOS) && defined(CLD_DEV_PM_QOS)
2273 	struct dev_pm_qos_request pm_qos_req[NR_CPUS];
2274 	struct cpumask qos_cpu_mask;
2275 #elif defined(CLD_PM_QOS)
2276 	struct pm_qos_request pm_qos_req;
2277 #endif
2278 	bool roam_ch_from_fw_supported;
2279 #ifdef FW_THERMAL_THROTTLE_SUPPORT
2280 	uint8_t dutycycle_off_percent;
2281 #endif
2282 	uint8_t pm_qos_request_flags;
2283 	qdf_work_t country_change_work;
2284 	int current_pcie_gen_speed;
2285 	qdf_workqueue_t *adapter_ops_wq;
2286 	struct hdd_adapter_ops_history adapter_ops_history;
2287 	bool ll_stats_per_chan_rx_tx_time;
2288 #ifdef FEATURE_CLUB_LL_STATS_AND_GET_STATION
2289 	bool is_get_station_clubbed_in_ll_stats_req;
2290 #endif
2291 #ifdef FEATURE_WPSS_THERMAL_MITIGATION
2292 	bool multi_client_thermal_mitigation;
2293 #endif
2294 	bool is_dual_mac_cfg_updated;
2295 	bool is_regulatory_update_in_progress;
2296 	qdf_event_t regulatory_update_event;
2297 	qdf_mutex_t regulatory_status_lock;
2298 	bool is_fw_dbg_log_levels_configured;
2299 #ifdef WLAN_SUPPORT_TWT
2300 	qdf_work_t twt_en_dis_work;
2301 #endif
2302 	bool is_wifi3_0_target;
2303 	bool dump_in_progress;
2304 	struct hdd_dual_sta_policy dual_sta_policy;
2305 #ifdef THERMAL_STATS_SUPPORT
2306 	bool is_therm_stats_in_progress;
2307 #endif
2308 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
2309 	bool is_vdev_macaddr_dynamic_update_supported;
2310 #endif
2311 #ifdef CONFIG_WLAN_FREQ_LIST
2312 	uint8_t power_type;
2313 #endif
2314 	bool is_wlan_disabled;
2315 
2316 	uint8_t oem_data[HDD_MAX_OEM_DATA_LEN];
2317 	uint8_t oem_data_len;
2318 	uint8_t file_name[HDD_MAX_FILE_NAME_LEN];
2319 #ifdef WLAN_FEATURE_DBAM_CONFIG
2320 	enum coex_dbam_config_mode dbam_mode;
2321 #endif
2322 	qdf_time_t last_pagefault_ssr_time;
2323 	uint8_t bridgeaddr[QDF_MAC_ADDR_SIZE];
2324 #ifdef WLAN_FEATURE_11BE_MLO
2325 	bool is_mlo_per_link_stats_supported;
2326 	uint8_t num_mlo_peers;
2327 	uint32_t more_peer_data;
2328 #endif
2329 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
2330 	struct hdd_lpc_info lpc_info;
2331 #endif
2332 };
2333 
2334 /**
2335  * struct hdd_vendor_acs_chan_params - vendor acs channel parameters
2336  * @pcl_count: pcl list count
2337  * @vendor_pcl_list: pointer to pcl frequency (MHz) list
2338  * @vendor_weight_list: pointer to pcl weight list
2339  */
2340 struct hdd_vendor_acs_chan_params {
2341 	uint32_t pcl_count;
2342 	uint32_t *vendor_pcl_list;
2343 	uint8_t *vendor_weight_list;
2344 };
2345 
2346 /**
2347  * struct hdd_external_acs_timer_context - acs timer context
2348  * @reason: reason for acs trigger
2349  * @adapter: hdd adapter for acs
2350  */
2351 struct hdd_external_acs_timer_context {
2352 	int8_t reason;
2353 	struct hdd_adapter *adapter;
2354 };
2355 
2356 /**
2357  * struct hdd_vendor_chan_info - vendor channel info
2358  * @band: channel operating band
2359  * @pri_chan_freq: primary channel freq in MHz
2360  * @ht_sec_chan_freq: secondary channel freq in MHz
2361  * @vht_seg0_center_chan_freq: segment0 for vht in MHz
2362  * @vht_seg1_center_chan_freq: vht segment 1 in MHz
2363  * @chan_width: channel width
2364  */
2365 struct hdd_vendor_chan_info {
2366 	uint8_t band;
2367 	uint32_t pri_chan_freq;
2368 	uint32_t ht_sec_chan_freq;
2369 	uint32_t vht_seg0_center_chan_freq;
2370 	uint32_t vht_seg1_center_chan_freq;
2371 	uint8_t chan_width;
2372 };
2373 
2374 /**
2375  * struct  hdd_channel_info - standard channel info
2376  * @freq: Freq in Mhz
2377  * @flags: channel info flags
2378  * @flagext: extended channel info flags
2379  * @ieee_chan_number: channel number
2380  * @max_reg_power: max tx power according to regulatory
2381  * @max_radio_power: max radio power
2382  * @min_radio_power: min radio power
2383  * @reg_class_id: regulatory class
2384  * @max_antenna_gain: max antenna gain allowed on channel
2385  * @vht_center_freq_seg0: vht center freq segment 0
2386  * @vht_center_freq_seg1: vht center freq segment 1
2387  */
2388 struct hdd_channel_info {
2389 	u_int16_t freq;
2390 	u_int32_t flags;
2391 	u_int16_t flagext;
2392 	u_int8_t ieee_chan_number;
2393 	int8_t max_reg_power;
2394 	int8_t max_radio_power;
2395 	int8_t min_radio_power;
2396 	u_int8_t reg_class_id;
2397 	u_int8_t max_antenna_gain;
2398 	u_int8_t vht_center_freq_seg0;
2399 	u_int8_t vht_center_freq_seg1;
2400 };
2401 
2402 /**
2403  * struct hdd_chwidth_info - channel width related info
2404  * @sir_chwidth_valid: If nl_chan_width is valid in Sir
2405  * @sir_chwidth: enum eSirMacHTChannelWidth
2406  * @ch_bw: enum hw_mode_bandwidth
2407  * @ch_bw_str: ch_bw in string format
2408  * @phy_chwidth: enum phy_ch_width
2409  * @bonding_mode: WNI_CFG_CHANNEL_BONDING_MODE_DISABLE or
2410  *		  WNI_CFG_CHANNEL_BONDING_MODE_ENABLE
2411  */
2412 struct hdd_chwidth_info {
2413 	bool sir_chwidth_valid;
2414 	enum eSirMacHTChannelWidth sir_chwidth;
2415 	enum hw_mode_bandwidth ch_bw;
2416 	char *ch_bw_str;
2417 	enum phy_ch_width phy_chwidth;
2418 	int bonding_mode;
2419 };
2420 
2421 /**
2422  * struct mac_addr_set_priv: Set MAC addr private context
2423  * @fw_resp_status: F/W response status
2424  * @pending_rsp_cnt: Pending response count
2425  */
2426 struct mac_addr_set_priv {
2427 	uint32_t fw_resp_status;
2428 	qdf_atomic_t pending_rsp_cnt;
2429 };
2430 
2431 /*
2432  * Function declarations and documentation
2433  */
2434 
2435 /**
2436  * wlan_hdd_history_get_next_index() - get next index to store the history
2437  *				       entry
2438  * @curr_idx: current index
2439  * @max_entries: max entries in the history
2440  *
2441  * Returns: The index at which record is to be stored in history
2442  */
wlan_hdd_history_get_next_index(qdf_atomic_t * curr_idx,uint32_t max_entries)2443 static inline uint32_t wlan_hdd_history_get_next_index(qdf_atomic_t *curr_idx,
2444 						       uint32_t max_entries)
2445 {
2446 	uint32_t idx = qdf_atomic_inc_return(curr_idx);
2447 
2448 	return idx & (max_entries - 1);
2449 }
2450 
2451 /**
2452  * hdd_adapter_ops_record_event() - record an entry in the adapter ops history
2453  * @hdd_ctx: pointer to hdd context
2454  * @event: event
2455  * @vdev_id: vdev id corresponding to event
2456  *
2457  * Returns: None
2458  */
2459 static inline void
hdd_adapter_ops_record_event(struct hdd_context * hdd_ctx,enum hdd_adapter_ops_event event,int vdev_id)2460 hdd_adapter_ops_record_event(struct hdd_context *hdd_ctx,
2461 			     enum hdd_adapter_ops_event event,
2462 			     int vdev_id)
2463 {
2464 	struct hdd_adapter_ops_history *adapter_hist;
2465 	struct hdd_adapter_ops_record *record;
2466 	uint32_t idx;
2467 
2468 	adapter_hist = &hdd_ctx->adapter_ops_history;
2469 
2470 	idx = wlan_hdd_history_get_next_index(&adapter_hist->index,
2471 					      WLAN_HDD_ADAPTER_OPS_HISTORY_MAX);
2472 
2473 	record = &adapter_hist->entry[idx];
2474 	record->event = event;
2475 	record->vdev_id = vdev_id;
2476 	record->timestamp = qdf_get_log_timestamp();
2477 }
2478 
2479 /**
2480  * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo
2481  * @adapter: HDD adapter
2482  * @chan_freq: Channel frequency
2483  * @chan_bw: Bandwidth
2484  *
2485  * Checks if the given bandwidth is valid for the given channel number.
2486  *
2487  * Return: 0 for success, non-zero for failure
2488  */
2489 int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter,
2490 				       qdf_freq_t chan_freq,
2491 				       enum phy_ch_width chan_bw);
2492 
2493 /**
2494  * hdd_get_front_adapter() - Get the first adapter from the adapter list
2495  * @hdd_ctx: pointer to the HDD context
2496  * @out_adapter: double pointer to pass the next adapter
2497  *
2498  * Return: QDF_STATUS
2499  */
2500 QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx,
2501 				 struct hdd_adapter **out_adapter);
2502 
2503 /**
2504  * hdd_get_next_adapter() - Get the next adapter from the adapter list
2505  * @hdd_ctx: pointer to the HDD context
2506  * @current_adapter: pointer to the current adapter
2507  * @out_adapter: double pointer to pass the next adapter
2508  *
2509  * Return: QDF_STATUS
2510  */
2511 QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx,
2512 				struct hdd_adapter *current_adapter,
2513 				struct hdd_adapter **out_adapter);
2514 
2515 /**
2516  * hdd_get_front_adapter_no_lock() - Get the first adapter from the adapter list
2517  * This API does not use any lock in it's implementation. It is the caller's
2518  * directive to ensure concurrency safety.
2519  * @hdd_ctx: pointer to the HDD context
2520  * @out_adapter: double pointer to pass the next adapter
2521  *
2522  * Return: QDF_STATUS
2523  */
2524 QDF_STATUS hdd_get_front_adapter_no_lock(struct hdd_context *hdd_ctx,
2525 					 struct hdd_adapter **out_adapter);
2526 
2527 /**
2528  * hdd_get_next_adapter_no_lock() - Get the next adapter from the adapter list
2529  * This API does not use any lock in it's implementation. It is the caller's
2530  * directive to ensure concurrency safety.
2531  * @hdd_ctx: pointer to the HDD context
2532  * @current_adapter: pointer to the current adapter
2533  * @out_adapter: double pointer to pass the next adapter
2534  *
2535  * Return: QDF_STATUS
2536  */
2537 QDF_STATUS hdd_get_next_adapter_no_lock(struct hdd_context *hdd_ctx,
2538 					struct hdd_adapter *current_adapter,
2539 					struct hdd_adapter **out_adapter);
2540 
2541 /**
2542  * hdd_remove_adapter() - Remove the adapter from the adapter list
2543  * @hdd_ctx: pointer to the HDD context
2544  * @adapter: pointer to the adapter to be removed
2545  *
2546  * Return: QDF_STATUS
2547  */
2548 QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx,
2549 			      struct hdd_adapter *adapter);
2550 
2551 /**
2552  * hdd_remove_front_adapter() - Remove the first adapter from the adapter list
2553  * @hdd_ctx: pointer to the HDD context
2554  * @out_adapter: pointer to the adapter to be removed
2555  *
2556  * Return: QDF_STATUS
2557  */
2558 QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx,
2559 				    struct hdd_adapter **out_adapter);
2560 
2561 /**
2562  * hdd_add_adapter_back() - Add an adapter to the adapter list
2563  * @hdd_ctx: pointer to the HDD context
2564  * @adapter: pointer to the adapter to be added
2565  *
2566  * Return: QDF_STATUS
2567  */
2568 QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx,
2569 				struct hdd_adapter *adapter);
2570 
2571 /**
2572  * hdd_add_adapter_front() - Add an adapter to the head of the adapter list
2573  * @hdd_ctx: pointer to the HDD context
2574  * @adapter: pointer to the adapter to be added
2575  *
2576  * Return: QDF_STATUS
2577  */
2578 QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx,
2579 				 struct hdd_adapter *adapter);
2580 
2581 /**
2582  * typedef hdd_adapter_iterate_cb() - Iteration callback function
2583  * @link_info: Link info pointer in HDD adapter
2584  * @context: user context supplied to the iterator
2585  *
2586  * This specifies the type of a callback function to supply to
2587  * hdd_adapter_iterate().
2588  *
2589  * Return:
2590  * * QDF_STATUS_SUCCESS if further iteration should continue
2591  * * QDF_STATUS_E_ABORTED if further iteration should be aborted
2592  */
2593 typedef QDF_STATUS
2594 (*hdd_adapter_iterate_cb)(struct wlan_hdd_link_info *link_info, void *context);
2595 
2596 /**
2597  * hdd_adapter_iterate() - Safely iterate over all adapters
2598  * @cb: callback function to invoke for each adapter
2599  * @context: user-supplied context to pass to @cb
2600  *
2601  * This function will iterate over all of the adapters known to the system in
2602  * a safe manner, invoking the callback function for each adapter.
2603  * The callback function will be invoked in the same context/thread as the
2604  * caller without any additional locks in force.
2605  * Iteration continues until either the callback has been invoked for all
2606  * adapters or a callback returns a value of QDF_STATUS_E_ABORTED to indicate
2607  * that further iteration should cease.
2608  *
2609  * Return:
2610  * * QDF_STATUS_E_ABORTED if any callback function returns that value
2611  * * QDF_STATUS_E_FAILURE if the callback was not invoked for all adapters due
2612  * to concurrency (i.e. adapter was deleted while iterating)
2613  * * QDF_STATUS_SUCCESS if @cb was invoked for each adapter and none returned
2614  * an error
2615  */
2616 QDF_STATUS hdd_adapter_iterate(hdd_adapter_iterate_cb cb,
2617 			       void *context);
2618 
2619 /**
2620  * hdd_adapter_dev_hold_debug - Debug API to call dev_hold
2621  * @adapter: hdd_adapter pointer
2622  * @dbgid: Debug ID corresponding to API that is requesting the dev_hold
2623  *
2624  * Return: none
2625  */
2626 void hdd_adapter_dev_hold_debug(struct hdd_adapter *adapter,
2627 				wlan_net_dev_ref_dbgid dbgid);
2628 
2629 /**
2630  * hdd_adapter_dev_put_debug - Debug API to call dev_put
2631  * @adapter: hdd_adapter pointer
2632  * @dbgid: Debug ID corresponding to API that is requesting the dev_put
2633  *
2634  * Return: none
2635  */
2636 void hdd_adapter_dev_put_debug(struct hdd_adapter *adapter,
2637 			       wlan_net_dev_ref_dbgid dbgid);
2638 
2639 /**
2640  * hdd_validate_next_adapter - API to check for infinite loop
2641  *                             in the adapter list traversal
2642  * @curr: current adapter pointer
2643  * @next: next adapter pointer
2644  * @dbg_id: Debug ID corresponding to API that is requesting the dev_put
2645  *
2646  * Return: None
2647  */
2648 void hdd_validate_next_adapter(struct hdd_adapter **curr,
2649 			       struct hdd_adapter **next,
2650 			       wlan_net_dev_ref_dbgid dbg_id);
2651 
2652 /**
2653  * __hdd_take_ref_and_fetch_front_adapter_safe - Helper macro to lock, fetch
2654  * front and next adapters, take ref and unlock.
2655  * @hdd_ctx: the global HDD context
2656  * @adapter: an hdd_adapter pointer to use as a cursor
2657  * @next_adapter: hdd_adapter pointer to next adapter
2658  * @dbgid: debug ID to detect reference leaks
2659  */
2660 #define __hdd_take_ref_and_fetch_front_adapter_safe(hdd_ctx, adapter, \
2661 						    next_adapter, dbgid) \
2662 	qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock), \
2663 	hdd_get_front_adapter_no_lock(hdd_ctx, &adapter), \
2664 	(adapter) ? hdd_adapter_dev_hold_debug(adapter, dbgid) : (false), \
2665 	hdd_get_next_adapter_no_lock(hdd_ctx, adapter, &next_adapter), \
2666 	(next_adapter) ? hdd_adapter_dev_hold_debug(next_adapter, dbgid) : \
2667 			 (false), \
2668 	qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock)
2669 
2670 /**
2671  * __hdd_take_ref_and_fetch_next_adapter_safe - Helper macro to lock, fetch next
2672  * adapter, take ref and unlock.
2673  * @hdd_ctx: the global HDD context
2674  * @adapter: hdd_adapter pointer to use as a cursor
2675  * @next_adapter: hdd_adapter pointer to next adapter
2676  * @dbgid: debug ID to detect reference leaks
2677  */
2678 #define __hdd_take_ref_and_fetch_next_adapter_safe(hdd_ctx, adapter, \
2679 						   next_adapter, dbgid) \
2680 	qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock), \
2681 	adapter = next_adapter, \
2682 	hdd_get_next_adapter_no_lock(hdd_ctx, adapter, &next_adapter), \
2683 	hdd_validate_next_adapter(&adapter, &next_adapter, dbgid), \
2684 	(next_adapter) ? hdd_adapter_dev_hold_debug(next_adapter, dbgid) : \
2685 			 (false), \
2686 	qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock)
2687 
2688 /**
2689  * __hdd_is_adapter_valid - Helper macro to return true/false for valid adapter.
2690  * @_adapter: an hdd_adapter pointer to use as a cursor
2691  */
2692 #define __hdd_is_adapter_valid(_adapter) !!_adapter
2693 
2694 /**
2695  * hdd_for_each_adapter_dev_held_safe - Adapter iterator with dev_hold called
2696  *                                      in a delete safe manner
2697  * @hdd_ctx: the global HDD context
2698  * @adapter: an hdd_adapter pointer to use as a cursor
2699  * @next_adapter: hdd_adapter pointer to the next adapter
2700  * @dbgid: reference count debugging id
2701  *
2702  * This iterator will take the reference of the netdev associated with the
2703  * given adapter so as to prevent it from being removed in other context. It
2704  * also takes the reference of the next adapter if exist. This avoids infinite
2705  * loop due to deletion of the adapter list entry inside the loop. Deletion of
2706  * list entry will make the list entry to point to self. If the control goes
2707  * inside the loop body then the dev_hold has been invoked.
2708  *
2709  *                           ***** NOTE *****
2710  * Before the end of each iteration, hdd_adapter_dev_put_debug(adapter, dbgid)
2711  * must be called. Not calling this will keep hold of a reference, thus
2712  * preventing unregister of the netdevice. If the loop is terminated in
2713  * between with return/goto/break statements,
2714  * hdd_adapter_dev_put_debug(next_adapter, dbgid) must be done along with
2715  * hdd_adapter_dev_put_debug(adapter, dbgid) before termination of the loop.
2716  *
2717  * Usage example:
2718  *  hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, dbgid) {
2719  *        <work involving adapter>
2720  *        <some more work>
2721  *        hdd_adapter_dev_put_debug(adapter, dbgid)
2722  *  }
2723  */
2724 #define hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, \
2725 					   dbgid) \
2726 	for (__hdd_take_ref_and_fetch_front_adapter_safe(hdd_ctx, adapter, \
2727 							 next_adapter, dbgid); \
2728 	     __hdd_is_adapter_valid(adapter); \
2729 	     __hdd_take_ref_and_fetch_next_adapter_safe(hdd_ctx, adapter, \
2730 							next_adapter, dbgid))
2731 
2732 /* Helper MACROS and APIs definition to iterate
2733  * link info array in HDD adapter.
2734  */
2735 #define __hdd_adapter_is_active_link(adapter, link_idx) \
2736 			qdf_atomic_test_bit(link_idx, &(adapter)->active_links)
2737 
2738 #define hdd_adapter_get_link_info_if_active(adapter, link_idx) \
2739 		__hdd_adapter_is_active_link((adapter), (link_idx)) ? \
2740 			&((adapter)->link_info[(link_idx)]) : NULL
2741 
2742 #define __hdd_is_link_info_valid(_link_info) !!_link_info
2743 
2744 #define __hdd_adapter_get_first_active_link_info(adapter, link_info) \
2745 	link_info = NULL, \
2746 	hdd_adapter_get_next_active_link_info(adapter, &link_info)
2747 
2748 
2749 static inline uint8_t
hdd_adapter_get_index_of_link_info(struct wlan_hdd_link_info * link_info)2750 hdd_adapter_get_index_of_link_info(struct wlan_hdd_link_info *link_info)
2751 {
2752 	return (link_info - &link_info->adapter->link_info[0]);
2753 }
2754 
2755 static inline void
hdd_adapter_get_next_active_link_info(struct hdd_adapter * adapter,struct wlan_hdd_link_info ** link_info)2756 hdd_adapter_get_next_active_link_info(struct hdd_adapter *adapter,
2757 				      struct wlan_hdd_link_info **link_info)
2758 {
2759 	uint8_t link_idx = WLAN_HDD_DEFLINK_IDX;
2760 	uint8_t link_idx_max;
2761 
2762 	if (!link_info || !adapter)
2763 		return;
2764 
2765 	/* If @link_info already points to valid link info address, get the
2766 	 * index of that link info and get the next valid link info which is
2767 	 * set to active.
2768 	 * If @link_info points to invalid address, then start the search
2769 	 * for active link info from WLAN_HDD_DEFLINK_IDX index.
2770 	 */
2771 	if (*link_info)
2772 		link_idx = hdd_adapter_get_index_of_link_info(*link_info) + 1;
2773 
2774 	*link_info = NULL;
2775 	link_idx_max = QDF_ARRAY_SIZE(adapter->link_info);
2776 	while (link_idx < link_idx_max && !(*link_info)) {
2777 		*link_info = hdd_adapter_get_link_info_if_active(adapter,
2778 								 link_idx);
2779 		link_idx++;
2780 	}
2781 }
2782 
2783 /**
2784  * hdd_adapter_for_each_active_link_info() - Link info iterator which loops
2785  * through the link info array elements which are set to active.
2786  * @adapter: HDD adapter to iterate for each active link info pointer.
2787  * @link_info: Pointer of active link info.
2788  *
2789  * The "active_links" bitmap in @adapter says which indices are active
2790  * in the link info array.
2791  * The MACRO iterates through all the active link info elements in link info
2792  * array and ends loop when no more active link info entries are present.
2793  * The @link_info points next active link info pointer on each iteration or
2794  * NULL value at the end of the loop.
2795  *
2796  * Callers to take reference of adapter if needed.
2797  */
2798 #define hdd_adapter_for_each_active_link_info(adapter, link_info) \
2799 	for (__hdd_adapter_get_first_active_link_info(adapter, link_info); \
2800 	     __hdd_is_link_info_valid(link_info); \
2801 	     hdd_adapter_get_next_active_link_info(adapter, &link_info))
2802 
2803 #define __hdd_adapter_get_firstlink(adapter, __link_info)	\
2804 		(__link_info = adapter ? &((adapter)->link_info[0]) : NULL)
2805 
2806 #define __hdd_is_link_info_idx_valid(adapter, __link_info) \
2807 	((__link_info - &(adapter)->link_info[0]) < \
2808 					QDF_ARRAY_SIZE((adapter)->link_info))
2809 
2810 #define __hdd_adapter_next_link_info(link_info)	((link_info)++)
2811 
2812 /**
2813  * hdd_adapter_for_each_link_info() - Link info iterator for all
2814  * link_info fields.
2815  * @adapter: HDD adapter to iterate each link_info.
2816  * @link_info: Pointer to each link info element in the array.
2817  *
2818  * The function iterates from the start index of link_info array
2819  * in @adapter till the end of the link_info array.
2820  *
2821  * Callers to take reference of adapter if needed.
2822  */
2823 
2824 #define hdd_adapter_for_each_link_info(adapter, link_info) \
2825 	for (__hdd_adapter_get_firstlink(adapter, link_info); \
2826 	     __hdd_is_link_info_valid(link_info) && \
2827 	     __hdd_is_link_info_idx_valid(adapter, link_info); \
2828 	     __hdd_adapter_next_link_info(link_info))
2829 
2830 /**
2831  * wlan_hdd_get_link_info_from_objmgr() - Fetch adapter from objmgr
2832  * @vdev: the vdev whose corresponding adapter has to be fetched
2833  *
2834  * Return: Address of link info pointer in HDD adapter corresponding to VDEV
2835  */
2836 struct wlan_hdd_link_info *
2837 wlan_hdd_get_link_info_from_objmgr(struct wlan_objmgr_vdev *vdev);
2838 
2839 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC) && \
2840 	defined(WLAN_HDD_MULTI_VDEV_SINGLE_NDEV)
2841 /**
2842  * hdd_adapter_disable_all_links() - Reset the links on stop adapter.
2843  * @adapter: HDD adapter
2844  * @clear_macaddr: Clears mac address if set to true
2845  *
2846  * Resets the MAC address in each link info and resets the link info
2847  * mapping in adapter array.
2848  *
2849  * Return: void
2850  */
2851 void
2852 hdd_adapter_disable_all_links(struct hdd_adapter *adapter, bool clear_macaddr);
2853 #else
2854 static inline void
hdd_adapter_disable_all_links(struct hdd_adapter * adapter,bool clear_macaddr)2855 hdd_adapter_disable_all_links(struct hdd_adapter *adapter, bool clear_macaddr)
2856 {
2857 }
2858 #endif
2859 
2860 struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx,
2861 				     uint8_t session_type,
2862 				     const char *name, tSirMacAddr mac_addr,
2863 				     unsigned char name_assign_type,
2864 				     bool rtnl_held,
2865 				     struct hdd_adapter_create_param *params);
2866 
2867 QDF_STATUS hdd_open_adapter_no_trans(struct hdd_context *hdd_ctx,
2868 				     enum QDF_OPMODE op_mode,
2869 				     const char *iface_name,
2870 				     uint8_t *mac_addr_bytes,
2871 				     struct hdd_adapter_create_param *params);
2872 /**
2873  * hdd_close_adapter() - remove and free @adapter from the adapter list
2874  * @hdd_ctx: The Hdd context containing the adapter list
2875  * @adapter: the adapter to remove and free
2876  * @rtnl_held: if the caller is already holding the RTNL lock
2877  *
2878  * Return: None
2879  */
2880 void hdd_close_adapter(struct hdd_context *hdd_ctx,
2881 		       struct hdd_adapter *adapter,
2882 		       bool rtnl_held);
2883 
2884 /**
2885  * hdd_close_all_adapters() - remove and free all adapters from the adapter list
2886  * @hdd_ctx: The Hdd context containing the adapter list
2887  * @rtnl_held: if the caller is already holding the RTNL lock
2888  *
2889  * Return: None
2890  */
2891 void hdd_close_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held);
2892 
2893 QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx);
2894 void hdd_deinit_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held);
2895 QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx);
2896 QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held);
2897 
2898 /**
2899  * hdd_get_link_info_by_vdev() - Return link info with the given vdev id
2900  * @hdd_ctx: hdd context.
2901  * @vdev_id: vdev id for the link info to get.
2902  *
2903  * This function is used to get the link info with provided vdev id
2904  *
2905  * Return: adapter pointer if found
2906  *
2907  */
2908 struct wlan_hdd_link_info *
2909 hdd_get_link_info_by_vdev(struct hdd_context *hdd_ctx, uint32_t vdev_id);
2910 
2911 /**
2912  * hdd_adapter_get_by_reference() - Return adapter with the given reference
2913  * @hdd_ctx: hdd context
2914  * @reference: reference for the adapter to get
2915  *
2916  * This function is used to get the adapter with provided reference.
2917  * The adapter reference will be held until being released by calling
2918  * hdd_adapter_put().
2919  *
2920  * Return: adapter pointer if found
2921  *
2922  */
2923 struct hdd_adapter *hdd_adapter_get_by_reference(struct hdd_context *hdd_ctx,
2924 						 struct hdd_adapter *reference);
2925 
2926 /**
2927  * hdd_adapter_put() - Release reference to adapter
2928  * @adapter: adapter reference
2929  *
2930  * Release reference to adapter previously acquired via
2931  * hdd_adapter_get_*() function
2932  */
2933 void hdd_adapter_put(struct hdd_adapter *adapter);
2934 
2935 /**
2936  * hdd_get_link_info_by_link_addr() - Get the link info pointer where
2937  * the link address matches.
2938  * @hdd_ctx: HDD context pointer
2939  * @link_addr: Link address to search
2940  *
2941  * In the given @adapter search for @link_addr in each entry of link_info
2942  * array, and return the matching link_info pointer.
2943  *
2944  * Return: NULL / Valid link info pointer
2945  */
2946 struct wlan_hdd_link_info *
2947 hdd_get_link_info_by_link_addr(struct hdd_context *hdd_ctx,
2948 			       struct qdf_mac_addr *link_addr);
2949 
2950 struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx,
2951 					       tSirMacAddr mac_addr);
2952 
2953 /**
2954  * hdd_get_link_info_home_channel() - return home channel of adapter
2955  * @link_info: Pointer of link_info in @adapter
2956  *
2957  * This function returns operation channel of station/p2p-cli if
2958  * connected, returns operation channel of sap/p2p-go if started.
2959  *
2960  * Return: home channel if connected/started or invalid channel 0
2961  */
2962 uint32_t hdd_get_link_info_home_channel(struct wlan_hdd_link_info *link_info);
2963 
2964 /**
2965  * hdd_get_link_info_width() - return current bandwidth of adapter
2966  * @link_info: Pointer of link_info in @adapter
2967  *
2968  * This function returns current bandwidth of station/p2p-cli if
2969  * connected, returns current bandwidth of sap/p2p-go if started.
2970  *
2971  * Return: bandwidth if connected/started or invalid bandwidth 0
2972  */
2973 enum phy_ch_width hdd_get_link_info_width(struct wlan_hdd_link_info *link_info);
2974 
2975 /*
2976  * hdd_get_adapter_by_rand_macaddr() - find Random mac adapter
2977  * @hdd_ctx: hdd context
2978  * @mac_addr: random mac addr
2979  *
2980  * Find the Adapter based on random mac addr. Adapter's vdev
2981  * have active random mac list.
2982  *
2983  * Return: adapter ptr or null
2984  */
2985 struct hdd_adapter *
2986 hdd_get_adapter_by_rand_macaddr(struct hdd_context *hdd_ctx,
2987 				tSirMacAddr mac_addr);
2988 
2989 /**
2990  * hdd_adapter_update_mlo_mgr_mac_addr() - Update each link address to MLO mgr.
2991  * @adapter: HDD adapter
2992  *
2993  * Update MLO manager with each link address and corresponding VDEV ID.
2994  * Only update for ML-STA adapter types.
2995  *
2996  * Return: void
2997  */
2998 void hdd_adapter_update_mlo_mgr_mac_addr(struct hdd_adapter *adapter);
2999 
3000 /**
3001  * hdd_is_vdev_in_conn_state() - Check whether the vdev is in
3002  * connected/started state.
3003  * @link_info: Pointer to link_info in adapter
3004  *
3005  * This function will give whether the vdev in the adapter is in
3006  * connected/started state.
3007  *
3008  * Return: True/false
3009  */
3010 bool hdd_is_vdev_in_conn_state(struct wlan_hdd_link_info *link_info);
3011 
3012 /**
3013  * hdd_adapter_deregister_fc() - Deregisters flow control
3014  * callbacks
3015  * @adapter: HDD adapter
3016  *
3017  * The function call deregisters flow control callbacks
3018  *
3019  * Return: void
3020  */
3021 void hdd_adapter_deregister_fc(struct hdd_adapter *adapter);
3022 
3023 #ifdef WLAN_OPEN_SOURCE
3024 /**
3025  * hdd_cancel_ip_notifier_work() - Cancel scheduled IP
3026  * notifier deferred work
3027  * @adapter: HDD adapter
3028  *
3029  * The API calls cancel work for IPv4 and IPv6 notifier
3030  * deferred task
3031  *
3032  * Return: void
3033  */
3034 void hdd_cancel_ip_notifier_work(struct hdd_adapter *adapter);
3035 #else
3036 static inline
hdd_cancel_ip_notifier_work(struct hdd_adapter * adapter)3037 void hdd_cancel_ip_notifier_work(struct hdd_adapter *adapter)
3038 {
3039 }
3040 #endif
3041 
3042 /**
3043  * hdd_vdev_create() - Create the vdev in the firmware
3044  * @link_info: Link info pointer in HDD adapter
3045  *
3046  * This function will create the vdev in the firmware
3047  *
3048  * Return: 0 when the vdev create is sent to firmware or -EINVAL when
3049  * there is a failure to send the command.
3050  */
3051 int hdd_vdev_create(struct wlan_hdd_link_info *link_info);
3052 
3053 /**
3054  * hdd_vdev_destroy() - Destroy the vdev in the firmware
3055  * @link_info: Link info pointer in HDD adapter
3056  *
3057  * This function will destroy the vdev in the firmware
3058  *
3059  * Return: 0 when the vdev destroy is sent to firmware
3060  * or -EINVAL when there is a failure to send the command.
3061  */
3062 int hdd_vdev_destroy(struct wlan_hdd_link_info *link_info);
3063 
3064 /**
3065  * hdd_vdev_ready() - Configure FW post VDEV create
3066  * @vdev: VDEV object.
3067  * @bridgeaddr: Bridge MAC address
3068  *
3069  * The function is used send configuration to the FW
3070  * post VDEV creation.
3071  * The caller to ensure to hold the VDEV reference
3072  *
3073  * Return: 0 on success, negative value on failure.
3074  */
3075 int hdd_vdev_ready(struct wlan_objmgr_vdev *vdev,
3076 		   struct qdf_mac_addr *bridgeaddr);
3077 
3078 /**
3079  * hdd_init_station_mode() - Initialize STA mode adapter
3080  * post vdev creation.
3081  * @link_info: Link info pointer in HDD adapter
3082  *
3083  * The function initializes the adapter post vdev
3084  * create for STA mode type adapters on start
3085  * adapter.
3086  *
3087  * Return: QDF_STATUS
3088  */
3089 QDF_STATUS hdd_init_station_mode(struct wlan_hdd_link_info *link_info);
3090 
3091 struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx,
3092 			enum QDF_OPMODE mode);
3093 
3094 /**
3095  * hdd_get_device_mode() - Get device mode
3096  * @vdev_id: vdev id
3097  *
3098  * Return: Device mode
3099  */
3100 enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id);
3101 
3102 /**
3103  * hdd_deinit_session() - Cleanup session context in
3104  * adapter
3105  * @adapter: HDD adapter
3106  *
3107  * The API cleans up session context and scan IEs
3108  * in link_info and adapter.
3109  *
3110  * Return: None
3111  */
3112 void hdd_deinit_session(struct hdd_adapter *adapter);
3113 
3114 void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
3115 			struct hdd_adapter *adapter,
3116 			bool rtnl_held);
3117 QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx,
3118 			    struct hdd_adapter *adapter);
3119 
3120 /**
3121  * hdd_set_station_ops() - update net_device ops
3122  * @dev: Handle to struct net_device to be updated.
3123  * Return: None
3124  */
3125 void hdd_set_station_ops(struct net_device *dev);
3126 
3127 /**
3128  * wlan_hdd_get_intf_addr() - Get address for the interface
3129  * @hdd_ctx: Pointer to hdd context
3130  * @interface_type: type of the interface for which address is queried
3131  *
3132  * This function is used to get mac address for every new interface
3133  *
3134  * Return: If addr is present then return pointer to MAC address
3135  *         else NULL
3136  */
3137 
3138 uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx,
3139 				enum QDF_OPMODE interface_type);
3140 void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx,
3141 				uint8_t *releaseAddr);
3142 
3143 /**
3144  * hdd_get_operating_chan_freq() - return operating channel of the device mode
3145  * @hdd_ctx:	Pointer to the HDD context.
3146  * @mode:	Device mode for which operating channel is required.
3147  *              Supported modes:
3148  *			QDF_STA_MODE,
3149  *			QDF_P2P_CLIENT_MODE,
3150  *			QDF_SAP_MODE,
3151  *			QDF_P2P_GO_MODE.
3152  *
3153  * This API returns the operating channel of the requested device mode
3154  *
3155  * Return: channel frequency, or
3156  *         0 if the requested device mode is not found.
3157  */
3158 uint32_t hdd_get_operating_chan_freq(struct hdd_context *hdd_ctx,
3159 				     enum QDF_OPMODE mode);
3160 
3161 void hdd_set_conparam(int32_t con_param);
3162 enum QDF_GLOBAL_MODE hdd_get_conparam(void);
3163 
3164 /**
3165  * wlan_hdd_reset_prob_rspies() - Reset probe response IEs
3166  * @link_info: Link info pointer in HDD adapter.
3167  *
3168  * Reset the probe response IEs for the VDEV pointer by link info.
3169  *
3170  * Return: void
3171  */
3172 void wlan_hdd_reset_prob_rspies(struct wlan_hdd_link_info *link_info);
3173 void hdd_prevent_suspend(uint32_t reason);
3174 
3175 /*
3176  * hdd_get_first_valid_adapter() - Get the first valid adapter from adapter list
3177  *
3178  * This function is used to fetch the first valid adapter from the adapter
3179  * list. If there is no valid adapter then it returns NULL
3180  *
3181  * @hdd_ctx: HDD context handler
3182  *
3183  * Return: NULL if no valid adapter found in the adapter list
3184  *
3185  */
3186 struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx);
3187 
3188 void hdd_allow_suspend(uint32_t reason);
3189 void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason);
3190 
3191 /**
3192  * wlan_hdd_validate_context() - check the HDD context
3193  * @hdd_ctx: Global HDD context pointer
3194  *
3195  * Return: 0 if the context is valid. Error code otherwise
3196  */
3197 #define wlan_hdd_validate_context(hdd_ctx) \
3198 	__wlan_hdd_validate_context(hdd_ctx, __func__)
3199 
3200 int __wlan_hdd_validate_context(struct hdd_context *hdd_ctx, const char *func);
3201 
3202 /**
3203  * hdd_validate_adapter() - Validate the given adapter
3204  * @adapter: the adapter to validate
3205  *
3206  * This function validates the given adapter, and ensures that it is open.
3207  *
3208  * Return: Errno
3209  */
3210 #define hdd_validate_adapter(adapter) \
3211 	__hdd_validate_adapter(adapter, __func__)
3212 
3213 int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func);
3214 
3215 /**
3216  * wlan_hdd_validate_vdev_id() - ensure the given vdev Id is valid
3217  * @vdev_id: the vdev Id to validate
3218  *
3219  * Return: Errno
3220  */
3221 #define wlan_hdd_validate_vdev_id(vdev_id) \
3222 	__wlan_hdd_validate_vdev_id(vdev_id, __func__)
3223 
3224 int __wlan_hdd_validate_vdev_id(uint8_t vdev_id, const char *func);
3225 
3226 /**
3227  * hdd_is_valid_mac_address() - validate MAC address
3228  * @mac_addr:	Pointer to the input MAC address
3229  *
3230  * This function validates whether the given MAC address is valid or not
3231  * Expected MAC address is of the format XX:XX:XX:XX:XX:XX
3232  * where X is the hexa decimal digit character and separated by ':'
3233  * This algorithm works even if MAC address is not separated by ':'
3234  *
3235  * This code checks given input string mac contains exactly 12 hexadecimal
3236  * digits and a separator colon : appears in the input string only after
3237  * an even number of hex digits.
3238  *
3239  * Return: true for valid and false for invalid
3240  */
3241 bool hdd_is_valid_mac_address(const uint8_t *mac_addr);
3242 
3243 bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx);
3244 
3245 /**
3246  * wlan_hdd_validate_mac_address() - Function to validate mac address
3247  * @mac_addr: input mac address
3248  *
3249  * Return QDF_STATUS
3250  */
3251 #define wlan_hdd_validate_mac_address(mac_addr) \
3252 	__wlan_hdd_validate_mac_address(mac_addr, __func__)
3253 
3254 QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr,
3255 					   const char *func);
3256 
3257 /**
3258  * hdd_is_any_adapter_connected() - Check if any adapter is in connected state
3259  * @hdd_ctx: the global hdd context
3260  *
3261  * Returns: true, if any of the adapters is in connected state,
3262  *	    false, if none of the adapters is in connected state.
3263  */
3264 bool hdd_is_any_adapter_connected(struct hdd_context *hdd_ctx);
3265 
3266 /**
3267  * hdd_init_adapter_ops_wq() - Init global workqueue for adapter operations.
3268  * @hdd_ctx: pointer to HDD context
3269  *
3270  * Return: QDF_STATUS_SUCCESS if workqueue is allocated,
3271  *	   QDF_STATUS_E_NOMEM if workqueue aloocation fails.
3272  */
3273 QDF_STATUS hdd_init_adapter_ops_wq(struct hdd_context *hdd_ctx);
3274 
3275 /**
3276  * hdd_deinit_adapter_ops_wq() - Deinit global workqueue for adapter operations.
3277  * @hdd_ctx: pointer to HDD context
3278  *
3279  * Return: None
3280  */
3281 void hdd_deinit_adapter_ops_wq(struct hdd_context *hdd_ctx);
3282 
3283 /**
3284  * hdd_adapter_feature_update_work_init() - Init per adapter work for netdev
3285  *					    feature update
3286  * @adapter: pointer to adapter structure
3287  *
3288  * Return: QDF_STATUS
3289  */
3290 QDF_STATUS hdd_adapter_feature_update_work_init(struct hdd_adapter *adapter);
3291 
3292 /**
3293  * hdd_adapter_feature_update_work_deinit() - Deinit per adapter work for
3294  *					      netdev feature update
3295  * @adapter: pointer to adapter structure
3296  *
3297  * Return: QDF_STATUS
3298  */
3299 void hdd_adapter_feature_update_work_deinit(struct hdd_adapter *adapter);
3300 
3301 int hdd_qdf_trace_enable(QDF_MODULE_ID module_id, uint32_t bitmask);
3302 
3303 int hdd_init(void);
3304 void hdd_deinit(void);
3305 
3306 /**
3307  * hdd_wlan_startup() - HDD init function
3308  * @hdd_ctx: the HDD context corresponding to the psoc to startup
3309  *
3310  * Return: Errno
3311  */
3312 int hdd_wlan_startup(struct hdd_context *hdd_ctx);
3313 
3314 /**
3315  * hdd_wlan_exit() - HDD WLAN exit function
3316  * @hdd_ctx: pointer to the HDD Context
3317  *
3318  * Return: None
3319  */
3320 void hdd_wlan_exit(struct hdd_context *hdd_ctx);
3321 
3322 /**
3323  * hdd_psoc_create_vdevs() - create the default vdevs for a psoc
3324  * @hdd_ctx: the HDD context for the psoc to operate against
3325  *
3326  * Return: QDF_STATUS
3327  */
3328 QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx);
3329 
3330 /*
3331  * hdd_context_create() - Allocate and inialize HDD context.
3332  * @dev: Device Pointer to the underlying device
3333  *
3334  * Allocate and initialize HDD context. HDD context is allocated as part of
3335  * wiphy allocation and then context is initialized.
3336  *
3337  * Return: HDD context on success and ERR_PTR on failure
3338  */
3339 struct hdd_context *hdd_context_create(struct device *dev);
3340 
3341 /**
3342  * hdd_context_destroy() - Destroy HDD context
3343  * @hdd_ctx: HDD context to be destroyed.
3344  *
3345  * Free config and HDD context as well as destroy all the resources.
3346  *
3347  * Return: None
3348  */
3349 void hdd_context_destroy(struct hdd_context *hdd_ctx);
3350 
3351 int hdd_wlan_notify_modem_power_state(int state);
3352 
3353 void wlan_hdd_send_svc_nlink_msg(int radio, int type, void *data, int len);
3354 #ifdef FEATURE_WLAN_AUTO_SHUTDOWN
3355 void wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable);
3356 #else
3357 static inline void
wlan_hdd_auto_shutdown_enable(struct hdd_context * hdd_ctx,bool enable)3358 wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable)
3359 {
3360 }
3361 #endif
3362 
3363 struct hdd_adapter *
3364 hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter,
3365 			bool check_start_bss);
3366 
3367 bool hdd_is_5g_supported(struct hdd_context *hdd_ctx);
3368 
3369 /**
3370  * hdd_is_2g_supported() - check if 2GHz channels are supported
3371  * @hdd_ctx:	Pointer to the hdd context
3372  *
3373  * HDD function to know if 2GHz channels are supported
3374  *
3375  * Return:  true if 2GHz channels are supported
3376  */
3377 bool hdd_is_2g_supported(struct hdd_context *hdd_ctx);
3378 
3379 /**
3380  * wlan_hdd_scan_abort() - abort ongoing scan
3381  * @link_info: Link info pointer in HDD adapter
3382  *
3383  * Return: 0 for success, non zero for failure
3384  */
3385 int wlan_hdd_scan_abort(struct wlan_hdd_link_info *link_info);
3386 
3387 /**
3388  * hdd_indicate_active_ndp_cnt() - Callback to indicate active ndp count to hdd
3389  * if ndp connection is on NDI established
3390  * @psoc: pointer to psoc object
3391  * @vdev_id: vdev id
3392  * @cnt: number of active ndp sessions
3393  *
3394  * This HDD callback registered with policy manager to indicates number of active
3395  * ndp sessions to hdd.
3396  *
3397  * Return:  none
3398  */
3399 void hdd_indicate_active_ndp_cnt(struct wlan_objmgr_psoc *psoc,
3400 				 uint8_t vdev_id, uint8_t cnt);
3401 
3402 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
roaming_offload_enabled(struct hdd_context * hdd_ctx)3403 static inline bool roaming_offload_enabled(struct hdd_context *hdd_ctx)
3404 {
3405 	bool is_roam_offload;
3406 
3407 	ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &is_roam_offload);
3408 
3409 	return is_roam_offload;
3410 }
3411 #else
roaming_offload_enabled(struct hdd_context * hdd_ctx)3412 static inline bool roaming_offload_enabled(struct hdd_context *hdd_ctx)
3413 {
3414 	return false;
3415 }
3416 #endif
3417 
3418 #ifdef WLAN_FEATURE_HOST_ROAM
hdd_driver_roaming_supported(struct hdd_context * hdd_ctx)3419 static inline bool hdd_driver_roaming_supported(struct hdd_context *hdd_ctx)
3420 {
3421 	bool lfr_enabled;
3422 
3423 	ucfg_mlme_is_lfr_enabled(hdd_ctx->psoc, &lfr_enabled);
3424 
3425 	return lfr_enabled;
3426 }
3427 #else
hdd_driver_roaming_supported(struct hdd_context * hdd_ctx)3428 static inline bool hdd_driver_roaming_supported(struct hdd_context *hdd_ctx)
3429 {
3430 	return false;
3431 }
3432 #endif
3433 
hdd_roaming_supported(struct hdd_context * hdd_ctx)3434 static inline bool hdd_roaming_supported(struct hdd_context *hdd_ctx)
3435 {
3436 	bool val;
3437 
3438 	val = hdd_driver_roaming_supported(hdd_ctx) ||
3439 		roaming_offload_enabled(hdd_ctx);
3440 
3441 	return val;
3442 }
3443 
3444 #ifdef WLAN_NS_OFFLOAD
3445 static inline void
hdd_adapter_flush_ipv6_notifier_work(struct hdd_adapter * adapter)3446 hdd_adapter_flush_ipv6_notifier_work(struct hdd_adapter *adapter)
3447 {
3448 	flush_work(&adapter->ipv6_notifier_work);
3449 }
3450 #else
3451 static inline void
hdd_adapter_flush_ipv6_notifier_work(struct hdd_adapter * adapter)3452 hdd_adapter_flush_ipv6_notifier_work(struct hdd_adapter *adapter)
3453 {
3454 }
3455 #endif
3456 
3457 #ifdef CFG80211_SCAN_RANDOM_MAC_ADDR
hdd_scan_random_mac_addr_supported(void)3458 static inline bool hdd_scan_random_mac_addr_supported(void)
3459 {
3460 	return true;
3461 }
3462 #else
hdd_scan_random_mac_addr_supported(void)3463 static inline bool hdd_scan_random_mac_addr_supported(void)
3464 {
3465 	return false;
3466 }
3467 #endif
3468 
3469 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
hdd_dynamic_mac_addr_supported(struct hdd_context * hdd_ctx)3470 static inline bool hdd_dynamic_mac_addr_supported(struct hdd_context *hdd_ctx)
3471 {
3472 	return hdd_ctx->is_vdev_macaddr_dynamic_update_supported;
3473 }
3474 #else
hdd_dynamic_mac_addr_supported(struct hdd_context * hdd_ctx)3475 static inline bool hdd_dynamic_mac_addr_supported(struct hdd_context *hdd_ctx)
3476 {
3477 	return false;
3478 }
3479 #endif
3480 
3481 /**
3482  * hdd_adapter_get_link_info_ptr() - To get the pointer of link_info
3483  * in adapter.
3484  * @adapter: HDD adapter
3485  * @link_idx: Index of link_info in @adapter.
3486  *
3487  * The API returns link_info in @adapter pointed at @link_idx in the array.
3488  *
3489  * Return: Pointer to wlan_hdd_link_info or NULL.
3490  */
3491 static inline struct wlan_hdd_link_info *
hdd_adapter_get_link_info_ptr(struct hdd_adapter * adapter,uint8_t link_idx)3492 hdd_adapter_get_link_info_ptr(struct hdd_adapter *adapter, uint8_t link_idx)
3493 {
3494 	if (!adapter || (link_idx >= QDF_ARRAY_SIZE(adapter->link_info)))
3495 		return NULL;
3496 
3497 	return &adapter->link_info[link_idx];
3498 }
3499 
3500 /**
3501  * hdd_start_vendor_acs(): Start vendor ACS procedure
3502  * @adapter: pointer to SAP adapter struct
3503  *
3504  * This function sends the ACS config to the ACS daemon and
3505  * starts the vendor ACS timer to wait for the next command.
3506  *
3507  * Return: Status of vendor ACS procedure
3508  */
3509 int hdd_start_vendor_acs(struct hdd_adapter *adapter);
3510 
3511 /**
3512  * hdd_acs_response_timeout_handler() - timeout handler for acs_timer
3513  * @context: timeout handler context
3514  *
3515  * Return: None
3516  */
3517 void hdd_acs_response_timeout_handler(void *context);
3518 
3519 /**
3520  * wlan_hdd_cfg80211_start_acs(): Start ACS Procedure for SAP
3521  * @link_info: Link info pointer in HDD adapter
3522  *
3523  * This function starts the ACS procedure if there are no
3524  * constraints like MBSSID DFS restrictions.
3525  *
3526  * Return: Status of ACS Start procedure
3527  */
3528 int wlan_hdd_cfg80211_start_acs(struct wlan_hdd_link_info *link_info);
3529 
3530 /**
3531  * wlan_hdd_trim_acs_channel_list() - Trims ACS channel list with
3532  * intersection of PCL
3533  * @pcl: preferred channel list
3534  * @pcl_count: Preferred channel list count
3535  * @org_freq_list: ACS channel list from user space
3536  * @org_ch_list_count: ACS channel count from user space
3537  *
3538  * Return: None
3539  */
3540 void wlan_hdd_trim_acs_channel_list(uint32_t *pcl, uint8_t pcl_count,
3541 				    uint32_t *org_freq_list,
3542 				    uint8_t *org_ch_list_count);
3543 
3544 /**
3545  * wlan_hdd_handle_zero_acs_list() - Handle worst case of ACS channel
3546  * trimmed to zero
3547  * @hdd_ctx: struct hdd_context
3548  * @acs_freq_list: Calculated ACS channel list
3549  * @acs_ch_list_count: Calculated ACS channel count
3550  * @org_freq_list: ACS channel list from user space
3551  * @org_ch_list_count: ACS channel count from user space
3552  *
3553  * When all channels in the ACS freq list is filtered out by
3554  * wlan_hdd_trim_acs_channel_list(), the hostapd start will fail.
3555  * This happens when PCL is PM_24G_SCC_CH_SBS_CH, and SAP ACS range
3556  * includes 5 GHz channel list. One example is STA active on 6 GHz
3557  * chan. Hostapd start SAP on 5 GHz ACS range. The intersection of PCL
3558  * and ACS range is zero.  Instead of ACS failure, this API selects
3559  * one channel from ACS range and report to Hostapd. When hostapd do
3560  * start_ap, the driver will force SCC to 6 GHz or move SAP to 2 GHz
3561  * based on SAP's configuration.
3562  *
3563  * Return: None
3564  */
3565 void wlan_hdd_handle_zero_acs_list(struct hdd_context *hdd_ctx,
3566 				   uint32_t *acs_freq_list,
3567 				   uint8_t *acs_ch_list_count,
3568 				   uint32_t *org_freq_list,
3569 				   uint8_t org_ch_list_count);
3570 
3571 /**
3572  * hdd_cfg80211_update_acs_config() - update acs config to application
3573  * @adapter: hdd adapter
3574  * @reason: channel change reason
3575  *
3576  * Return: 0 for success else error code
3577  */
3578 int hdd_cfg80211_update_acs_config(struct hdd_adapter *adapter,
3579 				   uint8_t reason);
3580 
3581 /**
3582  * hdd_update_acs_timer_reason() - update acs timer start reason
3583  * @adapter: hdd adapter
3584  * @reason: channel change reason
3585  *
3586  * Return: 0 for success
3587  */
3588 int hdd_update_acs_timer_reason(struct hdd_adapter *adapter, uint8_t reason);
3589 
3590 /**
3591  * hdd_switch_sap_channel() - Move SAP to the given channel
3592  * @link_info: Pointer of link_info in adapter
3593  * @channel: Channel
3594  * @forced: Force to switch channel, ignore SCC/MCC check
3595  *
3596  * Moves the SAP interface by invoking the function which
3597  * executes the callback to perform channel switch using (E)CSA.
3598  *
3599  * Return: QDF_STATUS
3600  */
3601 QDF_STATUS hdd_switch_sap_channel(struct wlan_hdd_link_info *link_info,
3602 				  uint8_t channel, bool forced);
3603 
3604 /**
3605  * hdd_switch_sap_chan_freq() - Move SAP to the given channel
3606  * @adapter: AP adapter
3607  * @chan_freq: Channel frequency
3608  * @ch_width: channel bandwidth
3609  * @forced: Force to switch channel, ignore SCC/MCC check
3610  *
3611  * Moves the SAP interface by invoking the function which
3612  * executes the callback to perform channel switch using (E)CSA.
3613  *
3614  * Return: QDF_STATUS_SUCCESS if successfully
3615  */
3616 QDF_STATUS hdd_switch_sap_chan_freq(struct hdd_adapter *adapter,
3617 				    qdf_freq_t chan_freq,
3618 				    enum phy_ch_width ch_width,
3619 				    bool forced);
3620 
3621 #if defined(FEATURE_WLAN_CH_AVOID)
3622 QDF_STATUS hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctx);
3623 
3624 void hdd_ch_avoid_ind(struct hdd_context *hdd_ctxt,
3625 		      struct unsafe_ch_list *unsafe_chan_list,
3626 		      struct ch_avoid_ind_type *avoid_freq_list);
3627 #else
3628 static inline
hdd_unsafe_channel_restart_sap(struct hdd_context * hdd_ctx)3629 QDF_STATUS hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctx)
3630 {
3631 	return QDF_STATUS_SUCCESS;
3632 }
3633 
3634 static inline
hdd_ch_avoid_ind(struct hdd_context * hdd_ctxt,struct unsafe_ch_list * unsafe_chan_list,struct ch_avoid_ind_type * avoid_freq_list)3635 void hdd_ch_avoid_ind(struct hdd_context *hdd_ctxt,
3636 		      struct unsafe_ch_list *unsafe_chan_list,
3637 		      struct ch_avoid_ind_type *avoid_freq_list)
3638 {
3639 }
3640 #endif
3641 
3642 /**
3643  * hdd_free_mac_address_lists() - Free both the MAC address lists
3644  * @hdd_ctx: HDD context
3645  *
3646  * This API clears/memset provisioned address list and
3647  * derived address list
3648  *
3649  */
3650 void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx);
3651 
3652 /**
3653  * hdd_update_macaddr() - update mac address
3654  * @hdd_ctx:	hdd contxt
3655  * @hw_macaddr:	mac address
3656  * @generate_mac_auto: Indicates whether the first address is
3657  * provisioned address or derived address.
3658  *
3659  * Mac address for multiple virtual interface is found as following
3660  * i) The mac address of the first interface is just the actual hw mac address.
3661  * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to
3662  *     define the mac address for the remaining interfaces and locally
3663  *     admistered bit is set. INTF_MACADDR_MASK is based on the number of
3664  *     supported virtual interfaces, right now this is 0x07 (meaning 8
3665  *     interface).
3666  *     Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1,
3667  *     for third interface it will be hw_macaddr[3](bit5..7) + 2, etc.
3668  *
3669  * Return: None
3670  */
3671 void hdd_update_macaddr(struct hdd_context *hdd_ctx,
3672 			struct qdf_mac_addr hw_macaddr, bool generate_mac_auto);
3673 
3674 /**
3675  * hdd_store_nss_chains_cfg_in_vdev() - Store the per vdev ini cfg in vdev_obj
3676  * @hdd_ctx: HDD context passed from caller
3677  * @vdev: VDEV passed with caller holding reference.
3678  *
3679  * This function will store the per vdev nss params to the particular mlme
3680  * vdev obj.
3681  * Caller shall acquire the reference for vdev objmgr and release on return.
3682  *
3683  * Return: None
3684  */
3685 void
3686 hdd_store_nss_chains_cfg_in_vdev(struct hdd_context *hdd_ctx,
3687 				 struct wlan_objmgr_vdev *vdev);
3688 
3689 /**
3690  * wlan_hdd_set_roaming_state() - Enable or disable roaming
3691  * on all STAs except the input one
3692  * @cur_link_info: Current link info pointer in HDD adapter
3693  * @rso_op_requestor: roam disable requestor
3694  * @enab_roam: Set to true to enable roaming or else set false
3695  *
3696  * This function loops through all adapters and enables or
3697  * disables roaming on each STA mode adapter except the
3698  * current adapter passed from the caller.
3699  * If @enab_roam is true, roaming is enabled or else
3700  * roaming is disabled
3701  *
3702  * Return: None
3703  */
3704 void
3705 wlan_hdd_set_roaming_state(struct wlan_hdd_link_info *cur_link_info,
3706 			   enum wlan_cm_rso_control_requestor rso_op_requestor,
3707 			   bool enab_roam);
3708 
3709 QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx);
3710 
3711 QDF_STATUS hdd_abort_mac_scan_all_adapters(struct hdd_context *hdd_ctx);
3712 
3713 void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter);
3714 
3715 /**
3716  * wlan_hdd_start_sap() - this function starts bss of SAP.
3717  * @link_info: Link info pointer in SAP/GO adapter
3718  * @reinit: true if this is a re-init, otherwise initial int
3719  *
3720  * This function will process the starting of sap adapter.
3721  *
3722  * Return: None
3723  */
3724 void wlan_hdd_start_sap(struct wlan_hdd_link_info *link_info, bool reinit);
3725 
3726 /**
3727  * wlan_hdd_set_sap_beacon_protection() - this function will set beacon
3728  * protection for SAP.
3729  * @hdd_ctx: pointer to HDD context
3730  * @link_info: Link info pointer
3731  * @beacon: pointer to beacon data structure
3732  *
3733  * This function will enable beacon protection and cache the value in vdev
3734  * priv object.
3735  *
3736  * Return: None
3737  */
3738 void wlan_hdd_set_sap_beacon_protection(struct hdd_context *hdd_ctx,
3739 					struct wlan_hdd_link_info *link_info,
3740 					struct hdd_beacon_data *beacon);
3741 #ifdef QCA_CONFIG_SMP
3742 int wlan_hdd_get_cpu(void);
3743 #else
wlan_hdd_get_cpu(void)3744 static inline int wlan_hdd_get_cpu(void)
3745 {
3746 	return 0;
3747 }
3748 #endif
3749 
3750 void wlan_hdd_txrx_pause_cb(uint8_t vdev_id,
3751 	enum netif_action_type action, enum netif_reason_type reason);
3752 
3753 #ifdef QCA_HL_NETDEV_FLOW_CONTROL
3754 void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter,
3755 			   enum netif_action_type action);
3756 #else
wlan_hdd_mod_fc_timer(struct hdd_adapter * adapter,enum netif_action_type action)3757 static inline void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter,
3758 					 enum netif_action_type action)
3759 {
3760 }
3761 #endif /* QCA_HL_NETDEV_FLOW_CONTROL */
3762 
3763 /**
3764  * hdd_wlan_dump_stats() - display dump Stats
3765  * @adapter: adapter handle
3766  * @stats_id: stats id from user
3767  *
3768  * Return: 0 => success, error code on failure
3769  */
3770 int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int stats_id);
3771 
3772 /**
3773  * hdd_wlan_clear_stats() - clear Stats
3774  * @adapter: adapter handle
3775  * @stats_id: stats id from user
3776  *
3777  * Return: 0 => success, error code on failure
3778  */
3779 int hdd_wlan_clear_stats(struct hdd_adapter *adapter, int stats_id);
3780 
3781 /**
3782  * hdd_cb_handle_to_context() - turn an HDD handle into an HDD context
3783  * @hdd_handle: HDD handle to be converted
3784  *
3785  * Return: HDD context referenced by @hdd_handle
3786  */
3787 static inline
hdd_cb_handle_to_context(hdd_cb_handle hdd_handle)3788 struct hdd_context *hdd_cb_handle_to_context(hdd_cb_handle hdd_handle)
3789 {
3790 	return (struct hdd_context *)hdd_handle;
3791 }
3792 
3793 /**
3794  * wlan_hdd_display_netif_queue_history() - display netif queue history
3795  * @context: opaque handle to hdd context
3796  * @verb_lvl: Verbosity levels for stats
3797  *
3798  * Return: none
3799  */
3800 void
3801 wlan_hdd_display_netif_queue_history(hdd_cb_handle context,
3802 				     enum qdf_stats_verbosity_level verb_lvl);
3803 
3804 /**
3805  * wlan_hdd_display_adapter_netif_queue_history() - display adapter based netif
3806  * queue history
3807  * @adapter: hdd adapter
3808  *
3809  * Return: none
3810  */
3811 void
3812 wlan_hdd_display_adapter_netif_queue_history(struct hdd_adapter *adapter);
3813 
3814 void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx);
3815 const char *hdd_get_fwpath(void);
3816 void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind);
3817 
3818 /**
3819  * hdd_get_adapter_by_iface_name() - Return adapter with given interface name
3820  * @hdd_ctx: hdd context.
3821  * @iface_name: interface name
3822  *
3823  * This function is used to get the adapter with given interface name
3824  *
3825  * Return: adapter pointer if found, NULL otherwise
3826  *
3827  */
3828 struct hdd_adapter *hdd_get_adapter_by_iface_name(struct hdd_context *hdd_ctx,
3829 						  const char *iface_name);
3830 
3831 /**
3832  * hdd_get_adapter_by_ifindex() - Return adapter associated with an ifndex
3833  * @hdd_ctx: hdd context.
3834  * @if_index: netdev interface index
3835  *
3836  * This function is used to get the adapter associated with a netdev with the
3837  * given interface index.
3838  *
3839  * Return: adapter pointer if found, NULL otherwise
3840  *
3841  */
3842 struct hdd_adapter *hdd_get_adapter_by_ifindex(struct hdd_context *hdd_ctx,
3843 					       uint32_t if_index);
3844 
3845 enum phy_ch_width hdd_map_nl_chan_width(enum nl80211_chan_width ch_width);
3846 
3847 /**
3848  * hdd_nl_to_qdf_iface_type() - map nl80211_iftype to QDF_OPMODE
3849  * @nl_type: the input NL80211 interface type to map
3850  * @out_qdf_type: the output, equivalent QDF operating mode
3851  *
3852  * Return: QDF_STATUS
3853  */
3854 QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type,
3855 				    enum QDF_OPMODE *out_qdf_type);
3856 
3857 /**
3858  * wlan_hdd_find_opclass() - Find operating class for a channel
3859  * @mac_handle: global MAC handle
3860  * @channel: channel id
3861  * @bw_offset: bandwidth offset
3862  *
3863  * Function invokes sme api to find the operating class
3864  *
3865  * Return: operating class
3866  */
3867 uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel,
3868 			      uint8_t bw_offset);
3869 
3870 int hdd_update_config(struct hdd_context *hdd_ctx);
3871 
3872 /**
3873  * hdd_update_components_config() - Initialize driver per module ini parameters
3874  * @hdd_ctx: HDD Context
3875  *
3876  * API is used to initialize components configuration parameters
3877  * Return: 0 for success, errno for failure
3878  */
3879 int hdd_update_components_config(struct hdd_context *hdd_ctx);
3880 
3881 /**
3882  * hdd_chan_change_notify_work_handler() - Function to notify hostapd about
3883  * channel change
3884  * @work: work pointer
3885  *
3886  * This function is used to notify hostapd about the channel change
3887  *
3888  * Return: None
3889  *
3890  */
3891 void hdd_chan_change_notify_work_handler(void *work);
3892 
3893 int wlan_hdd_set_channel(struct wiphy *wiphy,
3894 		struct net_device *dev,
3895 		struct cfg80211_chan_def *chandef,
3896 		enum nl80211_channel_type channel_type);
3897 
3898 /**
3899  * wlan_hdd_cfg80211_start_bss() - start bss
3900  * @link_info: Link info pointer in hostapd adapter
3901  * @params: Pointer to start bss beacon parameters
3902  * @ssid: Pointer ssid
3903  * @ssid_len: Length of ssid
3904  * @hidden_ssid: Hidden SSID parameter
3905  * @check_for_concurrency: Flag to indicate if check for concurrency is needed
3906  *
3907  * Return: 0 for success non-zero for failure
3908  */
3909 int wlan_hdd_cfg80211_start_bss(struct wlan_hdd_link_info *link_info,
3910 				struct cfg80211_beacon_data *params,
3911 				const u8 *ssid, size_t ssid_len,
3912 				enum nl80211_hidden_ssid hidden_ssid,
3913 				bool check_for_concurrency);
3914 
3915 #if !defined(REMOVE_PKT_LOG)
3916 int hdd_process_pktlog_command(struct hdd_context *hdd_ctx, uint32_t set_value,
3917 			       int set_value2);
3918 int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable,
3919 			      uint8_t user_triggered, int size);
3920 
3921 #else
3922 static inline
hdd_pktlog_enable_disable(struct hdd_context * hdd_ctx,bool enable,uint8_t user_triggered,int size)3923 int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable,
3924 			      uint8_t user_triggered, int size)
3925 {
3926 	return 0;
3927 }
3928 
3929 static inline
hdd_process_pktlog_command(struct hdd_context * hdd_ctx,uint32_t set_value,int set_value2)3930 int hdd_process_pktlog_command(struct hdd_context *hdd_ctx,
3931 			       uint32_t set_value, int set_value2)
3932 {
3933 	return 0;
3934 }
3935 #endif /* REMOVE_PKT_LOG */
3936 
3937 #if defined(FEATURE_SG) && !defined(CONFIG_HL_SUPPORT)
3938 /**
3939  * hdd_set_sg_flags() - enable SG flag in the network device
3940  * @hdd_ctx: HDD context
3941  * @wlan_dev: network device structure
3942  *
3943  * This function enables the SG feature flag in the
3944  * given network device.
3945  *
3946  * Return: none
3947  */
hdd_set_sg_flags(struct hdd_context * hdd_ctx,struct net_device * wlan_dev)3948 static inline void hdd_set_sg_flags(struct hdd_context *hdd_ctx,
3949 				struct net_device *wlan_dev)
3950 {
3951 	hdd_debug("SG Enabled");
3952 	wlan_dev->features |= NETIF_F_SG;
3953 }
3954 #else
hdd_set_sg_flags(struct hdd_context * hdd_ctx,struct net_device * wlan_dev)3955 static inline void hdd_set_sg_flags(struct hdd_context *hdd_ctx,
3956 				struct net_device *wlan_dev){}
3957 #endif
3958 
3959 /**
3960  * hdd_set_netdev_flags() - set netdev flags for adapter as per ini config
3961  * @adapter: hdd adapter context
3962  *
3963  * This function sets netdev feature flags for the adapter.
3964  *
3965  * Return: none
3966  */
3967 void hdd_set_netdev_flags(struct hdd_adapter *adapter);
3968 
3969 #ifdef FEATURE_TSO
3970 /**
3971  * hdd_get_tso_csum_feature_flags() - Return TSO and csum flags if enabled
3972  *
3973  * Return: Enabled feature flags set, 0 on failure
3974  */
hdd_get_tso_csum_feature_flags(void)3975 static inline netdev_features_t hdd_get_tso_csum_feature_flags(void)
3976 {
3977 	netdev_features_t netdev_features = 0;
3978 	ol_txrx_soc_handle soc = cds_get_context(QDF_MODULE_ID_SOC);
3979 
3980 	if (!soc) {
3981 		hdd_err("soc handle is NULL");
3982 		return 0;
3983 	}
3984 
3985 	if (cdp_cfg_get(soc, cfg_dp_enable_ip_tcp_udp_checksum_offload)) {
3986 		netdev_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
3987 
3988 		if (cdp_cfg_get(soc, cfg_dp_tso_enable)) {
3989 			/*
3990 			 * Enable TSO only if IP/UDP/TCP TX checksum flag is
3991 			 * enabled.
3992 			 */
3993 			netdev_features |= NETIF_F_TSO | NETIF_F_TSO6 |
3994 					   NETIF_F_SG;
3995 		}
3996 	}
3997 	return netdev_features;
3998 }
3999 
4000 /**
4001  * hdd_set_tso_flags() - enable TSO flags in the network device
4002  * @hdd_ctx: HDD context
4003  * @wlan_dev: network device structure
4004  *
4005  * This function enables the TSO related feature flags in the
4006  * given network device.
4007  *
4008  * Return: none
4009  */
hdd_set_tso_flags(struct hdd_context * hdd_ctx,struct net_device * wlan_dev)4010 static inline void hdd_set_tso_flags(struct hdd_context *hdd_ctx,
4011 	 struct net_device *wlan_dev)
4012 {
4013 	hdd_debug("TSO Enabled");
4014 
4015 	wlan_dev->features |= hdd_get_tso_csum_feature_flags();
4016 }
4017 #else
hdd_set_tso_flags(struct hdd_context * hdd_ctx,struct net_device * wlan_dev)4018 static inline void hdd_set_tso_flags(struct hdd_context *hdd_ctx,
4019 	 struct net_device *wlan_dev)
4020 {
4021 	hdd_set_sg_flags(hdd_ctx, wlan_dev);
4022 }
4023 
hdd_get_tso_csum_feature_flags(void)4024 static inline netdev_features_t hdd_get_tso_csum_feature_flags(void)
4025 {
4026 	return 0;
4027 }
4028 #endif /* FEATURE_TSO */
4029 
4030 /**
4031  * wlan_hdd_get_host_log_nl_proto() - Get host log netlink protocol
4032  * @hdd_ctx: HDD context
4033  *
4034  * This function returns with host log netlink protocol settings
4035  *
4036  * Return: none
4037  */
4038 #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
wlan_hdd_get_host_log_nl_proto(struct hdd_context * hdd_ctx)4039 static inline int wlan_hdd_get_host_log_nl_proto(struct hdd_context *hdd_ctx)
4040 {
4041 	return hdd_ctx->config->host_log_custom_nl_proto;
4042 }
4043 #else
wlan_hdd_get_host_log_nl_proto(struct hdd_context * hdd_ctx)4044 static inline int wlan_hdd_get_host_log_nl_proto(struct hdd_context *hdd_ctx)
4045 {
4046 	return NETLINK_USERSOCK;
4047 }
4048 #endif
4049 
4050 #ifdef CONFIG_CNSS_LOGGER
4051 /**
4052  * wlan_hdd_nl_init() - wrapper function to CNSS_LOGGER case
4053  * @hdd_ctx:	the hdd context pointer
4054  *
4055  * The nl_srv_init() will call to cnss_logger_device_register() and
4056  * expect to get a radio_index from cnss_logger module and assign to
4057  * hdd_ctx->radio_index, then to maintain the consistency to original
4058  * design, adding the radio_index check here, then return the error
4059  * code if radio_index is not assigned correctly, which means the nl_init
4060  * from cnss_logger is failed.
4061  *
4062  * Return: 0 if successfully, otherwise error code
4063  */
wlan_hdd_nl_init(struct hdd_context * hdd_ctx)4064 static inline int wlan_hdd_nl_init(struct hdd_context *hdd_ctx)
4065 {
4066 	int proto;
4067 
4068 	proto = wlan_hdd_get_host_log_nl_proto(hdd_ctx);
4069 	hdd_ctx->radio_index = nl_srv_init(hdd_ctx->wiphy, proto);
4070 
4071 	/* radio_index is assigned from 0, so only >=0 will be valid index  */
4072 	if (hdd_ctx->radio_index >= 0)
4073 		return 0;
4074 	else
4075 		return -EINVAL;
4076 }
4077 #else
4078 /**
4079  * wlan_hdd_nl_init() - wrapper function to non CNSS_LOGGER case
4080  * @hdd_ctx:	the hdd context pointer
4081  *
4082  * In case of non CNSS_LOGGER case, the nl_srv_init() will initialize
4083  * the netlink socket and return the success or not.
4084  *
4085  * Return: the return value from  nl_srv_init()
4086  */
wlan_hdd_nl_init(struct hdd_context * hdd_ctx)4087 static inline int wlan_hdd_nl_init(struct hdd_context *hdd_ctx)
4088 {
4089 	int proto;
4090 
4091 	proto = wlan_hdd_get_host_log_nl_proto(hdd_ctx);
4092 	return nl_srv_init(hdd_ctx->wiphy, proto);
4093 }
4094 #endif
4095 
4096 QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id);
4097 
4098 int hdd_register_cb(struct hdd_context *hdd_ctx);
4099 void hdd_deregister_cb(struct hdd_context *hdd_ctx);
4100 
4101 #ifdef WLAN_HDD_MULTI_VDEV_SINGLE_NDEV
4102 static inline struct qdf_mac_addr *
hdd_adapter_get_netdev_mac_addr(struct hdd_adapter * adapter)4103 hdd_adapter_get_netdev_mac_addr(struct hdd_adapter *adapter)
4104 {
4105 	return &adapter->mac_addr;
4106 }
4107 #else
4108 static inline struct qdf_mac_addr *
hdd_adapter_get_netdev_mac_addr(struct hdd_adapter * adapter)4109 hdd_adapter_get_netdev_mac_addr(struct hdd_adapter *adapter)
4110 {
4111 	if (hdd_adapter_is_ml_adapter(adapter) ||
4112 	    hdd_adapter_is_link_adapter(adapter))
4113 		return &adapter->mld_addr;
4114 
4115 	return &adapter->mac_addr;
4116 }
4117 #endif
4118 
4119 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC) && \
4120 	defined(WLAN_HDD_MULTI_VDEV_SINGLE_NDEV)
4121 /**
4122  * hdd_adapter_fill_link_address() - Fill derived
4123  * link address in adapter
4124  * @adapter: HDD adapter
4125  *
4126  * The API takes MLD address of @adapter and calls link address
4127  * derive API and fills the derived link address in each link.
4128  *
4129  * Return: QDF_STATUS
4130  */
4131 QDF_STATUS hdd_adapter_fill_link_address(struct hdd_adapter *adapter);
4132 #else
4133 static inline
hdd_adapter_fill_link_address(struct hdd_adapter * adapter)4134 QDF_STATUS hdd_adapter_fill_link_address(struct hdd_adapter *adapter)
4135 {
4136 	return QDF_STATUS_SUCCESS;
4137 }
4138 #endif
4139 
4140 /**
4141  * hdd_adapter_get_link_mac_addr() - Returns the appropriate
4142  * MAC address pointer in adapter.
4143  * @link_info: Link info in HDD adapter.
4144  *
4145  * If WLAN_HDD_MULTI_VDEV_SINGLE_NDEV flag is enabled, then MAC address pointer
4146  * returned is based on following conditions:
4147  *      -if adapter of link info is non-ml:
4148  *              Return pointer of mac_addr in adapter.
4149  *      -else if link_addr in @link_info is NULL:
4150  *              Return pointer of mac_addr in adapter.
4151  *      -else
4152  *              Return pointer of link_addr in @link_info.
4153  *
4154  * If WLAN_HDD_MULTI_VDEV_SINGLE_NDEV flag is not enabled, then return pointer
4155  * of mac_addr in adapter.
4156  *
4157  * Return: MAC address pointer based on adapter type.
4158  */
4159 struct qdf_mac_addr *
4160 hdd_adapter_get_link_mac_addr(struct wlan_hdd_link_info *link_info);
4161 
4162 /**
4163  * hdd_adapter_check_duplicate_session() - Check for duplicate
4164  * session on start adapter.
4165  * @adapter: HDD adapter
4166  *
4167  * The API passes list of addresses contained in @adapter to
4168  * sme_check_for_duplicate_session() to check the status
4169  * of existing peer with same MAC address.
4170  *
4171  * Return: QDF_STATUS
4172  */
4173 QDF_STATUS hdd_adapter_check_duplicate_session(struct hdd_adapter *adapter);
4174 
4175 /**
4176  * hdd_adapter_reset_station_ctx() - Resets station context with appropriate
4177  * initial value.
4178  * @adapter: HDD adapter
4179  *
4180  * Return: void
4181  */
4182 void hdd_adapter_reset_station_ctx(struct hdd_adapter *adapter);
4183 
4184 /**
4185  * hdd_start_station_adapter()- Start the Station Adapter
4186  * @adapter: HDD adapter
4187  *
4188  * This function initializes the adapter for the station mode.
4189  *
4190  * Return: 0 on success or errno on failure.
4191  */
4192 int hdd_start_station_adapter(struct hdd_adapter *adapter);
4193 
4194 /**
4195  * hdd_start_ap_adapter()- Start AP Adapter
4196  * @adapter: HDD adapter
4197  * @rtnl_held: True if rtnl lock is taken, otherwise false
4198  *
4199  * This function initializes the adapter for the AP mode.
4200  *
4201  * Return: 0 on success errno on failure.
4202  */
4203 int hdd_start_ap_adapter(struct hdd_adapter *adapter, bool rtnl_held);
4204 int hdd_configure_cds(struct hdd_context *hdd_ctx);
4205 int hdd_set_fw_params(struct hdd_adapter *adapter);
4206 
4207 #ifdef MULTI_CLIENT_LL_SUPPORT
4208 /**
4209  * wlan_hdd_deinit_multi_client_info_table() - to deinit multi client info table
4210  * @adapter: hdd vdev/net_device context
4211  *
4212  * Return: none
4213  */
4214 void wlan_hdd_deinit_multi_client_info_table(struct hdd_adapter *adapter);
4215 #else
4216 static inline void
wlan_hdd_deinit_multi_client_info_table(struct hdd_adapter * adapter)4217 wlan_hdd_deinit_multi_client_info_table(struct hdd_adapter *adapter)
4218 {}
4219 #endif
4220 
4221 /**
4222  * hdd_wlan_start_modules() - Single driver state machine for starting modules
4223  * @hdd_ctx: HDD context
4224  * @reinit: flag to indicate from SSR or normal path
4225  *
4226  * This function maintains the driver state machine it will be invoked from
4227  * startup, reinit and change interface. Depending on the driver state shall
4228  * perform the opening of the modules.
4229  *
4230  * Return: Errno
4231  */
4232 int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit);
4233 
4234 /**
4235  * hdd_wlan_stop_modules - Single driver state machine for stopping modules
4236  * @hdd_ctx: HDD context
4237  * @ftm_mode: ftm mode
4238  *
4239  * This function maintains the driver state machine it will be invoked from
4240  * exit, shutdown and con_mode change handler. Depending on the driver state
4241  * shall perform the stopping/closing of the modules.
4242  *
4243  * Return: Errno
4244  */
4245 int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode);
4246 
4247 /**
4248  * hdd_psoc_idle_timer_start() - start the idle psoc detection timer
4249  * @hdd_ctx: the hdd context for which the timer should be started
4250  *
4251  * Return: None
4252  */
4253 void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx);
4254 
4255 /**
4256  * hdd_psoc_idle_timer_stop() - stop the idle psoc detection timer
4257  * @hdd_ctx: the hdd context for which the timer should be stopped
4258  *
4259  * Return: None
4260  */
4261 void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx);
4262 
4263 /**
4264  * hdd_trigger_psoc_idle_restart() - trigger restart of a previously shutdown
4265  *                                   idle psoc, if needed
4266  * @hdd_ctx: the hdd context which should be restarted
4267  *
4268  * This API does nothing if the given psoc is already active.
4269  *
4270  * Return: Errno
4271  */
4272 int hdd_trigger_psoc_idle_restart(struct hdd_context *hdd_ctx);
4273 
4274 int hdd_start_adapter(struct hdd_adapter *adapter, bool rtnl_held);
4275 void hdd_populate_random_mac_addr(struct hdd_context *hdd_ctx, uint32_t num);
4276 /**
4277  * hdd_is_interface_up()- Check if the given interface is up
4278  * @adapter: interface to check
4279  *
4280  * Checks whether the given interface was brought up by userspace.
4281  *
4282  * Return: true if interface was opened else false
4283  */
4284 bool hdd_is_interface_up(struct hdd_adapter *adapter);
4285 
4286 #ifdef WLAN_FEATURE_FASTPATH
4287 void hdd_enable_fastpath(struct hdd_context *hdd_ctx,
4288 			 void *context);
4289 #else
hdd_enable_fastpath(struct hdd_context * hdd_ctx,void * context)4290 static inline void hdd_enable_fastpath(struct hdd_context *hdd_ctx,
4291 				       void *context)
4292 {
4293 }
4294 #endif
4295 void hdd_wlan_update_target_info(struct hdd_context *hdd_ctx, void *context);
4296 
4297 enum  sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode);
4298 
4299 /**
4300  * hdd_clone_local_unsafe_chan() - clone hdd ctx unsafe chan list
4301  * @hdd_ctx: hdd context pointer
4302  * @local_unsafe_list: copied unsafe chan list array
4303  * @local_unsafe_list_count: channel number in returned local_unsafe_list
4304  *
4305  * The function will allocate memory and make a copy the current unsafe
4306  * channels from hdd ctx. The caller need to free the local_unsafe_list
4307  * memory after use.
4308  *
4309  * Return: 0 if successfully clone unsafe chan list.
4310  */
4311 int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx,
4312 	uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count);
4313 
4314 /**
4315  * hdd_local_unsafe_channel_updated() - check unsafe chan list same or not
4316  * @hdd_ctx: hdd context pointer
4317  * @local_unsafe_list: unsafe chan list to be compared with hdd_ctx's list
4318  * @local_unsafe_list_count: channel number in local_unsafe_list
4319  * @restriction_mask: restriction mask is to differentiate current channel
4320  * list different from previous channel list
4321  *
4322  * The function checked the input channel is same as current unsafe chan
4323  * list in hdd_ctx.
4324  *
4325  * Return: true if input channel list is same as the list in hdd_ctx
4326  */
4327 bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx,
4328 	uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count,
4329 	uint32_t restriction_mask);
4330 
4331 int hdd_enable_disable_ca_event(struct hdd_context *hddctx,
4332 				uint8_t set_value);
4333 
4334 /**
4335  * wlan_hdd_undo_acs : Do cleanup of DO_ACS
4336  * @link_info: Pointer of link_info in adapter
4337  *
4338  * This function handle cleanup of what was done in DO_ACS, including free
4339  * memory.
4340  *
4341  * Return: void
4342  */
4343 void wlan_hdd_undo_acs(struct wlan_hdd_link_info *link_info);
4344 
4345 /**
4346  * wlan_hdd_set_restriction_mask() - set restriction mask for hdd context
4347  * @hdd_ctx: hdd context pointer
4348  *
4349  * Return: None
4350  */
4351 void wlan_hdd_set_restriction_mask(struct hdd_context *hdd_ctx);
4352 
4353 /**
4354  * wlan_hdd_get_restriction_mask() - get restriction mask from hdd context
4355  * @hdd_ctx: hdd context pointer
4356  *
4357  * Return: restriction_mask
4358  */
4359 uint32_t wlan_hdd_get_restriction_mask(struct hdd_context *hdd_ctx);
4360 
4361 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
4362 static inline int
hdd_wlan_nla_put_u64(struct sk_buff * skb,int attrtype,u64 value)4363 hdd_wlan_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
4364 {
4365 	return nla_put_u64(skb, attrtype, value);
4366 }
4367 #else
4368 static inline int
hdd_wlan_nla_put_u64(struct sk_buff * skb,int attrtype,u64 value)4369 hdd_wlan_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
4370 {
4371 	return nla_put_u64_64bit(skb, attrtype, value, NL80211_ATTR_PAD);
4372 }
4373 #endif
4374 
4375 /**
4376  * hdd_roam_profile() - Get adapter's roam profile
4377  * @link_info: Link info pointer in HDD adapter
4378  *
4379  * Given an adapter this function returns a pointer to its roam profile.
4380  *
4381  * NOTE WELL: Caller is responsible for ensuring this interface is only
4382  * invoked for STA-type interfaces
4383  *
4384  * Return: pointer to the adapter's roam profile
4385  */
4386 static inline struct csr_roam_profile *
hdd_roam_profile(struct wlan_hdd_link_info * link_info)4387 hdd_roam_profile(struct wlan_hdd_link_info *link_info)
4388 {
4389 	struct hdd_station_ctx *sta_ctx;
4390 
4391 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
4392 	return &sta_ctx->roam_profile;
4393 }
4394 
4395 /**
4396  * hdd_is_roaming_in_progress() - check if roaming is in progress
4397  * @hdd_ctx: Global HDD context
4398  *
4399  * Checks if roaming is in progress on any of the adapters
4400  *
4401  * Return: true if roaming is in progress else false
4402  */
4403 bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx);
4404 
4405 /**
4406  * hdd_is_connection_in_progress() - check if connection is in progress
4407  * @out_vdev_id: id of vdev where connection is occurring
4408  * @out_reason: scan reject reason
4409  *
4410  * Go through each adapter and check if connection is in progress.
4411  * Output parameters @out_vdev_id and @out_reason will only be written
4412  * when a connection is in progress.
4413  *
4414  * Return: true if connection is in progress else false
4415  */
4416 bool hdd_is_connection_in_progress(uint8_t *out_vdev_id,
4417 				   enum scan_reject_states *out_reason);
4418 
4419 /**
4420  * hdd_restart_sap() - to restart SAP in driver internally
4421  * @link_info: Link info pointer of SAP adapter
4422  *
4423  * Return: None
4424  */
4425 void hdd_restart_sap(struct wlan_hdd_link_info *link_info);
4426 bool hdd_set_connection_in_progress(bool value);
4427 
4428 /**
4429  * wlan_hdd_init_chan_info() - initialize channel info variables
4430  * @hdd_ctx: hdd ctx
4431  *
4432  * This API initialize channel info variables
4433  *
4434  * Return: None
4435  */
4436 void wlan_hdd_init_chan_info(struct hdd_context *hdd_ctx);
4437 
4438 /**
4439  * wlan_hdd_deinit_chan_info() - deinitialize channel info variables
4440  * @hdd_ctx: hdd ctx
4441  *
4442  * This API deinitialize channel info variables
4443  *
4444  * Return: None
4445  */
4446 void wlan_hdd_deinit_chan_info(struct hdd_context *hdd_ctx);
4447 
4448 /**
4449  * hdd_is_any_interface_open() - Check for interface up
4450  * @hdd_ctx: HDD context
4451  *
4452  * Return: true if any interface is open
4453  */
4454 bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx);
4455 
4456 #ifdef WIFI_POS_CONVERGED
4457 /**
4458  * hdd_send_peer_status_ind_to_app() - wrapper to call legacy or new wifi_pos
4459  * function to send peer status to a registered application
4460  * @peer_mac: MAC address of peer
4461  * @peer_status: ePeerConnected or ePeerDisconnected
4462  * @peer_timing_meas_cap: 0: RTT/RTT2, 1: RTT3. Default is 0
4463  * @vdev_id: ID of the underlying vdev
4464  * @chan_info: operating channel information
4465  * @dev_mode: dev mode for which indication is sent
4466  *
4467  * Return: none
4468  */
hdd_send_peer_status_ind_to_app(struct qdf_mac_addr * peer_mac,uint8_t peer_status,uint8_t peer_timing_meas_cap,uint8_t vdev_id,struct oem_channel_info * chan_info,enum QDF_OPMODE dev_mode)4469 static inline void hdd_send_peer_status_ind_to_app(
4470 					struct qdf_mac_addr *peer_mac,
4471 					uint8_t peer_status,
4472 					uint8_t peer_timing_meas_cap,
4473 					uint8_t vdev_id,
4474 					struct oem_channel_info *chan_info,
4475 					enum QDF_OPMODE dev_mode)
4476 {
4477 	struct wifi_pos_ch_info ch_info;
4478 
4479 	if (!chan_info) {
4480 		os_if_wifi_pos_send_peer_status(peer_mac, peer_status,
4481 						peer_timing_meas_cap, vdev_id,
4482 						NULL, dev_mode);
4483 		return;
4484 	}
4485 
4486 	/* chan_id is obsoleted by mhz */
4487 	ch_info.chan_id = 0;
4488 	ch_info.mhz = chan_info->mhz;
4489 	ch_info.band_center_freq1 = chan_info->band_center_freq1;
4490 	ch_info.band_center_freq2 = chan_info->band_center_freq2;
4491 	ch_info.info = chan_info->info;
4492 	ch_info.reg_info_1 = chan_info->reg_info_1;
4493 	ch_info.reg_info_2 = chan_info->reg_info_2;
4494 	ch_info.nss = chan_info->nss;
4495 	ch_info.rate_flags = chan_info->rate_flags;
4496 	ch_info.sec_ch_offset = chan_info->sec_ch_offset;
4497 	ch_info.ch_width = chan_info->ch_width;
4498 	os_if_wifi_pos_send_peer_status(peer_mac, peer_status,
4499 					peer_timing_meas_cap, vdev_id,
4500 					&ch_info, dev_mode);
4501 }
4502 #else
hdd_send_peer_status_ind_to_app(struct qdf_mac_addr * peer_mac,uint8_t peer_status,uint8_t peer_timing_meas_cap,uint8_t vdev_id,struct oem_channel_info * chan_info,enum QDF_OPMODE dev_mode)4503 static inline void hdd_send_peer_status_ind_to_app(
4504 					struct qdf_mac_addr *peer_mac,
4505 					uint8_t peer_status,
4506 					uint8_t peer_timing_meas_cap,
4507 					uint8_t vdev_id,
4508 					struct oem_channel_info *chan_info,
4509 					enum QDF_OPMODE dev_mode)
4510 {
4511 	hdd_send_peer_status_ind_to_oem_app(peer_mac, peer_status,
4512 			peer_timing_meas_cap, vdev_id, chan_info, dev_mode);
4513 }
4514 #endif /* WIFI_POS_CONVERGENCE */
4515 
4516 /**
4517  * wlan_hdd_send_mcc_vdev_quota()- Send mcc vdev quota value to FW
4518  * @adapter: Adapter data
4519  * @sval:    mcc vdev quota value
4520  *
4521  * Send mcc vdev quota value value to FW
4522  *
4523  * Return: 0 success else failure
4524  */
4525 int wlan_hdd_send_mcc_vdev_quota(struct hdd_adapter *adapter, int sval);
4526 
4527 /**
4528  * wlan_hdd_send_mcc_latency()- Send MCC latency to FW
4529  * @adapter: Adapter data
4530  * @sval:    MCC latency value
4531  *
4532  * Send MCC latency value to FW
4533  *
4534  * Return: 0 success else failure
4535  */
4536 int wlan_hdd_send_mcc_latency(struct hdd_adapter *adapter, int sval);
4537 
4538 /**
4539  * wlan_hdd_get_link_info_from_vdev()- Get link info from vdev id
4540  * and PSOC object data
4541  * @psoc: Psoc object data
4542  * @vdev_id: vdev id
4543  *
4544  * Get link info from vdev id and PSOC object data
4545  *
4546  * Return: link info pointer
4547  */
4548 struct wlan_hdd_link_info *
4549 wlan_hdd_get_link_info_from_vdev(struct wlan_objmgr_psoc *psoc,
4550 				 uint8_t vdev_id);
4551 
4552 /**
4553  * hdd_unregister_notifiers()- unregister kernel notifiers
4554  * @hdd_ctx: Hdd Context
4555  *
4556  * Unregister netdev notifiers like Netdevice,IPv4 and IPv6.
4557  *
4558  */
4559 void hdd_unregister_notifiers(struct hdd_context *hdd_ctx);
4560 
4561 /**
4562  * hdd_dbs_scan_selection_init() - initialization for DBS scan selection config
4563  * @hdd_ctx: HDD context
4564  *
4565  * This function sends the DBS scan selection config configuration to the
4566  * firmware via WMA
4567  *
4568  * Return: 0 - success, < 0 - failure
4569  */
4570 int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx);
4571 
4572 /**
4573  * hdd_update_scan_config - API to update scan configuration parameters
4574  * @hdd_ctx: HDD context
4575  *
4576  * Return: 0 if success else err
4577  */
4578 int hdd_update_scan_config(struct hdd_context *hdd_ctx);
4579 
4580 /**
4581  * hdd_start_complete()- complete the start event
4582  * @ret: return value for complete event.
4583  *
4584  * complete the startup event and set the return in
4585  * global variable
4586  *
4587  * Return: void
4588  */
4589 
4590 void hdd_start_complete(int ret);
4591 
4592 /**
4593  * hdd_chip_pwr_save_fail_detected_cb() - chip power save failure detected
4594  * callback
4595  * @hdd_handle: HDD handle
4596  * @data: chip power save failure detected data
4597  *
4598  * This function reads the chip power save failure detected data and fill in
4599  * the skb with NL attributes and send up the NL event.
4600  * This callback execute in atomic context and must not invoke any
4601  * blocking calls.
4602  *
4603  * Return: none
4604  */
4605 
4606 void hdd_chip_pwr_save_fail_detected_cb(hdd_handle_t hdd_handle,
4607 				struct chip_pwr_save_fail_detected_params
4608 				*data);
4609 
4610 /**
4611  * hdd_update_ie_allowlist_attr() - Copy probe req ie allowlist attrs from cfg
4612  * @ie_allowlist: output parameter
4613  * @hdd_ctx: pointer to hdd context
4614  *
4615  * Return: None
4616  */
4617 void hdd_update_ie_allowlist_attr(struct probe_req_allowlist_attr *ie_allowlist,
4618 				  struct hdd_context *hdd_ctx);
4619 
4620 /**
4621  * hdd_get_rssi_snr_by_bssid() - gets the rssi and snr by bssid from scan cache
4622  * @mac_handle: MAC handle
4623  * @bssid: bssid to look for in scan cache
4624  * @rssi: rssi value found
4625  * @snr: snr value found
4626  *
4627  * Return: QDF_STATUS
4628  */
4629 int hdd_get_rssi_snr_by_bssid(mac_handle_t mac_handle, const uint8_t *bssid,
4630 			      int8_t *rssi, int8_t *snr);
4631 
4632 /**
4633  * hdd_reset_limit_off_chan() - reset limit off-channel command parameters
4634  * @adapter: HDD adapter
4635  *
4636  * Return: 0 on success and non zero value on failure
4637  */
4638 int hdd_reset_limit_off_chan(struct hdd_adapter *adapter);
4639 
4640 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
hdd_dev_setup_destructor(struct net_device * dev)4641 static inline void hdd_dev_setup_destructor(struct net_device *dev)
4642 {
4643 	dev->destructor = free_netdev;
4644 }
4645 #else
hdd_dev_setup_destructor(struct net_device * dev)4646 static inline void hdd_dev_setup_destructor(struct net_device *dev)
4647 {
4648 	dev->needs_free_netdev = true;
4649 }
4650 #endif /* KERNEL_VERSION(4, 12, 0) */
4651 
4652 /**
4653  * hdd_update_score_config - API to update candidate scoring related params
4654  * configuration parameters
4655  * @hdd_ctx: hdd context
4656  *
4657  * Return: QDF_STATUS
4658  */
4659 QDF_STATUS hdd_update_score_config(struct hdd_context *hdd_ctx);
4660 
4661 /**
4662  * hdd_get_stainfo() - get stainfo for the specified peer
4663  * @astainfo: array of the station info in which the sta info
4664  * corresponding to mac_addr needs to be searched
4665  * @mac_addr: mac address of requested peer
4666  *
4667  * This function find the stainfo for the peer with mac_addr
4668  *
4669  * Return: stainfo if found, NULL if not found
4670  */
4671 struct hdd_station_info *hdd_get_stainfo(struct hdd_station_info *astainfo,
4672 					 struct qdf_mac_addr mac_addr);
4673 
4674 /**
4675  * hdd_component_psoc_open() - Open the legacy components
4676  * @psoc: Pointer to psoc object
4677  *
4678  * This function opens the legacy components and initializes the
4679  * component's private objects.
4680  *
4681  * Return: QDF_STATUS
4682  */
4683 QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc);
4684 
4685 /**
4686  * hdd_component_psoc_close() - Close the legacy components
4687  * @psoc: Pointer to psoc object
4688  *
4689  * This function closes the legacy components and resets the
4690  * component's private objects.
4691  *
4692  * Return: None
4693  */
4694 void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc);
4695 
4696 /**
4697  * hdd_component_psoc_enable() - Trigger psoc enable for CLD Components
4698  * @psoc: Pointer to psoc object
4699  *
4700  * Return: None
4701  */
4702 void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc);
4703 
4704 /**
4705  * hdd_component_psoc_disable() - Trigger psoc disable for CLD Components
4706  * @psoc: Pointer to psoc object
4707  *
4708  * Return: None
4709  */
4710 void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc);
4711 
4712 /**
4713  * hdd_component_pdev_open() - Trigger pdev open for CLD Components
4714  * @pdev: Pointer to pdev object
4715  *
4716  * Return: QDF_STATUS
4717  */
4718 QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev);
4719 
4720 /**
4721  * hdd_component_pdev_close() - Trigger pdev close for CLD Components
4722  * @pdev: Pointer to pdev object
4723  *
4724  * Return: None
4725  */
4726 void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev);
4727 
4728 #ifdef WLAN_FEATURE_MEMDUMP_ENABLE
4729 int hdd_driver_memdump_init(void);
4730 void hdd_driver_memdump_deinit(void);
4731 
4732 /**
4733  * hdd_driver_mem_cleanup() - Frees memory allocated for
4734  * driver dump
4735  *
4736  * This function  frees driver dump memory.
4737  *
4738  * Return: None
4739  */
4740 void hdd_driver_mem_cleanup(void);
4741 
4742 #else /* WLAN_FEATURE_MEMDUMP_ENABLE */
hdd_driver_memdump_init(void)4743 static inline int hdd_driver_memdump_init(void)
4744 {
4745 	return 0;
4746 }
hdd_driver_memdump_deinit(void)4747 static inline void hdd_driver_memdump_deinit(void)
4748 {
4749 }
4750 
hdd_driver_mem_cleanup(void)4751 static inline void hdd_driver_mem_cleanup(void)
4752 {
4753 }
4754 #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
4755 
4756 #ifdef FEATURE_MONITOR_MODE_SUPPORT
4757 /**
4758  * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
4759  * @adapter: Handle to adapter
4760  * @freq: Monitor mode frequency (MHz)
4761  * @bandwidth: Capture channel bandwidth
4762  *
4763  * Return: 0 on success else error code.
4764  */
4765 int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, qdf_freq_t freq,
4766 			  uint32_t bandwidth);
4767 #else
4768 static inline
wlan_hdd_set_mon_chan(struct hdd_adapter * adapter,qdf_freq_t freq,uint32_t bandwidth)4769 int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, qdf_freq_t freq,
4770 			  uint32_t bandwidth)
4771 {
4772 	return 0;
4773 }
4774 #endif
4775 
4776 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC) && \
4777 	!defined(WLAN_HDD_MULTI_VDEV_SINGLE_NDEV)
4778 /**
4779  *  hdd_set_mld_address() - Set the MLD address of the adapter
4780  *  @adapter: Handle to adapter
4781  *  @mac_addr: MAC address to be copied
4782  *
4783  *  The function copies the MAC address sent in @mac_addr to
4784  *  the adapter's MLD address and the MLD address of each
4785  *  link adapter mapped of the @adapter.
4786  *  The mode of operation must be 11be capable and @adapter
4787  *  has to be ML type.
4788  *
4789  *  Return: void
4790  */
4791 void
4792 hdd_set_mld_address(struct hdd_adapter *adapter,
4793 		    const struct qdf_mac_addr *mac_addr);
4794 #else
4795 static inline void
hdd_set_mld_address(struct hdd_adapter * adapter,const struct qdf_mac_addr * mac_addr)4796 hdd_set_mld_address(struct hdd_adapter *adapter,
4797 		    const struct qdf_mac_addr *mac_addr)
4798 {
4799 }
4800 #endif
4801 
4802 /**
4803  * hdd_wlan_get_version() - Get version information
4804  * @hdd_ctx: Global HDD context
4805  * @version_len: length of the version buffer size
4806  * @version: the buffer to the version string
4807  *
4808  * This function is used to get Wlan Driver, Firmware, Hardware Version
4809  * & the Board related information.
4810  *
4811  * Return: the length of the version string
4812  */
4813 uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx,
4814 			      const size_t version_len, uint8_t *version);
4815 /**
4816  * hdd_assemble_rate_code() - assemble rate code to be sent to FW
4817  * @preamble: rate preamble
4818  * @nss: number of streams
4819  * @rate: rate index
4820  *
4821  * Rate code assembling is different for targets which are 11ax capable.
4822  * Check for the target support and assemble the rate code accordingly.
4823  *
4824  * Return: assembled rate code
4825  */
4826 int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate);
4827 
4828 /**
4829  * hdd_update_country_code - Update country code
4830  * @hdd_ctx: HDD context
4831  *
4832  * Update country code based on module parameter country_code
4833  *
4834  * Return: 0 on success and errno on failure
4835  */
4836 int hdd_update_country_code(struct hdd_context *hdd_ctx);
4837 
4838 /**
4839  * hdd_set_11ax_rate() - set 11ax rate
4840  * @adapter: adapter being modified
4841  * @value: new 11ax rate code
4842  * @sap_config: pointer to SAP config to check HW mode
4843  *		this will be NULL for call from STA persona
4844  *
4845  * Return: 0 on success, negative errno on failure
4846  */
4847 int hdd_set_11ax_rate(struct hdd_adapter *adapter, int value,
4848 		      struct sap_config *sap_config);
4849 
4850 /**
4851  * hdd_update_hw_sw_info() - API to update the HW/SW information
4852  * @hdd_ctx: Global HDD context
4853  *
4854  * API to update the HW and SW information in the driver
4855  *
4856  * Note:
4857  * All the version/revision information would only be retrieved after
4858  * firmware download
4859  *
4860  * Return: None
4861  */
4862 void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx);
4863 
4864 /**
4865  * hdd_context_get_mac_handle() - get mac handle from hdd context
4866  * @hdd_ctx: Global HDD context pointer
4867  *
4868  * Retrieves the global MAC handle from the HDD context
4869  *
4870  * Return: The global MAC handle (which may be NULL)
4871  */
4872 static inline
hdd_context_get_mac_handle(struct hdd_context * hdd_ctx)4873 mac_handle_t hdd_context_get_mac_handle(struct hdd_context *hdd_ctx)
4874 {
4875 	return hdd_ctx ? hdd_ctx->mac_handle : NULL;
4876 }
4877 
4878 /**
4879  * hdd_adapter_get_mac_handle() - get mac handle from hdd adapter
4880  * @adapter: HDD adapter pointer
4881  *
4882  * Retrieves the global MAC handle given an HDD adapter
4883  *
4884  * Return: The global MAC handle (which may be NULL)
4885  */
4886 static inline
hdd_adapter_get_mac_handle(struct hdd_adapter * adapter)4887 mac_handle_t hdd_adapter_get_mac_handle(struct hdd_adapter *adapter)
4888 {
4889 	return adapter ?
4890 		hdd_context_get_mac_handle(adapter->hdd_ctx) : NULL;
4891 }
4892 
4893 /**
4894  * hdd_handle_to_context() - turn an HDD handle into an HDD context
4895  * @hdd_handle: HDD handle to be converted
4896  *
4897  * Return: HDD context referenced by @hdd_handle
4898  */
4899 static inline
hdd_handle_to_context(hdd_handle_t hdd_handle)4900 struct hdd_context *hdd_handle_to_context(hdd_handle_t hdd_handle)
4901 {
4902 	return (struct hdd_context *)hdd_handle;
4903 }
4904 
4905 /**
4906  * wlan_hdd_free_cache_channels() - Free the cache channels list
4907  * @hdd_ctx: Pointer to HDD context
4908  *
4909  * Return: None
4910  */
4911 void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx);
4912 
4913 /**
4914  * hdd_update_dynamic_mac() - Updates the dynamic MAC list
4915  * @hdd_ctx: Pointer to HDD context
4916  * @curr_mac_addr: Current interface mac address
4917  * @new_mac_addr: New mac address which needs to be updated
4918  *
4919  * This function updates newly configured MAC address to the
4920  * dynamic MAC address list corresponding to the current
4921  * adapter MAC address
4922  *
4923  * Return: None
4924  */
4925 void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx,
4926 			    struct qdf_mac_addr *curr_mac_addr,
4927 			    struct qdf_mac_addr *new_mac_addr);
4928 
4929 #ifdef WLAN_FEATURE_MOTION_DETECTION
4930 /**
4931  * hdd_md_host_evt_cb - Callback for Motion Detection Event
4932  * @ctx: HDD context
4933  * @event: motion detect event
4934  *
4935  * Callback for Motion Detection Event. Re-enables Motion
4936  * Detection again upon event
4937  *
4938  * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and
4939  * QDF_STATUS_E_FAILURE on failure
4940  */
4941 QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event);
4942 
4943 /**
4944  * hdd_md_bl_evt_cb - Callback for Motion Detection Baseline Event
4945  * @ctx: HDD context
4946  * @event: motion detect baseline event
4947  *
4948  * Callback for Motion Detection Baseline Event
4949  *
4950  * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and
4951  * QDF_STATUS_E_FAILURE on failure
4952  */
4953 QDF_STATUS hdd_md_bl_evt_cb(void *ctx, struct sir_md_bl_evt *event);
4954 #endif /* WLAN_FEATURE_MOTION_DETECTION */
4955 
4956 /**
4957  * hdd_hidden_ssid_enable_roaming() - enable roaming after hidden ssid rsp
4958  * @hdd_handle: Hdd handler
4959  * @vdev_id: Vdev Id
4960  *
4961  * This is a wrapper function to enable roaming after getting hidden
4962  * ssid rsp
4963  */
4964 void hdd_hidden_ssid_enable_roaming(hdd_handle_t hdd_handle, uint8_t vdev_id);
4965 
4966 /**
4967  * hdd_psoc_idle_shutdown - perform idle shutdown after interface inactivity
4968  *                          timeout
4969  * @dev: pointer to struct device
4970  *
4971  * Return: 0 for success non-zero error code for failure
4972  */
4973 int hdd_psoc_idle_shutdown(struct device *dev);
4974 
4975 /**
4976  * hdd_psoc_idle_restart - perform idle restart after idle shutdown
4977  * @dev: pointer to struct device
4978  *
4979  * Return: 0 for success non-zero error code for failure
4980  */
4981 int hdd_psoc_idle_restart(struct device *dev);
4982 
4983 /**
4984  * hdd_adapter_is_ap() - whether adapter is ap or not
4985  * @adapter: adapter to check
4986  * Return: true if it is AP
4987  */
4988 bool hdd_adapter_is_ap(struct hdd_adapter *adapter);
4989 
4990 /**
4991  * hdd_common_roam_callback() - common sme roam callback
4992  * @psoc: Object Manager Psoc
4993  * @session_id: session id for which callback is called
4994  * @roam_info: pointer to roam info
4995  * @roam_status: roam status
4996  * @roam_result: roam result
4997  *
4998  * Return: QDF_STATUS enumeration
4999  */
5000 QDF_STATUS hdd_common_roam_callback(struct wlan_objmgr_psoc *psoc,
5001 				    uint8_t session_id,
5002 				    struct csr_roam_info *roam_info,
5003 				    eRoamCmdStatus roam_status,
5004 				    eCsrRoamResult roam_result);
5005 
5006 #ifdef WLAN_FEATURE_PKT_CAPTURE
5007 /**
5008  * wlan_hdd_is_mon_concurrency() - check if MONITOR and STA concurrency
5009  * is UP when packet capture mode is enabled.
5010  *
5011  * Return: True - if STA and monitor concurrency is there, else False
5012  *
5013  */
5014 bool wlan_hdd_is_mon_concurrency(void);
5015 
5016 /**
5017  * wlan_hdd_del_monitor() - delete monitor interface
5018  * @hdd_ctx: pointer to hdd context
5019  * @adapter: adapter to be deleted
5020  * @rtnl_held: rtnl lock held
5021  *
5022  * This function is invoked to delete monitor interface.
5023  *
5024  * Return: None
5025  */
5026 void wlan_hdd_del_monitor(struct hdd_context *hdd_ctx,
5027 			  struct hdd_adapter *adapter, bool rtnl_held);
5028 
5029 /**
5030  * wlan_hdd_del_p2p_interface() - delete p2p interface
5031  * @hdd_ctx: pointer to hdd context
5032  *
5033  * This function is invoked to delete p2p interface.
5034  *
5035  * Return: None
5036  */
5037 void
5038 wlan_hdd_del_p2p_interface(struct hdd_context *hdd_ctx);
5039 
5040 /**
5041  * hdd_reset_monitor_interface() - reset monitor interface flags
5042  * @sta_adapter: station adapter
5043  *
5044  * Return: void
5045  */
5046 void hdd_reset_monitor_interface(struct hdd_adapter *sta_adapter);
5047 
5048 /**
5049  * hdd_is_pkt_capture_mon_enable() - Is packet capture monitor mode enable
5050  * @sta_adapter: station adapter
5051  *
5052  * Return: status of packet capture monitor adapter
5053  */
5054 struct hdd_adapter *
5055 hdd_is_pkt_capture_mon_enable(struct hdd_adapter *sta_adapter);
5056 #else
5057 static inline
wlan_hdd_del_monitor(struct hdd_context * hdd_ctx,struct hdd_adapter * adapter,bool rtnl_held)5058 void wlan_hdd_del_monitor(struct hdd_context *hdd_ctx,
5059 			  struct hdd_adapter *adapter, bool rtnl_held)
5060 {
5061 }
5062 
5063 static inline
wlan_hdd_is_mon_concurrency(void)5064 bool wlan_hdd_is_mon_concurrency(void)
5065 {
5066 	return false;
5067 }
5068 
5069 static inline
wlan_hdd_del_p2p_interface(struct hdd_context * hdd_ctx)5070 void wlan_hdd_del_p2p_interface(struct hdd_context *hdd_ctx)
5071 {
5072 }
5073 
hdd_reset_monitor_interface(struct hdd_adapter * sta_adapter)5074 static inline void hdd_reset_monitor_interface(struct hdd_adapter *sta_adapter)
5075 {
5076 }
5077 
hdd_is_pkt_capture_mon_enable(struct hdd_adapter * adapter)5078 static inline int hdd_is_pkt_capture_mon_enable(struct hdd_adapter *adapter)
5079 {
5080 	return 0;
5081 }
5082 #endif /* WLAN_FEATURE_PKT_CAPTURE */
5083 /**
5084  * wlan_hdd_is_session_type_monitor() - check if session type is MONITOR
5085  * @session_type: session type
5086  *
5087  * Return: True - if session type for adapter is monitor, else False
5088  *
5089  */
5090 bool wlan_hdd_is_session_type_monitor(uint8_t session_type);
5091 
5092 /**
5093  * wlan_hdd_add_monitor_check() - check for monitor intf and add if needed
5094  * @hdd_ctx: pointer to hdd context
5095  * @adapter: output pointer to hold created monitor adapter
5096  * @name: name of the interface
5097  * @rtnl_held: True if RTNL lock is held
5098  * @name_assign_type: the name of assign type of the netdev
5099  * @is_rx_mon: if monitor mode is getting enabled
5100  *
5101  * Return: 0 - on success
5102  *         err code - on failure
5103  */
5104 int wlan_hdd_add_monitor_check(struct hdd_context *hdd_ctx,
5105 			       struct hdd_adapter **adapter,
5106 			       const char *name, bool rtnl_held,
5107 			       unsigned char name_assign_type,
5108 			       bool is_rx_mon);
5109 
5110 #ifdef CONFIG_WLAN_DEBUG_CRASH_INJECT
5111 /**
5112  * hdd_crash_inject() - Inject a crash
5113  * @adapter: Adapter upon which the command was received
5114  * @v1: first value to inject
5115  * @v2: second value to inject
5116  *
5117  * This function is the handler for the crash inject debug feature.
5118  * This feature only exists for internal testing and must not be
5119  * enabled on a production device.
5120  *
5121  * Return: 0 on success and errno on failure
5122  */
5123 int hdd_crash_inject(struct hdd_adapter *adapter, uint32_t v1, uint32_t v2);
5124 #else
5125 static inline
hdd_crash_inject(struct hdd_adapter * adapter,uint32_t v1,uint32_t v2)5126 int hdd_crash_inject(struct hdd_adapter *adapter, uint32_t v1, uint32_t v2)
5127 {
5128 	return -ENOTSUPP;
5129 }
5130 #endif
5131 
5132 #ifdef FEATURE_MONITOR_MODE_SUPPORT
5133 
5134 void hdd_sme_monitor_mode_callback(uint8_t vdev_id);
5135 
5136 QDF_STATUS hdd_monitor_mode_vdev_status(struct hdd_adapter *adapter);
5137 
5138 QDF_STATUS hdd_monitor_mode_qdf_create_event(struct hdd_adapter *adapter,
5139 					     uint8_t session_type);
5140 #else
hdd_sme_monitor_mode_callback(uint8_t vdev_id)5141 static inline void hdd_sme_monitor_mode_callback(uint8_t vdev_id) {}
5142 
5143 static inline QDF_STATUS
hdd_monitor_mode_vdev_status(struct hdd_adapter * adapter)5144 hdd_monitor_mode_vdev_status(struct hdd_adapter *adapter)
5145 {
5146 	return QDF_STATUS_SUCCESS;
5147 }
5148 
5149 static inline QDF_STATUS
hdd_monitor_mode_qdf_create_event(struct hdd_adapter * adapter,uint8_t session_type)5150 hdd_monitor_mode_qdf_create_event(struct hdd_adapter *adapter,
5151 				  uint8_t session_type)
5152 {
5153 	return QDF_STATUS_SUCCESS;
5154 }
5155 #endif
5156 
5157 /**
5158  * hdd_cleanup_conn_info() - Cleanup connectin info
5159  * @link_info: pointer to link_info struct in adapter
5160  *
5161  * This function frees the memory allocated for the connection
5162  * info structure
5163  *
5164  * Return: none
5165  */
5166 void hdd_cleanup_conn_info(struct wlan_hdd_link_info *link_info);
5167 
5168 #ifdef FEATURE_WLAN_RESIDENT_DRIVER
5169 extern char *country_code;
5170 extern int con_mode;
5171 extern const struct kernel_param_ops con_mode_ops;
5172 extern int con_mode_ftm;
5173 extern const struct kernel_param_ops con_mode_ftm_ops;
5174 #endif
5175 
5176 /**
5177  * hdd_driver_load() - Perform the driver-level load operation
5178  *
5179  * Note: this is used in both static and DLKM driver builds
5180  *
5181  * Return: Errno
5182  */
5183 int hdd_driver_load(void);
5184 
5185 /**
5186  * hdd_driver_unload() - Performs the driver-level unload operation
5187  *
5188  * Note: this is used in both static and DLKM driver builds
5189  *
5190  * Return: None
5191  */
5192 void hdd_driver_unload(void);
5193 
5194 /**
5195  * hdd_init_start_completion() - Init the completion variable to wait on ON/OFF
5196  *
5197  * Return: None
5198  */
5199 void hdd_init_start_completion(void);
5200 
5201 #if defined(CLD_PM_QOS) && defined(WLAN_FEATURE_LL_MODE)
5202 /**
5203  * hdd_beacon_latency_event_cb() - Callback function to get latency level
5204  * @latency_level: latency level received from firmware
5205  *
5206  * Return: None
5207  */
5208 void hdd_beacon_latency_event_cb(uint32_t latency_level);
5209 #else
hdd_beacon_latency_event_cb(uint32_t latency_level)5210 static inline void hdd_beacon_latency_event_cb(uint32_t latency_level)
5211 {
5212 }
5213 #endif
5214 
5215 #if defined(CLD_PM_QOS) || defined(FEATURE_RUNTIME_PM)
5216 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0))
5217 /**
5218  * wlan_hdd_get_default_pm_qos_cpu_latency() - get default PM QOS CPU latency
5219  *
5220  * Return: PM QOS CPU latency value
5221  */
wlan_hdd_get_default_pm_qos_cpu_latency(void)5222 static inline unsigned long wlan_hdd_get_default_pm_qos_cpu_latency(void)
5223 {
5224 	return PM_QOS_CPU_LATENCY_DEFAULT_VALUE;
5225 }
5226 #else
wlan_hdd_get_default_pm_qos_cpu_latency(void)5227 static inline unsigned long wlan_hdd_get_default_pm_qos_cpu_latency(void)
5228 {
5229 	return PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
5230 }
5231 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0) */
5232 #endif /* defined(CLD_PM_QOS) || defined(FEATURE_RUNTIME_PM) */
5233 
5234 /**
5235  * hdd_get_wifi_standard() - Get wifi standard
5236  * @hdd_ctx: hdd context pointer
5237  * @dot11_mode: hdd dot11 mode
5238  * @band_capability: band capability bitmap
5239  *
5240  * Return: WMI_HOST_WIFI_STANDARD
5241  */
5242 WMI_HOST_WIFI_STANDARD
5243 hdd_get_wifi_standard(struct hdd_context *hdd_ctx,
5244 		      enum hdd_dot11_mode dot11_mode, uint32_t band_capability);
5245 
5246 /**
5247  * hdd_is_runtime_pm_enabled - if runtime pm enabled
5248  * @hdd_ctx: hdd context
5249  *
5250  * Return: true if runtime pm enabled. false if disabled.
5251  */
5252 bool hdd_is_runtime_pm_enabled(struct hdd_context *hdd_ctx);
5253 
5254 /**
5255  * hdd_netdev_update_features() - Update the netdev features
5256  * @adapter: adapter associated with the net_device
5257  *
5258  * This func holds the rtnl_lock. Do not call with rtnl_lock held.
5259  *
5260  * Return: None
5261  */
5262 void hdd_netdev_update_features(struct hdd_adapter *adapter);
5263 
5264 /**
5265  * hdd_stop_no_trans() - HDD stop function
5266  * @dev:	Pointer to net_device structure
5267  *
5268  * This is called in response to ifconfig down. Vdev sync transaction
5269  * should be started before calling this API.
5270  *
5271  * Return: 0 for success; non-zero for failure
5272  */
5273 int hdd_stop_no_trans(struct net_device *dev);
5274 
5275 #if defined(CLD_PM_QOS)
5276 /**
5277  * wlan_hdd_set_pm_qos_request() - Function to set pm_qos config in wlm mode
5278  * @hdd_ctx: HDD context
5279  * @pm_qos_request: pm_qos_request flag
5280  *
5281  * Return: None
5282  */
5283 void wlan_hdd_set_pm_qos_request(struct hdd_context *hdd_ctx,
5284 				 bool pm_qos_request);
5285 #else
5286 static inline
wlan_hdd_set_pm_qos_request(struct hdd_context * hdd_ctx,bool pm_qos_request)5287 void wlan_hdd_set_pm_qos_request(struct hdd_context *hdd_ctx,
5288 				 bool pm_qos_request)
5289 {
5290 }
5291 #endif
5292 
5293 /**
5294  * hdd_nl80211_chwidth_to_chwidth - Get sir chan width from nl chan width
5295  * @nl80211_chwidth: enum nl80211_chan_width
5296  *
5297  * Return: enum eSirMacHTChannelWidth or -INVAL for unsupported nl chan width
5298  */
5299 enum eSirMacHTChannelWidth
5300 hdd_nl80211_chwidth_to_chwidth(uint8_t nl80211_chwidth);
5301 
5302 /**
5303  * hdd_chwidth_to_nl80211_chwidth - Get nl chan width from sir chan width
5304  * @chwidth: enum eSirMacHTChannelWidth
5305  *
5306  * Return: enum nl80211_chan_width or 0xFF for unsupported sir chan width
5307  */
5308 uint8_t hdd_chwidth_to_nl80211_chwidth(enum eSirMacHTChannelWidth chwidth);
5309 
5310 /**
5311  * hdd_phy_chwidth_to_nl80211_chwidth() - Get nl chan width from phy chan width
5312  * @chwidth: enum phy_ch_width
5313  *
5314  * Return: enum nl80211_chan_width or 0xFF for unsupported phy chan width
5315  */
5316 uint8_t hdd_phy_chwidth_to_nl80211_chwidth(enum phy_ch_width chwidth);
5317 
5318 /**
5319  * wlan_hdd_get_channel_bw() - get channel bandwidth
5320  * @width: input channel width in nl80211_chan_width value
5321  *
5322  * Return: channel width value defined by driver
5323  */
5324 enum hw_mode_bandwidth wlan_hdd_get_channel_bw(enum nl80211_chan_width width);
5325 
5326 /**
5327  * hdd_ch_width_str() - Get string for channel width
5328  * @ch_width: channel width from connect info
5329  *
5330  * Return: User readable string for channel width
5331  */
5332 uint8_t *hdd_ch_width_str(enum phy_ch_width ch_width);
5333 
5334 /**
5335  * hdd_we_set_ch_width - Function to update channel width
5336  * @link_info: Link info pointer in HDD adapter.
5337  * @ch_width: enum eSirMacHTChannelWidth
5338  *
5339  * Return: 0 for success otherwise failure
5340  */
5341 int hdd_we_set_ch_width(struct wlan_hdd_link_info *link_info, int ch_width);
5342 
5343 /**
5344  * hdd_stop_adapter_ext: close/delete the vdev session in host/fw.
5345  * @hdd_ctx: HDD context
5346  * @adapter: Pointer to hdd_adapter
5347  *
5348  * Close/delete the vdev session in host/firmware.
5349  */
5350 QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx,
5351 				struct hdd_adapter *adapter);
5352 
5353 /**
5354  * hdd_check_for_net_dev_ref_leak: check for vdev reference leak in driver
5355  * @adapter: Pointer to hdd_adapter
5356  *
5357  * various function take netdev reference to get protected against netdev
5358  * getting deleted in parallel, check if all those references are cleanly
5359  * released.
5360  */
5361 void hdd_check_for_net_dev_ref_leak(struct hdd_adapter *adapter);
5362 
5363 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_HDD_MULTI_VDEV_SINGLE_NDEV)
5364 
5365 /**
5366  * hdd_link_switch_vdev_mac_addr_update() - API to update OSIF/HDD on VDEV
5367  * mac addr update due to link switch.
5368  * @ieee_old_link_id: Current  IEEE link ID of VDEV prior to link switch
5369  * @ieee_new_link_id: New IEEE link ID of VDEV post link switch
5370  * @vdev_id: VDEV undergoing link switch.
5371  *
5372  * Check if both @ieee_old_link_id and @ieee_new_link_id are part of adapter
5373  * corresponding to @vdev_id. Then take necessary actions to support link switch
5374  * MAC update and update DP to change link MAC address to new link's address.
5375  *
5376  * Return: QDF_STATUS
5377  */
5378 QDF_STATUS
5379 hdd_link_switch_vdev_mac_addr_update(int32_t ieee_old_link_id,
5380 				     int32_t ieee_new_link_id, uint8_t vdev_id);
5381 
5382 /**
5383  * hdd_get_link_info_by_ieee_link_id() - Find link info pointer matching with
5384  * IEEE link ID.
5385  * @adapter: HDD adapter
5386  * @link_id: IEEE link ID to search for.
5387  *
5388  * Search the station ctx connection info for matching link ID in @adapter and
5389  * return the link info pointer on match. The IEEE link ID is updated in station
5390  * context during MLO connection and reset on disconnection.
5391  *
5392  * Return: link info pointer
5393  */
5394 struct wlan_hdd_link_info *
5395 hdd_get_link_info_by_ieee_link_id(struct hdd_adapter *adapter, int32_t link_id);
5396 #endif
5397 
5398 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
5399 /**
5400  * hdd_dynamic_mac_address_set(): API to set MAC address, when interface
5401  *                                is up.
5402  * @link_info: Link info pointer in HDD adapter
5403  * @mac_addr: MAC address to set
5404  * @mld_addr: MLD address to set
5405  * @update_self_peer: Set to true to update self peer's address
5406  *
5407  * This API is used to update the current VDEV MAC address.
5408  *
5409  * Return: 0 for success. non zero valure for failure.
5410  */
5411 int hdd_dynamic_mac_address_set(struct wlan_hdd_link_info *link_info,
5412 				struct qdf_mac_addr mac_addr,
5413 				struct qdf_mac_addr mld_addr,
5414 				bool update_self_peer);
5415 
5416 /**
5417  * hdd_is_dynamic_set_mac_addr_allowed() - API to check dynamic MAC address
5418  *				           update is allowed or not
5419  * @adapter: Pointer to the adapter structure
5420  *
5421  * Return: true or false
5422  */
5423 bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter);
5424 
5425 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC)
5426 /**
5427  * hdd_update_vdev_mac_address() - Update VDEV MAC address dynamically
5428  * @adapter: Pointer to HDD adapter
5429  * @mac_addr: MAC address to be updated
5430  *
5431  * API to update VDEV MAC address during interface is in UP state.
5432  *
5433  * Return: 0 for Success. Error code for failure
5434  */
5435 int hdd_update_vdev_mac_address(struct hdd_adapter *adapter,
5436 				struct qdf_mac_addr mac_addr);
5437 #else
hdd_update_vdev_mac_address(struct hdd_adapter * adapter,struct qdf_mac_addr mac_addr)5438 static inline int hdd_update_vdev_mac_address(struct hdd_adapter *adapter,
5439 					      struct qdf_mac_addr mac_addr)
5440 {
5441 	struct qdf_mac_addr mld_addr = QDF_MAC_ADDR_ZERO_INIT;
5442 
5443 	return hdd_dynamic_mac_address_set(adapter->deflink, mac_addr,
5444 					   mld_addr, true);
5445 }
5446 #endif /* WLAN_FEATURE_11BE_MLO */
5447 #else
hdd_update_vdev_mac_address(struct hdd_adapter * adapter,struct qdf_mac_addr mac_addr)5448 static inline int hdd_update_vdev_mac_address(struct hdd_adapter *adapter,
5449 					      struct qdf_mac_addr mac_addr)
5450 {
5451 	return 0;
5452 }
5453 
5454 static inline int
hdd_dynamic_mac_address_set(struct wlan_hdd_link_info * link_info,struct qdf_mac_addr mac_addr,struct qdf_mac_addr mld_addr,bool update_self_peer)5455 hdd_dynamic_mac_address_set(struct wlan_hdd_link_info *link_info,
5456 			    struct qdf_mac_addr mac_addr,
5457 			    struct qdf_mac_addr mld_addr,
5458 			    bool update_self_peer)
5459 {
5460 	return 0;
5461 }
5462 
5463 static inline bool
hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter * adapter)5464 hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter)
5465 {
5466 	return false;
5467 }
5468 
5469 #endif /* WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE */
5470 
5471 #if defined(WLAN_FEATURE_ROAM_OFFLOAD) && \
5472 defined(FEATURE_RX_LINKSPEED_ROAM_TRIGGER)
5473 /**
5474  * wlan_hdd_link_speed_update() - Update link speed to F/W
5475  * @psoc: pointer to soc
5476  * @vdev_id: Vdev ID
5477  * @is_link_speed_good: true means good link speed,  false means bad link speed
5478  *
5479  * Return: None
5480  */
5481 void wlan_hdd_link_speed_update(struct wlan_objmgr_psoc *psoc,
5482 				uint8_t vdev_id,
5483 				bool is_link_speed_good);
5484 #else
wlan_hdd_link_speed_update(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool is_link_speed_good)5485 static inline void wlan_hdd_link_speed_update(struct wlan_objmgr_psoc *psoc,
5486 					      uint8_t vdev_id,
5487 					      bool is_link_speed_good)
5488 {}
5489 #endif
5490 
5491 /**
5492  * hdd_update_multicast_list() - update the multicast list
5493  * @vdev: pointer to VDEV object
5494  *
5495  * Return: none
5496  */
5497 void hdd_update_multicast_list(struct wlan_objmgr_vdev *vdev);
5498 
5499 /**
5500  * hdd_set_sar_init_index() - Set SAR safety index at init.
5501  * @hdd_ctx: HDD context
5502  *
5503  */
5504 #ifdef SAR_SAFETY_FEATURE
5505 void hdd_set_sar_init_index(struct hdd_context *hdd_ctx);
5506 #else
hdd_set_sar_init_index(struct hdd_context * hdd_ctx)5507 static inline void hdd_set_sar_init_index(struct hdd_context *hdd_ctx)
5508 {}
5509 #endif
5510 /**
5511  * hdd_send_coex_traffic_shaping_mode() - Send coex traffic shaping mode
5512  * to FW
5513  * @vdev_id: vdev ID
5514  * @mode: traffic shaping mode
5515  *
5516  * This function is used to send coex traffic shaping mode to FW
5517  *
5518  * Return: 0 on success and -EINVAL on failure
5519  */
5520 int hdd_send_coex_traffic_shaping_mode(uint8_t vdev_id, uint8_t mode);
5521 
5522 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
5523 /**
5524  * wlan_hdd_lpc_handle_concurrency() - Handle local packet capture
5525  * concurrency scenario
5526  * @hdd_ctx: hdd_ctx
5527  * @is_virtual_iface: is virtual interface
5528  *
5529  * This function takes care of handling concurrency scenario
5530  * If STA+Mon present and SAP is coming up, terminate Mon and let SAP come up
5531  * If STA+Mon present and P2P is coming up, terminate Mon and let P2P come up
5532  * If STA+Mon present and NAN is coming up, terminate Mon and let NAN come up
5533  *
5534  * Return: none
5535  */
5536 void wlan_hdd_lpc_handle_concurrency(struct hdd_context *hdd_ctx,
5537 				     bool is_virtual_iface);
5538 
5539 /**
5540  * hdd_lpc_is_work_scheduled() - function to return if lpc wq scheduled
5541  * @hdd_ctx: hdd_ctx
5542  *
5543  * Return: true if scheduled; false otherwise
5544  */
5545 bool hdd_lpc_is_work_scheduled(struct hdd_context *hdd_ctx);
5546 
5547 #else
5548 static inline void
wlan_hdd_lpc_handle_concurrency(struct hdd_context * hdd_ctx,bool is_virtual_iface)5549 wlan_hdd_lpc_handle_concurrency(struct hdd_context *hdd_ctx,
5550 				bool is_virtual_iface)
5551 {}
5552 
5553 static inline bool
hdd_lpc_is_work_scheduled(struct hdd_context * hdd_ctx)5554 hdd_lpc_is_work_scheduled(struct hdd_context *hdd_ctx)
5555 {
5556 	return false;
5557 }
5558 #endif
5559 
5560 /**
5561  * hdd_allow_new_intf() - Allow new intf created or not
5562  * @hdd_ctx: hdd context
5563  * @mode: qdf opmode of new interface
5564  *
5565  * Return: true if allowed, otherwise false
5566  */
5567 bool hdd_allow_new_intf(struct hdd_context *hdd_ctx,
5568 			enum QDF_OPMODE mode);
5569 #endif /* end #if !defined(WLAN_HDD_MAIN_H) */
5570