2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/os/linux/include/gl_os.h#2 $
6 \brief List the external reference to OS for GLUE Layer.
8 In this file we define the data structure - GLUE_INFO_T to store those objects
9 we acquired from OS - e.g. TIMER, SPINLOCK, NET DEVICE ... . And all the
10 external reference (header file, extern func() ..) to OS for GLUE Layer should
19 ** 08 20 2012 yuche.tsai
21 ** Fix possible KE issue.
23 ** 08 20 2012 yuche.tsai
24 ** [ALPS00339327] [Rose][6575JB][BSP Package][Free Test][KE][WIFI]There is no response when you tap the turn off/on button,wait a minutes, the device will reboot automatically and "KE" will pop up.
25 ** Fix possible KE when netlink operate mgmt frame register.
29 * Add AEE message support
30 * 1) Show AEE warning(red screen) if SDIO access error occurs
35 * Enable CFG80211 Support.
38 * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
39 * Adding the related ioctl / wlan oid function to set the Tx power cfg.
42 * [WCXRP00001136] [All Wi-Fi][Driver] Add wake lock for pending timer
43 * Add wake lock if timer timeout value is smaller than 5 seconds
45 * 11 18 2011 yuche.tsai
47 * CONFIG P2P support RSSI query, default turned off.
49 * 11 16 2011 yuche.tsai
51 * Avoid using work thread.
53 * 11 11 2011 yuche.tsai
55 * Fix work thread cancel issue.
58 * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
59 * adding the 802.11w related function and define .
63 * Show DRV_NAME by chip id.
66 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
67 * Remove flag CFG_WIFI_DIRECT_MOVED.
70 * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events
71 * implement kernel-to-userspace communication via generic netlink socket for whole-chip resetting mechanism
74 * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
75 * portability improvement
77 * 03 17 2011 chinglan.wang
78 * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
81 * 03 03 2011 jeffrey.chang
82 * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
83 * support concurrent network
85 * 03 03 2011 jeffrey.chang
86 * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
87 * modify net device relative functions to support multiple H/W queues
90 * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
91 * Add security check code.
94 * [WCXRP00000482] [MT6620 Wi-Fi][Driver] Simplify logic for checking NVRAM existence in driver domain
95 * simplify logic for checking NVRAM existence only once.
97 * 02 16 2011 jeffrey.chang
99 * Add query ipv4 and ipv6 address during early suspend and late resume
101 * 02 10 2011 chinghwa.yu
102 * [WCXRP00000065] Update BoW design and settings
103 * Fix kernel API change issue.
104 * Before ALPS 2.2 (2.2 included), kfifo_alloc() is
105 * struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock);
106 * After ALPS 2.3, kfifo_alloc() is changed to
107 * int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask);
110 * [WCXRP00000433] [MT6620 Wi-Fi][Driver] Remove WAPI structure define for avoid P2P module with structure miss-align pointer issue
111 * always pre-allio WAPI related structure for align p2p module.
113 * 02 09 2011 terry.wu
114 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
115 * Halt p2p module init and exit until TxThread finished p2p register and unregister.
117 * 02 01 2011 cm.chang
118 * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
121 * 01 27 2011 cm.chang
122 * [WCXRP00000402] [MT6620 Wi-Fi][Driver] Enable MCR read/write by iwpriv by default
126 * [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP
127 * implementation of separate BT_OVER_WIFI data path.
130 * [WCXRP00000356] [MT6620 Wi-Fi][Driver] fill mac header length for security frames 'cause hardware header translation needs such information
131 * fill mac header length information for 802.1x frames.
133 * 01 11 2011 chinglan.wang
135 * Modify to reslove the CR :[ALPS00028994] Use WEP security to connect Marvell 11N AP. Connection establish successfully.
136 * Use the WPS function to connect AP, the privacy bit always is set to 1.
139 * [WCXRP00000349] [MT6620 Wi-Fi][Driver] make kalIoctl() of linux port as a thread safe API to avoid potential issues due to multiple access
140 * use mutex to protect kalIoctl() for thread safe.
143 * [WCXRP00000283] [MT6620 Wi-Fi][Driver][Wi-Fi Direct] Implementation of interface for supporting Wi-Fi Direct Service Discovery
144 * ioctl implementations for P2P Service Discovery
147 * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
148 * adding the p2p random ssid support.
151 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
152 * complete implementation of Android NVRAM access
156 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
159 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
160 * add skeleton for NVRAM integration
164 * add waitq for poll() and read().
168 * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
172 * let the p2p can set the privacy bit at beacon and rsn ie at assoc req at key handshake state.
174 * 09 03 2010 kevin.huang
176 * Refine #include sequence and solve recursive/nested #include issue
180 * adding the wapi support for integration test.
182 * 08 31 2010 kevin.huang
184 * Use LINK LIST operation to process SCAN result
188 * revise constant definitions to be matched with implementation (original cmd-event definition is deprecated)
192 * P2P packets are now marked when being queued into driver, and identified later without checking MAC address
196 * revised implementation of Wi-Fi Direct io controls.
200 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
201 * 2) extending scanning result to 64 instead of 48
205 * driver hook modifications corresponding to ioctl interface change.
209 * [Wi-Fi Direct] add framework for driver hooks
211 * 08 02 2010 jeffrey.chang
213 * 1) modify tx service thread to avoid busy looping
214 * 2) add spin lock declartion for linux build
216 * 07 23 2010 jeffrey.chang
220 * 07 22 2010 jeffrey.chang
222 * modify tx thread and remove some spinlock
224 * 07 19 2010 jeffrey.chang
226 * add security frame pending count
230 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
232 * 06 06 2010 kevin.huang
233 * [WPD00003832][MT6620 5931] Create driver base
234 * [MT6620 5931] Create driver base
237 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
238 * add ioctl to configure scan mode for p2p connection
241 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
242 * add cfg80211 interface, which is to replace WE, for further extension
245 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
246 * add ioctl framework for Wi-Fi Direct by reusing wireless extension ioctls as well
249 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
250 * p2p ioctls revised.
253 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
254 * add ioctl for controlling p2p scan phase parameters
257 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
258 * implement basic wi-fi direct framework
260 * 05 07 2010 jeffrey.chang
261 * [WPD00003826]Initial import for Linux port
262 * prevent supplicant accessing driver during resume
265 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
266 * add basic framework for implementating P2P driver hook.
269 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
270 * change variable names for multiple physical link to match with coding convention
273 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
274 * identify BT Over Wi-Fi Security frame and mark it as 802.1X frame
277 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
278 * add multiple physical link support
280 * 04 27 2010 jeffrey.chang
281 * [WPD00003826]Initial import for Linux port
282 * 1) fix firmware download bug
283 * 2) remove query statistics for acelerating firmware download
285 * 04 27 2010 jeffrey.chang
286 * [WPD00003826]Initial import for Linux port
287 * follow Linux's firmware framework, and remove unused kal API
290 * [WPD00001943]Create WiFi test driver framework on WinXP
291 * surpress compiler warning
293 * 04 19 2010 jeffrey.chang
294 * [WPD00003826]Initial import for Linux port
295 * supporting power management
297 * 04 14 2010 jeffrey.chang
298 * [WPD00003826]Initial import for Linux port
299 * pvInformationBuffer and u4InformationBufferLength are no longer in glue
302 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
303 * add framework for BT-over-Wi-Fi support.
304 * * * * * * * * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
305 * * * * * * * * * * * * * * * * * * * * 2) command sequence number is now increased atomically
306 * * * * * * * * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
309 * [WPD00001943]Create WiFi test driver framework on WinXP
310 * rWlanInfo should be placed at adapter rather than glue due to most operations
311 * * * * * * * * * * are done in adapter layer.
313 * 04 06 2010 jeffrey.chang
314 * [WPD00003826]Initial import for Linux port
315 * Tag the packet for QoS on Tx path
317 * 04 06 2010 jeffrey.chang
318 * [WPD00003826]Initial import for Linux port
319 * (1)deliver the kalOidComplete status to upper layer
320 * * (2) fix spin lock
322 * 04 06 2010 jeffrey.chang
323 * [WPD00003826]Initial import for Linux port
324 * add timeout check in the kalOidComplete
326 * 04 06 2010 jeffrey.chang
327 * [WPD00003826]Initial import for Linux port
328 * improve none-glue code portability
331 * [WPD00001943]Create WiFi test driver framework on WinXP
332 * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
335 * [WPD00001943]Create WiFi test driver framework on WinXP
336 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
338 * 03 30 2010 jeffrey.chang
339 * [WPD00003826]Initial import for Linux port
340 * emulate NDIS Pending OID facility
342 * 03 26 2010 jeffrey.chang
343 * [WPD00003826]Initial import for Linux port
344 * [WPD00003826] Initial import for Linux port
345 * adding firmware download related data type
348 * [WPD00001943]Create WiFi test driver framework on WinXP
349 * 1) correct OID_802_11_CONFIGURATION with frequency setting behavior.
350 * * * * the frequency is used for adhoc connection only
351 * * * * 2) update with SD1 v0.9 CMD/EVENT documentation
354 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
355 * add Bluetooth-over-Wifi frame header check
357 * 03 24 2010 jeffrey.chang
358 * [WPD00003826]Initial import for Linux port
359 * initial import for Linux port
360 ** \main\maintrunk.MT5921\30 2009-10-20 17:38:31 GMT mtk01090
361 ** Refine driver unloading and clean up procedure. Block requests, stop main thread and clean up queued requests, and then stop hw.
362 ** \main\maintrunk.MT5921\29 2009-10-08 10:33:33 GMT mtk01090
363 ** Avoid accessing private data of net_device directly. Replace with netdev_priv(). Add more checking for input parameters and pointers.
364 ** \main\maintrunk.MT5921\28 2009-09-28 20:19:26 GMT mtk01090
365 ** Add private ioctl to carry OID structures. Restructure public/private ioctl interfaces to Linux kernel.
366 ** \main\maintrunk.MT5921\27 2009-08-18 22:57:12 GMT mtk01090
367 ** Add Linux SDIO (with mmc core) support.
368 ** Add Linux 2.6.21, 2.6.25, 2.6.26.
369 ** Fix compile warning in Linux.
370 ** \main\maintrunk.MT5921\26 2009-07-06 21:42:25 GMT mtk01088
371 ** fixed the compiling error at linux
372 ** \main\maintrunk.MT5921\25 2009-07-06 20:51:46 GMT mtk01088
373 ** adding the wapi 1x ether type define
374 ** \main\maintrunk.MT5921\24 2009-06-23 23:19:18 GMT mtk01090
375 ** Add build option BUILD_USE_EEPROM and compile option CFG_SUPPORT_EXT_CONFIG for NVRAM support
376 ** \main\maintrunk.MT5921\23 2009-02-07 15:05:06 GMT mtk01088
377 ** add the privacy flag to ingo driver the supplicant selected ap's security
378 ** \main\maintrunk.MT5921\22 2009-02-05 15:34:09 GMT mtk01088
379 ** fixed the compiling error for using bits marco for only one parameter
380 ** \main\maintrunk.MT5921\21 2009-01-22 13:02:13 GMT mtk01088
381 ** data frame is or not 802.1x value share with tid, using the same reserved byte, provide the function to set and get
382 ** \main\maintrunk.MT5921\20 2008-10-24 12:04:16 GMT mtk01088
383 ** move the config.h from precomp.h to here for lint check
384 ** \main\maintrunk.MT5921\19 2008-09-22 23:19:02 GMT mtk01461
385 ** Update driver for code review
386 ** \main\maintrunk.MT5921\18 2008-09-05 17:25:13 GMT mtk01461
387 ** Update Driver for Code Review
388 ** \main\maintrunk.MT5921\17 2008-08-01 13:32:47 GMT mtk01084
389 ** Prevent redundent driver assertion in driver logic when BUS is detached
390 ** \main\maintrunk.MT5921\16 2008-05-30 14:41:43 GMT mtk01461
391 ** Remove WMM Assoc Flag in KAL
392 ** \main\maintrunk.MT5921\15 2008-05-29 14:16:25 GMT mtk01084
393 ** remoev un-used variable
394 ** \main\maintrunk.MT5921\14 2008-05-03 15:17:14 GMT mtk01461
395 ** Add Media Status variable in Glue Layer
396 ** \main\maintrunk.MT5921\13 2008-04-24 11:58:41 GMT mtk01461
397 ** change threshold to 256
398 ** \main\maintrunk.MT5921\12 2008-03-11 14:51:05 GMT mtk01461
399 ** Remove redundant GL_CONN_INFO_T
400 ** \main\maintrunk.MT5921\11 2008-01-07 15:07:41 GMT mtk01461
401 ** Adjust the netif stop threshold to 150
402 ** \main\maintrunk.MT5921\10 2007-11-26 19:43:46 GMT mtk01461
403 ** Add OS_TIMESTAMP macro
405 ** \main\maintrunk.MT5921\9 2007-11-07 18:38:38 GMT mtk01461
407 ** \main\maintrunk.MT5921\8 2007-11-02 01:04:00 GMT mtk01461
408 ** Unify TX Path for Normal and IBSS Power Save + IBSS neighbor learning
409 ** Revision 1.5 2007/07/12 11:04:28 MTK01084
410 ** update macro to delay for ms order
412 ** Revision 1.4 2007/07/05 07:25:34 MTK01461
413 ** Add Linux initial code, modify doc, add 11BB, RF init code
415 ** Revision 1.3 2007/06/27 02:18:51 MTK01461
416 ** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API
418 ** Revision 1.2 2007/06/25 06:16:24 MTK01461
419 ** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API
426 /*******************************************************************************
427 * C O M P I L E R F L A G S
428 ********************************************************************************
430 /*------------------------------------------------------------------------------
431 * Flags for LINUX(OS) dependent
432 *------------------------------------------------------------------------------
434 #define CFG_MAX_WLAN_DEVICES 1 /* number of wlan card will coexist*/
436 #define CFG_MAX_TXQ_NUM 4 /* number of tx queue for support multi-queue h/w */
439 #define CFG_USE_SPIN_LOCK_BOTTOM_HALF 0 /* 1: Enable use of SPIN LOCK Bottom Half for LINUX
440 0: Disable - use SPIN LOCK IRQ SAVE instead */
442 #define CFG_TX_PADDING_SMALL_ETH_PACKET 0 /* 1: Enable - Drop ethernet packet if it < 14 bytes.
443 And pad ethernet packet with dummy 0 if it < 60 bytes.
446 #define CFG_TX_STOP_NETIF_QUEUE_THRESHOLD 256 /* packets */
448 #define CFG_TX_STOP_NETIF_PER_QUEUE_THRESHOLD 64 /* packets */
449 #define CFG_TX_START_NETIF_PER_QUEUE_THRESHOLD 32 /* packets */
452 #define ETH_P_1X 0x888E
453 #define IPTOS_PREC_OFFSET 5
454 #define USER_PRIORITY_DEFAULT 0
456 #define ETH_WPI_1X 0x88B4
459 #define ETH_TYPE_LEN_OFFSET 12
460 #define ETH_P_IP 0x0800
461 #define ETH_P_1X 0x888E
462 #define ETH_P_PRE_1X 0x88C7
465 #define IP_HEADER_LEN 20
467 #define IPVH_VERSION_OFFSET 4 // For Little-Endian
468 #define IPVH_VERSION_MASK 0xF0
469 #define IPTOS_PREC_OFFSET 5
470 #define IPTOS_PREC_MASK 0xE0
472 #define SOURCE_PORT_LEN 2
473 /* NOTE(Kevin): Without IP Option Length */
474 #define LOOK_AHEAD_LEN (ETH_HLEN + IP_HEADER_LEN + SOURCE_PORT_LEN)
477 #define ETH_LLC_OFFSET (ETH_HLEN)
478 #define ETH_LLC_LEN 3
479 #define ETH_LLC_DSAP_SNAP 0xAA
480 #define ETH_LLC_SSAP_SNAP 0xAA
481 #define ETH_LLC_CONTROL_UNNUMBERED_INFORMATION 0x03
484 #define ETH_SNAP_OFFSET (ETH_HLEN + ETH_LLC_LEN)
485 #define ETH_SNAP_LEN 5
486 #define ETH_SNAP_BT_SIG_OUI_0 0x00
487 #define ETH_SNAP_BT_SIG_OUI_1 0x19
488 #define ETH_SNAP_BT_SIG_OUI_2 0x58
490 #define BOW_PROTOCOL_ID_SECURITY_FRAME 0x0003
494 #define CHIP_NAME "MT6620"
495 #elif defined(MT5931)
496 #define CHIP_NAME "MT5931"
497 #elif defined(MT6628)
498 #define CHIP_NAME "MT6628"
501 #define DRV_NAME "["CHIP_NAME"]: "
503 /* Define if target platform is Android.
504 * It should already be defined in Android kernel source
506 #ifndef CONFIG_ANDROID
507 #define CONFIG_ANDROID 0
510 /* for CFG80211 IE buffering mechanism */
511 #define CFG_CFG80211_IE_BUF_LEN (512)
513 /*******************************************************************************
514 * E X T E R N A L R E F E R E N C E S
515 ********************************************************************************
517 #include <linux/version.h> /* constant of kernel version */
519 #include <linux/kernel.h> /* bitops.h */
521 #include <linux/timer.h> /* struct timer_list */
522 #include <linux/jiffies.h> /* jiffies */
523 #include <linux/delay.h> /* udelay and mdelay macro */
526 #include <linux/wakelock.h>
529 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12)
530 #include <linux/irq.h> /* IRQT_FALLING */
531 #include <linux/hardirq.h> /*for in_interrupt*/
534 #include <linux/netdevice.h> /* struct net_device, struct net_device_stats */
535 #include <linux/etherdevice.h> /* for eth_type_trans() function */
536 #include <linux/wireless.h> /* struct iw_statistics */
537 #include <linux/if_arp.h>
538 #include <linux/inetdevice.h> /* struct in_device */
540 #include <linux/ip.h> /* struct iphdr */
542 #include <linux/string.h> /* for memcpy()/memset() function */
543 #include <linux/stddef.h> /* for offsetof() macro */
545 #include <linux/proc_fs.h> /* The proc filesystem constants/structures */
547 #include <linux/rtnetlink.h> /* for rtnl_lock() and rtnl_unlock() */
548 #include <linux/kthread.h> /* kthread_should_stop(), kthread_run() */
549 #include <asm/uaccess.h> /* for copy_from_user() */
550 #include <linux/fs.h> /* for firmware download */
551 #include <linux/vmalloc.h>
553 #include <linux/kfifo.h> /* for kfifo interface */
554 #include <linux/cdev.h> /* for cdev interface */
556 #include <linux/firmware.h> /* for firmware download */
558 #if defined(_HIF_SDIO)
559 #include <linux/mmc/sdio.h>
560 #include <linux/mmc/sdio_func.h>
563 #include <linux/random.h>
565 #include <linux/lockdep.h>
567 #include <asm/io.h> /* readw and writew */
569 #if WIRELESS_EXT > 12
570 #include <net/iw_handler.h>
576 #if CFG_ENABLE_WIFI_DIRECT_CFG_80211
577 #include <linux/wireless.h>
578 #include <net/cfg80211.h>
581 #include <linux/module.h>
583 #include "gl_typedef.h"
587 #if CFG_CHIP_RESET_SUPPORT
595 #include "wlan_lib.h"
596 #include "wlan_oid.h"
598 #if CFG_ENABLE_AEE_MSG
599 #include <linux/aee.h>
602 extern BOOLEAN fgIsBusAccessFailed;
604 /*******************************************************************************
606 ********************************************************************************
608 #define GLUE_FLAG_HALT BIT(0)
609 #define GLUE_FLAG_INT BIT(1)
610 #define GLUE_FLAG_OID BIT(2)
611 #define GLUE_FLAG_TIMEOUT BIT(3)
612 #define GLUE_FLAG_TXREQ BIT(4)
613 #define GLUE_FLAG_SUB_MOD_INIT BIT(5)
614 #define GLUE_FLAG_SUB_MOD_EXIT BIT(6)
615 #define GLUE_FLAG_SUB_MOD_MULTICAST BIT(7)
616 #define GLUE_FLAG_FRAME_FILTER BIT(8)
617 #define GLUE_FLAG_HALT_BIT (0)
618 #define GLUE_FLAG_INT_BIT (1)
619 #define GLUE_FLAG_OID_BIT (2)
620 #define GLUE_FLAG_TIMEOUT_BIT (3)
621 #define GLUE_FLAG_TXREQ_BIT (4)
622 #define GLUE_FLAG_SUB_MOD_INIT_BIT (5)
623 #define GLUE_FLAG_SUB_MOD_EXIT_BIT (6)
624 #define GLUE_FLAG_SUB_MOD_MULTICAST_BIT (7)
625 #define GLUE_FLAG_FRAME_FILTER_BIT (8)
629 #define GLUE_BOW_KFIFO_DEPTH (1024)
630 //#define GLUE_BOW_DEVICE_NAME "MT6620 802.11 AMP"
631 #define GLUE_BOW_DEVICE_NAME "ampc0"
634 /*******************************************************************************
636 ********************************************************************************
638 typedef struct _GL_WPA_INFO_T {
639 UINT_32 u4WpaVersion;
641 UINT_32 u4CipherGroup;
642 UINT_32 u4CipherPairwise;
644 BOOLEAN fgPrivacyInvoke;
645 #if CFG_SUPPORT_802_11W
648 } GL_WPA_INFO_T, *P_GL_WPA_INFO_T;
650 typedef enum _ENUM_RSSI_TRIGGER_TYPE {
651 ENUM_RSSI_TRIGGER_NONE,
652 ENUM_RSSI_TRIGGER_GREATER,
653 ENUM_RSSI_TRIGGER_LESS,
654 ENUM_RSSI_TRIGGER_TRIGGERED,
655 ENUM_RSSI_TRIGGER_NUM
656 } ENUM_RSSI_TRIGGER_TYPE;
658 #if CFG_ENABLE_WIFI_DIRECT
659 typedef enum _ENUM_SUB_MODULE_IDX_T {
662 } ENUM_SUB_MODULE_IDX_T;
664 typedef enum _ENUM_NET_REG_STATE_T {
665 ENUM_NET_REG_STATE_UNREGISTERED,
666 ENUM_NET_REG_STATE_REGISTERING,
667 ENUM_NET_REG_STATE_REGISTERED,
668 ENUM_NET_REG_STATE_UNREGISTERING,
669 ENUM_NET_REG_STATE_NUM
670 } ENUM_NET_REG_STATE_T;
674 typedef struct _GL_IO_REQ_T {
675 QUE_ENTRY_T rQueEntry;
676 //wait_queue_head_t cmdwait_q;
679 #if CFG_ENABLE_WIFI_DIRECT
682 P_ADAPTER_T prAdapter;
683 PFN_OID_HANDLER_FUNC pfnOidHandler;
685 UINT_32 u4InfoBufLen;
686 PUINT_32 pu4QryInfoLen;
689 } GL_IO_REQ_T, *P_GL_IO_REQ_T;
691 #if CFG_ENABLE_BT_OVER_WIFI
692 typedef struct _GL_BOW_INFO {
693 BOOLEAN fgIsRegistered;
694 dev_t u4DeviceNumber; /* dynamic device number */
695 // struct kfifo *prKfifo; /* for buffering indicated events */
696 struct kfifo rKfifo; /* for buffering indicated events */
697 spinlock_t rSpinLock; /* spin lock for kfifo */
699 UINT_32 u4FreqInKHz; /* frequency */
701 UINT_8 aucRole[CFG_BOW_PHYSICAL_LINK_NUM]; /* 0: Responder, 1: Initiator */
702 ENUM_BOW_DEVICE_STATE aeState[CFG_BOW_PHYSICAL_LINK_NUM];
703 PARAM_MAC_ADDRESS arPeerAddr[CFG_BOW_PHYSICAL_LINK_NUM];
705 wait_queue_head_t outq;
707 #if CFG_BOW_SEPARATE_DATA_PATH
709 struct net_device *prDevHandler;
710 BOOLEAN fgIsNetRegistered;
713 } GL_BOW_INFO, *P_GL_BOW_INFO;
717 * type definition of pointer to p2p structure
719 typedef struct _GL_P2P_INFO_T GL_P2P_INFO_T, *P_GL_P2P_INFO_T;
721 struct _GLUE_INFO_T {
723 struct net_device *prDevHandler;
725 /* Device Index(index of arWlanDevInfo[]) */
728 /* Device statistics */
729 struct net_device_stats rNetDevStats;
731 /* Wireless statistics struct net_device */
732 struct iw_statistics rIwStats;
734 /* spinlock to sync power save mechanism */
735 spinlock_t rSpinLock[SPIN_LOCK_NUM];
737 /* semaphore for ioctl */
738 struct semaphore ioctl_sem;
740 UINT_32 u4Flag; /* GLUE_FLAG_XXX */
742 //UINT_32 u4TimeoutFlag;
743 UINT_32 u4OidCompleteFlag;
744 UINT_32 u4ReadyFlag; /* check if card is ready */
746 /* Number of pending frames, also used for debuging if any frame is
747 * missing during the process of unloading Driver.
749 * NOTE(Kevin): In Linux, we also use this variable as the threshold
750 * for manipulating the netif_stop(wake)_queue() func.
752 INT_32 ai4TxPendingFrameNumPerQueue[4][CFG_MAX_TXQ_NUM];
753 INT_32 i4TxPendingFrameNum;
754 INT_32 i4TxPendingSecurityFrameNum;
756 /* current IO request for kalIoctl */
757 GL_IO_REQ_T OidEntry;
763 struct firmware *prFw;
765 /* Host interface related information */
766 /* defined in related hif header file */
767 GL_HIF_INFO_T rHifInfo;
769 /*! \brief wext wpa related information */
770 GL_WPA_INFO_T rWpaInfo;
773 /* Pointer to ADAPTER_T - main data structure of internal protocol stack */
774 P_ADAPTER_T prAdapter;
776 #ifdef WLAN_INCLUDE_PROC
777 struct proc_dir_entry *pProcRoot;
778 #endif /* WLAN_INCLUDE_PROC */
780 /* Indicated media state */
781 ENUM_PARAM_MEDIA_STATE_T eParamMediaStateIndicated;
783 /* Device power state D0~D3 */
784 PARAM_DEVICE_POWER_STATE ePowerState;
786 struct completion rScanComp; /* indicate scan complete */
787 struct completion rHaltComp; /* indicate main thread halt complete */
788 struct completion rPendComp; /* indicate main thread halt complete */
789 #if CFG_ENABLE_WIFI_DIRECT
790 struct completion rSubModComp; /*indicate sub module init or exit complete*/
792 WLAN_STATUS rPendStatus;
799 //PVOID pvInformationBuffer;
800 //UINT_32 u4InformationBufferLength;
802 //PUINT_8 pucIOReqBuff;
804 //QUE_T rFreeIOReqQueue;
806 wait_queue_head_t waitq;
807 struct task_struct *main_thread;
809 struct timer_list tickfn;
812 #if CFG_SUPPORT_EXT_CONFIG
813 UINT_16 au2ExtCfg[256]; /* NVRAM data buffer */
814 UINT_32 u4ExtCfgLength; /* 0 means data is NOT valid */
817 #if 1//CFG_SUPPORT_WAPI
818 /* Should be large than the PARAM_WAPI_ASSOC_INFO_T */
819 UINT_8 aucWapiAssocInfoIEs[42];
820 UINT_16 u2WapiAssocInfoIESz;
823 #if CFG_ENABLE_BT_OVER_WIFI
824 GL_BOW_INFO rBowInfo;
827 #if CFG_ENABLE_WIFI_DIRECT
828 P_GL_P2P_INFO_T prP2PInfo;
829 #if CFG_SUPPORT_P2P_RSSI_QUERY
830 /* Wireless statistics struct net_device */
831 struct iw_statistics rP2pIwStats;
835 UINT_8 aucWSCIE[500]; /*for probe req*/
837 UINT_8 aucWSCAssocInfoIE[200]; /*for Assoc req*/
838 UINT_16 u2WSCAssocInfoIELen;
840 /* NVRAM availability */
841 BOOLEAN fgNvramAvailable;
843 BOOLEAN fgMcrAccessAllowed;
845 /* MAC Address Overriden by IOCTL */
846 BOOLEAN fgIsMacAddrOverride;
847 PARAM_MAC_ADDRESS rMacAddrOverride;
849 SET_TXPWR_CTRL_T rTxPwr;
851 /* for cfg80211 scan done indication */
852 struct cfg80211_scan_request *prScanRequest;
854 /* to indicate registered or not */
855 BOOLEAN fgIsRegistered;
857 /* for cfg80211 connected indication */
858 UINT_32 u4RspIeLength;
859 UINT_8 aucRspIe[CFG_CFG80211_IE_BUF_LEN];
861 UINT_32 u4ReqIeLength;
862 UINT_8 aucReqIe[CFG_CFG80211_IE_BUF_LEN];
865 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
867 typedef void (*PFN_WLANISR)(int irq, void *dev_id, struct pt_regs *regs);
869 typedef irqreturn_t (*PFN_WLANISR)(int irq, void *dev_id, struct pt_regs *regs);
872 typedef void (*PFN_LINUX_TIMER_FUNC)(unsigned long);
875 /* generic sub module init/exit handler
876 * now, we only have one sub module, p2p
878 #if CFG_ENABLE_WIFI_DIRECT
879 typedef BOOLEAN (*SUB_MODULE_INIT)(P_GLUE_INFO_T prGlueInfo);
880 typedef BOOLEAN (*SUB_MODULE_EXIT)(P_GLUE_INFO_T prGlueInfo);
882 typedef struct _SUB_MODULE_HANDLER {
883 SUB_MODULE_INIT subModInit;
884 SUB_MODULE_EXIT subModExit;
886 } SUB_MODULE_HANDLER, *P_SUB_MODULE_HANDLER;
890 #if CONFIG_NL80211_TESTMODE
892 typedef struct _NL80211_DRIVER_TEST_MODE_PARAMS {
895 } NL80211_DRIVER_TEST_MODE_PARAMS, *P_NL80211_DRIVER_TEST_MODE_PARAMS;
898 typedef struct _NL80211_DRIVER_SW_CMD_PARAMS {
899 NL80211_DRIVER_TEST_MODE_PARAMS hdr;
903 }NL80211_DRIVER_SW_CMD_PARAMS, *P_NL80211_DRIVER_SW_CMD_PARAMS;
905 struct iw_encode_exts {
906 __u32 ext_flags; /*!< IW_ENCODE_EXT_* */
907 __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /*!< LSB first */
908 __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /*!< LSB first */
909 __u8 addr[MAC_ADDR_LEN]; /*!< ff:ff:ff:ff:ff:ff for broadcast/multicast
910 * (group) keys or unicast address for
912 __u16 alg; /*!< IW_ENCODE_ALG_* */
918 typedef struct _NL80211_DRIVER_SET_KEY_EXTS {
919 NL80211_DRIVER_TEST_MODE_PARAMS hdr;
922 struct iw_encode_exts ext;
923 }NL80211_DRIVER_SET_KEY_EXTS, *P_NL80211_DRIVER_SET_KEY_EXTS;
928 /*******************************************************************************
929 * P U B L I C D A T A
930 ********************************************************************************
933 /*******************************************************************************
934 * P R I V A T E D A T A
935 ********************************************************************************
938 /*******************************************************************************
940 ********************************************************************************
942 /*----------------------------------------------------------------------------*/
943 /* Macros of SPIN LOCK operations for using in Glue Layer */
944 /*----------------------------------------------------------------------------*/
945 #if CFG_USE_SPIN_LOCK_BOTTOM_HALF
946 #define GLUE_SPIN_LOCK_DECLARATION()
947 #define GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, rLockCategory) \
949 if (rLockCategory < SPIN_LOCK_NUM) \
950 spin_lock_bh(&(prGlueInfo->rSpinLock[rLockCategory])); \
952 #define GLUE_RELEASE_SPIN_LOCK(prGlueInfo, rLockCategory) \
954 if (rLockCategory < SPIN_LOCK_NUM) \
955 spin_unlock_bh(&(prGlueInfo->rSpinLock[rLockCategory])); \
957 #else /* !CFG_USE_SPIN_LOCK_BOTTOM_HALF */
958 #define GLUE_SPIN_LOCK_DECLARATION() UINT_32 __u4Flags = 0
959 #define GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, rLockCategory) \
961 if (rLockCategory < SPIN_LOCK_NUM) \
962 spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \
964 #define GLUE_RELEASE_SPIN_LOCK(prGlueInfo, rLockCategory) \
966 if (rLockCategory < SPIN_LOCK_NUM) \
967 spin_unlock_irqrestore(&(prGlueInfo->rSpinLock[rLockCategory]), __u4Flags); \
969 #endif /* !CFG_USE_SPIN_LOCK_BOTTOM_HALF */
972 /*----------------------------------------------------------------------------*/
973 /* Macros for accessing Reserved Fields of native packet */
974 /*----------------------------------------------------------------------------*/
975 #define GLUE_GET_PKT_QUEUE_ENTRY(_p) \
976 (&( ((struct sk_buff *)(_p))->cb[0] ))
978 #define GLUE_GET_PKT_DESCRIPTOR(_prQueueEntry) \
979 ((P_NATIVE_PACKET) ((UINT_32)_prQueueEntry - offsetof(struct sk_buff, cb[0])) )
981 #define GLUE_SET_PKT_FLAG_802_11(_p) \
982 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(7))
984 #define GLUE_SET_PKT_FLAG_1X(_p) \
985 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(6))
987 #define GLUE_SET_PKT_FLAG_PAL(_p) \
988 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(5))
990 #define GLUE_SET_PKT_FLAG_P2P(_p) \
991 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(4))
995 #define GLUE_SET_PKT_TID(_p, _tid) \
996 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= (((UINT_8)((_tid) & (BITS(0,3))))))
999 #define GLUE_SET_PKT_FRAME_LEN(_p, _u2PayloadLen) \
1000 (*((PUINT_16) &( ((struct sk_buff *)(_p))->cb[6] )) = (UINT_16)(_u2PayloadLen))
1002 #define GLUE_GET_PKT_FRAME_LEN(_p) \
1003 (*((PUINT_16) &( ((struct sk_buff *)(_p))->cb[6] )) )
1006 #define GLUE_GET_PKT_IS_802_11(_p) \
1007 ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(7)))
1009 #define GLUE_GET_PKT_IS_1X(_p) \
1010 ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(6)))
1012 #define GLUE_GET_PKT_TID(_p) \
1013 ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BITS(0,3)))
1016 #define GLUE_GET_PKT_IS_PAL(_p) \
1017 ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(5)))
1019 #define GLUE_GET_PKT_IS_P2P(_p) \
1020 ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(4)))
1023 #define GLUE_SET_PKT_HEADER_LEN(_p, _ucMacHeaderLen) \
1024 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[5] )) = (UINT_8)(_ucMacHeaderLen))
1026 #define GLUE_GET_PKT_HEADER_LEN(_p) \
1027 (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[5] )) )
1029 #define GLUE_SET_PKT_ARRIVAL_TIME(_p, _rSysTime) \
1030 (*((POS_SYSTIME) &( ((struct sk_buff *)(_p))->cb[8] )) = (OS_SYSTIME)(_rSysTime))
1032 #define GLUE_GET_PKT_ARRIVAL_TIME(_p) \
1033 (*((POS_SYSTIME) &( ((struct sk_buff *)(_p))->cb[8] )) )
1035 /* Check validity of prDev, private data, and pointers */
1036 #define GLUE_CHK_DEV(prDev) \
1037 ((prDev && *((P_GLUE_INFO_T *) netdev_priv(prDev))) ? TRUE : FALSE)
1039 #define GLUE_CHK_PR2(prDev, pr2) \
1040 ((GLUE_CHK_DEV(prDev) && pr2) ? TRUE : FALSE)
1042 #define GLUE_CHK_PR3(prDev, pr2, pr3) \
1043 ((GLUE_CHK_PR2(prDev, pr2) && pr3) ? TRUE : FALSE)
1045 #define GLUE_CHK_PR4(prDev, pr2, pr3, pr4) \
1046 ((GLUE_CHK_PR3(prDev, pr2, pr3) && pr4) ? TRUE : FALSE)
1048 #define GLUE_SET_EVENT(pr) \
1051 #define GLUE_INC_REF_CNT(_refCount) atomic_inc((atomic_t *)&(_refCount))
1052 #define GLUE_DEC_REF_CNT(_refCount) atomic_dec((atomic_t *)&(_refCount))
1055 #define DbgPrint(...)
1056 /*******************************************************************************
1057 * F U N C T I O N D E C L A R A T I O N S
1058 ********************************************************************************
1060 #ifdef WLAN_INCLUDE_PROC
1063 struct net_device *prDev,
1069 struct net_device *prDev,
1072 #endif /* WLAN_INCLUDE_PROC */
1074 #if CFG_ENABLE_BT_OVER_WIFI
1077 P_GLUE_INFO_T prGlueInfo
1082 P_GLUE_INFO_T prGlueInfo
1086 #if CFG_ENABLE_WIFI_DIRECT
1090 P_GLUE_INFO_T prGlueInfo
1095 P_GLUE_INFO_T prGlueInfo
1100 P_GLUE_INFO_T prGlueInfo
1105 P_GLUE_INFO_T prGlueInfo
1109 wlanSubModRegisterInitExit(
1110 SUB_MODULE_INIT rSubModInit,
1111 SUB_MODULE_EXIT rSubModExit,
1112 ENUM_SUB_MODULE_IDX_T eSubModIdx
1117 P_GLUE_INFO_T *prGlueInfoExpAddr
1126 p2pSetMulticastListWorkQueueWrapper(
1127 P_GLUE_INFO_T prGlueInfo
1134 /*******************************************************************************
1136 ********************************************************************************
1139 #endif /* _GL_OS_H */