1 /** @file mlan_main.h
2  *
3  *  @brief This file defines the private and adapter data
4  *  structures and declares global function prototypes used
5  *  in MLAN module.
6  *
7  *  Copyright 2008-2024 NXP
8  *
9  *  SPDX-License-Identifier: BSD-3-Clause
10  *
11  */
12 
13 /******************************************************
14 Change log:
15     10/13/2008: initial version
16 ******************************************************/
17 
18 #ifndef _MLAN_MAIN_H_
19 #define _MLAN_MAIN_H_
20 #ifndef RW610
21 #include "mlan_main_defs.h"
22 #endif
23 #ifdef DEBUG_LEVEL1
24 extern t_void (*print_callback)(IN t_void *pmoal_handle, IN t_u32 level, IN t_s8 *pformat, IN...);
25 
26 extern mlan_status (*get_sys_time_callback)(IN t_void *pmoal_handle, OUT t_u32 *psec, OUT t_u32 *pusec);
27 
28 extern t_u32 drvdbg;
29 
30 #ifdef DEBUG_LEVEL2
31 #define PRINTM_MINFO(msg...)                      \
32     do                                            \
33     {                                             \
34         if ((drvdbg & MINFO) && (print_callback)) \
35             print_callback(MNULL, MINFO, msg);    \
36     } while (false)
37 #define PRINTM_MWARN(msg...)                      \
38     do                                            \
39     {                                             \
40         if ((drvdbg & MWARN) && (print_callback)) \
41             print_callback(MNULL, MWARN, msg);    \
42     } while (false)
43 #define PRINTM_MENTRY(msg...)                      \
44     do                                             \
45     {                                              \
46         if ((drvdbg & MENTRY) && (print_callback)) \
47             print_callback(MNULL, MENTRY, msg);    \
48     } while (false)
49 #define PRINTM_GET_SYS_TIME(level, psec, pusec)          \
50     do                                                   \
51     {                                                    \
52         if ((level & drvdbg) && (get_sys_time_callback)) \
53             get_sys_time_callback(MNULL, psec, pusec);   \
54     } while (false)
55 
56 /** Hexdump for level-2 debugging */
57 #define HEXDUMP(x, y, z)                                        \
58     do                                                          \
59     {                                                           \
60         if ((drvdbg & (MHEX_DUMP | MINFO)) && (print_callback)) \
61             print_callback(MNULL, MHEX_DUMP | MINFO, x, y, z);  \
62     } while (false)
63 
64 #else
65 
66 #define PRINTM_MINFO(msg...) \
67     do                       \
68     {                        \
69     } while (false)
70 #define PRINTM_MWARN(msg...) \
71     do                       \
72     {                        \
73     } while (false)
74 #define PRINTM_MENTRY(msg...) \
75     do                        \
76     {                         \
77     } while (false)
78 
79 #define PRINTM_GET_SYS_TIME(level, psec, pusec)                                                  \
80     do                                                                                           \
81     {                                                                                            \
82         if ((level & drvdbg) && (get_sys_time_callback) && (level != MINFO) && (level != MWARN)) \
83             get_sys_time_callback(MNULL, psec, pusec);                                           \
84     } while (false)
85 
86 /** Hexdump for debugging */
87 #define HEXDUMP(x, y, z) \
88     do                   \
89     {                    \
90     } while (false)
91 
92 #endif /* DEBUG_LEVEL2 */
93 
94 #define PRINTM_MFW_D(msg...)                      \
95     do                                            \
96     {                                             \
97         if ((drvdbg & MFW_D) && (print_callback)) \
98             print_callback(MNULL, MFW_D, msg);    \
99     } while (false)
100 #define PRINTM_MCMD_D(msg...)                      \
101     do                                             \
102     {                                              \
103         if ((drvdbg & MCMD_D) && (print_callback)) \
104             print_callback(MNULL, MCMD_D, msg);    \
105     } while (false)
106 #define PRINTM_MDAT_D(msg...)                      \
107     do                                             \
108     {                                              \
109         if ((drvdbg & MDAT_D) && (print_callback)) \
110             print_callback(MNULL, MDAT_D, msg);    \
111     } while (false)
112 #define PRINTM_MIF_D(msg...)                      \
113     do                                            \
114     {                                             \
115         if ((drvdbg & MIF_D) && (print_callback)) \
116             print_callback(MNULL, MIF_D, msg);    \
117     } while (false)
118 
119 #define PRINTM_MIOCTL(msg...)                      \
120     do                                             \
121     {                                              \
122         if ((drvdbg & MIOCTL) && (print_callback)) \
123             print_callback(MNULL, MIOCTL, msg);    \
124     } while (false)
125 #define PRINTM_MINTR(msg...)                      \
126     do                                            \
127     {                                             \
128         if ((drvdbg & MINTR) && (print_callback)) \
129             print_callback(MNULL, MINTR, msg);    \
130     } while (false)
131 #define PRINTM_MEVENT(msg...)                      \
132     do                                             \
133     {                                              \
134         if ((drvdbg & MEVENT) && (print_callback)) \
135             print_callback(MNULL, MEVENT, msg);    \
136     } while (false)
137 #define PRINTM_MCMND(msg...)                      \
138     do                                            \
139     {                                             \
140         if ((drvdbg & MCMND) && (print_callback)) \
141             print_callback(MNULL, MCMND, msg);    \
142     } while (false)
143 #define PRINTM_MDATA(msg...)                      \
144     do                                            \
145     {                                             \
146         if ((drvdbg & MDATA) && (print_callback)) \
147             print_callback(MNULL, MDATA, msg);    \
148     } while (false)
149 #define PRINTM_MERROR(msg...)                      \
150     do                                             \
151     {                                              \
152         if ((drvdbg & MERROR) && (print_callback)) \
153             print_callback(MNULL, MERROR, msg);    \
154     } while (false)
155 #define PRINTM_MFATAL(msg...)                      \
156     do                                             \
157     {                                              \
158         if ((drvdbg & MFATAL) && (print_callback)) \
159             print_callback(MNULL, MFATAL, msg);    \
160     } while (false)
161 #define PRINTM_MMSG(msg...)                      \
162     do                                           \
163     {                                            \
164         if ((drvdbg & MMSG) && (print_callback)) \
165             print_callback(MNULL, MMSG, msg);    \
166     } while (false)
167 
168 #define PRINTM(level, msg...) PRINTM_##level(msg)
169 
170 /** Log debug message */
171 #ifdef __GNUC__
172 #define PRINTM_NETINTF(level, pmpriv)                                                                               \
173     do                                                                                                              \
174     {                                                                                                               \
175         if ((drvdbg & level) && pmpriv && pmpriv->adapter->callbacks.moal_print_netintf)                            \
176             pmpriv->adapter->callbacks.moal_print_netintf(pmpriv->adapter->pmoal_handle, pmpriv->bss_index, level); \
177     } while (false)
178 #endif /* __GNUC__ */
179 
180 /** Max hex dump data length */
181 #define MAX_DATA_DUMP_LEN 64
182 
183 /** Debug hexdump for level-1 debugging */
184 #define DBG_HEXDUMP(level, x, y, z)                            \
185     do                                                         \
186     {                                                          \
187         if ((drvdbg & level) && print_callback)                \
188             print_callback(MNULL, MHEX_DUMP | level, x, y, z); \
189     } while (false)
190 
191 #else /* DEBUG_LEVEL1 */
192 
193 #define PRINTM(level, msg...) \
194     do                        \
195     {                         \
196     } while ((bool)false)
197 
198 #define PRINTM_NETINTF(level, pmpriv) \
199     do                                \
200     {                                 \
201     } while ((bool)false)
202 
203 /** Debug hexdump for level-1 debugging */
204 #define DBG_HEXDUMP(level, x, y, z) \
205     do                              \
206     {                               \
207     } while ((bool)false)
208 
209 /** Hexdump for debugging */
210 #define HEXDUMP(x, y, z) \
211     do                   \
212     {                    \
213     } while ((bool)false)
214 
215 #define PRINTM_GET_SYS_TIME(level, psec, pusec) \
216     do                                          \
217     {                                           \
218     } while ((bool)false)
219 
220 #endif /* DEBUG_LEVEL1 */
221 
222 /** Log entry point for debugging */
223 #define ENTER()                                      \
224     do                                               \
225     {                                                \
226         PRINTM(MENTRY, "Enter: %s\n", __FUNCTION__); \
227     } while ((bool)false)
228 
229 /** Log exit point for debugging */
230 #define LEAVE()                                      \
231     do                                               \
232     {                                                \
233         PRINTM(MENTRY, "Leave: %s\n", __FUNCTION__); \
234     } while ((bool)false)
235 
236 /** Find minimum */
237 #ifndef MIN
238 #define MIN(a, b) ((a) < (b) ? (a) : (b))
239 #endif
240 
241 /** Find maximum */
242 #ifndef MAX
243 #define MAX(a, b) ((a) > (b) ? (a) : (b))
244 #endif
245 
246 #if 0
247 #ifdef memset
248 #undef memset
249 #endif
250 /** Memset routine */
251 #define memset(adapter, s, c, len) adapter->callbacks.moal_memset(adapter->pmoal_handle, s, c, len)
252 
253 #ifdef memmove
254 #undef memmove
255 #endif
256 /** Memmove routine */
257 #define memmove(adapter, dest, src, len) adapter->callbacks.moal_memmove(adapter->pmoal_handle, dest, src, len)
258 
259 #ifdef memcpy
260 #undef memcpy
261 #endif
262 /** Memcpy routine */
263 #define memcpy(adapter, to, from, len) adapter->callbacks.moal_memcpy(adapter->pmoal_handle, to, from, len)
264 
265 #ifdef memcmp
266 #undef memcmp
267 #endif
268 /** Memcmp routine */
269 #define memcmp(adapter, s1, s2, len) adapter->callbacks.moal_memcmp(adapter->pmoal_handle, s1, s2, len)
270 #endif /* 0 */
271 
272 /* memcpy_ext rountine */
273 #define memcpy_ext(adapter, to, from, len, size) \
274     (adapter->callbacks.moal_memcpy_ext(adapter->pmoal_handle, to, from, len, size))
275 
276 /** Find number of elements */
277 #ifndef NELEMENTS
278 #define NELEMENTS(x) (sizeof(x) / sizeof(x[0]))
279 #endif
280 
281 /** SWAP: swap t_u8 */
282 #define SWAP_U8(a, b) \
283     {                 \
284         t_u8 t;       \
285         t = a;        \
286         a = b;        \
287         b = t;        \
288     }
289 
290 /** SWAP: swap t_u8 */
291 #define SWAP_U16(a, b) \
292     {                  \
293         t_u16 t;       \
294         t = a;         \
295         a = b;         \
296         b = t;         \
297     }
298 
299 /** MLAN MNULL pointer */
300 #ifndef MNULL
301 #define MNULL ((void *)0)
302 #endif
303 
304 /** 16 bits byte swap */
305 #define swap_byte_16(x) ((t_u16)((((t_u16)(x)&0x00ffU) << 8) | (((t_u16)(x)&0xff00U) >> 8)))
306 
307 /** 32 bits byte swap */
308 #define swap_byte_32(x)                                                                                                \
309     ((t_u32)((((t_u32)(x)&0x000000ffUL) << 24) | (((t_u32)(x)&0x0000ff00UL) << 8) | (((t_u32)(x)&0x00ff0000UL) >> 8) | \
310              (((t_u32)(x)&0xff000000UL) >> 24)))
311 
312 /** 64 bits byte swap */
313 #define swap_byte_64(x)                                                                                              \
314     ((t_u64)((t_u64)(((t_u64)(x)&0x00000000000000ffULL) << 56) | (t_u64)(((t_u64)(x)&0x000000000000ff00ULL) << 40) | \
315              (t_u64)(((t_u64)(x)&0x0000000000ff0000ULL) << 24) | (t_u64)(((t_u64)(x)&0x00000000ff000000ULL) << 8) |  \
316              (t_u64)(((t_u64)(x)&0x000000ff00000000ULL) >> 8) | (t_u64)(((t_u64)(x)&0x0000ff0000000000ULL) >> 24) |  \
317              (t_u64)(((t_u64)(x)&0x00ff000000000000ULL) >> 40) | (t_u64)(((t_u64)(x)&0xff00000000000000ULL) >> 56)))
318 
319 #ifdef BIG_ENDIAN_SUPPORT
320 /** Convert ulong n/w to host */
321 #define mlan_ntohl(x) x
322 /** Convert host ulong to n/w */
323 #define mlan_htonl(x) x
324 /** Convert n/w to host */
325 #define mlan_ntohs(x) x
326 /** Convert host to n/w */
327 #define mlan_htons(x) x
328 /** Convert from 16 bit little endian format to CPU format */
329 #define wlan_le16_to_cpu(x) swap_byte_16(x)
330 /** Convert from 32 bit little endian format to CPU format */
331 #define wlan_le32_to_cpu(x) swap_byte_32(x)
332 /** Convert from 64 bit little endian format to CPU format */
333 #define wlan_le64_to_cpu(x) swap_byte_64(x)
334 /** Convert to 16 bit little endian format from CPU format */
335 #define wlan_cpu_to_le16(x) swap_byte_16(x)
336 /** Convert to 32 bit little endian format from CPU format */
337 #define wlan_cpu_to_le32(x) swap_byte_32(x)
338 /** Convert to 64 bit little endian format from CPU format */
339 #define wlan_cpu_to_le64(x) swap_byte_64(x)
340 
341 /** Convert TxPD to little endian format from CPU format */
342 #define endian_convert_TxPD(x)                                     \
343     {                                                              \
344         (x)->tx_pkt_length = wlan_cpu_to_le16((x)->tx_pkt_length); \
345         (x)->tx_pkt_offset = wlan_cpu_to_le16((x)->tx_pkt_offset); \
346         (x)->tx_pkt_type   = wlan_cpu_to_le16((x)->tx_pkt_type);   \
347         (x)->tx_control    = wlan_cpu_to_le32((x)->tx_control);    \
348     }
349 
350 /** Convert RxPD from little endian format to CPU format */
351 #define endian_convert_RxPD(x)                                                                     \
352     {                                                                                              \
353         (x)->rx_pkt_length                                 = wlan_le16_to_cpu((x)->rx_pkt_length); \
354         (x)->rx_pkt_offset                                 = wlan_le16_to_cpu((x)->rx_pkt_offset); \
355         (x)->rx_pkt_type                                   = wlan_le16_to_cpu((x)->rx_pkt_type);   \
356         (x)->seq_num                                       = wlan_le16_to_cpu((x)->seq_num);       \
357         #if CONFIG_RSN_REPLAY_DETECTION (x)->hi_rx_count32 = wlan_le32_to_cpu((x)->hi_rx_count32); \
358         (x)->lo_rx_count16                                 = wlan_le16_to_cpu((x)->lo_rx_count16); \
359         #endif
360 }
361 #else
362 /** Convert ulong n/w to host */
363 #define mlan_ntohl(x)       swap_byte_32(x)
364 /** Convert host ulong to n/w */
365 #define mlan_htonl(x)       swap_byte_32(x)
366 /** Convert n/w to host */
367 #define mlan_ntohs(x)       swap_byte_16(x)
368 /** Convert host to n/w */
369 #define mlan_htons(x)       swap_byte_16(x)
370 /** Do nothing */
371 #define wlan_le16_to_cpu(x) x
372 /** Do nothing */
373 #define wlan_le32_to_cpu(x) x
374 /** Do nothing */
375 #define wlan_le64_to_cpu(x) x
376 /** Do nothing */
377 #define wlan_cpu_to_le16(x) x
378 /** Do nothing */
379 #define wlan_cpu_to_le32(x) x
380 /** Do nothing */
381 #define wlan_cpu_to_le64(x) x
382 
383 /** Convert TxPD to little endian format from CPU format */
384 #define endian_convert_TxPD(x) \
385     do                         \
386     {                          \
387     } while (false)
388 /** Convert RxPD from little endian format to CPU format */
389 #define endian_convert_RxPD(x) \
390     do                         \
391     {                          \
392     } while (false)
393 #endif /* BIG_ENDIAN_SUPPORT */
394 
395 /** Global moal_assert_callback */
396 extern t_void (*assert_callback)(IN t_void *pmoal_handle, IN t_u32 cond);
397 
398 /** Assertion */
399 #define MASSERT(cond)                                                   \
400     do                                                                  \
401     {                                                                   \
402         if (!(cond))                                                    \
403         {                                                               \
404             PRINTM(MFATAL, "ASSERT: %s: %i\n", __FUNCTION__, __LINE__); \
405             if (assert_callback != NULL)                                \
406             {                                                           \
407                 assert_callback(MNULL, (t_ptr)(cond));                  \
408             }                                                           \
409             else                                                        \
410             {                                                           \
411                 do                                                      \
412                 {                                                       \
413                 } while (true);                                         \
414             }                                                           \
415         }                                                               \
416     } while (false)
417 
418 /** Upload size */
419 #define WLAN_UPLD_SIZE (2312)
420 
421 /** Maximum event buffer size */
422 #define MAX_EVENT_SIZE 1024
423 
424 /** Maximum event buffer size */
425 #define MAX_P2P_EVENT_SIZE 512
426 
427 #ifdef STA_SUPPORT
428 /** Maximum buffer size for ARP filter */
429 #define ARP_FILTER_MAX_BUF_SIZE 68
430 #endif /* STA_SUPPORT */
431 
432 /** 60 seconds */
433 #define MRVDRV_TIMER_60S 60000
434 /** 10 seconds */
435 #define MRVDRV_TIMER_10S 10000U
436 /** 5 seconds */
437 #define MRVDRV_TIMER_5S 5000
438 /** 1 second */
439 #define MRVDRV_TIMER_1S 1000U
440 
441 /** Maximum size of multicast list */
442 #define MRVDRV_MAX_MULTICAST_LIST_SIZE 32
443 /** Maximum size of channel */
444 #define MRVDRV_MAX_CHANNEL_SIZE 14
445 /** Maximum length of SSID */
446 #define MRVDRV_MAX_SSID_LENGTH 32U
447 /** WEP list macros & data structures */
448 /** Size of key buffer in bytes */
449 #define MRVL_KEY_BUFFER_SIZE_IN_BYTE 16
450 /** Maximum length of WPA key */
451 #define MRVL_MAX_KEY_WPA_KEY_LENGTH 32
452 
453 /** Default listen interval */
454 /* wmsdk: Changed to keep same as was in legacy */
455 #define MLAN_DEFAULT_LISTEN_INTERVAL 10
456 
457 /** Maximum number of region codes */
458 #define MRVDRV_MAX_REGION_CODE 10U
459 
460 /** Maximum number of CFP codes for BG */
461 #define MRVDRV_MAX_CFP_CODE_BG 0
462 /** Maximum number of CFP codes for A */
463 #define MRVDRV_MAX_CFP_CODE_A 5
464 
465 #ifdef RW610
466 /** Default region code */
467 #define MRVDRV_DEFAULT_REGION_CODE 0x10
468 #else
469 /** Default region code */
470 #define MRVDRV_DEFAULT_REGION_CODE 0x00
471 #endif
472 
473 #ifdef RW610
474 /** Default country code */
475 #define MRVDRV_DEFAULT_COUNTRY_CODE "US"
476 #else
477 /** Default country code */
478 #define MRVDRV_DEFAULT_COUNTRY_CODE "WW"
479 #endif
480 
481 /** Japan country code */
482 #define COUNTRY_CODE_JP_40 0x40
483 /** Japan special country code */
484 #define COUNTRY_CODE_JP_FF 0xFF
485 
486 /** Default factor for calculating beacon average */
487 #define DEFAULT_BCN_AVG_FACTOR 8
488 /** Default factor for calculating data average */
489 #define DEFAULT_DATA_AVG_FACTOR 8
490 
491 /** The first valid channel for use */
492 #define FIRST_VALID_CHANNEL 0xffU
493 /** Default Ad-Hoc channel */
494 #define DEFAULT_AD_HOC_CHANNEL 6
495 /** Default Ad-Hoc channel A */
496 #define DEFAULT_AD_HOC_CHANNEL_A 36
497 
498 /** Number of WEP keys */
499 /* fixme: This param has been set to 1 as it is seen in legacy code */
500 /* that only one set is used. If needed could be increased upto 4 */
501 #define MRVL_NUM_WEP_KEY (1U) /* 4 */
502 
503 /** Default multiple DTIM */
504 #define MRVDRV_DEFAULT_MULTIPLE_DTIM 1
505 
506 /** Default beacon missing timeout */
507 #define DEFAULT_BCN_MISS_TIMEOUT 5
508 
509 #if CONFIG_EXT_SCAN_SUPPORT
510 /** Maximum buffer space for beacons retrieved from scan responses */
511 #define MAX_SCAN_BEACON_BUFFER 49152
512 #else
513 #define MAX_SCAN_BEACON_BUFFER 16384
514 #endif
515 /** Default buffer space for beacons retrieved from scan responses */
516 #define DEFAULT_SCAN_BEACON_BUFFER 4096
517 
518 #ifdef RW610
519 #define DEFAULT_11N_TX_BF_CAP 0x19870408
520 #endif
521 
522 /**
523  * @brief Buffer pad space for newly allocated beacons/probe responses
524  *
525  * Beacons are typically 6 bytes longer than an equivalent probe response.
526  *  For each scan response stored, allocate an extra byte pad at the end to
527  *  allow easy expansion to store a beacon in the same memory a probe response
528  *  previously contained
529  */
530 #define SCAN_BEACON_ENTRY_PAD 6
531 
532 /** Scan time specified in the channel TLV for each channel for passive scans */
533 /* wmsdk: Changed this so that UAP connectivity is not lost
534    for more than acceptable value to all known clients.
535    The downside is that some clients whose beacon interval
536    is more than 100mS and does not coincide with uAP
537    passive scan duration will not be listed in the scan */
538 #define MRVDRV_PASSIVE_SCAN_CHAN_TIME 100 /* 200 */
539 
540 /** Scan time specified in the channel TLV for each channel for active scans */
541 /* wmsdk: Note: Modified this to keep same as what was in legacy code. */
542 #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 /* 200 */
543 
544 /** Scan time specified in the channel TLV for each channel for specific scans */
545 #define MRVDRV_SPECIFIC_SCAN_CHAN_TIME 110
546 
547 /**
548  * Max total scan time in milliseconds
549  * The total scan time should be less than scan command timeout value (20s)
550  */
551 #define MRVDRV_MAX_TOTAL_SCAN_TIME (MRVDRV_TIMER_10S * 3U)
552 
553 /** Offset for GTK as it has version to skip past for GTK */
554 #define RSN_GTK_OUI_OFFSET 2
555 
556 /** If OUI is not found */
557 #define MLAN_OUI_NOT_PRESENT 0
558 /** If OUI is found */
559 #define MLAN_OUI_PRESENT 1
560 
561 /** RF antenna selection */
562 #define RF_ANTENNA_MASK(n) ((1 << (n)) - 1)
563 /** RF antenna auto select */
564 #define RF_ANTENNA_AUTO 0xFFFF
565 
566 /** Is cmd_resp, event or data packet received? */
567 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || adapter->event_received || adapter->data_received)
568 
569 /** Type command */
570 #define MLAN_TYPE_CMD 1U
571 /** Type data */
572 #define MLAN_TYPE_DATA 0U
573 /** Type event */
574 #define MLAN_TYPE_EVENT 3U
575 #if CONFIG_FW_VDLL
576 /** Type vdll */
577 #define MLAN_TYPE_VDLL 4U
578 #endif
579 /** Type null data */
580 #define MLAN_TYPE_NULL_DATA 4
581 
582 /** Type bypass data */
583 #define MLAN_TYPE_BYPASS_DATA 5
584 
585 #if CONFIG_RX_ABORT_CFG
586 /** Data structure of Rx abort configuration */
587 typedef struct
588 {
589     /** Enable/Disable Rx abort config */
590     t_u8 enable;
591     /** Rx weak RSSI pkt threshold */
592     int rssi_threshold;
593 } rx_abort_cfg_t;
594 #endif
595 
596 #if CONFIG_RX_ABORT_CFG_EXT
597 /** Data structure of Rx abort configuration */
598 typedef struct
599 {
600     /** Enable/disable dyn rx abort on weak pkt rssi */
601     int enable;
602     /** specify rssi margin */
603     int rssi_margin;
604     /** specify ceil rssi threshold */
605     int ceil_rssi_threshold;
606     /** specify floor rssi threshold */
607     int floor_rssi_threshold;
608     /** current dynamic rssi threshold */
609     int current_dynamic_rssi_threshold;
610     /** rssi config: default or user configured */
611     int rssi_default_config;
612     /** EDMAC status */
613     int edmac_enable;
614 } rx_abort_cfg_ext_t;
615 #endif
616 
617 #if CONFIG_CCK_DESENSE_CFG
618 typedef struct
619 {
620     /** cck desense mode: 0:disable 1:normal 2:dynamic */
621     t_u16 mode;
622     /** specify rssi margin */
623     int margin;
624     /** specify ceil rssi threshold */
625     int ceil_thresh;
626     /** cck desense "on" interval count */
627     int num_on_intervals;
628     /** cck desense "off" interval count */
629     int num_off_intervals;
630 } cck_desense_cfg_t;
631 #endif
632 
633 #ifdef SDIO_MULTI_PORT_TX_AGGR
634 /** Multi port TX aggregation buffer size */
635 #define SDIO_MP_TX_AGGR_DEF_BUF_SIZE (16384) /* 16K */
636 #endif                                       /* SDIO_MULTI_PORT_TX_AGGR */
637 
638 #ifdef SDIO_MULTI_PORT_RX_AGGR
639 /** Multi port RX aggregation buffer size */
640 #define SDIO_MP_RX_AGGR_DEF_BUF_SIZE (16384) /* 16K */
641 #endif                                       /* SDIO_MULTI_PORT_RX_AGGR */
642 
643 /** High threshold at which to start drop packets */
644 #define RX_HIGH_THRESHOLD 1024
645 /** Medium threshold at which to disable Rx BA */
646 #define RX_MED_THRESHOLD 256
647 /** Low threshold to allow Rx BA */
648 #define RX_LOW_THRESHOLD 128
649 
650 /** Debug command number */
651 #define DBG_CMD_NUM 5
652 
653 /** Hotspot status enable */
654 #define HOTSPOT_ENABLED MTRUE
655 /** Hotspot status disable */
656 #define HOTSPOT_DISABLED MFALSE
657 /** inteworking indication in extended capa IE */
658 #define HOTSPOT_ENABLE_INTERWORKING_IND MBIT(0)
659 /** TDLS indication in extended capa IE */
660 #define HOTSPOT_ENABLE_TDLS_IND MBIT(1)
661 
662 #define MLAN_SET_BIT_U64(x, val)   ((x) |= (1ULL << (val)))
663 #define MLAN_SET_BIT(x, val)       ((x) |= (1U << (val)))
664 #define MLAN_CLEAR_BIT_U64(x, val) ((x) &= ~(1ULL << (val)))
665 
666 /** scan GAP value is optional */
667 #define GAP_FLAG_OPTIONAL MBIT(15)
668 
669 /** Info for debug purpose */
670 typedef struct _wlan_dbg
671 {
672     /** Number of host to card command failures */
673     t_u32 num_cmd_host_to_card_failure;
674     /** Number of host to card sleep confirm failures */
675     t_u32 num_cmd_sleep_cfm_host_to_card_failure;
676     /** Number of host to card Tx failures */
677     t_u32 num_tx_host_to_card_failure;
678     /** Number of card to host command/event failures */
679     t_u32 num_cmdevt_card_to_host_failure;
680     /** Number of card to host Rx failures */
681     t_u32 num_rx_card_to_host_failure;
682     /** Number of interrupt read failures */
683     t_u32 num_int_read_failure;
684     /** Last interrupt status */
685     t_u32 last_int_status;
686     /** Number of deauthentication events */
687     t_u32 num_event_deauth;
688     /** Number of disassosiation events */
689     t_u32 num_event_disassoc;
690     /** Number of link lost events */
691     t_u32 num_event_link_lost;
692     /** Number of deauthentication commands */
693     t_u32 num_cmd_deauth;
694     /** Number of association comamnd successes */
695     t_u32 num_cmd_assoc_success;
696     /** Number of association command failures */
697     t_u32 num_cmd_assoc_failure;
698     /** Number of Tx timeouts */
699     t_u32 num_tx_timeout;
700     /** Number of command timeouts */
701     t_u32 num_cmd_timeout;
702     /** Timeout command ID */
703     t_u16 timeout_cmd_id;
704     /** Timeout command action */
705     t_u16 timeout_cmd_act;
706     /** List of last command IDs */
707     t_u16 last_cmd_id[DBG_CMD_NUM];
708     /** List of last command actions */
709     t_u16 last_cmd_act[DBG_CMD_NUM];
710     /** Last command index */
711     t_u16 last_cmd_index;
712     /** List of last command response IDs */
713     t_u16 last_cmd_resp_id[DBG_CMD_NUM];
714     /** Last command response index */
715     t_u16 last_cmd_resp_index;
716     /** List of last events */
717     t_u16 last_event[DBG_CMD_NUM];
718     /** Last event index */
719     t_u16 last_event_index;
720 } wlan_dbg;
721 
722 #if CONFIG_RF_TEST_MODE
723 #define MFG_CMD_SET_TEST_MODE        1
724 #define MFG_CMD_UNSET_TEST_MODE      0
725 #define MFG_CMD_TX_ANT               0x1004
726 #define MFG_CMD_RX_ANT               0x1005
727 #define MFG_CMD_TX_CONT              0x1009
728 #define MFG_CMD_RF_CHAN              0x100A
729 #define MFG_CMD_CLR_RX_ERR           0x1010
730 #define MFG_CMD_TX_FRAME             0x1021
731 #define MFG_CMD_RF_BAND_AG           0x1034
732 #define MFG_CMD_RF_CHANNELBW         0x1044
733 #define MFG_CMD_RADIO_MODE_CFG       0x1211
734 #define MFG_CMD_CONFIG_MAC_HE_TB_TX  0x110A
735 #define MFG_CMD_CONFIG_TRIGGER_FRAME 0x110C
736 #define MFG_CMD_OTP_MAC_ADD          0x108C
737 #define MFG_CMD_OTP_CAL_DATA         0x121A
738 #endif
739 
740 /** Hardware status codes */
741 typedef enum _WLAN_HARDWARE_STATUS
742 {
743     WlanHardwareStatusReady,
744     WlanHardwareStatusInitializing,
745     WlanHardwareStatusInitdone,
746     WlanHardwareStatusReset,
747     WlanHardwareStatusClosing,
748     WlanHardwareStatusNotReady
749 } WLAN_HARDWARE_STATUS;
750 
751 /** WLAN_802_11_POWER_MODE */
752 typedef enum _WLAN_802_11_POWER_MODE
753 {
754     Wlan802_11PowerModeCAM,
755     Wlan802_11PowerModePSP
756 } WLAN_802_11_POWER_MODE;
757 
758 /** Ethernet frame header */
759 typedef MLAN_PACK_START struct _eth_hdr
760 {
761     /** destination eth addr */
762     t_u8 dest_addr[MLAN_MAC_ADDR_LENGTH];
763     /** source ether addr */
764     t_u8 src_addr[MLAN_MAC_ADDR_LENGTH];
765     /** packet type ID field */
766     t_u16 h_proto;
767 } MLAN_PACK_END eth_hdr;
768 
769 /** Ethernet LLC frame header */
770 typedef MLAN_PACK_START struct _eth_llc_hdr
771 {
772     /* destination SAP */
773     t_u8 dsap;
774     /* source SAP */
775     t_u8 ssap;
776     /* LLC control field */
777     t_u8 llc;
778     /* protocol id */
779     t_u8 protid[3];
780     /* ether type field */
781     t_u16 type;
782 } MLAN_PACK_END eth_llc_hdr;
783 
784 /* The IPv4 header */
785 typedef MLAN_PACK_START struct _ip_hdr
786 {
787 #ifdef BIG_ENDIAN_SUPPORT
788     /* version */
789     t_u8 _version : 4;
790     /* header length */
791     t_u8 ihl : 4;
792 #else
793     /* header length */
794     t_u8 ihl : 4;
795     /* version */
796     t_u8 _version : 4;
797 #endif
798     /* type of service */
799     t_u8 _tos;
800     /* total length */
801     t_u16 tot_len;
802     /* identification */
803     t_u16 _id;
804     /* fragment offset field */
805     t_u16 doff;
806     /* time to live */
807     t_u8 _ttl;
808     /* protocol*/
809     t_u8 protocol;
810     /* checksum */
811     t_u16 _chksum;
812     /* source and destination IP addresses */
813     t_u32 src;
814     t_u32 dest;
815 } MLAN_PACK_END ip_hdr;
816 
817 /** TCP HDR flags */
818 typedef MLAN_PACK_START struct _tcp_hdr_flags_t
819 {
820 #ifdef BIG_ENDIAN_SUPPORT
821     t_u16 doff : 4;
822     t_u16 res1 : 4;
823     t_u16 cwr : 1;
824     t_u16 ece : 1;
825     t_u16 urg : 1;
826     t_u16 ack : 1;
827     t_u16 psh : 1;
828     t_u16 rst : 1;
829     t_u16 syn : 1;
830     t_u16 fin : 1;
831 #else
832     t_u16 res1 : 4;
833     t_u16 doff : 4;
834     t_u16 fin : 1;
835     t_u16 syn : 1;
836     t_u16 rst : 1;
837     t_u16 psh : 1;
838     t_u16 ack : 1;
839     t_u16 urg : 1;
840     t_u16 ece : 1;
841     t_u16 cwr : 1;
842 #endif
843 } MLAN_PACK_END tcp_hdr_flags_t;
844 
845 typedef MLAN_PACK_START struct _tcp_hdr
846 {
847     t_u16 src;
848     t_u16 dest;
849     t_u32 seqno;
850     t_u32 ackno;
851     tcp_hdr_flags_t _hdrlen_rsvd_flags;
852     t_u16 wnd;
853     t_u16 chksum;
854     t_u16 urgp;
855 } MLAN_PACK_END tcp_hdr;
856 
857 /** tx param */
858 typedef struct _mlan_tx_param
859 {
860     /** next packet length */
861     t_u32 next_pkt_len;
862 } mlan_tx_param;
863 
864 #if 0
865 /** PS_STATE */
866 typedef enum _PS_STATE
867 {
868     PS_STATE_AWAKE,
869     PS_STATE_PRE_SLEEP,
870     PS_STATE_SLEEP_CFM,
871     PS_STATE_SLEEP
872 } PS_STATE;
873 #endif
874 
875 /** Minimum flush timer for win size of 1 is 50 ms */
876 #define MIN_FLUSH_TIMER_MS 50U
877 /** Tx BA stream table */
878 typedef struct _TxBAStreamTbl TxBAStreamTbl;
879 
880 /** Add BA parameter data structure */
881 typedef struct
882 {
883     /** Window size for initiator */
884     t_u32 tx_win_size;
885     /** Window size for receiver */
886     t_u32 rx_win_size;
887     /** Block ack timeout */
888     t_u32 timeout;
889     /** amsdu support for ADDBA request */
890     t_u8 tx_amsdu;
891     /** amsdu support for ADDBA response */
892     t_u8 rx_amsdu;
893 } add_ba_param_t;
894 
895 /** Send add BA parameter */
896 typedef struct
897 {
898     /** Wi-Fi interface */
899     t_u8 interface;
900     /** TID */
901     int tid;
902     /** Peer MAC address */
903     t_u8 peer_mac[MLAN_MAC_ADDR_LENGTH];
904 } send_add_ba_param_t;
905 
906 /** Tx aggregation data structure */
907 typedef struct _txAggr_t
908 {
909     /** AMPDU user */
910     t_u8 ampdu_user;
911     /** AMPDU AP */
912     t_u8 ampdu_ap;
913     /** AMSDU */
914     t_u8 amsdu;
915 #if CONFIG_AMSDU_IN_AMPDU
916     /** peer AMSDU */
917     t_u8 amsdu_peer;
918 #endif
919     /** TX packet cnt */
920     t_u32 txpkt_cnt;
921     /** TX BA threshold */
922     t_u32 txba_thresh;
923 } tx_aggr_t;
924 
925 /** RA list table */
926 typedef struct _raListTbl raListTbl;
927 
928 /** RA list table */
929 struct _raListTbl
930 {
931     /** Pointer to previous node */
932     raListTbl *pprev;
933     /** Pointer to next node */
934     raListTbl *pnext;
935     /** Buffer list head */
936     mlan_list_head buf_head;
937     /** RA list buffer */
938     t_u8 ra[MLAN_MAC_ADDR_LENGTH];
939     /** total packets in RA list */
940     t_u16 total_pkts;
941     /** packets received */
942     t_u16 packet_count;
943     /** packet count threshold to setup BA */
944     t_u8 ba_packet_threshold;
945     /** is 11n enabled */
946     t_u8 is_11n_enabled;
947     /** max amsdu size */
948     t_u16 max_amsdu;
949     /** tx_pause flag */
950     t_u8 tx_pause;
951 #if CONFIG_WMM
952     /** drop packet count  */
953     t_u16 drop_count;
954 #endif
955 };
956 
957 /** TID table */
958 typedef struct _tidTbl
959 {
960     /** RA list head */
961     mlan_list_head ra_list;
962     /** Current RA list */
963     raListTbl *ra_list_curr;
964 } tid_tbl_t;
965 
966 /** Highest priority setting for a packet (uses voice AC) */
967 #define WMM_HIGHEST_PRIORITY 7
968 /** Highest priority TID  */
969 #define HIGH_PRIO_TID 7
970 /** Lowest priority TID  */
971 #define LOW_PRIO_TID 0
972 /** No packet priority (< lowest) */
973 #define NO_PKT_PRIO_TID -1
974 
975 /** Struct of WMM DESC */
976 typedef struct _wmm_desc
977 {
978     /** TID table */
979     tid_tbl_t tid_tbl_ptr[MAX_NUM_TID];
980     /** Packets out */
981     t_u32 packets_out[MAX_NUM_TID];
982     /** Packets queued */
983     t_u32 pkts_queued[MAX_NUM_TID];
984     /** Spin lock to protect ra_list */
985     t_void *ra_list_spinlock;
986 
987     /** AC status */
988     WmmAcStatus_t ac_status[MAX_AC_QUEUES];
989     /** AC downgraded values */
990     mlan_wmm_ac_e ac_down_graded_vals[MAX_AC_QUEUES];
991 
992     /** Max driver packet delay sent to the firmware for expiry eval */
993     t_u32 drv_pkt_delay_max;
994 
995     /** WMM queue priority table */
996     t_u8 queue_priority[MAX_AC_QUEUES];
997     /** User priority packet transmission control */
998     t_u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
999 
1000     /** Number of transmit packets queued */
1001     mlan_scalar tx_pkts_queued;
1002     /** Tracks highest priority with a packet queued */
1003     mlan_scalar highest_queued_prio;
1004 #if (CONFIG_WMM) && (CONFIG_WMM_DEBUG)
1005     /** Restored historical ralists for debug */
1006     mlan_list_head hist_ra[MAX_AC_QUEUES];
1007     /** Restored historical ralists count */
1008     t_u8 hist_ra_count[MAX_AC_QUEUES];
1009 #endif
1010 } wmm_desc_t;
1011 
1012 /** Security structure */
1013 typedef struct _wlan_802_11_security_t
1014 {
1015     /** WPA enabled flag */
1016     t_u8 wpa_enabled;
1017     /** WPA TKIP flag */
1018     bool is_wpa_tkip;
1019 #if CONFIG_11R
1020     /** FT attempt flag */
1021     bool is_ft;
1022 #endif
1023     /** E-Supplicant enabled flag */
1024     t_u8 ewpa_enabled;
1025     /** WPA2 enabled flag */
1026     t_u8 wpa2_enabled;
1027     /** WAPI enabled flag */
1028     t_u8 wapi_enabled;
1029     /** WAPI key on flag */
1030     t_u8 wapi_key_on;
1031     /** WEP status */
1032     WLAN_802_11_WEP_STATUS wep_status;
1033     /** Authentication mode */
1034     mlan_auth_mode authentication_mode;
1035     /** Encryption mode */
1036     mlan_encryption_mode encryption_mode;
1037 } wlan_802_11_security_t;
1038 
1039 /** Current Basic Service Set State Structure */
1040 typedef struct
1041 {
1042     /** BSS descriptor */
1043     BSSDescriptor_t bss_descriptor;
1044     /** WMM enable? */
1045     t_u8 wmm_enabled;
1046     /** Uapsd enable?*/
1047     t_u8 wmm_uapsd_enabled;
1048     /** Band */
1049     t_u8 band;
1050     /** Number of rates supported */
1051     t_u32 num_of_rates;
1052     /** Supported rates*/
1053     t_u8 data_rates[WLAN_SUPPORTED_RATES];
1054 #if CONFIG_HOST_MLME
1055     /** Host MLME flag*/
1056     t_u8 host_mlme;
1057 #endif
1058     /** prev_bssid */
1059     mlan_802_11_mac_addr prev_bssid;
1060     /** attemp_bssid */
1061     mlan_802_11_mac_addr attemp_bssid;
1062     t_u8 use_mfp;
1063 } current_bss_params_t;
1064 
1065 /** Sleep_params */
1066 typedef struct _sleep_params_t
1067 {
1068     /** Sleep parameter error */
1069     t_u16 sp_error;
1070     /** Sleep parameter offset */
1071     t_u16 sp_offset;
1072     /** Sleep parameter stable time */
1073     t_u16 sp_stable_time;
1074     /** Sleep parameter calibration control */
1075     t_u8 sp_cal_control;
1076     /** Sleep parameter external sleep clock */
1077     t_u8 sp_ext_sleep_clk;
1078     /** Sleep parameter reserved */
1079     t_u16 sp_reserved;
1080 } sleep_params_t;
1081 
1082 /** Sleep_period */
1083 typedef struct sleep_period_t
1084 {
1085     /** Sleep period */
1086     t_u16 period;
1087     /** Reserved */
1088     t_u16 reserved;
1089 } sleep_period_t;
1090 
1091 /** mrvl_wep_key_t */
1092 typedef struct _mrvl_wep_key_t
1093 {
1094     /** Length */
1095     t_u32 length;
1096     /** WEP key index */
1097     t_u32 key_index;
1098     /** WEP key length */
1099     t_u32 key_length;
1100     /** WEP keys */
1101     t_u8 key_material[MRVL_KEY_BUFFER_SIZE_IN_BYTE];
1102 } mrvl_wep_key_t;
1103 
1104 /** Maximum number of region channel */
1105 #define MAX_REGION_CHANNEL_NUM 2U
1106 
1107 /** Region-band mapping table */
1108 typedef struct _region_chan_t
1109 {
1110     /** TRUE if this entry is valid */
1111     t_u8 valid;
1112     /** Region code for US, Japan ... */
1113     t_u8 region;
1114     /** Band B/G/A, used for BAND_CONFIG cmd */
1115     t_u16 band;
1116     /** Actual No. of elements in the array below */
1117     t_u8 num_cfp;
1118     /** chan-freq-txpower mapping table */
1119     const chan_freq_power_t *pcfp;
1120 } region_chan_t;
1121 
1122 /** State of 11d */
1123 typedef enum _state_11d_t
1124 {
1125     DISABLE_11D = 0UL,
1126     ENABLE_11D  = 1UL,
1127 } state_11d_t;
1128 
1129 /** State of 11h */
1130 typedef enum _state_11h_t
1131 {
1132     DISABLE_11H = 0UL,
1133     ENABLE_11H  = 1UL,
1134 } state_11h_t;
1135 
1136 #define DEFAULT_11D_STATE DISABLE_11D
1137 
1138 /** Domain regulatory information */
1139 typedef struct _wlan_802_11d_domain_reg
1140 {
1141     /** Country Code */
1142     t_u8 country_code[COUNTRY_CODE_LEN];
1143     /** band that channels in sub_band belong to */
1144     t_u16 band;
1145     /** No. of subband in below */
1146     t_u8 no_of_sub_band;
1147     /** Subband data to send/last sent */
1148     IEEEtypes_SubbandSet_t sub_band[MRVDRV_MAX_SUBBAND_802_11D];
1149 } wlan_802_11d_domain_reg_t;
1150 
1151 /** Data for state machine */
1152 typedef struct _wlan_802_11d_state
1153 {
1154     /** True for enabling 11D */
1155     state_11d_t enable_11d;
1156     /** True for user enabling 11D */
1157     state_11d_t user_enable_11d;
1158     /** True for user enabling 11D support*/
1159     state_11d_t user_enable_11d_support;
1160 } wlan_802_11d_state_t;
1161 
1162 /** 802.11h State information kept in the 'mlan_private' driver structure */
1163 typedef struct
1164 {
1165     /** Indicates whether 11h is enabled in the driver */
1166     t_bool is_11h_enabled;
1167     /** Indicates whether 11h is active in the firmware */
1168     t_bool is_11h_active;
1169     /** Master device using automatic channel select */
1170     t_bool adhoc_auto_sel_chan;
1171     /** Set when driver receives a STOP TX event from fw */
1172     t_bool tx_disabled;
1173 } wlan_11h_interface_state_t;
1174 
1175 #if UAP_SUPPORT
1176 /** UAP get info callback state kept in the 'mlan_private' driver structure */
1177 typedef struct
1178 {
1179     /** UAP internal callback after wlan_uap_get_channel */
1180     /**  (parameter is really pointer to mlan_private)   */
1181     mlan_status (*get_chan_callback)(t_void *);
1182     /** current ioctl_req (to be completed in callback) */
1183     pmlan_ioctl_req pioctl_req_curr;
1184     /** band_cfg from MrvlIEtypes_channel_band_t */
1185     t_u8 band_config;
1186     /** channel from MrvlIEtypes_channel_band_t */
1187     t_u8 channel;
1188     /** beacon period (in msec) from MrvlIEtypes_beacon_period_t */
1189     t_u16 beacon_period;
1190     /** dtim period (no unit) from MrvlIEtypes_dtim_period_t */
1191     t_u8 dtim_period;
1192     /** Maximum number of stations that will be allowed to connect to the uAP.
1193      */
1194     t_u16 max_sta_count;
1195 } wlan_uap_get_info_cb_t;
1196 #endif
1197 
1198 /** Data structure for WPS information */
1199 typedef struct
1200 {
1201     /** WPS IE */
1202     IEEEtypes_VendorSpecific_t wps_ie;
1203     int wps_mgmt_bitmap_index;
1204     /** Session enable flag */
1205     t_u8 session_enable;
1206 } wps_t;
1207 
1208 typedef struct _mlan_private mlan_private;
1209 typedef struct _mlan_private *pmlan_private;
1210 
1211 /* 802.11D related structs */
1212 typedef struct
1213 {
1214 #ifdef STA_SUPPORT
1215     mlan_status (*wlan_11d_prepare_dnld_domain_info_cmd_p)(mlan_private *pmpriv);
1216     mlan_status (*wlan_11d_create_dnld_countryinfo_p)(mlan_private *pmpriv, t_u16 band);
1217     mlan_status (*wlan_11d_parse_dnld_countryinfo_p)(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc);
1218 #endif
1219 } wlan_11d_fn_t;
1220 
1221 typedef struct _mlan_adapter *pmlan_adapter;
1222 typedef struct _mlan_adapter mlan_adapter;
1223 
1224 typedef struct
1225 {
1226     mlan_status (*wlan_11d_cfg_ioctl_p)(IN mlan_private *pmpriv, IN pmlan_ioctl_req pioctl_req);
1227     mlan_status (*wlan_11d_cfg_domain_info_p)(IN pmlan_adapter pmadapter, IN mlan_ioctl_req *pioctl_req);
1228     mlan_status (*wlan_cmd_802_11d_domain_info_p)(mlan_private *pmpriv, HostCmd_DS_COMMAND *pcmd, t_u16 cmd_action);
1229     mlan_status (*wlan_11d_handle_uap_domain_info_p)(mlan_private *pmpriv,
1230                                                      t_u16 band,
1231                                                      t_u8 *domain_tlv,
1232                                                      t_void *pioctl_buf);
1233 } wlan_11d_apis_t;
1234 
1235 #if CONFIG_WMM
1236 typedef struct
1237 {
1238     mlan_list_head free_list;
1239     int free_cnt;
1240 } outbuf_pool_t;
1241 
1242 typedef struct
1243 {
1244     t_u16 tx_no_media;
1245     t_u16 tx_err_mem;
1246     t_u16 tx_wmm_retried_drop;
1247     t_u16 tx_wmm_pause_drop;
1248     t_u16 tx_wmm_pause_replaced;
1249     t_u16 rx_reorder_drop;
1250 } wlan_pkt_stat_t;
1251 #endif
1252 
1253 /** mlan_operations data structure */
1254 typedef struct _mlan_operations
1255 {
1256     /** cmd handler */
1257     mlan_status (*prepare_cmd)(IN t_void *priv,
1258                                IN t_u16 cmd_no,
1259                                IN t_u16 cmd_action,
1260                                IN t_u32 cmd_oid,
1261                                IN t_void *pioctl_buf,
1262                                IN t_void *pdata_buf,
1263                                IN t_void *pcmd_buf);
1264     /** rx handler */
1265     mlan_status (*process_rx_packet)(IN t_void *adapter, IN pmlan_buffer pmbuf);
1266     /** BSS role */
1267     mlan_bss_role bss_role;
1268 } mlan_operations;
1269 
1270 typedef MLAN_PACK_START struct _mlan_chan_info
1271 {
1272     unsigned int mode;
1273     int freq;
1274     int channel;
1275     int sec_channel_offset;
1276     int bandwidth;
1277     int ht_enabled;
1278     int vht_enabled;
1279     int he_enabled;
1280     int center_freq1;
1281     int center_freq2;
1282 } MLAN_PACK_END mlan_chan_info;
1283 
1284 #if CONFIG_HOST_MLME
1285 
1286 #define WLAN_AUTH_SAE 3
1287 
1288 /** AUTH pending flag */
1289 #define HOST_MLME_AUTH_PENDING MBIT(0)
1290 /** AUTH complete flag */
1291 #define HOST_MLME_AUTH_DONE     MBIT(1)
1292 #define HOST_MLME_ASSOC_PENDING MBIT(2)
1293 #define HOST_MLME_ASSOC_DONE    MBIT(3)
1294 #endif
1295 
1296 #ifdef RW610
1297 /**Adapter_operations data structure*/
1298 typedef struct _bus_operations
1299 {
1300     /** interface to check if fw is hang */
1301     bool (*fw_is_hang)(void);
1302     /**Interface header length*/
1303     t_u32 intf_header_len;
1304 } bus_operations;
1305 #endif
1306 
1307 /** Private structure for MLAN */
1308 struct _mlan_private
1309 {
1310     /** Pointer to mlan_adapter */
1311     struct _mlan_adapter *adapter;
1312     /** BSS index */
1313     t_u8 bss_index;
1314     /** BSS type */
1315     mlan_bss_type bss_type;
1316     /** BSS role */
1317     mlan_bss_role bss_role;
1318     /** BSS Priority */
1319     t_u8 bss_priority;
1320     /** BSS number */
1321     t_u8 bss_num;
1322     /** Frame type */
1323     t_u8 frame_type;
1324     /** MAC address information */
1325     t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
1326 #if CONFIG_P2P
1327     /** P2P MAC address information */
1328     t_u8 curr_p2p_addr[MLAN_MAC_ADDR_LENGTH];
1329 #endif
1330     /** Media connection status */
1331     t_bool media_connected;
1332 
1333     /** Current packet filter */
1334     t_u32 curr_pkt_filter;
1335     /** Infrastructure mode */
1336     mlan_bss_mode bss_mode;
1337 
1338     /** Channel info */
1339     mlan_chan_info chan;
1340 
1341     /** Tx packet control */
1342     t_u32 pkt_tx_ctrl;
1343 
1344     /** Tx power level */
1345     t_u16 tx_power_level;
1346     /** Maximum Tx power level */
1347     t_u8 max_tx_power_level;
1348     /** Minimum Tx power level */
1349     t_u8 min_tx_power_level;
1350     /** Tx rate */
1351     t_u8 tx_rate;
1352 #ifdef SD8801
1353     /** tx ht_info */
1354     t_u8 tx_htinfo;
1355     /** rxpd_htinfo */
1356     t_u8 rxpd_htinfo;
1357 #else
1358     t_u8 tx_rate_info;
1359 #if CONFIG_11AX
1360     /*HE tx tone mode and DCM info*/
1361     t_u8 ext_tx_rate_info;
1362 #endif
1363     /** rxpd_htinfo */
1364     t_u8 rxpd_rate_info;
1365 #endif
1366 
1367 #if CONFIG_11AX
1368     /** UAP 11ax flag */
1369     t_u8 is_11ax_enabled;
1370     /** length of hw he capability */
1371     t_u8 user_hecap_len;
1372     /** user configured 802.11ax HE capability */
1373     t_u8 user_he_cap[54];
1374     /** length of hw he capability */
1375     t_u8 user_2g_hecap_len;
1376     /** user configured 802.11ax HE capability */
1377     t_u8 user_2g_he_cap[54];
1378 #endif
1379 
1380     t_u8 ssid_filter;
1381 
1382     /** Filter SSID */
1383     mlan_802_11_ssid filter_ssid[MRVDRV_MAX_SSID_LIST_LENGTH];
1384     /** max amsdu size */
1385     t_u16 max_amsdu;
1386 #if CONFIG_AMSDU_IN_AMPDU
1387     /** amsdu enabled */
1388     t_bool is_amsdu_enabled;
1389 #endif
1390 #if UAP_SUPPORT
1391     /** UAP 11n flag */
1392     bool is_11n_enabled;
1393     /** UAP 11ac flag */
1394     bool is_11ac_enabled;
1395 #endif /* UAP_SUPPORT */
1396 #if UAP_SUPPORT
1397 #endif /* UAP_SUPPORT */
1398 #if UAP_SUPPORT
1399     /** packet forward control */
1400     t_u8 pkt_fwd;
1401     /**  dropped pkts */
1402     t_u32 num_drop_pkts;
1403 #endif
1404     /** TX beamforming capability */
1405     t_u32 tx_bf_cap;
1406     /** Rx PD rate */
1407     t_u8 rxpd_rate;
1408     /** Rate bitmap */
1409     t_u16 rate_bitmap;
1410     /** Bitmap rates */
1411     t_u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
1412     /** Data rate */
1413     t_u32 data_rate;
1414     /** Data rate index */
1415     t_s8 data_rate_index;
1416     /** Automatic data rate flag */
1417     bool is_data_rate_auto;
1418     /** Factor for calculating beacon average */
1419     t_u16 bcn_avg_factor;
1420     /** Factor for calculating data average */
1421     t_u16 data_avg_factor;
1422     /** Last data RSSI */
1423     t_s16 data_rssi_last;
1424     /** Last data Noise Floor */
1425     t_s16 data_nf_last;
1426     /** Average data RSSI */
1427     t_s16 data_rssi_avg;
1428     /** Averag data Noise Floor */
1429     t_s16 data_nf_avg;
1430     /** Last beacon RSSI */
1431     t_s16 bcn_rssi_last;
1432     /** Last beacon Noise Floor */
1433     t_s16 bcn_nf_last;
1434     /** Average beacon RSSI */
1435     t_s16 bcn_rssi_avg;
1436     /** Average beacon Noise Floor */
1437     t_s16 bcn_nf_avg;
1438 
1439     /** Attempted BSS descriptor */
1440     BSSDescriptor_t *pattempted_bss_desc;
1441 #if CONFIG_GTK_REKEY_OFFLOAD
1442     /** GTK rekey data*/
1443     mlan_ds_misc_gtk_rekey_data gtk_rekey;
1444 #endif
1445 
1446     /** Current SSID/BSSID related parameters*/
1447     current_bss_params_t curr_bss_params;
1448 
1449 #if CONFIG_HOST_MLME
1450     /** flag for auth */
1451     t_u8 auth_flag;
1452     /** flag for auth algorithm */
1453     t_u16 auth_alg;
1454 #if CONFIG_11R
1455     /** flag for ft roam */
1456     t_u8 ft_roam;
1457 #endif
1458 #endif
1459 
1460     /** User selected bands */
1461     t_u16 config_bands;
1462 
1463     /** Beacon period */
1464     t_u16 beacon_period;
1465     /** Listen interval */
1466     t_u16 listen_interval;
1467     /** ATIM window */
1468     t_u16 atim_window;
1469 
1470     /** AdHoc channel */
1471     t_u8 adhoc_channel;
1472     /** AdHoc link sensed flag */
1473     t_u8 adhoc_is_link_sensed;
1474     /** AdHoc operating state */
1475     t_u8 adhoc_state;
1476 #if defined(STA_SUPPORT)
1477     /** AdHoc operating state backup */
1478     t_u8 adhoc_state_prev;
1479     /** AdHoc previous ssid used for Start */
1480     mlan_802_11_ssid adhoc_last_start_ssid;
1481 #endif
1482     /** FSM variable for 11d support */
1483     wlan_802_11d_state_t state_11d;
1484     /** 11d function pointer */
1485     wlan_11d_fn_t *support_11d;
1486     /** 11d Driver function pointer */
1487     wlan_11d_apis_t *support_11d_APIs;
1488     /** FSM variable for 11h support */
1489     wlan_11h_interface_state_t intf_state_11h;
1490 #if UAP_SUPPORT
1491     /** Whether UAP interface has started */
1492     t_bool uap_bss_started;
1493     /** state variable for UAP Get Info callback */
1494     wlan_uap_get_info_cb_t uap_state_chan_cb;
1495 #endif
1496     /** Security related */
1497     /** Encryption parameter */
1498     wlan_802_11_security_t sec_info;
1499     /** WEP keys */
1500     mrvl_wep_key_t wep_key[MRVL_NUM_WEP_KEY];
1501     /** Current WEP key index */
1502     t_u16 wep_key_curr_index;
1503     /** EWPA query 0: disable, 1: enable */
1504     bool ewpa_query;
1505     /** Encryption Key*/
1506     t_u8 wpa_ie[MLAN_WMSDK_MAX_WPA_IE_LEN];
1507     /** WPA IE length */
1508     t_u8 wpa_ie_len;
1509 #if CONFIG_11R
1510     /** MD IE */
1511     t_u8 md_ie[5];
1512     /** MD IE length */
1513     size_t md_ie_len;
1514 #endif
1515     /** GTK set flag */
1516     t_u8 wpa_is_gtk_set;
1517     /** Pointer to the station table */
1518     mlan_list_head sta_list;
1519     /** mgmt frame passthru mask */
1520     t_u32 mgmt_frame_passthru_mask;
1521     /** Advanced Encryption Standard */
1522     bool adhoc_aes_enabled;
1523     /** WMM required */
1524     bool wmm_required;
1525     /** WMM enabled */
1526     bool wmm_enabled;
1527     /** WMM qos info */
1528     t_u8 wmm_qosinfo;
1529     /** WMM related variable*/
1530     wmm_desc_t wmm;
1531 #if CONFIG_WMM
1532     /** Bypass TX queue*/
1533     mlan_list_head bypass_txq;
1534     /** Bypass TX queue cnt*/
1535     t_u8 bypass_txq_cnt;
1536 #endif
1537     /* Mgmt Frame Protection config */
1538     mlan_ds_misc_pmfcfg pmfcfg;
1539 
1540     /* ED MAC MODE config */
1541     mlan_ds_misc_ed_mac_mode ed_mac_mode;
1542 
1543     /** Pointer to the Transmit BA stream table*/
1544     mlan_list_head tx_ba_stream_tbl_ptr;
1545     /** Semaphore to the Transmit BA stream table */
1546     OSA_MUTEX_HANDLE_DEFINE(tx_ba_stream_tbl_lock);
1547     /** Pointer to the priorities for AMSDU/AMPDU table*/
1548     tx_aggr_t aggr_prio_tbl[MAX_NUM_TID];
1549     /** Pointer to the priorities for AMSDU/AMPDU table*/
1550     t_u8 addba_reject[MAX_NUM_TID];
1551     /** Struct to store ADDBA parameters */
1552     add_ba_param_t add_ba_param;
1553     /** last rx_seq */
1554     t_u16 rx_seq[MAX_NUM_TID];
1555     /** Lock to the Receive Reordering table */
1556     OSA_SEMAPHORE_HANDLE_DEFINE(rx_reorder_tbl_lock);
1557     /** Pointer to the Receive Reordering table*/
1558     mlan_list_head rx_reorder_tbl_ptr;
1559     /** Lock for Rx packets */
1560     t_void *rx_pkt_lock;
1561 
1562 #ifdef STA_SUPPORT
1563     /** Generic IEEE IEs passed from the application to be inserted into the
1564      *    association request to firmware
1565      */
1566     t_u8 gen_ie_buf[MRVDRV_GENIE_BUF_SIZE];
1567     /** Length of the data stored in gen_ie_buf */
1568     t_u8 gen_ie_buf_len;
1569 
1570 #if CONFIG_WPA_SUPP
1571     /**
1572      * Default scan ies buffer
1573      */
1574     t_u8 default_scan_ies[MRVDRV_GENIE_BUF_SIZE];
1575     /** Length of the data stored in gen_ie_buf */
1576     t_u8 default_scan_ies_len;
1577 #endif
1578 
1579 #if CONFIG_WPA_SUPP
1580 #if CONFIG_WPA_SUPP_WPS
1581     /** WPS */
1582     wps_t wps;
1583 #endif
1584 #elif (CONFIG_WPS2)
1585     /** WPS */
1586     wps_t wps;
1587 #endif
1588     /** Buffer to store the association req IEs */
1589     t_u8 assoc_req_buf[MRVDRV_ASSOC_RSP_BUF_SIZE];
1590     /** Length of the data stored in assoc_rsp_buf */
1591     t_u32 assoc_req_size;
1592 #endif /* STA_SUPPORT */
1593 
1594     /** function table */
1595     mlan_operations ops;
1596 
1597 #if CONFIG_11K_OFFLOAD
1598     /** 11k flag */
1599     t_u8 enable_11k;
1600 #endif
1601 #if CONFIG_11K
1602     t_u8 enable_host_11k;
1603     int rrm_mgmt_bitmap_index;
1604     t_u8 neighbor_rep_token;
1605 #endif
1606 #if CONFIG_11V
1607     t_u8 bss_trans_query_token;
1608 #endif
1609 
1610     /** Port Control mode */
1611     bool port_ctrl_mode;
1612 
1613     /** Port open flag */
1614     bool port_open;
1615 
1616     /** Port open flag state at time of association attempt */
1617     bool prior_port_status;
1618 
1619     /** Scan block flag */
1620     bool scan_block;
1621     /** IP address operation */
1622     t_u32 op_code;
1623     /** IP address */
1624     t_u8 ip_addr[IPADDR_LEN];
1625     t_u32 hotspot_cfg;
1626     ExtCap_t ext_cap;
1627 #if (CONFIG_WNM_PS)
1628     /** WNM power save mode */
1629     bool wnm_set;
1630 #endif
1631 #if CONFIG_BG_SCAN
1632     t_u8 rssi_low;
1633     t_u8 roaming_enabled;
1634     t_u8 roaming_configured;
1635 #endif
1636 #if CONFIG_BG_SCAN
1637     /** bg_scan_start */
1638     t_u8 bg_scan_start;
1639     /** bg_scan reported */
1640     t_u8 bg_scan_reported;
1641     /** bg_scan config */
1642     wlan_bgscan_cfg scan_cfg;
1643     /** sched scaning flag */
1644     t_u8 sched_scanning;
1645     /** bgscan request id */
1646     t_u64 bg_scan_reqid;
1647 #endif
1648     /* interface pause status */
1649     t_u8 tx_pause;
1650 #if CONFIG_WMM
1651     wlan_pkt_stat_t driver_error_cnt;
1652 #endif
1653 #if CONFIG_1AS
1654     wifi_dot1as_info_t dot1as_info;
1655 #endif
1656 #if CONFIG_DRIVER_MBO
1657     t_u8 enable_mbo;
1658     int mbo_mgmt_bitmap_index;
1659 #endif
1660     /** tx_seq_num */
1661     t_u32 tx_seq_num;
1662 #if CONFIG_WPA_SUPP
1663     int probe_req_index;
1664 #if CONFIG_WPA_SUPP_AP
1665     int beacon_vendor_index;
1666     int beacon_index;
1667     int proberesp_index;
1668     int assocresp_index;
1669     int beacon_wps_index;
1670 #endif
1671 #endif
1672     /** uAP started or not */
1673     bool bss_started;
1674     /** host based uap flag */
1675     bool uap_host_based;
1676     /**UAP operating channel*/
1677     t_u8 uap_channel;
1678     /** uAP MAX STAs */
1679     t_u8 uap_max_sta;
1680 #if CONFIG_TCP_ACK_ENH
1681     bool enable_tcp_ack_enh;
1682 #endif
1683 #if CONFIG_WPA_SUPP_DPP
1684     /** configured by DPP */
1685     bool is_dpp_connect;
1686 #endif
1687 };
1688 
1689 /** BA stream status */
1690 typedef enum _baStatus_e
1691 {
1692     BA_STREAM_NOT_SETUP = 0,
1693     BA_STREAM_SETUP_INPROGRESS,
1694     BA_STREAM_SETUP_COMPLETE
1695 } baStatus_e;
1696 
1697 /** Tx BA stream table */
1698 struct _TxBAStreamTbl
1699 {
1700     /** TxBAStreamTbl previous node */
1701     TxBAStreamTbl *pprev;
1702     /** TxBAStreamTbl next node */
1703     TxBAStreamTbl *pnext;
1704     /** TID */
1705     int ampdu_stat[MAX_NUM_TID];
1706     /** RA */
1707     t_u8 ra[MLAN_MAC_ADDR_LENGTH];
1708     /** BA stream status */
1709     baStatus_e ba_status;
1710     t_u8 amsdu;
1711     t_u32 txpkt_cnt;
1712     t_u32 txba_thresh;
1713     t_u8 ampdu_supported[MAX_NUM_TID];
1714     /** last rx_seq */
1715     t_u16 rx_seq[MAX_NUM_TID];
1716 };
1717 
1718 /** RX reorder table */
1719 typedef struct _RxReorderTbl RxReorderTbl;
1720 
1721 typedef struct
1722 {
1723     /** Timer for flushing */
1724     OSA_TIMER_HANDLE_DEFINE(timer);
1725     /** Timer set flag */
1726     bool timer_is_set;
1727     /** RxReorderTbl ptr */
1728     RxReorderTbl *ptr;
1729     /** Priv pointer */
1730     mlan_private *priv;
1731 } reorder_tmr_cnxt_t;
1732 
1733 /** RX reorder table */
1734 struct _RxReorderTbl
1735 {
1736     /** RxReorderTbl previous node */
1737     RxReorderTbl *pprev;
1738     /** RxReorderTbl next node */
1739     RxReorderTbl *pnext;
1740     /** TID */
1741     int tid;
1742     /** TA */
1743     t_u8 ta[MLAN_MAC_ADDR_LENGTH];
1744     /** Start window */
1745     t_u16 start_win;
1746     /** last_seq */
1747     t_u16 last_seq;
1748     /** Window size */
1749     t_u16 win_size;
1750     /** Pointer to pointer to RxReorderTbl */
1751     t_void **rx_reorder_ptr;
1752     /** Timer context */
1753     reorder_tmr_cnxt_t timer_context;
1754     /** BA stream status */
1755     baStatus_e ba_status;
1756     t_u8 amsdu;
1757     /** no packet drop flag for rx_reorder_tbl */
1758     bool force_no_drop;
1759     /** flag for check start win */
1760     bool check_start_win;
1761     /** pkt receive after BA setup */
1762     t_u8 pkt_count;
1763     /** BA window bitmap */
1764     t_u64 bitmap;
1765 #if CONFIG_RSN_REPLAY_DETECTION
1766     /** PN number high 32 bits*/
1767     t_u32 hi_curr_rx_count32;
1768     /** PN number low 16 bits*/
1769     t_u16 lo_curr_rx_count16;
1770     /** PN drop counter */
1771     t_u32 pn_drop_count;
1772 #endif
1773 };
1774 
1775 /** BSS priority node */
1776 typedef struct _mlan_bssprio_node mlan_bssprio_node;
1777 
1778 /** BSS priority node */
1779 struct _mlan_bssprio_node
1780 {
1781     /** Pointer to previous node */
1782     mlan_bssprio_node *pprev;
1783     /** Pointer to next node */
1784     mlan_bssprio_node *pnext;
1785     /** Pointer to priv */
1786     pmlan_private priv;
1787 };
1788 
1789 /** BSS priority table */
1790 typedef struct _mlan_bssprio_tbl mlan_bssprio_tbl;
1791 
1792 /** BSS priority table */
1793 struct _mlan_bssprio_tbl
1794 {
1795     /** BSS priority list head */
1796     mlan_list_head bssprio_head;
1797     /** Current priority node */
1798     mlan_bssprio_node *bssprio_cur;
1799 };
1800 
1801 /** cmd_ctrl_node */
1802 typedef struct _cmd_ctrl_node cmd_ctrl_node;
1803 
1804 /** _cmd_ctrl_node */
1805 struct _cmd_ctrl_node
1806 {
1807     /** Pointer to previous node */
1808     cmd_ctrl_node *pprev;
1809     /** Pointer to next node */
1810     cmd_ctrl_node *pnext;
1811     /** Pointer to priv */
1812     pmlan_private priv;
1813     /** Command OID for sub-command use */
1814     t_u32 cmd_oid;
1815     /** Command flag */
1816     t_u32 cmd_flag;
1817     /** Pointer to mlan_buffer */
1818     mlan_buffer *cmdbuf;
1819     /** Pointer to mlan_buffer */
1820     mlan_buffer *respbuf;
1821     /** Command parameter */
1822     t_void *pdata_buf;
1823     /** Pointer to mlan_ioctl_req if command is from IOCTL */
1824     t_void *pioctl_buf;
1825     /** pre_allocated mlan_buffer for cmd */
1826     mlan_buffer *pmbuf;
1827 };
1828 
1829 /** station node */
1830 typedef struct _sta_node sta_node;
1831 
1832 /** station node*/
1833 struct _sta_node
1834 {
1835     /** previous node */
1836     sta_node *pprev;
1837     /** next node */
1838     sta_node *pnext;
1839     /** station mac address */
1840     t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
1841     /** wmm flag */
1842     t_u8 is_wmm_enabled;
1843     /** 11n flag */
1844     bool is_11n_enabled;
1845 #if CONFIG_11AC
1846     /** 11ac flag */
1847     bool is_11ac_enabled;
1848 #endif
1849 #if CONFIG_11AX
1850     t_u8 is_11ax_enabled;
1851     IEEEtypes_HECap_t he_cap;
1852 #endif
1853     /** AMPDU STA */
1854     t_u8 ampdu_sta[MAX_NUM_TID];
1855     /** last rx_seq */
1856     t_u16 rx_seq[MAX_NUM_TID];
1857     /** max amsdu size */
1858     t_u16 max_amsdu;
1859     /** HT cap */
1860     IEEEtypes_HTCap_t HTcap;
1861 #if defined(UAP_HOST_MLME)
1862     /** peer capability */
1863     t_u16 capability;
1864 #endif
1865     /** station band mode */
1866     t_u16 bandmode;
1867     /** wapi key on off flag */
1868     t_u8 wapi_key_on;
1869     /** tx pause status */
1870     t_u8 tx_pause;
1871 };
1872 
1873 /** 802.11h State information kept in the 'mlan_adapter' driver structure */
1874 typedef struct
1875 {
1876     /** Min TX Power capability sent to FW for 11h use and fw power control */
1877     t_s8 min_tx_power_capability;
1878     /** Max TX Power capability sent to FW for 11h use and fw power control */
1879     t_s8 max_tx_power_capability;
1880     /** User provisioned local power constraint sent in association requests */
1881     t_s8 usr_def_power_constraint;
1882     /** Received CHANNEL_SWITCH_ANN event */
1883     t_bool recvd_chanswann_event;
1884     /** Indicates an interface wants to enable master radar detection */
1885     t_bool master_radar_det_enable_pending;
1886     /** Indicates an interface wants to enable slave radar detection */
1887     t_bool slave_radar_det_enable_pending;
1888     /** Indicates whether master radar detection active in the firmware */
1889     t_bool is_master_radar_det_active;
1890     /** Indicates whether slave radar detection active in the firmware */
1891     t_bool is_slave_radar_det_active;
1892     /** Quiet IE */
1893     IEEEtypes_Quiet_t quiet_ie;
1894 } wlan_11h_device_state_t;
1895 
1896 /** Enumeration for DFS Timestamp represents field */
1897 enum _dfs_timestamp_repr_e
1898 {
1899     /** Ignore entry */
1900     DFS_TS_REPR_NOT_IN_USE = 0,
1901     /** NOP (Non-Occupancy Period) start time */
1902     DFS_TS_REPR_NOP_START = 1,
1903     /** CAC (Channel Availability Check) completion time */
1904     DFS_TS_REPR_CAC_COMPLETION
1905 };
1906 
1907 /** DFS Timestamp type used for marking NOP/CAC events */
1908 typedef struct _wlan_dfs_timestamp_t wlan_dfs_timestamp_t;
1909 
1910 /** DFS Timestamp type used for marking NOP/CAC events */
1911 struct _wlan_dfs_timestamp_t
1912 {
1913     /** Pointer to previous node */
1914     wlan_dfs_timestamp_t *pprev;
1915     /** Pointer to next node */
1916     wlan_dfs_timestamp_t *pnext;
1917     /** WLAN Channel number */
1918     t_u8 channel;
1919     /** What this timestamp represents */
1920     t_u8 represents;
1921     /** reserved field */
1922     t_u16 reserved;
1923     /** timestamp - seconds */
1924     t_u32 ts_sec;
1925     /** timestamp - microseconds */
1926     t_u32 ts_usec;
1927 };
1928 
1929 /** DFS State information kept in the 'mlan_adapter' driver structure */
1930 typedef struct
1931 {
1932     /** Indicates whether DFS channel check is occurring in firmware */
1933     t_bool dfs_check_pending;
1934     /** Indicates whether DFS channel check found radar */
1935     t_bool dfs_radar_found;
1936     /** Channel radar is being checked on.  BAND_A is assumed. */
1937     t_u8 dfs_check_channel;
1938     /** Timestamp when we got last report, to determine if data is old or not. */
1939     t_u32 dfs_report_time_sec;
1940     /** List for holding dfs_timestamps for NOP/CAC events */
1941     mlan_list_head dfs_ts_head;
1942 } wlan_dfs_device_state_t;
1943 
1944 /** Enumeration for mlan_ds_11h_radar_det_hndlg stages */
1945 enum _mlan_ds_11h_rdh_stages
1946 {
1947     RDH_OFF       = 0,
1948     RDH_CHK_INTFS = 1,
1949     RDH_STOP_TRAFFIC,
1950     RDH_GET_INFO_CHANNEL,
1951     RDH_GET_INFO_BEACON_DTIM,
1952     RDH_SET_CUSTOM_IE,
1953     RDH_REM_CUSTOM_IE,
1954     RDH_STOP_INTFS,
1955     RDH_SET_NEW_CHANNEL,
1956     RDH_RESTART_INTFS,
1957     RDH_RESTART_TRAFFIC
1958 };
1959 
1960 /** State info for Radar Detected Handling kept in 'mlan_adapter' */
1961 typedef struct
1962 {
1963     /** Stage (of Operation) */
1964     t_u8 stage;
1965     /** Number of interfaces to handle */
1966     t_u8 priv_list_count;
1967     /** Index of interface in process (used by some stages) */
1968     t_u8 priv_curr_idx;
1969     /** Current Channel (to leave) */
1970     t_u8 curr_channel;
1971     /** New Channel (to switch to) */
1972     t_u8 new_channel;
1973     /** UAP band_config */
1974     t_u8 uap_band_cfg;
1975     /** BEACON*DTIM period (in msec; max of STA/UAP) */
1976     t_u16 max_bcn_dtim_ms;
1977     /** List of interfaces to handle */
1978     mlan_private *priv_list[MLAN_MAX_BSS_NUM];
1979 } wlan_radar_det_hndlg_state_t;
1980 
1981 #ifdef DFS_TESTING_SUPPORT
1982 /** DFS/RDH testing exception settings kept in 'mlan_adapter' */
1983 typedef struct
1984 {
1985     /** user-configured CAC period (in msec) */
1986     t_u16 user_cac_period_msec;
1987     /** user-configured NOP period (in sec) */
1988     t_u16 user_nop_period_sec;
1989     /** user-configured skip channel change on radar */
1990     t_bool no_channel_change_on_radar;
1991     /** user-configured new channel to change to on radar */
1992     t_u8 fixed_new_channel_on_radar;
1993 } wlan_dfs_testing_settings_t;
1994 #endif /* DFS_SUPPORT_TESTING */
1995 
1996 /**
1997  * @brief Driver measurement state held in 'mlan_adapter' structure
1998  *
1999  *  Used to record a measurement request that the driver is pending on
2000  *    the result (received measurement report).
2001  */
2002 typedef struct
2003 {
2004     /**
2005      * Dialog token of a pending measurement request/report.  Used to
2006      *   block execution while waiting for the specific dialog token
2007      */
2008     t_u8 meas_rpt_pend_on;
2009 
2010     /**
2011      * Measurement report received from the firmware that we were pending on
2012      */
2013     HostCmd_DS_MEASUREMENT_REPORT meas_rpt_returned;
2014 
2015 } wlan_meas_state_t;
2016 
2017 #if CONFIG_WIFI_TX_PER_TRACK
2018 /** Tx Per Tracking Structure
2019  * Driver sets tx per tracking statistic to fw.
2020  * Fw will check tx packet error rate periodically and
2021  * report PER to host if per is high.
2022  */
2023 typedef struct
2024 {
2025     /** Enable/Disable tx per tracking */
2026     t_u8 tx_pert_check;
2027     /** Check period(unit sec) */
2028     t_u8 tx_pert_check_peroid;
2029     /** (Fail TX packet)/(Total TX packet) ratio(unit 10%)
2030      * default: 5
2031      */
2032     t_u8 tx_pert_check_ratio;
2033     /** A watermark of check number(default 5) */
2034     t_u16 tx_pert_check_num;
2035 } tx_pert_info;
2036 #endif
2037 
2038 #if CONFIG_TX_RX_HISTOGRAM
2039 typedef struct
2040 {
2041     /**  Enable or disable  */
2042     t_u8 enable;
2043     /** Choose to get TX, RX or both */
2044     t_u16 action;
2045 } txrx_histogram_info;
2046 #endif
2047 
2048 #ifdef SDIO_MULTI_PORT_TX_AGGR
2049 /** data structure for SDIO MPA TX */
2050 typedef struct _sdio_mpa_tx
2051 {
2052     /** allocated buf for tx aggreation */
2053     t_u8 *head_ptr;
2054     /** multiport tx aggregation buffer pointer */
2055     t_u8 *buf;
2056     /** multiport tx aggregation buffer length */
2057     t_u32 buf_len;
2058     /** multiport tx aggregation packet count */
2059     t_u32 pkt_cnt;
2060     /** multiport tx aggregation ports */
2061     t_u32 ports;
2062     /** multiport tx aggregation starting port */
2063     t_u16 start_port;
2064     /** multiport tx aggregation enable/disable flag */
2065     t_u8 enabled;
2066     /** multiport tx aggregation buffer size */
2067     t_u32 buf_size;
2068     /** multiport tx aggregation pkt aggr limit */
2069     t_u32 pkt_aggr_limit;
2070 } sdio_mpa_tx;
2071 #endif
2072 
2073 #ifdef SDIO_MULTI_PORT_RX_AGGR
2074 /** data structure for SDIO MPA RX */
2075 typedef struct _sdio_mpa_rx
2076 {
2077     /** allocated buf for rx aggreation */
2078     t_u8 *head_ptr;
2079     /** multiport rx aggregation buffer pointer */
2080     t_u8 *buf;
2081     /** multiport rx aggregation buffer length */
2082     t_u32 buf_len;
2083     /** multiport rx aggregation packet count */
2084     t_u32 pkt_cnt;
2085     /** multiport rx aggregation ports */
2086     t_u32 ports;
2087     /** multiport rx aggregation starting port */
2088     t_u16 start_port;
2089 
2090     /** multiport rx aggregation mbuf array */
2091     pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
2092     /** multiport rx aggregation pkt len array */
2093     t_u32 len_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
2094 
2095     /** multiport rx aggregation enable/disable flag */
2096     t_u8 enabled;
2097     /** multiport rx aggregation buffer size */
2098     t_u32 buf_size;
2099     /** multiport rx aggregation pkt aggr limit */
2100     t_u32 pkt_aggr_limit;
2101 } sdio_mpa_rx;
2102 #endif /* SDIO_MULTI_PORT_RX_AGGR */
2103 
2104 /** mlan_init_para structure */
2105 typedef struct _mlan_init_para
2106 {
2107 #ifdef WIFI_CALIB_CMD_SUPPORT
2108     /** WiFi Calibration mode */
2109     t_u32 wifi_calib_mode;
2110 #endif
2111     /** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */
2112     t_u32 int_mode;
2113     /** GPIO interrupt pin number */
2114     t_u32 gpio_pin;
2115 #ifdef SDIO_MULTI_PORT_TX_AGGR
2116     /** SDIO MPA Tx */
2117     t_u32 mpa_tx_cfg;
2118 #endif
2119 #ifdef SDIO_MULTI_PORT_RX_AGGR
2120     /** SDIO MPA Rx */
2121     t_u32 mpa_rx_cfg;
2122 #endif
2123     /** Auto deep sleep */
2124     t_u32 auto_ds;
2125     /** IEEE PS mode */
2126     t_u32 ps_mode;
2127     /** Max Tx buffer size */
2128     t_u32 max_tx_buf;
2129     /** 802.11d configuration */
2130     t_u32 cfg_11d;
2131     /** 802.11H DFS Master Radar Detect */
2132     t_u32 dfs_master_radar_det_en;
2133     /** 802.11H DFS Slave Radar Detect */
2134     t_u32 dfs_slave_radar_det_en;
2135     /** FW download CRC check flag */
2136     t_u32 fw_crc_check;
2137 } mlan_init_para, *pmlan_init_para;
2138 
2139 #define MLAN_MAX_BLACKLIST_BSSID 16
2140 
2141 /* BSSID blacklist */
2142 typedef struct
2143 {
2144     /** Number of blacklisted BSSIDs */
2145     int num_bssid;
2146     /** Blacklisted BSSIDs */
2147     mlan_802_11_mac_addr bssids[MLAN_MAX_BLACKLIST_BSSID];
2148 } mlan_blacklisted_bssid_params;
2149 
2150 #if CONFIG_FW_VDLL
2151 /** vdll_dnld_ctrl structure */
2152 typedef struct _vdll_dnld_ctrl
2153 {
2154     /**  pending  VDLL block */
2155     t_u8 *pending_block;
2156     /* pending VDLL block len */
2157     t_u16 pending_block_len;
2158     /** memory for VDLL fw image */
2159     t_u8 *vdll_mem;
2160     /**  VDLL fw image len */
2161     t_u32 vdll_len;
2162     /** cmd buffer for VDLL download */
2163     t_u8 *cmd_buf;
2164 } vdll_dnld_ctrl, *pvdll_dnld_ctrl;
2165 #endif
2166 
2167 #if CONFIG_HOST_SLEEP
2168 /* WLAN wakeup reason in detail */
2169 typedef struct
2170 {
2171     /* Rx IMU msg type */
2172     uint8_t type;
2173     /* IMU msg subtype for ctrl msg */
2174     uint8_t subtype;
2175     /* cmdresp or event id */
2176     uint16_t id;
2177 } wlan_wakeup_reason;
2178 #endif
2179 
2180 /** Adapter data structure for MLAN */
2181 struct _mlan_adapter
2182 {
2183     /** MOAL handle structure */
2184     t_void *pmoal_handle;
2185     /** Private pointer */
2186     pmlan_private priv[MLAN_MAX_BSS_NUM];
2187     /** Total number of Priv number */
2188     t_u8 priv_num;
2189     /** Firmware start addr */
2190     const t_u8 *fw_start_addr;
2191     mlan_callbacks callbacks;
2192     /** Init parameters */
2193     mlan_init_para init_para;
2194 #ifdef RW610
2195     /** bus operations*/
2196     bus_operations bus_ops;
2197 #endif
2198     /** Country ie ignore */
2199     t_u8 country_ie_ignore;
2200     /** In reset status now */
2201     t_u8 in_reset;
2202     /** IO port */
2203     t_u32 ioport;
2204     /** STATUS variables */
2205     WLAN_HARDWARE_STATUS hw_status;
2206     /** Firmware release number */
2207     t_u32 fw_release_number;
2208 
2209     /** Number of antenna used */
2210     t_u16 number_of_antenna;
2211 
2212     /** Firmware capability information */
2213     t_u32 fw_cap_info;
2214     /** Extended firmware capability information */
2215     t_u32 fw_cap_ext;
2216 #if CONFIG_FW_VDLL
2217     /** vdll ctrl */
2218     vdll_dnld_ctrl vdll_ctrl;
2219     /** VDLL operation in progress */
2220     volatile t_bool vdll_in_progress;
2221     /** Timer for vdll */
2222     OSA_TIMER_HANDLE_DEFINE(vdll_timer);
2223 #endif
2224     /** pint_lock for interrupt handling */
2225     t_void *pint_lock;
2226     /** Interrupt status */
2227     t_u8 sdio_ireg;
2228     /** SDIO multiple port read bitmap */
2229     t_u32 mp_rd_bitmap;
2230     /** SDIO multiple port write bitmap */
2231     t_u32 mp_wr_bitmap;
2232     /** SDIO end port from txbufcfg */
2233     t_u16 mp_end_port;
2234     /** SDIO port mask calculated based on txbufcfg end port */
2235     t_u32 mp_data_port_mask;
2236     /** Current available port for read */
2237     t_u8 curr_rd_port;
2238     /** Current available port for write */
2239     t_u8 curr_wr_port;
2240     /** Array to store values of SDIO multiple port group registers */
2241     t_u8 *mp_regs;
2242     /** allocated buf to read SDIO multiple port group registers */
2243     t_u8 *mp_regs_buf;
2244 
2245     /** ECSA support */
2246     bool ecsa_enable;
2247     /* Firmware support cmd_tx_data */
2248     t_u8 cmd_tx_data;
2249 
2250     /** CMD sent:
2251      *       TRUE - CMD is sent to fw, no CMD Done received
2252      *       FALSE - CMD done received for previous CMD
2253      */
2254     t_u8 cmd_sent;
2255     /** Region code */
2256     t_u16 region_code;
2257     /** Region code from HW*/
2258     t_u16 hw_region_code;
2259     /** Region Channel data */
2260     region_chan_t region_channel[MAX_REGION_CHANNEL_NUM];
2261     /** CFP table code for 2.4GHz */
2262     t_u8 cfp_code_bg;
2263     /** CFP table code for 5GHz */
2264     t_u8 cfp_code_a;
2265     /** WMM AC params */
2266     wmm_ac_parameters_t ac_params[MAX_AC_QUEUES];
2267     /** Minimum BA Threshold */
2268     t_u8 min_ba_threshold;
2269 #ifdef STA_SUPPORT
2270     /** Universal Channel data */
2271     region_chan_t universal_channel[MAX_REGION_CHANNEL_NUM];
2272     /** Parsed region channel */
2273     parsed_region_chan_11d_t parsed_region_chan;
2274 #endif /* STA_SUPPORT */
2275     /** 11D and Domain Regulatory Data */
2276     wlan_802_11d_domain_reg_t domain_reg;
2277     /** Country Code */
2278     t_u8 country_code[COUNTRY_CODE_LEN];
2279     /** FSM variable for 11h support */
2280     wlan_11h_device_state_t state_11h;
2281     /** FSM variable for DFS support */
2282     wlan_dfs_device_state_t state_dfs;
2283     /** FSM variable for RDH support */
2284     wlan_radar_det_hndlg_state_t state_rdh;
2285 #ifdef DFS_TESTING_SUPPORT
2286     /** User configured settings for DFS testing */
2287     wlan_dfs_testing_settings_t dfs_test_params;
2288 #endif
2289     /** FSM variable for MEAS support */
2290     wlan_meas_state_t state_meas;
2291     /** Scan table */
2292     BSSDescriptor_t *pscan_table;
2293     /** BSS blacklist */
2294     mlan_blacklisted_bssid_params blacklist_bss;
2295     /** scan age in secs */
2296     t_u32 age_in_secs;
2297     /** Active scan for hidden ssid triggered */
2298     t_u8 active_scan_triggered;
2299 #if CONFIG_WPA_SUPP
2300     /** WPA supplicant scan triggered */
2301     t_u8 wpa_supp_scan_triggered;
2302 #endif
2303 #if CONFIG_SCAN_CHANNEL_GAP
2304     /** channel statstics */
2305     ChanStatistics_t *pchan_stats;
2306     /** Number of records in the chan_stats */
2307     t_u32 num_in_chan_stats;
2308     /** index of chan stats */
2309     t_u32 idx_chan_stats;
2310     /** scan channel gap time */
2311     t_u16 scan_chan_gap;
2312 #endif
2313     /** Number of records in the scan table */
2314     t_u32 num_in_scan_table;
2315     /** Scan probes */
2316     t_u16 scan_probes;
2317 #if CONFIG_SCAN_WITH_RSSIFILTER
2318     /** Rssi threshold */
2319     t_s16 rssi_threshold;
2320 #endif
2321 
2322     /** Scan type */
2323     mlan_scan_type scan_type;
2324     /** Scan mode */
2325     t_u32 scan_mode;
2326     /** Specific scan time */
2327     t_u16 specific_scan_time;
2328     /** Active scan time */
2329     t_u16 active_scan_time;
2330     /** Passive scan time */
2331     t_u16 passive_scan_time;
2332 #if CONFIG_EXT_SCAN_SUPPORT
2333     /** Extended scan or legacy scan */
2334     t_u8 ext_scan;
2335 #endif
2336     /** F/W supported bands */
2337     t_u16 fw_bands;
2338     /** User selected band to start adhoc network */
2339     t_u16 adhoc_start_band;
2340     /** User selected bands */
2341     t_u16 config_bands;
2342     /** Pointer to channel list last sent to the firmware for scanning */
2343     ChanScanParamSet_t *pscan_channels;
2344 #if CONFIG_WMM_UAPSD
2345     /** Tx lock flag */
2346     t_u8 tx_lock_flag;
2347 
2348     /** sleep_params_t */
2349     sleep_params_t sleep_params;
2350     /** sleep_period_t (Enhanced Power Save) */
2351     sleep_period_t sleep_period;
2352 #endif
2353     /** Power Save state */
2354     enum wlan_ps_state ps_state;
2355     /** keep_wakeup */
2356     t_u8 keep_wakeup;
2357     /** Multiple DTIM */
2358     t_u16 multiple_dtim;
2359     /** Local listen interval */
2360     t_u16 local_listen_interval;
2361     /** Null packet interval */
2362     t_u16 null_pkt_interval;
2363 
2364     /** Beacon miss timeout */
2365     t_u16 bcn_miss_time_out;
2366 
2367     /** AdHoc awake period */
2368     t_u16 adhoc_awake_period;
2369 
2370     /** Delay to PS in milliseconds */
2371     t_u16 delay_to_ps;
2372     /** Enhanced PS mode */
2373     t_u16 enhanced_ps_mode;
2374 #if CONFIG_WMM_UAPSD
2375     /** Gen NULL pkg */
2376     t_u16 gen_null_pkt;
2377 
2378     /** PPS/UAPSD mode flag */
2379     t_u16 pps_uapsd_mode;
2380 #endif
2381 #if CONFIG_HOST_SLEEP
2382     /** Host Sleep configured flag */
2383     t_u8 is_hs_configured;
2384     /** management frame wakeup filter config */
2385     mgmt_frame_filter mgmt_filter[MAX_MGMT_FRAME_FILTER];
2386 #endif
2387     /** 802.11n device capabilities */
2388     t_u32 hw_dot_11n_dev_cap;
2389     /** Device support for MIMO abstraction of MCSs */
2390     t_u8 hw_dev_mcs_support;
2391     /** mpdu density */
2392     t_u8 hw_mpdu_density;
2393     /** 802.11n Device Capabilities for 2.4GHz */
2394     t_u32 usr_dot_11n_dev_cap_bg;
2395     /** 802.11n Device Capabilities for 5GHz */
2396     t_u32 usr_dot_11n_dev_cap_a;
2397     /** MIMO abstraction of MCSs supported by device */
2398     t_u8 usr_dev_mcs_support;
2399 #if CONFIG_WIFI_CAPA
2400     /** user configured 11n enable/disable */
2401     t_u8 usr_dot_11n_enable;
2402 #endif
2403 #ifdef STA_SUPPORT
2404     /** Enable 11n support for adhoc start */
2405     bool adhoc_11n_enabled;
2406     /** Adhoc Secondary Channel Bandwidth */
2407     t_u8 chan_bandwidth;
2408 #endif /* STA_SUPPORT */
2409 
2410     /** 802.11ac device capabilities */
2411     t_u32 hw_dot_11ac_dev_cap;
2412     /** 802.11ac device support for MIMO abstraction of MCSs */
2413     t_u32 hw_dot_11ac_mcs_support;
2414     /** tx vht_info */
2415     t_u8 tx_vhtinfo;
2416     /** rxpd_vhtinfo */
2417     t_u8 rxpd_vhtinfo;
2418 #if CONFIG_WIFI_CAPA
2419     /** user configured 11ac enable/disable */
2420     t_u8 usr_dot_11ac_enable;
2421 #endif
2422     /** 802.11ac Device Capabilities for 2.4GHz */
2423     t_u32 usr_dot_11ac_dev_cap_bg;
2424     /** 802.11ac Device Capabilities for 5GHz */
2425     t_u32 usr_dot_11ac_dev_cap_a;
2426     /** MIMO abstraction of MCSs supported by device */
2427     t_u32 usr_dot_11ac_mcs_support;
2428     /** user dot 11ac_BW */
2429     t_u8 usr_dot_11ac_bw;
2430     /** user dot 11ac_opermode_BW */
2431     t_u8 usr_dot_11ac_opermode_bw;
2432     /** user dot 11ac_opermode_nss */
2433     t_u8 usr_dot_11ac_opermode_nss;
2434 
2435 #if CONFIG_11AX
2436     /** length of hw he capability */
2437     t_u8 hw_hecap_len;
2438     /** 802.11ax HE capability */
2439     t_u8 hw_he_cap[54];
2440     /** length of hw 2.4G he capability */
2441     t_u8 hw_2g_hecap_len;
2442     /** 802.11ax 2.4G HE capability */
2443     t_u8 hw_2g_he_cap[54];
2444 #if CONFIG_WIFI_CAPA
2445     /** user configured 11ax enable/disable */
2446     t_u8 usr_dot_11ax_enable;
2447 #endif
2448 #endif
2449     /** max mgmt IE index in device */
2450     t_u16 max_mgmt_ie_index;
2451 #ifdef OTP_CHANINFO
2452     otp_region_info_t *otp_region;
2453     chan_freq_power_t *cfp_otp_bg;
2454     t_u8 *tx_power_table_bg;
2455     t_u32 tx_power_table_bg_size;
2456     t_u8 tx_power_table_bg_rows;
2457     t_u8 tx_power_table_bg_cols;
2458 #if CONFIG_5GHz_SUPPORT
2459     chan_freq_power_t *cfp_otp_a;
2460     t_u8 *tx_power_table_a;
2461     t_u32 tx_power_table_a_size;
2462     t_u8 tx_power_table_a_rows;
2463     t_u8 tx_power_table_a_cols;
2464 #endif
2465 #endif
2466 #if CONFIG_WIFI_TX_BUFF
2467     /** Tx buffer size */
2468     t_u16 tx_buffer_size;
2469 #endif
2470 #if CONFIG_WIFI_TX_PER_TRACK
2471     tx_pert_info tx_pert;
2472 #endif
2473 #if CONFIG_BG_SCAN
2474     t_u8 bgscan_reported;
2475 #endif
2476 #if CONFIG_MULTI_CHAN
2477     t_bool mc_policy;
2478 #endif
2479 #if CONFIG_WMM
2480     /* wmm buffer pool */
2481     outbuf_pool_t outbuf_pool;
2482     bool wait_txbuf;
2483 #endif
2484 #if CONFIG_HOST_SLEEP
2485     wlan_wakeup_reason wlan_wakeup;
2486 #endif
2487     bool skip_dfs;
2488     /* remain on channel flag */
2489     t_u8 remain_on_channel;
2490     t_u8 remain_bss_index;
2491 };
2492 
2493 /** Ethernet packet type for EAPOL */
2494 #define MLAN_ETHER_PKT_TYPE_EAPOL (0x888E)
2495 /** Ethernet packet type for WAPI */
2496 #define MLAN_ETHER_PKT_TYPE_WAPI (0x88B4)
2497 /** Ethernet packet type for ARP */
2498 #define MLAN_ETHER_PKT_TYPE_ARP (0x0806)
2499 /** Ethernet packet type for ARP */
2500 #define MLAN_ETHER_PKT_TYPE_IPV6 (0x86dd)
2501 /** Ethernet packet type offset */
2502 #define MLAN_ETHER_PKT_TYPE_OFFSET (12)
2503 
2504 #define MLAN_ETHER_PKT_DHCP_MAGIC_COOKIE        0x63825363UL
2505 #define MLAN_ETHER_PKT_DHCP_MAGIC_COOKIE_OFFSET 278
2506 
2507 mlan_status wlan_cmd_get_tsf(pmlan_private pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_u16 cmd_action);
2508 
2509 #if (CONFIG_WIFI_TX_PER_TRACK) || (CONFIG_TX_RX_HISTOGRAM)
2510 mlan_status wlan_cmd_txrx_pkt_stats(pmlan_private pmpriv,
2511                                     IN HostCmd_DS_COMMAND *cmd,
2512                                     IN t_u16 cmd_action,
2513                                     IN t_void *pdata_buf);
2514 #endif
2515 
2516 #if CONFIG_WIFI_TX_PER_TRACK
2517 mlan_status wlan_cmd_tx_pert(pmlan_private pmpriv,
2518                              IN HostCmd_DS_COMMAND *cmd,
2519                              IN t_u16 cmd_action,
2520                              IN t_void *pdata_buf);
2521 #endif
2522 
2523 #if CONFIG_TX_RX_HISTOGRAM
2524 mlan_status wlan_cmd_txrx_histogram(pmlan_private pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_void *pdata_buf);
2525 #endif
2526 
2527 mlan_status wlan_init_lock_list(IN pmlan_adapter pmadapter);
2528 
2529 /** Initialize firmware */
2530 mlan_status wlan_init_fw(IN pmlan_adapter pmadapter);
2531 
2532 /** Initialize mlan_adapter structure */
2533 t_void wlan_init_adapter(IN pmlan_adapter pmadapter);
2534 
2535 /** Initialize mlan_private structure */
2536 mlan_status wlan_init_priv(IN pmlan_private priv);
2537 
2538 /** Prepare command */
2539 mlan_status wlan_prepare_cmd(IN mlan_private *pmpriv,
2540                              IN t_u16 cmd_no,
2541                              IN t_u16 cmd_action,
2542                              IN t_u32 cmd_oid,
2543                              IN t_void *pioctl_buf,
2544                              IN t_void *pdata_buf);
2545 
2546 void wlan_clear_scan_bss(void);
2547 /** Allocate memory for adapter structure members */
2548 mlan_status wlan_allocate_adapter(pmlan_adapter pmadapter);
2549 /** Free adapter */
2550 t_void wlan_free_adapter(pmlan_adapter pmadapter);
2551 /** Handle received packet, has extra handling for aggregate packets */
2552 mlan_status wlan_handle_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
2553 #if CONFIG_WIFI_PKT_FWD
2554 /* Process received packet and forwards it to kernel/upper layer or send back to firmware */
2555 mlan_status wlan_process_uap_rx_packet(mlan_private *priv, pmlan_buffer pmbuf);
2556 #endif
2557 /** Transmit a null data packet */
2558 mlan_status wlan_send_null_packet(pmlan_private priv, t_u8 flags);
2559 
2560 #if defined(SDIO_MULTI_PORT_TX_AGGR) || defined(SDIO_MULTI_PORT_RX_AGGR)
2561 mlan_status wlan_alloc_sdio_mpa_buffers(IN mlan_adapter *pmadapter, t_u32 mpa_tx_buf_size, t_u32 mpa_rx_buf_size);
2562 
2563 mlan_status wlan_free_sdio_mpa_buffers(IN mlan_adapter *pmadapter);
2564 #endif
2565 
2566 /** Clean Tx Rx queues */
2567 t_void wlan_clean_txrx(pmlan_private priv);
2568 
2569 /** function to allocate a mlan_buffer */
2570 pmlan_buffer wlan_alloc_mlan_buffer(mlan_adapter *pmadapter, t_u32 data_len, t_u32 head_room, t_u32 malloc_flag);
2571 /** function to free a mlan_buffer */
2572 t_void wlan_free_mlan_buffer(mlan_adapter *pmadapter, pmlan_buffer pmbuf);
2573 
2574 /** handle command for enhanced power save mode */
2575 mlan_status wlan_cmd_enh_power_mode(pmlan_private pmpriv,
2576                                     IN HostCmd_DS_COMMAND *cmd,
2577                                     IN ENH_PS_MODES cmd_action,
2578                                     IN t_u16 ps_bitmap,
2579                                     IN t_void *pdata_buf);
2580 
2581 mlan_status wlan_process_802dot11_mgmt_pkt(mlan_private *priv, t_u8 *payload, t_u32 payload_len, RxPD *rxpd);
2582 
2583 mlan_status wlan_bypass_802dot11_mgmt_pkt(void *data);
2584 
2585 mlan_status wlan_cmd_remain_on_channel(IN pmlan_private pmpriv,
2586                                        IN HostCmd_DS_COMMAND *cmd,
2587                                        IN t_u16 cmd_action,
2588                                        IN t_void *pdata_buf);
2589 
2590 #ifdef WIFI_DIRECT_SUPPORT
2591 mlan_status wlan_bss_ioctl_wifi_direct_mode(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2592 
2593 mlan_status wlan_cmd_wifi_direct_mode(IN pmlan_private pmpriv,
2594                                       IN HostCmd_DS_COMMAND *cmd,
2595                                       IN t_u16 cmd_action,
2596                                       IN t_void *pdata_buf);
2597 mlan_status wlan_ret_wifi_direct_mode(IN pmlan_private pmpriv,
2598                                       IN HostCmd_DS_COMMAND *resp,
2599                                       IN mlan_ioctl_req *pioctl_buf);
2600 
2601 mlan_status wlan_radio_ioctl_remain_chan_cfg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2602 mlan_status wlan_ret_remain_on_channel(IN pmlan_private pmpriv,
2603                                        IN HostCmd_DS_COMMAND *resp,
2604                                        IN mlan_ioctl_req *pioctl_buf);
2605 #endif
2606 
2607 mlan_status wlan_cmd_tx_rate_cfg(IN pmlan_private pmpriv,
2608                                  IN HostCmd_DS_COMMAND *cmd,
2609                                  IN t_u16 cmd_action,
2610                                  IN t_void *pdata_buf,
2611                                  IN mlan_ioctl_req *pioctl_buf);
2612 mlan_status wlan_ret_tx_rate_cfg(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN void *pioctl);
2613 
2614 mlan_status wlan_rate_ioctl_cfg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2615 mlan_status wlan_ret_802_11_tx_rate_query(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN void *pioctl);
2616 #if (CONFIG_BG_SCAN)
2617 /** Handler for bgscan query commands */
2618 mlan_status wlan_cmd_802_11_bg_scan_query(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_u16 cmd_action);
2619 /** Handler for bgscan config command */
2620 mlan_status wlan_cmd_bgscan_config(IN mlan_private *pmpriv,
2621                                    IN HostCmd_DS_COMMAND *cmd,
2622                                    IN t_u16 cmd_action,
2623                                    IN t_void *pdata_buf);
2624 /** Hander for bgscan config command response */
2625 mlan_status wlan_ret_bgscan_config(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *resp, IN mlan_ioctl_req *pioctl_buf);
2626 #endif
2627 
2628 #if (CONFIG_ROAMING) || (CONFIG_SUBSCRIBE_EVENT_SUPPORT)
2629 /** Handler for subscribe event command */
2630 mlan_status wlan_cmd_subscribe_event(IN mlan_private *pmpriv,
2631                                      IN HostCmd_DS_COMMAND *cmd,
2632                                      IN t_u16 cmd_action,
2633                                      IN t_void *pioctl_buf);
2634 int wlan_parse_getdata(HostCmd_DS_COMMAND *resp, mlan_ds_subscribe_evt *sub_evt);
2635 #endif
2636 
2637 /** Handler to get current operating class */
2638 /* For several features, such as DPP and MBO, we need the global operating class. */
2639 mlan_status wlan_get_global_nonglobal_oper_class(
2640     mlan_private *pmpriv, t_u8 channel, t_u8 bw, t_u8 *oper_class, t_u8 *global_op_class);
2641 
2642 #define wlan_get_curr_oper_class(pmpriv, channel, bw, oper_class) \
2643     wlan_get_global_nonglobal_oper_class(pmpriv, channel, bw, oper_class, MNULL)
2644 #define wlan_get_curr_global_oper_class(pmpriv, channel, bw, oper_class) \
2645     wlan_get_global_nonglobal_oper_class(pmpriv, channel, bw, MNULL, oper_class)
2646 
2647 /** Handler to add supported operating class IE */
2648 int wlan_add_supported_oper_class_ie(mlan_private *pmpriv, t_u8 **pptlv_out, t_u8 curr_oper_class);
2649 
2650 #if defined(STA_SUPPORT) || UAP_SUPPORT
2651 /** rx handler for station/uap mode */
2652 mlan_status wlan_ops_process_rx_packet(IN t_void *adapter, IN pmlan_buffer pmbuf);
2653 /** Process received packet */
2654 mlan_status wlan_process_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
2655 #endif
2656 #ifdef STA_SUPPORT
2657 /** ioctl handler for station mode */
2658 mlan_status wlan_ops_sta_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req);
2659 
2660 /** cmd handler for station mode */
2661 mlan_status wlan_ops_sta_prepare_cmd(IN t_void *priv,
2662                                      IN t_u16 cmd_no,
2663                                      IN t_u16 cmd_action,
2664                                      IN t_u32 cmd_oid,
2665                                      IN t_void *pioctl_buf,
2666                                      IN t_void *pdata_buf,
2667                                      IN t_void *pcmd_buf);
2668 
2669 /** cmdresp handler for station mode */
2670 mlan_status wlan_ops_sta_process_cmdresp(IN t_void *priv, IN t_u16 cmdresp_no, IN t_void *pcmd_buf, IN t_void *pioctl);
2671 
2672 /** Scan for networks */
2673 mlan_status wlan_scan_networks(IN mlan_private *pmpriv,
2674                                IN t_void *pioctl_buf,
2675                                IN const wlan_user_scan_cfg *puser_scan_in);
2676 
2677 /** Scan command handler */
2678 mlan_status wlan_cmd_802_11_scan(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *pcmd, IN t_void *pdata_buf);
2679 
2680 /** Handler for scan command response */
2681 mlan_status wlan_ret_802_11_scan(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2682 
2683 #if CONFIG_EXT_SCAN_SUPPORT
2684 /** Extended scan command handler */
2685 mlan_status wlan_cmd_802_11_scan_ext(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *pcmd, IN t_void *pdata_buf);
2686 /** Handler for extended scan command response */
2687 mlan_status wlan_ret_802_11_scan_ext(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2688 /** Handler event for extended scan report */
2689 mlan_status wlan_handle_event_ext_scan_report(IN mlan_private *pmpriv, IN t_u8 *pmbuf);
2690 #endif
2691 
2692 /** check network compatibility */
2693 t_s32 wlan_is_network_compatible(IN mlan_private *pmpriv, IN t_u32 index, IN mlan_bss_mode mode);
2694 
2695 /** Find an SSID in a list */
2696 t_s32 wlan_find_ssid_in_list(IN pmlan_private pmpriv, IN mlan_802_11_ssid *ssid, IN t_u8 *bssid, IN mlan_bss_mode mode);
2697 
2698 /** Find a BSSID in a list */
2699 t_s32 wlan_find_bssid_in_list(IN mlan_private *pmpriv, IN const t_u8 *bssid, IN mlan_bss_mode mode);
2700 
2701 /** Compare two SSIDs */
2702 t_s32 wlan_ssid_cmp(IN pmlan_adapter pmadapter, IN mlan_802_11_ssid *ssid1, IN mlan_802_11_ssid *ssid2);
2703 
2704 /** Associate */
2705 mlan_status wlan_associate(IN mlan_private *pmpriv, IN t_void *pioctl_buf, IN BSSDescriptor_t *pbss_desc);
2706 
2707 /** Associate command handler */
2708 mlan_status wlan_cmd_802_11_associate(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_void *pdata_buf);
2709 
2710 /** Handler for association command response */
2711 mlan_status wlan_ret_802_11_associate(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2712 
2713 /** Reset connected state */
2714 t_void wlan_reset_connect_state(IN pmlan_private priv, IN t_u8 drv_disconnect);
2715 
2716 t_void wlan_handle_disconnect_event(pmlan_private pmpriv);
2717 
2718 mlan_status wlan_ret_802_11_deauthenticate(IN pmlan_private pmpriv,
2719                                            IN HostCmd_DS_COMMAND *resp,
2720                                            IN mlan_ioctl_req *pioctl_buf);
2721 
2722 /** convert band to radio type */
2723 t_u8 wlan_band_to_radio_type(IN t_u8 band);
2724 
2725 /** Disconnect */
2726 /* Temporary disable prototype. Same name function present in wmsdk */
2727 /* mlan_status wlan_disconnect(IN mlan_private * pmpriv, */
2728 /*                             IN mlan_ioctl_req * pioctl_req, */
2729 /*                             IN mlan_802_11_mac_addr * mac); */
2730 
2731 /** Get Channel-Frequency-Power by band and channel */
2732 const chan_freq_power_t *wlan_get_cfp_by_band_and_channel(pmlan_adapter pmadapter,
2733                                                           t_u16 band,
2734                                                           t_u16 channel,
2735                                                           region_chan_t *region_channel);
2736 /** Find Channel-Frequency-Power by band and channel */
2737 const chan_freq_power_t *wlan_find_cfp_by_band_and_channel(mlan_adapter *pmadapter, t_u16 band, t_u16 channel);
2738 /** Find Channel-Frequency-Power by band and frequency */
2739 const chan_freq_power_t *wlan_find_cfp_by_band_and_freq(mlan_adapter *pmadapter, t_u16 band, t_u32 freq);
2740 /** Get Tx power of channel from Channel-Frequency-Power */
2741 t_u8 wlan_get_txpwr_of_chan_from_cfp(mlan_private *pmpriv, t_u8 channel);
2742 
2743 #endif /* STA_SUPPORT */
2744 
2745 /* Rate related functions */
2746 /** Convert index into data rate */
2747 #ifdef SD8801
2748 t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter, t_u8 index, t_u8 ht_info);
2749 #else
2750 t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter,
2751                               t_u8 index,
2752                               t_u8 tx_rate_info
2753 #if CONFIG_11AX
2754                               ,
2755                               t_u8 ext_rate_info
2756 #endif
2757 );
2758 #endif
2759 /** Get active data rates */
2760 t_u32 wlan_get_active_data_rates(mlan_private *pmpriv,
2761                                  mlan_bss_mode bss_mode,
2762                                  t_u16 config_bands,
2763                                  WLAN_802_11_RATES rates);
2764 /** Get supported data rates */
2765 t_u32 wlan_get_supported_rates(mlan_private *pmpriv,
2766                                mlan_bss_mode bss_mode,
2767                                t_u16 config_bands,
2768                                WLAN_802_11_RATES rates);
2769 /** Check if rate is auto */
2770 bool wlan_is_rate_auto(mlan_private *pmpriv);
2771 /** Get rate index */
2772 int wlan_get_rate_index(pmlan_adapter pmadapter, t_u16 *rate_bitmap, int size);
2773 
2774 /* CFP related functions */
2775 /** Region code index table */
2776 extern t_u16 region_code_index[MRVDRV_MAX_REGION_CODE];
2777 
2778 /** The table to keep CFP code for A */
2779 extern t_u16 cfp_code_index_a[MRVDRV_MAX_CFP_CODE_A];
2780 /** Get region cfp table*/
2781 const chan_freq_power_t *wlan_get_region_cfp_table(pmlan_adapter pmadapter, t_u8 region, t_u16 band, int *cfp_no);
2782 /** Set region table */
2783 mlan_status wlan_set_regiontable(mlan_private *pmpriv, t_u8 region, t_u16 band);
2784 /** Get radar detection requirements*/
2785 t_bool wlan_get_cfp_radar_detect(mlan_private *priv, t_u8 chnl);
2786 /** check if scan type is passive for b/g band*/
2787 t_bool wlan_bg_scan_type_is_passive(mlan_private *priv, t_u8 chnl);
2788 t_u8 wlan_convert_v14_rate_ht_info(t_u8 ht_info);
2789 /** Check if channel number is valid */
2790 t_bool wlan_is_channel_valid(t_u8 chan_num);
2791 /** Check if radio mode number is valid */
2792 t_bool wlan_is_radio_mode_valid(t_u8 mode);
2793 /** Check if channel number and its frequency is valid */
2794 t_bool wlan_is_channel_and_freq_valid(mlan_adapter *pmadapter, t_u8 chan_num, t_u16 chan_freq);
2795 /** Set Custom CFP Table */
2796 #if CONFIG_5GHz_SUPPORT
2797 mlan_status wlan_set_custom_cfp_table(wifi_chanlist_t *chanlist, t_u8 *cfp_no_bg, t_u8 *cfp_no_a);
2798 void wlan_set_custom_regiontable(mlan_private *pmpriv, t_u8 cfp_no_bg, t_u8 cfp_no_a);
2799 #else
2800 mlan_status wlan_set_custom_cfp_table(wifi_chanlist_t *chanlist, t_u8 *cfp_no_bg);
2801 void wlan_set_custom_regiontable(mlan_private *pmpriv, t_u8 cfp_no_bg);
2802 #endif
2803 /** Get the list of active channels */
2804 void wlan_get_active_channel_list(mlan_private *pmpriv, t_u8 *chan_list, t_u8 *num_chans, t_u16 acs_band);
2805 
2806 /* 802.11D related functions */
2807 /** Initialize 11D */
2808 t_void wlan_11d_priv_init(mlan_private *pmpriv);
2809 /** Initialize 11D */
2810 t_void wlan_11d_init(mlan_adapter *pmadapter);
2811 /** Enable 11D support */
2812 t_u16 wlan_enable_11d_support(mlan_private *pmpriv);
2813 t_u16 wlan_11d_support_APIs(mlan_private *pmpriv);
2814 /** Get if 11D support is enabled */
2815 t_bool wlan_11d_support_is_enabled(mlan_private *pmpriv);
2816 /** Get if 11D is enabled */
2817 t_bool wlan_11d_is_enabled(mlan_private *pmpriv);
2818 /** 11D Region code to country code string */
2819 const t_u8 *wlan_11d_code_2_region(pmlan_adapter pmadapter, t_u8 code);
2820 /**converts region string to integer code*/
2821 mlan_status wlan_11d_region_2_code(pmlan_adapter pmadapter, t_u8 *region, OUT t_u8 *code);
2822 /** Store 11D domain info */
2823 mlan_status wlan_11d_set_domain_info(mlan_private *pmpriv,
2824                                      t_u16 band,
2825                                      const t_u8 country_code[COUNTRY_CODE_LEN],
2826                                      t_u8 num_sub_band,
2827                                      IEEEtypes_SubbandSet_t *sub_band_list);
2828 
2829 /** Get if priv is station */
2830 t_bool wlan_is_station(mlan_private *pmpriv);
2831 /** Command handler for 11D country info */
2832 mlan_status wlan_cmd_802_11d_domain_info(mlan_private *pmpriv, HostCmd_DS_COMMAND *pcmd, t_u16 cmd_action);
2833 #ifdef STA_SUPPORT
2834 /** Convert channel to frequency */
2835 t_u32 wlan_11d_chan_2_freq(pmlan_adapter pmadapter, t_u8 chan, t_u16 band);
2836 /** Set 11D universal table */
2837 mlan_status wlan_11d_set_universaltable(mlan_private *pmpriv, t_u16 band);
2838 /** Clear 11D region table */
2839 mlan_status wlan_11d_clear_parsedtable(mlan_private *pmpriv);
2840 /** Create 11D country information for downloading */
2841 mlan_status wlan_11d_create_dnld_countryinfo(mlan_private *pmpriv, t_u16 band);
2842 /** Get scan type from 11D info */
2843 mlan_scan_type wlan_11d_get_scan_type(mlan_private *pmpriv,
2844                                       t_u16 band,
2845                                       t_u8 chan,
2846                                       parsed_region_chan_11d_t *parsed_region_chan);
2847 /** Parse 11D country info */
2848 mlan_status wlan_11d_parse_dnld_countryinfo(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc);
2849 /** Prepare 11D domain information for download */
2850 mlan_status wlan_11d_prepare_dnld_domain_info_cmd(mlan_private *pmpriv);
2851 /** Parse 11D country information into domain info */
2852 mlan_status wlan_11d_parse_domain_info(pmlan_adapter pmadapter,
2853                                        IEEEtypes_CountryInfoFullSet_t *country_info,
2854                                        t_u16 band,
2855                                        parsed_region_chan_11d_t *parsed_region_chan);
2856 /** Configure 11D domain info command */
2857 mlan_status wlan_11d_cfg_domain_info(IN pmlan_adapter pmadapter, IN mlan_ioctl_req *pioctl_req);
2858 
2859 mlan_status wlan_11d_cfg_ioctl(IN mlan_private *pmpriv, IN pmlan_ioctl_req pioctl_req);
2860 #endif /* STA_SUPPORT */
2861 #if UAP_SUPPORT
2862 /** Handle 11D domain information from UAP */
2863 mlan_status wlan_11d_handle_uap_domain_info(mlan_private *pmpriv, t_u16 band, t_u8 *domain_tlv, t_void *pioctl_buf);
2864 #endif
2865 
2866 /** This function converts region string to CFP table code */
2867 mlan_status wlan_misc_country_2_cfp_table_code(IN pmlan_adapter pmadapter,
2868                                                IN t_u8 *country_code,
2869                                                OUT t_u8 *cfp_bg,
2870                                                OUT t_u8 *cfp_a);
2871 /** check if station list is empty */
2872 t_u8 wlan_is_station_list_empty(mlan_private *priv);
2873 /** get station node */
2874 sta_node *wlan_get_station_entry(mlan_private *priv, t_u8 *mac);
2875 /** delete station list */
2876 t_void wlan_delete_station_list(pmlan_private priv);
2877 /** delete station entry */
2878 t_void wlan_delete_station_entry(mlan_private *priv, t_u8 *mac);
2879 /** add station entry */
2880 sta_node *wlan_add_station_entry(mlan_private *priv, t_u8 *mac);
2881 /** process uap rx packet */
2882 
2883 void wlan_check_sta_capability(pmlan_private priv, pmlan_buffer pevent, sta_node *sta_ptr);
2884 
2885 #if CONFIG_RF_TEST_MODE
2886 mlan_status wlan_ret_mfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, void *pioctl_buf);
2887 mlan_status wlan_misc_ioctl_rf_test_cfg(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
2888 #endif
2889 
2890 #if CONFIG_11R
2891 t_u8 wlan_ft_akm_is_used(mlan_private *pmpriv, t_u8 *rsn_ie);
2892 #endif
2893 
2894 /** find specific ie */
2895 t_u8 *wlan_get_specific_ie(pmlan_private priv, t_u8 *ie_buf, t_u8 ie_len, IEEEtypes_ElementId_e id, t_u8 ext_id);
2896 
2897 /**
2898  *  @brief This function checks tx_pause flag for peer
2899  *
2900  *  @param priv     A pointer to mlan_private
2901  *  @param ra       Address of the receiver STA
2902  *
2903  *  @return 	    MTRUE or MFALSE
2904  */
2905 INLINE
2906 static int wlan_is_tx_pause(mlan_private *priv, t_u8 *ra)
2907 {
2908     sta_node *sta_ptr = MNULL;
2909     sta_ptr           = wlan_get_station_entry(priv, ra);
2910     if (sta_ptr != MNULL)
2911     {
2912         return sta_ptr->tx_pause;
2913     }
2914     return MFALSE;
2915 }
2916 
2917 t_bool wlan_check_channel_by_region_table(mlan_private *pmpriv, t_u8 chan_num);
2918 
2919 mlan_status wlan_cmd_get_hw_spec(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *pcmd);
2920 mlan_status wlan_ret_get_hw_spec(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2921 
2922 mlan_status wlan_cmd_802_11_rf_antenna(IN pmlan_private pmpriv,
2923                                        IN HostCmd_DS_COMMAND *cmd,
2924                                        IN t_u16 cmd_action,
2925                                        IN t_void *pdata_buf);
2926 #if CONFIG_NET_MONITOR
2927 mlan_status wlan_cmd_802_11_net_monitor(IN pmlan_private pmpriv,
2928                                         IN HostCmd_DS_COMMAND *cmd,
2929                                         IN t_u16 cmd_action,
2930                                         IN t_void *pdata_buf);
2931 #endif
2932 
2933 #ifdef DEBUG_LEVEL1
2934 mlan_status wlan_set_drvdbg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2935 #endif
2936 
2937 void wlan_add_ext_capa_info_ie(IN mlan_private *pmpriv, IN BSSDescriptor_t *pbss_desc, OUT t_u8 **pptlv_out);
2938 
2939 #ifdef WLAN_LOW_POWER_ENABLE
2940 mlan_status wlan_misc_ioctl_low_pwr_mode(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2941 #endif // WLAN_LOW_POWER_ENABLE
2942 
2943 #ifdef OTP_CHANINFO
2944 mlan_status wlan_ret_chan_region_cfg(IN pmlan_private pmpriv,
2945                                      IN HostCmd_DS_COMMAND *resp,
2946                                      IN mlan_ioctl_req *pioctl_buf);
2947 
2948 void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left);
2949 
2950 void wlan_free_fw_cfp_tables(mlan_adapter *pmadapter);
2951 
2952 // mlan_status wlan_misc_chan_reg_cfg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2953 #endif
2954 
2955 #if CONFIG_COMPRESS_TX_PWTBL
2956 mlan_status wlan_cmd_region_power_cfg(pmlan_private pmpriv,
2957                                       HostCmd_DS_COMMAND *cmd,
2958                                       t_u16 cmd_action,
2959                                       t_void *pdata_buf);
2960 #endif
2961 
2962 #if CONFIG_WIFI_CLOCKSYNC
2963 mlan_status wlan_cmd_gpio_tsf_latch(
2964     pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, mlan_ioctl_req *pioctl_buf, t_void *pdata_buf);
2965 mlan_status wlan_ret_gpio_tsf_latch(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
2966 mlan_status wlan_misc_gpio_tsf_latch_config(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
2967 mlan_status wlan_misc_get_tsf_info(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
2968 #endif /* CONFIG_WIFI_CLOCKSYNC */
2969 #if CONFIG_MULTI_CHAN
2970 mlan_status wlan_cmd_multi_chan_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2971 
2972 mlan_status wlan_ret_multi_chan_cfg(pmlan_private pmpriv, const HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
2973 
2974 mlan_status wlan_cmd_multi_chan_policy(pmlan_private pmpriv,
2975                                        HostCmd_DS_COMMAND *cmd,
2976                                        t_u16 cmd_action,
2977                                        t_void *pdata_buf);
2978 
2979 mlan_status wlan_ret_multi_chan_policy(pmlan_private pmpriv,
2980                                        const HostCmd_DS_COMMAND *resp,
2981                                        mlan_ioctl_req *pioctl_buf);
2982 
2983 mlan_status wlan_cmd_drcs_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2984 
2985 mlan_status wlan_ret_drcs_cfg(pmlan_private pmpriv, const HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
2986 
2987 #endif
2988 
2989 mlan_status wlan_cmd_tx_frame(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2990 
2991 #if CONFIG_ECSA
2992 mlan_status wlan_misc_ioctl_operclass_validation(pmlan_adapter pmadapter, mlan_ioctl_req *pioctl_req);
2993 mlan_status wlan_misc_ioctl_oper_class(pmlan_adapter pmadapter, mlan_ioctl_req *pioctl_req);
2994 mlan_status wlan_check_operclass_validation(mlan_private *pmpriv, t_u8 channel, t_u8 oper_class);
2995 #endif
2996 
2997 #if CONFIG_RX_ABORT_CFG
2998 mlan_status wlan_cmd_rx_abort_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2999 #endif
3000 
3001 #if CONFIG_RX_ABORT_CFG_EXT
3002 mlan_status wlan_cmd_rx_abort_cfg_ext(pmlan_private pmpriv,
3003                                       HostCmd_DS_COMMAND *cmd,
3004                                       t_u16 cmd_action,
3005                                       t_void *pdata_buf);
3006 #endif
3007 
3008 #if CONFIG_CCK_DESENSE_CFG
3009 mlan_status wlan_cmd_cck_desense_cfg(pmlan_private pmpriv,
3010                                      HostCmd_DS_COMMAND *cmd,
3011                                      t_u16 cmd_action,
3012                                      t_void *pdata_buf);
3013 #endif
3014 
3015 #define BW_20MHZ 0
3016 #define BW_40MHZ 1
3017 #define BW_80MHZ 2
3018 
3019 #if CONFIG_TURBO_MODE
3020 int wlan_get_set_turbo_mode(t_u16 action, t_u8 *mode, mlan_bss_type bss_type);
3021 #endif
3022 
3023 #if CONFIG_1AS
3024 mlan_status wlan_cmd_host_clock_cfg(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
3025 mlan_status wlan_ret_host_clock_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3026 #endif
3027 
3028 /**
3029  *  @brief RA based queueing
3030  *
3031  *  @param priv                 A pointer to mlan_private structure
3032  *
3033  *  @return 	   	        MTRUE or MFALSE
3034  */
3035 INLINE
3036 static t_u8 queuing_ra_based(pmlan_private priv)
3037 {
3038     /*
3039      * Currently we assume if we are in Infra, then DA=RA. This might not be
3040      * true in the future
3041      */
3042     if ((priv->bss_mode == MLAN_BSS_MODE_INFRA) && (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA))
3043     {
3044         return MFALSE;
3045     }
3046 
3047     return MTRUE;
3048 }
3049 
3050 /**
3051  *  @brief Copy Rates
3052  *
3053  *  @param dest                 A pointer to Dest Buf
3054  *  @param pos		        The position for copy
3055  *  @param src		        A pointer to Src Buf
3056  *  @param len                  The len of Src Buf
3057  *
3058  *  @return 	   	        Number of Rates copied
3059  */
3060 INLINE
3061 static t_u32 wlan_copy_rates(t_u8 *dest, t_u32 pos, t_u8 *src, int len)
3062 {
3063     int i;
3064 
3065     for (i = 0; i < len && src[i]; i++)
3066     {
3067         if (pos >= sizeof(WLAN_802_11_RATES))
3068         {
3069             break;
3070         }
3071         dest[pos] = src[i];
3072         pos++;
3073     }
3074 
3075     return pos;
3076 }
3077 
3078 /**
3079  *  @brief strlen
3080  *
3081  *  @param str		        A pointer to string
3082  *
3083  *  @return 	   	        Length of string
3084  */
3085 INLINE
3086 static t_u32 wlan_strlen(const t_s8 *str)
3087 {
3088     t_u32 i;
3089 
3090     for (i = 0; str[i] != '\0'; i++)
3091     {
3092     }
3093     return i;
3094 }
3095 
3096 /**
3097  *  @brief iscdigit
3098  *
3099  *  @param chr                  A char
3100  *
3101  *  @return                     Non zero if chr is a hex, else 0
3102  */
3103 INLINE
3104 static t_u32 wlan_isxdigit(t_u8 chr)
3105 {
3106     return ((chr <= 'f' && chr >= 'a') || (chr <= 'F' && chr >= 'A') || (chr <= '9' && chr >= '0'));
3107 }
3108 
3109 /**
3110  *  @brief isspace
3111  *
3112  *  @param                       A chr
3113  *
3114  *  @return                      Non zero if chr is space etc, else 0
3115  */
3116 INLINE
3117 static t_u32 wlan_isspace(t_u8 chr)
3118 {
3119     return (chr <= ' ' && (chr == ' ' || (chr <= 13 && chr >= 9)));
3120 }
3121 
3122 /** delay unit */
3123 typedef enum _delay_unit
3124 {
3125     USEC,
3126     MSEC,
3127     SEC,
3128 } t_delay_unit;
3129 
3130 /** delay function wrapper */
3131 #define wlan_delay(p, n) wlan_delay_func(p, n, SEC)
3132 /** delay function wrapper */
3133 #define wlan_mdelay(p, n) wlan_delay_func(p, n, MSEC)
3134 /** delay function wrapper */
3135 #define wlan_udelay(p, n) wlan_delay_func(p, n, USEC)
3136 
3137 /** Function to check if any command is pending in the queue */
3138 #define IS_COMMAND_PENDING(pmadapter)                                                    \
3139     ((cmd_ctrl_node *)util_peek_list(pmadapter->pmoal_handle, &pmadapter->cmd_pending_q, \
3140                                      pmadapter->callbacks.moal_spin_lock, pmadapter->callbacks.moal_spin_unlock))
3141 
3142 /** Get BSS number from priv */
3143 #define GET_BSS_NUM(priv) (priv)->bss_num
3144 /**
3145  *  @brief This function returns priv based on the BSS num and BSS type
3146  *
3147  *  @param pmadapter A pointer to mlan_adapter
3148  *  @param bss_num   BSS number
3149  *  @param bss_type  BSS type
3150  *
3151  *  @return          Pointer to mlan_private
3152  */
3153 INLINE
3154 static mlan_private *wlan_get_priv_by_id(mlan_adapter *pmadapter, t_u32 bss_num, t_u32 bss_type)
3155 {
3156     int i;
3157 
3158     for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++)
3159     {
3160         if (pmadapter->priv[i] != MNULL)
3161         {
3162             if ((pmadapter->priv[i]->bss_num == bss_num) && (pmadapter->priv[i]->bss_type == bss_type))
3163             {
3164                 return (pmadapter->priv[i]);
3165             }
3166         }
3167     }
3168     return MNULL;
3169 }
3170 
3171 /**
3172  *  @brief This function returns first available priv
3173  *  based on the BSS role
3174  *
3175  *  @param pmadapter A pointer to mlan_adapter
3176  *  @param bss_role  BSS role or MLAN_BSS_ROLE_ANY
3177  *
3178  *  @return          Pointer to mlan_private
3179  */
3180 INLINE
3181 static mlan_private *wlan_get_priv(mlan_adapter *pmadapter, mlan_bss_role bss_role)
3182 {
3183     int i;
3184 
3185     for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++)
3186     {
3187         if (pmadapter->priv[i] != MNULL)
3188         {
3189             if (bss_role == MLAN_BSS_ROLE_ANY || GET_BSS_ROLE(pmadapter->priv[i]) == bss_role)
3190             {
3191                 return (pmadapter->priv[i]);
3192             }
3193         }
3194     }
3195     return MNULL;
3196 }
3197 
3198 /**
3199  *  @brief This function counts the number of occurences for a certain
3200  *  condition among privs.  Which privs are checked can be configured
3201  *  via a second condition.
3202  *
3203  *  @param pmadapter  A pointer to mlan_adapter
3204  *  @param count_cond Function pointer to condition to count on privs
3205  *  @param check_cond Function pointer to condition to decide whether priv
3206  *                    should be counted or not.  Use MNULL to check all privs.
3207  *
3208  *  @return          Count of privs where count_cond returned MTRUE.
3209  */
3210 INLINE
3211 static int wlan_count_priv_cond(mlan_adapter *pmadapter,
3212                                 t_bool (*count_cond)(IN pmlan_private pmpriv),
3213                                 t_bool (*check_cond)(IN pmlan_private pmpriv))
3214 {
3215     pmlan_private pmpriv;
3216     int count = 0;
3217     t_u8 i;
3218 
3219     if (pmadapter == MNULL || count_cond == MNULL)
3220     {
3221         return 0;
3222     }
3223 
3224     for (i = 0; i < pmadapter->priv_num; i++)
3225     {
3226         pmpriv = pmadapter->priv[i];
3227         if (pmpriv != MNULL)
3228         {
3229             if ((check_cond == MNULL) || check_cond(pmpriv))
3230             {
3231                 if (count_cond(pmpriv))
3232                 {
3233                     count++;
3234                 }
3235             }
3236         }
3237     }
3238 
3239     return count;
3240 }
3241 
3242 /**
3243  *  @brief This function runs a procedure on each priv.
3244  *  Which privs it is run on can be configured via a condition.
3245  *
3246  *  @param pmadapter  A pointer to mlan_adapter
3247  *  @param operation  Function pointer to produedure to operate on priv
3248  *  @param check_cond Function pointer to condition to decide whether priv
3249  *                    operated on or not.  Use MNULL to run on all privs.
3250  *
3251  *  @return           Number of privs that operation was run on.
3252  */
3253 INLINE
3254 static int wlan_do_task_on_privs(mlan_adapter *pmadapter,
3255                                  t_void (*operation)(IN pmlan_private pmpriv),
3256                                  t_bool (*check_cond)(IN pmlan_private pmpriv))
3257 {
3258     pmlan_private pmpriv;
3259     int count = 0;
3260     t_u8 i;
3261 
3262     if (pmadapter == MNULL || operation == MNULL)
3263     {
3264         return 0;
3265     }
3266 
3267     for (i = 0; i < pmadapter->priv_num; i++)
3268     {
3269         pmpriv = pmadapter->priv[i];
3270         if (pmpriv != MNULL)
3271         {
3272             if ((check_cond == MNULL) || check_cond(pmpriv))
3273             {
3274                 operation(pmpriv);
3275                 count++;
3276             }
3277         }
3278     }
3279 
3280     return count;
3281 }
3282 
3283 /**
3284  *  @brief This function builds a list of privs that test for a condition
3285  *  This is useful if you need to do a number of operations on the same set
3286  *  of privs.  For one-off tasks, the above two functions might be better.
3287  *
3288  *  @param pmadapter  A pointer to mlan_adapter
3289  *  @param check_cond Function pointer to condition to decide whether priv
3290  *                    should be placed in the list.
3291  *  @param ppriv_list Output param.  Externally supplied array of mlan_private*
3292  *                    to hold priv's that test positive with check_cond.
3293  *                    Array size should be at least pmadapter->priv_num.
3294  *
3295  *  @return          Number of privs in ppriv_list
3296  *
3297  *  @sa              wlan_count_priv_cond
3298  */
3299 INLINE
3300 static int wlan_get_privs_by_cond(mlan_adapter *pmadapter,
3301                                   t_bool (*check_cond)(IN pmlan_private pmpriv),
3302                                   mlan_private **ppriv_list)
3303 {
3304     pmlan_private pmpriv;
3305     int count = 0;
3306     t_u8 i;
3307 
3308     if (pmadapter == MNULL || check_cond == MNULL || ppriv_list == MNULL)
3309     {
3310         return 0;
3311     }
3312 
3313     for (i = 0; i < pmadapter->priv_num; i++)
3314     {
3315         pmpriv = pmadapter->priv[i];
3316         if (pmpriv != MNULL)
3317         {
3318             if (check_cond(pmpriv))
3319             {
3320                 ppriv_list[count++] = pmpriv;
3321             }
3322         }
3323     }
3324 
3325     return count;
3326 }
3327 
3328 /**
3329  *  @brief This function builds a list of privs that test against two conditions
3330  *  This is useful if you need to do a number of operations on the same set
3331  *  of privs.  Can choose whether both conditions (AND) or either condition (OR)
3332  *  is required.
3333  *
3334  *  @param pmadapter      A pointer to mlan_adapter
3335  *  @param check_cond     Function pointer to condition to decide whether priv
3336  *                        should be placed in the list.
3337  *  @param check_cond_2   Function pointer to second condition to check.
3338  *  @param and_conditions If MTRUE, both conditions must be met (AND),
3339  *                        else either condition can be met (OR).
3340  *  @param ppriv_list     Output param.  Externally supplied array of mlan_private*
3341  *                        to hold priv's that test positive with check_cond.
3342  *                        Array size should be at least pmadapter->priv_num.
3343  *
3344  *  @return          Number of privs in ppriv_list
3345  *
3346  *  @sa              wlan_count_priv_cond, wlan_get_privs_by_cond
3347  */
3348 INLINE
3349 static int wlan_get_privs_by_two_cond(mlan_adapter *pmadapter,
3350                                       t_bool (*check_cond)(IN pmlan_private pmpriv),
3351                                       t_bool (*check_cond_2)(IN pmlan_private pmpriv),
3352                                       t_bool and_conditions,
3353                                       mlan_private **ppriv_list)
3354 {
3355     pmlan_private pmpriv;
3356     int count = 0;
3357     t_u8 i;
3358 
3359     if (pmadapter == MNULL || check_cond == MNULL || check_cond_2 == MNULL || ppriv_list == MNULL)
3360     {
3361         return 0;
3362     }
3363 
3364     for (i = 0; i < pmadapter->priv_num; i++)
3365     {
3366         pmpriv = pmadapter->priv[i];
3367         if (pmpriv != MNULL)
3368         {
3369             if (and_conditions)
3370             {
3371                 if (check_cond(pmpriv) && check_cond_2(pmpriv))
3372                 {
3373                     ppriv_list[count++] = pmpriv;
3374                 }
3375             }
3376             else
3377             {
3378                 if (check_cond(pmpriv) || check_cond_2(pmpriv))
3379                 {
3380                     ppriv_list[count++] = pmpriv;
3381                 }
3382             }
3383         }
3384     }
3385 
3386     return count;
3387 }
3388 
3389 #if CONFIG_WMM_UAPSD
3390 /** Check if there is no packet */
3391 t_u8 wifi_check_no_packet_indication(mlan_private *priv);
3392 /** Check if this is the last packet */
3393 t_u8 wifi_check_last_packet_indication(mlan_private *priv);
3394 #endif
3395 
3396 mlan_status wlan_cmd_hs_wakeup_reason(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_void *pdata_buf);
3397 
3398 mlan_status wlan_ret_hs_wakeup_reason(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3399 
3400 #if CONFIG_FW_VDLL
3401 mlan_status wlan_download_vdll_block(mlan_adapter *pmadapter, t_u8 *block, t_u16 block_len);
3402 mlan_status wlan_process_vdll_event(pmlan_private pmpriv, t_u8 *pevent);
3403 #endif
3404 
3405 #if CONFIG_WIFI_IND_RESET
3406 mlan_status wlan_misc_ioctl_ind_rst_cfg(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
3407 mlan_status wlan_cmd_ind_rst_cfg(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
3408 
3409 mlan_status wlan_ret_ind_rst_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3410 #endif
3411 
3412 mlan_status wlan_cmd_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
3413 
3414 mlan_status wlan_ret_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3415 
3416 t_bool wlan_is_etsi_country(pmlan_adapter pmadapter, t_u8 *country_code);
3417 
3418 #endif /* !_MLAN_MAIN_H_ */
3419