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 /** Tx aggregation data structure */
896 typedef struct _txAggr_t
897 {
898     /** AMPDU user */
899     t_u8 ampdu_user;
900     /** AMPDU AP */
901     t_u8 ampdu_ap;
902     /** AMSDU */
903     t_u8 amsdu;
904 #if CONFIG_AMSDU_IN_AMPDU
905     /** peer AMSDU */
906     t_u8 amsdu_peer;
907 #endif
908     /** TX packet cnt */
909     t_u32 txpkt_cnt;
910     /** TX BA threshold */
911     t_u32 txba_thresh;
912 } tx_aggr_t;
913 
914 /** RA list table */
915 typedef struct _raListTbl raListTbl;
916 
917 /** RA list table */
918 struct _raListTbl
919 {
920     /** Pointer to previous node */
921     raListTbl *pprev;
922     /** Pointer to next node */
923     raListTbl *pnext;
924     /** Buffer list head */
925     mlan_list_head buf_head;
926     /** RA list buffer */
927     t_u8 ra[MLAN_MAC_ADDR_LENGTH];
928     /** total packets in RA list */
929     t_u16 total_pkts;
930     /** packets received */
931     t_u16 packet_count;
932     /** packet count threshold to setup BA */
933     t_u8 ba_packet_threshold;
934     /** is 11n enabled */
935     t_u8 is_11n_enabled;
936     /** max amsdu size */
937     t_u16 max_amsdu;
938     /** tx_pause flag */
939     t_u8 tx_pause;
940 #if CONFIG_WMM
941     /** drop packet count  */
942     t_u16 drop_count;
943 #endif
944 };
945 
946 /** TID table */
947 typedef struct _tidTbl
948 {
949     /** RA list head */
950     mlan_list_head ra_list;
951     /** Current RA list */
952     raListTbl *ra_list_curr;
953 } tid_tbl_t;
954 
955 /** Highest priority setting for a packet (uses voice AC) */
956 #define WMM_HIGHEST_PRIORITY 7
957 /** Highest priority TID  */
958 #define HIGH_PRIO_TID 7
959 /** Lowest priority TID  */
960 #define LOW_PRIO_TID 0
961 /** No packet priority (< lowest) */
962 #define NO_PKT_PRIO_TID -1
963 
964 /** Struct of WMM DESC */
965 typedef struct _wmm_desc
966 {
967     /** TID table */
968     tid_tbl_t tid_tbl_ptr[MAX_NUM_TID];
969     /** Packets out */
970     t_u32 packets_out[MAX_NUM_TID];
971     /** Packets queued */
972     t_u32 pkts_queued[MAX_NUM_TID];
973     /** Spin lock to protect ra_list */
974     t_void *ra_list_spinlock;
975 
976     /** AC status */
977     WmmAcStatus_t ac_status[MAX_AC_QUEUES];
978     /** AC downgraded values */
979     mlan_wmm_ac_e ac_down_graded_vals[MAX_AC_QUEUES];
980 
981     /** Max driver packet delay sent to the firmware for expiry eval */
982     t_u32 drv_pkt_delay_max;
983 
984     /** WMM queue priority table */
985     t_u8 queue_priority[MAX_AC_QUEUES];
986     /** User priority packet transmission control */
987     t_u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
988 
989     /** Number of transmit packets queued */
990     mlan_scalar tx_pkts_queued;
991     /** Tracks highest priority with a packet queued */
992     mlan_scalar highest_queued_prio;
993 #if (CONFIG_WMM) && (CONFIG_WMM_DEBUG)
994     /** Restored historical ralists for debug */
995     mlan_list_head hist_ra[MAX_AC_QUEUES];
996     /** Restored historical ralists count */
997     t_u8 hist_ra_count[MAX_AC_QUEUES];
998 #endif
999 } wmm_desc_t;
1000 
1001 /** Security structure */
1002 typedef struct _wlan_802_11_security_t
1003 {
1004     /** WPA enabled flag */
1005     t_u8 wpa_enabled;
1006     /** WPA TKIP flag */
1007     bool is_wpa_tkip;
1008 #if CONFIG_11R
1009     /** FT attempt flag */
1010     bool is_ft;
1011 #endif
1012     /** E-Supplicant enabled flag */
1013     t_u8 ewpa_enabled;
1014     /** WPA2 enabled flag */
1015     t_u8 wpa2_enabled;
1016     /** WAPI enabled flag */
1017     t_u8 wapi_enabled;
1018     /** WAPI key on flag */
1019     t_u8 wapi_key_on;
1020     /** WEP status */
1021     WLAN_802_11_WEP_STATUS wep_status;
1022     /** Authentication mode */
1023     mlan_auth_mode authentication_mode;
1024     /** Encryption mode */
1025     mlan_encryption_mode encryption_mode;
1026 } wlan_802_11_security_t;
1027 
1028 /** Current Basic Service Set State Structure */
1029 typedef struct
1030 {
1031     /** BSS descriptor */
1032     BSSDescriptor_t bss_descriptor;
1033     /** WMM enable? */
1034     t_u8 wmm_enabled;
1035     /** Uapsd enable?*/
1036     t_u8 wmm_uapsd_enabled;
1037     /** Band */
1038     t_u8 band;
1039     /** Number of rates supported */
1040     t_u32 num_of_rates;
1041     /** Supported rates*/
1042     t_u8 data_rates[WLAN_SUPPORTED_RATES];
1043 #if CONFIG_HOST_MLME
1044     /** Host MLME flag*/
1045     t_u8 host_mlme;
1046 #endif
1047     /** prev_bssid */
1048     mlan_802_11_mac_addr prev_bssid;
1049     /** attemp_bssid */
1050     mlan_802_11_mac_addr attemp_bssid;
1051     t_u8 use_mfp;
1052 } current_bss_params_t;
1053 
1054 /** Sleep_params */
1055 typedef struct _sleep_params_t
1056 {
1057     /** Sleep parameter error */
1058     t_u16 sp_error;
1059     /** Sleep parameter offset */
1060     t_u16 sp_offset;
1061     /** Sleep parameter stable time */
1062     t_u16 sp_stable_time;
1063     /** Sleep parameter calibration control */
1064     t_u8 sp_cal_control;
1065     /** Sleep parameter external sleep clock */
1066     t_u8 sp_ext_sleep_clk;
1067     /** Sleep parameter reserved */
1068     t_u16 sp_reserved;
1069 } sleep_params_t;
1070 
1071 /** Sleep_period */
1072 typedef struct sleep_period_t
1073 {
1074     /** Sleep period */
1075     t_u16 period;
1076     /** Reserved */
1077     t_u16 reserved;
1078 } sleep_period_t;
1079 
1080 /** mrvl_wep_key_t */
1081 typedef struct _mrvl_wep_key_t
1082 {
1083     /** Length */
1084     t_u32 length;
1085     /** WEP key index */
1086     t_u32 key_index;
1087     /** WEP key length */
1088     t_u32 key_length;
1089     /** WEP keys */
1090     t_u8 key_material[MRVL_KEY_BUFFER_SIZE_IN_BYTE];
1091 } mrvl_wep_key_t;
1092 
1093 /** Maximum number of region channel */
1094 #define MAX_REGION_CHANNEL_NUM 2U
1095 
1096 /** Region-band mapping table */
1097 typedef struct _region_chan_t
1098 {
1099     /** TRUE if this entry is valid */
1100     t_u8 valid;
1101     /** Region code for US, Japan ... */
1102     t_u8 region;
1103     /** Band B/G/A, used for BAND_CONFIG cmd */
1104     t_u16 band;
1105     /** Actual No. of elements in the array below */
1106     t_u8 num_cfp;
1107     /** chan-freq-txpower mapping table */
1108     const chan_freq_power_t *pcfp;
1109 } region_chan_t;
1110 
1111 /** State of 11d */
1112 typedef enum _state_11d_t
1113 {
1114     DISABLE_11D = 0UL,
1115     ENABLE_11D  = 1UL,
1116 } state_11d_t;
1117 
1118 /** State of 11h */
1119 typedef enum _state_11h_t
1120 {
1121     DISABLE_11H = 0UL,
1122     ENABLE_11H  = 1UL,
1123 } state_11h_t;
1124 
1125 #define DEFAULT_11D_STATE DISABLE_11D
1126 
1127 /** Domain regulatory information */
1128 typedef struct _wlan_802_11d_domain_reg
1129 {
1130     /** Country Code */
1131     t_u8 country_code[COUNTRY_CODE_LEN];
1132     /** band that channels in sub_band belong to */
1133     t_u16 band;
1134     /** No. of subband in below */
1135     t_u8 no_of_sub_band;
1136     /** Subband data to send/last sent */
1137     IEEEtypes_SubbandSet_t sub_band[MRVDRV_MAX_SUBBAND_802_11D];
1138 } wlan_802_11d_domain_reg_t;
1139 
1140 /** Data for state machine */
1141 typedef struct _wlan_802_11d_state
1142 {
1143     /** True for enabling 11D */
1144     state_11d_t enable_11d;
1145     /** True for user enabling 11D */
1146     state_11d_t user_enable_11d;
1147     /** True for user enabling 11D support*/
1148     state_11d_t user_enable_11d_support;
1149 } wlan_802_11d_state_t;
1150 
1151 /** 802.11h State information kept in the 'mlan_private' driver structure */
1152 typedef struct
1153 {
1154     /** Indicates whether 11h is enabled in the driver */
1155     t_bool is_11h_enabled;
1156     /** Indicates whether 11h is active in the firmware */
1157     t_bool is_11h_active;
1158     /** Master device using automatic channel select */
1159     t_bool adhoc_auto_sel_chan;
1160     /** Set when driver receives a STOP TX event from fw */
1161     t_bool tx_disabled;
1162 } wlan_11h_interface_state_t;
1163 
1164 #if defined(UAP_SUPPORT)
1165 /** UAP get info callback state kept in the 'mlan_private' driver structure */
1166 typedef struct
1167 {
1168     /** UAP internal callback after wlan_uap_get_channel */
1169     /**  (parameter is really pointer to mlan_private)   */
1170     mlan_status (*get_chan_callback)(t_void *);
1171     /** current ioctl_req (to be completed in callback) */
1172     pmlan_ioctl_req pioctl_req_curr;
1173     /** band_cfg from MrvlIEtypes_channel_band_t */
1174     t_u8 band_config;
1175     /** channel from MrvlIEtypes_channel_band_t */
1176     t_u8 channel;
1177     /** beacon period (in msec) from MrvlIEtypes_beacon_period_t */
1178     t_u16 beacon_period;
1179     /** dtim period (no unit) from MrvlIEtypes_dtim_period_t */
1180     t_u8 dtim_period;
1181     /** Maximum number of stations that will be allowed to connect to the uAP.
1182      */
1183     t_u16 max_sta_count;
1184 } wlan_uap_get_info_cb_t;
1185 #endif
1186 
1187 /** Data structure for WPS information */
1188 typedef struct
1189 {
1190     /** WPS IE */
1191     IEEEtypes_VendorSpecific_t wps_ie;
1192     int wps_mgmt_bitmap_index;
1193     /** Session enable flag */
1194     t_u8 session_enable;
1195 } wps_t;
1196 
1197 typedef struct _mlan_private mlan_private;
1198 typedef struct _mlan_private *pmlan_private;
1199 
1200 /* 802.11D related structs */
1201 typedef struct
1202 {
1203 #ifdef STA_SUPPORT
1204     mlan_status (*wlan_11d_prepare_dnld_domain_info_cmd_p)(mlan_private *pmpriv);
1205     mlan_status (*wlan_11d_create_dnld_countryinfo_p)(mlan_private *pmpriv, t_u16 band);
1206     mlan_status (*wlan_11d_parse_dnld_countryinfo_p)(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc);
1207 #endif
1208 } wlan_11d_fn_t;
1209 
1210 typedef struct _mlan_adapter *pmlan_adapter;
1211 typedef struct _mlan_adapter mlan_adapter;
1212 
1213 typedef struct
1214 {
1215     mlan_status (*wlan_11d_cfg_ioctl_p)(IN mlan_private *pmpriv, IN pmlan_ioctl_req pioctl_req);
1216     mlan_status (*wlan_11d_cfg_domain_info_p)(IN pmlan_adapter pmadapter, IN mlan_ioctl_req *pioctl_req);
1217     mlan_status (*wlan_cmd_802_11d_domain_info_p)(mlan_private *pmpriv, HostCmd_DS_COMMAND *pcmd, t_u16 cmd_action);
1218     mlan_status (*wlan_11d_handle_uap_domain_info_p)(mlan_private *pmpriv,
1219                                                      t_u16 band,
1220                                                      t_u8 *domain_tlv,
1221                                                      t_void *pioctl_buf);
1222 } wlan_11d_apis_t;
1223 
1224 #if CONFIG_WMM
1225 typedef struct
1226 {
1227     mlan_list_head free_list;
1228     int free_cnt;
1229 } outbuf_pool_t;
1230 
1231 typedef struct
1232 {
1233     t_u16 tx_no_media;
1234     t_u16 tx_err_mem;
1235     t_u16 tx_wmm_retried_drop;
1236     t_u16 tx_wmm_pause_drop;
1237     t_u16 tx_wmm_pause_replaced;
1238     t_u16 rx_reorder_drop;
1239 } wlan_pkt_stat_t;
1240 #endif
1241 
1242 /** mlan_operations data structure */
1243 typedef struct _mlan_operations
1244 {
1245     /** cmd handler */
1246     mlan_status (*prepare_cmd)(IN t_void *priv,
1247                                IN t_u16 cmd_no,
1248                                IN t_u16 cmd_action,
1249                                IN t_u32 cmd_oid,
1250                                IN t_void *pioctl_buf,
1251                                IN t_void *pdata_buf,
1252                                IN t_void *pcmd_buf);
1253     /** rx handler */
1254     mlan_status (*process_rx_packet)(IN t_void *adapter, IN pmlan_buffer pmbuf);
1255     /** BSS role */
1256     mlan_bss_role bss_role;
1257 } mlan_operations;
1258 
1259 typedef MLAN_PACK_START struct _mlan_chan_info
1260 {
1261     unsigned int mode;
1262     int freq;
1263     int channel;
1264     int sec_channel_offset;
1265     int bandwidth;
1266     int ht_enabled;
1267     int vht_enabled;
1268     int he_enabled;
1269     int center_freq1;
1270     int center_freq2;
1271 } MLAN_PACK_END mlan_chan_info;
1272 
1273 #if CONFIG_HOST_MLME
1274 
1275 #define WLAN_AUTH_SAE 3
1276 
1277 /** AUTH pending flag */
1278 #define HOST_MLME_AUTH_PENDING MBIT(0)
1279 /** AUTH complete flag */
1280 #define HOST_MLME_AUTH_DONE     MBIT(1)
1281 #define HOST_MLME_ASSOC_PENDING MBIT(2)
1282 #define HOST_MLME_ASSOC_DONE    MBIT(3)
1283 #endif
1284 
1285 #ifdef RW610
1286 /**Adapter_operations data structure*/
1287 typedef struct _bus_operations
1288 {
1289     /** interface to check if fw is hang */
1290     bool (*fw_is_hang)(void);
1291     /**Interface header length*/
1292     t_u32 intf_header_len;
1293 } bus_operations;
1294 #endif
1295 
1296 /** Private structure for MLAN */
1297 struct _mlan_private
1298 {
1299     /** Pointer to mlan_adapter */
1300     struct _mlan_adapter *adapter;
1301     /** BSS index */
1302     t_u8 bss_index;
1303     /** BSS type */
1304     mlan_bss_type bss_type;
1305     /** BSS role */
1306     mlan_bss_role bss_role;
1307     /** BSS Priority */
1308     t_u8 bss_priority;
1309     /** BSS number */
1310     t_u8 bss_num;
1311     /** Frame type */
1312     t_u8 frame_type;
1313     /** MAC address information */
1314     t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
1315 #if CONFIG_P2P
1316     /** P2P MAC address information */
1317     t_u8 curr_p2p_addr[MLAN_MAC_ADDR_LENGTH];
1318 #endif
1319     /** Media connection status */
1320     t_bool media_connected;
1321 
1322     /** Current packet filter */
1323     t_u32 curr_pkt_filter;
1324     /** Infrastructure mode */
1325     mlan_bss_mode bss_mode;
1326 
1327     /** Channel info */
1328     mlan_chan_info chan;
1329 
1330     /** Tx packet control */
1331     t_u32 pkt_tx_ctrl;
1332 
1333     /** Tx power level */
1334     t_u16 tx_power_level;
1335     /** Maximum Tx power level */
1336     t_u8 max_tx_power_level;
1337     /** Minimum Tx power level */
1338     t_u8 min_tx_power_level;
1339     /** Tx rate */
1340     t_u8 tx_rate;
1341 #ifdef SD8801
1342     /** tx ht_info */
1343     t_u8 tx_htinfo;
1344     /** rxpd_htinfo */
1345     t_u8 rxpd_htinfo;
1346 #else
1347     t_u8 tx_rate_info;
1348 #if CONFIG_11AX
1349     /*HE tx tone mode and DCM info*/
1350     t_u8 ext_tx_rate_info;
1351 #endif
1352     /** rxpd_htinfo */
1353     t_u8 rxpd_rate_info;
1354 #endif
1355 
1356 #if CONFIG_11AX
1357     /** UAP 11ax flag */
1358     t_u8 is_11ax_enabled;
1359     /** length of hw he capability */
1360     t_u8 user_hecap_len;
1361     /** user configured 802.11ax HE capability */
1362     t_u8 user_he_cap[54];
1363     /** length of hw he capability */
1364     t_u8 user_2g_hecap_len;
1365     /** user configured 802.11ax HE capability */
1366     t_u8 user_2g_he_cap[54];
1367 #endif
1368 
1369     t_u8 ssid_filter;
1370 
1371     /** Filter SSID */
1372     mlan_802_11_ssid filter_ssid[MRVDRV_MAX_SSID_LIST_LENGTH];
1373     /** max amsdu size */
1374     t_u16 max_amsdu;
1375 #if CONFIG_AMSDU_IN_AMPDU
1376     /** amsdu enabled */
1377     t_bool is_amsdu_enabled;
1378 #endif
1379 #ifdef UAP_SUPPORT
1380     /** UAP 11n flag */
1381     bool is_11n_enabled;
1382     /** UAP 11ac flag */
1383     bool is_11ac_enabled;
1384 #endif /* UAP_SUPPORT */
1385 #ifdef UAP_SUPPORT
1386 #endif /* UAP_SUPPORT */
1387 #ifdef UAP_SUPPORT
1388     /** packet forward control */
1389     t_u8 pkt_fwd;
1390     /**  dropped pkts */
1391     t_u32 num_drop_pkts;
1392 #endif
1393     /** TX beamforming capability */
1394     t_u32 tx_bf_cap;
1395     /** Rx PD rate */
1396     t_u8 rxpd_rate;
1397     /** Rate bitmap */
1398     t_u16 rate_bitmap;
1399     /** Bitmap rates */
1400     t_u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
1401     /** Data rate */
1402     t_u32 data_rate;
1403     /** Data rate index */
1404     t_s8 data_rate_index;
1405     /** Automatic data rate flag */
1406     bool is_data_rate_auto;
1407     /** Factor for calculating beacon average */
1408     t_u16 bcn_avg_factor;
1409     /** Factor for calculating data average */
1410     t_u16 data_avg_factor;
1411     /** Last data RSSI */
1412     t_s16 data_rssi_last;
1413     /** Last data Noise Floor */
1414     t_s16 data_nf_last;
1415     /** Average data RSSI */
1416     t_s16 data_rssi_avg;
1417     /** Averag data Noise Floor */
1418     t_s16 data_nf_avg;
1419     /** Last beacon RSSI */
1420     t_s16 bcn_rssi_last;
1421     /** Last beacon Noise Floor */
1422     t_s16 bcn_nf_last;
1423     /** Average beacon RSSI */
1424     t_s16 bcn_rssi_avg;
1425     /** Average beacon Noise Floor */
1426     t_s16 bcn_nf_avg;
1427 
1428     /** Attempted BSS descriptor */
1429     BSSDescriptor_t *pattempted_bss_desc;
1430 #if CONFIG_GTK_REKEY_OFFLOAD
1431     /** GTK rekey data*/
1432     mlan_ds_misc_gtk_rekey_data gtk_rekey;
1433 #endif
1434 
1435     /** Current SSID/BSSID related parameters*/
1436     current_bss_params_t curr_bss_params;
1437 
1438 #if CONFIG_HOST_MLME
1439     /** flag for auth */
1440     t_u8 auth_flag;
1441     /** flag for auth algorithm */
1442     t_u16 auth_alg;
1443 #if CONFIG_11R
1444     /** flag for ft roam */
1445     t_u8 ft_roam;
1446 #endif
1447 #endif
1448 
1449     /** User selected bands */
1450     t_u16 config_bands;
1451 
1452     /** Beacon period */
1453     t_u16 beacon_period;
1454     /** Listen interval */
1455     t_u16 listen_interval;
1456     /** ATIM window */
1457     t_u16 atim_window;
1458 
1459     /** AdHoc channel */
1460     t_u8 adhoc_channel;
1461     /** AdHoc link sensed flag */
1462     t_u8 adhoc_is_link_sensed;
1463     /** AdHoc operating state */
1464     t_u8 adhoc_state;
1465 #if defined(STA_SUPPORT)
1466     /** AdHoc operating state backup */
1467     t_u8 adhoc_state_prev;
1468     /** AdHoc previous ssid used for Start */
1469     mlan_802_11_ssid adhoc_last_start_ssid;
1470 #endif
1471     /** FSM variable for 11d support */
1472     wlan_802_11d_state_t state_11d;
1473     /** 11d function pointer */
1474     wlan_11d_fn_t *support_11d;
1475     /** 11d Driver function pointer */
1476     wlan_11d_apis_t *support_11d_APIs;
1477     /** FSM variable for 11h support */
1478     wlan_11h_interface_state_t intf_state_11h;
1479 #if defined(UAP_SUPPORT)
1480     /** Whether UAP interface has started */
1481     t_bool uap_bss_started;
1482     /** state variable for UAP Get Info callback */
1483     wlan_uap_get_info_cb_t uap_state_chan_cb;
1484 #endif
1485     /** Security related */
1486     /** Encryption parameter */
1487     wlan_802_11_security_t sec_info;
1488     /** WEP keys */
1489     mrvl_wep_key_t wep_key[MRVL_NUM_WEP_KEY];
1490     /** Current WEP key index */
1491     t_u16 wep_key_curr_index;
1492     /** EWPA query 0: disable, 1: enable */
1493     bool ewpa_query;
1494     /** Encryption Key*/
1495     t_u8 wpa_ie[MLAN_WMSDK_MAX_WPA_IE_LEN];
1496     /** WPA IE length */
1497     t_u8 wpa_ie_len;
1498 #if CONFIG_11R
1499     /** MD IE */
1500     t_u8 md_ie[5];
1501     /** MD IE length */
1502     size_t md_ie_len;
1503 #endif
1504     /** GTK set flag */
1505     t_u8 wpa_is_gtk_set;
1506     /** Pointer to the station table */
1507     mlan_list_head sta_list;
1508     /** mgmt frame passthru mask */
1509     t_u32 mgmt_frame_passthru_mask;
1510     /** Advanced Encryption Standard */
1511     bool adhoc_aes_enabled;
1512     /** WMM required */
1513     bool wmm_required;
1514     /** WMM enabled */
1515     bool wmm_enabled;
1516     /** WMM qos info */
1517     t_u8 wmm_qosinfo;
1518     /** WMM related variable*/
1519     wmm_desc_t wmm;
1520 #if CONFIG_WMM
1521     /** Bypass TX queue*/
1522     mlan_list_head bypass_txq;
1523     /** Bypass TX queue cnt*/
1524     t_u8 bypass_txq_cnt;
1525 #endif
1526     /* Mgmt Frame Protection config */
1527     mlan_ds_misc_pmfcfg pmfcfg;
1528 
1529     /* ED MAC MODE config */
1530     mlan_ds_misc_ed_mac_mode ed_mac_mode;
1531 
1532     /** Pointer to the Transmit BA stream table*/
1533     mlan_list_head tx_ba_stream_tbl_ptr;
1534     /** Semaphore to the Transmit BA stream table */
1535     OSA_MUTEX_HANDLE_DEFINE(tx_ba_stream_tbl_lock);
1536     /** Pointer to the priorities for AMSDU/AMPDU table*/
1537     tx_aggr_t aggr_prio_tbl[MAX_NUM_TID];
1538     /** Pointer to the priorities for AMSDU/AMPDU table*/
1539     t_u8 addba_reject[MAX_NUM_TID];
1540     /** Struct to store ADDBA parameters */
1541     add_ba_param_t add_ba_param;
1542     /** last rx_seq */
1543     t_u16 rx_seq[MAX_NUM_TID];
1544     /** Lock to the Receive Reordering table */
1545     OSA_SEMAPHORE_HANDLE_DEFINE(rx_reorder_tbl_lock);
1546     /** Pointer to the Receive Reordering table*/
1547     mlan_list_head rx_reorder_tbl_ptr;
1548     /** Lock for Rx packets */
1549     t_void *rx_pkt_lock;
1550 
1551 #ifdef STA_SUPPORT
1552     /** Generic IEEE IEs passed from the application to be inserted into the
1553      *    association request to firmware
1554      */
1555     t_u8 gen_ie_buf[MRVDRV_GENIE_BUF_SIZE];
1556     /** Length of the data stored in gen_ie_buf */
1557     t_u8 gen_ie_buf_len;
1558 
1559 #if CONFIG_WPA_SUPP
1560     /**
1561      * Default scan ies buffer
1562      */
1563     t_u8 default_scan_ies[MRVDRV_GENIE_BUF_SIZE];
1564     /** Length of the data stored in gen_ie_buf */
1565     t_u8 default_scan_ies_len;
1566 #endif
1567 
1568 #if CONFIG_WPA_SUPP
1569 #if CONFIG_WPA_SUPP_WPS
1570     /** WPS */
1571     wps_t wps;
1572 #endif
1573 #elif (CONFIG_WPS2)
1574     /** WPS */
1575     wps_t wps;
1576 #endif
1577     /** Buffer to store the association req IEs */
1578     t_u8 assoc_req_buf[MRVDRV_ASSOC_RSP_BUF_SIZE];
1579     /** Length of the data stored in assoc_rsp_buf */
1580     t_u32 assoc_req_size;
1581 #endif /* STA_SUPPORT */
1582 
1583     /** function table */
1584     mlan_operations ops;
1585 
1586 #if CONFIG_11K_OFFLOAD
1587     /** 11k flag */
1588     t_u8 enable_11k;
1589 #endif
1590 #if CONFIG_11K
1591     t_u8 enable_host_11k;
1592     int rrm_mgmt_bitmap_index;
1593     t_u8 neighbor_rep_token;
1594 #endif
1595 #if CONFIG_11V
1596     t_u8 bss_trans_query_token;
1597 #endif
1598 
1599     /** Port Control mode */
1600     bool port_ctrl_mode;
1601 
1602     /** Port open flag */
1603     bool port_open;
1604 
1605     /** Port open flag state at time of association attempt */
1606     bool prior_port_status;
1607 
1608     /** Scan block flag */
1609     bool scan_block;
1610     /** IP address operation */
1611     t_u32 op_code;
1612     /** IP address */
1613     t_u8 ip_addr[IPADDR_LEN];
1614     t_u32 hotspot_cfg;
1615     ExtCap_t ext_cap;
1616 #if (CONFIG_WNM_PS)
1617     /** WNM power save mode */
1618     bool wnm_set;
1619 #endif
1620 #if CONFIG_BG_SCAN
1621     t_u8 rssi_low;
1622     t_u8 roaming_enabled;
1623     t_u8 roaming_configured;
1624 #endif
1625 #if CONFIG_BG_SCAN
1626     /** bg_scan_start */
1627     t_u8 bg_scan_start;
1628     /** bg_scan reported */
1629     t_u8 bg_scan_reported;
1630     /** bg_scan config */
1631     wlan_bgscan_cfg scan_cfg;
1632     /** sched scaning flag */
1633     t_u8 sched_scanning;
1634     /** bgscan request id */
1635     t_u64 bg_scan_reqid;
1636 #endif
1637     /* interface pause status */
1638     t_u8 tx_pause;
1639 #if CONFIG_WMM
1640     wlan_pkt_stat_t driver_error_cnt;
1641 #endif
1642 #if CONFIG_1AS
1643     wifi_dot1as_info_t dot1as_info;
1644 #endif
1645 #if CONFIG_DRIVER_MBO
1646     t_u8 enable_mbo;
1647     int mbo_mgmt_bitmap_index;
1648 #endif
1649     /** tx_seq_num */
1650     t_u32 tx_seq_num;
1651 #if CONFIG_WPA_SUPP
1652     int probe_req_index;
1653 #if CONFIG_WPA_SUPP_AP
1654     int beacon_vendor_index;
1655     int beacon_index;
1656     int proberesp_index;
1657     int assocresp_index;
1658     int beacon_wps_index;
1659 #endif
1660 #endif
1661     /** uAP started or not */
1662     bool bss_started;
1663     /** host based uap flag */
1664     bool uap_host_based;
1665     /**UAP operating channel*/
1666     t_u8 uap_channel;
1667     /** uAP MAX STAs */
1668     t_u8 uap_max_sta;
1669 #if CONFIG_TCP_ACK_ENH
1670     bool enable_tcp_ack_enh;
1671 #endif
1672 #if CONFIG_WPA_SUPP_DPP
1673     /** configured by DPP */
1674     bool is_dpp_connect;
1675 #endif
1676 };
1677 
1678 /** BA stream status */
1679 typedef enum _baStatus_e
1680 {
1681     BA_STREAM_NOT_SETUP = 0,
1682     BA_STREAM_SETUP_INPROGRESS,
1683     BA_STREAM_SETUP_COMPLETE
1684 } baStatus_e;
1685 
1686 /** Tx BA stream table */
1687 struct _TxBAStreamTbl
1688 {
1689     /** TxBAStreamTbl previous node */
1690     TxBAStreamTbl *pprev;
1691     /** TxBAStreamTbl next node */
1692     TxBAStreamTbl *pnext;
1693     /** TID */
1694     int ampdu_stat[MAX_NUM_TID];
1695     /** RA */
1696     t_u8 ra[MLAN_MAC_ADDR_LENGTH];
1697     /** BA stream status */
1698     baStatus_e ba_status;
1699     t_u8 amsdu;
1700     t_u32 txpkt_cnt;
1701     t_u32 txba_thresh;
1702     t_u8 ampdu_supported[MAX_NUM_TID];
1703     /** last rx_seq */
1704     t_u16 rx_seq[MAX_NUM_TID];
1705 };
1706 
1707 /** RX reorder table */
1708 typedef struct _RxReorderTbl RxReorderTbl;
1709 
1710 typedef struct
1711 {
1712     /** Timer for flushing */
1713     OSA_TIMER_HANDLE_DEFINE(timer);
1714     /** Timer set flag */
1715     bool timer_is_set;
1716     /** RxReorderTbl ptr */
1717     RxReorderTbl *ptr;
1718     /** Priv pointer */
1719     mlan_private *priv;
1720 } reorder_tmr_cnxt_t;
1721 
1722 /** RX reorder table */
1723 struct _RxReorderTbl
1724 {
1725     /** RxReorderTbl previous node */
1726     RxReorderTbl *pprev;
1727     /** RxReorderTbl next node */
1728     RxReorderTbl *pnext;
1729     /** TID */
1730     int tid;
1731     /** TA */
1732     t_u8 ta[MLAN_MAC_ADDR_LENGTH];
1733     /** Start window */
1734     t_u16 start_win;
1735     /** last_seq */
1736     t_u16 last_seq;
1737     /** Window size */
1738     t_u16 win_size;
1739     /** Pointer to pointer to RxReorderTbl */
1740     t_void **rx_reorder_ptr;
1741     /** Timer context */
1742     reorder_tmr_cnxt_t timer_context;
1743     /** BA stream status */
1744     baStatus_e ba_status;
1745     t_u8 amsdu;
1746     /** no packet drop flag for rx_reorder_tbl */
1747     bool force_no_drop;
1748     /** flag for check start win */
1749     bool check_start_win;
1750     /** pkt receive after BA setup */
1751     t_u8 pkt_count;
1752     /** BA window bitmap */
1753     t_u64 bitmap;
1754 #if CONFIG_RSN_REPLAY_DETECTION
1755     /** PN number high 32 bits*/
1756     t_u32 hi_curr_rx_count32;
1757     /** PN number low 16 bits*/
1758     t_u16 lo_curr_rx_count16;
1759     /** PN drop counter */
1760     t_u32 pn_drop_count;
1761 #endif
1762 };
1763 
1764 /** BSS priority node */
1765 typedef struct _mlan_bssprio_node mlan_bssprio_node;
1766 
1767 /** BSS priority node */
1768 struct _mlan_bssprio_node
1769 {
1770     /** Pointer to previous node */
1771     mlan_bssprio_node *pprev;
1772     /** Pointer to next node */
1773     mlan_bssprio_node *pnext;
1774     /** Pointer to priv */
1775     pmlan_private priv;
1776 };
1777 
1778 /** BSS priority table */
1779 typedef struct _mlan_bssprio_tbl mlan_bssprio_tbl;
1780 
1781 /** BSS priority table */
1782 struct _mlan_bssprio_tbl
1783 {
1784     /** BSS priority list head */
1785     mlan_list_head bssprio_head;
1786     /** Current priority node */
1787     mlan_bssprio_node *bssprio_cur;
1788 };
1789 
1790 /** cmd_ctrl_node */
1791 typedef struct _cmd_ctrl_node cmd_ctrl_node;
1792 
1793 /** _cmd_ctrl_node */
1794 struct _cmd_ctrl_node
1795 {
1796     /** Pointer to previous node */
1797     cmd_ctrl_node *pprev;
1798     /** Pointer to next node */
1799     cmd_ctrl_node *pnext;
1800     /** Pointer to priv */
1801     pmlan_private priv;
1802     /** Command OID for sub-command use */
1803     t_u32 cmd_oid;
1804     /** Command flag */
1805     t_u32 cmd_flag;
1806     /** Pointer to mlan_buffer */
1807     mlan_buffer *cmdbuf;
1808     /** Pointer to mlan_buffer */
1809     mlan_buffer *respbuf;
1810     /** Command parameter */
1811     t_void *pdata_buf;
1812     /** Pointer to mlan_ioctl_req if command is from IOCTL */
1813     t_void *pioctl_buf;
1814     /** pre_allocated mlan_buffer for cmd */
1815     mlan_buffer *pmbuf;
1816 };
1817 
1818 /** station node */
1819 typedef struct _sta_node sta_node;
1820 
1821 /** station node*/
1822 struct _sta_node
1823 {
1824     /** previous node */
1825     sta_node *pprev;
1826     /** next node */
1827     sta_node *pnext;
1828     /** station mac address */
1829     t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
1830     /** wmm flag */
1831     t_u8 is_wmm_enabled;
1832     /** 11n flag */
1833     bool is_11n_enabled;
1834 #if CONFIG_11AC
1835     /** 11ac flag */
1836     bool is_11ac_enabled;
1837 #endif
1838 #if CONFIG_11AX
1839     t_u8 is_11ax_enabled;
1840     IEEEtypes_HECap_t he_cap;
1841 #endif
1842     /** AMPDU STA */
1843     t_u8 ampdu_sta[MAX_NUM_TID];
1844     /** last rx_seq */
1845     t_u16 rx_seq[MAX_NUM_TID];
1846     /** max amsdu size */
1847     t_u16 max_amsdu;
1848     /** HT cap */
1849     IEEEtypes_HTCap_t HTcap;
1850 #if defined(UAP_HOST_MLME)
1851     /** peer capability */
1852     t_u16 capability;
1853 #endif
1854     /** station band mode */
1855     t_u16 bandmode;
1856     /** wapi key on off flag */
1857     t_u8 wapi_key_on;
1858     /** tx pause status */
1859     t_u8 tx_pause;
1860 };
1861 
1862 /** 802.11h State information kept in the 'mlan_adapter' driver structure */
1863 typedef struct
1864 {
1865     /** Min TX Power capability sent to FW for 11h use and fw power control */
1866     t_s8 min_tx_power_capability;
1867     /** Max TX Power capability sent to FW for 11h use and fw power control */
1868     t_s8 max_tx_power_capability;
1869     /** User provisioned local power constraint sent in association requests */
1870     t_s8 usr_def_power_constraint;
1871     /** Received CHANNEL_SWITCH_ANN event */
1872     t_bool recvd_chanswann_event;
1873     /** Indicates an interface wants to enable master radar detection */
1874     t_bool master_radar_det_enable_pending;
1875     /** Indicates an interface wants to enable slave radar detection */
1876     t_bool slave_radar_det_enable_pending;
1877     /** Indicates whether master radar detection active in the firmware */
1878     t_bool is_master_radar_det_active;
1879     /** Indicates whether slave radar detection active in the firmware */
1880     t_bool is_slave_radar_det_active;
1881     /** Quiet IE */
1882     IEEEtypes_Quiet_t quiet_ie;
1883 } wlan_11h_device_state_t;
1884 
1885 /** Enumeration for DFS Timestamp represents field */
1886 enum _dfs_timestamp_repr_e
1887 {
1888     /** Ignore entry */
1889     DFS_TS_REPR_NOT_IN_USE = 0,
1890     /** NOP (Non-Occupancy Period) start time */
1891     DFS_TS_REPR_NOP_START = 1,
1892     /** CAC (Channel Availability Check) completion time */
1893     DFS_TS_REPR_CAC_COMPLETION
1894 };
1895 
1896 /** DFS Timestamp type used for marking NOP/CAC events */
1897 typedef struct _wlan_dfs_timestamp_t wlan_dfs_timestamp_t;
1898 
1899 /** DFS Timestamp type used for marking NOP/CAC events */
1900 struct _wlan_dfs_timestamp_t
1901 {
1902     /** Pointer to previous node */
1903     wlan_dfs_timestamp_t *pprev;
1904     /** Pointer to next node */
1905     wlan_dfs_timestamp_t *pnext;
1906     /** WLAN Channel number */
1907     t_u8 channel;
1908     /** What this timestamp represents */
1909     t_u8 represents;
1910     /** reserved field */
1911     t_u16 reserved;
1912     /** timestamp - seconds */
1913     t_u32 ts_sec;
1914     /** timestamp - microseconds */
1915     t_u32 ts_usec;
1916 };
1917 
1918 /** DFS State information kept in the 'mlan_adapter' driver structure */
1919 typedef struct
1920 {
1921     /** Indicates whether DFS channel check is occurring in firmware */
1922     t_bool dfs_check_pending;
1923     /** Indicates whether DFS channel check found radar */
1924     t_bool dfs_radar_found;
1925     /** Channel radar is being checked on.  BAND_A is assumed. */
1926     t_u8 dfs_check_channel;
1927     /** Timestamp when we got last report, to determine if data is old or not. */
1928     t_u32 dfs_report_time_sec;
1929     /** List for holding dfs_timestamps for NOP/CAC events */
1930     mlan_list_head dfs_ts_head;
1931 } wlan_dfs_device_state_t;
1932 
1933 /** Enumeration for mlan_ds_11h_radar_det_hndlg stages */
1934 enum _mlan_ds_11h_rdh_stages
1935 {
1936     RDH_OFF       = 0,
1937     RDH_CHK_INTFS = 1,
1938     RDH_STOP_TRAFFIC,
1939     RDH_GET_INFO_CHANNEL,
1940     RDH_GET_INFO_BEACON_DTIM,
1941     RDH_SET_CUSTOM_IE,
1942     RDH_REM_CUSTOM_IE,
1943     RDH_STOP_INTFS,
1944     RDH_SET_NEW_CHANNEL,
1945     RDH_RESTART_INTFS,
1946     RDH_RESTART_TRAFFIC
1947 };
1948 
1949 /** State info for Radar Detected Handling kept in 'mlan_adapter' */
1950 typedef struct
1951 {
1952     /** Stage (of Operation) */
1953     t_u8 stage;
1954     /** Number of interfaces to handle */
1955     t_u8 priv_list_count;
1956     /** Index of interface in process (used by some stages) */
1957     t_u8 priv_curr_idx;
1958     /** Current Channel (to leave) */
1959     t_u8 curr_channel;
1960     /** New Channel (to switch to) */
1961     t_u8 new_channel;
1962     /** UAP band_config */
1963     t_u8 uap_band_cfg;
1964     /** BEACON*DTIM period (in msec; max of STA/UAP) */
1965     t_u16 max_bcn_dtim_ms;
1966     /** List of interfaces to handle */
1967     mlan_private *priv_list[MLAN_MAX_BSS_NUM];
1968 } wlan_radar_det_hndlg_state_t;
1969 
1970 #ifdef DFS_TESTING_SUPPORT
1971 /** DFS/RDH testing exception settings kept in 'mlan_adapter' */
1972 typedef struct
1973 {
1974     /** user-configured CAC period (in msec) */
1975     t_u16 user_cac_period_msec;
1976     /** user-configured NOP period (in sec) */
1977     t_u16 user_nop_period_sec;
1978     /** user-configured skip channel change on radar */
1979     t_bool no_channel_change_on_radar;
1980     /** user-configured new channel to change to on radar */
1981     t_u8 fixed_new_channel_on_radar;
1982 } wlan_dfs_testing_settings_t;
1983 #endif /* DFS_SUPPORT_TESTING */
1984 
1985 /**
1986  * @brief Driver measurement state held in 'mlan_adapter' structure
1987  *
1988  *  Used to record a measurement request that the driver is pending on
1989  *    the result (received measurement report).
1990  */
1991 typedef struct
1992 {
1993     /**
1994      * Dialog token of a pending measurement request/report.  Used to
1995      *   block execution while waiting for the specific dialog token
1996      */
1997     t_u8 meas_rpt_pend_on;
1998 
1999     /**
2000      * Measurement report received from the firmware that we were pending on
2001      */
2002     HostCmd_DS_MEASUREMENT_REPORT meas_rpt_returned;
2003 
2004 } wlan_meas_state_t;
2005 
2006 #if CONFIG_WIFI_TX_PER_TRACK
2007 /** Tx Per Tracking Structure
2008  * Driver sets tx per tracking statistic to fw.
2009  * Fw will check tx packet error rate periodically and
2010  * report PER to host if per is high.
2011  */
2012 typedef struct
2013 {
2014     /** Enable/Disable tx per tracking */
2015     t_u8 tx_pert_check;
2016     /** Check period(unit sec) */
2017     t_u8 tx_pert_check_peroid;
2018     /** (Fail TX packet)/(Total TX packet) ratio(unit 10%)
2019      * default: 5
2020      */
2021     t_u8 tx_pert_check_ratio;
2022     /** A watermark of check number(default 5) */
2023     t_u16 tx_pert_check_num;
2024 } tx_pert_info;
2025 #endif
2026 
2027 #if CONFIG_TX_RX_HISTOGRAM
2028 typedef struct
2029 {
2030     /**  Enable or disable  */
2031     t_u8 enable;
2032     /** Choose to get TX, RX or both */
2033     t_u16 action;
2034 } txrx_histogram_info;
2035 #endif
2036 
2037 #ifdef SDIO_MULTI_PORT_TX_AGGR
2038 /** data structure for SDIO MPA TX */
2039 typedef struct _sdio_mpa_tx
2040 {
2041     /** allocated buf for tx aggreation */
2042     t_u8 *head_ptr;
2043     /** multiport tx aggregation buffer pointer */
2044     t_u8 *buf;
2045     /** multiport tx aggregation buffer length */
2046     t_u32 buf_len;
2047     /** multiport tx aggregation packet count */
2048     t_u32 pkt_cnt;
2049     /** multiport tx aggregation ports */
2050     t_u32 ports;
2051     /** multiport tx aggregation starting port */
2052     t_u16 start_port;
2053     /** multiport tx aggregation enable/disable flag */
2054     t_u8 enabled;
2055     /** multiport tx aggregation buffer size */
2056     t_u32 buf_size;
2057     /** multiport tx aggregation pkt aggr limit */
2058     t_u32 pkt_aggr_limit;
2059 } sdio_mpa_tx;
2060 #endif
2061 
2062 #ifdef SDIO_MULTI_PORT_RX_AGGR
2063 /** data structure for SDIO MPA RX */
2064 typedef struct _sdio_mpa_rx
2065 {
2066     /** allocated buf for rx aggreation */
2067     t_u8 *head_ptr;
2068     /** multiport rx aggregation buffer pointer */
2069     t_u8 *buf;
2070     /** multiport rx aggregation buffer length */
2071     t_u32 buf_len;
2072     /** multiport rx aggregation packet count */
2073     t_u32 pkt_cnt;
2074     /** multiport rx aggregation ports */
2075     t_u32 ports;
2076     /** multiport rx aggregation starting port */
2077     t_u16 start_port;
2078 
2079     /** multiport rx aggregation mbuf array */
2080     pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
2081     /** multiport rx aggregation pkt len array */
2082     t_u32 len_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
2083 
2084     /** multiport rx aggregation enable/disable flag */
2085     t_u8 enabled;
2086     /** multiport rx aggregation buffer size */
2087     t_u32 buf_size;
2088     /** multiport rx aggregation pkt aggr limit */
2089     t_u32 pkt_aggr_limit;
2090 } sdio_mpa_rx;
2091 #endif /* SDIO_MULTI_PORT_RX_AGGR */
2092 
2093 /** mlan_init_para structure */
2094 typedef struct _mlan_init_para
2095 {
2096 #ifdef WIFI_CALIB_CMD_SUPPORT
2097     /** WiFi Calibration mode */
2098     t_u32 wifi_calib_mode;
2099 #endif
2100     /** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */
2101     t_u32 int_mode;
2102     /** GPIO interrupt pin number */
2103     t_u32 gpio_pin;
2104 #ifdef SDIO_MULTI_PORT_TX_AGGR
2105     /** SDIO MPA Tx */
2106     t_u32 mpa_tx_cfg;
2107 #endif
2108 #ifdef SDIO_MULTI_PORT_RX_AGGR
2109     /** SDIO MPA Rx */
2110     t_u32 mpa_rx_cfg;
2111 #endif
2112     /** Auto deep sleep */
2113     t_u32 auto_ds;
2114     /** IEEE PS mode */
2115     t_u32 ps_mode;
2116     /** Max Tx buffer size */
2117     t_u32 max_tx_buf;
2118     /** 802.11d configuration */
2119     t_u32 cfg_11d;
2120     /** 802.11H DFS Master Radar Detect */
2121     t_u32 dfs_master_radar_det_en;
2122     /** 802.11H DFS Slave Radar Detect */
2123     t_u32 dfs_slave_radar_det_en;
2124     /** FW download CRC check flag */
2125     t_u32 fw_crc_check;
2126 } mlan_init_para, *pmlan_init_para;
2127 
2128 #define MLAN_MAX_BLACKLIST_BSSID 16
2129 
2130 /* BSSID blacklist */
2131 typedef struct
2132 {
2133     /** Number of blacklisted BSSIDs */
2134     int num_bssid;
2135     /** Blacklisted BSSIDs */
2136     mlan_802_11_mac_addr bssids[MLAN_MAX_BLACKLIST_BSSID];
2137 } mlan_blacklisted_bssid_params;
2138 
2139 #if CONFIG_FW_VDLL
2140 /** vdll_dnld_ctrl structure */
2141 typedef struct _vdll_dnld_ctrl
2142 {
2143     /**  pending  VDLL block */
2144     t_u8 *pending_block;
2145     /* pending VDLL block len */
2146     t_u16 pending_block_len;
2147     /** memory for VDLL fw image */
2148     t_u8 *vdll_mem;
2149     /**  VDLL fw image len */
2150     t_u32 vdll_len;
2151     /** cmd buffer for VDLL download */
2152     t_u8 *cmd_buf;
2153 } vdll_dnld_ctrl, *pvdll_dnld_ctrl;
2154 #endif
2155 
2156 #if CONFIG_HOST_SLEEP
2157 /* WLAN wakeup reason in detail */
2158 typedef struct
2159 {
2160     /* Rx IMU msg type */
2161     uint8_t type;
2162     /* IMU msg subtype for ctrl msg */
2163     uint8_t subtype;
2164     /* cmdresp or event id */
2165     uint16_t id;
2166 } wlan_wakeup_reason;
2167 #endif
2168 
2169 /** Adapter data structure for MLAN */
2170 struct _mlan_adapter
2171 {
2172     /** MOAL handle structure */
2173     t_void *pmoal_handle;
2174     /** Private pointer */
2175     pmlan_private priv[MLAN_MAX_BSS_NUM];
2176     /** Total number of Priv number */
2177     t_u8 priv_num;
2178     /** Firmware start addr */
2179     const t_u8 *fw_start_addr;
2180     mlan_callbacks callbacks;
2181     /** Init parameters */
2182     mlan_init_para init_para;
2183 #ifdef RW610
2184     /** bus operations*/
2185     bus_operations bus_ops;
2186 #endif
2187     /** Country ie ignore */
2188     t_u8 country_ie_ignore;
2189     /** In reset status now */
2190     t_u8 in_reset;
2191     /** IO port */
2192     t_u32 ioport;
2193     /** STATUS variables */
2194     WLAN_HARDWARE_STATUS hw_status;
2195     /** Firmware release number */
2196     t_u32 fw_release_number;
2197 
2198     /** Number of antenna used */
2199     t_u16 number_of_antenna;
2200 
2201     /** Firmware capability information */
2202     t_u32 fw_cap_info;
2203     /** Extended firmware capability information */
2204     t_u32 fw_cap_ext;
2205 #if CONFIG_FW_VDLL
2206     /** vdll ctrl */
2207     vdll_dnld_ctrl vdll_ctrl;
2208     /** VDLL operation in progress */
2209     volatile t_bool vdll_in_progress;
2210     /** Timer for vdll */
2211     OSA_TIMER_HANDLE_DEFINE(vdll_timer);
2212 #endif
2213     /** pint_lock for interrupt handling */
2214     t_void *pint_lock;
2215     /** Interrupt status */
2216     t_u8 sdio_ireg;
2217     /** SDIO multiple port read bitmap */
2218     t_u32 mp_rd_bitmap;
2219     /** SDIO multiple port write bitmap */
2220     t_u32 mp_wr_bitmap;
2221     /** SDIO end port from txbufcfg */
2222     t_u16 mp_end_port;
2223     /** SDIO port mask calculated based on txbufcfg end port */
2224     t_u32 mp_data_port_mask;
2225     /** Current available port for read */
2226     t_u8 curr_rd_port;
2227     /** Current available port for write */
2228     t_u8 curr_wr_port;
2229     /** Array to store values of SDIO multiple port group registers */
2230     t_u8 *mp_regs;
2231     /** allocated buf to read SDIO multiple port group registers */
2232     t_u8 *mp_regs_buf;
2233 
2234     /** ECSA support */
2235     bool ecsa_enable;
2236     /* Firmware support cmd_tx_data */
2237     t_u8 cmd_tx_data;
2238 
2239     /** CMD sent:
2240      *       TRUE - CMD is sent to fw, no CMD Done received
2241      *       FALSE - CMD done received for previous CMD
2242      */
2243     t_u8 cmd_sent;
2244     /** Region code */
2245     t_u16 region_code;
2246     /** Region code from HW*/
2247     t_u16 hw_region_code;
2248     /** Region Channel data */
2249     region_chan_t region_channel[MAX_REGION_CHANNEL_NUM];
2250     /** CFP table code for 2.4GHz */
2251     t_u8 cfp_code_bg;
2252     /** CFP table code for 5GHz */
2253     t_u8 cfp_code_a;
2254     /** WMM AC params */
2255     wmm_ac_parameters_t ac_params[MAX_AC_QUEUES];
2256     /** Minimum BA Threshold */
2257     t_u8 min_ba_threshold;
2258 #ifdef STA_SUPPORT
2259     /** Universal Channel data */
2260     region_chan_t universal_channel[MAX_REGION_CHANNEL_NUM];
2261     /** Parsed region channel */
2262     parsed_region_chan_11d_t parsed_region_chan;
2263 #endif /* STA_SUPPORT */
2264     /** 11D and Domain Regulatory Data */
2265     wlan_802_11d_domain_reg_t domain_reg;
2266     /** Country Code */
2267     t_u8 country_code[COUNTRY_CODE_LEN];
2268     /** FSM variable for 11h support */
2269     wlan_11h_device_state_t state_11h;
2270     /** FSM variable for DFS support */
2271     wlan_dfs_device_state_t state_dfs;
2272     /** FSM variable for RDH support */
2273     wlan_radar_det_hndlg_state_t state_rdh;
2274 #ifdef DFS_TESTING_SUPPORT
2275     /** User configured settings for DFS testing */
2276     wlan_dfs_testing_settings_t dfs_test_params;
2277 #endif
2278     /** FSM variable for MEAS support */
2279     wlan_meas_state_t state_meas;
2280     /** Scan table */
2281     BSSDescriptor_t *pscan_table;
2282     /** BSS blacklist */
2283     mlan_blacklisted_bssid_params blacklist_bss;
2284     /** scan age in secs */
2285     t_u32 age_in_secs;
2286     /** Active scan for hidden ssid triggered */
2287     t_u8 active_scan_triggered;
2288 #if CONFIG_WPA_SUPP
2289     /** WPA supplicant scan triggered */
2290     t_u8 wpa_supp_scan_triggered;
2291 #endif
2292 #if CONFIG_SCAN_CHANNEL_GAP
2293     /** channel statstics */
2294     ChanStatistics_t *pchan_stats;
2295     /** Number of records in the chan_stats */
2296     t_u32 num_in_chan_stats;
2297     /** index of chan stats */
2298     t_u32 idx_chan_stats;
2299     /** scan channel gap time */
2300     t_u16 scan_chan_gap;
2301 #endif
2302     /** Number of records in the scan table */
2303     t_u32 num_in_scan_table;
2304     /** Scan probes */
2305     t_u16 scan_probes;
2306 #if CONFIG_SCAN_WITH_RSSIFILTER
2307     /** Rssi threshold */
2308     t_s16 rssi_threshold;
2309 #endif
2310 
2311     /** Scan type */
2312     mlan_scan_type scan_type;
2313     /** Scan mode */
2314     t_u32 scan_mode;
2315     /** Specific scan time */
2316     t_u16 specific_scan_time;
2317     /** Active scan time */
2318     t_u16 active_scan_time;
2319     /** Passive scan time */
2320     t_u16 passive_scan_time;
2321 #if CONFIG_EXT_SCAN_SUPPORT
2322     /** Extended scan or legacy scan */
2323     t_u8 ext_scan;
2324 #endif
2325     /** F/W supported bands */
2326     t_u16 fw_bands;
2327     /** User selected band to start adhoc network */
2328     t_u16 adhoc_start_band;
2329     /** User selected bands */
2330     t_u16 config_bands;
2331     /** Pointer to channel list last sent to the firmware for scanning */
2332     ChanScanParamSet_t *pscan_channels;
2333 #if CONFIG_WMM_UAPSD
2334     /** Tx lock flag */
2335     t_u8 tx_lock_flag;
2336 
2337     /** sleep_params_t */
2338     sleep_params_t sleep_params;
2339     /** sleep_period_t (Enhanced Power Save) */
2340     sleep_period_t sleep_period;
2341 #endif
2342     /** Power Save state */
2343     enum wlan_ps_state ps_state;
2344     /** keep_wakeup */
2345     t_u8 keep_wakeup;
2346     /** Multiple DTIM */
2347     t_u16 multiple_dtim;
2348     /** Local listen interval */
2349     t_u16 local_listen_interval;
2350     /** Null packet interval */
2351     t_u16 null_pkt_interval;
2352 
2353     /** Beacon miss timeout */
2354     t_u16 bcn_miss_time_out;
2355 
2356     /** AdHoc awake period */
2357     t_u16 adhoc_awake_period;
2358 
2359     /** Delay to PS in milliseconds */
2360     t_u16 delay_to_ps;
2361     /** Enhanced PS mode */
2362     t_u16 enhanced_ps_mode;
2363 #if CONFIG_WMM_UAPSD
2364     /** Gen NULL pkg */
2365     t_u16 gen_null_pkt;
2366 
2367     /** PPS/UAPSD mode flag */
2368     t_u16 pps_uapsd_mode;
2369 #endif
2370 #if CONFIG_HOST_SLEEP
2371     /** Host Sleep configured flag */
2372     t_u8 is_hs_configured;
2373     /** management frame wakeup filter config */
2374     mgmt_frame_filter mgmt_filter[MAX_MGMT_FRAME_FILTER];
2375 #endif
2376     /** 802.11n device capabilities */
2377     t_u32 hw_dot_11n_dev_cap;
2378     /** Device support for MIMO abstraction of MCSs */
2379     t_u8 hw_dev_mcs_support;
2380     /** mpdu density */
2381     t_u8 hw_mpdu_density;
2382     /** 802.11n Device Capabilities for 2.4GHz */
2383     t_u32 usr_dot_11n_dev_cap_bg;
2384     /** 802.11n Device Capabilities for 5GHz */
2385     t_u32 usr_dot_11n_dev_cap_a;
2386     /** MIMO abstraction of MCSs supported by device */
2387     t_u8 usr_dev_mcs_support;
2388 #if CONFIG_WIFI_CAPA
2389     /** user configured 11n enable/disable */
2390     t_u8 usr_dot_11n_enable;
2391 #endif
2392 #ifdef STA_SUPPORT
2393     /** Enable 11n support for adhoc start */
2394     bool adhoc_11n_enabled;
2395     /** Adhoc Secondary Channel Bandwidth */
2396     t_u8 chan_bandwidth;
2397 #endif /* STA_SUPPORT */
2398 
2399     /** 802.11ac device capabilities */
2400     t_u32 hw_dot_11ac_dev_cap;
2401     /** 802.11ac device support for MIMO abstraction of MCSs */
2402     t_u32 hw_dot_11ac_mcs_support;
2403     /** tx vht_info */
2404     t_u8 tx_vhtinfo;
2405     /** rxpd_vhtinfo */
2406     t_u8 rxpd_vhtinfo;
2407 #if CONFIG_WIFI_CAPA
2408     /** user configured 11ac enable/disable */
2409     t_u8 usr_dot_11ac_enable;
2410 #endif
2411     /** 802.11ac Device Capabilities for 2.4GHz */
2412     t_u32 usr_dot_11ac_dev_cap_bg;
2413     /** 802.11ac Device Capabilities for 5GHz */
2414     t_u32 usr_dot_11ac_dev_cap_a;
2415     /** MIMO abstraction of MCSs supported by device */
2416     t_u32 usr_dot_11ac_mcs_support;
2417     /** user dot 11ac_BW */
2418     t_u8 usr_dot_11ac_bw;
2419     /** user dot 11ac_opermode_BW */
2420     t_u8 usr_dot_11ac_opermode_bw;
2421     /** user dot 11ac_opermode_nss */
2422     t_u8 usr_dot_11ac_opermode_nss;
2423 
2424 #if CONFIG_11AX
2425     /** length of hw he capability */
2426     t_u8 hw_hecap_len;
2427     /** 802.11ax HE capability */
2428     t_u8 hw_he_cap[54];
2429     /** length of hw 2.4G he capability */
2430     t_u8 hw_2g_hecap_len;
2431     /** 802.11ax 2.4G HE capability */
2432     t_u8 hw_2g_he_cap[54];
2433 #if CONFIG_WIFI_CAPA
2434     /** user configured 11ax enable/disable */
2435     t_u8 usr_dot_11ax_enable;
2436 #endif
2437 #endif
2438     /** max mgmt IE index in device */
2439     t_u16 max_mgmt_ie_index;
2440 #ifdef OTP_CHANINFO
2441     otp_region_info_t *otp_region;
2442     chan_freq_power_t *cfp_otp_bg;
2443     t_u8 *tx_power_table_bg;
2444     t_u32 tx_power_table_bg_size;
2445     t_u8 tx_power_table_bg_rows;
2446     t_u8 tx_power_table_bg_cols;
2447 #if CONFIG_5GHz_SUPPORT
2448     chan_freq_power_t *cfp_otp_a;
2449     t_u8 *tx_power_table_a;
2450     t_u32 tx_power_table_a_size;
2451     t_u8 tx_power_table_a_rows;
2452     t_u8 tx_power_table_a_cols;
2453 #endif
2454 #endif
2455 #if CONFIG_WIFI_TX_BUFF
2456     /** Tx buffer size */
2457     t_u16 tx_buffer_size;
2458 #endif
2459 #if CONFIG_WIFI_TX_PER_TRACK
2460     tx_pert_info tx_pert;
2461 #endif
2462 #if CONFIG_BG_SCAN
2463     t_u8 bgscan_reported;
2464 #endif
2465 #if CONFIG_MULTI_CHAN
2466     t_bool mc_policy;
2467 #endif
2468 #if CONFIG_WMM
2469     /* wmm buffer pool */
2470     outbuf_pool_t outbuf_pool;
2471     bool wait_txbuf;
2472 #endif
2473 #if CONFIG_HOST_SLEEP
2474     wlan_wakeup_reason wlan_wakeup;
2475 #endif
2476     bool skip_dfs;
2477     /* remain on channel flag */
2478     t_u8 remain_on_channel;
2479     t_u8 remain_bss_index;
2480 };
2481 
2482 /** Ethernet packet type for EAPOL */
2483 #define MLAN_ETHER_PKT_TYPE_EAPOL (0x888E)
2484 /** Ethernet packet type for WAPI */
2485 #define MLAN_ETHER_PKT_TYPE_WAPI (0x88B4)
2486 /** Ethernet packet type for ARP */
2487 #define MLAN_ETHER_PKT_TYPE_ARP (0x0806)
2488 /** Ethernet packet type for ARP */
2489 #define MLAN_ETHER_PKT_TYPE_IPV6 (0x86dd)
2490 /** Ethernet packet type offset */
2491 #define MLAN_ETHER_PKT_TYPE_OFFSET (12)
2492 
2493 #define MLAN_ETHER_PKT_DHCP_MAGIC_COOKIE        0x63825363UL
2494 #define MLAN_ETHER_PKT_DHCP_MAGIC_COOKIE_OFFSET 278
2495 
2496 mlan_status wlan_cmd_get_tsf(pmlan_private pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_u16 cmd_action);
2497 
2498 #if (CONFIG_WIFI_TX_PER_TRACK) || (CONFIG_TX_RX_HISTOGRAM)
2499 mlan_status wlan_cmd_txrx_pkt_stats(pmlan_private pmpriv,
2500                                     IN HostCmd_DS_COMMAND *cmd,
2501                                     IN t_u16 cmd_action,
2502                                     IN t_void *pdata_buf);
2503 #endif
2504 
2505 #if CONFIG_WIFI_TX_PER_TRACK
2506 mlan_status wlan_cmd_tx_pert(pmlan_private pmpriv,
2507                              IN HostCmd_DS_COMMAND *cmd,
2508                              IN t_u16 cmd_action,
2509                              IN t_void *pdata_buf);
2510 #endif
2511 
2512 #if CONFIG_TX_RX_HISTOGRAM
2513 mlan_status wlan_cmd_txrx_histogram(pmlan_private pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_void *pdata_buf);
2514 #endif
2515 
2516 mlan_status wlan_init_lock_list(IN pmlan_adapter pmadapter);
2517 
2518 /** Initialize firmware */
2519 mlan_status wlan_init_fw(IN pmlan_adapter pmadapter);
2520 
2521 /** Initialize mlan_adapter structure */
2522 t_void wlan_init_adapter(IN pmlan_adapter pmadapter);
2523 
2524 /** Initialize mlan_private structure */
2525 mlan_status wlan_init_priv(IN pmlan_private priv);
2526 
2527 /** Prepare command */
2528 mlan_status wlan_prepare_cmd(IN mlan_private *pmpriv,
2529                              IN t_u16 cmd_no,
2530                              IN t_u16 cmd_action,
2531                              IN t_u32 cmd_oid,
2532                              IN t_void *pioctl_buf,
2533                              IN t_void *pdata_buf);
2534 
2535 void wlan_clear_scan_bss(void);
2536 /** Allocate memory for adapter structure members */
2537 mlan_status wlan_allocate_adapter(pmlan_adapter pmadapter);
2538 /** Free adapter */
2539 t_void wlan_free_adapter(pmlan_adapter pmadapter);
2540 /** Handle received packet, has extra handling for aggregate packets */
2541 mlan_status wlan_handle_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
2542 /** Transmit a null data packet */
2543 mlan_status wlan_send_null_packet(pmlan_private priv, t_u8 flags);
2544 
2545 #if defined(SDIO_MULTI_PORT_TX_AGGR) || defined(SDIO_MULTI_PORT_RX_AGGR)
2546 mlan_status wlan_alloc_sdio_mpa_buffers(IN mlan_adapter *pmadapter, t_u32 mpa_tx_buf_size, t_u32 mpa_rx_buf_size);
2547 
2548 mlan_status wlan_free_sdio_mpa_buffers(IN mlan_adapter *pmadapter);
2549 #endif
2550 
2551 /** Clean Tx Rx queues */
2552 t_void wlan_clean_txrx(pmlan_private priv);
2553 
2554 /** function to allocate a mlan_buffer */
2555 pmlan_buffer wlan_alloc_mlan_buffer(mlan_adapter *pmadapter, t_u32 data_len, t_u32 head_room, t_u32 malloc_flag);
2556 /** function to free a mlan_buffer */
2557 t_void wlan_free_mlan_buffer(mlan_adapter *pmadapter, pmlan_buffer pmbuf);
2558 
2559 /** handle command for enhanced power save mode */
2560 mlan_status wlan_cmd_enh_power_mode(pmlan_private pmpriv,
2561                                     IN HostCmd_DS_COMMAND *cmd,
2562                                     IN ENH_PS_MODES cmd_action,
2563                                     IN t_u16 ps_bitmap,
2564                                     IN t_void *pdata_buf);
2565 
2566 mlan_status wlan_process_802dot11_mgmt_pkt(mlan_private *priv, t_u8 *payload, t_u32 payload_len, RxPD *rxpd);
2567 
2568 mlan_status wlan_bypass_802dot11_mgmt_pkt(void *data);
2569 
2570 mlan_status wlan_cmd_remain_on_channel(IN pmlan_private pmpriv,
2571                                        IN HostCmd_DS_COMMAND *cmd,
2572                                        IN t_u16 cmd_action,
2573                                        IN t_void *pdata_buf);
2574 
2575 #ifdef WIFI_DIRECT_SUPPORT
2576 mlan_status wlan_bss_ioctl_wifi_direct_mode(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2577 
2578 mlan_status wlan_cmd_wifi_direct_mode(IN pmlan_private pmpriv,
2579                                       IN HostCmd_DS_COMMAND *cmd,
2580                                       IN t_u16 cmd_action,
2581                                       IN t_void *pdata_buf);
2582 mlan_status wlan_ret_wifi_direct_mode(IN pmlan_private pmpriv,
2583                                       IN HostCmd_DS_COMMAND *resp,
2584                                       IN mlan_ioctl_req *pioctl_buf);
2585 
2586 mlan_status wlan_radio_ioctl_remain_chan_cfg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2587 mlan_status wlan_ret_remain_on_channel(IN pmlan_private pmpriv,
2588                                        IN HostCmd_DS_COMMAND *resp,
2589                                        IN mlan_ioctl_req *pioctl_buf);
2590 #endif
2591 
2592 mlan_status wlan_cmd_tx_rate_cfg(IN pmlan_private pmpriv,
2593                                  IN HostCmd_DS_COMMAND *cmd,
2594                                  IN t_u16 cmd_action,
2595                                  IN t_void *pdata_buf,
2596                                  IN mlan_ioctl_req *pioctl_buf);
2597 mlan_status wlan_ret_tx_rate_cfg(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN void *pioctl);
2598 
2599 mlan_status wlan_rate_ioctl_cfg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2600 mlan_status wlan_ret_802_11_tx_rate_query(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN void *pioctl);
2601 #if (CONFIG_BG_SCAN)
2602 /** Handler for bgscan query commands */
2603 mlan_status wlan_cmd_802_11_bg_scan_query(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_u16 cmd_action);
2604 /** Handler for bgscan config command */
2605 mlan_status wlan_cmd_bgscan_config(IN mlan_private *pmpriv,
2606                                    IN HostCmd_DS_COMMAND *cmd,
2607                                    IN t_u16 cmd_action,
2608                                    IN t_void *pdata_buf);
2609 /** Hander for bgscan config command response */
2610 mlan_status wlan_ret_bgscan_config(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *resp, IN mlan_ioctl_req *pioctl_buf);
2611 #endif
2612 
2613 #if (CONFIG_ROAMING) || (CONFIG_SUBSCRIBE_EVENT_SUPPORT)
2614 /** Handler for subscribe event command */
2615 mlan_status wlan_cmd_subscribe_event(IN mlan_private *pmpriv,
2616                                      IN HostCmd_DS_COMMAND *cmd,
2617                                      IN t_u16 cmd_action,
2618                                      IN t_void *pioctl_buf);
2619 int wlan_parse_getdata(HostCmd_DS_COMMAND *resp, mlan_ds_subscribe_evt *sub_evt);
2620 #endif
2621 
2622 /** Handler to get current operating class */
2623 /* For several features, such as DPP and MBO, we need the global operating class. */
2624 mlan_status wlan_get_global_nonglobal_oper_class(
2625     mlan_private *pmpriv, t_u8 channel, t_u8 bw, t_u8 *oper_class, t_u8 *global_op_class);
2626 
2627 #define wlan_get_curr_oper_class(pmpriv, channel, bw, oper_class) \
2628     wlan_get_global_nonglobal_oper_class(pmpriv, channel, bw, oper_class, MNULL)
2629 #define wlan_get_curr_global_oper_class(pmpriv, channel, bw, oper_class) \
2630     wlan_get_global_nonglobal_oper_class(pmpriv, channel, bw, MNULL, oper_class)
2631 
2632 /** Handler to add supported operating class IE */
2633 int wlan_add_supported_oper_class_ie(mlan_private *pmpriv, t_u8 **pptlv_out, t_u8 curr_oper_class);
2634 
2635 #if defined(STA_SUPPORT) || defined(UAP_SUPPORT)
2636 /** rx handler for station/uap mode */
2637 mlan_status wlan_ops_process_rx_packet(IN t_void *adapter, IN pmlan_buffer pmbuf);
2638 /** Process received packet */
2639 mlan_status wlan_process_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
2640 #endif
2641 #ifdef STA_SUPPORT
2642 /** ioctl handler for station mode */
2643 mlan_status wlan_ops_sta_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req);
2644 
2645 /** cmd handler for station mode */
2646 mlan_status wlan_ops_sta_prepare_cmd(IN t_void *priv,
2647                                      IN t_u16 cmd_no,
2648                                      IN t_u16 cmd_action,
2649                                      IN t_u32 cmd_oid,
2650                                      IN t_void *pioctl_buf,
2651                                      IN t_void *pdata_buf,
2652                                      IN t_void *pcmd_buf);
2653 
2654 /** cmdresp handler for station mode */
2655 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);
2656 
2657 /** Scan for networks */
2658 mlan_status wlan_scan_networks(IN mlan_private *pmpriv,
2659                                IN t_void *pioctl_buf,
2660                                IN const wlan_user_scan_cfg *puser_scan_in);
2661 
2662 /** Scan command handler */
2663 mlan_status wlan_cmd_802_11_scan(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *pcmd, IN t_void *pdata_buf);
2664 
2665 /** Handler for scan command response */
2666 mlan_status wlan_ret_802_11_scan(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2667 
2668 #if CONFIG_EXT_SCAN_SUPPORT
2669 /** Extended scan command handler */
2670 mlan_status wlan_cmd_802_11_scan_ext(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *pcmd, IN t_void *pdata_buf);
2671 /** Handler for extended scan command response */
2672 mlan_status wlan_ret_802_11_scan_ext(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2673 /** Handler event for extended scan report */
2674 mlan_status wlan_handle_event_ext_scan_report(IN mlan_private *pmpriv, IN t_u8 *pmbuf);
2675 #endif
2676 
2677 /** check network compatibility */
2678 t_s32 wlan_is_network_compatible(IN mlan_private *pmpriv, IN t_u32 index, IN mlan_bss_mode mode);
2679 
2680 /** Find an SSID in a list */
2681 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);
2682 
2683 /** Find a BSSID in a list */
2684 t_s32 wlan_find_bssid_in_list(IN mlan_private *pmpriv, IN const t_u8 *bssid, IN mlan_bss_mode mode);
2685 
2686 /** Compare two SSIDs */
2687 t_s32 wlan_ssid_cmp(IN pmlan_adapter pmadapter, IN mlan_802_11_ssid *ssid1, IN mlan_802_11_ssid *ssid2);
2688 
2689 /** Associate */
2690 mlan_status wlan_associate(IN mlan_private *pmpriv, IN t_void *pioctl_buf, IN BSSDescriptor_t *pbss_desc);
2691 
2692 /** Associate command handler */
2693 mlan_status wlan_cmd_802_11_associate(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *cmd, IN t_void *pdata_buf);
2694 
2695 /** Handler for association command response */
2696 mlan_status wlan_ret_802_11_associate(IN mlan_private *pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2697 
2698 /** Reset connected state */
2699 t_void wlan_reset_connect_state(IN pmlan_private priv, IN t_u8 drv_disconnect);
2700 
2701 t_void wlan_handle_disconnect_event(pmlan_private pmpriv);
2702 
2703 mlan_status wlan_ret_802_11_deauthenticate(IN pmlan_private pmpriv,
2704                                            IN HostCmd_DS_COMMAND *resp,
2705                                            IN mlan_ioctl_req *pioctl_buf);
2706 
2707 /** convert band to radio type */
2708 t_u8 wlan_band_to_radio_type(IN t_u8 band);
2709 
2710 /** Disconnect */
2711 /* Temporary disable prototype. Same name function present in wmsdk */
2712 /* mlan_status wlan_disconnect(IN mlan_private * pmpriv, */
2713 /*                             IN mlan_ioctl_req * pioctl_req, */
2714 /*                             IN mlan_802_11_mac_addr * mac); */
2715 
2716 /** Get Channel-Frequency-Power by band and channel */
2717 const chan_freq_power_t *wlan_get_cfp_by_band_and_channel(pmlan_adapter pmadapter,
2718                                                           t_u16 band,
2719                                                           t_u16 channel,
2720                                                           region_chan_t *region_channel);
2721 /** Find Channel-Frequency-Power by band and channel */
2722 const chan_freq_power_t *wlan_find_cfp_by_band_and_channel(mlan_adapter *pmadapter, t_u16 band, t_u16 channel);
2723 /** Find Channel-Frequency-Power by band and frequency */
2724 const chan_freq_power_t *wlan_find_cfp_by_band_and_freq(mlan_adapter *pmadapter, t_u16 band, t_u32 freq);
2725 /** Get Tx power of channel from Channel-Frequency-Power */
2726 t_u8 wlan_get_txpwr_of_chan_from_cfp(mlan_private *pmpriv, t_u8 channel);
2727 
2728 #endif /* STA_SUPPORT */
2729 
2730 /* Rate related functions */
2731 /** Convert index into data rate */
2732 #ifdef SD8801
2733 t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter, t_u8 index, t_u8 ht_info);
2734 #else
2735 t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter,
2736                               t_u8 index,
2737                               t_u8 tx_rate_info
2738 #if CONFIG_11AX
2739                               ,
2740                               t_u8 ext_rate_info
2741 #endif
2742 );
2743 #endif
2744 /** Get active data rates */
2745 t_u32 wlan_get_active_data_rates(mlan_private *pmpriv,
2746                                  mlan_bss_mode bss_mode,
2747                                  t_u16 config_bands,
2748                                  WLAN_802_11_RATES rates);
2749 /** Get supported data rates */
2750 t_u32 wlan_get_supported_rates(mlan_private *pmpriv,
2751                                mlan_bss_mode bss_mode,
2752                                t_u16 config_bands,
2753                                WLAN_802_11_RATES rates);
2754 /** Check if rate is auto */
2755 bool wlan_is_rate_auto(mlan_private *pmpriv);
2756 /** Get rate index */
2757 int wlan_get_rate_index(pmlan_adapter pmadapter, t_u16 *rate_bitmap, int size);
2758 
2759 /* CFP related functions */
2760 /** Region code index table */
2761 extern t_u16 region_code_index[MRVDRV_MAX_REGION_CODE];
2762 
2763 /** The table to keep CFP code for A */
2764 extern t_u16 cfp_code_index_a[MRVDRV_MAX_CFP_CODE_A];
2765 /** Get region cfp table*/
2766 const chan_freq_power_t *wlan_get_region_cfp_table(pmlan_adapter pmadapter, t_u8 region, t_u16 band, int *cfp_no);
2767 /** Set region table */
2768 mlan_status wlan_set_regiontable(mlan_private *pmpriv, t_u8 region, t_u16 band);
2769 /** Get radar detection requirements*/
2770 t_bool wlan_get_cfp_radar_detect(mlan_private *priv, t_u8 chnl);
2771 /** check if scan type is passive for b/g band*/
2772 t_bool wlan_bg_scan_type_is_passive(mlan_private *priv, t_u8 chnl);
2773 t_u8 wlan_convert_v14_rate_ht_info(t_u8 ht_info);
2774 /** Check if channel number is valid */
2775 t_bool wlan_is_channel_valid(t_u8 chan_num);
2776 /** Check if radio mode number is valid */
2777 t_bool wlan_is_radio_mode_valid(t_u8 mode);
2778 /** Check if channel number and its frequency is valid */
2779 t_bool wlan_is_channel_and_freq_valid(mlan_adapter *pmadapter, t_u8 chan_num, t_u16 chan_freq);
2780 /** Set Custom CFP Table */
2781 #if CONFIG_5GHz_SUPPORT
2782 mlan_status wlan_set_custom_cfp_table(wifi_chanlist_t *chanlist, t_u8 *cfp_no_bg, t_u8 *cfp_no_a);
2783 void wlan_set_custom_regiontable(mlan_private *pmpriv, t_u8 cfp_no_bg, t_u8 cfp_no_a);
2784 #else
2785 mlan_status wlan_set_custom_cfp_table(wifi_chanlist_t *chanlist, t_u8 *cfp_no_bg);
2786 void wlan_set_custom_regiontable(mlan_private *pmpriv, t_u8 cfp_no_bg);
2787 #endif
2788 /** Get the list of active channels */
2789 void wlan_get_active_channel_list(mlan_private *pmpriv, t_u8 *chan_list, t_u8 *num_chans, t_u16 acs_band);
2790 
2791 /* 802.11D related functions */
2792 /** Initialize 11D */
2793 t_void wlan_11d_priv_init(mlan_private *pmpriv);
2794 /** Initialize 11D */
2795 t_void wlan_11d_init(mlan_adapter *pmadapter);
2796 /** Enable 11D support */
2797 t_u16 wlan_enable_11d_support(mlan_private *pmpriv);
2798 t_u16 wlan_11d_support_APIs(mlan_private *pmpriv);
2799 /** Get if 11D support is enabled */
2800 t_bool wlan_11d_support_is_enabled(mlan_private *pmpriv);
2801 /** Get if 11D is enabled */
2802 t_bool wlan_11d_is_enabled(mlan_private *pmpriv);
2803 /** 11D Region code to country code string */
2804 const t_u8 *wlan_11d_code_2_region(pmlan_adapter pmadapter, t_u8 code);
2805 /**converts region string to integer code*/
2806 mlan_status wlan_11d_region_2_code(pmlan_adapter pmadapter, t_u8 *region, OUT t_u8 *code);
2807 /** Store 11D domain info */
2808 mlan_status wlan_11d_set_domain_info(mlan_private *pmpriv,
2809                                      t_u16 band,
2810                                      const t_u8 country_code[COUNTRY_CODE_LEN],
2811                                      t_u8 num_sub_band,
2812                                      IEEEtypes_SubbandSet_t *sub_band_list);
2813 
2814 /** Get if priv is station */
2815 t_bool wlan_is_station(mlan_private *pmpriv);
2816 /** Command handler for 11D country info */
2817 mlan_status wlan_cmd_802_11d_domain_info(mlan_private *pmpriv, HostCmd_DS_COMMAND *pcmd, t_u16 cmd_action);
2818 #ifdef STA_SUPPORT
2819 /** Convert channel to frequency */
2820 t_u32 wlan_11d_chan_2_freq(pmlan_adapter pmadapter, t_u8 chan, t_u16 band);
2821 /** Set 11D universal table */
2822 mlan_status wlan_11d_set_universaltable(mlan_private *pmpriv, t_u16 band);
2823 /** Clear 11D region table */
2824 mlan_status wlan_11d_clear_parsedtable(mlan_private *pmpriv);
2825 /** Create 11D country information for downloading */
2826 mlan_status wlan_11d_create_dnld_countryinfo(mlan_private *pmpriv, t_u16 band);
2827 /** Get scan type from 11D info */
2828 mlan_scan_type wlan_11d_get_scan_type(mlan_private *pmpriv,
2829                                       t_u16 band,
2830                                       t_u8 chan,
2831                                       parsed_region_chan_11d_t *parsed_region_chan);
2832 /** Parse 11D country info */
2833 mlan_status wlan_11d_parse_dnld_countryinfo(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc);
2834 /** Prepare 11D domain information for download */
2835 mlan_status wlan_11d_prepare_dnld_domain_info_cmd(mlan_private *pmpriv);
2836 /** Parse 11D country information into domain info */
2837 mlan_status wlan_11d_parse_domain_info(pmlan_adapter pmadapter,
2838                                        IEEEtypes_CountryInfoFullSet_t *country_info,
2839                                        t_u16 band,
2840                                        parsed_region_chan_11d_t *parsed_region_chan);
2841 /** Configure 11D domain info command */
2842 mlan_status wlan_11d_cfg_domain_info(IN pmlan_adapter pmadapter, IN mlan_ioctl_req *pioctl_req);
2843 
2844 mlan_status wlan_11d_cfg_ioctl(IN mlan_private *pmpriv, IN pmlan_ioctl_req pioctl_req);
2845 #endif /* STA_SUPPORT */
2846 #ifdef UAP_SUPPORT
2847 /** Handle 11D domain information from UAP */
2848 mlan_status wlan_11d_handle_uap_domain_info(mlan_private *pmpriv, t_u16 band, t_u8 *domain_tlv, t_void *pioctl_buf);
2849 #endif
2850 
2851 /** This function converts region string to CFP table code */
2852 mlan_status wlan_misc_country_2_cfp_table_code(IN pmlan_adapter pmadapter,
2853                                                IN t_u8 *country_code,
2854                                                OUT t_u8 *cfp_bg,
2855                                                OUT t_u8 *cfp_a);
2856 /** check if station list is empty */
2857 t_u8 wlan_is_station_list_empty(mlan_private *priv);
2858 /** get station node */
2859 sta_node *wlan_get_station_entry(mlan_private *priv, t_u8 *mac);
2860 /** delete station list */
2861 t_void wlan_delete_station_list(pmlan_private priv);
2862 /** delete station entry */
2863 t_void wlan_delete_station_entry(mlan_private *priv, t_u8 *mac);
2864 /** add station entry */
2865 sta_node *wlan_add_station_entry(mlan_private *priv, t_u8 *mac);
2866 /** process uap rx packet */
2867 
2868 void wlan_check_sta_capability(pmlan_private priv, pmlan_buffer pevent, sta_node *sta_ptr);
2869 
2870 #if CONFIG_RF_TEST_MODE
2871 mlan_status wlan_ret_mfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, void *pioctl_buf);
2872 mlan_status wlan_misc_ioctl_rf_test_cfg(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
2873 #endif
2874 
2875 #if CONFIG_11R
2876 t_u8 wlan_ft_akm_is_used(mlan_private *pmpriv, t_u8 *rsn_ie);
2877 #endif
2878 
2879 /** find specific ie */
2880 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);
2881 
2882 /**
2883  *  @brief This function checks tx_pause flag for peer
2884  *
2885  *  @param priv     A pointer to mlan_private
2886  *  @param ra       Address of the receiver STA
2887  *
2888  *  @return 	    MTRUE or MFALSE
2889  */
2890 INLINE
2891 static int wlan_is_tx_pause(mlan_private *priv, t_u8 *ra)
2892 {
2893     sta_node *sta_ptr = MNULL;
2894     sta_ptr           = wlan_get_station_entry(priv, ra);
2895     if (sta_ptr != MNULL)
2896     {
2897         return sta_ptr->tx_pause;
2898     }
2899     return MFALSE;
2900 }
2901 
2902 t_bool wlan_check_channel_by_region_table(mlan_private *pmpriv, t_u8 chan_num);
2903 
2904 mlan_status wlan_cmd_get_hw_spec(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *pcmd);
2905 mlan_status wlan_ret_get_hw_spec(IN pmlan_private pmpriv, IN HostCmd_DS_COMMAND *resp, IN t_void *pioctl_buf);
2906 
2907 mlan_status wlan_cmd_802_11_rf_antenna(IN pmlan_private pmpriv,
2908                                        IN HostCmd_DS_COMMAND *cmd,
2909                                        IN t_u16 cmd_action,
2910                                        IN t_void *pdata_buf);
2911 #if CONFIG_NET_MONITOR
2912 mlan_status wlan_cmd_802_11_net_monitor(IN pmlan_private pmpriv,
2913                                         IN HostCmd_DS_COMMAND *cmd,
2914                                         IN t_u16 cmd_action,
2915                                         IN t_void *pdata_buf);
2916 #endif
2917 
2918 #ifdef DEBUG_LEVEL1
2919 mlan_status wlan_set_drvdbg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2920 #endif
2921 
2922 void wlan_add_ext_capa_info_ie(IN mlan_private *pmpriv, IN BSSDescriptor_t *pbss_desc, OUT t_u8 **pptlv_out);
2923 
2924 #ifdef WLAN_LOW_POWER_ENABLE
2925 mlan_status wlan_misc_ioctl_low_pwr_mode(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2926 #endif // WLAN_LOW_POWER_ENABLE
2927 
2928 #ifdef OTP_CHANINFO
2929 mlan_status wlan_ret_chan_region_cfg(IN pmlan_private pmpriv,
2930                                      IN HostCmd_DS_COMMAND *resp,
2931                                      IN mlan_ioctl_req *pioctl_buf);
2932 
2933 void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left);
2934 
2935 void wlan_free_fw_cfp_tables(mlan_adapter *pmadapter);
2936 
2937 // mlan_status wlan_misc_chan_reg_cfg(IN pmlan_adapter pmadapter, IN pmlan_ioctl_req pioctl_req);
2938 #endif
2939 
2940 #if CONFIG_COMPRESS_TX_PWTBL
2941 mlan_status wlan_cmd_region_power_cfg(pmlan_private pmpriv,
2942                                       HostCmd_DS_COMMAND *cmd,
2943                                       t_u16 cmd_action,
2944                                       t_void *pdata_buf);
2945 #endif
2946 
2947 #if CONFIG_WIFI_CLOCKSYNC
2948 mlan_status wlan_cmd_gpio_tsf_latch(
2949     pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, mlan_ioctl_req *pioctl_buf, t_void *pdata_buf);
2950 mlan_status wlan_ret_gpio_tsf_latch(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
2951 mlan_status wlan_misc_gpio_tsf_latch_config(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
2952 mlan_status wlan_misc_get_tsf_info(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
2953 #endif /* CONFIG_WIFI_CLOCKSYNC */
2954 #if CONFIG_MULTI_CHAN
2955 mlan_status wlan_cmd_multi_chan_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2956 
2957 mlan_status wlan_ret_multi_chan_cfg(pmlan_private pmpriv, const HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
2958 
2959 mlan_status wlan_cmd_multi_chan_policy(pmlan_private pmpriv,
2960                                        HostCmd_DS_COMMAND *cmd,
2961                                        t_u16 cmd_action,
2962                                        t_void *pdata_buf);
2963 
2964 mlan_status wlan_ret_multi_chan_policy(pmlan_private pmpriv,
2965                                        const HostCmd_DS_COMMAND *resp,
2966                                        mlan_ioctl_req *pioctl_buf);
2967 
2968 mlan_status wlan_cmd_drcs_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2969 
2970 mlan_status wlan_ret_drcs_cfg(pmlan_private pmpriv, const HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
2971 
2972 #endif
2973 
2974 mlan_status wlan_cmd_tx_frame(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2975 
2976 #if CONFIG_ECSA
2977 mlan_status wlan_misc_ioctl_operclass_validation(pmlan_adapter pmadapter, mlan_ioctl_req *pioctl_req);
2978 mlan_status wlan_misc_ioctl_oper_class(pmlan_adapter pmadapter, mlan_ioctl_req *pioctl_req);
2979 mlan_status wlan_check_operclass_validation(mlan_private *pmpriv, t_u8 channel, t_u8 oper_class);
2980 #endif
2981 
2982 #if CONFIG_RX_ABORT_CFG
2983 mlan_status wlan_cmd_rx_abort_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
2984 #endif
2985 
2986 #if CONFIG_RX_ABORT_CFG_EXT
2987 mlan_status wlan_cmd_rx_abort_cfg_ext(pmlan_private pmpriv,
2988                                       HostCmd_DS_COMMAND *cmd,
2989                                       t_u16 cmd_action,
2990                                       t_void *pdata_buf);
2991 #endif
2992 
2993 #if CONFIG_CCK_DESENSE_CFG
2994 mlan_status wlan_cmd_cck_desense_cfg(pmlan_private pmpriv,
2995                                      HostCmd_DS_COMMAND *cmd,
2996                                      t_u16 cmd_action,
2997                                      t_void *pdata_buf);
2998 #endif
2999 
3000 #define BW_20MHZ 0
3001 #define BW_40MHZ 1
3002 #define BW_80MHZ 2
3003 
3004 #if CONFIG_TURBO_MODE
3005 int wlan_get_set_turbo_mode(t_u16 action, t_u8 *mode, mlan_bss_type bss_type);
3006 #endif
3007 
3008 #if CONFIG_1AS
3009 mlan_status wlan_cmd_host_clock_cfg(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
3010 mlan_status wlan_ret_host_clock_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3011 #endif
3012 
3013 /**
3014  *  @brief RA based queueing
3015  *
3016  *  @param priv                 A pointer to mlan_private structure
3017  *
3018  *  @return 	   	        MTRUE or MFALSE
3019  */
3020 INLINE
3021 static t_u8 queuing_ra_based(pmlan_private priv)
3022 {
3023     /*
3024      * Currently we assume if we are in Infra, then DA=RA. This might not be
3025      * true in the future
3026      */
3027     if ((priv->bss_mode == MLAN_BSS_MODE_INFRA) && (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA))
3028     {
3029         return MFALSE;
3030     }
3031 
3032     return MTRUE;
3033 }
3034 
3035 /**
3036  *  @brief Copy Rates
3037  *
3038  *  @param dest                 A pointer to Dest Buf
3039  *  @param pos		        The position for copy
3040  *  @param src		        A pointer to Src Buf
3041  *  @param len                  The len of Src Buf
3042  *
3043  *  @return 	   	        Number of Rates copied
3044  */
3045 INLINE
3046 static t_u32 wlan_copy_rates(t_u8 *dest, t_u32 pos, t_u8 *src, int len)
3047 {
3048     int i;
3049 
3050     for (i = 0; i < len && src[i]; i++)
3051     {
3052         if (pos >= sizeof(WLAN_802_11_RATES))
3053         {
3054             break;
3055         }
3056         dest[pos] = src[i];
3057         pos++;
3058     }
3059 
3060     return pos;
3061 }
3062 
3063 /**
3064  *  @brief strlen
3065  *
3066  *  @param str		        A pointer to string
3067  *
3068  *  @return 	   	        Length of string
3069  */
3070 INLINE
3071 static t_u32 wlan_strlen(const t_s8 *str)
3072 {
3073     t_u32 i;
3074 
3075     for (i = 0; str[i] != '\0'; i++)
3076     {
3077     }
3078     return i;
3079 }
3080 
3081 /**
3082  *  @brief iscdigit
3083  *
3084  *  @param chr                  A char
3085  *
3086  *  @return                     Non zero if chr is a hex, else 0
3087  */
3088 INLINE
3089 static t_u32 wlan_isxdigit(t_u8 chr)
3090 {
3091     return ((chr <= 'f' && chr >= 'a') || (chr <= 'F' && chr >= 'A') || (chr <= '9' && chr >= '0'));
3092 }
3093 
3094 /**
3095  *  @brief isspace
3096  *
3097  *  @param                       A chr
3098  *
3099  *  @return                      Non zero if chr is space etc, else 0
3100  */
3101 INLINE
3102 static t_u32 wlan_isspace(t_u8 chr)
3103 {
3104     return (chr <= ' ' && (chr == ' ' || (chr <= 13 && chr >= 9)));
3105 }
3106 
3107 /** delay unit */
3108 typedef enum _delay_unit
3109 {
3110     USEC,
3111     MSEC,
3112     SEC,
3113 } t_delay_unit;
3114 
3115 /** delay function wrapper */
3116 #define wlan_delay(p, n) wlan_delay_func(p, n, SEC)
3117 /** delay function wrapper */
3118 #define wlan_mdelay(p, n) wlan_delay_func(p, n, MSEC)
3119 /** delay function wrapper */
3120 #define wlan_udelay(p, n) wlan_delay_func(p, n, USEC)
3121 
3122 /** Function to check if any command is pending in the queue */
3123 #define IS_COMMAND_PENDING(pmadapter)                                                    \
3124     ((cmd_ctrl_node *)util_peek_list(pmadapter->pmoal_handle, &pmadapter->cmd_pending_q, \
3125                                      pmadapter->callbacks.moal_spin_lock, pmadapter->callbacks.moal_spin_unlock))
3126 
3127 /** Get BSS number from priv */
3128 #define GET_BSS_NUM(priv) (priv)->bss_num
3129 /**
3130  *  @brief This function returns priv based on the BSS num and BSS type
3131  *
3132  *  @param pmadapter A pointer to mlan_adapter
3133  *  @param bss_num   BSS number
3134  *  @param bss_type  BSS type
3135  *
3136  *  @return          Pointer to mlan_private
3137  */
3138 INLINE
3139 static mlan_private *wlan_get_priv_by_id(mlan_adapter *pmadapter, t_u32 bss_num, t_u32 bss_type)
3140 {
3141     int i;
3142 
3143     for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++)
3144     {
3145         if (pmadapter->priv[i] != MNULL)
3146         {
3147             if ((pmadapter->priv[i]->bss_num == bss_num) && (pmadapter->priv[i]->bss_type == bss_type))
3148             {
3149                 return (pmadapter->priv[i]);
3150             }
3151         }
3152     }
3153     return MNULL;
3154 }
3155 
3156 /**
3157  *  @brief This function returns first available priv
3158  *  based on the BSS role
3159  *
3160  *  @param pmadapter A pointer to mlan_adapter
3161  *  @param bss_role  BSS role or MLAN_BSS_ROLE_ANY
3162  *
3163  *  @return          Pointer to mlan_private
3164  */
3165 INLINE
3166 static mlan_private *wlan_get_priv(mlan_adapter *pmadapter, mlan_bss_role bss_role)
3167 {
3168     int i;
3169 
3170     for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++)
3171     {
3172         if (pmadapter->priv[i] != MNULL)
3173         {
3174             if (bss_role == MLAN_BSS_ROLE_ANY || GET_BSS_ROLE(pmadapter->priv[i]) == bss_role)
3175             {
3176                 return (pmadapter->priv[i]);
3177             }
3178         }
3179     }
3180     return MNULL;
3181 }
3182 
3183 /**
3184  *  @brief This function counts the number of occurences for a certain
3185  *  condition among privs.  Which privs are checked can be configured
3186  *  via a second condition.
3187  *
3188  *  @param pmadapter  A pointer to mlan_adapter
3189  *  @param count_cond Function pointer to condition to count on privs
3190  *  @param check_cond Function pointer to condition to decide whether priv
3191  *                    should be counted or not.  Use MNULL to check all privs.
3192  *
3193  *  @return          Count of privs where count_cond returned MTRUE.
3194  */
3195 INLINE
3196 static int wlan_count_priv_cond(mlan_adapter *pmadapter,
3197                                 t_bool (*count_cond)(IN pmlan_private pmpriv),
3198                                 t_bool (*check_cond)(IN pmlan_private pmpriv))
3199 {
3200     pmlan_private pmpriv;
3201     int count = 0;
3202     t_u8 i;
3203 
3204     if (pmadapter == MNULL || count_cond == MNULL)
3205     {
3206         return 0;
3207     }
3208 
3209     for (i = 0; i < pmadapter->priv_num; i++)
3210     {
3211         pmpriv = pmadapter->priv[i];
3212         if (pmpriv != MNULL)
3213         {
3214             if ((check_cond == MNULL) || check_cond(pmpriv))
3215             {
3216                 if (count_cond(pmpriv))
3217                 {
3218                     count++;
3219                 }
3220             }
3221         }
3222     }
3223 
3224     return count;
3225 }
3226 
3227 /**
3228  *  @brief This function runs a procedure on each priv.
3229  *  Which privs it is run on can be configured via a condition.
3230  *
3231  *  @param pmadapter  A pointer to mlan_adapter
3232  *  @param operation  Function pointer to produedure to operate on priv
3233  *  @param check_cond Function pointer to condition to decide whether priv
3234  *                    operated on or not.  Use MNULL to run on all privs.
3235  *
3236  *  @return           Number of privs that operation was run on.
3237  */
3238 INLINE
3239 static int wlan_do_task_on_privs(mlan_adapter *pmadapter,
3240                                  t_void (*operation)(IN pmlan_private pmpriv),
3241                                  t_bool (*check_cond)(IN pmlan_private pmpriv))
3242 {
3243     pmlan_private pmpriv;
3244     int count = 0;
3245     t_u8 i;
3246 
3247     if (pmadapter == MNULL || operation == MNULL)
3248     {
3249         return 0;
3250     }
3251 
3252     for (i = 0; i < pmadapter->priv_num; i++)
3253     {
3254         pmpriv = pmadapter->priv[i];
3255         if (pmpriv != MNULL)
3256         {
3257             if ((check_cond == MNULL) || check_cond(pmpriv))
3258             {
3259                 operation(pmpriv);
3260                 count++;
3261             }
3262         }
3263     }
3264 
3265     return count;
3266 }
3267 
3268 /**
3269  *  @brief This function builds a list of privs that test for a condition
3270  *  This is useful if you need to do a number of operations on the same set
3271  *  of privs.  For one-off tasks, the above two functions might be better.
3272  *
3273  *  @param pmadapter  A pointer to mlan_adapter
3274  *  @param check_cond Function pointer to condition to decide whether priv
3275  *                    should be placed in the list.
3276  *  @param ppriv_list Output param.  Externally supplied array of mlan_private*
3277  *                    to hold priv's that test positive with check_cond.
3278  *                    Array size should be at least pmadapter->priv_num.
3279  *
3280  *  @return          Number of privs in ppriv_list
3281  *
3282  *  @sa              wlan_count_priv_cond
3283  */
3284 INLINE
3285 static int wlan_get_privs_by_cond(mlan_adapter *pmadapter,
3286                                   t_bool (*check_cond)(IN pmlan_private pmpriv),
3287                                   mlan_private **ppriv_list)
3288 {
3289     pmlan_private pmpriv;
3290     int count = 0;
3291     t_u8 i;
3292 
3293     if (pmadapter == MNULL || check_cond == MNULL || ppriv_list == MNULL)
3294     {
3295         return 0;
3296     }
3297 
3298     for (i = 0; i < pmadapter->priv_num; i++)
3299     {
3300         pmpriv = pmadapter->priv[i];
3301         if (pmpriv != MNULL)
3302         {
3303             if (check_cond(pmpriv))
3304             {
3305                 ppriv_list[count++] = pmpriv;
3306             }
3307         }
3308     }
3309 
3310     return count;
3311 }
3312 
3313 /**
3314  *  @brief This function builds a list of privs that test against two conditions
3315  *  This is useful if you need to do a number of operations on the same set
3316  *  of privs.  Can choose whether both conditions (AND) or either condition (OR)
3317  *  is required.
3318  *
3319  *  @param pmadapter      A pointer to mlan_adapter
3320  *  @param check_cond     Function pointer to condition to decide whether priv
3321  *                        should be placed in the list.
3322  *  @param check_cond_2   Function pointer to second condition to check.
3323  *  @param and_conditions If MTRUE, both conditions must be met (AND),
3324  *                        else either condition can be met (OR).
3325  *  @param ppriv_list     Output param.  Externally supplied array of mlan_private*
3326  *                        to hold priv's that test positive with check_cond.
3327  *                        Array size should be at least pmadapter->priv_num.
3328  *
3329  *  @return          Number of privs in ppriv_list
3330  *
3331  *  @sa              wlan_count_priv_cond, wlan_get_privs_by_cond
3332  */
3333 INLINE
3334 static int wlan_get_privs_by_two_cond(mlan_adapter *pmadapter,
3335                                       t_bool (*check_cond)(IN pmlan_private pmpriv),
3336                                       t_bool (*check_cond_2)(IN pmlan_private pmpriv),
3337                                       t_bool and_conditions,
3338                                       mlan_private **ppriv_list)
3339 {
3340     pmlan_private pmpriv;
3341     int count = 0;
3342     t_u8 i;
3343 
3344     if (pmadapter == MNULL || check_cond == MNULL || check_cond_2 == MNULL || ppriv_list == MNULL)
3345     {
3346         return 0;
3347     }
3348 
3349     for (i = 0; i < pmadapter->priv_num; i++)
3350     {
3351         pmpriv = pmadapter->priv[i];
3352         if (pmpriv != MNULL)
3353         {
3354             if (and_conditions)
3355             {
3356                 if (check_cond(pmpriv) && check_cond_2(pmpriv))
3357                 {
3358                     ppriv_list[count++] = pmpriv;
3359                 }
3360             }
3361             else
3362             {
3363                 if (check_cond(pmpriv) || check_cond_2(pmpriv))
3364                 {
3365                     ppriv_list[count++] = pmpriv;
3366                 }
3367             }
3368         }
3369     }
3370 
3371     return count;
3372 }
3373 
3374 #if CONFIG_WMM_UAPSD
3375 /** Check if there is no packet */
3376 t_u8 wifi_check_no_packet_indication(mlan_private *priv);
3377 /** Check if this is the last packet */
3378 t_u8 wifi_check_last_packet_indication(mlan_private *priv);
3379 #endif
3380 
3381 mlan_status wlan_cmd_hs_wakeup_reason(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_void *pdata_buf);
3382 
3383 mlan_status wlan_ret_hs_wakeup_reason(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3384 
3385 #if CONFIG_FW_VDLL
3386 mlan_status wlan_download_vdll_block(mlan_adapter *pmadapter, t_u8 *block, t_u16 block_len);
3387 mlan_status wlan_process_vdll_event(pmlan_private pmpriv, t_u8 *pevent);
3388 #endif
3389 
3390 #if CONFIG_WIFI_IND_RESET
3391 mlan_status wlan_misc_ioctl_ind_rst_cfg(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
3392 mlan_status wlan_cmd_ind_rst_cfg(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
3393 
3394 mlan_status wlan_ret_ind_rst_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3395 #endif
3396 
3397 mlan_status wlan_cmd_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, t_void *pdata_buf);
3398 
3399 mlan_status wlan_ret_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, mlan_ioctl_req *pioctl_buf);
3400 
3401 t_bool wlan_is_etsi_country(pmlan_adapter pmadapter, t_u8 *country_code);
3402 
3403 #endif /* !_MLAN_MAIN_H_ */
3404