c2413fa4a012d872fbfcc2d009328b49f9495fc0
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / mt5931 / include / nic / adapter.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic/adapter.h#3 $
3 */
4
5 /*! \file   adapter.h
6     \brief  Definition of internal data structure for driver manipulation.
7
8     In this file we define the internal data structure - ADAPTER_T which stands
9     for MiniPort ADAPTER(From Windows point of view) or stands for Network ADAPTER.
10 */
11
12
13
14 /*
15 ** $Log: adapter.h $
16 ** 
17 ** 08 31 2012 yuche.tsai
18 ** [ALPS00349585] [6577JB][WiFi direct][KE]Establish p2p connection while both device have connected to AP previously,one device reboots automatically with KE
19 ** Fix possible KE when concurrent & disconnect.
20 ** 
21 ** 07 26 2012 yuche.tsai
22 ** [ALPS00324337] [ALPS.JB][Hot-Spot] Driver update for Hot-Spot
23 ** Update driver code of ALPS.JB for hot-spot.
24  *
25  * 07 17 2012 yuche.tsai
26  * NULL
27  * Let netdev bring up.
28  *
29  * 07 17 2012 yuche.tsai
30  * NULL
31  * Compile no error before trial run.
32  *
33  * 06 13 2012 yuche.tsai
34  * NULL
35  * Update maintrunk driver.
36  * Add support for driver compose assoc request frame.
37  *
38  * 03 02 2012 terry.wu
39  * NULL
40  * Snc CFG80211 modification for ICS migration from branch 2.2.
41  *
42  * 03 02 2012 terry.wu
43  * NULL
44  * Sync CFG80211 modification from branch 2,2.
45  *
46  * 01 16 2012 cp.wu
47  * [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with corresponding network configuration 
48  * add wlanSetPreferBandByNetwork() for glue layer to invoke for setting preferred band configuration corresponding to network type.
49  *
50  * 12 13 2011 cm.chang
51  * [WCXRP00001136] [All Wi-Fi][Driver] Add wake lock for pending timer
52  * Add wake lock if timer timeout value is smaller than 5 seconds
53  *
54  * 12 02 2011 yuche.tsai
55  * NULL
56  * Resolve inorder issue under AP mode.
57  * 
58  * data frame may TX before assoc response frame.
59  *
60  * 11 19 2011 yuche.tsai
61  * NULL
62  * Update RSSI for P2P.
63  *
64  * 11 18 2011 yuche.tsai
65  * NULL
66  * CONFIG P2P support RSSI query, default turned off.
67  *
68  * 11 11 2011 yuche.tsai
69  * NULL
70  * Fix work thread cancel issue.
71  *
72  * 10 21 2011 eddie.chen
73  * [WCXRP00001051] [MT6620 Wi-Fi][Driver/Fw] Adjust the STA aging timeout
74  * Add switch to ignore the STA aging timeout.
75  *
76  * 10 12 2011 wh.su
77  * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
78  * adding the 802.11w related function and define .
79  *
80  * 09 20 2011 cm.chang
81  * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
82  * Remove ERP member in adapter structure
83  *
84  * 09 14 2011 yuche.tsai
85  * NULL
86  * Add P2P IE in assoc response.
87  *
88  * 08 31 2011 cm.chang
89  * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
90  * .
91  *
92  * 07 18 2011 chinghwa.yu
93  * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
94  * Add CMD/Event for RDD and BWCS.
95  *
96  * 06 23 2011 cp.wu
97  * [WCXRP00000812] [MT6620 Wi-Fi][Driver] not show NVRAM when there is no valid MAC address in NVRAM content
98  * check with firmware for valid MAC address.
99  *
100  * 04 18 2011 terry.wu
101  * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
102  * Remove flag CFG_WIFI_DIRECT_MOVED.
103  *
104  * 04 12 2011 cm.chang
105  * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
106  * .
107  *
108  * 04 08 2011 yuche.tsai
109  * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
110  * Add device discoverability support.
111  * Action frame callback for GO Device Discoverability Req.
112  *
113  * 04 08 2011 george.huang
114  * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
115  * separate settings of P2P and AIS
116  *
117  * 04 08 2011 eddie.chen
118  * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
119  * Fix for sigma
120  *
121  * 03 19 2011 yuche.tsai
122  * [WCXRP00000584] [Volunteer Patch][MT6620][Driver] Add beacon timeout support for WiFi Direct.
123  * Add beacon timeout support for WiFi Direct Network.
124  *
125  * 03 19 2011 yuche.tsai
126  * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
127  * Make assoc req to append P2P IE if wifi direct is enabled.
128  *
129  * 03 17 2011 cp.wu
130  * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
131  * use pre-allocated buffer for storing enhanced interrupt response as well
132  *
133  * 03 15 2011 cp.wu
134  * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous memory consumption
135  * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
136  * 2. Use common coalescing buffer for both TX/RX directions
137  *
138  *
139  * 03 10 2011 yuche.tsai
140  * [WCXRP00000533] [Volunteer Patch][MT6620][Driver] Provide a P2P function API for Legacy WiFi to query AP mode.
141  * Provide an API for Legacy WiFi to query the operation mode..
142  *
143  * 03 05 2011 wh.su
144  * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
145  * add the code to get the check rsponse and indicate to app.
146  *
147  * 03 02 2011 wh.su
148  * [WCXRP00000448] [MT6620 Wi-Fi][Driver] Fixed WSC IE not send out at probe request
149  * Add code to send beacon and probe response WSC IE at Auto GO.
150  *
151  * 03 02 2011 cp.wu
152  * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after connection is built.
153  * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
154  *
155  * 02 21 2011 terry.wu
156  * [WCXRP00000476] [MT6620 Wi-Fi][Driver] Clean P2P scan list while removing P2P
157  * Clean P2P scan list while removing P2P.
158  *
159  * 02 17 2011 eddie.chen
160  * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
161  * 1) Chnage GetFrameAction decision when BSS is absent.
162  * 2) Check channel and resource in processing ProbeRequest
163  *
164  * 02 16 2011 cm.chang
165  * [WCXRP00000447] [MT6620 Wi-Fi][FW] Support new NVRAM update mechanism
166  * .
167  *
168  * 02 10 2011 yuche.tsai
169  * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
170  * Add RX deauthentication & disassociation process under Hot-Spot mode.
171  *
172  * 02 09 2011 wh.su
173  * [WCXRP00000433] [MT6620 Wi-Fi][Driver] Remove WAPI structure define for avoid P2P module with structure miss-align pointer issue
174  * always pre-allio WAPI related structure for align p2p module.
175  *
176  * 02 08 2011 yuche.tsai
177  * [WCXRP00000419] [Volunteer Patch][MT6620/MT5931][Driver] Provide function of disconnect to target station for AAA module.
178  * Provide disconnect function for AAA module.
179  *
180  * 02 01 2011 cm.chang
181  * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
182  * .
183  *
184  * 01 27 2011 tsaiyuan.hsu
185  * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
186  * add roaming fsm
187  * 1. not support 11r, only use strength of signal to determine roaming.
188  * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
189  * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
190  * 4. assume that change of link quality in smooth way.
191  *
192  * 01 27 2011 george.huang
193  * [WCXRP00000400] [MT6620 Wi-Fi] support CTIA power mode setting
194  * Support CTIA power mode setting.
195  *
196  * 01 27 2011 george.huang
197  * [WCXRP00000355] [MT6620 Wi-Fi] Set WMM-PS related setting with qualifying AP capability
198  * Support current measure mode, assigned by registry (XP only).
199  *
200  * 01 24 2011 cp.wu
201  * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
202  * 1. add an extra counter for tracking pending forward frames.
203  * 2. notify TX service thread as well when there is pending forward frame
204  * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
205  *
206  * 01 12 2011 cm.chang
207  * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
208  * User-defined bandwidth is for 2.4G and 5G individually
209  *
210  * 12 29 2010 eddie.chen
211  * [WCXRP00000322] Add WMM IE in beacon,
212
213 Add per station flow control when STA is in PS
214
215
216  * Add WMM parameter for broadcast.
217  *
218  * 12 29 2010 eddie.chen
219  * [WCXRP00000322] Add WMM IE in beacon,
220
221 Add per station flow control when STA is in PS
222
223
224  * Add CWMin CWMax for AP to generate IE.
225  *
226  * 12 29 2010 eddie.chen
227  * [WCXRP00000322] Add WMM IE in beacon,
228 Add per station flow control when STA is in PS
229
230  * 1) PS flow control event
231  *
232  * 2) WMM IE in beacon, assoc resp, probe resp
233  *
234  * 12 28 2010 cp.wu
235  * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
236  * report EEPROM used flag via NIC_CAPABILITY
237  *
238  * 12 28 2010 cp.wu
239  * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
240  * integrate with 'EEPROM used' flag for reporting correct capability to Engineer Mode/META and other tools
241  *
242  * 12 07 2010 cm.chang
243  * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
244  * 1. Country code is from NVRAM or supplicant
245  * 2. Change band definition in CMD/EVENT.
246  *
247  * 11 01 2010 cp.wu
248  * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying current TX rate from firmware auto rate module
249  * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
250  * 2) Remove CNM CH-RECOVER event handling
251  * 3) cfg read/write API renamed with kal prefix for unified naming rules.
252  *
253  * 10 27 2010 george.huang
254  * [WCXRP00000127] [MT6620 Wi-Fi][Driver] Add a registry to disable Beacon Timeout function for SQA test by using E1 EVB
255  * Support registry option for disable beacon lost detection.
256  *
257  * 10 26 2010 cp.wu
258  * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000137] [MT6620 Wi-Fi] [FW] Support NIC capability query command
259  * 1) update NVRAM content template to ver 1.02
260  * 2) add compile option for querying NIC capability (default: off)
261  * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
262  * 4) correct auto-rate compiler error under linux (treat warning as error)
263  * 5) simplify usage of NVRAM and REG_INFO_T
264  * 6) add version checking between driver and firmware
265  *
266  * 10 08 2010 cp.wu
267  * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
268  * adding fixed rate support for distance test. (from registry setting)
269  *
270  * 10 06 2010 cp.wu
271  * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
272  * code reorganization to improve isolation between GLUE and CORE layers.
273  *
274  * 10 05 2010 cp.wu
275  * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
276  * 1) add NVRAM access API
277  * 2) fake scanning result when NVRAM doesn't exist and/or version mismatch. (off by compiler option)
278  * 3) add OID implementation for NVRAM read/write service
279  *
280  * 09 27 2010 chinghwa.yu
281  * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
282  * Update BCM/BoW design and settings.
283  *
284  * 09 24 2010 cp.wu
285  * [WCXRP00000057] [MT6620 Wi-Fi][Driver] Modify online scan to a run-time switchable feature
286  * Modify online scan as a run-time adjustable option (for Windows, in registry)
287  *
288  * 09 23 2010 cp.wu
289  * [WCXRP00000051] [MT6620 Wi-Fi][Driver] WHQL test fail in MAC address changed item
290  * use firmware reported mac address right after wlanAdapterStart() as permanent address
291  *
292  * 09 08 2010 cp.wu
293  * NULL
294  * use static memory pool for storing IEs of scanning result.
295  *
296  * 09 07 2010 yuche.tsai
297  * NULL
298  * Add a common IE buffer in P2P INFO structure.
299  *
300  * 09 03 2010 kevin.huang
301  * NULL
302  * Refine #include sequence and solve recursive/nested #include issue
303  *
304  * 09 01 2010 cp.wu
305  * NULL
306  * restore configuration as before.
307  *
308  * 09 01 2010 wh.su
309  * NULL
310  * adding the wapi support for integration test.
311  *
312  * 08 31 2010 kevin.huang
313  * NULL
314  * Use LINK LIST operation to process SCAN result
315  *
316  * 08 29 2010 yuche.tsai
317  * NULL
318  * Finish SLT TX/RX & Rate Changing Support.
319  *
320  * 08 25 2010 george.huang
321  * NULL
322  * update OID/ registry control path for PM related settings
323  *
324  * 08 24 2010 cm.chang
325  * NULL
326  * Support RLM initail channel of Ad-hoc, P2P and BOW
327  *
328  * 08 23 2010 chinghwa.yu
329  * NULL
330  * Update for BOW.
331  *
332  * 08 20 2010 cm.chang
333  * NULL
334  * Migrate RLM code to host from FW
335  *
336  * 08 16 2010 yuche.tsai
337  * NULL
338  * Add an intend mode for BSS info.
339  * It is used to let P2P BSS Info to know which OP Mode it is going to become.
340  *
341  * 08 04 2010 george.huang
342  * NULL
343  * handle change PS mode OID/ CMD
344  *
345  * 08 02 2010 cp.wu
346  * NULL
347  * comment out deprecated members in BSS_INFO, which are only used by firmware rather than driver.
348  *
349  * 07 29 2010 cp.wu
350  * NULL
351  * eliminate u4FreqInKHz usage, combined into rConnections.ucAdHoc*
352  *
353  * 07 28 2010 cp.wu
354  * NULL
355  * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
356  * 2) change nicMediaStateChange() API prototype
357  *
358  * 07 24 2010 wh.su
359  *
360  * .support the Wi-Fi RSN
361  *
362  * 07 21 2010 yuche.tsai
363  *
364  * Add for P2P Scan Result Parsing & Saving.
365  *
366  * 07 19 2010 wh.su
367  *
368  * update for security supporting.
369  *
370  * 07 19 2010 cm.chang
371  *
372  * Set RLM parameters and enable CNM channel manager
373  *
374  * 07 19 2010 yuche.tsai
375  *
376  * Remove BSS info which is redonedent in Wifi Var..
377  *
378  * 07 16 2010 yarco.yang
379  *
380  * 1. Support BSS Absence/Presence Event
381  * 2. Support STA change PS mode Event
382  * 3. Support BMC forwarding for AP mode.
383  *
384  * 07 14 2010 yarco.yang
385  *
386  * 1. Remove CFG_MQM_MIGRATION
387  * 2. Add CMD_UPDATE_WMM_PARMS command
388  *
389  * 07 09 2010 george.huang
390  *
391  * [WPD00001556] Migrate PM variables from FW to driver: for composing QoS Info
392  *
393  * 07 08 2010 cp.wu
394  *
395  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
396  *
397  * 07 08 2010 cm.chang
398  * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
399  * Check draft RLM code for HT cap
400  *
401  * 06 29 2010 yarco.yang
402  * [WPD00003837][MT6620]Data Path Refine
403  * replace g_rQM with Adpater->rQM
404  *
405  * 06 28 2010 cm.chang
406  * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
407  * 1st draft code for RLM module
408  *
409  * 06 21 2010 wh.su
410  * [WPD00003840][MT6620 5931] Security migration
411  * remove duplicate variable for migration.
412  *
413  * 06 21 2010 wh.su
414  * [WPD00003840][MT6620 5931] Security migration
415  * modify some code for concurrent network.
416  *
417  * 06 21 2010 yuche.tsai
418  * [WPD00003839][MT6620 5931][P2P] Feature migration
419  * Add P2P FSM Info in adapter.
420  *
421  * 06 21 2010 yarco.yang
422  * [WPD00003837][MT6620]Data Path Refine
423  * Support CFG_MQM_MIGRATION flag
424  *
425  * 06 18 2010 cm.chang
426  * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
427  * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
428  *
429  * 06 18 2010 wh.su
430  * [WPD00003840][MT6620 5931] Security migration
431  * migration the security related function from firmware.
432  *
433  * 06 17 2010 yuche.tsai
434  * [WPD00003839][MT6620 5931][P2P] Feature migration
435  * Add P2P related field, additional include p2p_fsm.h if p2p is enabled.
436  *
437  * 06 15 2010 cp.wu
438  * [WPD00003833][MT6620 and MT5931] Driver migration
439  * add scan.c.
440  *
441  * 06 14 2010 cp.wu
442  * [WPD00003833][MT6620 and MT5931] Driver migration
443  * add management dispatching function table.
444  *
445  * 06 11 2010 cp.wu
446  * [WPD00003833][MT6620 and MT5931] Driver migration
447  * auth.c is migrated.
448  *
449  * 06 11 2010 cp.wu
450  * [WPD00003833][MT6620 and MT5931] Driver migration
451  * 1) migrate assoc.c.
452  * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
453  * 3) add configuration options for CNM_MEM and RSN modules
454  * 4) add data path for management frames
455  * 5) eliminate rPacketInfo of MSDU_INFO_T
456  *
457  * 06 10 2010 cp.wu
458  * [WPD00003833][MT6620 and MT5931] Driver migration
459  * add buildable & linkable ais_fsm.c
460  *
461  * related reference are still waiting to be resolved
462  *
463  * 06 09 2010 cp.wu
464  * [WPD00003833][MT6620 and MT5931] Driver migration
465  * add definitions for module migration.
466  *
467  * 06 08 2010 cp.wu
468  * [WPD00003833][MT6620 and MT5931] Driver migration
469  * cnm_timer has been migrated.
470  *
471  * 06 08 2010 cp.wu
472  * [WPD00003833][MT6620 and MT5931] Driver migration
473  * hem_mbox is migrated.
474  *
475  * 06 07 2010 cp.wu
476  * [WPD00003833][MT6620 and MT5931] Driver migration
477  * merge wifi_var.h, precomp.h, cnm_timer.h (data type only)
478  *
479  * 06 06 2010 kevin.huang
480  * [WPD00003832][MT6620 5931] Create driver base
481  * [MT6620 5931] Create driver base
482  *
483  * 05 22 2010 cp.wu
484  * [WPD00001943]Create WiFi test driver framework on WinXP
485  * change OID behavior to meet WHQL requirement.
486  *
487  * 05 20 2010 cp.wu
488  * [WPD00001943]Create WiFi test driver framework on WinXP
489  * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
490  * 2) buffer statistics data for 2 seconds
491  * 3) use default value for adhoc parameters instead of 0
492  *
493  * 05 19 2010 cp.wu
494  * [WPD00001943]Create WiFi test driver framework on WinXP
495  * 1) do not take timeout mechanism for power mode oids
496  * 2) retrieve network type from connection status
497  * 3) after disassciation, set radio state to off
498  * 4) TCP option over IPv6 is supported
499  *
500  * 05 18 2010 cp.wu
501  * [WPD00001943]Create WiFi test driver framework on WinXP
502  * implement Wakeup-on-LAN except firmware integration part
503  *
504  * 04 27 2010 cp.wu
505  * [WPD00001943]Create WiFi test driver framework on WinXP
506  * reserve field of privacy filter and RTS threshold setting.
507  *
508  * 04 13 2010 cp.wu
509  * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
510  * add framework for BT-over-Wi-Fi support.
511  *  *  *  *  *  * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
512  *  *  *  *  *  * 2) command sequence number is now increased atomically
513  *  *  *  *  *  * 3) private data could be hold and taken use for other purpose
514  *
515  * 04 07 2010 cp.wu
516  * [WPD00001943]Create WiFi test driver framework on WinXP
517  * rWlanInfo should be placed at adapter rather than glue due to most operations
518  *  *  * are done in adapter layer.
519  *
520  * 04 06 2010 cp.wu
521  * [WPD00001943]Create WiFi test driver framework on WinXP
522  * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
523  *
524  * 03 31 2010 wh.su
525  * [WPD00003816][MT6620 Wi-Fi] Adding the security support
526  * modify the wapi related code for new driver's design.
527  *
528  * 03 19 2010 cp.wu
529  * [WPD00001943]Create WiFi test driver framework on WinXP
530  * 1) add ACPI D0/D3 state switching support
531  *  *  * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
532  *
533  * 03 03 2010 cp.wu
534  * [WPD00001943]Create WiFi test driver framework on WinXP
535  * implement OID_802_3_MULTICAST_LIST oid handling
536  *
537  * 03 02 2010 cp.wu
538  * [WPD00001943]Create WiFi test driver framework on WinXP
539  * 1) the use of prPendingOid revised, all accessing are now protected by spin lock
540  *  *  * 2) ensure wlanReleasePendingOid will clear all command queues
541  *
542  * 02 09 2010 cp.wu
543  * [WPD00001943]Create WiFi test driver framework on WinXP
544  * move ucCmdSeqNum as instance variable
545  *
546  * 01 27 2010 wh.su
547  * [WPD00003816][MT6620 Wi-Fi] Adding the security support
548  * .
549  *
550  * 01 27 2010 cp.wu
551  * [WPD00001943]Create WiFi test driver framework on WinXP
552  * 1. eliminate improper variable in rHifInfo
553  *  *  * 2. block TX/ordinary OID when RF test mode is engaged
554  *  *  * 3. wait until firmware finish operation when entering into and leaving from RF test mode
555  *  *  * 4. correct some HAL implementation
556  *
557  * 12 30 2009 cp.wu
558  * [WPD00001943]Create WiFi test driver framework on WinXP
559  * 1) According to CMD/EVENT documentation v0.8,
560  *  *  * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
561  *  *  * and result is retrieved by get ATInfo instead
562  *  *  * 2) add 4 counter for recording aggregation statistics
563  *
564  * 12 28 2009 cp.wu
565  * [WPD00001943]Create WiFi test driver framework on WinXP
566  * eliminate redundant variables for connection_state
567 **  \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-12-16 18:02:03 GMT mtk02752
568 **  add external reference to avoid compilation error
569 **  \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-12-10 16:40:26 GMT mtk02752
570 **  eliminate unused member
571 **  \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-12-08 17:36:08 GMT mtk02752
572 **  add RF test data members into P_ADAPTER_T
573 **  \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-10-13 21:58:45 GMT mtk01084
574 **  update for new HW architecture design
575 **  \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-28 10:29:57 GMT mtk01461
576 **  Add read WTSR for SDIO_STATUS_ENHANCE mode
577 **  \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-21 09:37:35 GMT mtk01461
578 **  Add prPendingCmdInfoOfOID for temporarily saving the CMD_INFO_T before en-queue to rCmdQueue
579 **  \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-17 19:57:51 GMT mtk01461
580 **  Add MGMT Buffer Info
581 **  \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:34:12 GMT mtk01461
582 **  Add SW pre test CFG_HIF_LOOPBACK_PRETEST
583 **  \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-23 21:41:48 GMT mtk01461
584 **  Add fgIsWmmAssoc flag for TC assignment
585 **  \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-19 18:32:51 GMT mtk01084
586 **  update for basic power management functions
587 **  \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-18 20:51:52 GMT mtk01426
588 **  Add #if CFG_SDIO_RX_ENHANCE related data structure
589 **  \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:16:17 GMT mtk01426
590 **  Init for develop
591 **
592 */
593
594 #ifndef _ADAPTER_H
595 #define _ADAPTER_H
596
597 /*******************************************************************************
598 *                         C O M P I L E R   F L A G S
599 ********************************************************************************
600 */
601
602 /*******************************************************************************
603 *                    E X T E R N A L   R E F E R E N C E S
604 ********************************************************************************
605 */
606
607 /*******************************************************************************
608 *                              C O N S T A N T S
609 ********************************************************************************
610 */
611
612 /*******************************************************************************
613 *                             D A T A   T Y P E S
614 ********************************************************************************
615 */
616 typedef struct _ENHANCE_MODE_DATA_STRUCT_T SDIO_CTRL_T, *P_SDIO_CTRL_T;
617
618 typedef struct _WLAN_INFO_T {
619     PARAM_BSSID_EX_T                rCurrBssId;
620
621     // Scan Result
622     PARAM_BSSID_EX_T                arScanResult[CFG_MAX_NUM_BSS_LIST];
623     PUINT_8                         apucScanResultIEs[CFG_MAX_NUM_BSS_LIST];
624     UINT_32                         u4ScanResultNum;
625
626     // IE pool for Scanning Result
627     UINT_8                          aucScanIEBuf[CFG_MAX_COMMON_IE_BUF_LEN];
628     UINT_32                         u4ScanIEBufferUsage;
629
630     OS_SYSTIME                      u4SysTime;
631
632     // connection parameter (for Ad-Hoc)
633     UINT_16                     u2BeaconPeriod;
634     UINT_16                     u2AtimWindow;
635
636     PARAM_RATES                 eDesiredRates;
637     CMD_LINK_ATTRIB             eLinkAttr;
638 //    CMD_PS_PROFILE_T         ePowerSaveMode;
639     CMD_PS_PROFILE_T         arPowerSaveMode[NETWORK_TYPE_INDEX_NUM];
640
641     // trigger parameter
642     ENUM_RSSI_TRIGGER_TYPE      eRssiTriggerType;
643     PARAM_RSSI                  rRssiTriggerValue;
644
645     // Privacy Filter
646     ENUM_PARAM_PRIVACY_FILTER_T ePrivacyFilter;
647
648     // RTS Threshold
649     PARAM_RTS_THRESHOLD         eRtsThreshold;
650
651     // Network Type
652     UINT_8                      ucNetworkType;
653
654     // Network Type In Use
655     UINT_8                      ucNetworkTypeInUse;
656
657 } WLAN_INFO_T, *P_WLAN_INFO_T;
658
659 /* Session for CONNECTION SETTINGS */
660 typedef struct _CONNECTION_SETTINGS_T {
661
662     UINT_8                          aucMacAddress[MAC_ADDR_LEN];
663
664     UINT_8                          ucDelayTimeOfDisconnectEvent;
665
666     BOOLEAN                         fgIsConnByBssidIssued;
667     UINT_8                          aucBSSID[MAC_ADDR_LEN];
668
669     BOOLEAN                         fgIsConnReqIssued;
670     UINT_8                          ucSSIDLen;
671     UINT_8                          aucSSID[ELEM_MAX_LEN_SSID];
672
673     ENUM_PARAM_OP_MODE_T            eOPMode;
674
675     ENUM_PARAM_CONNECTION_POLICY_T  eConnectionPolicy;
676
677     ENUM_PARAM_AD_HOC_MODE_T        eAdHocMode;
678
679     ENUM_PARAM_AUTH_MODE_T          eAuthMode;
680
681     ENUM_PARAM_ENCRYPTION_STATUS_T  eEncStatus;
682
683     BOOLEAN                         fgIsScanReqIssued;
684
685
686     /* MIB attributes */
687     UINT_16                         u2BeaconPeriod;
688
689     UINT_16                         u2RTSThreshold; /* User desired setting */
690
691     UINT_16                         u2DesiredNonHTRateSet; /* User desired setting */
692
693     UINT_8                          ucAdHocChannelNum; /* For AdHoc */
694
695     ENUM_BAND_T                     eAdHocBand; /* For AdHoc */
696
697     UINT_32                         u4FreqInKHz; /* Center frequency */
698
699     /* ATIM windows using for IBSS power saving function */
700     UINT_16                         u2AtimWindow;
701
702     /* Features */
703     BOOLEAN                         fgIsEnableRoaming;
704
705     BOOLEAN                         fgIsAdHocQoSEnable;
706
707     ENUM_PARAM_PHY_CONFIG_T         eDesiredPhyConfig;
708
709     /* Used for AP mode for desired channel and bandwidth */
710     UINT_16                         u2CountryCode;
711     UINT_8                          uc2G4BandwidthMode; /* 20/40M or 20M only */
712     UINT_8                          uc5GBandwidthMode;  /* 20/40M or 20M only */
713
714     BOOLEAN                         fgTxShortGIDisabled;
715     BOOLEAN                         fgRxShortGIDisabled;
716
717 #if CFG_SUPPORT_802_11D
718     BOOLEAN                         fgMultiDomainCapabilityEnabled;
719 #endif /* CFG_SUPPORT_802_11D*/
720
721
722 #if 1 //CFG_SUPPORT_WAPI
723     BOOL                            fgWapiMode;
724     UINT_32                         u4WapiSelectedGroupCipher;
725     UINT_32                         u4WapiSelectedPairwiseCipher;
726     UINT_32                         u4WapiSelectedAKMSuite;
727 #endif
728
729     /* CR1486, CR1640 */
730     /* for WPS, disable the privacy check for AP selection policy */
731     BOOLEAN                         fgPrivacyCheckDisable;
732
733     /* b0~3: trigger-en AC0~3. b4~7: delivery-en AC0~3 */
734     UINT_8                          bmfgApsdEnAc;
735
736 } CONNECTION_SETTINGS_T, *P_CONNECTION_SETTINGS_T;
737
738 struct _BSS_INFO_T {
739
740     ENUM_PARAM_MEDIA_STATE_T  eConnectionState;           /* Connected Flag used in AIS_NORMAL_TR */
741     ENUM_PARAM_MEDIA_STATE_T  eConnectionStateIndicated;  /* The Media State that report to HOST */
742
743     ENUM_OP_MODE_T          eCurrentOPMode;             /* Current Operation Mode - Infra/IBSS */
744 #if CFG_ENABLE_WIFI_DIRECT
745     ENUM_OP_MODE_T          eIntendOPMode;
746 #endif
747
748     BOOLEAN                 fgIsNetActive;              /* TRUE if this network has been activated */
749
750     UINT_8                  ucNetTypeIndex;             /* ENUM_NETWORK_TYPE_INDEX_T */
751
752     UINT_8                  ucReasonOfDisconnect;       /* Used by media state indication */
753
754     UINT_8                  ucSSIDLen;                  /* Length of SSID */
755
756 #if CFG_ENABLE_WIFI_DIRECT
757     ENUM_HIDDEN_SSID_TYPE_T eHiddenSsidType;            /* For Hidden SSID usage. */
758 #endif
759
760     UINT_8                  aucSSID[ELEM_MAX_LEN_SSID]; /* SSID used in this BSS */
761
762     UINT_8                  aucBSSID[MAC_ADDR_LEN];     /* The BSSID of the associated BSS */
763
764     UINT_8                  aucOwnMacAddr[MAC_ADDR_LEN];/* Owned MAC Address used in this BSS */
765
766     P_STA_RECORD_T          prStaRecOfAP;               /* For Infra Mode, and valid only if
767                                                          * eConnectionState == MEDIA_STATE_CONNECTED
768                                                          */
769     LINK_T                  rStaRecOfClientList;        /* For IBSS/AP Mode, all known STAs in current BSS */
770
771     UINT_16                 u2CapInfo;                  /* Change Detection */
772
773     UINT_16                 u2BeaconInterval;           /* The Beacon Interval of this BSS */
774
775
776     UINT_16                 u2ATIMWindow;               /* For IBSS Mode */
777
778     UINT_16                 u2AssocId;                  /* For Infra Mode, it is the Assoc ID assigned by AP.
779                                                          */
780
781
782     UINT_8                  ucDTIMPeriod;               /* For Infra/AP Mode */
783
784     UINT_8                  ucDTIMCount;                /* For AP Mode, it is the DTIM value we should carried in
785                                                          * the Beacon of next TBTT.
786                                                          */
787
788     UINT_8                  ucPhyTypeSet;               /* Available PHY Type Set of this peer
789                                                          * (This is deduced from received BSS_DESC_T)
790                                                          */
791
792     UINT_8                  ucNonHTBasicPhyType;        /* The Basic PHY Type Index, used to setup Phy Capability */
793
794     UINT_8                  ucConfigAdHocAPMode;        /* The configuration of AdHoc/AP Mode. e.g. 11g or 11b */
795
796     UINT_8                  ucBeaconTimeoutCount;       /* For Infra/AP Mode, it is a threshold of Beacon Lost Count to
797                                                            confirm connection was lost */
798
799     BOOLEAN                 fgHoldSameBssidForIBSS;     /* For IBSS Mode, to keep use same BSSID to extend the life cycle of an IBSS */
800
801     BOOLEAN                 fgIsBeaconActivated;        /* For AP/IBSS Mode, it is used to indicate that Beacon is sending */
802
803     P_MSDU_INFO_T           prBeacon;                   /* For AP/IBSS Mode - Beacon Frame */
804
805     BOOLEAN                 fgIsIBSSMaster;             /* For IBSS Mode - To indicate that we can reply ProbeResp Frame.
806                                                            In current TBTT interval */
807
808     BOOLEAN                 fgIsShortPreambleAllowed;   /* From Capability Info. of AssocResp Frame AND of Beacon/ProbeResp Frame */
809     BOOLEAN                 fgUseShortPreamble;         /* Short Preamble is enabled in current BSS. */
810     BOOLEAN                 fgUseShortSlotTime;         /* Short Slot Time is enabled in current BSS. */
811
812     UINT_16                 u2OperationalRateSet;       /* Operational Rate Set of current BSS */
813     UINT_16                 u2BSSBasicRateSet;          /* Basic Rate Set of current BSS */
814
815
816     UINT_8                  ucAllSupportedRatesLen;     /* Used for composing Beacon Frame in AdHoc or AP Mode */
817     UINT_8                  aucAllSupportedRates[RATE_NUM];
818
819     UINT_8                  ucAssocClientCnt;           /* TODO(Kevin): Number of associated clients */
820
821     BOOLEAN                 fgIsProtection;
822     BOOLEAN                 fgIsQBSS; /* fgIsWmmBSS; */ /* For Infra/AP/IBSS Mode, it is used to indicate if we support WMM in
823                                                          * current BSS. */
824     BOOLEAN                 fgIsNetAbsent;              /* TRUE: BSS is absent, FALSE: BSS is present */
825
826     UINT_32                 u4RsnSelectedGroupCipher;
827     UINT_32                 u4RsnSelectedPairwiseCipher;
828     UINT_32                 u4RsnSelectedAKMSuite;
829         UINT_16                 u2RsnSelectedCapInfo;
830
831     /*------------------------------------------------------------------------*/
832     /* Power Management related information                                   */
833     /*------------------------------------------------------------------------*/
834     PM_PROFILE_SETUP_INFO_T rPmProfSetupInfo;
835
836
837     /*------------------------------------------------------------------------*/
838     /* WMM/QoS related information                                            */
839     /*------------------------------------------------------------------------*/
840     UINT_8                  ucWmmParamSetCount;         /* Used to detect the change of EDCA parameters. For AP mode, the value is used in WMM IE */
841
842     AC_QUE_PARMS_T          arACQueParms[WMM_AC_INDEX_NUM];
843
844     UINT_8                  aucCWminLog2ForBcast[WMM_AC_INDEX_NUM];        /* For AP mode, broadcast the CWminLog2 */
845     UINT_8                  aucCWmaxLog2ForBcast[WMM_AC_INDEX_NUM];        /* For AP mode, broadcast the CWmaxLog2 */
846     AC_QUE_PARMS_T          arACQueParmsForBcast[WMM_AC_INDEX_NUM];        /* For AP mode, broadcast the value */
847
848     /*------------------------------------------------------------------------*/
849     /* 802.11n HT operation IE when (prStaRec->ucPhyTypeSet & PHY_TYPE_BIT_HT)*/
850     /* is true. They have the same definition with fields of                  */
851     /* information element (CM)                                               */
852     /*------------------------------------------------------------------------*/
853     ENUM_BAND_T             eBand;
854     UINT_8                  ucPrimaryChannel;
855     UINT_8                  ucHtOpInfo1;
856     UINT_16                 u2HtOpInfo2;
857     UINT_16                 u2HtOpInfo3;
858
859     /*------------------------------------------------------------------------*/
860     /* Required protection modes (CM)                                         */
861     /*------------------------------------------------------------------------*/
862     BOOLEAN                 fgErpProtectMode;
863     ENUM_HT_PROTECT_MODE_T  eHtProtectMode;
864     ENUM_GF_MODE_T          eGfOperationMode;
865     ENUM_RIFS_MODE_T        eRifsOperationMode;
866
867     BOOLEAN                 fgObssErpProtectMode;       /* GO only */
868     ENUM_HT_PROTECT_MODE_T  eObssHtProtectMode;         /* GO only */
869     ENUM_GF_MODE_T          eObssGfOperationMode;       /* GO only */
870     BOOLEAN                 fgObssRifsOperationMode;    /* GO only */
871
872     /*------------------------------------------------------------------------*/
873     /* OBSS to decide if 20/40M bandwidth is permitted.                       */
874     /* The first member indicates the following channel list length.          */
875     /*------------------------------------------------------------------------*/
876     BOOLEAN                 fgAssoc40mBwAllowed;
877     BOOLEAN                 fg40mBwAllowed;
878     ENUM_CHNL_EXT_T         eBssSCO;    /* Real setting for HW
879                                          * 20/40M AP mode will always set 40M,
880                                          * but its OP IE can be changed.
881                                          */
882     UINT_8                  auc2G_20mReqChnlList[CHNL_LIST_SZ_2G + 1];
883     UINT_8                  auc2G_NonHtChnlList[CHNL_LIST_SZ_2G + 1];
884     UINT_8                  auc2G_PriChnlList[CHNL_LIST_SZ_2G + 1];
885     UINT_8                  auc2G_SecChnlList[CHNL_LIST_SZ_2G + 1];
886
887     UINT_8                  auc5G_20mReqChnlList[CHNL_LIST_SZ_5G + 1];
888     UINT_8                  auc5G_NonHtChnlList[CHNL_LIST_SZ_5G + 1];
889     UINT_8                  auc5G_PriChnlList[CHNL_LIST_SZ_5G + 1];
890     UINT_8                  auc5G_SecChnlList[CHNL_LIST_SZ_5G + 1];
891
892     TIMER_T                 rObssScanTimer;
893     UINT_16                 u2ObssScanInterval;     /* in unit of sec */
894
895     BOOLEAN                 fgObssActionForcedTo20M;    /* GO only */
896     BOOLEAN                 fgObssBeaconForcedTo20M;    /* GO only */
897
898     /*------------------------------------------------------------------------*/
899     /* HW Related Fields (Kevin)                                              */
900     /*------------------------------------------------------------------------*/
901     UINT_8                  ucHwDefaultFixedRateCode;   /* The default rate code copied to MAC TX Desc */
902     UINT_16                 u2HwLPWakeupGuardTimeUsec;
903
904
905     UINT_8                  ucBssFreeQuota;              /* The value is updated from FW  */
906 };
907
908
909 struct _AIS_SPECIFIC_BSS_INFO_T {
910     UINT_8                  ucRoamingAuthTypes;         /* This value indicate the roaming type used in AIS_JOIN */
911
912     BOOLEAN                 fgIsIBSSActive;
913
914     /*! \brief Global flag to let arbiter stay at standby and not connect to any network */
915     BOOLEAN                 fgCounterMeasure;
916     UINT_8                  ucWEPDefaultKeyID;
917     BOOLEAN                 fgTransmitKeyExist; /* Legacy wep Transmit key exist or not */
918
919     /* While Do CounterMeasure procedure, check the EAPoL Error report have send out */
920     BOOLEAN                 fgCheckEAPoLTxDone;
921
922     UINT_32                 u4RsnaLastMICFailTime;
923
924     /* Stored the current bss wpa rsn cap filed, used for roaming policy */
925     //UINT_16                 u2RsnCap;
926     TIMER_T                 rPreauthenticationTimer;
927
928     /* By the flow chart of 802.11i,
929                wait 60 sec before associating to same AP
930                or roaming to a new AP
931                or sending data in IBSS,
932                keep a timer for handle the 60 sec counterMeasure */
933     TIMER_T                 rRsnaBlockTrafficTimer;
934     TIMER_T                 rRsnaEAPoLReportTimeoutTimer;
935
936     /* For Keep the Tx/Rx Mic key for TKIP SW Calculate Mic */
937     /* This is only one for AIS/AP */
938     UINT_8                  aucTxMicKey[8];
939     UINT_8                  aucRxMicKey[8];
940
941     /* Buffer for WPA2 PMKID */
942     /* The PMKID cache lifetime is expire by media_disconnect_indication */
943     UINT_32                 u4PmkidCandicateCount;
944     PMKID_CANDICATE_T       arPmkidCandicate[CFG_MAX_PMKID_CACHE];
945     UINT_32                 u4PmkidCacheCount;
946     PMKID_ENTRY_T           arPmkidCache[CFG_MAX_PMKID_CACHE];
947     BOOLEAN                 fgIndicatePMKID;
948 #if CFG_SUPPORT_802_11W
949     BOOLEAN                 fgMgmtProtection;
950     UINT_32                 u4SaQueryStart;
951     UINT_32                 u4SaQueryCount;
952     UINT_8                  ucSaQueryTimedOut;
953     PUINT_8                 pucSaQueryTransId;
954     TIMER_T                 rSaQueryTimer;
955     BOOLEAN                 fgBipKeyInstalled;
956 #endif
957 };
958
959 struct _BOW_SPECIFIC_BSS_INFO_T {
960     UINT_16                 u2Reserved; /* Reserved for Data Type Check */
961 };
962
963 #if CFG_SLT_SUPPORT
964 typedef struct _SLT_INFO_T {
965
966     P_BSS_DESC_T prPseudoBssDesc;
967     UINT_16 u2SiteID;
968     UINT_8 ucChannel2G4;
969     UINT_8 ucChannel5G;
970     BOOLEAN fgIsDUT;
971     UINT_32 u4BeaconReceiveCnt;
972     /////////Deprecated/////////
973     P_STA_RECORD_T prPseudoStaRec;
974 } SLT_INFO_T, *P_SLT_INFO_T;
975 #endif
976
977
978 /* Major member variables for WiFi FW operation.
979    Variables within this region will be ready for access after WIFI function is enabled.
980 */
981 typedef struct _WIFI_VAR_T {
982     BOOLEAN                 fgIsRadioOff;
983
984     BOOLEAN                 fgIsEnterD3ReqIssued;
985
986     BOOLEAN                 fgDebugCmdResp;
987
988     CONNECTION_SETTINGS_T   rConnSettings;
989
990     SCAN_INFO_T             rScanInfo;
991
992 #if CFG_SUPPORT_ROAMING
993     ROAMING_INFO_T          rRoamingInfo;
994 #endif /* CFG_SUPPORT_ROAMING */
995
996     AIS_FSM_INFO_T          rAisFsmInfo;
997
998     ENUM_PWR_STATE_T        aePwrState[NETWORK_TYPE_INDEX_NUM];
999
1000     BSS_INFO_T              arBssInfo[NETWORK_TYPE_INDEX_NUM];
1001
1002     AIS_SPECIFIC_BSS_INFO_T rAisSpecificBssInfo;
1003
1004 #if CFG_ENABLE_WIFI_DIRECT
1005     P_P2P_CONNECTION_SETTINGS_T prP2PConnSettings;
1006
1007     P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
1008
1009     P_P2P_FSM_INFO_T prP2pFsmInfo;
1010 #endif /* CFG_ENABLE_WIFI_DIRECT */
1011
1012 #if CFG_ENABLE_BT_OVER_WIFI
1013     BOW_SPECIFIC_BSS_INFO_T rBowSpecificBssInfo;
1014     BOW_FSM_INFO_T rBowFsmInfo;
1015 #endif /* CFG_ENABLE_BT_OVER_WIFI */
1016
1017     DEAUTH_INFO_T           arDeauthInfo[MAX_DEAUTH_INFO_COUNT];
1018
1019     /* Current Wi-Fi Settings and Flags */
1020     UINT_8                  aucPermanentAddress[MAC_ADDR_LEN];
1021     UINT_8                  aucMacAddress[MAC_ADDR_LEN];
1022     UINT_8                  aucDeviceAddress[MAC_ADDR_LEN];
1023     UINT_8                  aucInterfaceAddress[MAC_ADDR_LEN];
1024
1025     UINT_8                  ucAvailablePhyTypeSet;
1026
1027     ENUM_PHY_TYPE_INDEX_T   eNonHTBasicPhyType2G4; /* Basic Phy Type used by SCN according
1028                                                     * to the set of Available PHY Types
1029                                                     */
1030
1031     ENUM_PARAM_PREAMBLE_TYPE_T  ePreambleType;
1032     ENUM_REGISTRY_FIXED_RATE_T  eRateSetting;
1033
1034     BOOLEAN                 fgIsShortSlotTimeOptionEnable;
1035                             /* User desired setting, but will honor the capability of AP */
1036
1037     BOOLEAN                 fgEnableJoinToHiddenSSID;
1038     BOOLEAN                 fgSupportWZCDisassociation;
1039
1040     BOOLEAN                 fgSupportQoS;
1041     BOOLEAN                 fgSupportAmpduTx;
1042     BOOLEAN                 fgSupportAmpduRx;
1043     BOOLEAN                 fgSupportTspec;
1044     BOOLEAN                 fgSupportUAPSD;
1045     BOOLEAN                 fgSupportULPSMP;
1046
1047 #if CFG_SLT_SUPPORT
1048     SLT_INFO_T      rSltInfo;
1049 #endif
1050
1051 } WIFI_VAR_T, *P_WIFI_VAR_T;/* end of _WIFI_VAR_T */
1052
1053 /* cnm_timer module */
1054 typedef struct {
1055     LINK_T              rLinkHead;
1056     OS_SYSTIME          rNextExpiredSysTime;
1057     KAL_WAKE_LOCK_T     rWakeLock;
1058     BOOLEAN             fgWakeLocked;
1059 } ROOT_TIMER, *P_ROOT_TIMER;
1060
1061
1062 /* FW/DRV/NVRAM version information */
1063 typedef struct {
1064
1065     /* NVRAM or Registry */
1066     UINT_16     u2Part1CfgOwnVersion;
1067     UINT_16     u2Part1CfgPeerVersion;
1068     UINT_16     u2Part2CfgOwnVersion;
1069     UINT_16     u2Part2CfgPeerVersion;
1070
1071     /* Firmware */
1072     UINT_16     u2FwProductID;
1073     UINT_16     u2FwOwnVersion;
1074     UINT_16     u2FwPeerVersion;
1075
1076 } WIFI_VER_INFO_T, *P_WIFI_VER_INFO_T;
1077
1078
1079 #if CFG_ENABLE_WIFI_DIRECT
1080 /*
1081 * p2p function pointer structure
1082 */
1083
1084 typedef struct _P2P_FUNCTION_LINKER {
1085     P2P_REMOVE                                  prP2pRemove;
1086 //    NIC_P2P_MEDIA_STATE_CHANGE                  prNicP2pMediaStateChange;
1087 //    SCAN_UPDATE_P2P_DEVICE_DESC                 prScanUpdateP2pDeviceDesc;
1088 //    P2P_FSM_RUN_EVENT_RX_PROBE_RESPONSE_FRAME   prP2pFsmRunEventRxProbeResponseFrame;
1089     P2P_GENERATE_P2P_IE              prP2pGenerateWSC_IEForBeacon;
1090 //    P2P_CALCULATE_WSC_IE_LEN_FOR_PROBE_RSP      prP2pCalculateWSC_IELenForProbeRsp;
1091 //    P2P_GENERATE_WSC_IE_FOR_PROBE_RSP           prP2pGenerateWSC_IEForProbeRsp;
1092 //    SCAN_REMOVE_P2P_BSS_DESC                    prScanRemoveP2pBssDesc;
1093 //    P2P_HANDLE_SEC_CHECK_RSP                    prP2pHandleSecCheckRsp;
1094     P2P_NET_REGISTER                 prP2pNetRegister;
1095     P2P_NET_UNREGISTER               prP2pNetUnregister;
1096     P2P_CALCULATE_P2P_IE_LEN         prP2pCalculateP2p_IELenForAssocReq;   /* All IEs generated from supplicant. */
1097     P2P_GENERATE_P2P_IE              prP2pGenerateP2p_IEForAssocReq;           /* All IEs generated from supplicant. */
1098 } P2P_FUNCTION_LINKER, *P_P2P_FUNCTION_LINKER;
1099
1100
1101 #endif
1102
1103 /*
1104  * Major ADAPTER structure
1105  * Major data structure for driver operation
1106  */
1107 struct _ADAPTER_T {
1108     UINT_8                  ucRevID;
1109
1110     UINT_16                 u2NicOpChnlNum;
1111
1112     BOOLEAN                 fgIsEnableWMM;
1113     BOOLEAN                 fgIsWmmAssoc; /* This flag is used to indicate that WMM is enable in current BSS */
1114
1115     UINT_32                 u4OsPacketFilter;     // packet filter used by OS
1116
1117
1118 #if CFG_TCP_IP_CHKSUM_OFFLOAD
1119     UINT_32                 u4CSUMFlags;
1120 #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
1121
1122
1123     ENUM_BAND_T             aePreferBand[NETWORK_TYPE_INDEX_NUM];
1124
1125     /* ADAPTER flags */
1126     UINT_32                 u4Flags;
1127     UINT_32                 u4HwFlags;
1128
1129     BOOLEAN                 fgIsRadioOff;
1130
1131     BOOLEAN                 fgIsEnterD3ReqIssued;
1132
1133     UINT_8                  aucMacAddress[MAC_ADDR_LEN];
1134
1135     ENUM_PHY_TYPE_INDEX_T   eCurrentPhyType; /* Current selection basing on the set of Available PHY Types */
1136
1137 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
1138     UINT_32                 u4CoalescingBufCachedSize;
1139     PUINT_8                 pucCoalescingBufCached;
1140 #endif /* CFG_COALESCING_BUFFER_SIZE */
1141
1142     /* Buffer for CMD_INFO_T, Mgt packet and mailbox message */
1143     BUF_INFO_T              rMgtBufInfo;
1144     BUF_INFO_T              rMsgBufInfo;
1145     PUINT_8                 pucMgtBufCached;
1146     UINT_32                 u4MgtBufCachedSize;
1147     UINT_8                  aucMsgBuf[MSG_BUFFER_SIZE];
1148 #if CFG_DBG_MGT_BUF
1149     UINT_32                 u4MemAllocDynamicCount;     /* Debug only */
1150     UINT_32                 u4MemFreeDynamicCount;      /* Debug only */
1151 #endif
1152
1153     STA_RECORD_T            arStaRec[CFG_STA_REC_NUM];
1154
1155     /* Element for TX PATH */
1156     TX_CTRL_T               rTxCtrl;
1157     QUE_T                   rFreeCmdList;
1158     CMD_INFO_T              arHifCmdDesc[CFG_TX_MAX_CMD_PKT_NUM];
1159
1160     /* Element for RX PATH */
1161     RX_CTRL_T               rRxCtrl;
1162
1163     P_SDIO_CTRL_T           prSDIOCtrl;
1164
1165 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1166     /* Element for MT6620 E1 HIFSYS workaround */
1167     BOOLEAN                 fgIsClockGatingEnabled;
1168 #endif
1169
1170     /* Buffer for Authentication Event */
1171     /* <Todo> Move to glue layer and refine the kal function */
1172     /* Reference to rsnGeneratePmkidIndication function at rsn.c */
1173     UINT_8                  aucIndicationEventBuffer[(CFG_MAX_PMKID_CACHE * 20)  + 8 ];
1174
1175     UINT_32                 u4IntStatus;
1176
1177     ENUM_ACPI_STATE_T       rAcpiState;
1178
1179     BOOLEAN                 fgIsIntEnable;
1180     BOOLEAN                 fgIsIntEnableWithLPOwnSet;
1181
1182     BOOLEAN                 fgIsFwOwn;
1183     BOOLEAN                 fgWiFiInSleepyState;
1184
1185     UINT_32                 u4PwrCtrlBlockCnt;
1186
1187     QUE_T                   rPendingCmdQueue;
1188
1189     P_GLUE_INFO_T           prGlueInfo;
1190
1191     UINT_8                  ucCmdSeqNum;
1192     UINT_8                  ucTxSeqNum;
1193
1194 #if 1//CFG_SUPPORT_WAPI
1195     BOOLEAN                 fgUseWapi;
1196 #endif
1197
1198     /* RF Test flags */
1199     BOOLEAN         fgTestMode;
1200
1201     /* WLAN Info for DRIVER_CORE OID query */
1202     WLAN_INFO_T     rWlanInfo;
1203
1204 #if CFG_ENABLE_WIFI_DIRECT
1205     BOOLEAN             fgIsP2PRegistered;
1206     ENUM_NET_REG_STATE_T rP2PNetRegState;
1207     BOOLEAN             fgIsWlanLaunched;
1208     P_P2P_INFO_T        prP2pInfo;
1209 #if CFG_SUPPORT_P2P_RSSI_QUERY
1210     OS_SYSTIME          rP2pLinkQualityUpdateTime;
1211     BOOLEAN             fgIsP2pLinkQualityValid;
1212     EVENT_LINK_QUALITY  rP2pLinkQuality;
1213 #endif
1214 #endif
1215
1216     /* Online Scan Option */
1217     BOOLEAN         fgEnOnlineScan;
1218
1219     /* Online Scan Option */
1220     BOOLEAN         fgDisBcnLostDetection;
1221
1222     /* MAC address */
1223     PARAM_MAC_ADDRESS rMyMacAddr;
1224
1225     /* Wake-up Event for WOL */
1226     UINT_32         u4WakeupEventEnable;
1227
1228     /* Event Buffering */
1229     EVENT_STATISTICS    rStatStruct;
1230     OS_SYSTIME          rStatUpdateTime;
1231     BOOLEAN             fgIsStatValid;
1232
1233     EVENT_LINK_QUALITY  rLinkQuality;
1234     OS_SYSTIME          rLinkQualityUpdateTime;
1235     BOOLEAN             fgIsLinkQualityValid;
1236     OS_SYSTIME          rLinkRateUpdateTime;
1237     BOOLEAN             fgIsLinkRateValid;
1238
1239     /* WIFI_VAR_T */
1240     WIFI_VAR_T          rWifiVar;
1241
1242     /* MTK WLAN NIC driver IEEE 802.11 MIB */
1243     IEEE_802_11_MIB_T   rMib;
1244
1245     /* Mailboxs for inter-module communication */
1246     MBOX_T arMbox[MBOX_ID_TOTAL_NUM];
1247
1248     /* Timers for OID Pending Handling */
1249     TIMER_T             rOidTimeoutTimer;
1250
1251     /* Root Timer for cnm_timer module */
1252     ROOT_TIMER          rRootTimer;
1253
1254     /* RLM maintenance */
1255     ENUM_CHNL_EXT_T             eRfSco;
1256     ENUM_SYS_PROTECT_MODE_T     eSysProtectMode;
1257     ENUM_GF_MODE_T              eSysHtGfMode;
1258     ENUM_RIFS_MODE_T            eSysTxRifsMode;
1259     ENUM_SYS_PCO_PHASE_T        eSysPcoPhase;
1260
1261     P_DOMAIN_INFO_ENTRY         prDomainInfo;
1262
1263     /* QM */
1264     QUE_MGT_T                   rQM;
1265
1266     CNM_INFO_T                  rCnmInfo;
1267
1268     UINT_32 u4PowerMode;
1269
1270     UINT_32 u4CtiaPowerMode;
1271     BOOLEAN fgEnCtiaPowerMode;
1272
1273     UINT_32 fgEnArpFilter;
1274
1275     UINT_32 u4UapsdAcBmp;
1276
1277     UINT_32 u4MaxSpLen;
1278
1279     UINT_32 u4PsCurrentMeasureEn;
1280
1281     /* Version Information */
1282     WIFI_VER_INFO_T             rVerInfo;
1283
1284     /* 5GHz support (from F/W) */
1285     BOOLEAN fgIsHw5GBandDisabled;
1286     BOOLEAN fgEnable5GBand;
1287     BOOLEAN fgIsEepromUsed;
1288     BOOLEAN fgIsEfuseValid;
1289     BOOLEAN fgIsEmbbededMacAddrValid;
1290
1291     /* Packet Forwarding Tracking */
1292     INT_32  i4PendingFwdFrameCount;
1293
1294 #if CFG_SUPPORT_RDD_TEST_MODE
1295     UINT_8  ucRddStatus;
1296 #endif
1297
1298     BOOL fgDisStaAgingTimeoutDetection;
1299
1300 };/* end of _ADAPTER_T */
1301
1302 /*******************************************************************************
1303 *                            P U B L I C   D A T A
1304 ********************************************************************************
1305 */
1306
1307 /*******************************************************************************
1308 *                           P R I V A T E   D A T A
1309 ********************************************************************************
1310 */
1311
1312 /*******************************************************************************
1313 *                                 M A C R O S
1314 ********************************************************************************
1315 */
1316 /*----------------------------------------------------------------------------*/
1317 /* Macros for BSS_INFO_T - Flag of Net Active                                 */
1318 /*----------------------------------------------------------------------------*/
1319 #define IS_NET_ACTIVE(_prAdapter, _NetTypeIndex) \
1320                 (_prAdapter->rWifiVar.arBssInfo[(_NetTypeIndex)].fgIsNetActive)
1321 #define IS_BSS_ACTIVE(_prBssInfo)     ((_prBssInfo)->fgIsNetActive)
1322
1323 #define IS_AIS_ACTIVE(_prAdapter)     IS_NET_ACTIVE(_prAdapter, NETWORK_TYPE_AIS_INDEX)
1324 #define IS_P2P_ACTIVE(_prAdapter)     IS_NET_ACTIVE(_prAdapter, NETWORK_TYPE_P2P_INDEX)
1325 #define IS_BOW_ACTIVE(_prAdapter)     IS_NET_ACTIVE(_prAdapter, NETWORK_TYPE_BOW_INDEX)
1326
1327 #define SET_NET_ACTIVE(_prAdapter, _NetTypeIndex) \
1328                 {_prAdapter->rWifiVar.arBssInfo[(_NetTypeIndex)].fgIsNetActive = TRUE;}
1329
1330 #define UNSET_NET_ACTIVE(_prAdapter, _NetTypeIndex) \
1331                 {_prAdapter->rWifiVar.arBssInfo[(_NetTypeIndex)].fgIsNetActive = FALSE;}
1332
1333 #define BSS_INFO_INIT(_prAdapter, _NetTypeIndex) \
1334                 {   UINT_8 _aucZeroMacAddr[] = NULL_MAC_ADDR; \
1335                     P_BSS_INFO_T _prBssInfo = &(_prAdapter->rWifiVar.arBssInfo[(_NetTypeIndex)]); \
1336                     \
1337                     _prBssInfo->eConnectionState = PARAM_MEDIA_STATE_DISCONNECTED; \
1338                     _prBssInfo->eConnectionStateIndicated = PARAM_MEDIA_STATE_DISCONNECTED; \
1339                     _prBssInfo->eCurrentOPMode = OP_MODE_INFRASTRUCTURE; \
1340                     _prBssInfo->fgIsNetActive = FALSE; \
1341                     _prBssInfo->ucNetTypeIndex = (_NetTypeIndex); \
1342                     _prBssInfo->ucReasonOfDisconnect = DISCONNECT_REASON_CODE_RESERVED; \
1343                     COPY_MAC_ADDR(_prBssInfo->aucBSSID, _aucZeroMacAddr); \
1344                     LINK_INITIALIZE(&_prBssInfo->rStaRecOfClientList); \
1345                     _prBssInfo->fgIsBeaconActivated = FALSE; \
1346                     _prBssInfo->ucHwDefaultFixedRateCode = RATE_CCK_1M_LONG; \
1347                     _prBssInfo->fgIsNetAbsent = FALSE; \
1348                 }
1349
1350 #if CFG_ENABLE_BT_OVER_WIFI
1351 #define BOW_BSS_INFO_INIT(_prAdapter, _NetTypeIndex) \
1352                 {  \
1353                     P_BSS_INFO_T _prBssInfo = &(_prAdapter->rWifiVar.arBssInfo[(_NetTypeIndex)]); \
1354                     \
1355                     _prBssInfo->eConnectionState = PARAM_MEDIA_STATE_DISCONNECTED; \
1356                     _prBssInfo->eConnectionStateIndicated = PARAM_MEDIA_STATE_DISCONNECTED; \
1357                     _prBssInfo->eCurrentOPMode = OP_MODE_BOW; \
1358                     _prBssInfo->ucNetTypeIndex = (_NetTypeIndex); \
1359                     _prBssInfo->ucReasonOfDisconnect = DISCONNECT_REASON_CODE_RESERVED; \
1360                     LINK_INITIALIZE(&_prBssInfo->rStaRecOfClientList); \
1361                     _prBssInfo->fgIsBeaconActivated = TRUE; \
1362                     _prBssInfo->ucHwDefaultFixedRateCode = RATE_CCK_1M_LONG; \
1363                     _prBssInfo->fgIsNetAbsent = FALSE; \
1364                 }
1365 #endif
1366
1367 /*----------------------------------------------------------------------------*/
1368 /* Macros for Power State                                                     */
1369 /*----------------------------------------------------------------------------*/
1370 #define SET_NET_PWR_STATE_IDLE(_prAdapter, _NetTypeIndex) \
1371                 {_prAdapter->rWifiVar.aePwrState[(_NetTypeIndex)] = PWR_STATE_IDLE;}
1372
1373 #define SET_NET_PWR_STATE_ACTIVE(_prAdapter, _NetTypeIndex) \
1374                 {_prAdapter->rWifiVar.aePwrState[(_NetTypeIndex)] = PWR_STATE_ACTIVE;}
1375
1376 #define SET_NET_PWR_STATE_PS(_prAdapter, _NetTypeIndex) \
1377                 {_prAdapter->rWifiVar.aePwrState[(_NetTypeIndex)] = PWR_STATE_PS;}
1378
1379 #define IS_NET_PWR_STATE_ACTIVE(_prAdapter, _NetTypeIndex) \
1380                 (_prAdapter->rWifiVar.aePwrState[(_NetTypeIndex)] == PWR_STATE_ACTIVE)
1381
1382 #define IS_NET_PWR_STATE_IDLE(_prAdapter, _NetTypeIndex) \
1383                 (_prAdapter->rWifiVar.aePwrState[(_NetTypeIndex)] == PWR_STATE_IDLE)
1384
1385 #define IS_SCN_PWR_STATE_ACTIVE(_prAdapter) \
1386                 (_prAdapter->rWifiVar.rScanInfo.eScanPwrState == SCAN_PWR_STATE_ACTIVE)
1387
1388 #define IS_SCN_PWR_STATE_IDLE(_prAdapter) \
1389                 (_prAdapter->rWifiVar.rScanInfo.eScanPwrState == SCAN_PWR_STATE_IDLE)
1390
1391 /*******************************************************************************
1392 *                  F U N C T I O N   D E C L A R A T I O N S
1393 ********************************************************************************
1394 */
1395
1396
1397 /*******************************************************************************
1398 *                              F U N C T I O N S
1399 ********************************************************************************
1400 */
1401
1402 #endif /* _ADAPTER_H */
1403
1404