support different wifi bt chip auto compatible
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / mt5931_kk / drv_wlan / os / linux / include / gl_os.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT662X_593X_WIFI_DRIVER_V2_3/os/linux/include/gl_os.h#1 $
3 */
4
5 /*! \file   gl_os.h
6     \brief  List the external reference to OS for GLUE Layer.
7
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
11     also list down here.
12 */
13
14 /*******************************************************************************
15 * Copyright (c) 2007 MediaTek Inc.
16 *
17 * All rights reserved. Copying, compilation, modification, distribution
18 * or any other use whatsoever of this material is strictly prohibited
19 * except in accordance with a Software License Agreement with
20 * MediaTek Inc.
21 ********************************************************************************
22 */
23
24 /*******************************************************************************
25 * LEGAL DISCLAIMER
26 *
27 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
28 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
29 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
30 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
31 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
32 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
33 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
34 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
35 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
36 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
37 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
38 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
39 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
40 *
41 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
42 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
43 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
44 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
45 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
46 *
47 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
48 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
49 * OF LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
50 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
51 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
52 * (ICC).
53 ********************************************************************************
54 */
55
56 /*
57 ** $Log: gl_os.h $
58 ** 
59 ** 08 24 2012 cp.wu
60 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
61 ** .
62 ** 
63 ** 08 20 2012 yuche.tsai
64 ** NULL
65 ** Try to fix frame register KE issue.
66  *
67  * 04 12 2012 terry.wu
68  * NULL
69  * Add AEE message support
70  * 1) Show AEE warning(red screen) if SDIO access error occurs
71
72  *
73  * 03 02 2012 terry.wu
74  * NULL
75  * Enable CFG80211 Support.
76  *
77  * 01 05 2012 wh.su
78  * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
79  * Adding the related ioctl / wlan oid function to set the Tx power cfg.
80  *
81  * 12 13 2011 cm.chang
82  * [WCXRP00001136] [All Wi-Fi][Driver] Add wake lock for pending timer
83  * Add wake lock if timer timeout value is smaller than 5 seconds
84  *
85  * 11 18 2011 yuche.tsai
86  * NULL
87  * CONFIG P2P support RSSI query, default turned off.
88  *
89  * 11 16 2011 yuche.tsai
90  * NULL
91  * Avoid using work thread.
92  *
93  * 11 11 2011 yuche.tsai
94  * NULL
95  * Fix work thread cancel issue.
96  *
97  * 10 12 2011 wh.su
98  * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
99  * adding the 802.11w related function and define .
100  *
101  * 09 29 2011 terry.wu
102  * NULL
103  * Show DRV_NAME by chip id.
104  *
105  * 04 18 2011 terry.wu
106  * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
107  * Remove flag CFG_WIFI_DIRECT_MOVED.
108  *
109  * 03 29 2011 cp.wu
110  * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events
111  * implement kernel-to-userspace communication via generic netlink socket for whole-chip resetting mechanism
112  *
113  * 03 21 2011 cp.wu
114  * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
115  * portability improvement
116  *
117  * 03 17 2011 chinglan.wang
118  * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
119  * .
120  *
121  * 03 03 2011 jeffrey.chang
122  * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
123  * support concurrent network
124  *
125  * 03 03 2011 jeffrey.chang
126  * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
127  * modify net device relative functions to support multiple H/W queues
128  *
129  * 03 02 2011 wh.su
130  * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
131  * Add security check code.
132  *
133  * 02 21 2011 cp.wu
134  * [WCXRP00000482] [MT6620 Wi-Fi][Driver] Simplify logic for checking NVRAM existence in driver domain
135  * simplify logic for checking NVRAM existence only once.
136  *
137  * 02 16 2011 jeffrey.chang
138  * NULL
139  * Add query ipv4 and ipv6 address during early suspend and late resume
140  *
141  * 02 10 2011 chinghwa.yu
142  * [WCXRP00000065] Update BoW design and settings
143  * Fix kernel API change issue.
144  * Before ALPS 2.2 (2.2 included), kfifo_alloc() is
145  * struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock);
146  * After ALPS 2.3, kfifo_alloc() is changed to
147  * int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask);
148  *
149  * 02 09 2011 wh.su
150  * [WCXRP00000433] [MT6620 Wi-Fi][Driver] Remove WAPI structure define for avoid P2P module with structure miss-align pointer issue
151  * always pre-allio WAPI related structure for align p2p module.
152  *
153  * 02 09 2011 terry.wu
154  * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
155  * Halt p2p module init and exit until TxThread finished p2p register and unregister.
156  *
157  * 02 01 2011 cm.chang
158  * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
159  * .
160  *
161  * 01 27 2011 cm.chang
162  * [WCXRP00000402] [MT6620 Wi-Fi][Driver] Enable MCR read/write by iwpriv by default
163  * .
164  *
165  * 01 12 2011 cp.wu
166  * [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP
167  * implementation of separate BT_OVER_WIFI data path.
168  *
169  * 01 12 2011 cp.wu
170  * [WCXRP00000356] [MT6620 Wi-Fi][Driver] fill mac header length for security frames 'cause hardware header translation needs such information
171  * fill mac header length information for 802.1x frames.
172  *
173  * 01 11 2011 chinglan.wang
174  * NULL
175  * Modify to reslove the CR :[ALPS00028994] Use WEP security to connect Marvell 11N AP.  Connection establish successfully.
176  * Use the WPS function to connect AP, the privacy bit always is set to 1.
177  *
178  * 01 10 2011 cp.wu
179  * [WCXRP00000349] [MT6620 Wi-Fi][Driver] make kalIoctl() of linux port as a thread safe API to avoid potential issues due to multiple access
180  * use mutex to protect kalIoctl() for thread safe.
181  *
182  * 01 05 2011 cp.wu
183  * [WCXRP00000283] [MT6620 Wi-Fi][Driver][Wi-Fi Direct] Implementation of interface for supporting Wi-Fi Direct Service Discovery
184  * ioctl implementations for P2P Service Discovery
185  *
186  * 11 04 2010 wh.su
187  * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
188  * adding the p2p random ssid support.
189  *
190  * 10 18 2010 cp.wu
191  * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
192  * complete implementation of Android NVRAM access
193  *
194  * 09 28 2010 wh.su
195  * NULL
196  * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
197  *
198  * 09 23 2010 cp.wu
199  * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
200  * add skeleton for NVRAM integration
201  *
202  * 09 13 2010 cp.wu
203  * NULL
204  * add waitq for poll() and read().
205  *
206  * 09 07 2010 wh.su
207  * NULL
208  * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
209  *
210  * 09 06 2010 wh.su
211  * NULL
212  * let the p2p can set the privacy bit at beacon and rsn ie at assoc req at key handshake state.
213  *
214  * 09 03 2010 kevin.huang
215  * NULL
216  * Refine #include sequence and solve recursive/nested #include issue
217  *
218  * 09 01 2010 wh.su
219  * NULL
220  * adding the wapi support for integration test.
221  *
222  * 08 31 2010 kevin.huang
223  * NULL
224  * Use LINK LIST operation to process SCAN result
225  *
226  * 08 23 2010 cp.wu
227  * NULL
228  * revise constant definitions to be matched with implementation (original cmd-event definition is deprecated)
229  *
230  * 08 16 2010 cp.wu
231  * NULL
232  * P2P packets are now marked when being queued into driver, and identified later without checking MAC address
233  *
234  * 08 16 2010 cp.wu
235  * NULL
236  * revised implementation of Wi-Fi Direct io controls.
237  *
238  * 08 11 2010 cp.wu
239  * NULL
240  * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
241  * 2) extending scanning result to 64 instead of 48
242  *
243  * 08 06 2010 cp.wu
244  * NULL
245  * driver hook modifications corresponding to ioctl interface change.
246  *
247  * 08 03 2010 cp.wu
248  * NULL
249  * [Wi-Fi Direct] add framework for driver hooks
250  *
251  * 08 02 2010 jeffrey.chang
252  * NULL
253  * 1) modify tx service thread to avoid busy looping
254  * 2) add spin lock declartion for linux build
255  *
256  * 07 23 2010 jeffrey.chang
257  *
258  * add new KAL api
259  *
260  * 07 22 2010 jeffrey.chang
261  *
262  * modify tx thread and remove some spinlock
263  *
264  * 07 19 2010 jeffrey.chang
265  *
266  * add security frame pending count
267  *
268  * 07 08 2010 cp.wu
269  *
270  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
271  *
272  * 06 06 2010 kevin.huang
273  * [WPD00003832][MT6620 5931] Create driver base
274  * [MT6620 5931] Create driver base
275  *
276  * 06 01 2010 cp.wu
277  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
278  * add ioctl to configure scan mode for p2p connection
279  *
280  * 05 31 2010 cp.wu
281  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
282  * add cfg80211 interface, which is to replace WE, for further extension
283  *
284  * 05 14 2010 cp.wu
285  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
286  * add ioctl framework for Wi-Fi Direct by reusing wireless extension ioctls as well
287  *
288  * 05 11 2010 cp.wu
289  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
290  * p2p ioctls revised.
291  *
292  * 05 11 2010 cp.wu
293  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
294  * add ioctl for controlling p2p scan phase parameters
295  *
296  * 05 10 2010 cp.wu
297  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
298  * implement basic wi-fi direct framework
299  *
300  * 05 07 2010 jeffrey.chang
301  * [WPD00003826]Initial import for Linux port
302  * prevent supplicant accessing driver during resume
303  *
304  * 05 07 2010 cp.wu
305  * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
306  * add basic framework for implementating P2P driver hook.
307  *
308  * 05 05 2010 cp.wu
309  * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
310  * change variable names for multiple physical link to match with coding convention
311  *
312  * 04 27 2010 cp.wu
313  * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
314  * identify BT Over Wi-Fi Security frame and mark it as 802.1X frame
315  *
316  * 04 27 2010 cp.wu
317  * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
318  * add multiple physical link support
319  *
320  * 04 27 2010 jeffrey.chang
321  * [WPD00003826]Initial import for Linux port
322  * 1) fix firmware download bug
323  * 2) remove query statistics for acelerating firmware download
324  *
325  * 04 27 2010 jeffrey.chang
326  * [WPD00003826]Initial import for Linux port
327  * follow Linux's firmware framework, and remove unused kal API
328  *
329  * 04 23 2010 cp.wu
330  * [WPD00001943]Create WiFi test driver framework on WinXP
331  * surpress compiler warning
332  *
333  * 04 19 2010 jeffrey.chang
334  * [WPD00003826]Initial import for Linux port
335  * supporting power management
336  *
337  * 04 14 2010 jeffrey.chang
338  * [WPD00003826]Initial import for Linux port
339  * pvInformationBuffer and u4InformationBufferLength are no longer in glue
340  *
341  * 04 13 2010 cp.wu
342  * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
343  * add framework for BT-over-Wi-Fi support.
344  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
345  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 2) command sequence number is now increased atomically
346  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 3) private data could be hold and taken use for other purpose
347  *
348  * 04 07 2010 cp.wu
349  * [WPD00001943]Create WiFi test driver framework on WinXP
350  * rWlanInfo should be placed at adapter rather than glue due to most operations
351  *  *  *  *  *  *  *  *  *  * are done in adapter layer.
352  *
353  * 04 06 2010 jeffrey.chang
354  * [WPD00003826]Initial import for Linux port
355  * Tag the packet for QoS on Tx path
356  *
357  * 04 06 2010 jeffrey.chang
358  * [WPD00003826]Initial import for Linux port
359  * (1)deliver the kalOidComplete status to upper layer
360  *  * (2) fix spin lock
361  *
362  * 04 06 2010 jeffrey.chang
363  * [WPD00003826]Initial import for Linux port
364  * add timeout check in the kalOidComplete
365  *
366  * 04 06 2010 jeffrey.chang
367  * [WPD00003826]Initial import for Linux port
368  * improve none-glue code portability
369  *
370  * 04 06 2010 cp.wu
371  * [WPD00001943]Create WiFi test driver framework on WinXP
372  * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
373  *
374  * 04 06 2010 cp.wu
375  * [WPD00001943]Create WiFi test driver framework on WinXP
376  * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
377  *
378  * 03 30 2010 jeffrey.chang
379  * [WPD00003826]Initial import for Linux port
380  * emulate NDIS Pending OID facility
381  *
382  * 03 26 2010 jeffrey.chang
383  * [WPD00003826]Initial import for Linux port
384  * [WPD00003826] Initial import for Linux port
385  * adding firmware download related data type
386  *
387  * 03 25 2010 cp.wu
388  * [WPD00001943]Create WiFi test driver framework on WinXP
389  * 1) correct OID_802_11_CONFIGURATION with frequency setting behavior.
390  *  *  *  * the frequency is used for adhoc connection only
391  *  *  *  * 2) update with SD1 v0.9 CMD/EVENT documentation
392  *
393  * 03 25 2010 cp.wu
394  * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
395  * add Bluetooth-over-Wifi frame header check
396  *
397  * 03 24 2010 jeffrey.chang
398  * [WPD00003826]Initial import for Linux port
399  * initial import for Linux port
400 **  \main\maintrunk.MT5921\30 2009-10-20 17:38:31 GMT mtk01090
401 **  Refine driver unloading and clean up procedure. Block requests, stop main thread and clean up queued requests, and then stop hw.
402 **  \main\maintrunk.MT5921\29 2009-10-08 10:33:33 GMT mtk01090
403 **  Avoid accessing private data of net_device directly. Replace with netdev_priv(). Add more checking for input parameters and pointers.
404 **  \main\maintrunk.MT5921\28 2009-09-28 20:19:26 GMT mtk01090
405 **  Add private ioctl to carry OID structures. Restructure public/private ioctl interfaces to Linux kernel.
406 **  \main\maintrunk.MT5921\27 2009-08-18 22:57:12 GMT mtk01090
407 **  Add Linux SDIO (with mmc core) support.
408 **  Add Linux 2.6.21, 2.6.25, 2.6.26.
409 **  Fix compile warning in Linux.
410 **  \main\maintrunk.MT5921\26 2009-07-06 21:42:25 GMT mtk01088
411 **  fixed the compiling error at linux
412 **  \main\maintrunk.MT5921\25 2009-07-06 20:51:46 GMT mtk01088
413 **  adding the wapi 1x ether type define
414 **  \main\maintrunk.MT5921\24 2009-06-23 23:19:18 GMT mtk01090
415 **  Add build option BUILD_USE_EEPROM and compile option CFG_SUPPORT_EXT_CONFIG for NVRAM support
416 **  \main\maintrunk.MT5921\23 2009-02-07 15:05:06 GMT mtk01088
417 **  add the privacy flag to ingo driver the supplicant selected ap's security
418 **  \main\maintrunk.MT5921\22 2009-02-05 15:34:09 GMT mtk01088
419 **  fixed the compiling error for using bits marco for only one parameter
420 **  \main\maintrunk.MT5921\21 2009-01-22 13:02:13 GMT mtk01088
421 **  data frame is or not 802.1x value share with tid, using the same reserved byte, provide the function to set and get
422 **  \main\maintrunk.MT5921\20 2008-10-24 12:04:16 GMT mtk01088
423 **  move the config.h from precomp.h to here for lint check
424 **  \main\maintrunk.MT5921\19 2008-09-22 23:19:02 GMT mtk01461
425 **  Update driver for code review
426 **  \main\maintrunk.MT5921\18 2008-09-05 17:25:13 GMT mtk01461
427 **  Update Driver for Code Review
428 **  \main\maintrunk.MT5921\17 2008-08-01 13:32:47 GMT mtk01084
429 **  Prevent redundent driver assertion in driver logic when BUS is detached
430 **  \main\maintrunk.MT5921\16 2008-05-30 14:41:43 GMT mtk01461
431 **  Remove WMM Assoc Flag in KAL
432 **  \main\maintrunk.MT5921\15 2008-05-29 14:16:25 GMT mtk01084
433 **  remoev un-used variable
434 **  \main\maintrunk.MT5921\14 2008-05-03 15:17:14 GMT mtk01461
435 **  Add Media Status variable in Glue Layer
436 **  \main\maintrunk.MT5921\13 2008-04-24 11:58:41 GMT mtk01461
437 **  change threshold to 256
438 **  \main\maintrunk.MT5921\12 2008-03-11 14:51:05 GMT mtk01461
439 **  Remove redundant GL_CONN_INFO_T
440 **  \main\maintrunk.MT5921\11 2008-01-07 15:07:41 GMT mtk01461
441 **  Adjust the netif stop threshold to 150
442 **  \main\maintrunk.MT5921\10 2007-11-26 19:43:46 GMT mtk01461
443 **  Add OS_TIMESTAMP macro
444 **
445 **  \main\maintrunk.MT5921\9 2007-11-07 18:38:38 GMT mtk01461
446 **  Move definition
447 **  \main\maintrunk.MT5921\8 2007-11-02 01:04:00 GMT mtk01461
448 **  Unify TX Path for Normal and IBSS Power Save + IBSS neighbor learning
449 ** Revision 1.5  2007/07/12 11:04:28  MTK01084
450 ** update macro to delay for ms order
451 **
452 ** Revision 1.4  2007/07/05 07:25:34  MTK01461
453 ** Add Linux initial code, modify doc, add 11BB, RF init code
454 **
455 ** Revision 1.3  2007/06/27 02:18:51  MTK01461
456 ** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API
457 **
458 ** Revision 1.2  2007/06/25 06:16:24  MTK01461
459 ** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API
460 **
461 */
462
463 #ifndef _GL_OS_H
464 #define _GL_OS_H
465
466 /*******************************************************************************
467 *                         C O M P I L E R   F L A G S
468 ********************************************************************************
469 */
470 /*------------------------------------------------------------------------------
471  * Flags for LINUX(OS) dependent
472  *------------------------------------------------------------------------------
473  */
474 #define CFG_MAX_WLAN_DEVICES                1 /* number of wlan card will coexist*/
475
476 #define CFG_MAX_TXQ_NUM                     4 /* number of tx queue for support multi-queue h/w  */
477
478
479 #define CFG_USE_SPIN_LOCK_BOTTOM_HALF       0 /* 1: Enable use of SPIN LOCK Bottom Half for LINUX
480                                                  0: Disable - use SPIN LOCK IRQ SAVE instead */
481
482 #define CFG_TX_PADDING_SMALL_ETH_PACKET     0 /* 1: Enable - Drop ethernet packet if it < 14 bytes.
483                                                              And pad ethernet packet with dummy 0 if it < 60 bytes.
484                                                  0: Disable */
485
486 #define CFG_TX_STOP_NETIF_QUEUE_THRESHOLD   256 /* packets */
487
488 #define CFG_TX_STOP_NETIF_PER_QUEUE_THRESHOLD   256  /* packets */
489 #define CFG_TX_START_NETIF_PER_QUEUE_THRESHOLD  128  /* packets */
490
491
492 #define ETH_P_1X                            0x888E
493 #define IPTOS_PREC_OFFSET                   5
494 #define USER_PRIORITY_DEFAULT               0
495
496 #define ETH_WPI_1X                         0x88B4
497
498 #define ETH_HLEN                                14
499 #define ETH_TYPE_LEN_OFFSET                     12
500 #define ETH_P_IP                                0x0800
501 #define ETH_P_1X                                0x888E
502 #define ETH_P_PRE_1X                            0x88C7
503
504 #define IPVERSION                               4
505 #define IP_HEADER_LEN                           20
506
507 #define IPVH_VERSION_OFFSET                     4 // For Little-Endian
508 #define IPVH_VERSION_MASK                       0xF0
509 #define IPTOS_PREC_OFFSET                       5
510 #define IPTOS_PREC_MASK                         0xE0
511
512 #define SOURCE_PORT_LEN                         2
513 /* NOTE(Kevin): Without IP Option Length */
514 #define LOOK_AHEAD_LEN                          (ETH_HLEN + IP_HEADER_LEN + SOURCE_PORT_LEN)
515
516 /* 802.2 LLC/SNAP */
517 #define ETH_LLC_OFFSET                          (ETH_HLEN)
518 #define ETH_LLC_LEN                             3
519 #define ETH_LLC_DSAP_SNAP                       0xAA
520 #define ETH_LLC_SSAP_SNAP                       0xAA
521 #define ETH_LLC_CONTROL_UNNUMBERED_INFORMATION  0x03
522
523 /* Bluetooth SNAP */
524 #define ETH_SNAP_OFFSET                         (ETH_HLEN + ETH_LLC_LEN)
525 #define ETH_SNAP_LEN                            5
526 #define ETH_SNAP_BT_SIG_OUI_0                   0x00
527 #define ETH_SNAP_BT_SIG_OUI_1                   0x19
528 #define ETH_SNAP_BT_SIG_OUI_2                   0x58
529
530 #define BOW_PROTOCOL_ID_SECURITY_FRAME          0x0003
531
532
533 #if defined(MT6620)
534     #define CHIP_NAME    "MT6620"
535 #elif defined(MT5931)
536     #define CHIP_NAME    "MT5931"
537 #elif defined(MT6628)
538     #define CHIP_NAME    "MT6628"
539 #endif
540
541 #define DRV_NAME "["CHIP_NAME"]: "
542
543 /* Define if target platform is Android.
544  * It should already be defined in Android kernel source
545  */
546 #ifndef CONFIG_ANDROID
547 #define CONFIG_ANDROID      0
548 #endif
549
550 /* for CFG80211 IE buffering mechanism */
551 #define CFG_CFG80211_IE_BUF_LEN     (512)
552
553 /*******************************************************************************
554 *                    E X T E R N A L   R E F E R E N C E S
555 ********************************************************************************
556 */
557 #include <linux/version.h>      /* constant of kernel version */
558
559 #include <linux/kernel.h>       /* bitops.h */
560
561 #include <linux/timer.h>        /* struct timer_list */
562 #include <linux/jiffies.h>      /* jiffies */
563 #include <linux/delay.h>        /* udelay and mdelay macro */
564
565 #if CONFIG_ANDROID
566 #include <linux/wakelock.h>
567 #endif
568
569 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12)
570 #include <linux/irq.h>          /* IRQT_FALLING */
571 #endif
572
573 #include <linux/netdevice.h>    /* struct net_device, struct net_device_stats */
574 #include <linux/etherdevice.h>  /* for eth_type_trans() function */
575 #include <linux/wireless.h>     /* struct iw_statistics */
576 #include <linux/if_arp.h>
577 #include <linux/inetdevice.h>   /* struct in_device */
578
579 #include <linux/ip.h>           /* struct iphdr */
580
581 #include <linux/string.h>       /* for memcpy()/memset() function */
582 #include <linux/stddef.h>       /* for offsetof() macro */
583
584 #include <linux/proc_fs.h>      /* The proc filesystem constants/structures */
585
586 #include <linux/rtnetlink.h>    /* for rtnl_lock() and rtnl_unlock() */
587 #include <linux/kthread.h>      /* kthread_should_stop(), kthread_run() */
588 #include <asm/uaccess.h>        /* for copy_from_user() */
589 #include <linux/fs.h>           /* for firmware download */
590 #include <linux/vmalloc.h>
591
592 #include <linux/kfifo.h>        /* for kfifo interface */
593 #include <linux/cdev.h>         /* for cdev interface */
594
595 #include <linux/firmware.h>     /* for firmware download */
596
597 #if defined(_HIF_SDIO)
598 #include <linux/mmc/sdio.h>
599 #include <linux/mmc/sdio_func.h>
600 #endif
601
602 #include <linux/random.h>
603
604 #include <linux/lockdep.h>
605
606 #include <asm/io.h>             /* readw and writew */
607
608 #if WIRELESS_EXT > 12
609 #include <net/iw_handler.h>
610 #endif
611
612 #include "version.h"
613 #include "config.h"
614
615 #if CFG_ENABLE_WIFI_DIRECT_CFG_80211
616 #include <linux/wireless.h>
617 #include <net/cfg80211.h>
618 #endif
619
620 #include <linux/module.h>
621
622 #include "gl_typedef.h"
623 #include "typedef.h"
624 #include "queue.h"
625 #include "gl_kal.h"
626 #if CFG_CHIP_RESET_SUPPORT
627     #include "gl_rst.h"
628 #endif
629 #include "hif.h"
630
631
632 #include "debug.h"
633
634 #include "wlan_lib.h"
635 #include "wlan_oid.h"
636
637 #if CFG_ENABLE_AEE_MSG
638 #include <linux/aee.h>
639 #endif
640
641 extern BOOLEAN fgIsBusAccessFailed;
642
643 /*******************************************************************************
644 *                              C O N S T A N T S
645 ********************************************************************************
646 */
647 #define GLUE_FLAG_HALT          BIT(0)
648 #define GLUE_FLAG_INT           BIT(1)
649 #define GLUE_FLAG_OID           BIT(2)
650 #define GLUE_FLAG_TIMEOUT       BIT(3)
651 #define GLUE_FLAG_TXREQ         BIT(4)
652 #define GLUE_FLAG_SUB_MOD_INIT  BIT(5)
653 #define GLUE_FLAG_SUB_MOD_EXIT  BIT(6)
654 #define GLUE_FLAG_SUB_MOD_MULTICAST  BIT(7)
655 #define GLUE_FLAG_FRAME_FILTER      BIT(8)
656 #define GLUE_FLAG_HALT_BIT          (0)
657 #define GLUE_FLAG_INT_BIT           (1)
658 #define GLUE_FLAG_OID_BIT           (2)
659 #define GLUE_FLAG_TIMEOUT_BIT       (3)
660 #define GLUE_FLAG_TXREQ_BIT         (4)
661 #define GLUE_FLAG_SUB_MOD_INIT_BIT  (5)
662 #define GLUE_FLAG_SUB_MOD_EXIT_BIT  (6)
663 #define GLUE_FLAG_SUB_MOD_MULTICAST_BIT  (7)
664 #define GLUE_FLAG_FRAME_FILTER_BIT  (8)
665
666
667
668 #define GLUE_BOW_KFIFO_DEPTH        (1024)
669 //#define GLUE_BOW_DEVICE_NAME        "MT6620 802.11 AMP"
670 #define GLUE_BOW_DEVICE_NAME        "ampc0"
671
672
673 /*******************************************************************************
674 *                             D A T A   T Y P E S
675 ********************************************************************************
676 */
677 typedef struct _GL_WPA_INFO_T {
678     UINT_32 u4WpaVersion;
679     UINT_32 u4KeyMgmt;
680     UINT_32 u4CipherGroup;
681     UINT_32 u4CipherPairwise;
682     UINT_32 u4AuthAlg;
683     BOOLEAN fgPrivacyInvoke;
684 #if CFG_SUPPORT_802_11W
685     UINT_32 u4Mfp;
686 #endif
687 } GL_WPA_INFO_T, *P_GL_WPA_INFO_T;
688
689 typedef enum _ENUM_RSSI_TRIGGER_TYPE {
690     ENUM_RSSI_TRIGGER_NONE,
691     ENUM_RSSI_TRIGGER_GREATER,
692     ENUM_RSSI_TRIGGER_LESS,
693     ENUM_RSSI_TRIGGER_TRIGGERED,
694     ENUM_RSSI_TRIGGER_NUM
695 } ENUM_RSSI_TRIGGER_TYPE;
696
697 #if CFG_ENABLE_WIFI_DIRECT
698 typedef enum _ENUM_SUB_MODULE_IDX_T {
699     P2P_MODULE = 0,
700     SUB_MODULE_NUM
701 } ENUM_SUB_MODULE_IDX_T;
702
703 typedef enum _ENUM_NET_REG_STATE_T {
704     ENUM_NET_REG_STATE_UNREGISTERED,
705     ENUM_NET_REG_STATE_REGISTERING,
706     ENUM_NET_REG_STATE_REGISTERED,
707     ENUM_NET_REG_STATE_UNREGISTERING,
708     ENUM_NET_REG_STATE_NUM
709 } ENUM_NET_REG_STATE_T;
710
711 #endif
712
713 typedef struct _GL_IO_REQ_T {
714     QUE_ENTRY_T             rQueEntry;
715     //wait_queue_head_t       cmdwait_q;
716     BOOL                    fgRead;
717     BOOL                    fgWaitResp;
718 #if CFG_ENABLE_WIFI_DIRECT
719     BOOL                    fgIsP2pOid;
720 #endif
721     P_ADAPTER_T             prAdapter;
722     PFN_OID_HANDLER_FUNC    pfnOidHandler;
723     PVOID                   pvInfoBuf;
724     UINT_32                 u4InfoBufLen;
725     PUINT_32                pu4QryInfoLen;
726     WLAN_STATUS             rStatus;
727     UINT_32                 u4Flag;
728 } GL_IO_REQ_T, *P_GL_IO_REQ_T;
729
730 #if CFG_ENABLE_BT_OVER_WIFI
731 typedef struct _GL_BOW_INFO {
732     BOOLEAN                 fgIsRegistered;
733     dev_t                   u4DeviceNumber; /* dynamic device number */
734 //    struct kfifo            *prKfifo;       /* for buffering indicated events */
735     struct kfifo                      rKfifo;   /* for buffering indicated events */
736     spinlock_t              rSpinLock;      /* spin lock for kfifo */
737     struct cdev             cdev;
738     UINT_32                 u4FreqInKHz;    /* frequency */
739
740     UINT_8                  aucRole[CFG_BOW_PHYSICAL_LINK_NUM];  /* 0: Responder, 1: Initiator */
741     ENUM_BOW_DEVICE_STATE   aeState[CFG_BOW_PHYSICAL_LINK_NUM];
742     PARAM_MAC_ADDRESS       arPeerAddr[CFG_BOW_PHYSICAL_LINK_NUM];
743
744     wait_queue_head_t       outq;
745
746     #if CFG_BOW_SEPARATE_DATA_PATH
747     /* Device handle */
748     struct net_device           *prDevHandler;
749     BOOLEAN                     fgIsNetRegistered;
750     #endif
751
752 } GL_BOW_INFO, *P_GL_BOW_INFO;
753 #endif
754
755 /*
756 * type definition of pointer to p2p structure
757 */
758 typedef struct _GL_P2P_INFO_T   GL_P2P_INFO_T, *P_GL_P2P_INFO_T;
759
760 struct _GLUE_INFO_T {
761     /* Device handle */
762     struct net_device *prDevHandler;
763
764     /* Device Index(index of arWlanDevInfo[]) */
765     INT_32 i4DevIdx;
766
767     /* Device statistics */
768     struct net_device_stats rNetDevStats;
769
770     /* Wireless statistics struct net_device */
771     struct iw_statistics rIwStats;
772
773     /* spinlock to sync power save mechanism */
774     spinlock_t rSpinLock[SPIN_LOCK_NUM];
775
776     /* semaphore for ioctl */
777     struct semaphore ioctl_sem;
778
779     UINT_32 u4Flag; /* GLUE_FLAG_XXX */
780     UINT_32 u4PendFlag;
781     //UINT_32 u4TimeoutFlag;
782     UINT_32 u4OidCompleteFlag;
783     UINT_32 u4ReadyFlag;  /* check if card is ready */
784
785     /* Number of pending frames, also used for debuging if any frame is
786      * missing during the process of unloading Driver.
787      *
788      * NOTE(Kevin): In Linux, we also use this variable as the threshold
789      * for manipulating the netif_stop(wake)_queue() func.
790      */
791     INT_32             ai4TxPendingFrameNumPerQueue[4][CFG_MAX_TXQ_NUM];
792     INT_32             i4TxPendingFrameNum;
793     INT_32             i4TxPendingSecurityFrameNum;
794
795     /* current IO request for kalIoctl */
796     GL_IO_REQ_T         OidEntry;
797
798     /* registry info*/
799     REG_INFO_T rRegInfo;
800
801     /* firmware */
802     struct firmware     *prFw;
803
804     /* Host interface related information */
805     /* defined in related hif header file */
806     GL_HIF_INFO_T       rHifInfo;
807
808     /*! \brief wext wpa related information */
809     GL_WPA_INFO_T       rWpaInfo;
810
811
812     /* Pointer to ADAPTER_T - main data structure of internal protocol stack */
813     P_ADAPTER_T         prAdapter;
814
815 #ifdef WLAN_INCLUDE_PROC
816     struct proc_dir_entry *pProcRoot;
817 #endif /* WLAN_INCLUDE_PROC */
818
819     /* Indicated media state */
820     ENUM_PARAM_MEDIA_STATE_T eParamMediaStateIndicated;
821
822     /* Device power state D0~D3 */
823     PARAM_DEVICE_POWER_STATE ePowerState;
824
825     struct completion rScanComp; /* indicate scan complete */
826     struct completion rHaltComp; /* indicate main thread halt complete */
827     struct completion rPendComp; /* indicate main thread halt complete */
828         
829 #if 0// LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
830                 struct completion rMgmtTxComp; /* indicate supp mgmt TX done, supp can request channel again. */
831                 atomic_t rMgmtTxAto;
832 #endif
833
834 #if CFG_ENABLE_WIFI_DIRECT
835     struct completion rSubModComp; /*indicate sub module init or exit complete*/
836 #endif
837     WLAN_STATUS             rPendStatus;
838
839     QUE_T                   rTxQueue;
840
841
842     /* OID related */
843     QUE_T                   rCmdQueue;
844     //PVOID                   pvInformationBuffer;
845     //UINT_32                 u4InformationBufferLength;
846     //PVOID                   pvOidEntry;
847     //PUINT_8                 pucIOReqBuff;
848     //QUE_T                   rIOReqQueue;
849     //QUE_T                   rFreeIOReqQueue;
850
851     wait_queue_head_t       waitq;
852     struct task_struct      *main_thread;
853
854     struct timer_list tickfn;
855
856
857 #if CFG_SUPPORT_EXT_CONFIG
858     UINT_16     au2ExtCfg[256];  /* NVRAM data buffer */
859     UINT_32     u4ExtCfgLength;  /* 0 means data is NOT valid */
860 #endif
861
862 #if 1//CFG_SUPPORT_WAPI
863     /* Should be large than the PARAM_WAPI_ASSOC_INFO_T */
864     UINT_8                  aucWapiAssocInfoIEs[42];
865     UINT_16                 u2WapiAssocInfoIESz;
866 #endif
867
868 #if CFG_ENABLE_BT_OVER_WIFI
869     GL_BOW_INFO             rBowInfo;
870 #endif
871
872 #if CFG_ENABLE_WIFI_DIRECT
873     P_GL_P2P_INFO_T         prP2PInfo;
874 #if CFG_SUPPORT_P2P_RSSI_QUERY
875     /* Wireless statistics struct net_device */
876     struct iw_statistics    rP2pIwStats;
877 #endif
878 #endif
879     BOOLEAN                 fgWpsActive;
880         UINT_8                  aucWSCIE[500]; /*for probe req*/
881     UINT_16                 u2WSCIELen;
882         UINT_8                  aucWSCAssocInfoIE[200]; /*for Assoc req*/
883     UINT_16                 u2WSCAssocInfoIELen;
884
885     /* NVRAM availability */
886     BOOLEAN                 fgNvramAvailable;
887
888     BOOLEAN                 fgMcrAccessAllowed;
889
890     /* MAC Address Overriden by IOCTL */
891     BOOLEAN                 fgIsMacAddrOverride;
892     PARAM_MAC_ADDRESS       rMacAddrOverride;
893
894     SET_TXPWR_CTRL_T        rTxPwr;
895
896     /* for cfg80211 scan done indication */
897     struct cfg80211_scan_request    *prScanRequest;
898
899     /* to indicate registered or not */
900     BOOLEAN                 fgIsRegistered;
901
902     /* for cfg80211 connected indication */
903     UINT_32                 u4RspIeLength;
904     UINT_8                  aucRspIe[CFG_CFG80211_IE_BUF_LEN];
905
906     UINT_32                 u4ReqIeLength;
907     UINT_8                  aucReqIe[CFG_CFG80211_IE_BUF_LEN];
908 };
909
910 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
911     /* linux 2.4 */
912     typedef void (*PFN_WLANISR)(int irq, void *dev_id, struct pt_regs *regs);
913 #else
914     typedef irqreturn_t (*PFN_WLANISR)(int irq, void *dev_id, struct pt_regs *regs);
915 #endif
916
917 typedef void (*PFN_LINUX_TIMER_FUNC)(unsigned long);
918
919
920 /* generic sub module init/exit handler
921 *   now, we only have one sub module, p2p
922 */
923 #if CFG_ENABLE_WIFI_DIRECT
924 typedef BOOLEAN (*SUB_MODULE_INIT)(P_GLUE_INFO_T prGlueInfo);
925 typedef BOOLEAN (*SUB_MODULE_EXIT)(P_GLUE_INFO_T prGlueInfo);
926
927 typedef struct _SUB_MODULE_HANDLER {
928     SUB_MODULE_INIT subModInit;
929     SUB_MODULE_EXIT subModExit;
930     BOOLEAN fgIsInited;
931 } SUB_MODULE_HANDLER, *P_SUB_MODULE_HANDLER;
932
933 #endif
934
935 #if CONFIG_NL80211_TESTMODE
936
937 typedef struct _NL80211_DRIVER_TEST_MODE_PARAMS {
938         UINT_32  index;
939         UINT_32  buflen;
940 } NL80211_DRIVER_TEST_MODE_PARAMS, *P_NL80211_DRIVER_TEST_MODE_PARAMS;
941
942 /*SW CMD */
943 typedef struct _NL80211_DRIVER_SW_CMD_PARAMS {
944     NL80211_DRIVER_TEST_MODE_PARAMS hdr;
945     UINT_8           set;
946     unsigned long    adr;
947     unsigned long    data;
948 }NL80211_DRIVER_SW_CMD_PARAMS, *P_NL80211_DRIVER_SW_CMD_PARAMS;
949
950 struct iw_encode_exts {
951     __u32   ext_flags;                      /*!< IW_ENCODE_EXT_* */
952     __u8    tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /*!< LSB first */
953     __u8    rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /*!< LSB first */
954     __u8    addr[MAC_ADDR_LEN];   /*!< ff:ff:ff:ff:ff:ff for broadcast/multicast
955                                                           *   (group) keys or unicast address for
956                                                           *   individual keys */
957     __u16   alg;            /*!< IW_ENCODE_ALG_* */
958     __u16   key_len;
959     __u8    key[32];
960 };
961
962 /*SET KEY EXT */
963 typedef struct _NL80211_DRIVER_SET_KEY_EXTS {
964     NL80211_DRIVER_TEST_MODE_PARAMS hdr;
965     UINT_8     key_index;
966     UINT_8     key_len;
967     struct iw_encode_exts ext;
968 }NL80211_DRIVER_SET_KEY_EXTS, *P_NL80211_DRIVER_SET_KEY_EXTS;
969
970
971 #endif
972
973 /*******************************************************************************
974 *                            P U B L I C   D A T A
975 ********************************************************************************
976 */
977
978 /*******************************************************************************
979 *                           P R I V A T E   D A T A
980 ********************************************************************************
981 */
982
983 /*******************************************************************************
984 *                                 M A C R O S
985 ********************************************************************************
986 */
987 /*----------------------------------------------------------------------------*/
988 /* Macros of SPIN LOCK operations for using in Glue Layer                     */
989 /*----------------------------------------------------------------------------*/
990 #if CFG_USE_SPIN_LOCK_BOTTOM_HALF
991     #define GLUE_SPIN_LOCK_DECLARATION()
992     #define GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, rLockCategory)   \
993             { \
994                 if (rLockCategory < SPIN_LOCK_NUM) \
995                 spin_lock_bh(&(prGlueInfo->rSpinLock[rLockCategory])); \
996             }
997     #define GLUE_RELEASE_SPIN_LOCK(prGlueInfo, rLockCategory)   \
998             { \
999                 if (rLockCategory < SPIN_LOCK_NUM) \
1000                 spin_unlock_bh(&(prGlueInfo->rSpinLock[rLockCategory])); \
1001             }
1002 #else /* !CFG_USE_SPIN_LOCK_BOTTOM_HALF */
1003     #define GLUE_SPIN_LOCK_DECLARATION()                        UINT_32 __u4Flags = 0
1004     #define GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, rLockCategory)   \
1005             { \
1006                 if (rLockCategory < SPIN_LOCK_NUM) \
1007                 spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \
1008             }
1009     #define GLUE_RELEASE_SPIN_LOCK(prGlueInfo, rLockCategory)   \
1010             { \
1011                 if (rLockCategory < SPIN_LOCK_NUM) \
1012                 spin_unlock_irqrestore(&(prGlueInfo->rSpinLock[rLockCategory]), __u4Flags); \
1013             }
1014 #endif /* !CFG_USE_SPIN_LOCK_BOTTOM_HALF */
1015
1016
1017 /*----------------------------------------------------------------------------*/
1018 /* Macros for accessing Reserved Fields of native packet                      */
1019 /*----------------------------------------------------------------------------*/
1020 #define GLUE_GET_PKT_QUEUE_ENTRY(_p)    \
1021             (&( ((struct sk_buff *)(_p))->cb[0] ))
1022
1023 #define GLUE_GET_PKT_DESCRIPTOR(_prQueueEntry)  \
1024             ((P_NATIVE_PACKET) ((UINT_32)_prQueueEntry - offsetof(struct sk_buff, cb[0])) )
1025
1026 #define  GLUE_SET_PKT_FLAG_802_11(_p)  \
1027             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(7))
1028
1029 #define GLUE_SET_PKT_FLAG_1X(_p)  \
1030             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(6))
1031
1032 #define GLUE_SET_PKT_FLAG_PAL(_p)  \
1033             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(5))
1034
1035 #define GLUE_SET_PKT_FLAG_P2P(_p)  \
1036             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= BIT(4))
1037
1038
1039
1040 #define GLUE_SET_PKT_TID(_p, _tid)  \
1041             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) |= (((UINT_8)((_tid) & (BITS(0,3))))))
1042
1043
1044 #define GLUE_SET_PKT_FRAME_LEN(_p, _u2PayloadLen) \
1045             (*((PUINT_16) &( ((struct sk_buff *)(_p))->cb[6] )) = (UINT_16)(_u2PayloadLen))
1046
1047 #define GLUE_GET_PKT_FRAME_LEN(_p)    \
1048             (*((PUINT_16) &( ((struct sk_buff *)(_p))->cb[6] )) )
1049
1050
1051 #define  GLUE_GET_PKT_IS_802_11(_p)        \
1052             ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(7)))
1053
1054 #define  GLUE_GET_PKT_IS_1X(_p)        \
1055             ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(6)))
1056
1057 #define GLUE_GET_PKT_TID(_p)        \
1058             ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BITS(0,3)))
1059
1060
1061 #define GLUE_GET_PKT_IS_PAL(_p)        \
1062             ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(5)))
1063
1064 #define GLUE_GET_PKT_IS_P2P(_p)        \
1065             ((*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[4] )) ) & (BIT(4)))
1066
1067
1068 #define GLUE_SET_PKT_HEADER_LEN(_p, _ucMacHeaderLen)    \
1069             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[5] )) = (UINT_8)(_ucMacHeaderLen))
1070
1071 #define GLUE_GET_PKT_HEADER_LEN(_p) \
1072             (*((PUINT_8) &( ((struct sk_buff *)(_p))->cb[5] )) )
1073
1074 #define GLUE_SET_PKT_ARRIVAL_TIME(_p, _rSysTime) \
1075             (*((POS_SYSTIME) &( ((struct sk_buff *)(_p))->cb[8] )) = (OS_SYSTIME)(_rSysTime))
1076
1077 #define GLUE_GET_PKT_ARRIVAL_TIME(_p)    \
1078             (*((POS_SYSTIME) &( ((struct sk_buff *)(_p))->cb[8] )) )
1079
1080 /* Check validity of prDev, private data, and pointers */
1081 #define GLUE_CHK_DEV(prDev) \
1082     ((prDev && *((P_GLUE_INFO_T *) netdev_priv(prDev))) ? TRUE : FALSE)
1083
1084 #define GLUE_CHK_PR2(prDev, pr2) \
1085     ((GLUE_CHK_DEV(prDev) && pr2) ? TRUE : FALSE)
1086
1087 #define GLUE_CHK_PR3(prDev, pr2, pr3) \
1088     ((GLUE_CHK_PR2(prDev, pr2) && pr3) ? TRUE : FALSE)
1089
1090 #define GLUE_CHK_PR4(prDev, pr2, pr3, pr4) \
1091     ((GLUE_CHK_PR3(prDev, pr2, pr3) && pr4) ? TRUE : FALSE)
1092
1093 #define GLUE_SET_EVENT(pr) \
1094         kalSetEvent(pr)
1095
1096 #define GLUE_INC_REF_CNT(_refCount)     atomic_inc((atomic_t *)&(_refCount))
1097 #define GLUE_DEC_REF_CNT(_refCount)     atomic_dec((atomic_t *)&(_refCount))
1098
1099
1100 #define DbgPrint(...)
1101 /*******************************************************************************
1102 *                  F U N C T I O N   D E C L A R A T I O N S
1103 ********************************************************************************
1104 */
1105 #ifdef WLAN_INCLUDE_PROC
1106 INT_32
1107 procRemoveProcfs (
1108     struct net_device *prDev,
1109     char *pucDevName
1110     );
1111
1112 INT_32
1113 procInitProcfs (
1114     struct net_device *prDev,
1115     char *pucDevName
1116     );
1117 #endif /* WLAN_INCLUDE_PROC */
1118
1119 #if CFG_ENABLE_BT_OVER_WIFI
1120 BOOLEAN
1121 glRegisterAmpc (
1122     P_GLUE_INFO_T prGlueInfo
1123     );
1124
1125 BOOLEAN
1126 glUnregisterAmpc (
1127     P_GLUE_INFO_T prGlueInfo
1128     );
1129 #endif
1130
1131 #if CFG_ENABLE_WIFI_DIRECT
1132
1133 VOID
1134 wlanSubModRunInit(
1135     P_GLUE_INFO_T prGlueInfo
1136     );
1137
1138 VOID
1139 wlanSubModRunExit(
1140     P_GLUE_INFO_T prGlueInfo
1141     );
1142
1143 BOOLEAN
1144 wlanSubModInit(
1145     P_GLUE_INFO_T prGlueInfo
1146     );
1147
1148 BOOLEAN
1149 wlanSubModExit(
1150     P_GLUE_INFO_T prGlueInfo
1151     );
1152
1153 VOID
1154 wlanSubModRegisterInitExit(
1155     SUB_MODULE_INIT rSubModInit,
1156     SUB_MODULE_EXIT rSubModExit,
1157     ENUM_SUB_MODULE_IDX_T eSubModIdx
1158     );
1159
1160 BOOLEAN
1161 wlanExportGlueInfo(
1162     P_GLUE_INFO_T *prGlueInfoExpAddr
1163     );
1164
1165 BOOLEAN
1166 wlanIsLaunched(
1167     VOID
1168     );
1169
1170 void
1171 p2pSetMulticastListWorkQueueWrapper(
1172     P_GLUE_INFO_T prGlueInfo
1173     );
1174
1175
1176
1177 #endif
1178
1179 /*******************************************************************************
1180 *                              F U N C T I O N S
1181 ********************************************************************************
1182 */
1183
1184 #endif /* _GL_OS_H */
1185