xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/mvl88w8977/mlan/mlan_main.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 (C) 2008-2017, Marvell International Ltd.
8  *
9  *  This software file (the "File") is distributed by Marvell International
10  *  Ltd. under the terms of the GNU General Public License Version 2, June 1991
11  *  (the "License").  You may use, redistribute and/or modify this File in
12  *  accordance with the terms and conditions of the License, a copy of which
13  *  is available by writing to the Free Software Foundation, Inc.,
14  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
15  *  worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
16  *
17  *  THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
20  *  this warranty disclaimer.
21  */
22 
23 /******************************************************
24 Change log:
25     10/13/2008: initial version
26 ******************************************************/
27 
28 #ifndef _MLAN_MAIN_H_
29 #define _MLAN_MAIN_H_
30 
31 #ifdef DEBUG_LEVEL1
32 extern t_void (*print_callback) (IN t_void *pmoal_handle,
33 				 IN t_u32 level, IN char *pformat, IN ...
34 	);
35 
36 extern mlan_status (*get_sys_time_callback) (IN t_void *pmoal_handle,
37 					     OUT t_u32 *psec, OUT t_u32 *pusec);
38 
39 extern t_u32 mlan_drvdbg;
40 
41 /* Reason Code 3: STA is leaving (or has left) IBSS or ESS */
42 #define DEF_DEAUTH_REASON_CODE (0x3)
43 
44 #ifdef	DEBUG_LEVEL2
45 #define	PRINTM_MINFO(msg...) do { \
46 	if ((mlan_drvdbg & MINFO) && (print_callback)) \
47 		print_callback(MNULL, MINFO, msg); \
48 	} while (0)
49 #define	PRINTM_MWARN(msg...)  do { \
50 	if ((mlan_drvdbg & MWARN) && (print_callback)) \
51 		print_callback(MNULL, MWARN, msg); \
52 	} while (0)
53 #define	PRINTM_MENTRY(msg...) do { \
54 	if ((mlan_drvdbg & MENTRY) && (print_callback)) \
55 		print_callback(MNULL, MENTRY, msg); \
56 } while (0)
57 #define PRINTM_GET_SYS_TIME(level, psec, pusec)              \
58 do {                                                         \
59 	if ((level & mlan_drvdbg) && (get_sys_time_callback))\
60 	    get_sys_time_callback(MNULL, psec, pusec);       \
61 } while (0)
62 
63 /** Hexdump for level-2 debugging */
64 #define HEXDUMP(x, y, z)   \
65 do {                \
66 	if ((mlan_drvdbg & (MHEX_DUMP | MINFO)) && (print_callback))  \
67 	    print_callback(MNULL, MHEX_DUMP | MINFO, x, y, z); \
68 } while (0)
69 
70 #else
71 
72 #define	PRINTM_MINFO(msg...)  do {} while (0)
73 #define	PRINTM_MWARN(msg...)  do {} while (0)
74 #define	PRINTM_MENTRY(msg...) do {} while (0)
75 
76 #define PRINTM_GET_SYS_TIME(level, psec, pusec)         \
77 do {                                                    \
78 	if ((level & mlan_drvdbg) && (get_sys_time_callback)     \
79 			&& (level != MINFO) && (level != MWARN))    \
80 	    get_sys_time_callback(MNULL, psec, pusec);      \
81 } while (0)
82 
83 /** Hexdump for debugging */
84 #define HEXDUMP(x, y, z) do {} while (0)
85 
86 #endif /* DEBUG_LEVEL2 */
87 
88 #define	PRINTM_MFW_D(msg...)  do { \
89 	if ((mlan_drvdbg & MFW_D) && (print_callback)) \
90 		print_callback(MNULL, MFW_D, msg); \
91 	} while (0)
92 #define	PRINTM_MCMD_D(msg...) do { \
93 	if ((mlan_drvdbg & MCMD_D) && (print_callback)) \
94 		print_callback(MNULL, MCMD_D, msg); \
95 	} while (0)
96 #define	PRINTM_MDAT_D(msg...) do { \
97 	if ((mlan_drvdbg & MDAT_D) && (print_callback)) \
98 		print_callback(MNULL, MDAT_D, msg); \
99 	} while (0)
100 #define	PRINTM_MIF_D(msg...) do { \
101 	if ((mlan_drvdbg & MIF_D) && (print_callback)) \
102 		print_callback(MNULL, MIF_D, msg); \
103 	} while (0)
104 
105 #define	PRINTM_MIOCTL(msg...) do { \
106 	if ((mlan_drvdbg & MIOCTL) && (print_callback)) \
107 		print_callback(MNULL, MIOCTL, msg); \
108 	} while (0)
109 #define	PRINTM_MINTR(msg...)  do { \
110 	if ((mlan_drvdbg & MINTR) && (print_callback)) \
111 		print_callback(MNULL, MINTR, msg); \
112 	} while (0)
113 #define	PRINTM_MEVENT(msg...) do { \
114 	if ((mlan_drvdbg & MEVENT) && (print_callback)) \
115 		print_callback(MNULL, MEVENT, msg); \
116 	} while (0)
117 #define	PRINTM_MCMND(msg...)  do { \
118 	if ((mlan_drvdbg & MCMND) && (print_callback)) \
119 		print_callback(MNULL, MCMND, msg); \
120 	} while (0)
121 #define	PRINTM_MDATA(msg...)  do { \
122 	if ((mlan_drvdbg & MDATA) && (print_callback)) \
123 		print_callback(MNULL, MDATA, msg); \
124 	} while (0)
125 #define	PRINTM_MERROR(msg...) do { \
126 	if ((mlan_drvdbg & MERROR) && (print_callback)) \
127 		print_callback(MNULL, MERROR, msg); \
128 	} while (0)
129 #define	PRINTM_MFATAL(msg...) do { \
130 	if ((mlan_drvdbg & MFATAL) && (print_callback)) \
131 		print_callback(MNULL, MFATAL, msg); \
132 	} while (0)
133 #define	PRINTM_MMSG(msg...) do { \
134 	if ((mlan_drvdbg & MMSG) && (print_callback)) \
135 		print_callback(MNULL, MMSG, msg); \
136 	} while (0)
137 
138 #define	PRINTM(level, msg...) PRINTM_##level((char *)msg)
139 
140 /** Log debug message */
141 #ifdef __GNUC__
142 #define PRINTM_NETINTF(level, pmpriv)   \
143 do {                                    \
144 	if ((mlan_drvdbg & level) && pmpriv      \
145 			&& pmpriv->adapter->callbacks.moal_print_netintf) \
146 	    pmpriv->adapter->callbacks.moal_print_netintf( \
147 		    pmpriv->adapter->pmoal_handle, \
148 		    pmpriv->bss_index, level); \
149 } while (0)
150 #endif /* __GNUC__ */
151 
152 /** Max hex dump data length */
153 #define MAX_DATA_DUMP_LEN	64
154 
155 /** Debug hexdump for level-1 debugging */
156 #define DBG_HEXDUMP(level, x, y, z)   \
157 do {                \
158 	if ((mlan_drvdbg & level) && print_callback)  \
159 		print_callback(MNULL, MHEX_DUMP | level, x, y, z); \
160 } while (0)
161 
162 #else /* DEBUG_LEVEL1 */
163 
164 #define	PRINTM(level, msg...) do {} while (0)
165 
166 #define PRINTM_NETINTF(level, pmpriv) do {} while (0)
167 
168 /** Debug hexdump for level-1 debugging */
169 #define DBG_HEXDUMP(level, x, y, z) do {} while (0)
170 
171 /** Hexdump for debugging */
172 #define HEXDUMP(x, y, z) do {} while (0)
173 
174 #define PRINTM_GET_SYS_TIME(level, psec, pusec) do { } while (0)
175 
176 #endif /* DEBUG_LEVEL1 */
177 
178 /** Log entry point for debugging */
179 #define ENTER()     \
180 do {                \
181 	PRINTM(MENTRY, "Enter: %s\n", __func__);   \
182 } while (0)
183 
184 /** Log exit point for debugging */
185 #define LEAVE()     \
186 do {                \
187 	PRINTM(MENTRY, "Leave: %s\n", __func__);   \
188 } while (0)
189 
190 /** Find minimum */
191 #ifndef MIN
192 #define MIN(a, b)		((a) < (b) ? (a) : (b))
193 #endif
194 
195 /** Find maximum */
196 #ifndef MAX
197 #define MAX(a, b)		((a) > (b) ? (a) : (b))
198 #endif
199 
200 #ifdef memset
201 #undef memset
202 #endif
203 /** Memset routine */
204 #define memset(adapter, s, c, len) \
205 	(adapter->callbacks.moal_memset(adapter->pmoal_handle, s, c, len))
206 
207 #ifdef memmove
208 #undef memmove
209 #endif
210 /** Memmove routine */
211 #define memmove(adapter, dest, src, len) \
212 	(adapter->callbacks.moal_memmove(adapter->pmoal_handle, dest, src, len))
213 
214 #ifdef memcpy
215 #undef memcpy
216 #endif
217 /** Memcpy routine */
218 #define memcpy(adapter, to, from, len) \
219 	(adapter->callbacks.moal_memcpy(adapter->pmoal_handle, to, from, len))
220 
221 #ifdef memcmp
222 #undef memcmp
223 #endif
224 /** Memcmp routine */
225 #define memcmp(adapter, s1, s2, len) \
226 	(adapter->callbacks.moal_memcmp(adapter->pmoal_handle, s1, s2, len))
227 
228 /** Find number of elements */
229 #ifndef NELEMENTS
230 #define NELEMENTS(x)    (sizeof(x)/sizeof(x[0]))
231 #endif
232 
233 /** SWAP: swap t_u8 */
234 #define SWAP_U8(a, b)	{t_u8 t; t = a; a = b; b = t; }
235 
236 /** SWAP: swap t_u8 */
237 #define SWAP_U16(a, b)	{t_u16 t; t = a; a = b; b = t; }
238 
239 /** MLAN MNULL pointer */
240 #define MNULL                           (0)
241 
242 /** 16 bits byte swap */
243 #define swap_byte_16(x) \
244 ((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \
245 		 (((t_u16)(x) & 0xff00U) >> 8)))
246 
247 /** 32 bits byte swap */
248 #define swap_byte_32(x) \
249 ((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \
250 	 (((t_u32)(x) & 0x0000ff00UL) <<  8) | \
251 	 (((t_u32)(x) & 0x00ff0000UL) >>  8) | \
252 	 (((t_u32)(x) & 0xff000000UL) >> 24)))
253 
254 /** 64 bits byte swap */
255 #define swap_byte_64(x) \
256 ((t_u64)((t_u64)(((t_u64)(x) & 0x00000000000000ffULL) << 56) | \
257 	     (t_u64)(((t_u64)(x) & 0x000000000000ff00ULL) << 40) | \
258 	     (t_u64)(((t_u64)(x) & 0x0000000000ff0000ULL) << 24) | \
259 	     (t_u64)(((t_u64)(x) & 0x00000000ff000000ULL) <<  8) | \
260 	     (t_u64)(((t_u64)(x) & 0x000000ff00000000ULL) >>  8) | \
261 	     (t_u64)(((t_u64)(x) & 0x0000ff0000000000ULL) >> 24) | \
262 	     (t_u64)(((t_u64)(x) & 0x00ff000000000000ULL) >> 40) | \
263 	     (t_u64)(((t_u64)(x) & 0xff00000000000000ULL) >> 56)))
264 
265 #ifdef BIG_ENDIAN_SUPPORT
266 /** Convert ulong n/w to host */
267 #define mlan_ntohl(x) x
268 /** Convert host ulong to n/w */
269 #define mlan_htonl(x) x
270 /** Convert n/w to host */
271 #define mlan_ntohs(x)  x
272 /** Convert host to n/w */
273 #define mlan_htons(x)  x
274 /** Convert from 16 bit little endian format to CPU format */
275 #define wlan_le16_to_cpu(x) swap_byte_16(x)
276 /** Convert from 32 bit little endian format to CPU format */
277 #define wlan_le32_to_cpu(x) swap_byte_32(x)
278 /** Convert from 64 bit little endian format to CPU format */
279 #define wlan_le64_to_cpu(x) swap_byte_64(x)
280 /** Convert to 16 bit little endian format from CPU format */
281 #define wlan_cpu_to_le16(x) swap_byte_16(x)
282 /** Convert to 32 bit little endian format from CPU format */
283 #define wlan_cpu_to_le32(x) swap_byte_32(x)
284 /** Convert to 64 bit little endian format from CPU format */
285 #define wlan_cpu_to_le64(x) swap_byte_64(x)
286 
287 /** Convert TxPD to little endian format from CPU format */
288 #define endian_convert_TxPD(x)                                          \
289 	{                                                                   \
290 	    (x)->tx_pkt_length = wlan_cpu_to_le16((x)->tx_pkt_length);      \
291 	    (x)->tx_pkt_offset = wlan_cpu_to_le16((x)->tx_pkt_offset);      \
292 	    (x)->tx_pkt_type   = wlan_cpu_to_le16((x)->tx_pkt_type);        \
293 	    (x)->tx_control    = wlan_cpu_to_le32((x)->tx_control);         \
294         (x)->tx_control_1  = wlan_cpu_to_le32((x)->tx_control_1);         \
295 	}
296 /** Convert RxPD from little endian format to CPU format */
297 #define endian_convert_RxPD(x)                                          \
298 	{                                                                   \
299 	    (x)->rx_pkt_length = wlan_le16_to_cpu((x)->rx_pkt_length);      \
300 	    (x)->rx_pkt_offset = wlan_le16_to_cpu((x)->rx_pkt_offset);      \
301 	    (x)->rx_pkt_type   = wlan_le16_to_cpu((x)->rx_pkt_type);        \
302 	    (x)->seq_num       = wlan_le16_to_cpu((x)->seq_num);            \
303         (x)->rx_info       = wlan_le32_to_cpu((x)->rx_info);            \
304 	}
305 /** Convert RxPD extra header from little endian format to CPU format */
306 #define endian_convert_RxPD_extra_header(x)                                          \
307 	{                                                                   \
308 	    (x)->channel_flags = wlan_le16_to_cpu((x)->channel_flags);      \
309 	}
310 #else
311 /** Convert ulong n/w to host */
312 #define mlan_ntohl(x) swap_byte_32(x)
313 /** Convert host ulong to n/w */
314 #define mlan_htonl(x) swap_byte_32(x)
315 /** Convert n/w to host */
316 #define mlan_ntohs(x) swap_byte_16(x)
317 /** Convert host to n/w */
318 #define mlan_htons(x) swap_byte_16(x)
319 /** Do nothing */
320 #define wlan_le16_to_cpu(x) x
321 /** Do nothing */
322 #define wlan_le32_to_cpu(x) x
323 /** Do nothing */
324 #define wlan_le64_to_cpu(x) x
325 /** Do nothing */
326 #define wlan_cpu_to_le16(x) x
327 /** Do nothing */
328 #define wlan_cpu_to_le32(x) x
329 /** Do nothing */
330 #define wlan_cpu_to_le64(x) x
331 
332 /** Convert TxPD to little endian format from CPU format */
333 #define endian_convert_TxPD(x)  do {} while (0)
334 /** Convert RxPD from little endian format to CPU format */
335 #define endian_convert_RxPD(x)  do {} while (0)
336 /** Convert RxPD extra header from little endian format to CPU format */
337 #define endian_convert_RxPD_extra_header(x)  do {} while (0)
338 #endif /* BIG_ENDIAN_SUPPORT */
339 
340 /** Global moal_assert_callback */
341 extern t_void (*assert_callback) (IN t_void *pmoal_handle, IN t_u32 cond);
342 
343 /** Assertion */
344 #define MASSERT(cond)                   \
345 do {                                    \
346 	if (!(cond)) {                      \
347 	    PRINTM(MFATAL, "ASSERT: %s: %i\n", __func__, __LINE__); \
348 	    if (assert_callback) {          \
349 			assert_callback(MNULL, (t_ptr)(cond)); \
350 	    } else {                        \
351 			do {} while (1);             \
352 	    }                               \
353 	}                                   \
354 } while (0)
355 
356 /** Upload size */
357 #define WLAN_UPLD_SIZE                  (2312)
358 
359 /** Maximum event buffer size */
360 #define MAX_EVENT_SIZE                  2048
361 
362 #ifdef STA_SUPPORT
363 /** Maximum buffer size for ARP filter */
364 #define ARP_FILTER_MAX_BUF_SIZE         68
365 #endif /* STA_SUPPORT */
366 
367 /** 60 seconds */
368 #define MRVDRV_TIMER_60S                60000
369 /** 10 seconds */
370 #define MRVDRV_TIMER_10S                10000
371 /** 5 seconds */
372 #define MRVDRV_TIMER_5S                 5000
373 /** 1 second */
374 #define MRVDRV_TIMER_1S                 1000
375 
376 /** Maximum size of multicast list */
377 #define MRVDRV_MAX_MULTICAST_LIST_SIZE  32
378 /** Maximum size of channel */
379 #define MRVDRV_MAX_CHANNEL_SIZE         14
380 /** Maximum length of SSID */
381 #define MRVDRV_MAX_SSID_LENGTH          32
382 /** WEP list macros & data structures */
383 /** Size of key buffer in bytes */
384 #define MRVL_KEY_BUFFER_SIZE_IN_BYTE    16
385 /** Maximum length of WPA key */
386 #define MRVL_MAX_KEY_WPA_KEY_LENGTH     32
387 
388 /** Default listen interval */
389 #define MLAN_DEFAULT_LISTEN_INTERVAL    20
390 
391 /** Maximum number of region codes */
392 #define MRVDRV_MAX_REGION_CODE          8
393 
394 /** Maximum number of CFP codes for BG */
395 #define MRVDRV_MAX_CFP_CODE_BG          0
396 /** Maximum number of CFP codes for A */
397 #define MRVDRV_MAX_CFP_CODE_A           5
398 
399 /** high rx pending packets */
400 #define HIGH_RX_PENDING         100
401 /** low rx pending packets */
402 #define LOW_RX_PENDING          80
403 
404 /** Default region code */
405 #define MRVDRV_DEFAULT_REGION_CODE      0x10
406 
407 /** Default country code */
408 #define MRVDRV_DEFAULT_COUNTRY_CODE      "US"
409 
410 /** Japan country code */
411 #define COUNTRY_CODE_JP_40	        0x40
412 /** Japan special country code */
413 #define COUNTRY_CODE_JP_FF	        0xFF
414 
415 /** Default factor for calculating beacon average */
416 #define DEFAULT_BCN_AVG_FACTOR          8
417 /** Default factor for calculating data average */
418 #define DEFAULT_DATA_AVG_FACTOR         8
419 
420 /** The first valid channel for use */
421 #define FIRST_VALID_CHANNEL          0xff
422 /** Default Ad-Hoc channel */
423 #define DEFAULT_AD_HOC_CHANNEL       6
424 /** Default Ad-Hoc channel A */
425 #define DEFAULT_AD_HOC_CHANNEL_A     36
426 
427 /** Number of WEP keys */
428 #define MRVL_NUM_WEP_KEY                (4)
429 
430 /** Default multiple DTIM */
431 #define MRVDRV_DEFAULT_MULTIPLE_DTIM        1
432 
433 /** Default beacon missing timeout */
434 #define DEFAULT_BCN_MISS_TIMEOUT            10
435 
436 /** Maximum buffer space for beacons retrieved from scan responses */
437 #define MAX_SCAN_BEACON_BUFFER          49152
438 /** Default buffer space for beacons retrieved from scan responses */
439 #define DEFAULT_SCAN_BEACON_BUFFER      4096
440 
441 /**
442  * @brief Buffer pad space for newly allocated beacons/probe responses
443  *
444  * Beacons are typically 6 bytes longer than an equivalent probe response.
445  *  For each scan response stored, allocate an extra byte pad at the end to
446  *  allow easy expansion to store a beacon in the same memory a probe response
447  *  previously contained
448  */
449 #define SCAN_BEACON_ENTRY_PAD          6
450 
451 /** Scan time specified in the channel TLV
452  *  for each channel for passive scans
453  */
454 #define MRVDRV_PASSIVE_SCAN_CHAN_TIME       200
455 
456 /** Scan time specified in the channel TLV
457  *  for each channel for active scans
458  */
459 #define MRVDRV_ACTIVE_SCAN_CHAN_TIME        200
460 
461 /** Scan time specified in the channel TLV
462  *  for each channel for specific scans
463  */
464 #define MRVDRV_SPECIFIC_SCAN_CHAN_TIME      110
465 
466 /**
467  * Max total scan time in milliseconds
468  * The total scan time should be less than scan command timeout value (20s)
469  */
470 #define MRVDRV_MAX_TOTAL_SCAN_TIME     (MRVDRV_TIMER_10S * 2 - MRVDRV_TIMER_1S)
471 
472 /** Offset for GTK as it has version to skip past for GTK */
473 #define RSN_GTK_OUI_OFFSET 2
474 
475 /** If OUI is not found */
476 #define MLAN_OUI_NOT_PRESENT 0
477 /** If OUI is found */
478 #define MLAN_OUI_PRESENT 1
479 
480 /** Is cmd_resp, event or data packet received? */
481 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
482 	adapter->event_received || \
483 	adapter->data_received)
484 /** Type command */
485 #define MLAN_TYPE_CMD			1
486 /** Type data */
487 #define MLAN_TYPE_DATA			0
488 /** Type event */
489 #define MLAN_TYPE_EVENT			3
490 
491 /** Type single port aggr data */
492 #define MLAN_TYPE_SPA_DATA     10
493 /** OFFSET of 512 block number */
494 #define OFFSET_OF_BLOCK_NUMBER  15
495 /** OFFSET of SDIO Header */
496 #define OFFSET_OF_SDIO_HEADER      28
497 /** sdio max rx size for cmd53, 255 * 256, reserve 1 block for DMA alignment */
498 #define SDIO_CMD53_MAX_SIZE     65280
499 #define MAX_SUPPORT_AMSDU_SIZE          4096
500 /** Maximum numbfer of registers to read for multiple port */
501 #define MAX_MP_REGS			196
502 /** Maximum port */
503 #define MAX_PORT			32
504 
505 #ifdef SDIO_MULTI_PORT_TX_AGGR
506 /** Multi port TX aggregation buffer size */
507 #define SDIO_MP_TX_AGGR_DEF_BUF_SIZE        (65280)	/* 64K - 256 */
508 #endif /* SDIO_MULTI_PORT_TX_AGGR */
509 
510 #ifdef SDIO_MULTI_PORT_RX_AGGR
511 /** Multi port RX aggregation buffer size */
512 #define SDIO_MP_RX_AGGR_DEF_BUF_SIZE        (65280)	/* 64K - 256 */
513 #endif /* SDIO_MULTI_PORT_RX_AGGR */
514 
515 /** High threshold at which to start drop packets */
516 #define  RX_HIGH_THRESHOLD           1024
517 /** Low threshold to allow Rx BA */
518 #define  RX_LOW_THRESHOLD            128
519 
520 /** Debug command number */
521 #define DBG_CMD_NUM	10
522 
523 /** Info for debug purpose */
524 typedef struct _wlan_dbg {
525     /** Number of host to card command failures */
526 	t_u32 num_cmd_host_to_card_failure;
527     /** Number of host to card sleep confirm failures */
528 	t_u32 num_cmd_sleep_cfm_host_to_card_failure;
529     /** Number of host to card Tx failures */
530 	t_u32 num_tx_host_to_card_failure;
531     /** Number of card to host command/event failures */
532 	t_u32 num_cmdevt_card_to_host_failure;
533     /** Number of card to host Rx failures */
534 	t_u32 num_rx_card_to_host_failure;
535     /** Number of interrupt read failures */
536 	t_u32 num_int_read_failure;
537     /** Last interrupt status */
538 	t_u32 last_int_status;
539     /** Number of allocate buffer failure */
540 	t_u32 num_alloc_buffer_failure;
541 	/** Number of pkt dropped */
542 	t_u32 num_pkt_dropped;
543     /** Number of deauthentication events */
544 	t_u32 num_event_deauth;
545     /** Number of disassosiation events */
546 	t_u32 num_event_disassoc;
547     /** Number of link lost events */
548 	t_u32 num_event_link_lost;
549     /** Number of deauthentication commands */
550 	t_u32 num_cmd_deauth;
551     /** Number of association comamnd successes */
552 	t_u32 num_cmd_assoc_success;
553     /** Number of association command failures */
554 	t_u32 num_cmd_assoc_failure;
555     /** Number of Tx timeouts */
556 	t_u32 num_tx_timeout;
557     /** Number of command timeouts */
558 	t_u32 num_cmd_timeout;
559     /** Timeout command ID */
560 	t_u16 timeout_cmd_id;
561     /** Timeout command action */
562 	t_u16 timeout_cmd_act;
563     /** List of last command IDs */
564 	t_u16 last_cmd_id[DBG_CMD_NUM];
565     /** List of last command actions */
566 	t_u16 last_cmd_act[DBG_CMD_NUM];
567     /** Last command index */
568 	t_u16 last_cmd_index;
569     /** List of last command response IDs */
570 	t_u16 last_cmd_resp_id[DBG_CMD_NUM];
571     /** Last command response index */
572 	t_u16 last_cmd_resp_index;
573     /** List of last events */
574 	t_u16 last_event[DBG_CMD_NUM];
575     /** Last event index */
576 	t_u16 last_event_index;
577     /** Number of no free command node */
578 	t_u16 num_no_cmd_node;
579 } wlan_dbg;
580 
581 /** Hardware status codes */
582 typedef enum _WLAN_HARDWARE_STATUS {
583 	WlanHardwareStatusReady,
584 	WlanHardwareStatusGetHwSpec,
585 	WlanHardwareStatusGetHwSpecdone,
586 	WlanHardwareStatusInitializing,
587 	WlanHardwareStatusInitdone,
588 	WlanHardwareStatusReset,
589 	WlanHardwareStatusClosing,
590 	WlanHardwareStatusNotReady
591 } WLAN_HARDWARE_STATUS;
592 
593 /** WLAN_802_11_POWER_MODE */
594 typedef enum _WLAN_802_11_POWER_MODE {
595 	Wlan802_11PowerModeCAM,
596 	Wlan802_11PowerModePSP
597 } WLAN_802_11_POWER_MODE;
598 
599 /** tx param */
600 typedef struct _mlan_tx_param {
601     /** next packet length */
602 	t_u32 next_pkt_len;
603 } mlan_tx_param;
604 
605 /** PS_STATE */
606 typedef enum _PS_STATE {
607 	PS_STATE_AWAKE,
608 	PS_STATE_PRE_SLEEP,
609 	PS_STATE_SLEEP_CFM,
610 	PS_STATE_SLEEP
611 } PS_STATE;
612 
613 /** Minimum flush timer for win size of 1 is 50 ms */
614 #define MIN_FLUSH_TIMER_MS 50
615 /** Minimum flush timer for win size of 1 is 15 ms */
616 #define MIN_FLUSH_TIMER_15_MS 15
617 
618 /** Tx BA stream table */
619 typedef struct _TxBAStreamTbl TxBAStreamTbl;
620 
621 /** Add BA parameter data structure */
622 typedef struct {
623     /** Window size for initiator */
624 	t_u32 tx_win_size;
625     /** Window size for receiver */
626 	t_u32 rx_win_size;
627     /** Block ack timeout */
628 	t_u32 timeout;
629     /** amsdu support for ADDBA request */
630 	t_u8 tx_amsdu;
631     /** amsdu support for ADDBA response */
632 	t_u8 rx_amsdu;
633 } add_ba_param_t;
634 
635 /** Tx aggregation data structure */
636 typedef struct _txAggr_t {
637     /** AMPDU user */
638 	t_u8 ampdu_user;
639     /** AMPDU AP */
640 	t_u8 ampdu_ap;
641     /** AMSDU */
642 	t_u8 amsdu;
643 } tx_aggr_t;
644 
645 /** del ba threshold */
646 #define DEL_BA_THRESHOLD    10
647 /** BA stream status */
648 typedef enum _baStatus_e {
649 	BA_STREAM_NOT_SETUP = 0,
650 	BA_STREAM_SETUP_INPROGRESS,
651 	BA_STREAM_SETUP_COMPLETE
652 } baStatus_e;
653 
654 /** RA list table */
655 typedef struct _raListTbl raListTbl;
656 
657 /** RA list table */
658 struct _raListTbl {
659     /** Pointer to previous node */
660 	raListTbl *pprev;
661     /** Pointer to next node */
662 	raListTbl *pnext;
663     /** Buffer list head */
664 	mlan_list_head buf_head;
665     /** RA list buffer */
666 	t_u8 ra[MLAN_MAC_ADDR_LENGTH];
667     /** total packets in RA list */
668 	t_u16 total_pkts;
669 	/** packets received */
670 	t_u16 packet_count;
671 	/** packet count threshold to setup BA */
672 	t_u8 ba_packet_threshold;
673 	/** is 11n enabled */
674 	t_u8 is_11n_enabled;
675 	/** max amsdu size */
676 	t_u16 max_amsdu;
677     /** BA stream status */
678 	baStatus_e ba_status;
679     /** del ba count */
680 	t_u8 del_ba_count;
681     /** amsdu in ampdu flag */
682 	t_u8 amsdu_in_ampdu;
683 	/** tdls flag */
684 	t_u8 is_tdls_link;
685 	/** tx_pause flag */
686 	t_u8 tx_pause;
687 };
688 
689 /** TID table */
690 typedef struct _tidTbl {
691     /** RA list head */
692 	mlan_list_head ra_list;
693     /** Current RA list */
694 	raListTbl *ra_list_curr;
695 } tid_tbl_t;
696 
697 /** Highest priority setting for a packet (uses voice AC) */
698 #define WMM_HIGHEST_PRIORITY  7
699 /** Highest priority TID  */
700 #define HIGH_PRIO_TID   7
701 /** Lowest priority TID  */
702 #define LOW_PRIO_TID    0
703 /** No packet priority (< lowest) */
704 #define NO_PKT_PRIO_TID    -1
705 
706 /** Max driver packet delay in msec */
707 #define WMM_DRV_DELAY_MAX	510
708 
709 /** Struct of WMM DESC */
710 typedef struct _wmm_desc {
711     /** TID table */
712 	tid_tbl_t tid_tbl_ptr[MAX_NUM_TID];
713     /** Packets out */
714 	t_u32 packets_out[MAX_NUM_TID];
715     /** Packets queued */
716 	t_u32 pkts_queued[MAX_NUM_TID];
717     /** Packets paused */
718 	t_u32 pkts_paused[MAX_NUM_TID];
719     /** Spin lock to protect ra_list */
720 	t_void *ra_list_spinlock;
721 
722     /** AC status */
723 	WmmAcStatus_t ac_status[MAX_AC_QUEUES];
724     /** AC downgraded values */
725 	mlan_wmm_ac_e ac_down_graded_vals[MAX_AC_QUEUES];
726 
727     /** Max driver packet delay sent to the firmware for expiry eval */
728 	t_u32 drv_pkt_delay_max;
729 
730     /** WMM queue priority table */
731 	t_u8 queue_priority[MAX_AC_QUEUES];
732     /** User priority packet transmission control */
733 	t_u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1];	/* UP: 0 to 7 */
734 
735     /** Number of transmit packets queued */
736 	mlan_scalar tx_pkts_queued;
737     /** Tracks highest priority with a packet queued */
738 	mlan_scalar highest_queued_prio;
739 } wmm_desc_t;
740 
741 /** Security structure */
742 typedef struct _wlan_802_11_security_t {
743     /** WPA enabled flag */
744 	t_u8 wpa_enabled;
745     /** E-Supplicant enabled flag */
746 	t_u8 ewpa_enabled;
747     /** WPA2 enabled flag */
748 	t_u8 wpa2_enabled;
749     /** WAPI enabled flag */
750 	t_u8 wapi_enabled;
751     /** WAPI key on flag */
752 	t_u8 wapi_key_on;
753     /** WEP status */
754 	WLAN_802_11_WEP_STATUS wep_status;
755     /** Authentication mode */
756 	t_u32 authentication_mode;
757     /** Encryption mode */
758 	t_u32 encryption_mode;
759 } wlan_802_11_security_t;
760 
761 /** Current Basic Service Set State Structure */
762 typedef struct {
763     /** BSS descriptor */
764 	BSSDescriptor_t bss_descriptor;
765     /** WMM enable? */
766 	t_u8 wmm_enabled;
767     /** Uapsd enable?*/
768 	t_u8 wmm_uapsd_enabled;
769     /** Band */
770 	t_u8 band;
771     /** Number of rates supported */
772 	t_u32 num_of_rates;
773     /** Supported rates*/
774 	t_u8 data_rates[WLAN_SUPPORTED_RATES];
775 } current_bss_params_t;
776 
777 /** Sleep_params */
778 typedef struct _sleep_params_t {
779     /** Sleep parameter error */
780 	t_u16 sp_error;
781     /** Sleep parameter offset */
782 	t_u16 sp_offset;
783     /** Sleep parameter stable time */
784 	t_u16 sp_stable_time;
785     /** Sleep parameter calibration control */
786 	t_u8 sp_cal_control;
787     /** Sleep parameter external sleep clock */
788 	t_u8 sp_ext_sleep_clk;
789     /** Sleep parameter reserved */
790 	t_u16 sp_reserved;
791 } sleep_params_t;
792 
793 /** Sleep_period */
794 typedef struct sleep_period_t {
795     /** Sleep period */
796 	t_u16 period;
797     /** Reserved */
798 	t_u16 reserved;
799 } sleep_period_t;
800 
801 /** mrvl_wep_key_t */
802 typedef struct _mrvl_wep_key_t {
803     /** Length */
804 	t_u32 length;
805     /** WEP key index */
806 	t_u32 key_index;
807     /** WEP key length */
808 	t_u32 key_length;
809     /** WEP keys */
810 	t_u8 key_material[MRVL_KEY_BUFFER_SIZE_IN_BYTE];
811 } mrvl_wep_key_t;
812 
813 /** Maximum number of region channel */
814 #define MAX_REGION_CHANNEL_NUM  2
815 
816 /** CFP dynamic (non-const) elements */
817 typedef struct _cfp_dyn_t {
818 	/** extra flags to specify channel usability
819 	 *  bit 7 : if set, channel is disabled
820 	 *  bit 4 : if set, 160MHz on channel is disabled
821 	 *  bit 3 : if set, 80MHz on channel is disabled
822 	 *  bit 2 : if set, 40MHz on channel is disabled
823 	 *  bit 1 : if set, channel is DFS channel
824 	 *  bit 0 : if set, channel is passive
825 	 */
826 	t_u8 flags;
827     /** TRUE: Channel is blacklisted (do not use) */
828 	t_bool blacklist;
829 } cfp_dyn_t;
830 
831 /** Chan-Freq-TxPower mapping table*/
832 typedef struct _chan_freq_power_t {
833     /** Channel Number */
834 	t_u16 channel;
835     /** Frequency of this Channel */
836 	t_u32 freq;
837     /** Max allowed Tx power level */
838 	t_u16 max_tx_power;
839     /** TRUE:radar detect required for BAND A or passive scan for BAND B/G;
840       * FALSE:radar detect not required for BAND A or active scan for BAND B/G*/
841 	t_bool passive_scan_or_radar_detect;
842     /** Elements associated to cfp that change at run-time */
843 	cfp_dyn_t dynamic;
844 } chan_freq_power_t;
845 
846 /** Region-band mapping table */
847 typedef struct _region_chan_t {
848     /** TRUE if this entry is valid */
849 	t_u8 valid;
850     /** Region code for US, Japan ... */
851 	t_u8 region;
852     /** Band B/G/A, used for BAND_CONFIG cmd */
853 	t_u8 band;
854     /** Actual No. of elements in the array below */
855 	t_u8 num_cfp;
856     /** chan-freq-txpower mapping table */
857 	chan_freq_power_t *pcfp;
858 } region_chan_t;
859 
860 /** State of 11d */
861 typedef enum _state_11d_t {
862 	DISABLE_11D = 0,
863 	ENABLE_11D = 1,
864 } state_11d_t;
865 
866 #define DEFAULT_11D_STATE   DISABLE_11D
867 
868 /** Domain regulatory information */
869 typedef struct _wlan_802_11d_domain_reg {
870     /** Country Code */
871 	t_u8 country_code[COUNTRY_CODE_LEN];
872     /** band that channels in sub_band belong to */
873 	t_u8 band;
874     /** No. of subband in below */
875 	t_u8 no_of_sub_band;
876     /** Subband data to send/last sent */
877 	IEEEtypes_SubbandSet_t sub_band[MRVDRV_MAX_SUBBAND_802_11D];
878 } wlan_802_11d_domain_reg_t;
879 
880 /** Data for state machine */
881 typedef struct _wlan_802_11d_state {
882     /** True for enabling 11D */
883 	state_11d_t enable_11d;
884     /** True for user enabling 11D */
885 	state_11d_t user_enable_11d;
886 } wlan_802_11d_state_t;
887 
888 /** 802.11h State information kept in the 'mlan_private' driver structure */
889 typedef struct {
890     /** Indicate 11h is enabled from host */
891 	t_bool is_11h_host;
892     /** Indicates whether 11h is enabled in the driver */
893 	t_bool is_11h_enabled;
894     /** Indicates whether 11h is active in the firmware */
895 	t_bool is_11h_active;
896     /** Master device using automatic channel select */
897 	t_bool adhoc_auto_sel_chan;
898     /** Set when driver receives a STOP TX event from fw */
899 	t_bool tx_disabled;
900     /** Channel that ChanSwAnn was received for, non-zero = active */
901 	t_u8 dfs_slave_csa_chan;
902     /** Expiry for above variable, seconds in system time */
903 	t_u32 dfs_slave_csa_expire_at_sec;
904 } wlan_11h_interface_state_t;
905 
906 #if defined(UAP_SUPPORT)
907 /** UAP get info callback state kept in the 'mlan_private' driver structure */
908 typedef struct {
909     /** UAP internal callback after wlan_uap_get_channel */
910     /**  (parameter is really pointer to mlan_private)   */
911 	mlan_status (*get_chan_callback) (t_void *);
912     /** current ioctl_req (to be completed in callback) */
913 	pmlan_ioctl_req pioctl_req_curr;
914     /** band config from MrvlIEtypes_channel_band_t */
915 	Band_Config_t bandcfg;
916     /** channel from MrvlIEtypes_channel_band_t */
917 	t_u8 channel;
918     /** beacon period (in msec) from MrvlIEtypes_beacon_period_t */
919 	t_u16 beacon_period;
920     /** dtim period (no unit) from MrvlIEtypes_dtim_period_t */
921 	t_u8 dtim_period;
922 } wlan_uap_get_info_cb_t;
923 #endif
924 
925 /** Data structure for WPS information */
926 typedef struct {
927     /** WPS IE */
928 	IEEEtypes_VendorSpecific_t wps_ie;
929     /** Session enable flag */
930 	t_u8 session_enable;
931 } wps_t;
932 
933 /** mlan_operations data structure */
934 typedef struct _mlan_operations {
935     /** cmd init handler */
936 	mlan_status (*init_cmd) (IN t_void *priv, IN t_u8 first_bss);
937     /** ioctl handler */
938 	mlan_status (*ioctl) (t_void *adapter, pmlan_ioctl_req pioctl_req);
939     /** cmd handler */
940 	mlan_status (*prepare_cmd) (IN t_void *priv,
941 				    IN t_u16 cmd_no,
942 				    IN t_u16 cmd_action,
943 				    IN t_u32 cmd_oid,
944 				    IN t_void *pioctl_buf,
945 				    IN t_void *pdata_buf, IN t_void *pcmd_buf);
946     /** cmdresp handler */
947 	mlan_status (*process_cmdresp) (IN t_void *priv,
948 					IN t_u16 cmdresp_no,
949 					IN t_void *pcmd_buf, IN t_void *pioctl);
950     /** rx handler */
951 	mlan_status (*process_rx_packet) (IN t_void *adapter,
952 					  IN pmlan_buffer pmbuf);
953     /** event handler */
954 	mlan_status (*process_event) (IN t_void *priv);
955     /** txpd handler */
956 	t_void *(*process_txpd) (IN t_void *priv, IN pmlan_buffer pmbuf);
957     /** BSS role */
958 	mlan_bss_role bss_role;
959 } mlan_operations;
960 
961 /** Private structure for MLAN */
962 typedef struct _mlan_private {
963     /** Pointer to mlan_adapter */
964 	struct _mlan_adapter *adapter;
965     /** BSS index */
966 	t_u8 bss_index;
967     /** BSS type */
968 	t_u8 bss_type;
969     /** BSS role */
970 	t_u8 bss_role;
971     /** BSS virtual flag */
972 	t_u8 bss_virtual;
973     /** BSS Priority */
974 	t_u8 bss_priority;
975     /** BSS number */
976 	t_u8 bss_num;
977     /** Frame type */
978 	t_u8 frame_type;
979     /** MAC address information */
980 	t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
981     /** Media connection status */
982 	t_bool media_connected;
983 
984     /** Current packet filter */
985 	t_u32 curr_pkt_filter;
986     /** Infrastructure mode */
987 	t_u32 bss_mode;
988 
989     /** Tx packet control */
990 	t_u32 pkt_tx_ctrl;
991 
992     /** Tx power level */
993 	t_s16 tx_power_level;
994     /** Maximum Tx power level */
995 	t_s8 max_tx_power_level;
996     /** Minimum Tx power level */
997 	t_s8 min_tx_power_level;
998     /** Tx rate */
999 	t_u8 tx_rate;
1000 	t_u8 tx_rate_info;
1001     /** rxpd_htinfo */
1002 	t_u8 rxpd_rate_info;
1003     /** max amsdu size */
1004 	t_u16 max_amsdu;
1005     /** 802.11n Device Capabilities for 2.4GHz */
1006 	t_u32 usr_dot_11n_dev_cap_bg;
1007     /** 802.11n Device Capabilities for 5GHz */
1008 	t_u32 usr_dot_11n_dev_cap_a;
1009     /** MIMO abstraction of MCSs supported by device */
1010 	t_u8 usr_dev_mcs_support;
1011 #ifdef UAP_SUPPORT
1012     /** UAP 11n flag */
1013 	t_u8 is_11n_enabled;
1014 #endif				/* UAP_SUPPORT */
1015 #ifdef UAP_SUPPORT
1016 #endif				/* UAP_SUPPORT */
1017     /**  dropped pkts */
1018 	t_u32 num_drop_pkts;
1019 #ifdef UAP_SUPPORT
1020     /** packet forward control */
1021 	t_u8 pkt_fwd;
1022 #endif
1023     /** TX beamforming capability */
1024 	t_u32 tx_bf_cap;
1025     /** Rx PD rate */
1026 	t_u8 rxpd_rate;
1027     /** Rate bitmap */
1028 	t_u16 rate_bitmap;
1029     /** Bitmap rates */
1030 	t_u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
1031     /** Data rate */
1032 	t_u32 data_rate;
1033     /** Automatic data rate flag */
1034 	t_u8 is_data_rate_auto;
1035     /** Factor for calculating beacon average */
1036 	t_u16 bcn_avg_factor;
1037     /** Factor for calculating data average */
1038 	t_u16 data_avg_factor;
1039     /** Last data RSSI */
1040 	t_s16 data_rssi_last;
1041     /** Last data Noise Floor */
1042 	t_s16 data_nf_last;
1043     /** Average data RSSI */
1044 	t_s16 data_rssi_avg;
1045     /** Averag data Noise Floor */
1046 	t_s16 data_nf_avg;
1047     /** Last beacon RSSI */
1048 	t_s16 bcn_rssi_last;
1049     /** Last beacon Noise Floor */
1050 	t_s16 bcn_nf_last;
1051     /** Average beacon RSSI */
1052 	t_s16 bcn_rssi_avg;
1053     /** Average beacon Noise Floor */
1054 	t_s16 bcn_nf_avg;
1055 
1056     /** Attempted BSS descriptor */
1057 	BSSDescriptor_t *pattempted_bss_desc;
1058 
1059     /** GTK rekey data*/
1060 	mlan_ds_misc_gtk_rekey_data gtk_rekey;
1061 
1062     /** Current SSID/BSSID related parameters*/
1063 	current_bss_params_t curr_bss_params;
1064     /** current channel flags */
1065 	t_u32 curr_chan_flags;
1066     /** User selected bands */
1067 	t_u8 config_bands;
1068 
1069     /** Beacon period */
1070 	t_u16 beacon_period;
1071     /** Listen interval */
1072 	t_u16 listen_interval;
1073     /** ATIM window */
1074 	t_u16 atim_window;
1075 
1076     /** AdHoc channel */
1077 	t_u8 adhoc_channel;
1078     /** AdHoc link sensed flag */
1079 	t_u8 adhoc_is_link_sensed;
1080     /** AdHoc operating state */
1081 	t_u8 adhoc_state;
1082 #if defined(STA_SUPPORT)
1083     /** AdHoc operating state backup */
1084 	t_u8 adhoc_state_prev;
1085     /** AdHoc previous ssid used for Start */
1086 	mlan_802_11_ssid adhoc_last_start_ssid;
1087 #endif
1088     /** FSM variable for 11d support */
1089 	wlan_802_11d_state_t state_11d;
1090     /** FSM variable for 11h support */
1091 	wlan_11h_interface_state_t intf_state_11h;
1092 	/** 11k flag */
1093 	t_u8 enable_11k;
1094 #ifdef UAP_SUPPORT
1095     /** Whether UAP interface has started */
1096 	t_bool uap_bss_started;
1097     /** Whether UAP interface start from hostapd */
1098 	t_bool uap_host_based;
1099     /**UAP operating channel*/
1100 	t_u8 uap_channel;
1101     /** state variable for UAP Get Info callback */
1102 	wlan_uap_get_info_cb_t uap_state_chan_cb;
1103 #endif				/* UAP_SUPPORT */
1104 
1105     /** Security related */
1106     /** Encryption parameter */
1107 	wlan_802_11_security_t sec_info;
1108     /** WEP keys */
1109 	mrvl_wep_key_t wep_key[MRVL_NUM_WEP_KEY];
1110     /** Current WEP key index */
1111 	t_u16 wep_key_curr_index;
1112     /** EWPA query 0: disable, 1: enable */
1113 	t_u8 ewpa_query;
1114     /** Encryption Key*/
1115 	t_u8 wpa_ie[256];
1116     /** WPA IE length */
1117 	t_u8 wpa_ie_len;
1118     /** GTK set flag */
1119 	t_u8 wpa_is_gtk_set;
1120 	mlan_ds_encrypt_key aes_key;
1121 #if defined(STA_SUPPORT)
1122 	/* Mgmt Frame Protection config */
1123 	mlan_ds_misc_pmfcfg pmfcfg;
1124 #endif
1125     /** WAPI IE */
1126 	t_u8 wapi_ie[256];
1127     /** WAPI IE length */
1128 	t_u8 wapi_ie_len;
1129     /** Pointer to the station table */
1130 	mlan_list_head sta_list;
1131     /** tdls pending queue */
1132 	mlan_list_head tdls_pending_txq;
1133 	t_u16 tdls_idle_time;
1134 
1135     /** MGMT IE */
1136 	custom_ie mgmt_ie[MAX_MGMT_IE_INDEX];
1137     /** mgmt frame passthru mask */
1138 	t_u32 mgmt_frame_passthru_mask;
1139     /** Advanced Encryption Standard */
1140 	t_u8 adhoc_aes_enabled;
1141     /** WMM required */
1142 	t_u8 wmm_required;
1143     /** WMM enabled */
1144 	t_u8 wmm_enabled;
1145     /** WMM qos info */
1146 	t_u8 wmm_qosinfo;
1147     /** saved WMM qos info */
1148 	t_u8 saved_wmm_qosinfo;
1149     /**host tdls uapsd support*/
1150 	t_u8 host_tdls_uapsd_support;
1151     /**host tdls channel switch support*/
1152 	t_u8 host_tdls_cs_support;
1153     /**supported channel IE len*/
1154 	t_u8 chan_supp_len;
1155     /**save channel support IE*/
1156 	t_u8 chan_supp[MAX_IE_SIZE];
1157     /**supported regulatory classl IE len*/
1158 	t_u8 supp_regulatory_class_len;
1159     /**save support channel regulatory class IE*/
1160 	t_u8 supp_regulatory_class[MAX_IE_SIZE];
1161     /**tdls cs off channel*/
1162 	t_u8 tdls_cs_channel;
1163     /** WMM related variable*/
1164 	wmm_desc_t wmm;
1165 
1166     /** Pointer to the Transmit BA stream table*/
1167 	mlan_list_head tx_ba_stream_tbl_ptr;
1168     /** Pointer to the priorities for AMSDU/AMPDU table*/
1169 	tx_aggr_t aggr_prio_tbl[MAX_NUM_TID];
1170     /** Pointer to the priorities for AMSDU/AMPDU table*/
1171 	t_u8 addba_reject[MAX_NUM_TID];
1172      /** Pointer to the priorities for AMSDU/AMPDU table*/
1173 	t_u8 ibss_ampdu[MAX_NUM_TID];
1174     /** Pointer to the priorities for AMSDU/AMPDU table*/
1175 	t_u8 ibss_addba_reject[MAX_NUM_TID];
1176     /** Struct to store ADDBA parameters */
1177 	add_ba_param_t add_ba_param;
1178     /**  user rx_win_size */
1179 	t_u32 user_rxwinsize;
1180     /** last rx_seq */
1181 	t_u16 rx_seq[MAX_NUM_TID];
1182     /** Pointer to the Receive Reordering table*/
1183 	mlan_list_head rx_reorder_tbl_ptr;
1184     /** Lock for Rx packets */
1185 	t_void *rx_pkt_lock;
1186 
1187 #ifdef STA_SUPPORT
1188     /** Buffer to store the association response for application retrieval */
1189 	t_u8 assoc_rsp_buf[MRVDRV_ASSOC_RSP_BUF_SIZE];
1190     /** Length of the data stored in assoc_rsp_buf */
1191 	t_u32 assoc_rsp_size;
1192 
1193     /** Generic IEEE IEs passed from the application to be inserted into the
1194      *    association request to firmware
1195      */
1196 	t_u8 gen_ie_buf[MRVDRV_GENIE_BUF_SIZE];
1197     /** Length of the data stored in gen_ie_buf */
1198 	t_u8 gen_ie_buf_len;
1199 
1200 	t_u8 *pcurr_bcn_buf;
1201 	t_u32 curr_bcn_size;
1202 	t_void *curr_bcn_buf_lock;
1203 
1204     /** WPS */
1205 	wps_t wps;
1206 #endif				/* STA_SUPPORT */
1207 
1208     /** function table */
1209 	mlan_operations ops;
1210     /** tx pause flag */
1211 	t_u8 tx_pause;
1212     /** Port Control mode */
1213 	t_u8 port_ctrl_mode;
1214 
1215     /** Port open flag */
1216 	t_u8 port_open;
1217 
1218     /** Port open flag state at time of association attempt */
1219 	t_u8 prior_port_status;
1220     /** Bypass TX queue */
1221 	mlan_list_head bypass_txq;
1222     /** IP address operation */
1223 	t_u32 op_code;
1224     /** IP address */
1225 	t_u8 ip_addr[IPADDR_LEN];
1226 #ifdef STA_SUPPORT
1227 	ExtCap_t ext_cap;
1228 	ExtCap_t def_ext_cap;
1229 #endif
1230     /** interface header len */
1231 	t_u8 intf_hr_len;
1232     /** Control TX AMPDU on infra link */
1233 	t_u8 txaggrctrl;
1234 #if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT)
1235 	t_void *psapriv;
1236 #endif
1237     /** rx per packet info */
1238 	t_u8 rx_pkt_info;
1239     /** received amsdu count*/
1240 	t_u32 amsdu_rx_cnt;
1241     /** received msdu count in amsdu*/
1242 	t_u32 msdu_in_rx_amsdu_cnt;
1243     /** tx amsdu count*/
1244 	t_u32 amsdu_tx_cnt;
1245     /** tx msdu count in amsdu*/
1246 	t_u32 msdu_in_tx_amsdu_cnt;
1247 } mlan_private, *pmlan_private;
1248 
1249 /** Tx BA stream table */
1250 struct _TxBAStreamTbl {
1251     /** TxBAStreamTbl previous node */
1252 	TxBAStreamTbl *pprev;
1253     /** TxBAStreamTbl next node */
1254 	TxBAStreamTbl *pnext;
1255     /** TID */
1256 	int tid;
1257     /** RA */
1258 	t_u8 ra[MLAN_MAC_ADDR_LENGTH];
1259     /** BA stream status */
1260 	baStatus_e ba_status;
1261 	t_u8 amsdu;
1262 };
1263 
1264 /** RX reorder table */
1265 typedef struct _RxReorderTbl RxReorderTbl;
1266 
1267 typedef struct {
1268     /** Timer for flushing */
1269 	t_void *timer;
1270     /** Timer set flag */
1271 	t_u8 timer_is_set;
1272     /** RxReorderTbl ptr */
1273 	RxReorderTbl *ptr;
1274     /** Priv pointer */
1275 	mlan_private *priv;
1276 } reorder_tmr_cnxt_t;
1277 
1278 /** RX reorder table */
1279 struct _RxReorderTbl {
1280     /** RxReorderTbl previous node */
1281 	RxReorderTbl *pprev;
1282     /** RxReorderTbl next node */
1283 	RxReorderTbl *pnext;
1284     /** TID */
1285 	int tid;
1286     /** TA */
1287 	t_u8 ta[MLAN_MAC_ADDR_LENGTH];
1288     /** Start window */
1289 	int start_win;
1290     /** last_seq */
1291 	int last_seq;
1292     /** Window size */
1293 	int win_size;
1294     /** Pointer to pointer to RxReorderTbl */
1295 	t_void **rx_reorder_ptr;
1296     /** Timer context */
1297 	reorder_tmr_cnxt_t timer_context;
1298     /** BA stream status */
1299 	baStatus_e ba_status;
1300 	t_u8 amsdu;
1301     /** no packet drop flag for rx_reorder_tbl */
1302 	t_u8 force_no_drop;
1303     /** flag for check start win */
1304 	t_u8 check_start_win;
1305 	/** pkt receive after BA setup */
1306 	t_u8 pkt_count;
1307     /** flush data flag */
1308 	t_u8 flush_data;
1309 };
1310 
1311 /** BSS priority node */
1312 typedef struct _mlan_bssprio_node mlan_bssprio_node;
1313 
1314 /** BSS priority node */
1315 struct _mlan_bssprio_node {
1316     /** Pointer to previous node */
1317 	mlan_bssprio_node *pprev;
1318     /** Pointer to next node */
1319 	mlan_bssprio_node *pnext;
1320     /** Pointer to priv */
1321 	pmlan_private priv;
1322 };
1323 
1324 /** BSS priority table */
1325 typedef struct _mlan_bssprio_tbl mlan_bssprio_tbl;
1326 
1327 /** BSS priority table */
1328 struct _mlan_bssprio_tbl {
1329     /** BSS priority list head */
1330 	mlan_list_head bssprio_head;
1331     /** Current priority node */
1332 	mlan_bssprio_node *bssprio_cur;
1333 };
1334 
1335 /** cmd_ctrl_node */
1336 typedef struct _cmd_ctrl_node cmd_ctrl_node;
1337 
1338 /** _cmd_ctrl_node */
1339 struct _cmd_ctrl_node {
1340     /** Pointer to previous node */
1341 	cmd_ctrl_node *pprev;
1342     /** Pointer to next node */
1343 	cmd_ctrl_node *pnext;
1344     /** Pointer to priv */
1345 	pmlan_private priv;
1346     /** Command OID for sub-command use */
1347 	t_u32 cmd_oid;
1348     /** Command flag */
1349 	t_u32 cmd_flag;
1350     /** Pointer to mlan_buffer */
1351 	mlan_buffer *cmdbuf;
1352     /** Pointer to mlan_buffer */
1353 	mlan_buffer *respbuf;
1354     /** Command parameter */
1355 	t_void *pdata_buf;
1356     /** Pointer to mlan_ioctl_req if command is from IOCTL */
1357 	t_void *pioctl_buf;
1358     /** pre_allocated mlan_buffer for cmd */
1359 	mlan_buffer *pmbuf;
1360 };
1361 
1362 /** default tdls wmm qosinfo */
1363 #define DEFAULT_TDLS_WMM_QOS_INFO        15
1364 /** default tdls sleep period */
1365 #define DEFAULT_TDLS_SLEEP_PERIOD   30
1366 
1367 /** TDLS status */
1368 typedef enum _tdlsStatus_e {
1369 	TDLS_NOT_SETUP = 0,
1370 	TDLS_SETUP_INPROGRESS,
1371 	TDLS_SETUP_COMPLETE,
1372 	TDLS_SETUP_FAILURE,
1373 	TDLS_TEAR_DOWN,
1374 	TDLS_SWITCHING_CHANNEL,
1375 	TDLS_IN_BASE_CHANNEL,
1376 	TDLS_IN_OFF_CHANNEL,
1377 } tdlsStatus_e;
1378 /** station node */
1379 typedef struct _sta_node sta_node;
1380 
1381 /** station node*/
1382 struct _sta_node {
1383     /** previous node */
1384 	sta_node *pprev;
1385     /** next node */
1386 	sta_node *pnext;
1387     /** station mac address */
1388 	t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
1389     /** wmm flag */
1390 	t_u8 is_wmm_enabled;
1391     /** 11n flag */
1392 	t_u8 is_11n_enabled;
1393     /** AMPDU STA */
1394 	t_u8 ampdu_sta[MAX_NUM_TID];
1395     /** last rx_seq */
1396 	t_u16 rx_seq[MAX_NUM_TID];
1397     /** max amsdu size */
1398 	t_u16 max_amsdu;
1399     /** HT cap */
1400 	IEEEtypes_HTCap_t HTcap;
1401     /** tdls status */
1402 	tdlsStatus_e status;
1403     /** SNR */
1404 	t_s8 snr;
1405     /** Noise Floor */
1406 	t_s8 nf;
1407     /** flag for host based tdls */
1408 	t_u8 external_tdls;
1409     /** peer capability */
1410 	t_u16 capability;
1411     /** peer support rates */
1412 	t_u8 support_rate[32];
1413     /** rate size */
1414 	t_u8 rate_len;
1415 	/*Qos capability info */
1416 	t_u8 qos_info;
1417     /** HT info in TDLS setup confirm*/
1418 	IEEEtypes_HTInfo_t HTInfo;
1419     /** peer BSSCO_20_40*/
1420 	IEEEtypes_2040BSSCo_t BSSCO_20_40;
1421 	/*Extended capability */
1422 	IEEEtypes_ExtCap_t ExtCap;
1423 	/*RSN IE */
1424 	IEEEtypes_Generic_t rsn_ie;
1425     /**Link ID*/
1426 	IEEEtypes_LinkIDElement_t link_ie;
1427     /** wapi key on off flag */
1428 	t_u8 wapi_key_on;
1429     /** tx pause status */
1430 	t_u8 tx_pause;
1431     /** station band mode */
1432 	t_u8 bandmode;
1433 #if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT)
1434 	t_void *cm_connectioninfo;
1435 #endif
1436 };
1437 
1438 /** 802.11h State information kept in the 'mlan_adapter' driver structure */
1439 typedef struct {
1440     /** Min TX Power capability sent to FW for 11h use and fw power control */
1441 	t_s8 min_tx_power_capability;
1442     /** Max TX Power capability sent to FW for 11h use and fw power control */
1443 	t_s8 max_tx_power_capability;
1444     /** User provisioned local power constraint sent in association requests */
1445 	t_s8 usr_def_power_constraint;
1446     /** Received CHANNEL_SWITCH_ANN event */
1447 	t_bool recvd_chanswann_event;
1448     /** Indicates an interface wants to enable master radar detection */
1449 	t_bool master_radar_det_enable_pending;
1450     /** Indicates an interface wants to enable slave radar detection */
1451 	t_bool slave_radar_det_enable_pending;
1452     /** Indicates whether master radar detection active in the firmware */
1453 	t_bool is_master_radar_det_active;
1454     /** Indicates whether slave radar detection active in the firmware */
1455 	t_bool is_slave_radar_det_active;
1456     /** Quiet IE */
1457 	IEEEtypes_Quiet_t quiet_ie;
1458 } wlan_11h_device_state_t;
1459 
1460 /** Enumeration for DFS Timestamp represents field */
1461 enum _dfs_timestamp_repr_e {
1462     /** Ignore entry */
1463 	DFS_TS_REPR_NOT_IN_USE = 0,
1464     /** NOP (Non-Occupancy Period) start time */
1465 	DFS_TS_REPR_NOP_START = 1,
1466     /** CAC (Channel Availability Check) completion time */
1467 	DFS_TS_REPR_CAC_COMPLETION
1468 };
1469 
1470 /** DFS Timestamp type used for marking NOP/CAC events */
1471 typedef struct _wlan_dfs_timestamp_t wlan_dfs_timestamp_t;
1472 
1473 /** DFS Timestamp type used for marking NOP/CAC events */
1474 struct _wlan_dfs_timestamp_t {
1475     /** Pointer to previous node */
1476 	wlan_dfs_timestamp_t *pprev;
1477     /** Pointer to next node */
1478 	wlan_dfs_timestamp_t *pnext;
1479     /** WLAN Channel number */
1480 	t_u8 channel;
1481     /** What this timestamp represents */
1482 	t_u8 represents;
1483     /** reserved field */
1484 	t_u16 reserved;
1485     /** timestamp - seconds */
1486 	t_u32 ts_sec;
1487     /** timestamp - microseconds */
1488 	t_u32 ts_usec;
1489 };
1490 
1491 /** DFS State information kept in the 'mlan_adapter' driver structure */
1492 typedef struct {
1493     /** Indicates whether DFS channel check is occurring in firmware */
1494 	t_bool dfs_check_pending;
1495     /** Indicates whether DFS channel check found radar */
1496 	t_bool dfs_radar_found;
1497     /** Channel radar is being checked on.  BAND_A is assumed. */
1498 	t_u8 dfs_check_channel;
1499     /** point to the priv which start the DFS check */
1500 	t_void *dfs_check_priv;
1501     /** Timestamp when we got last report,
1502      * to determine if data is old or not.
1503      */
1504 	t_u32 dfs_report_time_sec;
1505     /** List for holding dfs_timestamps for NOP/CAC events */
1506 	mlan_list_head dfs_ts_head;
1507 } wlan_dfs_device_state_t;
1508 
1509 /** Enumeration for mlan_ds_11h_radar_det_hndlg stages */
1510 enum _mlan_ds_11h_rdh_stages {
1511 	RDH_OFF = 0,
1512 	RDH_CHK_INTFS = 1,
1513 	RDH_STOP_TRAFFIC,
1514 	RDH_GET_INFO_CHANNEL,
1515 	RDH_GET_INFO_BEACON_DTIM,
1516 	RDH_SET_CUSTOM_IE,
1517 	RDH_REM_CUSTOM_IE,
1518 	RDH_STOP_INTFS,
1519 	RDH_SET_NEW_CHANNEL,
1520 	RDH_RESTART_INTFS,
1521 	RDH_RESTART_TRAFFIC
1522 };
1523 
1524 /** State info for Radar Detected Handling kept in 'mlan_adapter' */
1525 typedef struct {
1526     /** Stage (of Operation) */
1527 	t_u8 stage;
1528     /** Number of interfaces to handle */
1529 	t_u8 priv_list_count;
1530     /** Index of interface in process (used by some stages) */
1531 	t_u8 priv_curr_idx;
1532     /** Current Channel (to leave) */
1533 	t_u8 curr_channel;
1534     /** New Channel (to switch to) */
1535 	t_u8 new_channel;
1536     /** UAP band_config */
1537 	Band_Config_t uap_band_cfg;
1538     /** BEACON*DTIM period (in msec; max of STA/UAP) */
1539 	t_u16 max_bcn_dtim_ms;
1540     /** tx block flag */
1541 	t_u8 tx_block;
1542     /** List of interfaces to handle */
1543 	mlan_private *priv_list[MLAN_MAX_BSS_NUM];
1544 } wlan_radar_det_hndlg_state_t;
1545 
1546 #ifdef DFS_TESTING_SUPPORT
1547 /** DFS/RDH testing exception settings kept in 'mlan_adapter' */
1548 typedef struct {
1549     /** user-configured CAC period (in msec) */
1550 	t_u32 user_cac_period_msec;
1551     /** user-configured NOP period (in sec) */
1552 	t_u16 user_nop_period_sec;
1553     /** user-configured skip channel change on radar */
1554 	t_bool no_channel_change_on_radar;
1555     /** user-configured new channel to change to on radar */
1556 	t_u8 fixed_new_channel_on_radar;
1557 } wlan_dfs_testing_settings_t;
1558 #endif /* DFS_SUPPORT_TESTING */
1559 
1560 /**
1561  * @brief Driver measurement state held in 'mlan_adapter' structure
1562  *
1563  *  Used to record a measurement request that the driver is pending on
1564  *    the result (received measurement report).
1565  */
1566 typedef struct {
1567     /**
1568      * Dialog token of a pending measurement request/report.  Used to
1569      *   block execution while waiting for the specific dialog token
1570      */
1571 	t_u8 meas_rpt_pend_on;
1572 
1573     /**
1574      * Measurement report received from the firmware that we were pending on
1575      */
1576 	HostCmd_DS_MEASUREMENT_REPORT meas_rpt_returned;
1577 
1578 } wlan_meas_state_t;
1579 
1580 #if defined(SDIO_MULTI_PORT_TX_AGGR) || defined(SDIO_MULTI_PORT_RX_AGGR)
1581 /**
1582  *  @brief Link buffer into aggregate head buffer
1583  *
1584  *  @param pmbuf_aggr	Pointer to aggregation buffer
1585  *  @param pmbuf		Pointer to buffer to copy
1586  */
1587 static inline t_void
wlan_link_buf_to_aggr(pmlan_buffer pmbuf_aggr,pmlan_buffer pmbuf)1588 wlan_link_buf_to_aggr(pmlan_buffer pmbuf_aggr, pmlan_buffer pmbuf)
1589 {
1590 	/* link new buf at end of list */
1591 	pmbuf->pnext = pmbuf_aggr;
1592 	pmbuf->pprev = pmbuf_aggr->pprev;
1593 	pmbuf->pparent = pmbuf_aggr;
1594 	pmbuf_aggr->pprev->pnext = pmbuf;
1595 	pmbuf_aggr->pprev = pmbuf;
1596 	pmbuf_aggr->use_count++;
1597 }
1598 #endif
1599 
1600 #ifdef SDIO_MULTI_PORT_TX_AGGR
1601 /** data structure for SDIO MPA TX */
1602 typedef struct _sdio_mpa_tx {
1603 	/** allocated buf for tx aggreation */
1604 	t_u8 *head_ptr;
1605 	/** multiport tx aggregation buffer pointer */
1606 	t_u8 *buf;
1607 	/** multiport tx aggregation buffer length */
1608 	t_u32 buf_len;
1609 	/** multiport tx aggregation packet count */
1610 	t_u32 pkt_cnt;
1611 	/** multiport tx aggregation ports */
1612 	t_u32 ports;
1613 	/** multiport tx aggregation starting port */
1614 	t_u16 start_port;
1615 	/** multiport tx aggregation enable/disable flag */
1616 	t_u8 enabled;
1617 	/** multiport tx aggregation buffer size */
1618 	t_u32 buf_size;
1619 	/** multiport tx aggregation pkt aggr limit */
1620 	t_u32 pkt_aggr_limit;
1621 	/** multiport write info */
1622 	t_u16 mp_wr_info[SDIO_MP_AGGR_DEF_PKT_LIMIT];
1623 	/** multiport rx aggregation mbuf array */
1624 	pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
1625 } sdio_mpa_tx;
1626 #endif
1627 
1628 #ifdef SDIO_MULTI_PORT_RX_AGGR
1629 /** data structure for SDIO MPA RX */
1630 typedef struct _sdio_mpa_rx {
1631 	/** allocated buf for rx aggreation */
1632 	t_u8 *head_ptr;
1633 	/** multiport rx aggregation buffer pointer */
1634 	t_u8 *buf;
1635 	/** multiport rx aggregation buffer length */
1636 	t_u32 buf_len;
1637 	/** multiport rx aggregation packet count */
1638 	t_u32 pkt_cnt;
1639 	/** multiport rx aggregation ports */
1640 	t_u32 ports;
1641 	/** multiport rx aggregation starting port */
1642 	t_u16 start_port;
1643 
1644 	/** multiport rx aggregation mbuf array */
1645 	pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
1646 	/** multiport rx aggregation pkt len array */
1647 	t_u32 len_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT];
1648 
1649 	/** multiport rx aggregation enable/disable flag */
1650 	t_u8 enabled;
1651 	/** multiport rx aggregation buffer size */
1652 	t_u32 buf_size;
1653 	/** multiport rx aggregation pkt aggr limit */
1654 	t_u32 pkt_aggr_limit;
1655 } sdio_mpa_rx;
1656 #endif /* SDIO_MULTI_PORT_RX_AGGR */
1657 
1658 /** mlan_init_para structure */
1659 typedef struct _mlan_init_para {
1660 #ifdef MFG_CMD_SUPPORT
1661     /** MFG mode */
1662 	t_u32 mfg_mode;
1663 #endif
1664     /** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */
1665 	t_u32 int_mode;
1666     /** GPIO interrupt pin number */
1667 	t_u32 gpio_pin;
1668 #ifdef SDIO_MULTI_PORT_TX_AGGR
1669     /** SDIO MPA Tx */
1670 	t_u32 mpa_tx_cfg;
1671 #endif
1672 #ifdef SDIO_MULTI_PORT_RX_AGGR
1673     /** SDIO MPA Rx */
1674 	t_u32 mpa_rx_cfg;
1675 #endif
1676     /** Auto deep sleep */
1677 	t_u32 auto_ds;
1678     /** IEEE PS mode */
1679 	t_u32 ps_mode;
1680     /** Max Tx buffer size */
1681 	t_u32 max_tx_buf;
1682     /** 802.11d configuration */
1683 	t_u32 cfg_11d;
1684     /** 802.11H DFS Master Radar Detect */
1685 	t_u32 dfs_master_radar_det_en;
1686     /** 802.11H DFS Slave Radar Detect */
1687 	t_u32 dfs_slave_radar_det_en;
1688     /** dev cap mask */
1689 	t_u32 dev_cap_mask;
1690     /** oob independent reset mode */
1691 	t_u32 indrstcfg;
1692 	t_u32 drcs_chantime_mode;
1693 	t_bool fw_region;
1694 } mlan_init_para, *pmlan_init_para;
1695 
1696 /** Adapter data structure for MLAN */
1697 typedef struct _mlan_adapter {
1698     /** MOAL handle structure */
1699 	t_void *pmoal_handle;
1700     /** BSS Attributes */
1701 	mlan_bss_attr bss_attr[MLAN_MAX_BSS_NUM];
1702     /** Private pointer */
1703 	pmlan_private priv[MLAN_MAX_BSS_NUM];
1704     /** Total number of Priv number */
1705 	t_u8 priv_num;
1706     /** Priority table for bss */
1707 	mlan_bssprio_tbl bssprio_tbl[MLAN_MAX_BSS_NUM];
1708     /** Callback table */
1709 	mlan_callbacks callbacks;
1710     /** Init parameters */
1711 	mlan_init_para init_para;
1712     /** mlan_lock for init/shutdown */
1713 	t_void *pmlan_lock;
1714     /** main_proc_lock for main_process */
1715 	t_void *pmain_proc_lock;
1716     /** mlan_processing */
1717 	t_u32 mlan_processing;
1718     /** main_process_cnt */
1719 	t_u32 main_process_cnt;
1720     /** mlan_rx_processing */
1721 	t_u32 mlan_rx_processing;
1722     /** rx_proc_lock for main_rx_process */
1723 	t_void *prx_proc_lock;
1724     /** rx work enable flag */
1725 	t_u8 rx_work_flag;
1726 	/* number of rx pkts queued */
1727 	t_u16 rx_pkts_queued;
1728     /** more task flag */
1729 	t_u32 more_task_flag;
1730     /** delay task flag */
1731 	t_u32 delay_task_flag;
1732     /** Max tx buf size */
1733 	t_u16 max_tx_buf_size;
1734     /** Tx buf size */
1735 	t_u16 tx_buf_size;
1736     /** current tx buf size in fw */
1737 	t_u16 curr_tx_buf_size;
1738     /** flush data */
1739 	t_u8 flush_data;
1740     /** IO port */
1741 	t_u32 ioport;
1742 
1743     /** STATUS variables */
1744 	WLAN_HARDWARE_STATUS hw_status;
1745     /** PnP SUPPORT */
1746 	t_u8 surprise_removed;
1747 
1748     /** ECSA support */
1749 	t_u8 ecsa_enable;
1750 
1751     /** Get log support */
1752 	t_u8 getlog_enable;
1753 
1754     /** Radio on flag */
1755 	t_u16 radio_on;
1756 
1757     /** Firmware release number */
1758 	t_u32 fw_release_number;
1759     /** firmware version */
1760 	t_u8 fw_ver;
1761     /** firmware minor version */
1762 	t_u8 fw_min_ver;
1763     /** uap firmware version */
1764 	t_u8 uap_fw_ver;
1765     /** mac address retrun from get_hw_spec */
1766 	t_u8 permanent_addr[MLAN_MAC_ADDR_LENGTH];
1767     /** Number of antenna used */
1768 	t_u16 number_of_antenna;
1769     /** antenna info */
1770 	t_u8 antinfo;
1771     /** Firmware capability information */
1772 	t_u32 fw_cap_info;
1773     /** pint_lock for interrupt handling */
1774 	t_void *pint_lock;
1775     /** Interrupt status */
1776 	t_u8 sdio_ireg;
1777     /** number of interrupt receive */
1778 	t_u32 num_of_irq;
1779     /** max SDIO single port tx size */
1780 	t_u16 max_sp_tx_size;
1781     /** max SDIO single port rx size */
1782 	t_u16 max_sp_rx_size;
1783     /** SDIO multiple port read bitmap */
1784 	t_u32 mp_rd_bitmap;
1785     /** SDIO multiple port write bitmap */
1786 	t_u32 mp_wr_bitmap;
1787     /** SDIO end port from txbufcfg */
1788 	t_u16 mp_end_port;
1789     /** SDIO port mask calculated based on txbufcfg end port */
1790 	t_u32 mp_data_port_mask;
1791     /** Current available port for read */
1792 	t_u8 curr_rd_port;
1793     /** Current available port for write */
1794 	t_u8 curr_wr_port;
1795 	/** FW update port number */
1796 	t_u32 mp_update[SDIO_MP_AGGR_DEF_PKT_LIMIT * 2];
1797 	/** Invalid port update count */
1798 	t_u32 mp_invalid_update;
1799     /** Array to store values of SDIO multiple port group registers */
1800 	t_u8 *mp_regs;
1801     /** allocated buf to read SDIO multiple port group registers */
1802 	t_u8 *mp_regs_buf;
1803     /** buffer to handle receive packet */
1804 	t_u8 *rx_buf;
1805     /** allocated buf for receive */
1806 	t_u8 *rx_buffer;
1807 #if defined(SDIO_MULTI_PORT_TX_AGGR) || defined(SDIO_MULTI_PORT_RX_AGGR)
1808 	/* see blk_queue_max_segment_size */
1809 	t_u32 max_seg_size;
1810 	/* see blk_queue_max_segments */
1811 	t_u16 max_segs;
1812 #endif
1813 
1814 #ifdef SDIO_MULTI_PORT_TX_AGGR
1815 	/** data structure for SDIO MPA TX */
1816 	sdio_mpa_tx mpa_tx;
1817     /** packet number for tx aggr */
1818 	t_u32 mpa_tx_count[SDIO_MP_AGGR_DEF_PKT_LIMIT];
1819     /** no more packets count*/
1820 	t_u32 mpa_sent_last_pkt;
1821     /** no write_ports count */
1822 	t_u32 mpa_sent_no_ports;
1823     /** last wr_bitmap from FW */
1824 	t_u32 last_recv_wr_bitmap;
1825     /** last mp_wr_bitmap */
1826 	t_u32 last_mp_wr_bitmap[SDIO_MP_DBG_NUM];
1827     /** last ports for cmd53 write data */
1828 	t_u32 last_mp_wr_ports[SDIO_MP_DBG_NUM];
1829     /** last length for cmd53 write data */
1830 	t_u32 last_mp_wr_len[SDIO_MP_DBG_NUM];
1831     /** length info for cmd53 write data */
1832 	t_u16 last_mp_wr_info[SDIO_MP_DBG_NUM * SDIO_MP_AGGR_DEF_PKT_LIMIT];
1833     /** last curr_wr_port */
1834 	t_u8 last_curr_wr_port[SDIO_MP_DBG_NUM];
1835 
1836     /** buffer for mp debug */
1837 	t_u8 *mpa_buf;
1838     /** length info for mp buf size */
1839 	t_u32 mpa_buf_size;
1840 
1841     /** last mp_index */
1842 	t_u8 last_mp_index;
1843 #endif				/* SDIO_MULTI_PORT_TX_AGGR */
1844 
1845 #ifdef SDIO_MULTI_PORT_RX_AGGR
1846 	/** data structure for SDIO MPA RX */
1847 	sdio_mpa_rx mpa_rx;
1848     /** packet number for tx aggr */
1849 	t_u32 mpa_rx_count[SDIO_MP_AGGR_DEF_PKT_LIMIT];
1850 #endif				/* SDIO_MULTI_PORT_RX_AGGR */
1851 
1852     /** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */
1853 	t_u32 int_mode;
1854     /** GPIO interrupt pin number */
1855 	t_u32 gpio_pin;
1856 
1857     /** Event cause */
1858 	t_u32 event_cause;
1859     /** Event buffer */
1860 	pmlan_buffer pmlan_buffer_event;
1861     /** Upload length */
1862 	t_u32 upld_len;
1863     /** Upload buffer*/
1864 	t_u8 upld_buf[WLAN_UPLD_SIZE];
1865     /** Data sent:
1866      *       TRUE - Data is sent to fw, no Tx Done received
1867      *       FALSE - Tx done received for previous Tx
1868      */
1869 	t_u8 data_sent;
1870     /** CMD sent:
1871      *       TRUE - CMD is sent to fw, no CMD Done received
1872      *       FALSE - CMD done received for previous CMD
1873      */
1874 	t_u8 cmd_sent;
1875     /** CMD Response received:
1876      *       TRUE - CMD is response is received from fw, and yet to process
1877      *       FALSE - No cmd response to process
1878      */
1879 	t_u8 cmd_resp_received;
1880     /** Event received:
1881      *       TRUE - Event received from fw, and yet to process
1882      *       FALSE - No events to process
1883      */
1884 	t_u8 event_received;
1885 
1886     /** Data received:
1887      *       TRUE - Data received from fw
1888      *       FALSE - No Data received
1889      */
1890 	t_u8 data_received;
1891 
1892     /** Command-related variables */
1893     /** Command sequence number */
1894 	t_u16 seq_num;
1895     /** Command controller nodes */
1896 	cmd_ctrl_node *cmd_pool;
1897     /** Current Command */
1898 	cmd_ctrl_node *curr_cmd;
1899     /** mlan_lock for command */
1900 	t_void *pmlan_cmd_lock;
1901     /** Number of command timeouts */
1902 	t_u32 num_cmd_timeout;
1903     /** Last init fw command id */
1904 	t_u16 last_init_cmd;
1905     /** Command timer */
1906 	t_void *pmlan_cmd_timer;
1907     /** Command timer set flag */
1908 	t_u8 cmd_timer_is_set;
1909     /** time stamp for command dnld */
1910 	t_u32 dnld_cmd_in_secs;
1911 
1912     /** Command Queues */
1913     /** Free command buffers */
1914 	mlan_list_head cmd_free_q;
1915     /** Pending command buffers */
1916 	mlan_list_head cmd_pending_q;
1917     /** Command queue for scanning */
1918 	mlan_list_head scan_pending_q;
1919     /** ioctl pending queue */
1920 	mlan_list_head ioctl_pending_q;
1921     /** pending_ioctl flag */
1922 	t_u8 pending_ioctl;
1923     /** mlan_processing */
1924 	t_u32 scan_processing;
1925     /** firmware support for roaming*/
1926 	t_u8 fw_roaming;
1927     /** User set passphrase*/
1928 	t_u8 userset_passphrase;
1929     /** ext_scan enh support flag */
1930 	t_u8 ext_scan_enh;
1931     /** scan type: 0 legacy, 1: enhance scan*/
1932 	t_u8 ext_scan_type;
1933     /** ext scan timeout */
1934 	t_u8 ext_scan_timeout;
1935     /** coex scan flag */
1936 	t_u8 coex_scan;
1937     /** coex min scan time */
1938 	t_u8 coex_min_scan_time;
1939     /** coex max scan time */
1940 	t_u8 coex_max_scan_time;
1941     /** coex win size flag */
1942 	t_u8 coex_win_size;
1943     /** coex amdpdu tx win size */
1944 	t_u8 coex_tx_win_size;
1945     /** coex ampdu rx win size */
1946 	t_u8 coex_rx_win_size;
1947     /** Region code */
1948 	t_u16 region_code;
1949     /** Region Channel data */
1950 	region_chan_t region_channel[MAX_REGION_CHANNEL_NUM];
1951     /** CFP table code for 2.4GHz */
1952 	t_u8 cfp_code_bg;
1953     /** CFP table code for 5GHz */
1954 	t_u8 cfp_code_a;
1955 	wmm_ac_parameters_t ac_params[MAX_AC_QUEUES];
1956 #ifdef STA_SUPPORT
1957     /** Universal Channel data */
1958 	region_chan_t universal_channel[MAX_REGION_CHANNEL_NUM];
1959     /** Parsed region channel */
1960 	parsed_region_chan_11d_t parsed_region_chan;
1961 #endif				/* STA_SUPPORT */
1962     /** 11D and Domain Regulatory Data */
1963 	wlan_802_11d_domain_reg_t domain_reg;
1964     /** Country Code */
1965 	t_u8 country_code[COUNTRY_CODE_LEN];
1966     /** FSM variable for 11h support */
1967 	wlan_11h_device_state_t state_11h;
1968     /** FSM variable for DFS support */
1969 	wlan_dfs_device_state_t state_dfs;
1970     /** FSM variable for RDH support */
1971 	wlan_radar_det_hndlg_state_t state_rdh;
1972     /** variable to configure dfs channel switch count */
1973 	t_s8 dfs_cs_count;
1974 #ifdef DFS_TESTING_SUPPORT
1975     /** User configured settings for DFS testing */
1976 	wlan_dfs_testing_settings_t dfs_test_params;
1977 #endif
1978     /** FSM variable for MEAS support */
1979 	wlan_meas_state_t state_meas;
1980     /** Scan table */
1981 	BSSDescriptor_t *pscan_table;
1982     /** scan age in secs */
1983 	t_u32 age_in_secs;
1984     /** Active scan for hidden ssid triggered */
1985 	t_u8 active_scan_triggered;
1986     /** channel statstics */
1987 	ChanStatistics_t *pchan_stats;
1988     /** Number of records in the chan_stats */
1989 	t_u32 num_in_chan_stats;
1990     /** index of chan stats */
1991 	t_u32 idx_chan_stats;
1992 	t_u8 bgscan_reported;
1993 
1994     /** Number of records in the scan table */
1995 	t_u32 num_in_scan_table;
1996     /** Scan probes */
1997 	t_u16 scan_probes;
1998 
1999     /** Scan type */
2000 	t_u8 scan_type;
2001     /** Scan mode */
2002 	t_u32 scan_mode;
2003     /** Specific scan time */
2004 	t_u16 specific_scan_time;
2005     /** Active scan time */
2006 	t_u16 active_scan_time;
2007     /** Passive scan time */
2008 	t_u16 passive_scan_time;
2009     /** Scan block flag */
2010 	t_u8 scan_block;
2011     /** Extended scan or legacy scan */
2012 	t_u8 ext_scan;
2013 	t_u16 bcn_buf_size;
2014     /** Beacon buffer */
2015 	t_u8 *bcn_buf;
2016     /** Pointer to valid beacon buffer end */
2017 	t_u8 *pbcn_buf_end;
2018     /** allocate fixed scan beacon buffer size*/
2019 	t_u32 fixed_beacon_buffer;
2020 
2021     /** F/W supported bands */
2022 	t_u8 fw_bands;
2023     /** User selected band to start adhoc network */
2024 	t_u8 adhoc_start_band;
2025     /** User selected bands */
2026 	t_u8 config_bands;
2027     /** Pointer to channel list last sent to the firmware for scanning */
2028 	ChanScanParamSet_t *pscan_channels;
2029 
2030     /** Tx lock flag */
2031 	t_u8 tx_lock_flag;
2032     /** Rx lock flag */
2033 	t_u8 rx_lock_flag;
2034     /** main lock flag */
2035 	t_u8 main_lock_flag;
2036 	/** Multi channel status */
2037 	t_u8 mc_status;
2038 
2039     /** sleep_params_t */
2040 	sleep_params_t sleep_params;
2041     /** sleep_period_t (Enhanced Power Save) */
2042 	sleep_period_t sleep_period;
2043     /** saved sleep_period_t (Enhanced Power Save) */
2044 	sleep_period_t saved_sleep_period;
2045 
2046     /** Power Save mode */
2047     /**
2048       * Wlan802_11PowerModeCAM = disable
2049       * Wlan802_11PowerModePSP = enable
2050       */
2051 	t_u16 ps_mode;
2052     /** Power Save state */
2053 	t_u32 ps_state;
2054     /** Need to wakeup flag */
2055 	t_u8 need_to_wakeup;
2056 
2057     /** Multiple DTIM */
2058 	t_u16 multiple_dtim;
2059     /** Local listen interval */
2060 	t_u16 local_listen_interval;
2061     /** Null packet interval */
2062 	t_u16 null_pkt_interval;
2063 
2064     /** IEEE ps inactivity timout value */
2065 	t_u16 inact_tmo;
2066     /** Power save confirm sleep command buffer */
2067 	pmlan_buffer psleep_cfm;
2068     /** Beacon miss timeout */
2069 	t_u16 bcn_miss_time_out;
2070 
2071     /** AdHoc awake period */
2072 	t_u16 adhoc_awake_period;
2073 
2074     /** Firmware wakeup method */
2075 	t_u16 fw_wakeup_method;
2076     /** Firmware wakeup GPIO pin */
2077 	t_u8 fw_wakeup_gpio_pin;
2078     /** Deep Sleep flag */
2079 	t_u8 is_deep_sleep;
2080     /** Idle time */
2081 	t_u16 idle_time;
2082     /** Auto Deep Sleep enabled at init time */
2083 	t_u8 init_auto_ds;
2084 
2085     /** delay null pkt flag */
2086 	t_u8 delay_null_pkt;
2087     /** Delay to PS in milliseconds */
2088 	t_u16 delay_to_ps;
2089     /** Enhanced PS mode */
2090 	t_u16 enhanced_ps_mode;
2091     /** Device wakeup required flag */
2092 	t_u8 pm_wakeup_card_req;
2093 
2094     /** Gen NULL pkg */
2095 	t_u16 gen_null_pkt;
2096 
2097     /** PPS/UAPSD mode flag */
2098 	t_u16 pps_uapsd_mode;
2099     /** Number of wakeup tries */
2100 	t_u32 pm_wakeup_fw_try;
2101     /** time stamp when host try to wake up firmware */
2102 	t_u32 pm_wakeup_in_secs;
2103 
2104     /** Host Sleep configured flag */
2105 	t_u8 is_hs_configured;
2106     /** Host Sleep configuration */
2107 	hs_config_param hs_cfg;
2108     /** Host Sleep activated flag */
2109 	t_u8 hs_activated;
2110     /** Event body */
2111 	t_u8 event_body[MAX_EVENT_SIZE];
2112     /** 802.11n device capabilities */
2113 	t_u32 hw_dot_11n_dev_cap;
2114     /** Device support for MIMO abstraction of MCSs */
2115 	t_u8 hw_dev_mcs_support;
2116 #ifdef STA_SUPPORT
2117     /** Enable 11n support for adhoc start */
2118 	t_u8 adhoc_11n_enabled;
2119     /** Adhoc Secondary Channel Bandwidth */
2120 	t_u8 chan_bandwidth;
2121 #endif				/* STA_SUPPORT */
2122 
2123     /** max mgmt IE index in device */
2124 	t_u16 max_mgmt_ie_index;
2125     /** Head of Rx data queue */
2126 	mlan_list_head rx_data_queue;
2127 #ifdef MFG_CMD_SUPPORT
2128 	t_u32 mfg_mode;
2129 #endif
2130     /** Debug */
2131 	wlan_dbg dbg;
2132 
2133     /** RX pending for forwarding packets */
2134 	mlan_scalar pending_bridge_pkts;
2135 
2136 #ifdef STA_SUPPORT
2137     /** ARP filter buffer */
2138 	t_u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
2139     /** ARP filter buffer size */
2140 	t_u32 arp_filter_size;
2141 #endif				/* STA_SUPPORT */
2142     /** Minimum delay between HsActive and HostWake (in msec) */
2143 	t_u16 min_wake_holdoff;
2144     /** Host sleep wake interval(in msec) */
2145 	t_u32 hs_wake_interval;
2146     /** Host sleep inactivity timeout (in msec) */
2147 	t_u32 hs_inactivity_timeout;
2148     /** Parameter type for indication gpio*/
2149 	t_u8 param_type_ind;
2150     /** GPIO pin for indication wakeup source */
2151 	t_u32 ind_gpio;
2152     /** Level on ind_gpio pin for indication normal wakeup source */
2153 	t_u32 level;
2154     /** Parameter type for extend hscfg*/
2155 	t_u8 param_type_ext;
2156     /** Events that will be forced ignore */
2157 	t_u32 event_force_ignore;
2158     /** Events that will use extend gap to inform host*/
2159 	t_u32 event_use_ext_gap;
2160     /** Extend gap*/
2161 	t_u8 ext_gap;
2162     /** GPIO wave level for extend hscfg */
2163 	t_u8 gpio_wave;
2164     /** management frame wakeup filter config */
2165 	mlan_mgmt_frame_wakeup mgmt_filter[MAX_MGMT_FRAME_FILTER];
2166 
2167     /** Bypass TX queue pkt count  */
2168 	t_u16 bypass_pkt_count;
2169 #if defined(STA_SUPPORT)
2170     /** warm-reset IOCTL request buffer pointer */
2171 	pmlan_ioctl_req pwarm_reset_ioctl_req;
2172 #endif
2173     /** SCAN IOCTL request buffer pointer */
2174 	pmlan_ioctl_req pscan_ioctl_req;
2175     /** DPD data pointer */
2176 	t_u8 *pdpd_data;
2177     /** DPD data length  */
2178 	t_u32 dpd_data_len;
2179 	/** region txpowerlimit cfg data buf pointer */
2180 	t_u8 *ptxpwr_data;
2181 	/** region txpowerlimit cfg data len */
2182 	t_u32 txpwr_data_len;
2183     /** Cal data pointer */
2184 	t_u8 *pcal_data;
2185     /** Cal data length  */
2186 	t_u32 cal_data_len;
2187     /** tdls status */
2188 	/* TDLS_NOT_SETUP|TDLS_SWITCHING_CHANNEL|TDLS_IN_BASE_CHANNEL|TDLS_IN_SWITCH_CHANNEL */
2189 	tdlsStatus_e tdls_status;
2190     /** NetMon enabled */
2191 	t_u32 enable_net_mon;
2192 
2193     /** Control coex RX window size configuration */
2194 	t_u8 coex_rx_winsize;
2195     /** DFS repeater */
2196 	t_bool dfs_repeater;
2197     /** DFSr channel */
2198 	t_u32 dfsr_channel;
2199     /** multi channel policy */
2200 	t_bool mc_policy;
2201 	/** flag for sdio rx aggr */
2202 	t_bool sdio_rx_aggr_enable;
2203 	/** fw rx block size */
2204 	t_u16 sdio_rx_block_size;
2205     /**channel param band config */
2206 	t_u8 chanrpt_param_bandcfg;
2207 	/** d1 time */
2208 	t_u64 d1;
2209 	 /** d2 time */
2210 	t_u64 d2;
2211      /** host bbu clock delta */
2212 	t_u64 host_bbu_clk_delta;
2213     /** maximum station connection */
2214 	t_u8 max_sta_conn;
2215 	otp_region_info_t *otp_region;
2216 	chan_freq_power_t *cfp_otp_bg;
2217 	t_u8 *tx_power_table_bg;
2218 	t_u32 tx_power_table_bg_size;
2219 	chan_freq_power_t *cfp_otp_a;
2220 	t_u8 *tx_power_table_a;
2221 	t_u32 tx_power_table_a_size;
2222 } mlan_adapter, *pmlan_adapter;
2223 
2224 /** Ethernet packet type for EAPOL */
2225 #define MLAN_ETHER_PKT_TYPE_EAPOL	(0x888E)
2226 /** Ethernet packet type for WAPI */
2227 #define MLAN_ETHER_PKT_TYPE_WAPI	(0x88B4)
2228 /** Ethernet packet type offset */
2229 #define MLAN_ETHER_PKT_TYPE_OFFSET	(12)
2230 
2231 mlan_status wlan_cmd_net_monitor(IN HostCmd_DS_COMMAND *cmd,
2232 				 IN t_u16 cmd_action, IN t_void *pdata_buf);
2233 
2234 mlan_status wlan_ret_net_monitor(IN pmlan_private pmpriv,
2235 				 IN HostCmd_DS_COMMAND *resp,
2236 				 IN mlan_ioctl_req *pioctl_buf);
2237 
2238 mlan_status wlan_misc_ioctl_net_monitor(IN pmlan_adapter pmadapter,
2239 					IN pmlan_ioctl_req pioctl_req);
2240 
2241 void wlan_rxpdinfo_to_radiotapinfo(pmlan_private priv,
2242 				   RxPD *prx_pd, radiotap_info * prt_info);
2243 
2244 mlan_status wlan_init_lock_list(IN pmlan_adapter pmadapter);
2245 mlan_status wlan_init_priv_lock_list(IN pmlan_adapter pmadapter,
2246 				     t_u8 start_index);
2247 t_void wlan_free_lock_list(IN pmlan_adapter pmadapter);
2248 mlan_status wlan_init_timer(IN pmlan_adapter pmadapter);
2249 t_void wlan_free_timer(IN pmlan_adapter pmadapter);
2250 
2251 /* Function prototype */
2252 /** Download firmware */
2253 mlan_status wlan_dnld_fw(IN pmlan_adapter pmadapter, IN pmlan_fw_image pmfw);
2254 
2255 /** Initialize firmware */
2256 mlan_status wlan_init_fw(IN pmlan_adapter pmadapter);
2257 
2258 /** get hw spec complete */
2259 mlan_status wlan_get_hw_spec_complete(IN pmlan_adapter pmadapter);
2260 
2261 /** Initialize firmware complete */
2262 mlan_status wlan_init_fw_complete(IN pmlan_adapter pmadapter);
2263 
2264 /** Shutdown firmware complete */
2265 mlan_status wlan_shutdown_fw_complete(IN pmlan_adapter pmadapter);
2266 
2267 /** Receive event */
2268 mlan_status wlan_recv_event(pmlan_private priv,
2269 			    mlan_event_id event_id, t_void *pmevent);
2270 
2271 /** Initialize mlan_adapter structure */
2272 t_void wlan_init_adapter(IN pmlan_adapter pmadapter);
2273 
2274 /** Initialize mlan_private structure */
2275 mlan_status wlan_init_priv(IN pmlan_private priv);
2276 
2277 /** Process event */
2278 mlan_status wlan_process_event(pmlan_adapter pmadapter);
2279 
2280 /** Prepare command */
2281 mlan_status wlan_prepare_cmd(IN pmlan_private priv,
2282 			     IN t_u16 cmd_no,
2283 			     IN t_u16 cmd_action,
2284 			     IN t_u32 cmd_oid,
2285 			     IN t_void *pioctl_buf, IN t_void *pdata_buf);
2286 
2287 /** cmd timeout handler */
2288 t_void wlan_cmd_timeout_func(t_void *function_context);
2289 /** process host cmd */
2290 mlan_status wlan_misc_ioctl_host_cmd(IN pmlan_adapter pmadapter,
2291 				     IN pmlan_ioctl_req pioctl_req);
2292 /** process init/shutdown cmd*/
2293 mlan_status wlan_misc_ioctl_init_shutdown(IN pmlan_adapter pmadapter,
2294 					  IN pmlan_ioctl_req pioctl_req);
2295 /** process debug info */
2296 mlan_status wlan_get_info_debug_info(IN pmlan_adapter pmadapter,
2297 				     IN pmlan_ioctl_req pioctl_req);
2298 
2299 #if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
2300 /** Set/Get BSS role */
2301 mlan_status wlan_bss_ioctl_bss_role(IN pmlan_adapter pmadapter,
2302 				    IN pmlan_ioctl_req pioctl_req);
2303 #endif
2304 
2305 mlan_status wlan_misc_get_correlated_time(IN pmlan_adapter pmadapter,
2306 					  IN pmlan_ioctl_req pioctl_req);
2307 mlan_status wlan_set_ewpa_mode(mlan_private *priv, mlan_ds_passphrase *psec_pp);
2308 mlan_status wlan_find_bss(mlan_private *pmpriv, pmlan_ioctl_req pioctl_req);
2309 
2310 /* block main process */
2311 void mlan_block_main_process(mlan_adapter *pmadapter, t_u8 block);
2312 /* block rx process */
2313 void mlan_block_rx_process(mlan_adapter *pmadapter, t_u8 block);
2314 /** check pending command */
2315 int wlan_check_pending_cmd(mlan_adapter *pmadapter);
2316 /** Allocate memory for adapter structure members */
2317 mlan_status wlan_allocate_adapter(pmlan_adapter pmadapter);
2318 /** Free adapter */
2319 t_void wlan_free_adapter(pmlan_adapter pmadapter);
2320 /** Free priv */
2321 t_void wlan_free_priv(mlan_private *pmpriv);
2322 /** Allocate command buffer */
2323 mlan_status wlan_alloc_cmd_buffer(IN mlan_adapter *pmadapter);
2324 /** Free command buffer */
2325 mlan_status wlan_free_cmd_buffer(IN mlan_adapter *pmadapter);
2326 /** Request command lock */
2327 t_void wlan_request_cmd_lock(mlan_adapter *pmadapter);
2328 /** Release command lock */
2329 t_void wlan_release_cmd_lock(mlan_adapter *pmadapter);
2330 #ifdef STA_SUPPORT
2331 /** Flush the scan pending queue */
2332 t_void wlan_flush_scan_queue(pmlan_adapter pmadapter);
2333 mlan_status wlan_cancel_pending_scan_cmd(pmlan_adapter pmadapter,
2334 					 pmlan_ioctl_req pioctl_req);
2335 #endif
2336 /**Cancel pending command */
2337 t_void wlan_cancel_all_pending_cmd(pmlan_adapter pmadapter);
2338 /**Cancel pending ioctl */
2339 t_void wlan_cancel_pending_ioctl(pmlan_adapter pmadapter,
2340 				 pmlan_ioctl_req pioctl_req);
2341 /**Cancel bss pending ioctl */
2342 t_void wlan_cancel_bss_pending_cmd(pmlan_adapter pmadapter, t_u32 bss_index);
2343 
2344 /** Insert command to free queue */
2345 t_void wlan_insert_cmd_to_free_q(IN mlan_adapter *pmadapter,
2346 				 IN cmd_ctrl_node *pcmd_node);
2347 
2348 /** Insert command to pending queue */
2349 t_void wlan_insert_cmd_to_pending_q(IN mlan_adapter *pmadapter,
2350 				    IN cmd_ctrl_node *pcmd_node,
2351 				    IN t_u32 addtail);
2352 
2353 /** Execute next command */
2354 mlan_status wlan_exec_next_cmd(mlan_adapter *pmadapter);
2355 /** Proecess command response */
2356 mlan_status wlan_process_cmdresp(mlan_adapter *pmadapter);
2357 /** Handle received packet, has extra handling for aggregate packets */
2358 mlan_status wlan_handle_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
2359 /** Process transmission */
2360 mlan_status wlan_process_tx(pmlan_private priv, pmlan_buffer pmbuf,
2361 			    mlan_tx_param *tx_param);
2362 /** Transmit a null data packet */
2363 mlan_status wlan_send_null_packet(pmlan_private priv, t_u8 flags);
2364 
2365 #if defined(SDIO_MULTI_PORT_TX_AGGR) || defined(SDIO_MULTI_PORT_RX_AGGR)
2366 mlan_status wlan_alloc_sdio_mpa_buffers(IN mlan_adapter *pmadapter,
2367 					t_u32 mpa_tx_buf_size,
2368 					t_u32 mpa_rx_buf_size);
2369 
2370 mlan_status wlan_free_sdio_mpa_buffers(IN mlan_adapter *pmadapter);
2371 #endif
2372 
2373 /** Process write data complete */
2374 mlan_status wlan_write_data_complete(pmlan_adapter pmlan_adapter,
2375 				     pmlan_buffer pmbuf, mlan_status status);
2376 /** Process receive packet complete */
2377 mlan_status wlan_recv_packet_complete(pmlan_adapter pmadapter,
2378 				      pmlan_buffer pmbuf, mlan_status status);
2379 /** Clean Tx Rx queues */
2380 t_void wlan_clean_txrx(pmlan_private priv);
2381 
2382 t_void wlan_add_buf_bypass_txqueue(mlan_adapter *pmadapter, pmlan_buffer pmbuf);
2383 t_void wlan_process_bypass_tx(mlan_adapter *pmadapter);
2384 t_void wlan_cleanup_bypass_txq(pmlan_private priv);
2385 t_u8 wlan_bypass_tx_list_empty(mlan_adapter *pmadapter);
2386 
2387 /** Check if this is the last packet */
2388 t_u8 wlan_check_last_packet_indication(pmlan_private priv);
2389 
2390 #define MOAL_ALLOC_MLAN_BUFFER  (0)
2391 #define MOAL_MALLOC_BUFFER      (1)
2392 
2393 /** function to allocate a mlan_buffer */
2394 pmlan_buffer wlan_alloc_mlan_buffer(mlan_adapter *pmadapter, t_u32 data_len,
2395 				    t_u32 head_room, t_u32 malloc_flag);
2396 /** function to free a mlan_buffer */
2397 t_void wlan_free_mlan_buffer(mlan_adapter *pmadapter, pmlan_buffer pmbuf);
2398 
2399 /** command resp handler for version ext */
2400 mlan_status wlan_ret_ver_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
2401 			     mlan_ioctl_req *pioctl_buf);
2402 
2403 /** command resp handler for rx mgmt forward registration */
2404 mlan_status wlan_ret_rx_mgmt_ind(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
2405 				 mlan_ioctl_req *pioctl_buf);
2406 
2407 /** Check Power Save condition */
2408 t_void wlan_check_ps_cond(mlan_adapter *pmadapter);
2409 
2410 /** handle command for enhanced power save mode */
2411 mlan_status wlan_cmd_enh_power_mode(pmlan_private pmpriv,
2412 				    IN HostCmd_DS_COMMAND *cmd,
2413 				    IN t_u16 cmd_action,
2414 				    IN t_u16 ps_bitmap, IN t_void *pdata_buf);
2415 /** handle command resp for enhanced power save mode */
2416 mlan_status wlan_ret_enh_power_mode(IN pmlan_private pmpriv,
2417 				    IN HostCmd_DS_COMMAND *resp,
2418 				    IN mlan_ioctl_req *pioctl_buf);
2419 
2420 /** handle commnand for cfg data */
2421 mlan_status wlan_cmd_cfg_data(IN pmlan_private pmpriv,
2422 			      IN HostCmd_DS_COMMAND *pcmd,
2423 			      IN t_u16 cmd_action,
2424 			      IN t_u32 cmd_oid, IN t_void *pdata_buf);
2425 /** handle command resp for cfg data */
2426 mlan_status wlan_ret_cfg_data(IN pmlan_private pmpriv,
2427 			      IN HostCmd_DS_COMMAND *resp,
2428 			      IN t_void *pioctl_buf);
2429 
2430 /** Process sleep confirm command response */
2431 void wlan_process_sleep_confirm_resp(pmlan_adapter pmadapter, t_u8 *pbuf,
2432 				     t_u32 len);
2433 
2434 /** Perform hs related activities on receving the power up interrupt */
2435 void wlan_process_hs_config(pmlan_adapter pmadapter);
2436 
2437 mlan_status wlan_pm_reset_card(pmlan_adapter adapter);
2438 mlan_status wlan_pm_wakeup_card(pmlan_adapter pmadapter);
2439 
2440 mlan_status wlan_process_802dot11_mgmt_pkt(mlan_private *priv, t_u8 *payload,
2441 					   t_u32 payload_len, RxPD *prx_pd);
2442 
2443 mlan_status wlan_pm_ioctl_hscfg(pmlan_adapter pmadapter,
2444 				pmlan_ioctl_req pioctl_req);
2445 
2446 #ifdef WIFI_DIRECT_SUPPORT
2447 mlan_status wlan_bss_ioctl_wifi_direct_mode(IN pmlan_adapter pmadapter,
2448 					    IN pmlan_ioctl_req pioctl_req);
2449 
2450 mlan_status wlan_cmd_wifi_direct_mode(IN pmlan_private pmpriv,
2451 				      IN HostCmd_DS_COMMAND *cmd,
2452 				      IN t_u16 cmd_action,
2453 				      IN t_void *pdata_buf);
2454 mlan_status wlan_ret_wifi_direct_mode(IN pmlan_private pmpriv,
2455 				      IN HostCmd_DS_COMMAND *resp,
2456 				      IN mlan_ioctl_req *pioctl_buf);
2457 
2458 mlan_status wlan_cmd_p2p_params_config(IN pmlan_private pmpriv,
2459 				       IN HostCmd_DS_COMMAND *cmd,
2460 				       IN t_u16 cmd_action,
2461 				       IN t_void *pdata_buf);
2462 mlan_status wlan_ret_p2p_params_config(IN pmlan_private pmpriv,
2463 				       IN HostCmd_DS_COMMAND *resp,
2464 				       IN mlan_ioctl_req *pioctl_buf);
2465 mlan_status wlan_misc_p2p_config(IN pmlan_adapter pmadapter,
2466 				 IN pmlan_ioctl_req pioctl_req);
2467 #endif
2468 /** get ralist info */
2469 int wlan_get_ralist_info(mlan_private *priv, ralist_info *buf);
2470 /** dump ralist */
2471 void wlan_dump_ralist(mlan_private *priv);
2472 
2473 /** get pm info */
2474 mlan_status wlan_get_pm_info(IN pmlan_adapter pmadapter,
2475 			     IN pmlan_ioctl_req pioctl_req);
2476 
2477 mlan_status wlan_bss_ioctl_bss_remove(IN pmlan_adapter pmadapter,
2478 				      IN pmlan_ioctl_req pioctl_req);
2479 
2480 mlan_status wlan_misc_per_pkt_cfg(IN pmlan_adapter pmadapter,
2481 				  IN pmlan_ioctl_req pioctl_req);
2482 
2483 mlan_status wlan_config_mgmt_filter(IN pmlan_adapter pmadapter,
2484 				    IN pmlan_ioctl_req pioctl_req);
2485 mlan_status wlan_get_hs_wakeup_reason(IN pmlan_adapter pmadapter,
2486 				      IN pmlan_ioctl_req pioctl_req);
2487 
2488 mlan_status wlan_cmd_hs_wakeup_reason(IN pmlan_private pmpriv,
2489 				      IN HostCmd_DS_COMMAND *cmd,
2490 				      IN t_void *pdata_buf);
2491 
2492 mlan_status wlan_ret_hs_wakeup_reason(IN pmlan_private pmpriv,
2493 				      IN HostCmd_DS_COMMAND *resp,
2494 				      IN mlan_ioctl_req *pioctl_buf);
2495 
2496 mlan_status wlan_radio_ioctl_radio_ctl(IN pmlan_adapter pmadapter,
2497 				       IN pmlan_ioctl_req pioctl_req);
2498 mlan_status wlan_radio_ioctl_remain_chan_cfg(IN pmlan_adapter pmadapter,
2499 					     IN pmlan_ioctl_req pioctl_req);
2500 mlan_status wlan_cmd_remain_on_channel(IN pmlan_private pmpriv,
2501 				       IN HostCmd_DS_COMMAND *cmd,
2502 				       IN t_u16 cmd_action,
2503 				       IN t_void *pdata_buf);
2504 mlan_status wlan_ret_remain_on_channel(IN pmlan_private pmpriv,
2505 				       IN HostCmd_DS_COMMAND *resp,
2506 				       IN mlan_ioctl_req *pioctl_buf);
2507 
2508 mlan_status wlan_radio_ioctl_ant_cfg(IN pmlan_adapter pmadapter,
2509 				     IN pmlan_ioctl_req pioctl_req);
2510 
2511 mlan_status wlan_cmd_tx_rate_cfg(IN pmlan_private pmpriv,
2512 				 IN HostCmd_DS_COMMAND *cmd,
2513 				 IN t_u16 cmd_action, IN t_void *pdata_buf);
2514 mlan_status wlan_ret_tx_rate_cfg(IN pmlan_private pmpriv,
2515 				 IN HostCmd_DS_COMMAND *resp,
2516 				 IN mlan_ioctl_req *pioctl_buf);
2517 
2518 mlan_status wlan_rate_ioctl_cfg(IN pmlan_adapter pmadapter,
2519 				IN pmlan_ioctl_req pioctl_req);
2520 mlan_status wlan_ret_802_11_tx_rate_query(IN pmlan_private pmpriv,
2521 					  IN HostCmd_DS_COMMAND *resp,
2522 					  IN mlan_ioctl_req *pioctl_buf);
2523 
2524 mlan_status wlan_rate_ioctl_get_data_rate(IN pmlan_adapter pmadapter,
2525 					  IN pmlan_ioctl_req pioctl_req);
2526 
2527 t_void wlan_host_sleep_activated_event(pmlan_private priv, t_u8 activated);
2528 /** Handles the command response of hs_cfg */
2529 mlan_status wlan_ret_802_11_hs_cfg(IN pmlan_private pmpriv,
2530 				   IN HostCmd_DS_COMMAND *resp,
2531 				   IN mlan_ioctl_req *pioctl_buf);
2532 /** Sends HS_WAKEUP event to applications */
2533 t_void wlan_host_sleep_wakeup_event(pmlan_private priv);
2534 
2535 mlan_status wlan_cmd_802_11_fw_wakeup_method(IN pmlan_private pmpriv,
2536 					     IN HostCmd_DS_COMMAND *cmd,
2537 					     IN t_u16 cmd_action,
2538 					     IN t_u16 *pdata_buf);
2539 mlan_status wlan_ret_fw_wakeup_method(IN pmlan_private pmpriv,
2540 				      IN HostCmd_DS_COMMAND *resp,
2541 				      IN mlan_ioctl_req *pioctl_buf);
2542 mlan_status wlan_fw_wakeup_method(IN pmlan_adapter pmadapter,
2543 				  IN pmlan_ioctl_req pioctl_req);
2544 
2545 /** Prepares command of robustcoex */
2546 mlan_status wlan_cmd_robustcoex(IN pmlan_private pmpriv,
2547 				IN HostCmd_DS_COMMAND *cmd,
2548 				IN t_u16 cmd_action, IN t_u16 *pdata_buf);
2549 /** Set Robustcoex gpiocfg */
2550 mlan_status wlan_misc_robustcoex(IN pmlan_adapter pmadapter,
2551 				 IN pmlan_ioctl_req pioctl_req);
2552 
2553 /** send get hw spec command to firmware */
2554 mlan_status wlan_adapter_get_hw_spec(IN pmlan_adapter pmadapter);
2555 /** send adapter specific init cmd to firmware */
2556 mlan_status wlan_adapter_init_cmd(IN pmlan_adapter pmadapter);
2557 
2558 #ifdef RX_PACKET_COALESCE
2559 mlan_status wlan_cmd_rx_pkt_coalesce_cfg(IN pmlan_private pmpriv,
2560 					 IN HostCmd_DS_COMMAND *cmd,
2561 					 IN t_u16 cmd_action,
2562 					 IN t_void *pdata_buf);
2563 mlan_status wlan_ret_rx_pkt_coalesce_cfg(IN pmlan_private pmpriv,
2564 					 const IN HostCmd_DS_COMMAND *resp,
2565 					 OUT mlan_ioctl_req *pioctl_buf);
2566 #endif
2567 mlan_status wlan_handle_event_multi_chan_info(IN pmlan_private pmpriv,
2568 					      pmlan_buffer pevent);
2569 
2570 #ifdef STA_SUPPORT
2571 /** warm reset */
2572 mlan_status wlan_misc_ioctl_warm_reset(IN pmlan_adapter pmadapter,
2573 				       IN pmlan_ioctl_req pioctl_req);
2574 /** Process received packet */
2575 mlan_status wlan_process_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
2576 /** ioctl handler for station mode */
2577 mlan_status wlan_ops_sta_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req);
2578 
2579 /** cmd handler for station mode */
2580 mlan_status wlan_ops_sta_prepare_cmd(IN t_void *priv,
2581 				     IN t_u16 cmd_no,
2582 				     IN t_u16 cmd_action,
2583 				     IN t_u32 cmd_oid,
2584 				     IN t_void *pioctl_buf,
2585 				     IN t_void *pdata_buf, IN t_void *pcmd_buf);
2586 
2587 /** cmdresp handler for station mode */
2588 mlan_status wlan_ops_sta_process_cmdresp(IN t_void *priv,
2589 					 IN t_u16 cmdresp_no,
2590 					 IN t_void *pcmd_buf,
2591 					 IN t_void *pioctl);
2592 
2593 /** rx handler for station mode */
2594 mlan_status wlan_ops_sta_process_rx_packet(IN t_void *adapter,
2595 					   IN pmlan_buffer pmbuf);
2596 
2597 /** event handler for station mode */
2598 mlan_status wlan_ops_sta_process_event(IN t_void *priv);
2599 
2600 /** fill txpd for station mode */
2601 t_void *wlan_ops_sta_process_txpd(IN t_void *priv, IN pmlan_buffer pmbuf);
2602 
2603 /** send init cmd to firmware for station mode */
2604 mlan_status wlan_ops_sta_init_cmd(IN t_void *priv, IN t_u8 first_bss);
2605 
2606 /** Flush the scan table */
2607 mlan_status wlan_flush_scan_table(IN pmlan_adapter pmadapter);
2608 
2609 /** Scan for networks */
2610 mlan_status wlan_scan_networks(IN mlan_private *pmpriv,
2611 			       IN t_void *pioctl_buf,
2612 			       IN wlan_user_scan_cfg *puser_scan_in);
2613 
2614 /** Scan for specific SSID */
2615 mlan_status wlan_scan_specific_ssid(IN mlan_private *pmpriv,
2616 				    IN t_void *pioctl_buf,
2617 				    IN mlan_802_11_ssid *preq_ssid);
2618 
2619 /** Scan command handler */
2620 mlan_status wlan_cmd_802_11_scan(IN pmlan_private pmpriv,
2621 				 IN HostCmd_DS_COMMAND *pcmd,
2622 				 IN t_void *pdata_buf);
2623 
2624 /** Handler for scan command response */
2625 mlan_status wlan_ret_802_11_scan(IN pmlan_private pmpriv,
2626 				 IN HostCmd_DS_COMMAND *resp,
2627 				 IN t_void *pioctl_buf);
2628 
2629 /** Extended scan command handler */
2630 mlan_status wlan_cmd_802_11_scan_ext(IN pmlan_private pmpriv,
2631 				     IN HostCmd_DS_COMMAND *pcmd,
2632 				     IN t_void *pdata_buf);
2633 /** Handler for extended scan command response */
2634 mlan_status wlan_ret_802_11_scan_ext(IN pmlan_private pmpriv,
2635 				     IN HostCmd_DS_COMMAND *resp,
2636 				     IN t_void *pioctl_buf);
2637 /** Handler event for extended scan report */
2638 mlan_status wlan_handle_event_ext_scan_report(IN mlan_private *pmpriv,
2639 					      IN mlan_buffer *pmbuf);
2640 mlan_status wlan_handle_event_ext_scan_status(IN mlan_private *pmpriv,
2641 					      IN mlan_buffer *pmbuf);
2642 
2643 /** check network compatibility */
2644 t_s32 wlan_is_network_compatible(IN mlan_private *pmpriv,
2645 				 IN t_u32 index, IN t_u32 mode);
2646 
2647 /** Find an SSID in a list */
2648 t_s32 wlan_find_ssid_in_list(IN pmlan_private pmpriv,
2649 			     IN mlan_802_11_ssid *ssid,
2650 			     IN t_u8 *bssid, IN t_u32 mode);
2651 
2652 /** Find a BSSID in a list */
2653 t_s32 wlan_find_bssid_in_list(IN mlan_private *pmpriv,
2654 			      IN t_u8 *bssid, IN t_u32 mode);
2655 
2656 /** Find best network */
2657 mlan_status wlan_find_best_network(IN mlan_private *pmpriv,
2658 				   OUT mlan_ssid_bssid *preq_ssid_bssid);
2659 
2660 /** Compare two SSIDs */
2661 t_s32 wlan_ssid_cmp(IN pmlan_adapter pmadapter,
2662 		    IN mlan_802_11_ssid *ssid1, IN mlan_802_11_ssid *ssid2);
2663 
2664 /** Associate */
2665 mlan_status wlan_associate(IN mlan_private *pmpriv,
2666 			   IN t_void *pioctl_buf, IN BSSDescriptor_t *pBSSDesc);
2667 
2668 /** Associate command handler */
2669 mlan_status wlan_cmd_802_11_associate(IN mlan_private *pmpriv,
2670 				      IN HostCmd_DS_COMMAND *cmd,
2671 				      IN t_void *pdata_buf);
2672 
2673 /** Handler for association command response */
2674 mlan_status wlan_ret_802_11_associate(IN mlan_private *pmpriv,
2675 				      IN HostCmd_DS_COMMAND *resp,
2676 				      IN t_void *pioctl_buf);
2677 
2678 /** Reset connected state */
2679 t_void wlan_reset_connect_state(IN pmlan_private priv, IN t_u8 drv_disconnect);
2680 
2681 t_void wlan_2040_coex_event(pmlan_private pmpriv);
2682 
2683 /** convert band to radio type */
2684 t_u8 wlan_band_to_radio_type(IN t_u8 band);
2685 /** convert radio_type to band */
2686 t_u8 radio_type_to_band(t_u8 chanBand);
2687 
2688 /** Disconnect */
2689 mlan_status wlan_disconnect(IN mlan_private *pmpriv,
2690 			    IN mlan_ioctl_req *pioctl_req,
2691 			    IN mlan_deauth_param *deauth_param);
2692 
2693 /** Ad-Hoc start */
2694 mlan_status wlan_adhoc_start(IN mlan_private *pmpriv,
2695 			     IN t_void *pioctl_buf,
2696 			     IN mlan_802_11_ssid *padhoc_ssid);
2697 
2698 /** Ad-Hoc join */
2699 mlan_status wlan_adhoc_join(IN mlan_private *pmpriv,
2700 			    IN t_void *pioctl_buf,
2701 			    IN BSSDescriptor_t *pBSSDesc);
2702 
2703 /** Ad-Hoc start command handler */
2704 mlan_status wlan_cmd_802_11_ad_hoc_start(IN mlan_private *pmpriv,
2705 					 IN HostCmd_DS_COMMAND *cmd,
2706 					 IN t_void *pdata_buf);
2707 
2708 /** Ad-Hoc command handler */
2709 mlan_status wlan_cmd_802_11_ad_hoc_join(IN mlan_private *pmpriv,
2710 					IN HostCmd_DS_COMMAND *cmd,
2711 					IN t_void *pdata_buf);
2712 
2713 /** Handler for Ad-Hoc commands */
2714 mlan_status wlan_ret_802_11_ad_hoc(IN mlan_private *pmpriv,
2715 				   IN HostCmd_DS_COMMAND *resp,
2716 				   IN t_void *pioctl_buf);
2717 
2718 /** Handler for bgscan query commands */
2719 mlan_status wlan_cmd_802_11_bg_scan_query(IN mlan_private *pmpriv,
2720 					  IN HostCmd_DS_COMMAND *pcmd,
2721 					  IN t_void *pdata_buf);
2722 /** Handler for bgscan config command */
2723 mlan_status wlan_cmd_bgscan_config(IN mlan_private *pmpriv,
2724 				   IN HostCmd_DS_COMMAND *pcmd,
2725 				   IN t_void *pdata_buf);
2726 /** Hander for bgscan config command response */
2727 mlan_status wlan_ret_bgscan_config(IN mlan_private *pmpriv,
2728 				   IN HostCmd_DS_COMMAND *resp,
2729 				   IN mlan_ioctl_req *pioctl_buf);
2730 mlan_status wlan_ret_802_11_bgscan_query(IN mlan_private *pmpriv,
2731 					 IN HostCmd_DS_COMMAND *resp,
2732 					 IN mlan_ioctl_req *pioctl_buf);
2733 
2734 /** Get Channel-Frequency-Power by band and channel */
2735 chan_freq_power_t *wlan_get_cfp_by_band_and_channel(pmlan_adapter pmadapter,
2736 						    t_u8 band, t_u16 channel,
2737 						    region_chan_t
2738 						    *region_channel);
2739 /** Find Channel-Frequency-Power by band and channel */
2740 chan_freq_power_t *wlan_find_cfp_by_band_and_channel(mlan_adapter *pmadapter,
2741 						     t_u8 band, t_u16 channel);
2742 /** Find Channel-Frequency-Power by band and frequency */
2743 chan_freq_power_t *wlan_find_cfp_by_band_and_freq(mlan_adapter *pmadapter,
2744 						  t_u8 band, t_u32 freq);
2745 /** Get Tx power of channel from Channel-Frequency-Power */
2746 t_u8 wlan_get_txpwr_of_chan_from_cfp(mlan_private *pmpriv, t_u8 channel);
2747 /** find frequency from band and channel */
2748 t_u32 wlan_find_freq_from_band_chan(t_u8, t_u8);
2749 
2750 /*  Save a beacon buffer of the current bss descriptor */
2751 t_void wlan_save_curr_bcn(IN mlan_private *pmpriv);
2752 /*  Free a beacon buffer of the current bss descriptor */
2753 t_void wlan_free_curr_bcn(IN mlan_private *pmpriv);
2754 
2755 #endif /* STA_SUPPORT */
2756 
2757 /* Rate related functions */
2758 t_u8 wlan_convert_v14_rate_ht_info(t_u8 ht_info);
2759 /** Convert index into data rate */
2760 t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter, t_u8 index,
2761 			      t_u8 rate_info);
2762 /** Get active data rates */
2763 t_u32 wlan_get_active_data_rates(mlan_private *pmpriv, t_u32 bss_mode,
2764 				 t_u8 config_bands, WLAN_802_11_RATES rates);
2765 /** Get supported data rates */
2766 t_u32 wlan_get_supported_rates(mlan_private *pmpriv, t_u32 bss_mode,
2767 			       t_u8 config_bands, WLAN_802_11_RATES rates);
2768 /** Convert data rate to index */
2769 t_u8 wlan_data_rate_to_index(pmlan_adapter pmadapter, t_u32 rate);
2770 /** Check if rate is auto */
2771 t_u8 wlan_is_rate_auto(mlan_private *pmpriv);
2772 /** Get rate index */
2773 int wlan_get_rate_index(pmlan_adapter pmadapter, t_u16 *rateBitmap, int size);
2774 
2775 /* CFP related functions */
2776 /** Region code index table */
2777 extern t_u16 region_code_index[MRVDRV_MAX_REGION_CODE];
2778 /** The table to keep CFP code for BG */
2779 extern t_u16 cfp_code_index_bg[MRVDRV_MAX_CFP_CODE_BG];
2780 /** The table to keep CFP code for A */
2781 extern t_u16 cfp_code_index_a[MRVDRV_MAX_CFP_CODE_A];
2782 
2783 /** Set region table */
2784 mlan_status wlan_set_regiontable(mlan_private *pmpriv, t_u8 region, t_u8 band);
2785 /** Get radar detection requirements*/
2786 t_bool wlan_get_cfp_radar_detect(mlan_private *priv, t_u8 chnl);
2787 /** check if scan type is passive for b/g band*/
2788 t_bool wlan_bg_scan_type_is_passive(mlan_private *priv, t_u8 chnl);
2789 /** check if channel is disabled */
2790 t_bool wlan_is_chan_disabled(mlan_private *priv, t_u8 band, t_u8 chan);
2791 /** check if channel is blacklisted */
2792 t_bool wlan_is_chan_blacklisted(mlan_private *priv, t_u8 band, t_u8 chan);
2793 /** set blacklist setting for a channel */
2794 t_bool wlan_set_chan_blacklist(mlan_private *priv, t_u8 band, t_u8 chan,
2795 			       t_bool bl);
2796 
2797 /* 802.11D related functions */
2798 /** Initialize 11D */
2799 t_void wlan_11d_priv_init(mlan_private *pmpriv);
2800 /** Initialize 11D */
2801 t_void wlan_11d_init(mlan_adapter *pmadapter);
2802 /** Enable 11D */
2803 mlan_status wlan_11d_enable(mlan_private *pmpriv, t_void *pioctl_buf,
2804 			    state_11d_t flag);
2805 /** Get if 11D is enabled */
2806 t_bool wlan_11d_is_enabled(mlan_private *pmpriv);
2807 /** Get if priv is station */
2808 t_bool wlan_is_station(mlan_private *pmpriv);
2809 /** Command handler for 11D country info */
2810 mlan_status wlan_cmd_802_11d_domain_info(mlan_private *pmpriv,
2811 					 HostCmd_DS_COMMAND *pcmd,
2812 					 t_u16 cmd_action);
2813 /** Handler for 11D country info command response */
2814 mlan_status wlan_ret_802_11d_domain_info(mlan_private *pmpriv,
2815 					 HostCmd_DS_COMMAND *resp);
2816 #ifdef STA_SUPPORT
2817 /** Convert channel to frequency */
2818 t_u32 wlan_11d_chan_2_freq(pmlan_adapter pmadapter, t_u8 chan, t_u8 band);
2819 /** Set 11D universal table */
2820 mlan_status wlan_11d_set_universaltable(mlan_private *pmpriv, t_u8 band);
2821 /** Clear 11D region table */
2822 mlan_status wlan_11d_clear_parsedtable(mlan_private *pmpriv);
2823 /** Create 11D country information for downloading */
2824 mlan_status wlan_11d_create_dnld_countryinfo(mlan_private *pmpriv, t_u8 band);
2825 /** Get scan type from 11D info */
2826 t_u8 wlan_11d_get_scan_type(pmlan_adapter pmadapter, t_u8 band, t_u8 chan,
2827 			    parsed_region_chan_11d_t *parsed_region_chan);
2828 /** Parse 11D country info */
2829 mlan_status wlan_11d_parse_dnld_countryinfo(mlan_private *pmpriv,
2830 					    BSSDescriptor_t *pBSSDesc);
2831 /** Prepare 11D domain information for download */
2832 mlan_status wlan_11d_prepare_dnld_domain_info_cmd(mlan_private *pmpriv);
2833 /** Parse 11D country information into domain info */
2834 mlan_status wlan_11d_parse_domain_info(pmlan_adapter pmadapter,
2835 				       IEEEtypes_CountryInfoFullSet_t
2836 				       *country_info, t_u8 band,
2837 				       parsed_region_chan_11d_t
2838 				       *parsed_region_chan);
2839 /** Configure 11D domain info command */
2840 mlan_status wlan_11d_cfg_domain_info(IN pmlan_adapter pmadapter,
2841 				     IN mlan_ioctl_req *pioctl_req);
2842 #endif /* STA_SUPPORT */
2843 #ifdef UAP_SUPPORT
2844 /** Handle 11D domain information from UAP */
2845 mlan_status wlan_11d_handle_uap_domain_info(mlan_private *pmpriv,
2846 					    t_u8 band,
2847 					    t_u8 *domain_tlv,
2848 					    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 
2857 /** This function finds if given country code is in EU table */
2858 t_bool wlan_is_etsi_country(pmlan_adapter pmadapter, t_u8 *country_code);
2859 
2860 /** check if station list is empty */
2861 t_u8 wlan_is_station_list_empty(mlan_private *priv);
2862 /** get station node */
2863 sta_node *wlan_get_station_entry(mlan_private *priv, t_u8 *mac);
2864 /** delete station list */
2865 t_void wlan_delete_station_list(pmlan_private priv);
2866 /** delete station entry */
2867 t_void wlan_delete_station_entry(mlan_private *priv, t_u8 *mac);
2868 /** add station entry */
2869 sta_node *wlan_add_station_entry(mlan_private *priv, t_u8 *mac);
2870 /** process uap rx packet */
2871 
2872 void wlan_check_sta_capability(pmlan_private priv, pmlan_buffer pevent,
2873 			       sta_node *sta_ptr);
2874 /** find specific ie */
2875 t_u8 *wlan_get_specific_ie(pmlan_private priv, t_u8 *ie_buf, t_u8 ie_len,
2876 			   IEEEtypes_ElementId_e id);
2877 t_u8 wlan_is_wmm_ie_present(pmlan_adapter pmadapter, t_u8 *pbuf, t_u16 buf_len);
2878 
2879 /**
2880  *  @brief This function checks whether a station TDLS link is enabled or not
2881  *
2882  *  @param priv     A pointer to mlan_private
2883  *  @param mac      station mac address
2884  *  @return         TDLS_NOT_SETUP/TDLS_SETUP_INPROGRESS/TDLS_SETUP_COMPLETE/TDLS_SETUP_FAILURE/TDLS_TEAR_DOWN
2885  */
2886 static INLINE tdlsStatus_e
wlan_get_tdls_link_status(mlan_private * priv,t_u8 * mac)2887 wlan_get_tdls_link_status(mlan_private *priv, t_u8 *mac)
2888 {
2889 	sta_node *sta_ptr = MNULL;
2890 	sta_ptr = wlan_get_station_entry(priv, mac);
2891 	if (sta_ptr)
2892 		return sta_ptr->status;
2893 	return TDLS_NOT_SETUP;
2894 }
2895 
2896 /**
2897  *  @brief This function checks if TDLS link is in channel switching
2898  *
2899  *  @param status     tdls link status
2900  *  @return         MTRUE/MFALSE
2901  */
2902 static INLINE int
wlan_is_tdls_link_chan_switching(tdlsStatus_e status)2903 wlan_is_tdls_link_chan_switching(tdlsStatus_e status)
2904 {
2905 	return (status == TDLS_SWITCHING_CHANNEL) ? MTRUE : MFALSE;
2906 }
2907 
2908 /**
2909  *  @brief This function checks if send command to firmware is allowed
2910  *
2911  *  @param status     tdls link status
2912  *  @return         MTRUE/MFALSE
2913  */
2914 static INLINE int
wlan_is_send_cmd_allowed(tdlsStatus_e status)2915 wlan_is_send_cmd_allowed(tdlsStatus_e status)
2916 {
2917 	int ret = MTRUE;
2918 	switch (status) {
2919 	case TDLS_SWITCHING_CHANNEL:
2920 	case TDLS_IN_OFF_CHANNEL:
2921 		ret = MFALSE;
2922 		break;
2923 	default:
2924 		break;
2925 	}
2926 	return ret;
2927 }
2928 
2929 /**
2930  *  @brief This function checks if TDLS link is setup
2931  *
2932  *  @param status     tdls link status
2933  *  @return         MTRUE/MFALSE
2934  */
2935 static INLINE int
wlan_is_tdls_link_setup(tdlsStatus_e status)2936 wlan_is_tdls_link_setup(tdlsStatus_e status)
2937 {
2938 	int ret = MFALSE;
2939 	switch (status) {
2940 	case TDLS_SWITCHING_CHANNEL:
2941 	case TDLS_IN_OFF_CHANNEL:
2942 	case TDLS_IN_BASE_CHANNEL:
2943 	case TDLS_SETUP_COMPLETE:
2944 		ret = MTRUE;
2945 		break;
2946 	default:
2947 		break;
2948 	}
2949 	return ret;
2950 }
2951 
2952 /**
2953  *  @brief This function checks tx_pause flag for peer
2954  *
2955  *  @param priv     A pointer to mlan_private
2956  *  @param ra       Address of the receiver STA
2957  *
2958  *  @return         MTRUE or MFALSE
2959  */
2960 static int INLINE
wlan_is_tx_pause(mlan_private * priv,t_u8 * ra)2961 wlan_is_tx_pause(mlan_private *priv, t_u8 *ra)
2962 {
2963 	sta_node *sta_ptr = MNULL;
2964 	sta_ptr = wlan_get_station_entry(priv, ra);
2965 	if (sta_ptr)
2966 		return sta_ptr->tx_pause;
2967 	return MFALSE;
2968 }
2969 
2970 t_void wlan_update_ralist_tx_pause(pmlan_private priv, t_u8 *mac,
2971 				   t_u8 tx_pause);
2972 
2973 #ifdef UAP_SUPPORT
2974 mlan_status wlan_process_uap_rx_packet(IN mlan_private *priv,
2975 				       IN pmlan_buffer pmbuf);
2976 t_void wlan_drop_tx_pkts(pmlan_private priv);
2977 #endif /* UAP_SUPPORT */
2978 
2979 #ifdef UAP_SUPPORT
2980 /* process the recevied packet and bridge the packet */
2981 mlan_status wlan_uap_recv_packet(IN mlan_private *priv, IN pmlan_buffer pmbuf);
2982 #endif /* UAP_SUPPORT */
2983 
2984 mlan_status wlan_misc_ioctl_coalescing_status(IN pmlan_adapter pmadapter,
2985 					      IN pmlan_ioctl_req pioctl_req);
2986 
2987 mlan_status wlan_misc_ioctl_custom_ie_list(IN pmlan_adapter pmadapter,
2988 					   IN pmlan_ioctl_req pioctl_req,
2989 					   IN t_bool send_ioctl);
2990 
2991 mlan_status wlan_cmd_get_hw_spec(IN pmlan_private pmpriv,
2992 				 IN HostCmd_DS_COMMAND *pcmd);
2993 mlan_status wlan_ret_get_hw_spec(IN pmlan_private pmpriv,
2994 				 IN HostCmd_DS_COMMAND *resp,
2995 				 IN t_void *pioctl_buf);
2996 mlan_status wlan_cmd_sdio_rx_aggr_cfg(IN HostCmd_DS_COMMAND *pcmd,
2997 				      IN t_u16 cmd_action,
2998 				      IN t_void *pdata_buf);
2999 mlan_status wlan_ret_sdio_rx_aggr_cfg(IN pmlan_private pmpriv,
3000 				      IN HostCmd_DS_COMMAND *resp);
3001 
3002 mlan_status wlan_misc_ioctl_mac_control(IN pmlan_adapter pmadapter,
3003 					IN pmlan_ioctl_req pioctl_req);
3004 mlan_status wlan_cmd_mac_control(IN pmlan_private pmpriv,
3005 				 IN HostCmd_DS_COMMAND *pcmd,
3006 				 IN t_u16 cmd_action, IN t_void *pdata_buf);
3007 mlan_status wlan_ret_mac_control(IN pmlan_private pmpriv,
3008 				 IN HostCmd_DS_COMMAND *resp,
3009 				 IN mlan_ioctl_req *pioctl_buf);
3010 
3011 mlan_status wlan_cmd_cw_mode_ctrl(IN pmlan_private pmpriv,
3012 				  IN HostCmd_DS_COMMAND *cmd,
3013 				  IN t_u16 cmd_action, IN t_void *pdata_buf);
3014 mlan_status wlan_ret_cw_mode_ctrl(IN pmlan_private pmpriv,
3015 				  IN HostCmd_DS_COMMAND *resp,
3016 				  IN mlan_ioctl_req *pioctl_buf);
3017 
3018 mlan_status wlan_cmd_802_11_radio_control(IN pmlan_private pmpriv,
3019 					  IN HostCmd_DS_COMMAND *cmd,
3020 					  IN t_u16 cmd_action,
3021 					  IN t_void *pdata_buf);
3022 mlan_status wlan_ret_802_11_radio_control(IN pmlan_private pmpriv,
3023 					  IN HostCmd_DS_COMMAND *resp,
3024 					  IN mlan_ioctl_req *pioctl_buf);
3025 
3026 mlan_status wlan_cmd_802_11_rf_antenna(IN pmlan_private pmpriv,
3027 				       IN HostCmd_DS_COMMAND *cmd,
3028 				       IN t_u16 cmd_action,
3029 				       IN t_void *pdata_buf);
3030 mlan_status wlan_ret_802_11_rf_antenna(IN pmlan_private pmpriv,
3031 				       IN HostCmd_DS_COMMAND *resp,
3032 				       IN mlan_ioctl_req *pioctl_buf);
3033 
3034 mlan_status wlan_ret_reg_access(mlan_adapter *pmadapter,
3035 				t_u16 type,
3036 				IN HostCmd_DS_COMMAND *resp,
3037 				IN mlan_ioctl_req *pioctl_buf);
3038 mlan_status wlan_ret_mem_access(IN pmlan_private pmpriv,
3039 				IN HostCmd_DS_COMMAND *resp,
3040 				IN mlan_ioctl_req *pioctl_buf);
3041 
3042 mlan_status wlan_reg_mem_ioctl_reg_rw(IN pmlan_adapter pmadapter,
3043 				      IN pmlan_ioctl_req pioctl_req);
3044 mlan_status wlan_reg_mem_ioctl_read_eeprom(IN pmlan_adapter pmadapter,
3045 					   IN pmlan_ioctl_req pioctl_req);
3046 mlan_status wlan_reg_mem_ioctl_mem_rw(IN pmlan_adapter pmadapter,
3047 				      IN pmlan_ioctl_req pioctl_req);
3048 mlan_status wlan_cmd_reg_access(IN HostCmd_DS_COMMAND *cmd,
3049 				IN t_u16 cmd_action, IN t_void *pdata_buf);
3050 mlan_status wlan_cmd_mem_access(IN HostCmd_DS_COMMAND *cmd,
3051 				IN t_u16 cmd_action, IN t_void *pdata_buf);
3052 
3053 int wlan_get_tdls_list(mlan_private *priv, tdls_peer_info *buf);
3054 t_void wlan_hold_tdls_packets(pmlan_private priv, t_u8 *mac);
3055 t_void wlan_restore_tdls_packets(pmlan_private priv, t_u8 *mac,
3056 				 tdlsStatus_e status);
3057 t_void wlan_update_non_tdls_ralist(mlan_private *priv, t_u8 *mac,
3058 				   t_u8 tx_pause);
3059 mlan_status wlan_misc_ioctl_tdls_config(IN pmlan_adapter pmadapter,
3060 					IN pmlan_ioctl_req pioctl_req);
3061 void wlan_11n_send_delba_to_peer(mlan_private *priv, t_u8 *ra);
3062 void wlan_process_tdls_action_frame(pmlan_private priv, t_u8 *pbuf, t_u32 len);
3063 mlan_status wlan_misc_ioctl_tdls_oper(IN pmlan_adapter pmadapter,
3064 				      IN pmlan_ioctl_req pioctl_req);
3065 
3066 mlan_status
3067 
3068 wlan_misc_ioctl_tdls_get_ies(IN pmlan_adapter pmadapter,
3069 			     IN pmlan_ioctl_req pioctl_req);
3070 mlan_status wlan_misc_ioctl_tdls_idle_time(IN pmlan_adapter pmadapter,
3071 					   IN pmlan_ioctl_req pioctl_req);
3072 
3073 t_void wlan_tdls_config(IN pmlan_private pmpriv, IN t_u8 enable);
3074 mlan_status wlan_misc_ioctl_tdls_cs_channel(IN pmlan_adapter pmadapter,
3075 					    IN pmlan_ioctl_req pioctl_req);
3076 mlan_status wlan_get_info_ver_ext(IN pmlan_adapter pmadapter,
3077 				  IN pmlan_ioctl_req pioctl_req);
3078 
3079 mlan_status wlan_reg_rx_mgmt_ind(IN pmlan_adapter pmadapter,
3080 				 IN pmlan_ioctl_req pioctl_req);
3081 
3082 #ifdef DEBUG_LEVEL1
3083 mlan_status wlan_set_drvdbg(IN pmlan_adapter pmadapter,
3084 			    IN pmlan_ioctl_req pioctl_req);
3085 #endif
3086 
3087 #ifdef STA_SUPPORT
3088 mlan_status wlan_misc_ext_capa_cfg(IN pmlan_adapter pmadapter,
3089 				   IN pmlan_ioctl_req pioctl_req);
3090 
3091 t_u32 wlan_is_ext_capa_support(IN mlan_private *pmpriv);
3092 #endif
3093 
3094 #ifdef STA_SUPPORT
3095 void wlan_add_ext_capa_info_ie(IN mlan_private *pmpriv, OUT t_u8 **pptlv_out);
3096 #endif
3097 
3098 mlan_status wlan_cmd_boot_sleep(IN pmlan_private pmpriv,
3099 				IN HostCmd_DS_COMMAND *cmd,
3100 				IN t_u16 cmd_action, IN t_void *pdata_buf);
3101 
3102 mlan_status wlan_ret_boot_sleep(IN pmlan_private pmpriv,
3103 				IN HostCmd_DS_COMMAND *resp,
3104 				IN mlan_ioctl_req *pioctl_buf);
3105 
3106 #define BW_20MHZ  0
3107 #define BW_40MHZ  1
3108 #define BW_80MHZ  2
3109 #define BW_160MHZ 3
3110 int wlan_add_supported_oper_class_ie(IN mlan_private *pmpriv,
3111 				     OUT t_u8 **pptlv_out,
3112 				     t_u8 curr_oper_class);
3113 mlan_status wlan_get_curr_oper_class(mlan_private *pmpriv, t_u8 channel,
3114 				     t_u8 bw, t_u8 *oper_class);
3115 mlan_status wlan_check_operclass_validation(mlan_private *pmpriv, t_u8 channel,
3116 					    t_u8 oper_class);
3117 mlan_status wlan_misc_ioctl_operclass_validation(IN pmlan_adapter pmadapter,
3118 						 IN mlan_ioctl_req *pioctl_req);
3119 mlan_status wlan_misc_ioctl_oper_class(IN pmlan_adapter pmadapter,
3120 				       IN mlan_ioctl_req *pioctl_req);
3121 
3122 t_u8 wlan_adjust_data_rate(mlan_private *priv, t_u8 rx_rate, t_u8 rate_info);
3123 t_u8 wlan_adjust_antenna(pmlan_private priv, RxPD *prx_pd);
3124 
3125 mlan_status wlan_misc_otp_user_data(IN pmlan_adapter pmadapter,
3126 				    IN pmlan_ioctl_req pioctl_req);
3127 
3128 mlan_status wlan_misc_ioctl_txcontrol(IN pmlan_adapter pmadapter,
3129 				      IN pmlan_ioctl_req pioctl_req);
3130 
3131 mlan_status wlan_misc_ioctl_region(IN pmlan_adapter pmadapter,
3132 				   IN pmlan_ioctl_req pioctl_req);
3133 
3134 #ifdef RX_PACKET_COALESCE
3135 mlan_status
3136 
3137 wlan_misc_ioctl_rx_pkt_coalesce_config(IN pmlan_adapter pmadapter,
3138 				       IN pmlan_ioctl_req pioctl_req);
3139 #endif
3140 
3141 mlan_status wlan_misc_ioctl_multi_chan_config(IN pmlan_adapter pmadapter,
3142 					      IN pmlan_ioctl_req pioctl_req);
3143 
3144 mlan_status wlan_cmd_multi_chan_cfg(IN pmlan_private pmpriv,
3145 				    IN HostCmd_DS_COMMAND *cmd,
3146 				    IN t_u16 cmd_action, IN t_void *pdata_buf);
3147 
3148 mlan_status wlan_ret_multi_chan_cfg(IN pmlan_private pmpriv,
3149 				    const IN HostCmd_DS_COMMAND *resp,
3150 				    OUT mlan_ioctl_req *pioctl_buf);
3151 
3152 mlan_status wlan_misc_ioctl_multi_chan_policy(IN pmlan_adapter pmadapter,
3153 					      IN pmlan_ioctl_req pioctl_req);
3154 
3155 mlan_status wlan_cmd_multi_chan_policy(IN pmlan_private pmpriv,
3156 				       IN HostCmd_DS_COMMAND *cmd,
3157 				       IN t_u16 cmd_action,
3158 				       IN t_void *pdata_buf);
3159 
3160 mlan_status wlan_ret_multi_chan_policy(IN pmlan_private pmpriv,
3161 				       const IN HostCmd_DS_COMMAND *resp,
3162 				       OUT mlan_ioctl_req *pioctl_buf);
3163 
3164 mlan_status wlan_misc_ioctl_drcs_config(IN pmlan_adapter pmadapter,
3165 					IN pmlan_ioctl_req pioctl_req);
3166 
3167 mlan_status wlan_cmd_drcs_cfg(IN pmlan_private pmpriv,
3168 			      IN HostCmd_DS_COMMAND *cmd,
3169 			      IN t_u16 cmd_action, IN t_void *pdata_buf);
3170 
3171 mlan_status wlan_ret_drcs_cfg(IN pmlan_private pmpriv,
3172 			      const IN HostCmd_DS_COMMAND *resp,
3173 			      OUT mlan_ioctl_req *pioctl_buf);
3174 
3175 void wlan_bt_coex_wlan_param_update_event(pmlan_private priv,
3176 					  pmlan_buffer pevent);
3177 
3178 mlan_status wlan_misc_ioctl_dfs_repeater_cfg(IN pmlan_adapter pmadapter,
3179 					     IN pmlan_ioctl_req pioctl_req);
3180 
3181 t_bool wlan_check_interface_active(mlan_adapter *pmadapter);
3182 
3183 mlan_status wlan_misc_ioctl_coalesce_cfg(IN pmlan_adapter pmadapter,
3184 					 IN pmlan_ioctl_req pioctl_req);
3185 
3186 mlan_status wlan_misc_ioctl_pmic_configure(IN pmlan_adapter pmadapter,
3187 					   IN pmlan_ioctl_req pioctl_req);
3188 
3189 mlan_status wlan_misc_ioctl_cwmode_ctrl(IN pmlan_adapter pmadapter,
3190 					IN pmlan_ioctl_req pioctl_req);
3191 
3192 mlan_status wlan_misc_ioctl_ind_rst_cfg(IN pmlan_adapter pmadapter,
3193 					IN pmlan_ioctl_req pioctl_req);
3194 mlan_status wlan_cmd_ind_rst_cfg(IN HostCmd_DS_COMMAND *cmd,
3195 				 IN t_u16 cmd_action, IN t_void *pdata_buf);
3196 mlan_status wlan_ret_ind_rst_cfg(IN pmlan_private pmpriv,
3197 				 IN HostCmd_DS_COMMAND *resp,
3198 				 IN mlan_ioctl_req *pioctl_buf);
3199 
3200 mlan_status wlan_cmd_802_11_supplicant_pmk(IN pmlan_private pmpriv,
3201 					   IN HostCmd_DS_COMMAND *cmd,
3202 					   IN t_u16 cmd_action,
3203 					   IN t_void *pdata_buf);
3204 
3205 mlan_status wlan_ret_802_11_supplicant_pmk(IN pmlan_private pmpriv,
3206 					   IN HostCmd_DS_COMMAND *resp,
3207 					   IN mlan_ioctl_req *pioctl_buf);
3208 mlan_status wlan_sec_ioctl_passphrase(IN pmlan_adapter pmadapter,
3209 				      IN pmlan_ioctl_req pioctl_req);
3210 
3211 mlan_status wlan_misc_ioctl_get_tsf(IN pmlan_adapter pmadapter,
3212 				    IN pmlan_ioctl_req pioctl_req);
3213 void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left);
3214 
3215 void wlan_free_fw_cfp_tables(mlan_adapter *pmadapter);
3216 
3217 mlan_status wlan_misc_chan_reg_cfg(IN pmlan_adapter pmadapter,
3218 				   IN pmlan_ioctl_req pioctl_req);
3219 
3220 mlan_status wlan_get_cfpinfo(IN pmlan_adapter pmadapter,
3221 			     IN pmlan_ioctl_req pioctl_req);
3222 
3223 mlan_status wlan_cmd_get_tsf(pmlan_private pmpriv,
3224 			     IN HostCmd_DS_COMMAND *cmd, IN t_u16 cmd_action);
3225 mlan_status wlan_ret_get_tsf(IN pmlan_private pmpriv,
3226 			     IN HostCmd_DS_COMMAND *resp,
3227 			     IN mlan_ioctl_req *pioctl_buf);
3228 
3229 t_u8 wlan_ft_akm_is_used(mlan_private *pmpriv, t_u8 *rsn_ie);
3230 
3231 mlan_status wlan_clear_fw_roaming_pmk(IN pmlan_private pmpriv);
3232 
3233 mlan_status wlan_cmd_ps_inactivity_timeout(IN pmlan_private pmpriv,
3234 					   IN HostCmd_DS_COMMAND *cmd,
3235 					   IN t_u16 cmd_action,
3236 					   IN t_void *pdata_buf);
3237 
3238 mlan_status wlan_cmd_host_clock_cfg(IN HostCmd_DS_COMMAND *cmd,
3239 				    IN t_u16 cmd_action, IN t_void *pdata_buf);
3240 mlan_status wlan_ret_host_clock_cfg(IN pmlan_private pmpriv,
3241 				    IN HostCmd_DS_COMMAND *resp,
3242 				    IN mlan_ioctl_req *pioctl_buf);
3243 
3244 t_u8 wlan_ieee_rateid_to_mrvl_rateid(IN mlan_private *priv,
3245 				     IN t_u16 IeeeMacRate, IN t_u8 *dst_mac);
3246 t_u8 wlan_mrvl_rateid_to_ieee_rateid(IN t_u8 rate);
3247 
3248 mlan_status wlan_ret_chan_region_cfg(IN pmlan_private pmpriv,
3249 				     IN HostCmd_DS_COMMAND *resp,
3250 				     IN mlan_ioctl_req *pioctl_buf);
3251 #if defined(SYSKT_MULTI) && defined(OOB_WAKEUP) || defined(SUSPEND_SDIO_PULL_DOWN)
3252 mlan_status wlan_cmd_sdio_pull_ctl(pmlan_private pmpriv,
3253 				   IN HostCmd_DS_COMMAND *cmd,
3254 				   IN t_u16 cmd_action);
3255 #endif
3256 
3257 mlan_status wlan_misc_ioctl_fw_dump_event(IN pmlan_adapter pmadapter,
3258 					  IN mlan_ioctl_req *pioctl_req);
3259 mlan_status wlan_cmd_fw_dump_event(IN pmlan_private pmpriv,
3260 				   IN HostCmd_DS_COMMAND *cmd,
3261 				   IN t_u16 cmd_action, IN t_void *pdata_buf);
3262 
3263 mlan_status wlan_misc_bootsleep(IN pmlan_adapter pmadapter,
3264 				IN pmlan_ioctl_req pioctl_req);
3265 
3266 /**
3267  *  @brief RA based queueing
3268  *
3269  *  @param priv             A pointer to mlan_private structure
3270  *
3271  *  @return                 MTRUE or MFALSE
3272  */
3273 static INLINE t_u8
queuing_ra_based(pmlan_private priv)3274 queuing_ra_based(pmlan_private priv)
3275 {
3276 	/*
3277 	 * Currently we assume if we are in Infra, then DA=RA. This might not be
3278 	 * true in the future
3279 	 */
3280 	if ((priv->bss_mode == MLAN_BSS_MODE_INFRA) &&
3281 	    (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA))
3282 		return MFALSE;
3283 
3284 	return MTRUE;
3285 }
3286 
3287 /**
3288  *  @brief Copy Rates
3289  *
3290  *  @param dest             A pointer to Dest Buf
3291  *  @param pos		        The position for copy
3292  *  @param src		        A pointer to Src Buf
3293  *  @param len              The len of Src Buf
3294  *
3295  *  @return                 Number of Rates copied
3296  */
3297 static INLINE t_u32
wlan_copy_rates(t_u8 * dest,t_u32 pos,t_u8 * src,int len)3298 wlan_copy_rates(t_u8 *dest, t_u32 pos, t_u8 *src, int len)
3299 {
3300 	int i;
3301 
3302 	for (i = 0; i < len && src[i]; i++, pos++) {
3303 		if (pos >= sizeof(WLAN_802_11_RATES))
3304 			break;
3305 		dest[pos] = src[i];
3306 	}
3307 
3308 	return pos;
3309 }
3310 
3311 /**
3312  *  @brief strlen
3313  *
3314  *  @param str		        A pointer to string
3315  *
3316  *  @return                 Length of string
3317  */
3318 static INLINE t_u32
wlan_strlen(const char * str)3319 wlan_strlen(const char *str)
3320 {
3321 	t_u32 i;
3322 
3323 	for (i = 0; str[i] != 0; i++) ;
3324 
3325 	return i;
3326 }
3327 
3328 /**
3329  *  @brief iscdigit
3330  *
3331  *  @param chr                  A char
3332  *
3333  *  @return                     Non zero if chr is a hex, else 0
3334  */
3335 static INLINE t_u32
wlan_isxdigit(t_u8 chr)3336 wlan_isxdigit(t_u8 chr)
3337 {
3338 	return (chr <= 'f' && chr >= 'a') || (chr <= 'F' && chr >= 'A') ||
3339 		(chr <= '9' && chr >= '0');
3340 }
3341 
3342 /**
3343  *  @brief isspace
3344  *
3345  *  @param                       A chr
3346  *
3347  *  @return                      Non zero if chr is space etc, else 0
3348  */
3349 static INLINE t_u32
wlan_isspace(t_u8 chr)3350 wlan_isspace(t_u8 chr)
3351 {
3352 	return chr <= ' ' && (chr == ' ' || (chr <= 13 && chr >= 9));
3353 }
3354 
3355 /** delay unit */
3356 typedef enum _delay_unit {
3357 	USEC,
3358 	MSEC,
3359 	SEC,
3360 } t_delay_unit;
3361 
3362 /** delay function */
3363 t_void wlan_delay_func(mlan_adapter *pmadapter, t_u32 delay, t_delay_unit u);
3364 
3365 /** delay function wrapper */
3366 #define wlan_delay(p, n)   wlan_delay_func(p, n, SEC)
3367 /** delay function wrapper */
3368 #define wlan_mdelay(p, n)  wlan_delay_func(p, n, MSEC)
3369 /** delay function wrapper */
3370 #define wlan_udelay(p, n)  wlan_delay_func(p, n, USEC)
3371 
3372 /**
3373  *  @brief This function check if there are pending cmd
3374  *         in cmd pending Q
3375  *
3376  *  @param pmadapter  A pointer to mlan_adapter structure
3377  *
3378  *  @return  MTRUE -- cmd pending
3379  *           MFALSE -- no pending cmd
3380  */
3381 static INLINE int
wlan_is_cmd_pending(mlan_adapter * pmadapter)3382 wlan_is_cmd_pending(mlan_adapter *pmadapter)
3383 {
3384 	int ret;
3385 	cmd_ctrl_node *pcmd_node = MNULL;
3386 	wlan_request_cmd_lock(pmadapter);
3387 	pcmd_node =
3388 		(cmd_ctrl_node *)util_peek_list(pmadapter->pmoal_handle,
3389 						&pmadapter->cmd_pending_q,
3390 						MNULL, MNULL);
3391 	if (pcmd_node)
3392 		ret = MTRUE;
3393 	else
3394 		ret = MFALSE;
3395 	wlan_release_cmd_lock(pmadapter);
3396 	return ret;
3397 }
3398 
3399 /** Get BSS number from priv */
3400 #define GET_BSS_NUM(priv)   ((priv)->bss_num)
3401 
3402 /**
3403  *  @brief This function returns priv based on the BSS num and BSS type
3404  *
3405  *  @param pmadapter A pointer to mlan_adapter
3406  *  @param bss_num   BSS number
3407  *  @param bss_type  BSS type
3408  *
3409  *  @return          Pointer to mlan_private
3410  */
3411 static INLINE mlan_private *
wlan_get_priv_by_id(mlan_adapter * pmadapter,t_u32 bss_num,t_u32 bss_type)3412 wlan_get_priv_by_id(mlan_adapter *pmadapter, t_u32 bss_num, t_u32 bss_type)
3413 {
3414 	int i;
3415 
3416 	for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++) {
3417 		if (pmadapter->priv[i]) {
3418 			if ((pmadapter->priv[i]->bss_num == bss_num) &&
3419 			    (pmadapter->priv[i]->bss_type == bss_type))
3420 				return pmadapter->priv[i];
3421 		}
3422 	}
3423 	return MNULL;
3424 }
3425 
3426 /**
3427  *  @brief This function returns first available priv
3428  *  based on the BSS role
3429  *
3430  *  @param pmadapter A pointer to mlan_adapter
3431  *  @param bss_role  BSS role or MLAN_BSS_ROLE_ANY
3432  *
3433  *  @return          Pointer to mlan_private
3434  */
3435 static INLINE mlan_private *
wlan_get_priv(mlan_adapter * pmadapter,mlan_bss_role bss_role)3436 wlan_get_priv(mlan_adapter *pmadapter, mlan_bss_role bss_role)
3437 {
3438 	int i;
3439 
3440 	for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++) {
3441 		if (pmadapter->priv[i]) {
3442 			if (bss_role == MLAN_BSS_ROLE_ANY ||
3443 			    GET_BSS_ROLE(pmadapter->priv[i]) == bss_role)
3444 				return pmadapter->priv[i];
3445 		}
3446 	}
3447 	return MNULL;
3448 }
3449 
3450 /**
3451  *  @brief This function counts the number of occurences for a certain
3452  *  condition among privs.  Which privs are checked can be configured
3453  *  via a second condition.
3454  *
3455  *  @param pmadapter  A pointer to mlan_adapter
3456  *  @param count_cond Function pointer to condition to count on privs
3457  *  @param check_cond Function pointer to condition to decide whether priv
3458  *                    should be counted or not.  Use MNULL to check all privs.
3459  *
3460  *  @return          Count of privs where count_cond returned MTRUE.
3461  */
3462 static int INLINE
wlan_count_priv_cond(mlan_adapter * pmadapter,t_bool (* count_cond)(IN pmlan_private pmpriv),t_bool (* check_cond)(IN pmlan_private pmpriv))3463 wlan_count_priv_cond(mlan_adapter *pmadapter,
3464 		     t_bool (*count_cond) (IN pmlan_private pmpriv),
3465 		     t_bool (*check_cond) (IN pmlan_private pmpriv))
3466 {
3467 	pmlan_private pmpriv;
3468 	int count = 0;
3469 	int i;
3470 
3471 	if (pmadapter == MNULL || count_cond == MNULL)
3472 		return 0;
3473 
3474 	for (i = 0; i < pmadapter->priv_num; i++) {
3475 		pmpriv = pmadapter->priv[i];
3476 		if (pmpriv) {
3477 			if ((check_cond == MNULL) ||
3478 			    (check_cond && check_cond(pmpriv))) {
3479 				if (count_cond(pmpriv))
3480 					count++;
3481 			}
3482 		}
3483 	}
3484 
3485 	return count;
3486 }
3487 
3488 /**
3489  *  @brief This function runs a procedure on each priv.
3490  *  Which privs it is run on can be configured via a condition.
3491  *
3492  *  @param pmadapter  A pointer to mlan_adapter
3493  *  @param operation  Function pointer to produedure to operate on priv
3494  *  @param check_cond Function pointer to condition to decide whether priv
3495  *                    operated on or not.  Use MNULL to run on all privs.
3496  *
3497  *  @return           Number of privs that operation was run on.
3498  */
3499 static int INLINE
wlan_do_task_on_privs(mlan_adapter * pmadapter,t_void (* operation)(IN pmlan_private pmpriv),t_bool (* check_cond)(IN pmlan_private pmpriv))3500 wlan_do_task_on_privs(mlan_adapter *pmadapter,
3501 		      t_void (*operation) (IN pmlan_private pmpriv),
3502 		      t_bool (*check_cond) (IN pmlan_private pmpriv))
3503 {
3504 	pmlan_private pmpriv;
3505 	int count = 0;
3506 	int i;
3507 
3508 	if (pmadapter == MNULL || operation == MNULL)
3509 		return 0;
3510 
3511 	for (i = 0; i < pmadapter->priv_num; i++) {
3512 		pmpriv = pmadapter->priv[i];
3513 		if (pmpriv) {
3514 			if ((check_cond == MNULL) ||
3515 			    (check_cond && check_cond(pmpriv))) {
3516 				operation(pmpriv);
3517 				count++;
3518 			}
3519 		}
3520 	}
3521 
3522 	return count;
3523 }
3524 
3525 /**
3526  *  @brief This function builds a list of privs that test for a condition
3527  *  This is useful if you need to do a number of operations on the same set
3528  *  of privs.  For one-off tasks, the above two functions might be better.
3529  *
3530  *  @param pmadapter  A pointer to mlan_adapter
3531  *  @param check_cond Function pointer to condition to decide whether priv
3532  *                    should be placed in the list.
3533  *  @param ppriv_list Output param.  Externally supplied array of mlan_private*
3534  *                    to hold priv's that test positive with check_cond.
3535  *                    Array size should be at least pmadapter->priv_num.
3536  *
3537  *  @return          Number of privs in ppriv_list
3538  *
3539  *  @sa              wlan_count_priv_cond
3540  */
3541 static int INLINE
wlan_get_privs_by_cond(mlan_adapter * pmadapter,t_bool (* check_cond)(IN pmlan_private pmpriv),mlan_private ** ppriv_list)3542 wlan_get_privs_by_cond(mlan_adapter *pmadapter,
3543 		       t_bool (*check_cond) (IN pmlan_private pmpriv),
3544 		       mlan_private **ppriv_list)
3545 {
3546 	pmlan_private pmpriv;
3547 	int count = 0;
3548 	int i;
3549 
3550 	if (pmadapter == MNULL || check_cond == MNULL || ppriv_list == MNULL)
3551 		return 0;
3552 
3553 	for (i = 0; i < pmadapter->priv_num; i++) {
3554 		pmpriv = pmadapter->priv[i];
3555 		if (pmpriv) {
3556 			if (check_cond(pmpriv))
3557 				ppriv_list[count++] = pmpriv;
3558 		}
3559 	}
3560 
3561 	return count;
3562 }
3563 
3564 /**
3565  *  @brief This function builds a list of privs that test against two conditions
3566  *  This is useful if you need to do a number of operations on the same set
3567  *  of privs.  Can choose whether both conditions (AND) or either condition (OR)
3568  *  is required.
3569  *
3570  *  @param pmadapter      A pointer to mlan_adapter
3571  *  @param check_cond     Function pointer to condition to decide whether priv
3572  *                        should be placed in the list.
3573  *  @param check_cond_2   Function pointer to second condition to check.
3574  *  @param and_conditions If MTRUE, both conditions must be met (AND),
3575  *                        else either condition can be met (OR).
3576  *  @param ppriv_list     Output param.  Externally supplied array of mlan_private*
3577  *                        to hold priv's that test positive with check_cond.
3578  *                        Array size should be at least pmadapter->priv_num.
3579  *
3580  *  @return          Number of privs in ppriv_list
3581  *
3582  *  @sa              wlan_count_priv_cond, wlan_get_privs_by_cond
3583  */
3584 static int INLINE
wlan_get_privs_by_two_cond(mlan_adapter * pmadapter,t_bool (* check_cond)(IN pmlan_private pmpriv),t_bool (* check_cond_2)(IN pmlan_private pmpriv),t_bool and_conditions,mlan_private ** ppriv_list)3585 wlan_get_privs_by_two_cond(mlan_adapter *pmadapter,
3586 			   t_bool (*check_cond) (IN pmlan_private pmpriv),
3587 			   t_bool (*check_cond_2) (IN pmlan_private pmpriv),
3588 			   t_bool and_conditions, mlan_private **ppriv_list)
3589 {
3590 	pmlan_private pmpriv;
3591 	int count = 0;
3592 	int i;
3593 
3594 	if (pmadapter == MNULL || check_cond == MNULL ||
3595 	    check_cond_2 == MNULL || ppriv_list == MNULL)
3596 		return 0;
3597 
3598 	for (i = 0; i < pmadapter->priv_num; i++) {
3599 		pmpriv = pmadapter->priv[i];
3600 		if (pmpriv) {
3601 			if (and_conditions) {
3602 				if (check_cond(pmpriv) && check_cond_2(pmpriv))
3603 					ppriv_list[count++] = pmpriv;
3604 			} else {
3605 				if (check_cond(pmpriv) || check_cond_2(pmpriv))
3606 					ppriv_list[count++] = pmpriv;
3607 			}
3608 		}
3609 	}
3610 
3611 	return count;
3612 }
3613 #endif /* !_MLAN_MAIN_H_ */
3614