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