1 /** @file moal_main.h
2 *
3 * @brief This file contains wlan driver specific defines etc.
4 *
5 *
6 * Copyright 2008-2022 NXP
7 *
8 * This software file (the File) is distributed by NXP
9 * under the terms of the GNU General Public License Version 2, June 1991
10 * (the License). You may use, redistribute and/or modify the File in
11 * accordance with the terms and conditions of the License, a copy of which
12 * is available by writing to the Free Software Foundation, Inc.,
13 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
14 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
15 *
16 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
18 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
19 * this warranty disclaimer.
20 *
21 */
22
23 /********************************************************
24 Change log:
25 10/21/2008: initial version
26 ********************************************************/
27
28 #ifndef _MOAL_MAIN_H
29 #define _MOAL_MAIN_H
30
31 /* warnfix for FS redefination if any? */
32 #ifdef FS
33 #undef FS
34 #endif
35
36 /* Linux header files */
37 #include <linux/kernel.h>
38 #include <linux/module.h>
39 #include <linux/init.h>
40 #include <linux/version.h>
41 #include <linux/param.h>
42 #include <linux/delay.h>
43 #include <linux/slab.h>
44 #include <linux/mm.h>
45 #include <linux/types.h>
46 #include <linux/sched.h>
47 #include <linux/timer.h>
48 #include <linux/ioport.h>
49 #include <linux/pci.h>
50 #include <linux/ctype.h>
51 #include <linux/proc_fs.h>
52 #include <linux/vmalloc.h>
53 #include <linux/ptrace.h>
54 #include <linux/string.h>
55 #include <linux/irqreturn.h>
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
57 #include <linux/namei.h>
58 #include <linux/fs.h>
59 #endif
60 #include <linux/of.h>
61
62 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
63 #include <linux/config.h>
64 #endif
65
66 #ifdef USB
67 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
68 #include <linux/freezer.h>
69 #endif
70 #include <linux/usb.h>
71 #endif /* USB */
72
73 /* ASM files */
74 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
75 #include <linux/semaphore.h>
76 #else
77 #include <asm/semaphore.h>
78 #endif
79 #include <asm/byteorder.h>
80 #include <asm/irq.h>
81 #include <asm/uaccess.h>
82 #include <asm/io.h>
83 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
84 #include <asm/switch_to.h>
85 #else
86 #include <asm/system.h>
87 #endif
88
89 #include <linux/spinlock.h>
90
91 /* Net header files */
92 #include <linux/netdevice.h>
93 #include <linux/net.h>
94 #include <linux/inet.h>
95 #include <linux/ip.h>
96 #include <linux/skbuff.h>
97 #include <linux/if_arp.h>
98 #include <linux/if_ether.h>
99 #include <linux/etherdevice.h>
100 #include <net/sock.h>
101 #include <net/arp.h>
102 #include <linux/rtnetlink.h>
103 #include <linux/inetdevice.h>
104
105 #include <linux/firmware.h>
106
107 #ifdef ANDROID_KERNEL
108 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
109 #include <linux/pm_wakeup.h>
110 #include <linux/device.h>
111 #else
112 #include <linux/wakelock.h>
113 #endif
114 #endif
115
116 #include <net/ieee80211_radiotap.h>
117
118 #include "mlan.h"
119 #include "moal_shim.h"
120 /* Wireless header */
121 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
122 #include <net/lib80211.h>
123 #include <net/cfg80211.h>
124 #include <net/ieee80211_radiotap.h>
125 #endif
126 #if defined(STA_WEXT) || defined(UAP_WEXT)
127 #include <linux/wireless.h>
128 #include <net/iw_handler.h>
129 #include "moal_wext.h"
130 #endif
131 #ifdef STA_WEXT
132 #include "moal_priv.h"
133 #endif
134
135 #ifdef IMX_SUPPORT
136 #include <linux/of_irq.h>
137 #include <linux/suspend.h>
138 #endif /* IMX_SUPPORT */
139
140 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
141 #include <linux/pm_qos.h>
142 #else
143 #include <linux/pm_qos_params.h>
144 #endif
145
146 #ifndef MIN
147 /** Find minimum */
148 #define MIN(a, b) ((a) < (b) ? (a) : (b))
149 #endif
150
151 /** Find maximum */
152 #ifndef MAX
153 #define MAX(a, b) ((a) > (b) ? (a) : (b))
154 #endif
155
156 #define COMPAT_VERSION_CODE KERNEL_VERSION(0, 0, 0)
157 #define CFG80211_VERSION_CODE MAX(LINUX_VERSION_CODE, COMPAT_VERSION_CODE)
158
159 #define IMX_ANDROID_13 0
160
161 #if defined(IMX_SUPPORT)
162 #if defined(IMX_ANDROID)
163 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 15, 41)
164 #undef IMX_ANDROID_13
165 #define IMX_ANDROID_13 1
166 #endif
167 #endif
168 #endif
169
170 /**
171 * Reason Code 3: STA is leaving (or has left) IBSS or ESS
172 */
173 #define DEF_DEAUTH_REASON_CODE (0x3)
174
175 /**
176 * 802.1 Local Experimental 1.
177 */
178
179 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 24)
180 #define REFDATA __refdata
181 #else
182 #define REFDATA
183 #endif
184
185 /**
186 * Linux Kernels later 3.9 use CONFIG_PM_RUNTIME instead of
187 * CONFIG_USB_SUSPEND
188 * Linux Kernels later 3.19 use CONFIG_PM instead of
189 * CONFIG_PM_RUNTIME
190 */
191 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
192 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
193 #ifdef CONFIG_PM
194 #ifndef CONFIG_USB_SUSPEND
195 #define CONFIG_USB_SUSPEND
196 #endif
197 #ifndef CONFIG_PM_RUNTIME
198 #define CONFIG_PM_RUNTIME
199 #endif
200 #endif
201 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) */
202 #ifdef CONFIG_PM_RUNTIME
203 #ifndef CONFIG_USB_SUSPEND
204 #define CONFIG_USB_SUSPEND
205 #endif
206 #endif
207 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) */
208 #endif
209
210 /**
211 * Linux kernel later 3.10 use strncasecmp instead of strnicmp
212 */
213 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
214 #define strnicmp strncasecmp
215 #endif
216
217 /**
218 * Linux kernel later 4.7 use nl80211_band instead of ieee80211_band
219 * Linux kernel later 4.7 use new macro
220 */
221 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
222 #define ieee80211_band nl80211_band
223 #define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
224 #define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
225 #define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
226 #endif
227
228 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
229 #define IEEE80211_BAND_6GHZ NL80211_BAND_6GHZ
230 #endif
231
232 /**
233 * interface name
234 */
235 #define default_mlan_name "mlan%d"
236 #define default_uap_name "uap%d"
237 #define default_wfd_name "wfd%d"
238 #define default_nan_name "nan%d"
239 #define default_mpl_name "mpl%d"
240 #define default_11p_name "ocb%d"
241 #define default_dfs_name "dfs%d"
242 #define mwiphy_name "mwiphy%d"
243
244 /** country txpower mode */
245 #define CNTRY_TXPOWER_MODE 1
246 /** country rgpower mode */
247 #define CNTRY_RGPOWER_MODE 2
248
249 /** Define BOOLEAN */
250 typedef t_u8 BOOLEAN;
251
252 #define INTF_CARDTYPE "----------%s-MM"
253
254 #define KERN_VERSION "5X"
255
256 #define V14 "14"
257 #define V15 "15"
258 #define V16 "16"
259 #define V17 "17"
260 #define V18 "18"
261
262 /** Chip Magic Value */
263 #define CHIP_MAGIC_VALUE 0x24
264 /** card type SD_UART */
265 #define CARD_TYPE_SD_UART 0
266 /** card type SD_SD */
267 #define CARD_TYPE_SD_SD 1
268 /** card type PCIE_PCIE */
269 #define CARD_TYPE_PCIE_PCIE 2
270 /** card type PCIE_UART */
271 #define CARD_TYPE_PCIE_UART 3
272 /** card type USB_UART */
273 #define CARD_TYPE_USB_UART 4
274 /** card type USB_USB */
275 #define CARD_TYPE_USB_USB 6
276 /** card type PCIE_USB */
277 #define CARD_TYPE_PCIE_USB 7
278 /** card type SD9177_UART */
279 #define CARD_TYPE_SD9177_UART 1 // As per datasheet/SoC design
280
281 /** Driver version */
282 extern char driver_version[];
283
284 extern struct semaphore AddRemoveCardSem;
285 extern int wifi_status;
286 extern int max_tx_buf;
287 extern int pcie_int_mode;
288
289 #ifdef STA_SUPPORT
290 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
291 extern const struct net_device_ops woal_netdev_ops;
292 #endif
293 #endif
294
295 #ifdef UAP_SUPPORT
296 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
297 extern const struct net_device_ops woal_uap_netdev_ops;
298 #endif
299 #endif
300
301 /** Global veriable for usb independent reset */
302 extern int fw_reload;
303
304 #ifdef MFG_CMD_SUPPORT
305 /** Mfg mode */
306 extern int mfg_mode;
307 #endif
308
309 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
310 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
311 extern int fw_region;
312 #endif
313 #endif
314
315 #if defined(USB)
316 extern int skip_fwdnld;
317 #endif
318 #if defined(SDIO) || defined(PCIE)
319 typedef enum {
320 RDWR_STATUS_SUCCESS = 0,
321 RDWR_STATUS_FAILURE = 1,
322 RDWR_STATUS_DONE = 2
323 } rdwr_status;
324 #endif
325 /** Private structure for MOAL */
326 typedef struct _moal_private moal_private, *pmoal_private;
327 /** Handle data structure for MOAL */
328 typedef struct _moal_handle moal_handle, *pmoal_handle;
329
330 /** Hardware status codes */
331 typedef enum _MOAL_HARDWARE_STATUS {
332 HardwareStatusReady,
333 HardwareStatusInitializing,
334 HardwareStatusFwReady,
335 HardwareStatusReset,
336 HardwareStatusClosing,
337 HardwareStatusNotReady
338 } MOAL_HARDWARE_STATUS;
339
340 #define WIFI_STATUS_OK 0
341 #define WIFI_STATUS_FW_DNLD 1
342 #define WIFI_STATUS_FW_DNLD_COMPLETE 2
343 #define WIFI_STATUS_INIT_FW 3
344 #define WIFI_STATUS_DNLD_FW_FAIL 4
345 #define WIFI_STATUS_INIT_FW_FAIL 5
346 #define WIFI_STATUS_TX_TIMEOUT 6
347 #define WIFI_STATUS_WIFI_HANG 7
348 #define WIFI_STATUS_SCAN_TIMEOUT 8
349 #define WIFI_STATUS_FW_DUMP 9
350 #define WIFI_STATUS_FW_RELOAD 10
351
352 /** fw cap info 11p */
353 #define FW_CAPINFO_80211P MBIT(24)
354 /** fw cap info bit26 for 0-DFS support */
355 #define FW_CAPINFO_ZERO_DFS MBIT(31)
356 /** fw cap info disable nan */
357 #define FW_CAPINFO_DISABLE_NAN MBIT(29)
358 /** fw cap info BGA */
359 #define FW_CAPINFO_80211BGA (MBIT(8) | MBIT(9) | MBIT(10))
360
361 /** moal_wait_option */
362 enum { MOAL_NO_WAIT, MOAL_IOCTL_WAIT, MOAL_IOCTL_WAIT_TIMEOUT };
363
364 /** moal_main_state */
365 enum { MOAL_STATE_IDLE,
366 MOAL_RECV_INT,
367 MOAL_ENTER_WORK_QUEUE,
368 MOAL_START_MAIN_PROCESS,
369 MOAL_END_MAIN_PROCESS };
370
371 /** HostCmd_Header */
372 typedef struct _HostCmd_Header {
373 /** Command */
374 t_u16 command;
375 /** Size */
376 t_u16 size;
377 } HostCmd_Header;
378
379 /*
380 * OS timer specific
381 */
382
383 /** Timer structure */
384 typedef struct _moal_drv_timer {
385 /** Timer list */
386 struct timer_list tl;
387 /** Timer function */
388 void (*timer_function)(void *context);
389 /** Timer function context */
390 void *function_context;
391 /** Time period */
392 t_u32 time_period;
393 /** Is timer periodic ? */
394 t_u32 timer_is_periodic;
395 /** Is timer cancelled ? */
396 t_u32 timer_is_canceled;
397 } moal_drv_timer, *pmoal_drv_timer;
398
399 /**
400 * @brief Timer handler
401 *
402 * @param fcontext Timer context
403 *
404 * @return N/A
405 */
406 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
woal_timer_handler(struct timer_list * t)407 static inline void woal_timer_handler(struct timer_list *t)
408 {
409 pmoal_drv_timer timer = from_timer(timer, t, tl);
410 #else
411 static inline void woal_timer_handler(unsigned long fcontext)
412 {
413 pmoal_drv_timer timer = (pmoal_drv_timer)fcontext;
414 #endif
415
416 if (!timer->timer_is_canceled)
417 timer->timer_function(timer->function_context);
418
419 if (timer->timer_is_periodic == MTRUE && !timer->timer_is_canceled) {
420 mod_timer(&timer->tl,
421 jiffies + ((timer->time_period * HZ) / 1000));
422 } else {
423 timer->timer_is_canceled = MTRUE;
424 timer->time_period = 0;
425 }
426 }
427
428 /**
429 * @brief Initialize timer
430 *
431 * @param timer Timer structure
432 * @param TimerFunction Timer function
433 * @param FunctionContext Timer function context
434 *
435 * @return N/A
436 */
437 static inline void woal_initialize_timer(pmoal_drv_timer timer,
438 void (*TimerFunction)(void *context),
439 void *FunctionContext)
440 {
441 /* First, setup the timer to trigger the wlan_timer_handler proxy */
442 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
443 timer_setup(&timer->tl, woal_timer_handler, 0);
444 #else
445 init_timer(&timer->tl);
446 timer->tl.function = woal_timer_handler;
447 timer->tl.data = (t_ptr)timer;
448 #endif
449
450 /* Then tell the proxy which function to call and what to pass it */
451 timer->timer_function = TimerFunction;
452 timer->function_context = FunctionContext;
453 timer->timer_is_canceled = MTRUE;
454 timer->time_period = 0;
455 timer->timer_is_periodic = MFALSE;
456 }
457
458 /**
459 * @brief Modify timer
460 *
461 * @param timer Timer structure
462 * @param millisecondperiod Time period in millisecond
463 *
464 * @return N/A
465 */
466 static inline void woal_mod_timer(pmoal_drv_timer timer,
467 t_u32 millisecondperiod)
468 {
469 timer->time_period = millisecondperiod;
470 mod_timer(&timer->tl, jiffies + (millisecondperiod * HZ) / 1000);
471 timer->timer_is_canceled = MFALSE;
472 }
473
474 /**
475 * @brief Cancel timer
476 *
477 * @param timer Timer structure
478 *
479 * @return N/A
480 */
481 static inline void woal_cancel_timer(moal_drv_timer *timer)
482 {
483 if (timer->timer_is_periodic || in_atomic() || irqs_disabled())
484 del_timer(&timer->tl);
485 else
486 del_timer_sync(&timer->tl);
487 timer->timer_is_canceled = MTRUE;
488 timer->time_period = 0;
489 }
490
491 #ifdef REASSOCIATION
492 /*
493 * OS Thread Specific
494 */
495
496 #include <linux/kthread.h>
497
498 /** Kernel thread structure */
499 typedef struct _moal_thread {
500 /** Task control structrue */
501 struct task_struct *task;
502 /** Pointer to wait_queue_head */
503 wait_queue_head_t wait_q;
504 /** PID */
505 pid_t pid;
506 /** Pointer to moal_handle */
507 void *handle;
508 } moal_thread;
509
510 /**
511 * @brief Activate thread
512 *
513 * @param thr Thread structure
514 * @return N/A
515 */
516 static inline void woal_activate_thread(moal_thread *thr)
517 {
518 /** Initialize the wait queue */
519 init_waitqueue_head(&thr->wait_q);
520
521 /** Record the thread pid */
522 thr->pid = current->pid;
523 }
524
525 /**
526 * @brief De-activate thread
527 *
528 * @param thr Thread structure
529 * @return N/A
530 */
531 static inline void woal_deactivate_thread(moal_thread *thr)
532 {
533 /* Reset the pid */
534 thr->pid = 0;
535 }
536
537 /**
538 * @brief Create and run the thread
539 *
540 * @param threadfunc Thread function
541 * @param thr Thread structure
542 * @param name Thread name
543 * @return N/A
544 */
545 static inline void woal_create_thread(int (*threadfunc)(void *),
546 moal_thread *thr, char *name)
547 {
548 /* Create and run the thread */
549 thr->task = kthread_run(threadfunc, thr, "%s", name);
550 }
551 #endif /* REASSOCIATION */
552
553 /* The following macros are neccessary to retain compatibility
554 * around the workqueue chenges happened in kernels >= 2.6.20:
555 * - INIT_WORK changed to take 2 arguments and let the work function
556 * get its own data through the container_of macro
557 * - delayed works have been split from normal works to save some
558 * memory usage in struct work_struct
559 */
560 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
561 /** Work_queue work initialization */
562 #define MLAN_INIT_WORK(_work, _fun) \
563 INIT_WORK(_work, ((void (*)(void *))_fun), _work)
564 /** Work_queue delayed work initialization */
565 #define MLAN_INIT_DELAYED_WORK(_work, _fun) \
566 INIT_WORK(_work, ((void (*)(void *))_fun), _work)
567 /** Work_queue container parameter */
568 #define MLAN_DELAYED_CONTAINER_OF(_ptr, _type, _m) container_of(_ptr, _type, _m)
569 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) */
570 /** Work_queue work initialization */
571 #define MLAN_INIT_WORK INIT_WORK
572 /** Work_queue delayed work initialization */
573 #define MLAN_INIT_DELAYED_WORK INIT_DELAYED_WORK
574 /** Work_queue container parameter */
575 #define MLAN_DELAYED_CONTAINER_OF(_ptr, _type, _m) \
576 container_of(_ptr, _type, _m.work)
577 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) */
578
579 /**
580 * @brief Schedule timeout
581 *
582 * @param millisec Timeout duration in milli second
583 *
584 * @return N/A
585 */
586 static inline void woal_sched_timeout(t_u32 millisec)
587 {
588 set_current_state(TASK_INTERRUPTIBLE);
589
590 schedule_timeout((millisec * HZ) / 1000);
591 }
592
593 /**
594 * @brief Schedule timeout uninterruptible
595 *
596 * @param millisec Timeout duration in milli second
597 *
598 * @return N/A
599 */
600 static inline void woal_sched_timeout_uninterruptible(t_u32 millisec)
601 {
602 set_current_state(TASK_UNINTERRUPTIBLE);
603 schedule_timeout_uninterruptible((millisec * HZ) / 1000);
604 }
605
606 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
607 #define IN6PTON_XDIGIT 0x00010000
608 #define IN6PTON_DIGIT 0x00020000
609 #define IN6PTON_COLON_MASK 0x00700000
610 #define IN6PTON_COLON_1 0x00100000 /* single : requested */
611 #define IN6PTON_COLON_2 0x00200000 /* second : requested */
612 #define IN6PTON_COLON_1_2 0x00400000 /* :: requested */
613 #define IN6PTON_DOT 0x00800000 /* . */
614 #define IN6PTON_DELIM 0x10000000
615 #define IN6PTON_NULL 0x20000000 /* first/tail */
616 #define IN6PTON_UNKNOWN 0x40000000
617
618 static inline int xdigit2bin(char c, int delim)
619 {
620 if (c == delim || c == '\0')
621 return IN6PTON_DELIM;
622 if (c == ':')
623 return IN6PTON_COLON_MASK;
624 if (c == '.')
625 return IN6PTON_DOT;
626 if (c >= '0' && c <= '9')
627 return IN6PTON_XDIGIT | IN6PTON_DIGIT | (c - '0');
628 if (c >= 'a' && c <= 'f')
629 return IN6PTON_XDIGIT | (c - 'a' + 10);
630 if (c >= 'A' && c <= 'F')
631 return IN6PTON_XDIGIT | (c - 'A' + 10);
632 if (delim == -1)
633 return IN6PTON_DELIM;
634 return IN6PTON_UNKNOWN;
635 }
636
637 static inline int in4_pton(const char *src, int srclen, u8 *dst, int delim,
638 const char **end)
639 {
640 const char *s;
641 u8 *d;
642 u8 dbuf[4];
643 int ret = 0;
644 int i;
645 int w = 0;
646
647 if (srclen < 0)
648 srclen = strlen(src);
649 s = src;
650 d = dbuf;
651 i = 0;
652 while (1) {
653 int c;
654 c = xdigit2bin(srclen > 0 ? *s : '\0', delim);
655 if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM |
656 IN6PTON_COLON_MASK))) {
657 goto out;
658 }
659 if (c & (IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
660 if (w == 0)
661 goto out;
662 *d++ = w & 0xff;
663 w = 0;
664 i++;
665 if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
666 if (i != 4)
667 goto out;
668 break;
669 }
670 goto cont;
671 }
672 w = (w * 10) + c;
673 if ((w & 0xffff) > 255)
674 goto out;
675 cont:
676 if (i >= 4)
677 goto out;
678 s++;
679 srclen--;
680 }
681 ret = 1;
682 moal_memcpy_ext(NULL, dst, dbuf, sizeof(dbuf), sizeof(dbuf));
683 out:
684 if (end)
685 *end = s;
686 return ret;
687 }
688 #endif /* < 2.6.19 */
689
690 #ifndef __ATTRIB_ALIGN__
691 #define __ATTRIB_ALIGN__ __attribute__((aligned(4)))
692 #endif
693
694 #ifndef __ATTRIB_PACK__
695 #define __ATTRIB_PACK__ __attribute__((packed))
696 #endif
697
698 /** Get module */
699 #define MODULE_GET try_module_get(THIS_MODULE)
700 /** Put module */
701 #define MODULE_PUT module_put(THIS_MODULE)
702
703 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
704 /** Initialize semaphore */
705 #define MOAL_INIT_SEMAPHORE(x) init_MUTEX(x)
706 /** Initialize semaphore */
707 #define MOAL_INIT_SEMAPHORE_LOCKED(x) init_MUTEX_LOCKED(x)
708 #else
709 /** Initialize semaphore */
710 #define MOAL_INIT_SEMAPHORE(x) sema_init(x, 1)
711 /** Initialize semaphore */
712 #define MOAL_INIT_SEMAPHORE_LOCKED(x) sema_init(x, 0)
713 #endif
714
715 /** Acquire semaphore and with blocking */
716 #define MOAL_ACQ_SEMAPHORE_BLOCK(x) down_interruptible(x)
717 /** Acquire semaphore without blocking */
718 #define MOAL_ACQ_SEMAPHORE_NOBLOCK(x) down_trylock(x)
719 /** Release semaphore */
720 #define MOAL_REL_SEMAPHORE(x) up(x)
721
722 /** Request FW timeout in second */
723 #define REQUEST_FW_TIMEOUT 30
724
725 #if defined(USB) || defined(SYSKT)
726 /** Max loop count (* 100ms) for waiting device ready at init time */
727 #define MAX_WAIT_DEVICE_READY_COUNT 50
728 #endif
729
730 /** Default watchdog timeout */
731 #define MRVDRV_DEFAULT_WATCHDOG_TIMEOUT (10 * HZ)
732
733 #ifdef UAP_SUPPORT
734 /** Default watchdog timeout
735 Increase the value to avoid kernel Tx timeout message in case
736 station in PS mode or left.
737 The default value of PS station ageout timer is 40 seconds.
738 Hence, the watchdog timer is set to a value higher than it.
739 */
740 #define MRVDRV_DEFAULT_UAP_WATCHDOG_TIMEOUT (41 * HZ)
741 #endif
742
743 /* IOCTL Timeout */
744 #define MOAL_IOCTL_TIMEOUT (20 * HZ)
745
746 #ifdef ANDROID_KERNEL
747 /** Wake lock timeout in msec */
748 #define WAKE_LOCK_TIMEOUT 3000
749 /** Roaming Wake lock timeout in msec */
750 #define ROAMING_WAKE_LOCK_TIMEOUT 10000
751 #endif
752
753 /** Threshold value of number of times the Tx timeout happened */
754 /* WAR For EDMAC Test */
755 #define NUM_TX_TIMEOUT_THRESHOLD 10
756 /** Custom event : DRIVER HANG */
757 #define CUS_EVT_DRIVER_HANG "EVENT=DRIVER_HANG"
758 /** Custom event : FW_DUMP */
759 #define CUS_EVT_FW_DUMP "EVENT=FW_DUMP"
760 /** Custom event : START FW RESET */
761 #define CUS_EVT_FW_RECOVER_START "EVENT=FW_RECOVER_START"
762 #define CUS_EVT_FW_RECOVER_SUCCESS "EVENT=FW_RECOVER_SUCCESS"
763 #define CUS_EVT_FW_RECOVER_FAIL "EVENT=FW_RECOVER_FAILURE"
764
765 /** TDLS connected event */
766 #define CUS_EVT_TDLS_CONNECTED "EVENT=TDLS_CONNECTED"
767 /** TDLS tear down event */
768 #define CUS_EVT_TDLS_TEARDOWN "EVENT=TDLS_TEARDOWN"
769 /** wmm info */
770 #define WMM_TYPE_INFO 0
771 /** wmm parameter */
772 #define WMM_TYPE_PARAMETER 1
773
774 /** AP connected event */
775 #define CUS_EVT_AP_CONNECTED "EVENT=AP_CONNECTED"
776
777 /** Custom event : BW changed */
778 #define CUS_EVT_BW_CHANGED "EVENT=BW_CHANGED"
779 /** Custom event : OBSS scan parameter */
780 #define CUS_EVT_OBSS_SCAN_PARAM "EVENT=OBSS_SCAN_PARAM"
781
782 /** Custom event : AdHoc link sensed */
783 #define CUS_EVT_ADHOC_LINK_SENSED "EVENT=ADHOC_LINK_SENSED"
784 /** Custom event : AdHoc link lost */
785 #define CUS_EVT_ADHOC_LINK_LOST "EVENT=ADHOC_LINK_LOST"
786 /** Custom event : MIC failure, unicast */
787 #define CUS_EVT_MLME_MIC_ERR_UNI "MLME-MICHAELMICFAILURE.indication unicast"
788 /** Custom event : MIC failure, multicast */
789 #define CUS_EVT_MLME_MIC_ERR_MUL "MLME-MICHAELMICFAILURE.indication multicast"
790 /** Custom event : Beacon RSSI low */
791 #define CUS_EVT_BEACON_RSSI_LOW "EVENT=BEACON_RSSI_LOW"
792 /** Custom event : Beacon SNR low */
793 #define CUS_EVT_BEACON_SNR_LOW "EVENT=BEACON_SNR_LOW"
794 /** Custom event : Beacon RSSI high */
795 #define CUS_EVT_BEACON_RSSI_HIGH "EVENT=BEACON_RSSI_HIGH"
796 /** Custom event : Beacon SNR high */
797 #define CUS_EVT_BEACON_SNR_HIGH "EVENT=BEACON_SNR_HIGH"
798 /** Custom event : Max fail */
799 #define CUS_EVT_MAX_FAIL "EVENT=MAX_FAIL"
800 /** Custom event : Data RSSI low */
801 #define CUS_EVT_DATA_RSSI_LOW "EVENT=DATA_RSSI_LOW"
802 /** Custom event : Data SNR low */
803 #define CUS_EVT_DATA_SNR_LOW "EVENT=DATA_SNR_LOW"
804 /** Custom event : Data RSSI high */
805 #define CUS_EVT_DATA_RSSI_HIGH "EVENT=DATA_RSSI_HIGH"
806 /** Custom event : Data SNR high */
807 #define CUS_EVT_DATA_SNR_HIGH "EVENT=DATA_SNR_HIGH"
808 /** Custom event : Link Quality */
809 #define CUS_EVT_LINK_QUALITY "EVENT=LINK_QUALITY"
810 /** Custom event : Port Release */
811 #define CUS_EVT_PORT_RELEASE "EVENT=PORT_RELEASE"
812 /** Custom event : Pre-Beacon Lost */
813 #define CUS_EVT_PRE_BEACON_LOST "EVENT=PRE_BEACON_LOST"
814
815 /** Custom event : Deep Sleep awake */
816 #define CUS_EVT_DEEP_SLEEP_AWAKE "EVENT=DS_AWAKE"
817
818 #define CUS_EVT_TOD_TOA "EVENT=TOD-TOA"
819
820 /** Custom event : Host Sleep activated */
821 #define CUS_EVT_HS_ACTIVATED "HS_ACTIVATED"
822 /** Custom event : Host Sleep deactivated */
823 #define CUS_EVT_HS_DEACTIVATED "HS_DEACTIVATED"
824 /** Custom event : Host Sleep wakeup */
825 #define CUS_EVT_HS_WAKEUP "HS_WAKEUP"
826
827 /** Wakeup Reason */
828 typedef enum {
829 NO_HSWAKEUP_REASON = 0, // 0.unknown
830 BCAST_DATA_MATCHED, // 1. Broadcast data matched
831 MCAST_DATA_MATCHED, // 2. Multicast data matched
832 UCAST_DATA_MATCHED, // 3. Unicast data matched
833 MASKTABLE_EVENT_MATCHED, // 4. Maskable event matched
834 NON_MASKABLE_EVENT_MATCHED, // 5. Non-maskable event matched
835 NON_MASKABLE_CONDITION_MATCHED, // 6. Non-maskable condition matched
836 // (EAPoL rekey)
837 MAGIC_PATTERN_MATCHED, // 7. Magic pattern matched
838 CONTROL_FRAME_MATCHED, // 8. Control frame matched
839 MANAGEMENT_FRAME_MATCHED, // 9. Management frame matched
840 GTK_REKEY_FAILURE, // 10. GTK rekey failure
841 RESERVED // Others: reserved
842 } HSWakeupReason_t;
843
844 /** Custom event : Radar Detected */
845 #define CUS_EVT_RADAR_DETECTED "EVENT=RADAR_DETECTED"
846 /** Custom event : CAC finished */
847 #define CUS_EVT_CAC_FINISHED "EVENT=CAC_FINISHED"
848 #ifdef UAP_SUPPORT
849 void woal_move_to_next_channel(moal_private *priv);
850 void woal_chan_event(moal_private *priv, t_u8 type, t_u8 channel, t_u8 radar);
851 void woal_process_chan_event(moal_private *priv, t_u8 type, t_u8 channel,
852 t_u8 radar);
853 mlan_status woal_do_dfs_cac(moal_private *priv,
854 mlan_ds_11h_chan_rep_req *ch_rpt_req);
855 #endif
856
857 /** Custom event : WEP ICV error */
858 #define CUS_EVT_WEP_ICV_ERR "EVENT=WEP_ICV_ERR"
859
860 /** Custom event : Channel Switch Announcment */
861 #define CUS_EVT_CHANNEL_SWITCH_ANN "EVENT=CHANNEL_SWITCH_ANN"
862
863 /** Custom indiciation message sent to the application layer for WMM changes */
864 #define WMM_CONFIG_CHANGE_INDICATION "WMM_CONFIG_CHANGE.indication"
865
866 #define CUS_EVT_FW_DUMP_DONE "EVENT=FW_DUMP_DONE"
867
868 #ifdef UAP_SUPPORT
869 /** Custom event : STA connected */
870 #define CUS_EVT_STA_CONNECTED "EVENT=STA_CONNECTED"
871 /** Custom event : STA disconnected */
872 #define CUS_EVT_STA_DISCONNECTED "EVENT=STA_DISCONNECTED"
873 #endif
874 #define FW_DEBUG_INFO "EVENT=FW_DEBUG_INFO"
875
876 #define CUS_EVT_CSI "EVENT=MLAN_CSI"
877
878 /** 10 seconds */
879 #define MOAL_TIMER_10S 10000
880 /** 5 seconds */
881 #define MOAL_TIMER_5S 5000
882 /** 1 second */
883 #define MOAL_TIMER_1S 1000
884 /** 1 milisecond */
885 #define MOAL_TIMER_1MS 1
886 /** scan timeout set to 25 seconds */
887 #define SCAN_TIMEOUT_25S 25000
888
889 /** passive scan time */
890 #define PASSIVE_SCAN_CHAN_TIME 110
891 /** active scan time */
892 #define ACTIVE_SCAN_CHAN_TIME 110
893 /** specific scan time */
894 #define SPECIFIC_SCAN_CHAN_TIME 110
895 /** passive scan time */
896 #define INIT_PASSIVE_SCAN_CHAN_TIME 80
897 /** active scan time */
898 #define INIT_ACTIVE_SCAN_CHAN_TIME 80
899 /** specific scan time */
900 #define INIT_SPECIFIC_SCAN_CHAN_TIME 80
901 /** specific scan time after connected */
902 #define MIN_SPECIFIC_SCAN_CHAN_TIME 40
903
904 /** Default value of re-assoc timer */
905 #define REASSOC_TIMER_DEFAULT 500
906
907 /** Netlink protocol number */
908 #define NETLINK_NXP (MAX_LINKS - 1)
909 /** Netlink maximum payload size */
910 #define NL_MAX_PAYLOAD (3 * 1024)
911 /** Netlink multicast group number */
912 #define NL_MULTICAST_GROUP 1
913
914 #define MAX_RX_PENDING_THRHLD 50
915
916 /** high rx pending packets */
917 #define USB_HIGH_RX_PENDING 100
918 /** low rx pending packets */
919 #define USB_LOW_RX_PENDING 80
920
921 /** MAX Tx Pending count */
922 #define MAX_TX_PENDING 800
923
924 /** LOW Tx Pending count */
925 #define LOW_TX_PENDING 380
926
927 /** Offset for subcommand */
928 #define SUBCMD_OFFSET 4
929
930 /** default scan channel gap */
931 #define DEF_SCAN_CHAN_GAP 50
932 /** default scan time per channel in miracast mode */
933 #define DEF_MIRACAST_SCAN_TIME 20
934 /** GAP value is optional */
935 #define GAP_FLAG_OPTIONAL MBIT(15)
936
937 /** max retry count for wait_event_interupptible_xx while loop */
938 #define MAX_RETRY_CNT 100
939 /** wait_queue structure */
940 typedef struct _wait_queue {
941 /** wait_queue_head */
942 wait_queue_head_t wait;
943 /** Wait condition */
944 BOOLEAN condition;
945 /** Start time */
946 long start_time;
947 /** Status from MLAN */
948 mlan_status status;
949 /** flag for wait_timeout */
950 t_u8 wait_timeout;
951 /** retry count */
952 t_u8 retry;
953 } wait_queue, *pwait_queue;
954
955 /** Auto Rate */
956 #define AUTO_RATE 0xFF
957
958 #define STA_WEXT_MASK MBIT(0)
959 #define UAP_WEXT_MASK MBIT(1)
960 #define STA_CFG80211_MASK MBIT(2)
961 #define UAP_CFG80211_MASK MBIT(3)
962 #ifdef STA_CFG80211
963 #ifdef STA_SUPPORT
964 /** Is STA CFG80211 enabled in module param */
965 #define IS_STA_CFG80211(x) (x & STA_CFG80211_MASK)
966 #endif
967 #endif
968 #ifdef UAP_CFG80211
969 #ifdef UAP_SUPPORT
970 /** Is UAP CFG80211 enabled in module param */
971 #define IS_UAP_CFG80211(x) (x & UAP_CFG80211_MASK)
972 #endif
973 #endif
974 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
975 /** Is UAP or STA CFG80211 enabled in module param */
976 #define IS_STA_OR_UAP_CFG80211(x) (x & (STA_CFG80211_MASK | UAP_CFG80211_MASK))
977 #endif
978
979 #ifdef STA_WEXT
980 /** Is STA WEXT enabled in module param */
981 #define IS_STA_WEXT(x) (x & STA_WEXT_MASK)
982 #endif /* STA_WEXT */
983 #ifdef UAP_WEXT
984 /** Is UAP WEXT enabled in module param */
985 #define IS_UAP_WEXT(x) (x & UAP_WEXT_MASK)
986 #endif /* UAP_WEXT */
987 #if defined(STA_WEXT) || defined(UAP_WEXT)
988 /** Is UAP or STA WEXT enabled in module param */
989 #define IS_STA_OR_UAP_WEXT(x) (x & (STA_WEXT_MASK | UAP_WEXT_MASK))
990 #endif
991
992 #ifdef STA_SUPPORT
993 /** Driver mode STA bit */
994 #define DRV_MODE_STA MBIT(0)
995 /** Maximum STA BSS */
996 #define MAX_STA_BSS 1
997 /** Default STA BSS */
998 #define DEF_STA_BSS 1
999 #endif
1000 #ifdef UAP_SUPPORT
1001 /** Driver mode uAP bit */
1002 #define DRV_MODE_UAP MBIT(1)
1003 /** Maximum uAP BSS */
1004 #define MAX_UAP_BSS 3
1005 /** Default uAP BSS */
1006 #define DEF_UAP_BSS 1
1007
1008 /** WACP Modes for uAP */
1009 #define WACP_MODE_DEFAULT 0
1010 #define WACP_MODE_1 1
1011 #define WACP_MODE_2 2
1012 #endif
1013 #ifdef WIFI_DIRECT_SUPPORT
1014 /** Driver mode WIFIDIRECT bit */
1015 #define DRV_MODE_WIFIDIRECT MBIT(2)
1016 /** Maximum WIFIDIRECT BSS */
1017 #define MAX_WIFIDIRECT_BSS 2
1018 /** Default WIFIDIRECT BSS */
1019 #define DEF_WIFIDIRECT_BSS 1
1020 #if defined(STA_CFG80211) && defined(UAP_CFG80211)
1021 #define DEF_VIRTUAL_BSS 0
1022 #endif
1023 #endif /* WIFI_DIRECT_SUPPORT */
1024
1025 /**Driver mode 0DFS bit**/
1026 #define DRV_MODE_DFS MBIT(7)
1027 /**Maxinmum DFS BSS**/
1028 #define MAX_DFS_BSS 1
1029 /**Default DFS BSS**/
1030 #define DEF_DFS_BSS 1
1031
1032 #define DRV_MODE_WLAN (MBIT(0) | MBIT(1) | MBIT(2) | MBIT(3) | MBIT(4))
1033
1034 /**
1035 * the maximum number of adapter supported
1036 **/
1037 #define MAX_MLAN_ADAPTER 4
1038
1039 typedef struct _moal_drv_mode {
1040 /** driver mode */
1041 t_u16 drv_mode;
1042 /** total number of interfaces */
1043 t_u16 intf_num;
1044 /** attribute of bss */
1045 mlan_bss_attr *bss_attr;
1046 /** name of firmware image */
1047 char *fw_name;
1048 } moal_drv_mode;
1049
1050 extern moal_handle *m_handle[MAX_MLAN_ADAPTER];
1051
1052 /** Indicate if handle->info's address */
1053 #define INFO_ADDR BIT(0)
1054 #define IS_INFO_ADDR(attr) (attr & INFO_ADDR)
1055 /** Indicate if handle's address */
1056 #define HANDLE_ADDR BIT(1)
1057 #define IS_HANDLE_ADDR(attr) (attr & HANDLE_ADDR)
1058 /** Indicate if card's address */
1059 #define CARD_ADDR BIT(2)
1060 #define IS_CARD_ADDR(attr) (attr & CARD_ADDR)
1061 /** indicate if priv's address */
1062 #define PRIV_ADDR BIT(3)
1063 #define IS_PRIV_ADDR(attr) (attr & PRIV_ADDR)
1064
1065 /** Debug data */
1066 struct debug_data {
1067 /** Name */
1068 char name[32];
1069 /** Size */
1070 t_u32 size;
1071 /** Address */
1072 t_ptr addr;
1073 /** Attribute:
1074 0-7bit: start address for addr to add to, 0 means common(no specific)
1075 8-15bit: interface type, 0 means common(no interface specific)
1076 other: unused
1077 */
1078 t_u32 attr;
1079 };
1080
1081 /** Private debug data */
1082 struct debug_data_priv {
1083 /** moal_private handle */
1084 moal_private *priv;
1085 /** Debug items */
1086 struct debug_data *items;
1087 /** numbre of item */
1088 int num_of_items;
1089 };
1090
1091 /** Maximum IP address buffer length */
1092 #define IPADDR_MAX_BUF 20
1093 /** IP address operation: Remove */
1094 #define IPADDR_OP_REMOVE 0
1095
1096 #define TCP_ACK_MAX_HOLD 9
1097 #define DROP_TCP_ACK 1
1098 #define HOLD_TCP_ACK 2
1099 struct tcp_sess {
1100 struct list_head link;
1101 /** tcp session info */
1102 t_u32 src_ip_addr;
1103 t_u32 dst_ip_addr;
1104 t_u16 src_tcp_port;
1105 t_u16 dst_tcp_port;
1106 /** tx ack packet info */
1107 t_u32 ack_seq;
1108 /** tcp ack buffer */
1109 void *ack_skb;
1110 /** priv structure */
1111 void *priv;
1112 /** pmbuf */
1113 void *pmbuf;
1114 /** timer for ack */
1115 moal_drv_timer ack_timer __ATTRIB_ALIGN__;
1116 /** timer is set */
1117 atomic_t is_timer_set;
1118 /** last update time*/
1119 wifi_timeval update_time;
1120 };
1121
1122 struct tx_status_info {
1123 struct list_head link;
1124 /** cookie */
1125 t_u64 tx_cookie;
1126 /** seq_num */
1127 t_u8 tx_seq_num;
1128 /** cancel remain on channel when receive tx status */
1129 t_u8 cancel_remain_on_channel;
1130 /** skb */
1131 void *tx_skb;
1132 };
1133
1134 /** woal event type */
1135 enum woal_event_type {
1136 WOAL_EVENT_CHAN_SWITCH,
1137 WOAL_EVENT_RX_MGMT_PKT,
1138 WOAL_EVENT_BGSCAN_STOP,
1139 #if defined(UAP_CFG80211) || defined(STA_CFG80211)
1140 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
1141 WOAL_EVENT_DEAUTH,
1142 WOAL_EVENT_ASSOC_RESP,
1143 #endif
1144 #endif
1145 WOAL_EVENT_CHAN_RPT,
1146 WOAL_EVENT_RADAR,
1147 #ifdef UAP_CFG80211
1148 #if KERNEL_VERSION(3, 12, 0) <= CFG80211_VERSION_CODE
1149 WOAL_EVENT_CANCEL_CHANRPT,
1150 #endif
1151 #endif
1152 };
1153
1154 /** chan_rpt_info */
1155 typedef struct _chan_radar_info {
1156 /** channel */
1157 t_u8 channel;
1158 /** radar */
1159 t_u8 radar;
1160 } chan_radar_info;
1161
1162 typedef struct _woal_evt_buf {
1163 /** Event len */
1164 t_u16 event_len;
1165 /** Event buffer */
1166 t_u8 event_buf[1500];
1167 } woal_evt_buf;
1168
1169 /** woal event */
1170 struct woal_event {
1171 /*list head */
1172 struct list_head link;
1173 /** type */
1174 enum woal_event_type type;
1175 /** priv pointer */
1176 void *priv;
1177 union {
1178 chan_band_info chan_info;
1179 woal_evt_buf evt;
1180 mlan_ds_assoc_info assoc_info;
1181 int reason_code;
1182 chan_radar_info radar_info;
1183 };
1184 };
1185
1186 #define MAX_NUM_ETHER_TYPE 8
1187 typedef struct {
1188 /** number of protocols in protocol array*/
1189 t_u8 protocol_num;
1190 /** protocols supported */
1191 t_u16 protocols[MAX_NUM_ETHER_TYPE];
1192 } __ATTRIB_PACK__ dot11_protocol;
1193 typedef struct {
1194 /** Data rate in unit of 0.5Mbps */
1195 t_u16 datarate;
1196 /** Channel number to transmit the frame */
1197 t_u8 channel;
1198 /** Bandwidth to transmit the frame */
1199 t_u8 bw;
1200 /** Power to be used for transmission */
1201 t_u8 power;
1202 /** Priority of the packet to be transmitted */
1203 t_u8 priority;
1204 /** retry time of tx transmission*/
1205 t_u8 retry_limit;
1206 /** Reserved fields*/
1207 t_u8 reserved[1];
1208 } __ATTRIB_PACK__ dot11_txcontrol;
1209
1210 typedef struct {
1211 /** Data rate of received paccket*/
1212 t_u16 datarate;
1213 /** Channel on which packet was received*/
1214 t_u8 channel;
1215 /** Rx antenna*/
1216 t_u8 antenna;
1217 /** RSSI */
1218 t_u8 rssi;
1219 /** Reserved */
1220 t_u8 reserved[3];
1221 } __ATTRIB_PACK__ dot11_rxcontrol;
1222
1223 #define OKC_WAIT_TARGET_PMKSA_TIMEOUT (4 * HZ / 1000)
1224 #define PMKID_LEN 16
1225 struct pmksa_entry {
1226 struct list_head link;
1227 u8 bssid[ETH_ALEN];
1228 u8 pmkid[PMKID_LEN];
1229 };
1230
1231 /** default rssi low threshold */
1232 #define TDLS_RSSI_LOW_THRESHOLD 55
1233 /** default rssi high threshold */
1234 #define TDLS_RSSI_HIGH_THRESHOLD 50
1235 /** TDLS idle time */
1236 #define TDLS_IDLE_TIME (10 * HZ)
1237 /** TDLS max failure count */
1238 #define TDLS_MAX_FAILURE_COUNT 4
1239 /** TDLS tear down reason */
1240 #define TDLS_TEARN_DOWN_REASON_UNSPECIFIC 26
1241
1242 /** TDLS status */
1243 typedef enum _tdlsStatus_e {
1244 TDLS_NOT_SETUP = 0,
1245 TDLS_SETUP_INPROGRESS,
1246 TDLS_SETUP_COMPLETE,
1247 TDLS_SETUP_FAILURE,
1248 TDLS_TEAR_DOWN,
1249 TDLS_SWITCHING_CHANNEL,
1250 TDLS_IN_BASE_CHANNEL,
1251 TDLS_IN_OFF_CHANNEL,
1252 } tdlsStatus_e;
1253
1254 /** tdls peer_info */
1255 struct tdls_peer {
1256 struct list_head link;
1257 /** MAC address information */
1258 t_u8 peer_addr[ETH_ALEN];
1259 /** rssi */
1260 int rssi;
1261 /** jiffies with rssi */
1262 long rssi_jiffies;
1263 /** link status */
1264 tdlsStatus_e link_status;
1265 /** num of set up failure */
1266 t_u8 num_failure;
1267 };
1268
1269 /** mcast node */
1270 struct mcast_node {
1271 struct list_head link;
1272 /** mcast address information */
1273 t_u8 mcast_addr[ETH_ALEN];
1274 };
1275
1276 /** This is a flag for auto assoc/re-connect retry forever */
1277 #define AUTO_ASSOC_RETRY_FOREVER 0xFFFF
1278
1279 typedef enum {
1280 AUTO_ASSOC_TYPE_NONE = 0,
1281 AUTO_ASSOC_TYPE_DRV_ASSOC,
1282 AUTO_ASSOC_TYPE_DRV_RECONN,
1283 AUTO_ASSOC_TYPE_FW_RECONN,
1284 } AUTO_ASSOC_TYPE;
1285
1286 typedef struct {
1287 /** driver auto assoc retry count */
1288 t_u8 retry_count;
1289 /** driver auto assoc retry interval */
1290 t_u8 retry_interval;
1291 /** driver auto assoc status */
1292 t_u8 status;
1293 } drv_auto_assoc;
1294
1295 typedef struct {
1296 /** Bitmap for auto assoc type on/off */
1297 t_u8 auto_assoc_type_on;
1298 /** flag of being triggered by drv auto assoc/re-connect */
1299 t_u8 auto_assoc_trigger_flag;
1300 /** driver auto assoc info*/
1301 drv_auto_assoc drv_assoc;
1302 /** driver auto re-connect info*/
1303 drv_auto_assoc drv_reconnect;
1304 } auto_assoc;
1305
1306 struct rf_test_mode_data {
1307 /* tx antenna num */
1308 t_u32 tx_antenna;
1309 /* rx antenna num */
1310 t_u32 rx_antenna;
1311 /* radio mode */
1312 t_u32 radio_mode[2];
1313 /* RF band */
1314 t_u32 band;
1315 /* RF bandwidth */
1316 t_u32 bandwidth;
1317 /* RF channel */
1318 t_u32 channel;
1319 /* Total Rx ucast/mcast/bcast pkt count */
1320 t_u32 rx_tot_pkt_count;
1321 /* Rx mcast/bcast pkt count */
1322 t_u32 rx_mcast_bcast_pkt_count;
1323 /* Rx fcs error count */
1324 t_u32 rx_pkt_fcs_err_count;
1325 /* Tx power config values */
1326 t_u32 tx_power_data[3];
1327 /* Tx continuous config values */
1328 t_u32 tx_cont_data[6];
1329 /* Tx frame config values */
1330 t_u32 tx_frame_data[20];
1331 /* HE TB Tx values */
1332 t_u32 he_tb_tx[5];
1333 /* BSSID */
1334 t_u8 bssid[ETH_ALEN];
1335 };
1336
1337 /** Number of samples in histogram (/proc/mwlan/adapterX/mlan0/histogram).*/
1338 #define HIST_MAX_SAMPLES 1048576
1339 #define RX_RATE_MAX 196
1340
1341 /** SRN MAX */
1342 #define SNR_MAX 256
1343 /** NOISE FLR MAX */
1344 #define NOISE_FLR_MAX 256
1345 /** SIG STRENTGH MAX */
1346 #define SIG_STRENGTH_MAX 256
1347 /** historgram data */
1348 typedef struct _hgm_data {
1349 /** snr */
1350 atomic_t snr[SNR_MAX];
1351 /** noise flr */
1352 atomic_t noise_flr[NOISE_FLR_MAX];
1353 /** sig_str */
1354 atomic_t sig_str[SIG_STRENGTH_MAX];
1355 /** num sample */
1356 atomic_t num_samples;
1357 /** rx rate */
1358 atomic_t rx_rate[];
1359 } hgm_data, *phgm_data;
1360
1361 /** max antenna number */
1362 #define MAX_ANTENNA_NUM 4
1363
1364 /* wlan_hist_proc_data */
1365 typedef struct _wlan_hist_proc_data {
1366 /** antenna */
1367 u8 ant_idx;
1368 /** Private structure */
1369 struct _moal_private *priv;
1370 } wlan_hist_proc_data;
1371
1372 enum ring_id {
1373 VERBOSE_RING_ID,
1374 EVENT_RING_ID,
1375 RING_ID_MAX,
1376 };
1377
1378 #define AUTO_DFS_ENABLE 0x1
1379 #define AUTO_DFS_DISABLE 0x0
1380 #define MAX_DFS_CHAN_LIST 16
1381
1382 /** Auto Zero DFS config structure */
1383 typedef struct _auto_zero_dfs_cfg {
1384 /** 1: start 0: stop */
1385 t_u8 start_auto_zero_dfs;
1386 /** start channel for ZeroDFS */
1387 t_u8 cac_start_chan;
1388 /** cac timer */
1389 t_u32 cac_timer;
1390 /** bw: 0: 20MHz 1: 40Mz above 3: 40MHz below 4: Bandwidth 80MHz */
1391 t_u8 bw;
1392 /** enable uap chan switch after first CAC finished*/
1393 t_u8 uap_chan_switch;
1394 /** enable auto zero dfs */
1395 t_u8 multi_chan_dfs;
1396 /** num of chan */
1397 t_u8 num_of_chan;
1398 /** dfs channel list */
1399 t_u8 dfs_chan_list[MAX_DFS_CHAN_LIST];
1400 } __ATTRIB_PACK__ auto_zero_dfs_cfg;
1401
1402 /** Private structure for MOAL */
1403 struct _moal_private {
1404 /** Handle structure */
1405 moal_handle *phandle;
1406 /** Tx timeout count */
1407 t_u32 num_tx_timeout;
1408 /** BSS index */
1409 t_u8 bss_index;
1410 /** BSS type */
1411 t_u8 bss_type;
1412 /** BSS role */
1413 t_u8 bss_role;
1414 /** bss virtual flag */
1415 t_u8 bss_virtual;
1416 /** MAC address information */
1417 t_u8 current_addr[ETH_ALEN];
1418 /** Media connection status */
1419 BOOLEAN media_connected;
1420 /** mclist work queue */
1421 struct workqueue_struct *mclist_workqueue;
1422 /** mclist work */
1423 struct work_struct mclist_work;
1424 /** Statistics of tcp ack tx dropped */
1425 t_u32 tcp_ack_drop_cnt;
1426 /** Statistics of tcp ack tx in total from kernel */
1427 t_u32 tcp_ack_cnt;
1428 /** Statistics of tcp ack with payload*/
1429 t_u32 tcp_ack_payload;
1430 #ifdef UAP_SUPPORT
1431 /** uAP started or not */
1432 BOOLEAN bss_started;
1433 /** host based uap flag */
1434 BOOLEAN uap_host_based;
1435 /** target channel */
1436 t_u8 target_chan;
1437 /** backup channel */
1438 t_u8 backup_chan;
1439 /** uAP skip CAC*/
1440 BOOLEAN skip_cac;
1441 /** tx block flag */
1442 BOOLEAN uap_tx_blocked;
1443 /** user cac period */
1444 t_u32 user_cac_period_msec;
1445 /** channel under nop */
1446 BOOLEAN chan_under_nop;
1447 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
1448 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
1449 /** radar background */
1450 t_u8 radar_background;
1451 /** radar background channel */
1452 struct cfg80211_chan_def radar_background_chan;
1453 #endif
1454 #endif
1455 /** chan_rpt_req on Zero DFS interface */
1456 mlan_ds_11h_chan_rep_req chan_rpt_req;
1457 /** chan_rpt pending */
1458 t_u8 chan_rpt_pending;
1459 /** auto dfs cfg */
1460 auto_zero_dfs_cfg auto_dfs_cfg;
1461 /** index of cac */
1462 int curr_cac_idx;
1463 #ifdef UAP_CFG80211
1464 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
1465 /** current working channel */
1466 struct cfg80211_chan_def chan;
1467 #endif
1468 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
1469 /** switch channel */
1470 struct cfg80211_chan_def csa_chan;
1471 /** beacon after channel switch */
1472 struct cfg80211_beacon_data beacon_after;
1473 /** CSA work queue */
1474 struct workqueue_struct *csa_workqueue;
1475 /** csa work */
1476 struct delayed_work csa_work;
1477 #endif
1478 #endif
1479 #endif
1480 /** IP addr type */
1481 t_u32 ip_addr_type;
1482 /** IP addr */
1483 t_u8 ip_addr[IPADDR_LEN];
1484 t_u8 ipv6_addr_configured;
1485 t_u8 ipv6_addr[16];
1486 #ifdef STA_SUPPORT
1487 /** scan type */
1488 t_u8 scan_type;
1489 /** extended capabilities */
1490 ExtCap_t extended_capabilities;
1491 /** bg_scan_start */
1492 t_u8 bg_scan_start;
1493 /** bg_scan reported */
1494 t_u8 bg_scan_reported;
1495 /** bg_scan config */
1496 wlan_bgscan_cfg scan_cfg;
1497 /** sched scaning flag */
1498 t_u8 sched_scanning;
1499 /** bgscan request id */
1500 t_u64 bg_scan_reqid;
1501 #ifdef STA_CFG80211
1502 /** roaming enabled flag */
1503 t_u8 roaming_enabled;
1504 /** roaming required flag */
1505 t_u8 roaming_required;
1506 #endif
1507 #ifdef STA_CFG80211
1508 /** rssi low threshold */
1509 int rssi_low;
1510 /** channel for connect */
1511 struct ieee80211_channel conn_chan;
1512 /** bssid for connect */
1513 t_u8 conn_bssid[ETH_ALEN];
1514 /** ssid for connect */
1515 t_u8 conn_ssid[MLAN_MAX_SSID_LENGTH];
1516 /** length of ssid for connect */
1517 t_u8 conn_ssid_len;
1518 /** key data */
1519 t_u8 conn_wep_key[MAX_WEP_KEY_SIZE];
1520 /** connection param */
1521 struct cfg80211_connect_params sme_current;
1522 /** station info */
1523 struct station_info *sinfo;
1524 /* associcate bss */
1525 struct cfg80211_bss *assoc_bss;
1526 #endif
1527 t_u8 wait_target_ap_pmkid;
1528 wait_queue_head_t okc_wait_q __ATTRIB_ALIGN__;
1529 struct list_head pmksa_cache_list;
1530 spinlock_t pmksa_list_lock;
1531 struct pmksa_entry *target_ap_pmksa;
1532 t_u8 okc_ie_len;
1533 t_u8 *okc_roaming_ie;
1534 #endif
1535 /** Net device pointer */
1536 struct net_device *netdev;
1537 /** Net device statistics structure */
1538 struct net_device_stats stats;
1539 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
1540 /** Wireless device pointer */
1541 struct wireless_dev *wdev;
1542 /** Wireless device */
1543 struct wireless_dev w_dev;
1544 /** Net device pointer */
1545 struct net_device *pa_netdev;
1546 /** channel parameter for UAP/GO */
1547 t_u16 channel;
1548 #ifdef UAP_SUPPORT
1549 /** wep key */
1550 wep_key uap_wep_key[4];
1551 /** cipher */
1552 t_u32 cipher;
1553 #endif
1554 /** pmk saved flag */
1555 t_u8 pmk_saved;
1556 /** pmk */
1557 mlan_pmk_t pmk;
1558 /** beacon ie index */
1559 t_u16 beacon_index;
1560 /** proberesp ie index */
1561 t_u16 proberesp_index;
1562 /** proberesp_p2p_index */
1563 t_u16 proberesp_p2p_index;
1564 /** assocresp ie index */
1565 t_u16 assocresp_index;
1566 /** assocresp qos map ie index */
1567 t_u16 assocresp_qos_map_index;
1568 /** probereq index for mgmt ie */
1569 t_u16 probereq_index;
1570 /** mgmt_subtype_mask */
1571 t_u32 mgmt_subtype_mask;
1572 /** beacon wps index for mgmt ie */
1573 t_u16 beacon_wps_index;
1574 /** beacon/proberesp vendor ie index */
1575 t_u16 beacon_vendor_index;
1576 #endif
1577 #ifdef STA_CFG80211
1578 #ifdef STA_SUPPORT
1579 /** CFG80211 association description */
1580 t_u8 cfg_bssid[ETH_ALEN];
1581 /** Disconnect request from CFG80211 */
1582 bool cfg_disconnect;
1583 /** connect request from CFG80211 */
1584 bool cfg_connect;
1585 /** lock for cfg connect */
1586 spinlock_t connect_lock;
1587 /** assoc status */
1588 t_u32 assoc_status;
1589 /** rssi_threshold */
1590 s32 cqm_rssi_thold;
1591 /** rssi_high_threshold */
1592 s32 cqm_rssi_high_thold;
1593 /** rssi hysteresis */
1594 u32 cqm_rssi_hyst;
1595 /** last rssi_low */
1596 u8 last_rssi_low;
1597 /** last rssi_high */
1598 u8 last_rssi_high;
1599 /** mrvl rssi threshold */
1600 u8 mrvl_rssi_low;
1601 /** last event */
1602 u32 last_event;
1603 /** fake scan flag */
1604 u8 fake_scan_complete;
1605 /**ft ie*/
1606 t_u8 ft_ie[MAX_IE_SIZE];
1607 /**ft ie len*/
1608 t_u8 ft_ie_len;
1609 /**ft ie*/
1610 t_u8 pre_ft_ie[MAX_IE_SIZE];
1611 /**ft ie len*/
1612 t_u8 pre_ft_ie_len;
1613 /**mobility domain value*/
1614 t_u16 ft_md;
1615 /**ft capability*/
1616 t_u8 ft_cap;
1617 /** set true when receive ft auth or action ft roaming */
1618 t_bool ft_pre_connect;
1619 /**ft roaming triggered by driver or not*/
1620 t_bool ft_roaming_triggered_by_driver;
1621 /**target ap mac address for Fast Transition*/
1622 t_u8 target_ap_bssid[ETH_ALEN];
1623 /** IOCTL wait queue for FT*/
1624 wait_queue_head_t ft_wait_q __ATTRIB_ALIGN__;
1625 /** ft wait condition */
1626 t_bool ft_wait_condition;
1627 #endif /* STA_SUPPORT */
1628 #endif /* STA_CFG80211 */
1629 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
1630 /** flag for host_mlme */
1631 t_u8 host_mlme;
1632 /** flag for auth */
1633 t_u8 auth_flag;
1634 /** flag for auth algorithm */
1635 t_u16 auth_alg;
1636 #endif
1637 #ifdef CONFIG_PROC_FS
1638 /** Proc entry */
1639 struct proc_dir_entry *proc_entry;
1640 /** Proc entry name */
1641 char proc_entry_name[IFNAMSIZ];
1642 /** proc entry for hist */
1643 struct proc_dir_entry *hist_entry;
1644 /** ant_hist_proc_data */
1645 wlan_hist_proc_data hist_proc[MAX_ANTENNA_NUM];
1646 #endif /* CONFIG_PROC_FS */
1647 #ifdef STA_SUPPORT
1648 /** Nickname */
1649 t_u8 nick_name[16];
1650 /** AdHoc link sensed flag */
1651 BOOLEAN is_adhoc_link_sensed;
1652 /** Current WEP key index */
1653 t_u16 current_key_index;
1654 #ifdef REASSOCIATION
1655 mlan_ssid_bssid prev_ssid_bssid;
1656 /** Re-association required */
1657 BOOLEAN reassoc_required;
1658 /** Flag of re-association on/off */
1659 BOOLEAN reassoc_on;
1660 /** Set asynced essid flag */
1661 BOOLEAN set_asynced_essid_flag;
1662 #endif /* REASSOCIATION */
1663 /** Report scan result */
1664 t_u8 report_scan_result;
1665 /** wpa_version */
1666 t_u8 wpa_version;
1667 /** key mgmt */
1668 t_u8 key_mgmt;
1669 /** rx_filter */
1670 t_u8 rx_filter;
1671 #endif /* STA_SUPPORT */
1672 /** Rate index */
1673 t_u16 rate_index;
1674 #if defined(STA_WEXT) || defined(UAP_WEXT)
1675 /** IW statistics */
1676 struct iw_statistics w_stats;
1677 #endif
1678 #ifdef UAP_WEXT
1679 /** Pairwise Cipher used for WPA/WPA2 mode */
1680 t_u16 pairwise_cipher;
1681 /** Group Cipher */
1682 t_u16 group_cipher;
1683 /** Protocol stored during uap wext configuratoin */
1684 t_u16 uap_protocol;
1685 /** Key Mgmt whether PSK or 1x */
1686 t_u16 uap_key_mgmt;
1687 /** Beacon IE length from hostapd */
1688 t_u16 bcn_ie_len;
1689 /** Beacon IE buffer from hostapd */
1690 t_u8 bcn_ie_buf[MAX_IE_SIZE];
1691 #endif
1692
1693 /** dscp mapping */
1694 t_u8 dscp_map[64];
1695 /** MLAN debug info */
1696 struct debug_data_priv items_priv;
1697
1698 /** tcp session queue */
1699 struct list_head tcp_sess_queue;
1700 /** TCP Ack enhance flag */
1701 t_u8 enable_tcp_ack_enh;
1702 /** TCP Ack drop count */
1703 t_u8 tcp_ack_max_hold;
1704 /** TCP session spin lock */
1705 spinlock_t tcp_sess_lock;
1706 /** mcast spin lock */
1707 spinlock_t mcast_lock;
1708 /** mcast list */
1709 struct list_head mcast_list;
1710 /** num_mcast_addr */
1711 t_u32 num_mcast_addr;
1712 /** enable mc_aggr */
1713 t_u8 enable_mc_aggr;
1714 /** tcp list */
1715 struct list_head tdls_list;
1716 /** tdls spin lock */
1717 spinlock_t tdls_lock;
1718 /** auto tdls flag */
1719 t_u8 enable_auto_tdls;
1720 /** check tx packet for tdls peer */
1721 t_u8 tdls_check_tx;
1722 auto_assoc auto_assoc_priv;
1723 #if CFG80211_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
1724 atomic_t wmm_tx_pending[4];
1725 #endif
1726 struct sk_buff_head tx_q;
1727 /** per interface extra headroom */
1728 t_u16 extra_tx_head_len;
1729 /** TX status spin lock */
1730 spinlock_t tx_stat_lock;
1731 /** tx_seq_num */
1732 t_u8 tx_seq_num;
1733 /** tx status queue */
1734 struct list_head tx_stat_queue;
1735 /** rx hgm data */
1736 phgm_data hist_data[MAX_ANTENNA_NUM];
1737 t_u8 random_mac[MLAN_MAC_ADDR_LENGTH];
1738 BOOLEAN assoc_with_mac;
1739 t_u8 gtk_data_ready;
1740 mlan_ds_misc_gtk_rekey_data gtk_rekey_data;
1741 dot11_protocol tx_protocols;
1742 dot11_protocol rx_protocols;
1743 t_u16 csi_seq;
1744 /** 0-disable, 1-enable */
1745 t_u16 csi_enable;
1746 /** default-ASCII, 1-binary */
1747 t_u8 csi_dump_format;
1748 /** total length of csi dump */
1749 t_u32 csi_dump_len;
1750 /** path name of csi dump */
1751 char csi_dump_path[64];
1752 /** CSI config */
1753 mlan_ds_csi_params csi_config;
1754 #if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT)
1755 /** hostcmd_wait_q */
1756 wait_queue_head_t hostcmd_wait_q __ATTRIB_ALIGN__;
1757 /** hostcmd_wait_condition */
1758 t_bool hostcmd_wait_condition;
1759 #endif
1760 void *rings[RING_ID_MAX];
1761 t_u8 pkt_fate_monitor_enable;
1762 void *packet_filter;
1763 /** txwatchdog disable */
1764 t_u8 txwatchdog_disable;
1765
1766 /** secure boot uuid lower and higher 8 bytes */
1767 t_u64 uuid_lo;
1768 t_u64 uuid_hi;
1769 };
1770
1771 #ifdef SDIO
1772 #define DUMP_FW_SDIO_V2 2
1773 #define DUMP_FW_SDIO_V3 3
1774
1775 #define DUMP_REG_MAX 13
1776
1777 typedef struct _dump_reg_t {
1778 t_u8 reg_table[DUMP_REG_MAX];
1779 t_u8 reg_table_size;
1780 } dump_reg_t;
1781 #endif
1782
1783 #define FW_NAMW_MAX_LEN 64
1784
1785 /** card info */
1786 typedef struct _card_info {
1787 /** support embeded supp */
1788 t_bool embedded_supp;
1789 /** support drcs */
1790 t_bool drcs;
1791 /** support Go NOA*/
1792 t_bool go_noa;
1793 /** support V14_FW_API*/
1794 t_bool v14_fw_api;
1795 /** support V16_FW_API*/
1796 t_bool v16_fw_api;
1797 /** support V17_FW_API*/
1798 t_bool v17_fw_api;
1799 /** support pmic */
1800 t_bool pmic;
1801 /** support antcfg */
1802 t_bool antcfg;
1803 /** support cal_data_cfg */
1804 t_bool cal_data_cfg;
1805 /** support WLAN_LOW_POWER_ENABLE */
1806 t_bool low_power_enable;
1807 /** rx_rate_max for hist_data: 11N: 76 11AC:196 11AX: 412 */
1808 t_u16 rx_rate_max;
1809 t_u8 histogram_table_num;
1810 /* feature_control */
1811 t_u32 feature_control;
1812 /* Revision id register */
1813 t_u32 rev_id_reg;
1814 /* host interface selection reg*/
1815 t_u32 host_strap_reg;
1816 /* Chip Magic Register */
1817 t_u32 magic_reg;
1818 /* FW Name */
1819 char fw_name[FW_NAMW_MAX_LEN];
1820 char fw_name_wlan[FW_NAMW_MAX_LEN];
1821 #ifdef SDIO
1822 t_u8 dump_fw_info;
1823 t_u8 dump_fw_ctrl_reg;
1824 t_u8 dump_fw_start_reg;
1825 t_u8 dump_fw_end_reg;
1826 t_u8 dump_fw_host_ready;
1827 dump_reg_t dump_reg;
1828 t_u8 scratch_reg;
1829 t_u8 func1_reg_start;
1830 t_u8 func1_reg_end;
1831 t_u32 fw_reset_reg;
1832 t_u8 fw_reset_val;
1833 t_u32 slew_rate_reg;
1834 t_u8 slew_rate_bit_offset;
1835 #endif
1836 t_u8 sniffer_support;
1837 t_u8 per_pkt_cfg_support;
1838 } card_info;
1839
1840 /** channel_field.flags */
1841 #define CHANNEL_FLAGS_TURBO 0x0010
1842 #define CHANNEL_FLAGS_CCK 0x0020
1843 #define CHANNEL_FLAGS_OFDM 0x0040
1844 #define CHANNEL_FLAGS_2GHZ 0x0080
1845 #define CHANNEL_FLAGS_5GHZ 0x0100
1846 #define CHANNEL_FLAGS_ONLY_PASSIVSCAN_ALLOW 0x0200
1847 #define CHANNEL_FLAGS_DYNAMIC_CCK_OFDM 0x0400
1848 #define CHANNEL_FLAGS_GFSK 0x0800
1849 struct channel_field {
1850 /** frequency */
1851 t_u16 frequency;
1852 /** flags */
1853 t_u16 flags;
1854 } __packed;
1855
1856 /** mcs_field.known */
1857 #define MCS_KNOWN_BANDWIDTH 0x01
1858 #define MCS_KNOWN_MCS_INDEX_KNOWN 0x02
1859 #define MCS_KNOWN_GUARD_INTERVAL 0x04
1860 #define MCS_KNOWN_HT_FORMAT 0x08
1861 #define MCS_KNOWN_FEC_TYPE 0x10
1862 #define MCS_KNOWN_STBC_KNOWN 0x20
1863 #define MCS_KNOWN_NESS_KNOWN 0x40
1864 #define MCS_KNOWN_NESS_DATA 0x80
1865 /** bandwidth */
1866 #define RX_BW_20 0
1867 #define RX_BW_40 1
1868 #define RX_BW_20L 2
1869 #define RX_BW_20U 3
1870 #define RX_BW_80 4
1871 /** mcs_field.flags
1872 The flags field is any combination of the following:
1873 0x03 bandwidth - 0: 20, 1: 40, 2: 20L, 3: 20U
1874 0x04 guard interval - 0: long GI, 1: short GI
1875 0x08 HT format - 0: mixed, 1: greenfield
1876 0x10 FEC type - 0: BCC, 1: LDPC
1877 0x60 Number of STBC streams
1878 0x80 Ness - bit 0 (LSB) of Number of extension spatial streams */
1879 struct mcs_field {
1880 /** known */
1881 t_u8 known;
1882 /** flags */
1883 t_u8 flags;
1884 /** mcs */
1885 t_u8 mcs;
1886 } __packed;
1887
1888 /** vht_field.known */
1889 #define VHT_KNOWN_STBC 0x0001
1890 #define VHT_KNOWN_TXOP_PS_NA 0x0002
1891 #define VHT_KNOWN_GI 0x0004
1892 #define VHT_KNOWN_SGI_NSYM_DIS 0x0008
1893 #define VHT_KNOWN_LDPC_EXTRA_OFDM_SYM 0x0010
1894 #define VHT_KNOWN_BEAMFORMED 0x0020
1895 #define VHT_KNOWN_BANDWIDTH 0x0040
1896 #define VHT_KNOWN_GROUP_ID 0x0080
1897 #define VHT_KNOWN_PARTIAL_AID 0x0100
1898
1899 /** vht_field.flags */
1900 #define VHT_FLAG_STBC 0x01
1901 #define VHT_FLAG_TXOP_PS_NA 0x02
1902 #define VHT_FLAG_SGI 0x04
1903 #define VHT_FLAG_SGI_NSYM_M10_9 0x08
1904 #define VHT_FLAG_LDPC_EXTRA_OFDM_SYM 0x10
1905 #define VHT_FLAG_BEAMFORMED 0x20
1906
1907 /** vht_field.coding */
1908 #define VHT_CODING_LDPC_USER0 0x01
1909 #define VHT_CODING_LDPC_USER1 0x02
1910 #define VHT_CODING_LDPC_USER2 0x04
1911 #define VHT_CODING_LDPC_USER3 0x08
1912
1913 /** vht_field */
1914 struct vht_field {
1915 /** pad: for vht field require 2 bytes alignment */
1916 t_u8 pad;
1917 /** known */
1918 t_u16 known;
1919 /** flags */
1920 t_u8 flags;
1921 /** bandwidth */
1922 t_u8 bandwidth;
1923 /** mcs_nss for up to 4 users */
1924 t_u8 mcs_nss[4];
1925 /** coding for up to 4 users */
1926 t_u8 coding;
1927 /** group_id */
1928 t_u8 group_id;
1929 /** partial_aid */
1930 t_u16 partial_aid;
1931 } __packed;
1932
1933 /** radiotap_body.flags */
1934 #define RADIOTAP_FLAGS_DURING_CFG 0x01
1935 #define RADIOTAP_FLAGS_SHORT_PREAMBLE 0x02
1936 #define RADIOTAP_FLAGS_WEP_ENCRYPTION 0x04
1937 #define RADIOTAP_FLAGS_WITH_FRAGMENT 0x08
1938 #define RADIOTAP_FLAGS_INCLUDE_FCS 0x10
1939 #define RADIOTAP_FLAGS_PAD_BTW_HEADER_PAYLOAD 0x20
1940 #define RADIOTAP_FLAGS_FAILED_FCS_CHECK 0x40
1941 #define RADIOTAP_FLAGS_USE_SGI_HT 0x80
1942 struct radiotap_body {
1943 /** timestamp */
1944 t_u64 timestamp;
1945 /** flags */
1946 t_u8 flags;
1947 /** rate for LG pkt, RATE flag will be present, it shows datarate in
1948 * 500Kbps. For HT/VHT pkt, RATE flag will not be present, it is not
1949 * used. */
1950 t_u8 rate;
1951 /** channel */
1952 struct channel_field channel;
1953 /** antenna_signal */
1954 t_s8 antenna_signal;
1955 /** antenna_noise */
1956 t_s8 antenna_noise;
1957 /** antenna */
1958 t_u8 antenna;
1959 /** union for HT/VHT pkt */
1960 union {
1961 /** mcs field */
1962 struct mcs_field mcs;
1963 /** vht field */
1964 struct vht_field vht;
1965 } u;
1966 } __packed;
1967
1968 struct radiotap_header {
1969 struct ieee80211_radiotap_header hdr;
1970 struct radiotap_body body;
1971 } __packed;
1972
1973 /** Roam offload config parameters */
1974 typedef struct woal_priv_fw_roam_offload_cfg {
1975 /* User set passphrase*/
1976 t_u8 userset_passphrase;
1977 /* BSSID for fw roaming/auto_reconnect*/
1978 t_u8 bssid[MLAN_MAC_ADDR_LENGTH];
1979 /* Retry_count for fw roaming/auto_reconnect*/
1980 t_u8 retry_count;
1981 /* Condition to trigger roaming
1982 * Bit0 : RSSI low trigger
1983 * Bit1 : Pre-beacon lost trigger
1984 * Bit2 : Link Lost trigger
1985 * Bit3 : Deauth by ext-AP trigger
1986 * Bit4 ~ Bit15 : Reserved
1987 * value 0 : no trigger
1988 * value 0xff : invalid
1989 */
1990 t_u16 trigger_condition;
1991 /* SSID List(White list)*/
1992 mlan_ds_misc_ssid_list ssid_list;
1993 /* Black list(BSSID list)*/
1994 mlan_ds_misc_roam_offload_aplist black_list;
1995
1996 /* RSSI paramters set flag*/
1997 t_u8 rssi_param_set_flag;
1998 /* MAX_RSSI for fw roaming*/
1999 t_u8 max_rssi;
2000 /* MIN_RSSI for fw roaming*/
2001 t_u8 min_rssi;
2002 /* Step_RSSI for fw roaming*/
2003 t_u8 step_rssi;
2004
2005 /* BAND and RSSI_HYSTERESIS set flag*/
2006 t_u8 band_rssi_flag;
2007 mlan_ds_misc_band_rssi band_rssi;
2008
2009 /* BGSCAN params set flag*/
2010 t_u8 bgscan_set_flag;
2011 mlan_ds_misc_bgscan_cfg bgscan_cfg;
2012
2013 /* EES mode params set flag*/
2014 t_u8 ees_param_set_flag;
2015 mlan_ds_misc_ees_cfg ees_cfg;
2016
2017 /* Beacon miss threshold*/
2018 t_u8 bcn_miss_threshold;
2019
2020 /* Beacon miss threshold*/
2021 t_u8 pre_bcn_miss_threshold;
2022
2023 /* scan repeat count*/
2024 t_u16 repeat_count;
2025 } woal_roam_offload_cfg;
2026 #ifdef STA_CFG80211
2027 int woal_set_clear_pmk(moal_private *priv, t_u8 action);
2028 #endif
2029 int woal_config_fw_roaming(moal_private *priv, t_u8 cfg_mode,
2030 woal_roam_offload_cfg *roam_offload_cfg);
2031 int woal_enable_fw_roaming(moal_private *priv, int data);
2032
2033 #define GTK_REKEY_OFFLOAD_DISABLE 0
2034 #define GTK_REKEY_OFFLOAD_ENABLE 1
2035 #define GTK_REKEY_OFFLOAD_SUSPEND 2
2036
2037 /** Monitor Band Channel Config */
2038 typedef struct _netmon_band_chan_cfg {
2039 t_u32 band;
2040 t_u32 channel;
2041 t_u32 chan_bandwidth;
2042 } netmon_band_chan_cfg;
2043
2044 #if defined(STA_CFG80211) && defined(UAP_CFG80211)
2045 typedef struct _monitor_iface {
2046 /* The priv data of interface on which the monitor iface is based */
2047 moal_private *priv;
2048 struct wireless_dev wdev;
2049 /** 0 - Disabled
2050 * 1 - Channel Specified sniffer mode
2051 * 2 - In-Channel sniffer mode
2052 */
2053 int sniffer_mode;
2054 int radiotap_enabled;
2055 /* The net_device on which the monitor iface is based. */
2056 struct net_device *base_ndev;
2057 struct net_device *mon_ndev;
2058 char ifname[IFNAMSIZ];
2059 int flag;
2060 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
2061 struct cfg80211_chan_def chandef;
2062 #endif
2063 /** Netmon Band Channel Config */
2064 netmon_band_chan_cfg band_chan_cfg;
2065 /** Monitor device statistics structure */
2066 struct net_device_stats stats;
2067 } monitor_iface;
2068 #endif
2069
2070 #define MAX_KEEP_ALIVE_ID 4
2071
2072 /** Operation data structure for MOAL bus interfaces */
2073 typedef struct _moal_if_ops {
2074 mlan_status (*register_dev)(moal_handle *handle);
2075 void (*unregister_dev)(moal_handle *handle);
2076 mlan_status (*read_reg)(moal_handle *handle, t_u32 reg, t_u32 *data);
2077 mlan_status (*write_reg)(moal_handle *handle, t_u32 reg, t_u32 data);
2078 mlan_status (*read_data_sync)(moal_handle *handle, mlan_buffer *pmbuf,
2079 t_u32 port, t_u32 timeout);
2080 mlan_status (*write_data_sync)(moal_handle *handle, mlan_buffer *pmbuf,
2081 t_u32 port, t_u32 timeout);
2082 mlan_status (*get_fw_name)(moal_handle *handle);
2083 void (*dump_fw_info)(moal_handle *handle);
2084 int (*dump_reg_info)(moal_handle *handle, t_u8 *buf);
2085 void (*reg_dbg)(moal_handle *handle);
2086 t_u8 (*is_second_mac)(moal_handle *handle);
2087 } moal_if_ops;
2088
2089 #define WIFI_DIRECT_KERNEL_VERSION KERNEL_VERSION(2, 6, 39)
2090
2091 /** Extended flags */
2092 enum ext_mod_params {
2093 EXT_HW_TEST,
2094 #ifdef CONFIG_OF
2095 EXT_DTS_ENABLE,
2096 #endif
2097 EXT_REQ_FW_NOWAIT,
2098 EXT_FW_SERIAL,
2099 EXT_PM_KEEP_POWER,
2100 #ifdef SDIO
2101 EXT_INTMODE,
2102 #ifdef SDIO_SUSPEND_RESUME
2103 EXT_SHUTDOWN_HS,
2104 #endif
2105 #endif
2106 #if defined(USB)
2107 EXT_SKIP_FWDNLD,
2108 #endif
2109 EXT_AGGR_CTRL,
2110 EXT_LOW_PW_MODE,
2111 #ifdef SDIO
2112 EXT_SDIO_RX_AGGR,
2113 #endif
2114 EXT_PMIC,
2115 EXT_DISCONNECT_ON_SUSPEND,
2116 EXT_HS_MIMO_SWITCH,
2117 EXT_FIX_BCN_BUF,
2118 EXT_NAPI,
2119 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
2120 EXT_DFS_OFFLOAD,
2121 #endif
2122 EXT_DISABLE_REGD_BY_DRIVER,
2123 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
2124 EXT_COUNTRY_IE_IGNORE,
2125 EXT_BEACON_HINTS,
2126 #endif
2127 EXT_ROAMOFFLOAD_IN_HS,
2128 #ifdef STA_CFG80211
2129 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
2130 EXT_HOST_MLME,
2131 #endif
2132 #endif
2133 EXT_TX_WORK,
2134 EXT_TX_SKB_CLONE,
2135 EXT_PMQOS,
2136 EXT_CHAN_TRACK,
2137 EXT_MAX_PARAM,
2138 };
2139
2140 /** Module parameter data structure for MOAL */
2141 typedef struct _moal_mod_para {
2142 t_u8 ext_flgs[DIV_ROUND_UP(EXT_MAX_PARAM, 8)];
2143 /* BIT24 ~ BIT32 reserved */
2144 t_u8 flag;
2145 char *fw_name;
2146 int fw_reload;
2147 int auto_fw_reload;
2148 char *mac_addr;
2149 #ifdef MFG_CMD_SUPPORT
2150 int mfg_mode;
2151 #endif /* MFG_CMD_SUPPORT */
2152 char *hw_name;
2153 int drv_mode;
2154 #ifdef DEBUG_LEVEL1
2155 int drvdbg;
2156 #endif
2157 #ifdef STA_SUPPORT
2158 int max_sta_bss;
2159 char *sta_name;
2160 #endif /* STA_SUPPORT */
2161 #ifdef UAP_SUPPORT
2162 int max_uap_bss;
2163 char *uap_name;
2164 int uap_max_sta;
2165 int wacp_mode;
2166 #endif /* UAP_SUPPORT */
2167 #ifdef WIFI_DIRECT_SUPPORT
2168 int max_wfd_bss;
2169 char *wfd_name;
2170 #if defined(STA_CFG80211) && defined(UAP_CFG80211)
2171 int max_vir_bss;
2172 #endif
2173 #endif /* WIFI_DIRECT_SUPPORT */
2174 int auto_ds;
2175 int net_rx;
2176 int amsdu_deaggr;
2177 int ext_scan;
2178 int ps_mode;
2179 int p2a_scan;
2180 /** scan chan gap */
2181 int scan_chan_gap;
2182 int sched_scan;
2183 int max_tx_buf;
2184 #if defined(SDIO)
2185 int gpiopin;
2186 #endif
2187 #if defined(STA_SUPPORT)
2188 int cfg_11d;
2189 #endif
2190 #if defined(SDIO)
2191 int slew_rate;
2192 #endif
2193 char *dpd_data_cfg;
2194 char *init_cfg;
2195 char *cal_data_cfg;
2196 char *txpwrlimit_cfg;
2197 int cntry_txpwr;
2198 char *init_hostcmd_cfg;
2199 char *band_steer_cfg;
2200 int cfg80211_wext;
2201 int wq_sched_prio;
2202 int wq_sched_policy;
2203 int rx_work;
2204 #ifdef USB
2205 int usb_aggr;
2206 #endif
2207 #ifdef PCIE
2208 int pcie_int_mode;
2209 int ring_size;
2210 #endif /* PCIE */
2211 #ifdef ANDROID_KERNEL
2212 int wakelock_timeout;
2213 #endif
2214 unsigned int dev_cap_mask;
2215 int pmic;
2216 int antcfg;
2217 unsigned int uap_oper_ctrl;
2218 int hs_wake_interval;
2219 int indication_gpio;
2220 int indrstcfg;
2221 #ifdef WIFI_DIRECT_SUPPORT
2222 int GoAgeoutTime;
2223 #endif
2224 int gtk_rekey_offload;
2225 t_u16 multi_dtim;
2226 t_u16 inact_tmo;
2227 char *reg_alpha2;
2228 int dfs53cfg;
2229 t_u8 mcs32;
2230
2231 int keep_previous_scan;
2232 } moal_mod_para;
2233
2234 void woal_tp_acnt_timer_func(void *context);
2235 void woal_set_tp_state(moal_private *priv);
2236 #define MAX_TP_ACCOUNT_DROP_POINT_NUM 5
2237 #define RX_DROP_P1 (MAX_TP_ACCOUNT_DROP_POINT_NUM)
2238 #define RX_DROP_P2 (MAX_TP_ACCOUNT_DROP_POINT_NUM + 1)
2239 #define RX_DROP_P3 (MAX_TP_ACCOUNT_DROP_POINT_NUM + 2)
2240 #define RX_DROP_P4 (MAX_TP_ACCOUNT_DROP_POINT_NUM + 3)
2241 #define RX_DROP_P5 (MAX_TP_ACCOUNT_DROP_POINT_NUM + 4)
2242 #define TXRX_MAX_SAMPLE 60
2243 #define RX_TIME_PKT (MAX_TP_ACCOUNT_DROP_POINT_NUM + 5)
2244 #define TX_TIME_PKT (MAX_TP_ACCOUNT_DROP_POINT_NUM + 6)
2245
2246 typedef struct _moal_tp_acnt_t {
2247 /* TX accounting */
2248 unsigned long tx_packets[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2249 unsigned long tx_packets_last[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2250 unsigned long tx_packets_rate[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2251 unsigned long tx_bytes[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2252 unsigned long tx_bytes_last[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2253 unsigned long tx_bytes_rate[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2254 unsigned long tx_amsdu_cnt;
2255 unsigned long tx_amsdu_cnt_last;
2256 unsigned long tx_amsdu_cnt_rate;
2257 unsigned long tx_amsdu_pkt_cnt;
2258 unsigned long tx_amsdu_pkt_cnt_last;
2259 unsigned long tx_amsdu_pkt_cnt_rate;
2260 unsigned long tx_intr_cnt;
2261 unsigned long tx_intr_last;
2262 unsigned long tx_intr_rate;
2263 unsigned long tx_pending;
2264 unsigned long tx_xmit_skb_realloc_cnt;
2265 unsigned long tx_stop_queue_cnt;
2266 unsigned long tx_delay_driver[TXRX_MAX_SAMPLE];
2267
2268 /** RX accounting */
2269 unsigned long rx_packets[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2270 unsigned long rx_packets_last[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2271 unsigned long rx_packets_rate[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2272 unsigned long rx_bytes[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2273 unsigned long rx_bytes_last[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2274 unsigned long rx_bytes_rate[MAX_TP_ACCOUNT_DROP_POINT_NUM];
2275 unsigned long rx_amsdu_cnt;
2276 unsigned long rx_amsdu_cnt_last;
2277 unsigned long rx_amsdu_cnt_rate;
2278 unsigned long rx_amsdu_pkt_cnt;
2279 unsigned long rx_amsdu_pkt_cnt_last;
2280 unsigned long rx_amsdu_pkt_cnt_rate;
2281 unsigned long rx_intr_cnt;
2282 unsigned long rx_intr_last;
2283 unsigned long rx_intr_rate;
2284 unsigned long rx_pending;
2285 unsigned long rx_paused_cnt;
2286 unsigned long rx_rdptr_full_cnt;
2287 unsigned long rx_delay1_driver[TXRX_MAX_SAMPLE];
2288 unsigned long rx_delay2_driver[TXRX_MAX_SAMPLE];
2289 unsigned long rx_delay_kernel[TXRX_MAX_SAMPLE];
2290 unsigned long rx_amsdu_delay[TXRX_MAX_SAMPLE];
2291 unsigned long rx_amsdu_copy_delay[TXRX_MAX_SAMPLE];
2292 t_u8 rx_amsdu_index;
2293 t_u8 rx_index;
2294 t_u8 tx_index;
2295 /* TP account mode 0-disable 1-enable */
2296 unsigned int on;
2297 /* drop point */
2298 unsigned int drop_point;
2299 /* periodic timer */
2300 moal_drv_timer timer;
2301 } moal_tp_acnt_t;
2302
2303 /** Handle data structure for MOAL */
2304 struct _moal_handle {
2305 /** MLAN adapter structure */
2306 t_void *pmlan_adapter;
2307 /** Private pointer */
2308 moal_private *priv[MLAN_MAX_BSS_NUM];
2309 /** Priv number */
2310 t_u8 priv_num;
2311 /** Bss attr */
2312 moal_drv_mode drv_mode;
2313
2314 #if defined(STA_CFG80211) && defined(UAP_CFG80211)
2315 /** Monitor interface */
2316 monitor_iface *mon_if;
2317 #endif
2318
2319 /** set mac address flag */
2320 t_u8 set_mac_addr;
2321 /** MAC address */
2322 t_u8 mac_addr[ETH_ALEN];
2323 #ifdef CONFIG_PROC_FS
2324 /** Proc top level directory entry */
2325 struct proc_dir_entry *proc_wlan;
2326 /** Proc top level directory entry name */
2327 char proc_wlan_name[32];
2328 #endif
2329 #ifdef USB
2330 /** Firmware download skip flag */
2331 t_u8 skip_fw_dnld;
2332 #endif /* USB */
2333 /** Firmware */
2334 const struct firmware *firmware;
2335 /** Firmware request start time */
2336 wifi_timeval req_fw_time;
2337 /** Init config file */
2338 const struct firmware *init_cfg_data;
2339 /** Init config file */
2340 const struct firmware *user_data;
2341 /** Init user configure wait queue token */
2342 t_u16 init_user_conf_wait_flag;
2343 /** Init user configure file wait queue */
2344 wait_queue_head_t init_user_conf_wait_q __ATTRIB_ALIGN__;
2345 /** dpd config file */
2346 const struct firmware *dpd_data;
2347 /** txpwr data file */
2348 const struct firmware *txpwr_data;
2349 /** Hotplug device */
2350 struct device *hotplug_device;
2351 /** STATUS variables */
2352 MOAL_HARDWARE_STATUS hardware_status;
2353 BOOLEAN fw_reload;
2354 /** POWER MANAGEMENT AND PnP SUPPORT */
2355 BOOLEAN surprise_removed;
2356 /** Firmware release number */
2357 t_u32 fw_release_number;
2358 /** Firmware Hotfix version */
2359 t_u8 fw_hotfix_version;
2360 /** Firmware support bands */
2361 t_u16 fw_bands;
2362 /** ECSA support */
2363 t_u8 fw_ecsa_enable;
2364 /** FW ROAMING support */
2365 t_u8 fw_roam_enable;
2366 /** FW ROAMING capability in fw */
2367 t_u8 fw_roaming_support;
2368 /** Retry count for auto reconnect based on FW ROAMING*/
2369 t_u16 auto_reconnect_retry_count;
2370 /** The SSID for auto reconnect FW ROAMING*/
2371 mlan_802_11_ssid auto_reconnect_ssid;
2372 /** The BSSID for auto reconnect FW ROAMING*/
2373 mlan_802_11_mac_addr auto_reconnect_bssid;
2374 /** The parameters for FW ROAMING*/
2375 woal_roam_offload_cfg fw_roam_params;
2376 /** The keys for FW ROAMING*/
2377 mlan_ds_passphrase ssid_passphrase[MAX_SEC_SSID_NUM];
2378
2379 /** Getlog support */
2380 t_u8 fw_getlog_enable;
2381 /** Init wait queue token */
2382 t_u16 init_wait_q_woken;
2383 /** Init wait queue */
2384 wait_queue_head_t init_wait_q __ATTRIB_ALIGN__;
2385 /** Device suspend flag */
2386 BOOLEAN is_suspended;
2387 #ifdef SDIO_SUSPEND_RESUME
2388 /** suspend notify flag */
2389 BOOLEAN suspend_notify_req;
2390 /** hs_shutdown in process flag */
2391 BOOLEAN shutdown_hs_in_process;
2392 #endif
2393 /** Suspend wait queue token */
2394 t_u16 suspend_wait_q_woken;
2395 /** Suspend wait queue */
2396 wait_queue_head_t suspend_wait_q __ATTRIB_ALIGN__;
2397 /** Host Sleep activated flag */
2398 t_u8 hs_activated;
2399 /** Host Sleep activated event wait queue token */
2400 t_u16 hs_activate_wait_q_woken;
2401 /** Host Sleep activated event wait queue */
2402 wait_queue_head_t hs_activate_wait_q __ATTRIB_ALIGN__;
2403 /** auto_arp and ipv6 offload enable/disable flag */
2404 t_u8 hs_auto_arp;
2405 #ifdef IMX_SUPPORT
2406 /** wakeup irq number */
2407 int irq_oob_wakeup;
2408 /** wakeup notify flag */
2409 bool wake_by_wifi;
2410 #endif /* IMX_SUPPORT */
2411 /** Card pointer */
2412 t_void *card;
2413 /** Rx pending in MLAN */
2414 atomic_t rx_pending;
2415 /** Tx packet pending count in mlan */
2416 atomic_t tx_pending;
2417 /** IOCTL pending count in mlan */
2418 atomic_t ioctl_pending;
2419 /** lock count */
2420 atomic_t lock_count;
2421 /** Malloc count */
2422 atomic_t malloc_count;
2423 /** vmalloc count */
2424 atomic_t vmalloc_count;
2425 /** mlan buffer alloc count */
2426 atomic_t mbufalloc_count;
2427 #ifdef PCIE
2428 /** Malloc consistent count */
2429 atomic_t malloc_cons_count;
2430 #endif
2431 /** hs skip count */
2432 t_u32 hs_skip_count;
2433 /** hs force count */
2434 t_u32 hs_force_count;
2435 /** suspend_fail flag */
2436 BOOLEAN suspend_fail;
2437 #ifdef REASSOCIATION
2438 /** Re-association thread */
2439 moal_thread reassoc_thread;
2440 /** Re-association timer set flag */
2441 BOOLEAN is_reassoc_timer_set;
2442 /** Re-association timer */
2443 moal_drv_timer reassoc_timer __ATTRIB_ALIGN__;
2444 /** */
2445 struct semaphore reassoc_sem;
2446 /** Bitmap for re-association on/off */
2447 t_u8 reassoc_on;
2448 #endif /* REASSOCIATION */
2449 /** Driver workqueue */
2450 struct workqueue_struct *workqueue;
2451 /** main work */
2452 struct work_struct main_work;
2453 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
2454 /** host_mlme_priv */
2455 moal_private *host_mlme_priv;
2456 /** Host Mlme Work struct**/
2457 struct work_struct host_mlme_work;
2458 #endif
2459 /** Driver workqueue */
2460 struct workqueue_struct *rx_workqueue;
2461 /** main work */
2462 struct work_struct rx_work;
2463 /** Driver event workqueue */
2464 struct workqueue_struct *evt_workqueue;
2465 /** event work */
2466 struct work_struct evt_work;
2467 /** event spin lock */
2468 spinlock_t evt_lock;
2469 /** event queue */
2470 struct list_head evt_queue;
2471 /** tx workqueue */
2472 struct workqueue_struct *tx_workqueue;
2473 /** tx work */
2474 struct work_struct tx_work;
2475 /** remain on channel flag */
2476 t_u8 remain_on_channel;
2477 /** bss index for remain on channel */
2478 t_u8 remain_bss_index;
2479 /** wifi hal enabled flag */
2480 t_u8 wifi_hal_flag;
2481 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
2482 struct wiphy *wiphy;
2483 /** Country code for regulatory domain */
2484 t_u8 country_code[COUNTRY_CODE_LEN];
2485 /** dfs_region */
2486 t_u8 dfs_region;
2487 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
2488 /** regulatory work */
2489 struct work_struct regulatory_work;
2490 #endif
2491 /** band */
2492 enum ieee80211_band band;
2493 /** first scan done flag */
2494 t_u8 first_scan_done;
2495 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
2496 /** remain_on_channel timer set flag */
2497 BOOLEAN is_remain_timer_set;
2498 /** remani_on_channel_timer */
2499 moal_drv_timer remain_timer __ATTRIB_ALIGN__;
2500 /** ieee802_11_channel */
2501 struct ieee80211_channel chan;
2502 #if CFG80211_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
2503 /** channel type */
2504 enum nl80211_channel_type channel_type;
2505 #endif
2506 /** cookie */
2507 t_u64 cookie;
2508 #endif
2509
2510 #ifdef WIFI_DIRECT_SUPPORT
2511 /** NoA duration */
2512 t_u32 noa_duration;
2513 /** NoA interval */
2514 t_u32 noa_interval;
2515 /** miracast mode */
2516 t_u8 miracast_mode;
2517 /** scan time in miracast mode */
2518 t_u16 miracast_scan_time;
2519 /** GO timer set flag */
2520 BOOLEAN is_go_timer_set;
2521 /** GO timer */
2522 moal_drv_timer go_timer __ATTRIB_ALIGN__;
2523 #endif
2524 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
2525 /** cfg80211_suspend status */
2526 t_u8 cfg80211_suspend;
2527 #endif
2528 #endif
2529 /** FW debug flag */
2530 t_u8 fw_dbg;
2531 /** reg debug flag */
2532 t_u8 reg_dbg;
2533 #ifdef SDIO
2534 #endif /* SDIO */
2535 /** Netlink kernel socket */
2536 struct sock *nl_sk;
2537 /** Netlink kernel socket number */
2538 t_u32 netlink_num;
2539 /** w_stats wait queue token */
2540 BOOLEAN meas_wait_q_woken;
2541 /** w_stats wait queue */
2542 wait_queue_head_t meas_wait_q __ATTRIB_ALIGN__;
2543 /** Measurement start jiffes */
2544 long meas_start_jiffies;
2545 /** CAC checking period flag */
2546 BOOLEAN cac_period;
2547 /** CAC timer jiffes */
2548 long cac_timer_jiffies;
2549 /** User NOP Period in sec */
2550 t_u16 usr_nop_period_sec;
2551 /** BSS START command delay executing flag */
2552 BOOLEAN delay_bss_start;
2553 /** SSID,BSSID parameter of delay executing */
2554 mlan_ssid_bssid delay_ssid_bssid;
2555 #ifdef UAP_CFG80211
2556 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
2557 /* CAC channel info */
2558 struct cfg80211_chan_def dfs_channel;
2559 /* time set flag*/
2560 BOOLEAN is_cac_timer_set;
2561 /** cac_timer */
2562 moal_drv_timer cac_timer __ATTRIB_ALIGN__;
2563 /** cac bss index */
2564 t_u8 cac_bss_index;
2565 #endif
2566 #endif
2567 #if defined(UAP_SUPPORT)
2568 /** channel switch wait queue token */
2569 BOOLEAN chsw_wait_q_woken;
2570 /** channel switch wait queue */
2571 wait_queue_head_t chsw_wait_q __ATTRIB_ALIGN__;
2572 #endif
2573 /** cac period length, valid only when dfs testing is enabled */
2574 long cac_period_jiffies;
2575 /** cac restart*/
2576 t_u8 cac_restart;
2577 /** handle index - for multiple card supports */
2578 t_u8 handle_idx;
2579 #if defined(USB)
2580 /** Flag to indicate boot state */
2581 t_u8 boot_state;
2582 #endif /* USB_NEW_FW_DNLD */
2583 #ifdef SDIO_MMC_DEBUG
2584 /** cmd53 write state */
2585 u8 cmd53w;
2586 /** cmd53 read state */
2587 u8 cmd53r;
2588 #endif
2589 #ifdef STA_SUPPORT
2590 /** Scan pending on blocked flag */
2591 t_u8 scan_pending_on_block;
2592 /** Scan Private pointer */
2593 moal_private *scan_priv;
2594 /** Async scan semaphore */
2595 struct semaphore async_sem;
2596 /** scan channel gap */
2597 t_u16 scan_chan_gap;
2598 #ifdef STA_CFG80211
2599 /** CFG80211 scan request description */
2600 struct cfg80211_scan_request *scan_request;
2601 /** fake scan flag */
2602 u8 fake_scan_complete;
2603 /** Scan timeout work*/
2604 struct delayed_work scan_timeout_work;
2605 /** scan timeout time */
2606 t_u32 scan_timeout;
2607 #endif
2608 #endif
2609 /** main state */
2610 t_u8 main_state;
2611 /** driver status */
2612 t_u8 driver_status;
2613 /** driver state */
2614 t_u8 driver_state;
2615 /** ioctl timeout */
2616 t_u8 ioctl_timeout;
2617 /** Pointer of fw dump buffer */
2618 t_u8 *drv_dump_buf;
2619 /** drv dump len */
2620 t_u32 drv_dump_len;
2621 /** FW dump state */
2622 t_u8 fw_dump;
2623 /** event fw dump */
2624 t_u8 event_fw_dump;
2625 /** Re-association timer set flag */
2626 BOOLEAN is_fw_dump_timer_set;
2627 /** Re-association timer */
2628 moal_drv_timer fw_dump_timer __ATTRIB_ALIGN__;
2629 /** fw dump buffer total len */
2630 t_u64 fw_dump_len;
2631 /** fw dump status for each chip, useful in multichip drive */
2632 BOOLEAN fw_dump_status;
2633 /** Pointer of fw dump buffer */
2634 t_u8 *fw_dump_buf;
2635 /** FW dump full name */
2636 t_u8 firmware_dump_file[128];
2637
2638 #ifdef SDIO
2639 /** cmd52 function */
2640 t_u8 cmd52_func;
2641 /** cmd52 register */
2642 t_u8 cmd52_reg;
2643 /** cmd52 value */
2644 t_u8 cmd52_val;
2645 #endif
2646 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
2647 /** spinlock to stop_queue/wake_queue*/
2648 spinlock_t queue_lock;
2649 #endif
2650 /** Driver spin lock */
2651 spinlock_t driver_lock;
2652 /** Driver ioctl spin lock */
2653 spinlock_t ioctl_lock;
2654 /** lock for scan_request */
2655 spinlock_t scan_req_lock;
2656 /** Interface type: 1 byte, Card type: 1 byte */
2657 t_u16 card_type;
2658 /** card revsion */
2659 t_u8 card_rev;
2660 /** card info */
2661 card_info *card_info;
2662 /** Card specific driver version */
2663 t_s8 driver_version[MLAN_MAX_VER_STR_LEN];
2664 char *fwdump_fname;
2665 #ifdef ANDROID_KERNEL
2666 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
2667 struct wakeup_source ws;
2668 #else
2669 struct wake_lock wake_lock;
2670 #endif
2671 #endif
2672 t_u16 dfs_repeater_mode;
2673 /* feature_control */
2674 t_u32 feature_control;
2675 struct notifier_block woal_notifier;
2676 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
2677 #if IS_ENABLED(CONFIG_IPV6)
2678 struct notifier_block woal_inet6_notifier;
2679 #endif
2680 #endif
2681 mlan_ds_misc_keep_alive keep_alive[MAX_KEEP_ALIVE_ID];
2682 struct net_device napi_dev;
2683 struct napi_struct napi_rx;
2684 /* bus interface operations */
2685 moal_if_ops ops;
2686 /* module parameter data */
2687 const struct firmware *param_data;
2688 /* wrapped module parameters */
2689 moal_mod_para params;
2690 /* debug info */
2691 mlan_debug_info debug_info;
2692 /* block id in module param config file */
2693 int blk_id;
2694 /** time when FW is active, time is get from boot time, in Nanosecond */
2695 t_u64 on_time;
2696 /** tx time, in usecs */
2697 t_u64 tx_time;
2698 /** systime when tx start */
2699 wifi_timeval tx_time_start;
2700 /** systime when tx end */
2701 wifi_timeval tx_time_end;
2702 /** rx time, in usecs */
2703 t_u64 rx_time;
2704 /** scan time, in usecs */
2705 t_u64 scan_time;
2706 /** systime when scan cmd response return success */
2707 wifi_timeval scan_time_start;
2708 /** systime when scan event has no more event */
2709 wifi_timeval scan_time_end;
2710 /** seecond mac flag */
2711 t_u8 second_mac;
2712 /** moal handle for another mac */
2713 void *pref_mac;
2714 /** RF test mode status */
2715 t_u8 rf_test_mode;
2716 /** pointer to rf test mode data struct */
2717 struct rf_test_mode_data *rf_data;
2718 /** TP accounting parameters */
2719 moal_tp_acnt_t tp_acnt;
2720 BOOLEAN is_tp_acnt_timer_set;
2721
2722 t_u8 request_pm;
2723 #ifdef IMX_SUPPORT
2724 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
2725 struct pm_qos_request woal_pm_qos_req;
2726 #endif
2727 #endif
2728 t_u32 ips_ctrl;
2729 };
2730
2731 /**
2732 * @brief set extended flag in bitmap
2733 *
2734 * @param dev A pointer to moal_handle structure
2735 * @param idx extended flags id
2736 * @return N/A
2737 */
2738 static inline void moal_extflg_set(moal_handle *handle, enum ext_mod_params idx)
2739 {
2740 t_u8 *ext_fbyte;
2741 ext_fbyte = &handle->params.ext_flgs[idx / 8];
2742 *ext_fbyte |= MBIT(idx % 8);
2743 }
2744
2745 /**
2746 * @brief clear extended flag in bitmap
2747 *
2748 * @param dev A pointer to moal_handle structure
2749 * @param idx extended flags id
2750 * @return N/A
2751 */
2752 static inline void moal_extflg_clear(moal_handle *handle,
2753 enum ext_mod_params idx)
2754 {
2755 t_u8 *ext_fbyte;
2756 ext_fbyte = &handle->params.ext_flgs[idx / 8];
2757 *ext_fbyte &= ~MBIT(idx % 8);
2758 }
2759
2760 /**
2761 * @brief check value of extended flag in bitmap
2762 *
2763 * @param dev A pointer to moal_handle structure
2764 * @param idx extended flags id
2765 * @return value of extended flag
2766 */
2767 static inline t_u8 moal_extflg_isset(moal_handle *handle,
2768 enum ext_mod_params idx)
2769 {
2770 t_u8 ext_fbyte;
2771 ext_fbyte = handle->params.ext_flgs[idx / 8];
2772 return (ext_fbyte & MBIT(idx % 8)) != 0;
2773 }
2774
2775 /**
2776 * @brief set trans_start for each TX queue.
2777 *
2778 * @param dev A pointer to net_device structure
2779 *
2780 * @return N/A
2781 */
2782 static inline void woal_set_trans_start(struct net_device *dev)
2783 {
2784 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
2785 unsigned int i;
2786 for (i = 0; i < dev->num_tx_queues; i++)
2787 netdev_get_tx_queue(dev, i)->trans_start = jiffies;
2788 #endif
2789 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
2790 dev->trans_start = jiffies;
2791 #else
2792 netif_trans_update(dev);
2793 #endif
2794 }
2795
2796 /**
2797 * @brief Start queue
2798 *
2799 * @param dev A pointer to net_device structure
2800 *
2801 * @return N/A
2802 */
2803 static inline void woal_start_queue(struct net_device *dev)
2804 {
2805 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 29)
2806 netif_start_queue(dev);
2807 #else
2808 if (dev->reg_state == NETREG_REGISTERED)
2809 netif_tx_wake_all_queues(dev);
2810 else
2811 netif_tx_start_all_queues(dev);
2812 #endif
2813 }
2814
2815 /**
2816 * @brief Stop queue
2817 *
2818 * @param dev A pointer to net_device structure
2819 *
2820 * @return N/A
2821 */
2822 static inline void woal_stop_queue(struct net_device *dev)
2823 {
2824 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
2825 unsigned long flags;
2826 moal_private *priv = (moal_private *)netdev_priv(dev);
2827 spin_lock_irqsave(&priv->phandle->queue_lock, flags);
2828 woal_set_trans_start(dev);
2829 if (!netif_queue_stopped(dev))
2830 netif_tx_stop_all_queues(dev);
2831 spin_unlock_irqrestore(&priv->phandle->queue_lock, flags);
2832 #else
2833 woal_set_trans_start(dev);
2834 if (!netif_queue_stopped(dev))
2835 netif_stop_queue(dev);
2836 #endif
2837 }
2838
2839 /**
2840 * @brief wake queue
2841 *
2842 * @param dev A pointer to net_device structure
2843 *
2844 * @return N/A
2845 */
2846 static inline void woal_wake_queue(struct net_device *dev)
2847 {
2848 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
2849 unsigned long flags;
2850 moal_private *priv = (moal_private *)netdev_priv(dev);
2851 spin_lock_irqsave(&priv->phandle->queue_lock, flags);
2852 if (netif_queue_stopped(dev))
2853 netif_tx_wake_all_queues(dev);
2854 spin_unlock_irqrestore(&priv->phandle->queue_lock, flags);
2855 #else
2856 if (netif_queue_stopped(dev))
2857 netif_wake_queue(dev);
2858 #endif
2859 }
2860
2861 /** Debug Macro definition*/
2862 #ifdef DEBUG_LEVEL1
2863 extern t_u32 drvdbg;
2864
2865 #define LOG_CTRL(level) (0)
2866
2867 #ifdef DEBUG_LEVEL2
2868 #define PRINTM_MINFO(level, msg...) \
2869 do { \
2870 woal_print(level, msg); \
2871 if (drvdbg & MINFO) \
2872 printk(KERN_DEBUG msg); \
2873 } while (0)
2874 #define PRINTM_MWARN(level, msg...) \
2875 do { \
2876 woal_print(level, msg); \
2877 if (drvdbg & MWARN) \
2878 printk(KERN_DEBUG msg); \
2879 } while (0)
2880 #define PRINTM_MENTRY(level, msg...) \
2881 do { \
2882 woal_print(level, msg); \
2883 if (drvdbg & MENTRY) \
2884 printk(KERN_DEBUG msg); \
2885 } while (0)
2886 #else
2887 #define PRINTM_MINFO(level, msg...) \
2888 do { \
2889 } while (0)
2890 #define PRINTM_MWARN(level, msg...) \
2891 do { \
2892 } while (0)
2893 #define PRINTM_MENTRY(level, msg...) \
2894 do { \
2895 } while (0)
2896 #endif /* DEBUG_LEVEL2 */
2897
2898 #define PRINTM_MFW_D(level, msg...) \
2899 do { \
2900 woal_print(level, msg); \
2901 if (drvdbg & MFW_D) \
2902 printk(KERN_DEBUG msg); \
2903 } while (0)
2904 #define PRINTM_MCMD_D(level, msg...) \
2905 do { \
2906 woal_print(level, msg); \
2907 if (drvdbg & MCMD_D) \
2908 printk(KERN_DEBUG msg); \
2909 } while (0)
2910 #define PRINTM_MDAT_D(level, msg...) \
2911 do { \
2912 woal_print(level, msg); \
2913 if (drvdbg & MDAT_D) \
2914 printk(KERN_DEBUG msg); \
2915 } while (0)
2916 #define PRINTM_MIF_D(level, msg...) \
2917 do { \
2918 woal_print(level, msg); \
2919 if (drvdbg & MIF_D) \
2920 printk(KERN_DEBUG msg); \
2921 } while (0)
2922
2923 #define PRINTM_MIOCTL(level, msg...) \
2924 do { \
2925 woal_print(level, msg); \
2926 if (drvdbg & MIOCTL) \
2927 printk(KERN_DEBUG msg); \
2928 } while (0)
2929 #define PRINTM_MINTR(level, msg...) \
2930 do { \
2931 woal_print(level, msg); \
2932 if (drvdbg & MINTR) \
2933 printk(KERN_DEBUG msg); \
2934 } while (0)
2935 #define PRINTM_MEVENT(level, msg...) \
2936 do { \
2937 woal_print(level, msg); \
2938 if (drvdbg & MEVENT) \
2939 printk(msg); \
2940 } while (0)
2941 #define PRINTM_MCMND(level, msg...) \
2942 do { \
2943 woal_print(level, msg); \
2944 if (drvdbg & MCMND) \
2945 printk(KERN_DEBUG msg); \
2946 } while (0)
2947 #define PRINTM_MDATA(level, msg...) \
2948 do { \
2949 woal_print(level, msg); \
2950 if (drvdbg & MDATA) \
2951 printk(KERN_DEBUG msg); \
2952 } while (0)
2953 #define PRINTM_MERROR(level, msg...) \
2954 do { \
2955 woal_print(level, msg); \
2956 if (drvdbg & MERROR) \
2957 printk(KERN_ERR msg); \
2958 } while (0)
2959 #define PRINTM_MFATAL(level, msg...) \
2960 do { \
2961 woal_print(level, msg); \
2962 if (drvdbg & MFATAL) \
2963 printk(KERN_ERR msg); \
2964 } while (0)
2965 #define PRINTM_MMSG(level, msg...) \
2966 do { \
2967 woal_print(level, msg); \
2968 if (drvdbg & MMSG) \
2969 printk(KERN_ALERT msg); \
2970 } while (0)
2971
2972 static inline void woal_print(t_u32 level, char *fmt, ...)
2973 {
2974 }
2975
2976 #define PRINTM(level, msg...) PRINTM_##level(level, msg)
2977
2978 #else
2979
2980 #define PRINTM(level, msg...) \
2981 do { \
2982 } while (0)
2983
2984 #endif /* DEBUG_LEVEL1 */
2985
2986 /** Wait until a condition becomes true */
2987 #define MASSERT(cond) \
2988 do { \
2989 if (!(cond)) { \
2990 PRINTM(MFATAL, "ASSERT: %s: %i\n", __func__, \
2991 __LINE__); \
2992 panic("Assert failed: Panic!"); \
2993 } \
2994 } while (0)
2995
2996 /** Log entry point for debugging */
2997 #define ENTER() PRINTM(MENTRY, "Enter: %s\n", __func__)
2998 /** Log exit point for debugging */
2999 #define LEAVE() PRINTM(MENTRY, "Leave: %s\n", __func__)
3000
3001 #ifdef DEBUG_LEVEL1
3002 #define DBG_DUMP_BUF_LEN 64
3003 #define MAX_DUMP_PER_LINE 16
3004
3005 static inline void hexdump(t_u32 level, char *prompt, t_u8 *buf, int len)
3006 {
3007 int i;
3008 char dbgdumpbuf[DBG_DUMP_BUF_LEN];
3009 char *ptr = dbgdumpbuf;
3010
3011 if (drvdbg & level)
3012 printk(KERN_DEBUG "%s:\n", prompt);
3013 for (i = 1; i <= len; i++) {
3014 ptr += snprintf(ptr, 4, "%02x ", *buf);
3015 buf++;
3016 if (i % MAX_DUMP_PER_LINE == 0) {
3017 *ptr = 0;
3018 if (drvdbg & level)
3019 printk(KERN_DEBUG "%s\n", dbgdumpbuf);
3020 ptr = dbgdumpbuf;
3021 }
3022 }
3023 if (len % MAX_DUMP_PER_LINE) {
3024 *ptr = 0;
3025 if (drvdbg & level)
3026 printk(KERN_DEBUG "%s\n", dbgdumpbuf);
3027 }
3028 }
3029
3030 #define DBG_HEXDUMP_MERROR(x, y, z) \
3031 do { \
3032 if ((drvdbg & MERROR) || LOG_CTRL(MERROR)) \
3033 hexdump(MERROR, x, y, z); \
3034 } while (0)
3035 #define DBG_HEXDUMP_MCMD_D(x, y, z) \
3036 do { \
3037 if ((drvdbg & MCMD_D) || LOG_CTRL(MCMD_D)) \
3038 hexdump(MCMD_D, x, y, z); \
3039 } while (0)
3040 #define DBG_HEXDUMP_MDAT_D(x, y, z) \
3041 do { \
3042 if ((drvdbg & MDAT_D) || LOG_CTRL(MDAT_D)) \
3043 hexdump(MDAT_D, x, y, z); \
3044 } while (0)
3045 #define DBG_HEXDUMP_MIF_D(x, y, z) \
3046 do { \
3047 if ((drvdbg & MIF_D) || LOG_CTRL(MIF_D)) \
3048 hexdump(MIF_D, x, y, z); \
3049 } while (0)
3050 #define DBG_HEXDUMP_MEVT_D(x, y, z) \
3051 do { \
3052 if ((drvdbg & MEVT_D) || LOG_CTRL(MEVT_D)) \
3053 hexdump(MEVT_D, x, y, z); \
3054 } while (0)
3055 #define DBG_HEXDUMP_MFW_D(x, y, z) \
3056 do { \
3057 if ((drvdbg & MFW_D) || LOG_CTRL(MFW_D)) \
3058 hexdump(MFW_D, x, y, z); \
3059 } while (0)
3060 #define DBG_HEXDUMP(level, x, y, z) DBG_HEXDUMP_##level(x, y, z)
3061
3062 #else
3063 /** Do nothing since debugging is not turned on */
3064 #define DBG_HEXDUMP(level, x, y, z) \
3065 do { \
3066 } while (0)
3067 #endif
3068
3069 #ifdef DEBUG_LEVEL2
3070 #define HEXDUMP(x, y, z) \
3071 do { \
3072 if ((drvdbg & MINFO) || LOG_CTRL(MINFO)) \
3073 hexdump(MINFO, x, y, z); \
3074 } while (0)
3075 #else
3076 /** Do nothing since debugging is not turned on */
3077 #define HEXDUMP(x, y, z) \
3078 do { \
3079 } while (0)
3080 #endif
3081
3082 #ifdef BIG_ENDIAN_SUPPORT
3083 /** Convert from 16 bit little endian format to CPU format */
3084 #define woal_le16_to_cpu(x) le16_to_cpu(x)
3085 /** Convert from 32 bit little endian format to CPU format */
3086 #define woal_le32_to_cpu(x) le32_to_cpu(x)
3087 /** Convert from 64 bit little endian format to CPU format */
3088 #define woal_le64_to_cpu(x) le64_to_cpu(x)
3089 /** Convert to 16 bit little endian format from CPU format */
3090 #define woal_cpu_to_le16(x) cpu_to_le16(x)
3091 /** Convert to 32 bit little endian format from CPU format */
3092 #define woal_cpu_to_le32(x) cpu_to_le32(x)
3093 /** Convert to 64 bit little endian format from CPU format */
3094 #define woal_cpu_to_le64(x) cpu_to_le64(x)
3095 #else
3096 /** Do nothing */
3097 #define woal_le16_to_cpu(x) x
3098 /** Do nothing */
3099 #define woal_le32_to_cpu(x) x
3100 /** Do nothing */
3101 #define woal_le64_to_cpu(x) x
3102 /** Do nothing */
3103 #define woal_cpu_to_le16(x) x
3104 /** Do nothing */
3105 #define woal_cpu_to_le32(x) x
3106 /** Do nothing */
3107 #define woal_cpu_to_le64(x) x
3108 #endif
3109
3110 /**
3111 * @brief This function returns first available priv
3112 * based on the BSS role
3113 *
3114 * @param handle A pointer to moal_handle
3115 * @param bss_role BSS role or MLAN_BSS_ROLE_ANY
3116 *
3117 * @return Pointer to moal_private
3118 */
3119 static inline moal_private *woal_get_priv(moal_handle *handle,
3120 mlan_bss_role bss_role)
3121 {
3122 int i;
3123
3124 for (i = 0; i < MIN(handle->priv_num, MLAN_MAX_BSS_NUM); i++) {
3125 if (handle->priv[i]) {
3126 if (bss_role == MLAN_BSS_ROLE_ANY ||
3127 GET_BSS_ROLE(handle->priv[i]) == bss_role)
3128 return handle->priv[i];
3129 }
3130 }
3131 return NULL;
3132 }
3133
3134 /**
3135 * @brief This function returns first available priv
3136 * based on the BSS type
3137 *
3138 * @param handle A pointer to moal_handle
3139 * @param bss_type BSS type or MLAN_BSS_TYPE_ANY
3140 *
3141 * @return Pointer to moal_private
3142 */
3143 static inline moal_private *woal_get_priv_bss_type(moal_handle *handle,
3144 mlan_bss_type bss_type)
3145 {
3146 int i;
3147
3148 for (i = 0; i < MIN(handle->priv_num, MLAN_MAX_BSS_NUM); i++) {
3149 if (handle->priv[i]) {
3150 if (bss_type == MLAN_BSS_TYPE_ANY ||
3151 handle->priv[i]->bss_type == bss_type)
3152 return handle->priv[i];
3153 }
3154 }
3155 return NULL;
3156 }
3157
3158 static inline moal_private *woal_get_vir_priv_bss_type(moal_handle *handle,
3159 mlan_bss_type bss_type)
3160 {
3161 int i;
3162
3163 for (i = 0; i < MIN(handle->priv_num, MLAN_MAX_BSS_NUM); i++) {
3164 if (handle->priv[i]) {
3165 if (handle->priv[i]->bss_type == bss_type &&
3166 handle->priv[i]->bss_virtual)
3167 return handle->priv[i];
3168 }
3169 }
3170 return NULL;
3171 }
3172
3173 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
3174 /** get any cfg80211 priv */
3175 static inline moal_private *woal_get_priv_with_wdev(moal_handle *handle)
3176 {
3177 int i;
3178 for (i = 0; i < MIN(handle->priv_num, MLAN_MAX_BSS_NUM); i++) {
3179 if (handle->priv[i]) {
3180 if (handle->priv[i]->wdev)
3181 return handle->priv[i];
3182 }
3183 }
3184 return NULL;
3185 }
3186 #endif
3187
3188 static inline void woal_get_monotonic_time(wifi_timeval *tv)
3189 {
3190 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
3191 struct timespec64 ts;
3192 #else
3193 struct timespec ts;
3194 #endif
3195
3196 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
3197 ktime_get_raw_ts64(&ts);
3198 #else
3199 getrawmonotonic(&ts);
3200 #endif
3201 if (tv) {
3202 tv->time_sec = (t_u32)ts.tv_sec;
3203 tv->time_usec = (t_u32)ts.tv_nsec / 1000;
3204 }
3205 }
3206
3207 /* CAC Measure report default time 60 seconds */
3208 #define MEAS_REPORT_TIME (60 * HZ)
3209
3210 /** Max line length allowed in init config file */
3211 #define MAX_LINE_LEN 256
3212 /** Max MAC address string length allowed */
3213 #define MAX_MAC_ADDR_LEN 18
3214 /** Max register type/offset/value etc. parameter length allowed */
3215 #define MAX_PARAM_LEN 12
3216
3217 /** HostCmd_CMD_CFG_DATA for CAL data */
3218 #define HostCmd_CMD_CFG_DATA 0x008f
3219 /** HostCmd action set */
3220 #define HostCmd_ACT_GEN_SET 0x0001
3221 /** HostCmd CAL data header length */
3222 #define CFG_DATA_HEADER_LEN 6
3223
3224 typedef struct _HostCmd_DS_GEN {
3225 t_u16 command;
3226 t_u16 size;
3227 t_u16 seq_num;
3228 t_u16 result;
3229 } HostCmd_DS_GEN;
3230
3231 typedef struct _HostCmd_DS_802_11_CFG_DATA {
3232 /** Action */
3233 t_u16 action;
3234 /** Type */
3235 t_u16 type;
3236 /** Data length */
3237 t_u16 data_len;
3238 /** Data */
3239 t_u8 data[1];
3240 } __ATTRIB_PACK__ HostCmd_DS_802_11_CFG_DATA;
3241
3242 /** combo scan header */
3243 #define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00"
3244 /** combo scan header size */
3245 #define WEXT_CSCAN_HEADER_SIZE 12
3246 /** combo scan ssid section */
3247 #define WEXT_CSCAN_SSID_SECTION 'S'
3248 /** commbo scan channel section */
3249 #define WEXT_CSCAN_CHANNEL_SECTION 'C'
3250 /** commbo scan passive dwell section */
3251 #define WEXT_CSCAN_PASV_DWELL_SECTION 'P'
3252 /** commbo scan home dwell section */
3253 #define WEXT_CSCAN_HOME_DWELL_SECTION 'H'
3254 /** BGSCAN RSSI section */
3255 #define WEXT_BGSCAN_RSSI_SECTION 'R'
3256 /** BGSCAN SCAN INTERVAL SECTION */
3257 #define WEXT_BGSCAN_INTERVAL_SECTION 'T'
3258 /** BGSCAN REPEAT SECTION */
3259 #define WEXT_BGSCAN_REPEAT_SECTION 'E'
3260 /** Min BGSCAN interval 30 second */
3261 #define MIN_BGSCAN_INTERVAL 30000
3262 /** default repeat count */
3263 #define DEF_REPEAT_COUNT 6
3264
3265 /** default rssi low threshold */
3266 #define DEFAULT_RSSI_LOW_THRESHOLD 70
3267 /** RSSI HYSTERSIS */
3268 #define RSSI_HYSTERESIS 6
3269 /** lowest rssi threshold */
3270 #define LOWEST_RSSI_THRESHOLD 82
3271 /** delta rssi */
3272 #define DELTA_RSSI 10
3273
3274 /** NL80211 scan configuration header */
3275 #define NL80211_SCANCFG_HEADER "SCAN-CFG "
3276 /** NL80211 scan configuration header length */
3277 #define NL80211_SCANCFG_HEADER_SIZE 9
3278 /** NL80211 scan configuration active scan section */
3279 #define NL80211_SCANCFG_ACTV_DWELL_SECTION 'A'
3280 /** NL80211 scan configuration passive scan section */
3281 #define NL80211_SCANCFG_PASV_DWELL_SECTION 'P'
3282 /** NL80211 scan configuration specific scan section */
3283 #define NL80211_SCANCFG_SPCF_DWELL_SECTION 'S'
3284
3285 /** band AUTO */
3286 #define WIFI_FREQUENCY_BAND_AUTO 0
3287 /** band 5G */
3288 #define WIFI_FREQUENCY_BAND_5GHZ 1
3289 /** band 2G */
3290 #define WIFI_FREQUENCY_BAND_2GHZ 2
3291 /** All band */
3292 #define WIFI_FREQUENCY_ALL_BAND 3
3293
3294 /** Rx filter: IPV4 multicast */
3295 #define RX_FILTER_IPV4_MULTICAST 1
3296 /** Rx filter: broadcast */
3297 #define RX_FILTER_BROADCAST 2
3298 /** Rx filter: unicast */
3299 #define RX_FILTER_UNICAST 4
3300 /** Rx filter: IPV6 multicast */
3301 #define RX_FILTER_IPV6_MULTICAST 8
3302
3303 /** Convert ASCII string to hex value */
3304 int woal_ascii2hex(t_u8 *d, char *s, t_u32 dlen);
3305 /** parse ie */
3306 const t_u8 *woal_parse_ie_tlv(const t_u8 *ie, int len, t_u8 id);
3307 /** parse extension ie */
3308 const t_u8 *woal_parse_ext_ie_tlv(const t_u8 *ie, int len, t_u8 ext_id);
3309 /** Convert mac address from string to t_u8 buffer */
3310 void woal_mac2u8(t_u8 *mac_addr, char *buf);
3311 /** Extract token from string */
3312 char *woal_strsep(char **s, char delim, char esc);
3313 /** Return int value of a given ASCII string */
3314 mlan_status woal_atoi(int *data, char *a);
3315 /** Return hex value of a given ASCII string */
3316 int woal_atox(char *a);
3317 /** Allocate buffer */
3318 pmlan_buffer woal_alloc_mlan_buffer(moal_handle *handle, int size);
3319 /** Allocate IOCTL request buffer */
3320 pmlan_ioctl_req woal_alloc_mlan_ioctl_req(int size);
3321 /** Free buffer */
3322 void woal_free_mlan_buffer(moal_handle *handle, pmlan_buffer pmbuf);
3323 /** Get private structure of a BSS by index */
3324 moal_private *woal_bss_index_to_priv(moal_handle *handle, t_u8 bss_index);
3325 /* Functions in init module */
3326 /** init module parameters */
3327 mlan_status woal_init_module_param(moal_handle *handle);
3328 /** free module parameters */
3329 void woal_free_module_param(moal_handle *handle);
3330 /** init module parameters from device tree */
3331 void woal_init_from_dev_tree(void);
3332 /** initializes software */
3333 mlan_status woal_init_sw(moal_handle *handle);
3334 /** update the default firmware name */
3335 void woal_update_firmware_name(moal_handle *handle);
3336 /** cancel all works in the queue */
3337 void woal_terminate_workqueue(moal_handle *handle);
3338 void woal_flush_workqueue(moal_handle *handle);
3339 /** initializes firmware */
3340 mlan_status woal_init_fw(moal_handle *handle);
3341 /** frees the structure of moal_handle */
3342 void woal_free_moal_handle(moal_handle *handle);
3343 /** shutdown fw */
3344 mlan_status woal_shutdown_fw(moal_private *priv, t_u8 wait_option);
3345 /* Functions in interface module */
3346 #ifdef ANDROID_KERNEL
3347 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
3348 static inline void wakeup_source_init(struct wakeup_source *ws,
3349 const char *name)
3350 {
3351 ENTER();
3352
3353 if (ws) {
3354 memset(ws, 0, sizeof(*ws));
3355 ws->name = name;
3356 }
3357 wakeup_source_add(ws);
3358
3359 LEAVE();
3360 }
3361
3362 static inline void wakeup_source_trash(struct wakeup_source *ws)
3363 {
3364 ENTER();
3365
3366 if (!ws) {
3367 PRINTM(MERROR, "ws is null!\n");
3368 return;
3369 }
3370 wakeup_source_remove(ws);
3371 __pm_relax(ws);
3372
3373 LEAVE();
3374 }
3375 #endif
3376 #endif
3377 /** Add card */
3378 moal_handle *woal_add_card(void *card, struct device *dev, moal_if_ops *if_ops,
3379 t_u16 card_type);
3380 /** Remove card */
3381 mlan_status woal_remove_card(void *card);
3382 /** broadcast event */
3383 mlan_status woal_broadcast_event(moal_private *priv, t_u8 *payload, t_u32 len);
3384 #ifdef CONFIG_PROC_FS
3385 /** switch driver mode */
3386 mlan_status woal_switch_drv_mode(moal_handle *handle, t_u32 mode);
3387 #endif
3388
3389 int woal_check_media_connected(t_void *pmoal);
3390 /** check if any interface is up */
3391 t_u8 woal_is_any_interface_active(moal_handle *handle);
3392 /** Get version */
3393 void woal_get_version(moal_handle *handle, char *version, int maxlen);
3394 /** Get Driver Version */
3395 int woal_get_driver_version(moal_private *priv, struct ifreq *req);
3396 /** Get extended driver version */
3397 int woal_get_driver_verext(moal_private *priv, struct ifreq *ireq);
3398 /** check driver status */
3399 t_u8 woal_check_driver_status(moal_handle *handle);
3400 /** Mgmt frame forward registration */
3401 int woal_reg_rx_mgmt_ind(moal_private *priv, t_u16 action,
3402 t_u32 *pmgmt_subtype_mask, t_u8 wait_option);
3403 #ifdef DEBUG_LEVEL1
3404 /** Set driver debug bit masks */
3405 int woal_set_drvdbg(moal_private *priv, t_u32 drv_dbg);
3406 #endif
3407
3408 mlan_status woal_set_get_tx_bf_cap(moal_private *priv, t_u16 action,
3409 t_u32 *tx_bf_cap);
3410 /** Set/Get TX beamforming configurations */
3411 mlan_status woal_set_get_tx_bf_cfg(moal_private *priv, t_u16 action,
3412 mlan_ds_11n_tx_bf_cfg *bf_cfg);
3413 /** Request MAC address setting */
3414 mlan_status woal_request_set_mac_address(moal_private *priv, t_u8 wait_option);
3415 /** Request multicast list setting */
3416 void woal_request_set_multicast_list(moal_private *priv,
3417 struct net_device *dev);
3418 /** Request IOCTL action */
3419 mlan_status woal_request_ioctl(moal_private *priv, mlan_ioctl_req *req,
3420 t_u8 wait_option);
3421 /** Set/Get generic element */
3422 mlan_status woal_set_get_gen_ie(moal_private *priv, t_u32 action, t_u8 *ie,
3423 int *ie_len, t_u8 wait_option);
3424 #ifdef CONFIG_PROC_FS
3425 mlan_status woal_request_soft_reset(moal_handle *handle);
3426 #endif
3427 int woal_request_fw_reload(moal_handle *phandle, t_u8 mode);
3428
3429 /** Get debug information */
3430 mlan_status woal_get_debug_info(moal_private *priv, t_u8 wait_option,
3431 mlan_debug_info *debug_info);
3432 /** Set debug information */
3433 mlan_status woal_set_debug_info(moal_private *priv, t_u8 wait_option,
3434 mlan_debug_info *debug_info);
3435 /** Disconnect */
3436 mlan_status woal_disconnect(moal_private *priv, t_u8 wait_option, t_u8 *mac,
3437 t_u16 reason_code);
3438 /** associate */
3439 mlan_status woal_bss_start(moal_private *priv, t_u8 wait_option,
3440 mlan_ssid_bssid *ssid_bssid);
3441 /** Request firmware information */
3442 mlan_status woal_request_get_fw_info(moal_private *priv, t_u8 wait_option,
3443 mlan_fw_info *fw_info);
3444 /** Get channel of active intf */
3445 mlan_status woal_get_active_intf_channel(moal_private *priv,
3446 chan_band_info *channel);
3447 #ifdef STA_SUPPORT
3448 /** Request Exented Capability information */
3449 int woal_request_extcap(moal_private *priv, t_u8 *buf, t_u8 len);
3450 #endif
3451 mlan_status woal_set_get_dtim_period(moal_private *priv, t_u32 action,
3452 t_u8 wait_option, t_u8 *value);
3453 /** Set/get Host Sleep parameters */
3454 mlan_status woal_set_get_hs_params(moal_private *priv, t_u16 action,
3455 t_u8 wait_option, mlan_ds_hs_cfg *hscfg);
3456 /** Cancel Host Sleep configuration */
3457 mlan_status woal_cancel_hs(moal_private *priv, t_u8 wait_option);
3458 /** Enable Host Sleep configuration */
3459 int woal_enable_hs(moal_private *priv);
3460 /** hs active timeout 2 second */
3461 #define HS_ACTIVE_TIMEOUT (2 * HZ)
3462 /** Get wakeup reason */
3463 mlan_status woal_get_wakeup_reason(moal_private *priv,
3464 mlan_ds_hs_wakeup_reason *wakeup_reason);
3465 int woal_process_proc_hssetpara(moal_handle *handle, t_u8 *buf);
3466 #define FW_DUMP_INFO_LEN 0x280000
3467 /** mem dump header */
3468 typedef struct {
3469 /** seq number */
3470 t_u16 seq_num;
3471 /** resvered */
3472 t_u16 reserved;
3473 /** type */
3474 t_u16 type;
3475 /** len */
3476 t_u16 len;
3477 /** start addr */
3478 t_u32 start_addr;
3479 } mem_dump_header;
3480 int woal_save_dump_info_to_buf(moal_handle *phandle, t_u8 *src, t_u32 len,
3481 t_u32 type);
3482 void woal_append_end_block(moal_handle *phandle);
3483 t_u8 *woal_dump_drv_info(moal_handle *phandle, t_u32 *dump_len);
3484
3485 #define FW_DUMP_TYPE_ENDED 0x002
3486 #define FW_DUMP_TYPE_MEM_ITCM 0x004
3487 #define FW_DUMP_TYPE_MEM_DTCM 0x005
3488 #define FW_DUMP_TYPE_MEM_SQRAM 0x006
3489 #define FW_DUMP_TYPE_MEM_IRAM 0x007
3490 #define FW_DUMP_TYPE_REG_MAC 0x009
3491 #define FW_DUMP_TYPE_REG_CIU 0x00E
3492 #define FW_DUMP_TYPE_REG_APU 0x00F
3493 #define FW_DUMP_TYPE_REG_ICU 0x014
3494 #ifdef SDIO_MMC
3495 void woal_dump_firmware_info(moal_handle *phandle);
3496 void woal_dump_firmware_info_v2(moal_handle *phandle);
3497 void woal_dump_firmware_info_v3(moal_handle *phandle);
3498 #endif /* SDIO_MMC */
3499 /* Store the FW dumps received from events in a file */
3500 void woal_store_firmware_dump(moal_handle *phandle, pmlan_event pmevent);
3501 void woal_send_fw_dump_complete_event(moal_private *priv);
3502
3503 int woal_pre_warmreset(moal_private *priv);
3504 int woal_warmreset(moal_private *priv);
3505
3506 /** get deep sleep */
3507 int woal_get_deep_sleep(moal_private *priv, t_u32 *data);
3508 /** set deep sleep */
3509 int woal_set_deep_sleep(moal_private *priv, t_u8 wait_option,
3510 BOOLEAN bdeep_sleep, t_u16 idletime);
3511 /** process hang */
3512 void woal_process_hang(moal_handle *handle);
3513 /** Get BSS information */
3514 mlan_status woal_get_bss_info(moal_private *priv, t_u8 wait_option,
3515 mlan_bss_info *bss_info);
3516 void woal_process_ioctl_resp(moal_private *priv, mlan_ioctl_req *req);
3517 char *region_code_2_string(t_u8 region_code);
3518 t_bool woal_is_etsi_country(t_u8 *country_code);
3519 t_u8 woal_is_valid_alpha2(char *alpha2);
3520 #ifdef STA_SUPPORT
3521 void woal_send_disconnect_to_system(moal_private *priv, t_u16 reason_code);
3522 void woal_send_mic_error_event(moal_private *priv, t_u32 event);
3523 void woal_ioctl_get_bss_resp(moal_private *priv, mlan_ds_bss *bss);
3524 void woal_ioctl_get_info_resp(moal_private *priv, mlan_ds_get_info *info);
3525 mlan_status woal_get_assoc_rsp(moal_private *priv,
3526 mlan_ds_misc_assoc_rsp *assoc_rsp,
3527 t_u8 wait_option);
3528 mlan_status woal_get_assoc_req(moal_private *priv,
3529 mlan_ds_misc_assoc_req *assoc_req,
3530 t_u8 wait_option);
3531
3532 /** Get signal information */
3533 mlan_status woal_get_signal_info(moal_private *priv, t_u8 wait_option,
3534 mlan_ds_get_signal *signal);
3535 /** Get mode */
3536 t_u32 woal_get_mode(moal_private *priv, t_u8 wait_option);
3537 mlan_status woal_get_sta_channel(moal_private *priv, t_u8 wait_option,
3538 chan_band_info *channel);
3539 #ifdef STA_WEXT
3540 /** Get data rates */
3541 mlan_status woal_get_data_rates(moal_private *priv, t_u8 wait_option,
3542 pmoal_802_11_rates m_rates);
3543 void woal_send_iwevcustom_event(moal_private *priv, char *str);
3544 /** Get channel list */
3545 mlan_status woal_get_channel_list(moal_private *priv, t_u8 wait_option,
3546 mlan_chan_list *chanlist);
3547 mlan_status woal_11d_check_ap_channel(moal_private *priv, t_u8 wait_option,
3548 mlan_ssid_bssid *ssid_bssid);
3549 #endif
3550 /** Set/Get retry count */
3551 mlan_status woal_set_get_retry(moal_private *priv, t_u32 action,
3552 t_u8 wait_option, int *value);
3553 /** Set/Get RTS threshold */
3554 mlan_status woal_set_get_rts(moal_private *priv, t_u32 action, t_u8 wait_option,
3555 int *value);
3556 /** Set/Get fragment threshold */
3557 mlan_status woal_set_get_frag(moal_private *priv, t_u32 action,
3558 t_u8 wait_option, int *value);
3559 /** Set/Get TX power */
3560 mlan_status woal_set_get_tx_power(moal_private *priv, t_u32 action,
3561 mlan_power_cfg_t *pwr);
3562 /** Set/Get power IEEE management */
3563 mlan_status woal_set_get_power_mgmt(moal_private *priv, t_u32 action,
3564 int *disabled, int type, t_u8 wait_option);
3565 /** Get data rate */
3566 mlan_status woal_set_get_data_rate(moal_private *priv, t_u8 action,
3567 mlan_rate_cfg_t *datarate);
3568 /** Request a network scan */
3569 mlan_status woal_request_scan(moal_private *priv, t_u8 wait_option,
3570 mlan_802_11_ssid *req_ssid);
3571 /** Set radio on/off */
3572 int woal_set_radio(moal_private *priv, t_u8 option);
3573 /** Set region code */
3574 mlan_status woal_set_region_code(moal_private *priv, char *region);
3575 /** Set authentication mode */
3576 mlan_status woal_set_auth_mode(moal_private *priv, t_u8 wait_option,
3577 t_u32 auth_mode);
3578 /** Set encryption mode */
3579 mlan_status woal_set_encrypt_mode(moal_private *priv, t_u8 wait_option,
3580 t_u32 encrypt_mode);
3581 /** Enable wep key */
3582 mlan_status woal_enable_wep_key(moal_private *priv, t_u8 wait_option);
3583 /** Set WPA enable */
3584 mlan_status woal_set_wpa_enable(moal_private *priv, t_u8 wait_option,
3585 t_u32 enable);
3586 /** cancel scan command */
3587 mlan_status woal_cancel_scan(moal_private *priv, t_u8 wait_option);
3588 /** Find best network to connect */
3589 mlan_status woal_find_best_network(moal_private *priv, t_u8 wait_option,
3590 mlan_ssid_bssid *ssid_bssid);
3591 /** Set Ad-Hoc channel */
3592 mlan_status woal_change_adhoc_chan(moal_private *priv, int channel,
3593 t_u8 wait_option);
3594
3595 /** Get scan table */
3596 mlan_status woal_get_scan_table(moal_private *priv, t_u8 wait_option,
3597 mlan_scan_resp *scanresp);
3598 /** Get authentication mode */
3599 mlan_status woal_get_auth_mode(moal_private *priv, t_u8 wait_option,
3600 t_u32 *auth_mode);
3601 /** Get encryption mode */
3602 mlan_status woal_get_encrypt_mode(moal_private *priv, t_u8 wait_option,
3603 t_u32 *encrypt_mode);
3604 /** Get WPA state */
3605 mlan_status woal_get_wpa_enable(moal_private *priv, t_u8 wait_option,
3606 t_u32 *enable);
3607 #endif /**STA_SUPPORT */
3608
3609 mlan_status woal_set_11d(moal_private *priv, t_u8 wait_option, t_u8 enable);
3610
3611 mlan_status woal_process_rf_test_mode(moal_handle *handle, t_u32 mode);
3612 mlan_status woal_process_rf_test_mode_cmd(moal_handle *handle, t_u32 cmd,
3613 const char *buffer, size_t len,
3614 t_u32 action, t_u32 val);
3615 #if defined(STA_SUPPORT) || defined(UAP_SUPPORT)
3616 /** Get statistics information */
3617 mlan_status woal_get_stats_info(moal_private *priv, t_u8 wait_option,
3618 pmlan_ds_get_stats stats);
3619 #endif /**STA_SUPPORT||UAP_SUPPORT*/
3620
3621 mlan_status woal_set_wapi_enable(moal_private *priv, t_u8 wait_option,
3622 t_u32 enable);
3623
3624 /** Initialize priv */
3625 void woal_init_priv(moal_private *priv, t_u8 wait_option);
3626 /** Reset interface(s) */
3627 mlan_status woal_reset_intf(moal_private *priv, t_u8 wait_option, int all_intf);
3628 #define TLV_TYPE_MGMT_IE (0x169)
3629 #define MGMT_MASK_ASSOC_REQ 0x01
3630 #define MGMT_MASK_REASSOC_REQ 0x04
3631 #define MGMT_MASK_ASSOC_RESP 0x02
3632 #define MGMT_MASK_REASSOC_RESP 0x08
3633 #define MGMT_MASK_PROBE_REQ 0x10
3634 #define MGMT_MASK_PROBE_RESP 0x20
3635 #define MGMT_MASK_BEACON 0x100
3636 #define MGMT_MASK_ASSOC_RESP_QOS_MAP 0x4000
3637 #define MGMT_MASK_BEACON_WPS_P2P 0x8000
3638 #define MLAN_CUSTOM_IE_DELETE_MASK 0x0
3639 /** common ioctl for uap, station */
3640 int woal_custom_ie_ioctl(struct net_device *dev, struct ifreq *req);
3641 #ifdef UAP_SUPPORT
3642 int woal_priv_get_nonglobal_operclass_by_bw_channel(moal_private *priv,
3643 t_u8 bandwidth,
3644 t_u8 channel,
3645 t_u8 *oper_class);
3646 #endif
3647 int woal_send_host_packet(struct net_device *dev, struct ifreq *req);
3648 /** Private command ID to pass mgmt frame */
3649 #define WOAL_MGMT_FRAME_TX_IOCTL (SIOCDEVPRIVATE + 12)
3650 /** common ioctl for TDLS */
3651 int woal_tdls_config_ioctl(struct net_device *dev, struct ifreq *req);
3652
3653 int woal_get_bss_type(struct net_device *dev, struct ifreq *req);
3654 #if defined(STA_WEXT) || defined(UAP_WEXT)
3655 int woal_host_command(moal_private *priv, struct iwreq *wrq);
3656 #endif
3657 #if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
3658 mlan_status woal_bss_role_cfg(moal_private *priv, t_u8 action, t_u8 wait_option,
3659 t_u8 *bss_role);
3660 #if defined(STA_CFG80211) && defined(UAP_CFG80211)
3661 void woal_go_timer_func(void *context);
3662 #endif
3663 #if defined(STA_WEXT) || defined(UAP_WEXT)
3664 int woal_set_get_bss_role(moal_private *priv, struct iwreq *wrq);
3665 #endif
3666 #endif
3667 #if defined(WIFI_DIRECT_SUPPORT) || defined(UAP_SUPPORT)
3668 /** hostcmd ioctl for uap, wifidirect */
3669 int woal_hostcmd_ioctl(struct net_device *dev, struct ifreq *req);
3670 #endif
3671
3672 mlan_status woal_set_remain_channel_ioctl(moal_private *priv, t_u8 wait_option,
3673 pmlan_ds_remain_chan pchan);
3674 void woal_remain_timer_func(void *context);
3675 #ifdef WIFI_DIRECT_SUPPORT
3676 mlan_status woal_wifi_direct_mode_cfg(moal_private *priv, t_u16 action,
3677 t_u16 *mode);
3678 mlan_status woal_p2p_config(moal_private *priv, t_u32 action,
3679 mlan_ds_wifi_direct_config *p2p_config);
3680 #endif /* WIFI_DIRECT_SUPPORT */
3681
3682 int woal_11h_cancel_chan_report_ioctl(moal_private *priv, t_u8 wait_option);
3683
3684 #ifdef CONFIG_PROC_FS
3685 /** Initialize /proc/mwlan */
3686 mlan_status woal_root_proc_init(void);
3687 /** Remove /proc/mwlan */
3688 void woal_root_proc_remove(void);
3689 /** Initialize proc fs */
3690 void woal_proc_init(moal_handle *handle);
3691 /** Clean up proc fs */
3692 void woal_proc_exit(moal_handle *handle);
3693 /** Create proc entry */
3694 void woal_create_proc_entry(moal_private *priv);
3695 /** Remove proc entry */
3696 void woal_proc_remove(moal_private *priv);
3697 /** string to number */
3698 int woal_string_to_number(char *s);
3699 #endif
3700
3701 /** Create debug proc fs */
3702 void woal_debug_entry(moal_private *priv);
3703 /** Remove debug proc fs */
3704 void woal_debug_remove(moal_private *priv);
3705
3706 /** check pm info */
3707 mlan_status woal_get_pm_info(moal_private *priv, mlan_ds_ps_info *pm_info);
3708 /** get mlan debug info */
3709 void woal_mlan_debug_info(moal_private *priv);
3710
3711 #ifdef USB
3712 #ifdef CONFIG_USB_SUSPEND
3713 /** Enter USB Suspend */
3714 int woal_enter_usb_suspend(moal_handle *handle);
3715 /** Exit from USB Suspend */
3716 int woal_exit_usb_suspend(moal_handle *handle);
3717 #endif /* CONFIG_USB_SUSPEND */
3718 #endif
3719
3720 #ifdef REASSOCIATION
3721 int woal_reassociation_thread(void *data);
3722 void woal_reassoc_timer_func(void *context);
3723 #endif /* REASSOCIATION */
3724
3725 void woal_fw_dump_timer_func(void *context);
3726
3727 t_void woal_main_work_queue(struct work_struct *work);
3728 t_void woal_rx_work_queue(struct work_struct *work);
3729 t_void woal_evt_work_queue(struct work_struct *work);
3730 t_void woal_mclist_work_queue(struct work_struct *work);
3731 #ifdef STA_CFG80211
3732 t_void woal_scan_timeout_handler(struct work_struct *work);
3733 #endif
3734
3735 netdev_tx_t woal_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
3736 #ifdef STA_SUPPORT
3737 mlan_status woal_init_sta_dev(struct net_device *dev, moal_private *priv);
3738 #endif
3739 #ifdef UAP_SUPPORT
3740 mlan_status woal_init_uap_dev(struct net_device *dev, moal_private *priv);
3741 #endif
3742 mlan_status woal_update_drv_tbl(moal_handle *handle, int drv_mode_local);
3743 void woal_fill_mlan_buffer(moal_private *priv, mlan_buffer *pmbuf,
3744 struct sk_buff *skb);
3745 moal_private *woal_add_interface(moal_handle *handle, t_u8 bss_num,
3746 t_u8 bss_type);
3747 void woal_remove_interface(moal_handle *handle, t_u8 bss_index);
3748 void woal_set_multicast_list(struct net_device *dev);
3749 mlan_status woal_request_fw(moal_handle *handle);
3750 mlan_status woal_ioctl_aggr_prio_tbl(moal_private *priv, t_u32 action,
3751 mlan_ds_11n_aggr_prio_tbl *aggr_prio_tbl);
3752
3753 int woal_11h_channel_check_ioctl(moal_private *priv, t_u8 wait_option);
3754 void woal_cancel_cac_block(moal_private *priv);
3755 void woal_moal_debug_info(moal_private *priv, moal_handle *handle, u8 flag);
3756
3757 #ifdef STA_SUPPORT
3758 mlan_status woal_get_powermode(moal_private *priv, int *powermode);
3759 mlan_status woal_set_scan_type(moal_private *priv, t_u32 scan_type);
3760 mlan_status woal_get_scan_config(moal_private *priv, mlan_scan_cfg *scan_cfg);
3761 mlan_status woal_enable_ext_scan(moal_private *priv, t_u8 enable);
3762 mlan_status woal_set_powermode(moal_private *priv, char *powermode);
3763 int woal_find_essid(moal_private *priv, mlan_ssid_bssid *ssid_bssid,
3764 t_u8 wait_option);
3765 mlan_status woal_find_bssid(moal_private *priv, mlan_802_11_mac_addr bssid);
3766 mlan_status woal_request_userscan(moal_private *priv, t_u8 wait_option,
3767 wlan_user_scan_cfg *scan_cfg);
3768 mlan_status woal_do_scan(moal_private *priv, wlan_user_scan_cfg *scan_cfg);
3769 int woal_set_combo_scan(moal_private *priv, char *buf, int length);
3770 mlan_status woal_set_scan_time(moal_private *priv, t_u16 active_scan_time,
3771 t_u16 passive_scan_time,
3772 t_u16 specific_scan_time);
3773 mlan_status woal_get_band(moal_private *priv, int *band);
3774 mlan_status woal_set_band(moal_private *priv, char *pband);
3775 mlan_status woal_add_rxfilter(moal_private *priv, char *rxfilter);
3776 mlan_status woal_remove_rxfilter(moal_private *priv, char *rxfilter);
3777 mlan_status woal_priv_qos_cfg(moal_private *priv, t_u32 action, char *qos_cfg);
3778 mlan_status woal_set_sleeppd(moal_private *priv, char *psleeppd);
3779 int woal_set_scan_cfg(moal_private *priv, char *buf, int length);
3780 void woal_update_dscp_mapping(moal_private *priv);
3781
3782 /* EVENT: BCN_RSSI_LOW */
3783 #define EVENT_BCN_RSSI_LOW 0x0001
3784 /* EVENT: PRE_BCN_LOST */
3785 #define EVENT_PRE_BCN_LOST 0x0002
3786 mlan_status woal_set_rssi_low_threshold(moal_private *priv, char *rssi,
3787 t_u8 wait_option);
3788 mlan_status woal_set_rssi_threshold(moal_private *priv, t_u32 event_id,
3789 t_u8 wait_option);
3790 /* EVENT: BG_SCAN_REPORT */
3791 #define EVENT_BG_SCAN_REPORT 0x0004
3792 mlan_status woal_set_bg_scan(moal_private *priv, char *buf, int length);
3793 mlan_status woal_stop_bg_scan(moal_private *priv, t_u8 wait_option);
3794 void woal_reconfig_bgscan(moal_handle *handle);
3795 #ifdef STA_CFG80211
3796 void woal_config_bgscan_and_rssi(moal_private *priv, t_u8 set_rssi);
3797 void woal_start_roaming(moal_private *priv);
3798 #endif
3799 mlan_status woal_request_bgscan(moal_private *priv, t_u8 wait_option,
3800 wlan_bgscan_cfg *scan_cfg);
3801 #endif
3802 #ifdef STA_CFG80211
3803 void woal_save_conn_params(moal_private *priv,
3804 struct cfg80211_connect_params *sme);
3805 void woal_clear_conn_params(moal_private *priv);
3806 #endif
3807
3808 void woal_flush_tcp_sess_queue(moal_private *priv);
3809 #ifdef STA_CFG80211
3810 void woal_flush_tdls_list(moal_private *priv);
3811 #endif
3812 void wlan_scan_create_brief_table_entry(t_u8 **ppbuffer,
3813 BSSDescriptor_t *pbss_desc);
3814 int wlan_get_scan_table_ret_entry(BSSDescriptor_t *pbss_desc, t_u8 **ppbuffer,
3815 int *pspace_left);
3816 BOOLEAN woal_ssid_valid(mlan_802_11_ssid *pssid);
3817 int woal_is_connected(moal_private *priv, mlan_ssid_bssid *ssid_bssid);
3818 int woal_priv_hostcmd(moal_private *priv, t_u8 *respbuf, t_u32 respbuflen,
3819 t_u8 wait_option);
3820 void woal_flush_tx_stat_queue(moal_private *priv);
3821 struct tx_status_info *woal_get_tx_info(moal_private *priv, t_u8 tx_seq_num);
3822 void woal_remove_tx_info(moal_private *priv, t_u8 tx_seq_num);
3823
3824 void woal_flush_mcast_list(moal_private *priv);
3825 t_void woal_add_mcast_node(moal_private *priv, t_u8 *mcast_addr);
3826 void woal_remove_mcast_node(moal_private *priv, t_u8 *mcast_addr);
3827 t_u8 woal_find_mcast_node_tx(moal_private *priv, struct sk_buff *skb);
3828
3829 mlan_status woal_request_country_power_table(moal_private *priv, char *region);
3830 #ifdef RX_PACKET_COALESCE
3831 mlan_status woal_rx_pkt_coalesce_cfg(moal_private *priv, t_u16 *enable,
3832 t_u8 wait_option, t_u8 action);
3833 #endif
3834 mlan_status woal_set_low_pwr_mode(moal_handle *handle, t_u8 wait_option);
3835 mlan_status woal_set_chan_track_mode(moal_handle *handle, t_u8 wait_option);
3836 int woal_hexval(char chr);
3837 mlan_status woal_pmic_configure(moal_handle *handle, t_u8 wait_option);
3838 mlan_status woal_set_user_antcfg(moal_handle *handle, t_u8 wait_option);
3839 void woal_hist_data_reset(moal_private *priv);
3840 void woal_hist_do_reset(moal_private *priv, void *data);
3841 void woal_hist_reset_table(moal_private *priv, t_u8 antenna);
3842 void woal_hist_data_add(moal_private *priv, t_u16 rx_rate, t_s8 snr, t_s8 nflr,
3843 t_u8 antenna);
3844 mlan_status woal_set_hotspotcfg(moal_private *priv, t_u8 wait_option,
3845 t_u32 hotspotcfg);
3846
3847 mlan_status woal_set_get_wowlan_config(moal_private *priv, t_u16 action,
3848 t_u8 wait_option,
3849 mlan_ds_misc_mef_flt_cfg *mefcfg);
3850 mlan_status woal_set_auto_arp_ext(moal_handle *handle, t_u8 enable);
3851 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
3852 mlan_status woal_set_net_monitor(moal_private *priv, t_u8 wait_option,
3853 t_u8 enable, t_u8 filter,
3854 netmon_band_chan_cfg *band_chan_cfg);
3855 #endif
3856 mlan_status woal_delba_all(moal_private *priv, t_u8 wait_option);
3857 #ifdef STA_CFG80211
3858 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
3859 int woal_mkeep_alive_vendor_event(moal_private *priv,
3860 pmlan_ds_misc_keep_alive mkeep_alive);
3861 #endif
3862 #endif
3863 int woal_start_mkeep_alive(moal_private *priv, t_u8 mkeep_alive_id,
3864 t_u8 *ip_pkt, t_u16 ip_pkt_len, t_u8 *src_mac,
3865 t_u8 *dst_mac, t_u32 period_msec,
3866 t_u32 retry_interval, t_u8 retry_cnt);
3867 int woal_stop_mkeep_alive(moal_private *priv, t_u8 mkeep_alive_id, t_u8 reset,
3868 t_u8 *ip_pkt, t_u8 *pkt_len);
3869 int woal_priv_save_cloud_keep_alive_params(
3870 moal_private *priv, t_u8 mkeep_alive_id, t_u8 enable, t_u16 ether_type,
3871 t_u8 *ip_pkt, t_u16 ip_pkt_len, t_u8 *src_mac, t_u8 *dst_mac,
3872 t_u32 period_msec, t_u32 retry_interval, t_u8 retry_cnt);
3873 #ifdef UAP_SUPPORT
3874 mlan_status woal_set_wacp_mode(moal_private *priv, t_u8 wait_option);
3875 #endif
3876 mlan_status woal_init_aggr_ctrl(moal_handle *handle, t_u8 wait_option);
3877
3878 #if defined(STA_CFG80211) && defined(UAP_CFG80211)
3879 monitor_iface *woal_prepare_mon_if(moal_private *priv, const char *name,
3880 unsigned char name_assign_type,
3881 int sniffer_mode);
3882 #endif
3883
3884 #if defined(STA_CFG80211) || defined(UAP_CFG80211)
3885 #if KERNEL_VERSION(3, 14, 0) <= CFG80211_VERSION_CODE
3886 void woal_cfg80211_vendor_event_fw_dump(moal_private *priv);
3887 #endif
3888 #endif
3889
3890 #ifdef STA_CFG80211
3891 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
3892 mlan_status woal_set_rekey_data(moal_private *priv,
3893 mlan_ds_misc_gtk_rekey_data *gtk_rekey,
3894 t_u8 action, t_u8 wait_option);
3895 #endif
3896 #endif
3897
3898 mlan_status woal_vdll_req_fw(moal_handle *handle);
3899
3900 void woal_ioctl_get_misc_conf(moal_private *priv, mlan_ds_misc_cfg *info);
3901 t_u8 woal_get_second_channel_offset(moal_private *priv, int chan);
3902
3903 #ifdef IMX_SUPPORT
3904 void woal_regist_oob_wakeup_irq(moal_handle *handle);
3905 void woal_unregist_oob_wakeup_irq(moal_handle *handle);
3906 void woal_disable_oob_wakeup_irq(moal_handle *handle);
3907 void woal_enable_oob_wakeup_irq(moal_handle *handle);
3908 irqreturn_t woal_oob_wakeup_irq_handler(int irq, void *priv);
3909 #endif /* IMX_SUPPORT */
3910 #endif /* _MOAL_MAIN_H */
3911