2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_2/nic/nic.c#3 $
6 \brief Functions that provide operation in NIC's (Network Interface Card) point of view.
8 This file includes functions which unite multiple hal(Hardware) operations
9 and also take the responsibility of Software Resource Management in order
10 to keep the synchronization with Hardware Manipulation.
13 /*******************************************************************************
14 * Copyright (c) 2007 MediaTek Inc.
16 * All rights reserved. Copying, compilation, modification, distribution
17 * or any other use whatsoever of this material is strictly prohibited
18 * except in accordance with a Software License Agreement with
20 ********************************************************************************
23 /*******************************************************************************
26 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
27 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
28 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
29 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
30 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
31 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
33 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
34 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
35 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
36 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
37 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
38 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
40 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
41 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
42 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
43 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
44 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
46 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
47 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
48 * OF LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
49 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
50 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
52 ********************************************************************************
58 * 02 14 2012 yuche.tsai
59 * [ALPS00118350] [ALPS.ICS][WiFi Direct] Dirver update for wifi direct connection
60 * Replace Beacon/Probe Response IE by driver generating instead of from supplicant.
62 * 01 13 2012 yuche.tsai
64 * Update driver/p2p driver for ICS tethering mode.
65 * Fix FW reply probe request issue.
67 * 01 13 2012 yuche.tsai
69 * WiFi Hot Spot Tethering for ICS ALPHA testing version.
72 * [WCXRP00001125] [MT6620 Wi-Fi][Firmware] Strengthen Wi-Fi power off sequence to have a clearroom environment when returining to ROM code
73 * 1. Due to firmware now stops HIF DMA for powering off, do not try to receive any packet from firmware
74 * 2. Take use of prAdapter->fgIsEnterD3ReqIssued for tracking whether it is powering off or not
76 * 11 22 2011 tsaiyuan.hsu
77 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
78 * keep debug counter setting after wake up.
80 * 11 19 2011 yuche.tsai
82 * Add P2P RSSI Link Quality Query Support. (Default Off)
84 * 11 04 2011 tsaiyuan.hsu
85 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
86 * add debug counters and periodically dump counters for Xlog debugging.
89 * [WCXRP00001079] [MT5931][Driver] Release pending MMPDU only when BSS is being deactivated
90 * pre-check for NULL before calling MMPDU freeing function
93 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
94 * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
96 * 11 01 2011 chinglan.wang
98 * Modify the Wi-Fi method of the flush TX queue when disconnect the AP.
99 * If disconnect the AP and flush all the data frame in the TX queue, WPS cannot do the 4-way handshake to connect to the AP..
101 * 10 19 2011 yuche.tsai
102 * [WCXRP00001045] [WiFi Direct][Driver] Check 2.1 branch.
104 * Davinci Maintrunk Label: MT6620_WIFI_DRIVER_FW_TRUNK_MT6620E5_111019_0926.
106 * 08 03 2011 terry.wu
107 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
108 * Reply Probe Rsp in FW for Hotspot Mode.
112 * 08 03 2011 terry.wu
113 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
114 * Reply Probe Rsp in FW for Hotspot Mode.
117 * 08 03 2011 terry.wu
118 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
119 * Reply Probe Rsp in FW for Hotspot Mode.
121 * 08 03 2011 terry.wu
122 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
123 * Reply Probe Rsp in FW for Hotspot Mode.
125 * 08 02 2011 yuche.tsai
126 * [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a disconnecting device issue.
127 * Support TX Deauth while tearing down a station connection.
130 * [WCXRP00000849] [MT6620 Wi-Fi][Driver] Remove some of the WAPI define for make sure the value is initialize, for customer not enable WAPI
131 * For make sure wapi initial value is set.
134 * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky AP which use space character as hidden SSID
136 * 2. replace only BSS-DESC which doesn't have a valid SSID.
139 * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky AP which use space character as hidden SSID
140 * allow to have a single BSSID with multiple SSID to be presented in scanning result
142 * 05 11 2011 eddie.chen
143 * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
144 * Fix dest type when GO packet copying.
146 * 04 18 2011 terry.wu
147 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
148 * Remove flag CFG_WIFI_DIRECT_MOVED.
151 * [WCXRP00000651] [MT6620 Wi-Fi][Driver] Refine RSSI buffering mechanism
152 * ROLLBACK due to the special design is to workaround incorrect initial RCPI value coming from firmware domain.
154 * 04 14 2011 cm.chang
155 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
159 * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events
160 * sync. whole-chip resetting mechanism to V2.0 branch.
163 * [WCXRP00000635] [MT6620 Wi-Fi][Driver] Clear pending security frames when QM clear pending data frames for dedicated network type
164 * clear pending security frames for dedicated network type when BSS is being deactivated/disconnected
168 * enable the p2p check the cipher to set the bssInfo auth mode.
172 * prepare the code for sync the auth mode and encryption status for P2P and BOW.
174 * 04 11 2011 yuche.tsai
175 * [WCXRP00000627] [Volunteer Patch][MT6620][Driver] Pending MMPUD of P2P Network may crash system issue.
176 * Fix kernel panic issue when MMPDU of P2P is pending in driver after WLAN module removed.
178 * 04 10 2011 george.huang
179 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
180 * Fix compiler issue.
182 * 04 08 2011 george.huang
183 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
184 * separate settings of P2P and AIS
186 * 04 07 2011 eddie.chen
187 * [WCXRP00000527] [MT6620 Wi-Fi][FW/Driver] Clean buffered packet when BSS is inactive or disconnected[WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
188 * Remove packet when BSS is inactive
191 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
195 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
196 * implementation of internal error handling of nicAllocateAdapterMemory.
198 * 03 31 2011 chinglan.wang
199 * [WCXRP00000613] [MT6620 Wi-Fi] [FW] [Driver] BssInfo can get the security mode which is WPA/WPA2/WAPI or not.
203 * [WCXRP00000577] [MT6620 Wi-Fi][Driver][FW] Create V2.0 branch for firmware and driver
204 * create V2.0 driver release based on label "MT6620_WIFI_DRIVER_V2_0_110318_1600" from main trunk
207 * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
208 * use pre-allocated buffer for storing enhanced interrupt response as well
211 * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
212 * 1. pre-allocate physical continuous buffer while module is being loaded
213 * 2. use pre-allocated physical continuous buffer for TX/RX DMA transfer
215 * The windows part remained the same as before, but added similiar APIs to hide the difference.
218 * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous memory consumption
219 * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
220 * 2. Use common coalescing buffer for both TX/RX directions
223 * 03 10 2011 cm.chang
224 * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
225 * Add some functions to let AIS/Tethering or AIS/BOW be the same channel
227 * 03 07 2011 terry.wu
228 * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
229 * Toggle non-standard debug messages to comments.
232 * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after connection is built.
233 * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
235 * 02 08 2011 terry.wu
236 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
237 * Use kalPrint to print firmware assert info.
239 * 02 01 2011 terry.wu
240 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
243 * 02 01 2011 cm.chang
244 * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
247 * 01 31 2011 terry.wu
248 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
249 * Print firmware ASSERT info at Android kernel log, driver side
251 * 01 27 2011 tsaiyuan.hsu
252 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
254 * 1. not support 11r, only use strength of signal to determine roaming.
255 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
256 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
257 * 4. assume that change of link quality in smooth way.
259 * 01 26 2011 cm.chang
260 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
261 * Allocate system RAM if fixed message or mgmt buffer is not available
264 * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
265 * 1. add an extra counter for tracking pending forward frames.
266 * 2. notify TX service thread as well when there is pending forward frame
267 * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
270 * [WCXRP00000372] [MT6620 Wi-Fi][Driver] Check bus access failure inside nicProcessIST()
271 * check bus error and/or card removal when retrieving interrupt status from HAL
274 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
275 * 1) correct typo in scan.c
276 * 2) TX descriptors, RX descriptos and management buffer should use virtually continous buffer instead of physically contineous one
279 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
280 * separate kalMemAlloc() into virtually-continous and physically-continous type to ease slab system pressure
283 * [WCXRP00000327] [MT6620 Wi-Fi][Driver] Improve HEC WHQA 6972 workaround coverage in driver side
284 * host driver not to set FW-own when there is still pending interrupts
287 * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
288 * before BSS disconnection is indicated to firmware, all correlated peer should be cleared and freed
290 * 12 07 2010 cm.chang
291 * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
292 * 1. BSSINFO include RLM parameter
293 * 2. free all sta records when network is disconnected
295 * 12 02 2010 eddie.chen
296 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
297 * Add more control value but dont use it now.
299 * 11 30 2010 eddie.chen
300 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
301 * Add auto rate check window in registry
303 * 11 10 2010 eddie.chen
304 * [WCXRP00000156] [MT6620][FW] Change Auto rate window to 64 and add throughput swcr
305 * Use autorate parameter 1 as phy rate mask.
308 * [WCXRP00000166] [MT6620 Wi-Fi][Driver] use SDIO CMD52 for enabling/disabling interrupt to reduce transaction period
309 * change to use CMD52 for enabling/disabling interrupt to reduce SDIO transaction time
311 * 10 26 2010 eddie.chen
312 * [WCXRP00000134] [MT6620 Wi-Fi][Driver] Add a registry to enable auto rate for SQA test by using E1 EVB
313 * Add auto rate parameter in registry.
316 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
317 * 1. remove redundant variables in STA_REC structure
318 * 2. add STA-REC uninitialization routine for clearing pending events
321 * [WCXRP00000103] [MT6620 Wi-Fi][Driver] Driver crashed when using WZC to connect to AP#B with connection with AP#A
322 * reset ptrs when IEs are going to be dropped
325 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
326 * add HT (802.11n) fixed rate support.
329 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
330 * adding fixed rate support for distance test. (from registry setting)
333 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
334 * add firmware download for MT5931.
337 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
338 * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
341 * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by ENUM_NETWORK_TYPE_INDEX_T only
342 * remove ENUM_NETWORK_TYPE_T definitions
345 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
346 * Do a complete reset with STA-REC null checking for RF test re-entry
350 * use static memory pool for storing IEs of scanning result.
354 * Androi/Linux: return current operating channel information
358 * HIFSYS Clock Source Workaround
360 * 08 26 2010 yuche.tsai
362 * Fix someones coding error while enable WIFI_DIRECT.
364 * 08 25 2010 george.huang
366 * update OID/ registry control path for PM related settings
368 * 08 24 2010 cm.chang
370 * Support RLM initail channel of Ad-hoc, P2P and BOW
372 * 08 24 2010 chinghwa.yu
374 * Update BOW for the 1st time.
376 * 08 23 2010 chinghwa.yu
380 * 08 20 2010 yuche.tsai
382 * Add state change indication.
384 * 08 16 2010 yuche.tsai
386 * Add support for P2P BSS update info.
390 * [removing debugging] not to dump beacon content.
394 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
398 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
399 * 2) extending scanning result to 64 instead of 48
401 * 08 04 2010 yarco.yang
403 * Add TX_AMPDU and ADDBA_REJECT command
407 * surpress compilation warning.
411 * Centralize mgmt/system service procedures into independent calls.
415 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
416 * 2) change nicMediaStateChange() API prototype
420 * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
424 * .support the Wi-Fi RSN
428 * FIX: structure of CMD_SET_BSS_INFO has been changed but no follow-ups are done.
430 * 07 22 2010 george.huang
434 * 07 22 2010 george.huang
436 * Update fgIsQoS information in BSS INFO by CMD
440 * [WPD00003833] [MT6620 and MT5931] Driver migration.
441 * Add Ad-Hoc support to AIS-FSM
443 * 07 14 2010 yarco.yang
445 * 1. Remove CFG_MQM_MIGRATION
446 * 2. Add CMD_UPDATE_WMM_PARMS command
450 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
453 * [WPD00003833][MT6620 and MT5931] Driver migration
454 * update prStaRecOfAP with BSS-INFO.
456 * 07 06 2010 george.huang
457 * [WPD00001556]Basic power managemenet function
458 * Update arguments for nicUpdateBeaconIETemplate()
461 * [WPD00003833][MT6620 and MT5931] Driver migration
462 * STA-REC is maintained by CNM only.
465 * [WPD00003833][MT6620 and MT5931] Driver migration
466 * 1) ignore RSN checking when RSN is not turned on.
467 * 2) set STA-REC deactivation callback as NULL
468 * 3) add variable initialization API based on PHY configuration
470 * 07 01 2010 cm.chang
471 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
472 * Support sync command of STA_REC
475 * [WPD00003833][MT6620 and MT5931] Driver migration
476 * sync. with CMD/EVENT document ver0.07.
479 * [WPD00003833][MT6620 and MT5931] Driver migration
480 * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
483 * [WPD00003833][MT6620 and MT5931] Driver migration
484 * 1) sync to. CMD/EVENT document v0.03
485 * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
486 * 3) send command packet to indicate FW-PM after
487 * a) 1st beacon is received after AIS has connected to an AP
488 * b) IBSS-ALONE has been created
489 * c) IBSS-MERGE has occured
491 * 06 25 2010 george.huang
492 * [WPD00001556]Basic power managemenet function
493 * Create beacon update path, with expose bssUpdateBeaconContent()
496 * [WPD00003833][MT6620 and MT5931] Driver migration
497 * fill fgIsUapsdConnection when indicating BSS-CREATE with AIS-STA mode.
500 * [WPD00003833][MT6620 and MT5931] Driver migration
501 * 1) add command warpper for STA-REC/BSS-INFO sync.
502 * 2) enhance command packet sending procedure for non-oid part
503 * 3) add command packet definitions for STA-REC/BSS-INFO sync.
506 * [WPD00003833][MT6620 and MT5931] Driver migration
507 * implement TX_DONE callback path.
510 * [WPD00003840][MT6620 5931] Security migration
511 * remove duplicate variable for migration.
514 * [WPD00003833][MT6620 and MT5931] Driver migration
515 * TX descriptors are now allocated once for reducing allocation overhead
517 * 06 18 2010 cm.chang
518 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
519 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
522 * [WPD00003833][MT6620 and MT5931] Driver migration
523 * 1) migrate assoc.c.
524 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
525 * 3) add configuration options for CNM_MEM and RSN modules
526 * 4) add data path for management frames
527 * 5) eliminate rPacketInfo of MSDU_INFO_T
530 * [WPD00003833][MT6620 and MT5931] Driver migration
531 * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
532 * 2) when disconnected, indicate nic directly (no event is needed)
534 * 06 06 2010 kevin.huang
535 * [WPD00003832][MT6620 5931] Create driver base
536 * [MT6620 5931] Create driver base
539 * [WPD00001943]Create WiFi test driver framework on WinXP
540 * 1) surpress compiler warning
541 * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
544 * [WPD00001943]Create WiFi test driver framework on WinXP
545 * surpress compiler warning
548 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
549 * add framework for BT-over-Wi-Fi support.
550 * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
551 * * * * * * * * * * * * * 2) command sequence number is now increased atomically
552 * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
555 * [WPD00001943]Create WiFi test driver framework on WinXP
556 * add channel frequency <-> number conversion
559 * [WPD00001943]Create WiFi test driver framework on WinXP
560 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
563 * [WPD00003827][MT6620 Wi-Fi] Chariot fail and following ping fail, no pkt send from driver
564 * correct nicProcessIST_impl() for interrupt status brought up by RX enhanced response
567 * [WPD00001943]Create WiFi test driver framework on WinXP
568 * 1) add ACPI D0/D3 state switching support
569 * * * * * * * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
572 * [WPD00001943]Create WiFi test driver framework on WinXP
573 * always process TX interrupt first then RX interrupt.
576 * [WPD00001943]Create WiFi test driver framework on WinXP
577 * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
580 * [WPD00001943]Create WiFi test driver framework on WinXP
581 * add checksum offloading support.
582 ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-12-16 18:03:43 GMT mtk02752
583 ** handling enhanced response which fields are fetched at different moments
584 ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-12-15 17:00:29 GMT mtk02752
585 ** if RX enhanced response is used, D2H interrupt status should be coming from buffered result as well
586 ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-12-15 12:01:55 GMT mtk02752
587 ** if TX_DONE bit is not set but WTSR0/WTSR1 is non-zero, then set TX_DONE bit due to time latency of interrupt status enhanced response
588 ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-12-10 16:52:52 GMT mtk02752
590 ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-11-24 20:51:01 GMT mtk02752
591 ** integrate with SD1 by invoking qmHandleMailboxRxMessage()
592 ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-16 17:32:33 GMT mtk02752
593 ** prepare code for invoking rxHandleMailboxRxMessage()
594 ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-11 10:36:08 GMT mtk01084
595 ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-09 22:56:41 GMT mtk01084
596 ** modify HW access routines
597 ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-10-30 18:17:20 GMT mtk01084
599 ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:54:57 GMT mtk01084
601 ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-10-23 16:08:30 GMT mtk01084
602 ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-10-13 21:59:12 GMT mtk01084
603 ** update for new HW design
604 ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-09-09 17:26:15 GMT mtk01084
605 ** modify for CFG_TEST_WITH_MT5921
606 ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-05-19 10:55:22 GMT mtk01461
607 ** Unmask the unused HISR
608 ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-05-18 15:59:13 GMT mtk01084
609 ** remove debug purpose code
610 ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-05-18 14:05:02 GMT mtk01084
611 ** update for WIFI ownback part on initial
612 ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-05-04 21:32:57 GMT mtk01084
613 ** add temporarily code to set driver own on adapter initialization
614 ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-28 10:35:41 GMT mtk01461
615 ** Add init of TX aggregation and fix RX STATUS is DW align for SDIO_STATUS_ENHANCE mode
616 ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-24 21:12:10 GMT mtk01104
617 ** Add function nicRestoreSpiDefMode()
618 ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-21 09:43:31 GMT mtk01461
619 ** Revise for MTK coding style - nicInitializeAdapter()
620 ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-17 19:52:47 GMT mtk01461
621 ** Update allocate Adapter Memory for MGMT Memory pool
622 ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:57:08 GMT mtk01461
623 ** Refine the order of release memory from pucRxCoalescingBufCached
624 ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-19 18:32:57 GMT mtk01084
625 ** update for basic power management functions
626 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 21:00:14 GMT mtk01426
627 ** Add CFG_SDIO_RX_ENHANCE support
628 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-16 09:10:27 GMT mtk01461
629 ** Update TX PATH API
630 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:25:59 GMT mtk01426
635 /*******************************************************************************
636 * C O M P I L E R F L A G S
637 ********************************************************************************
640 /*******************************************************************************
641 * E X T E R N A L R E F E R E N C E S
642 ********************************************************************************
647 /*******************************************************************************
649 ********************************************************************************
651 const UINT_8 aucPhyCfg2PhyTypeSet[PHY_CONFIG_NUM] =
653 PHY_TYPE_SET_802_11ABG, /* PHY_CONFIG_802_11ABG */
654 PHY_TYPE_SET_802_11BG, /* PHY_CONFIG_802_11BG */
655 PHY_TYPE_SET_802_11G, /* PHY_CONFIG_802_11G */
656 PHY_TYPE_SET_802_11A, /* PHY_CONFIG_802_11A */
657 PHY_TYPE_SET_802_11B, /* PHY_CONFIG_802_11B */
658 PHY_TYPE_SET_802_11ABGN, /* PHY_CONFIG_802_11ABGN */
659 PHY_TYPE_SET_802_11BGN, /* PHY_CONFIG_802_11BGN */
660 PHY_TYPE_SET_802_11AN, /* PHY_CONFIG_802_11AN */
661 PHY_TYPE_SET_802_11GN /* PHY_CONFIG_802_11GN */
664 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
665 #define REQ_GATING_ENABLE_H2D_INT BIT(31)
666 #define REQ_GATING_DISABLE_H2D_INT BIT(30)
667 #define ACK_GATING_ENABLE_D2H_INT BIT(31)
668 #define ACK_GATING_DISABLE_D2H_INT BIT(30)
670 #define GATING_CONTROL_POLL_LIMIT 64
673 /*******************************************************************************
675 ********************************************************************************
678 /*******************************************************************************
679 * P U B L I C D A T A
680 ********************************************************************************
683 static INT_EVENT_MAP_T arIntEventMapTable[] = {
684 {WHISR_ABNORMAL_INT, INT_EVENT_ABNORMAL},
685 {WHISR_D2H_SW_INT, INT_EVENT_SW_INT},
686 {WHISR_TX_DONE_INT, INT_EVENT_TX},
687 {(WHISR_RX0_DONE_INT | WHISR_RX1_DONE_INT), INT_EVENT_RX}
690 static const UINT_8 ucIntEventMapSize = (sizeof(arIntEventMapTable) / sizeof(INT_EVENT_MAP_T));
692 static IST_EVENT_FUNCTION apfnEventFuncTable[] = {
693 nicProcessAbnormalInterrupt, /*!< INT_EVENT_ABNORMAL */
694 nicProcessSoftwareInterrupt, /*!< INT_EVENT_SW_INT */
695 nicProcessTxInterrupt, /*!< INT_EVENT_TX */
696 nicProcessRxInterrupt, /*!< INT_EVENT_RX */
698 /*******************************************************************************
699 * P R I V A T E D A T A
700 ********************************************************************************
703 /*******************************************************************************
705 ********************************************************************************
707 /*! This macro is used to reduce coding errors inside nicAllocateAdapterMemory()
708 * and also enhance the readability.
710 #define LOCAL_NIC_ALLOCATE_MEMORY(pucMem, u4Size, eMemType, pucComment) \
712 DBGLOG(INIT, INFO, ("Allocating %ld bytes for %s.\n", u4Size, pucComment)); \
713 if ((pucMem = (PUINT_8)kalMemAlloc(u4Size, eMemType)) == (PUINT_8)NULL) { \
714 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for %s.\n", u4Size, pucComment)); \
717 ASSERT(((UINT_32)pucMem % 4) == 0); \
718 DBGLOG(INIT, INFO, ("Virtual Address = %08lx for %s.\n", (UINT_32)pucMem, pucComment)); \
723 /*******************************************************************************
724 * F U N C T I O N D E C L A R A T I O N S
725 ********************************************************************************
728 /*******************************************************************************
730 ********************************************************************************
734 /*----------------------------------------------------------------------------*/
736 * @brief This routine is responsible for the allocation of the data structures
737 * inside the Adapter structure, include:
739 * 2. Common coalescing buffer for TX PATH.
741 * @param prAdapter Pointer of Adapter Data Structure
743 * @retval WLAN_STATUS_SUCCESS - Has enough memory.
744 * @retval WLAN_STATUS_RESOURCES - Memory is not enough.
746 /*----------------------------------------------------------------------------*/
748 nicAllocateAdapterMemory (
749 IN P_ADAPTER_T prAdapter
752 WLAN_STATUS status = WLAN_STATUS_RESOURCES;
753 P_RX_CTRL_T prRxCtrl;
754 P_TX_CTRL_T prTxCtrl;
756 DEBUGFUNC("nicAllocateAdapterMemory");
759 prRxCtrl = &prAdapter->rRxCtrl;
760 prTxCtrl = &prAdapter->rTxCtrl;
763 //4 <0> Reset all Memory Handler
765 prAdapter->u4MemFreeDynamicCount = 0;
766 prAdapter->u4MemAllocDynamicCount = 0;
768 prAdapter->pucMgtBufCached = (PUINT_8)NULL;
769 prRxCtrl->pucRxCached = (PUINT_8)NULL;
770 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)NULL;
773 //4 <1> Memory for Management Memory Pool and CMD_INFO_T
774 /* Allocate memory for the CMD_INFO_T and its MGMT memory pool. */
775 prAdapter->u4MgtBufCachedSize = MGT_BUFFER_SIZE;
777 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter->pucMgtBufCached,
778 prAdapter->u4MgtBufCachedSize,
780 "COMMON MGMT MEMORY POOL");
782 //4 <2> Memory for RX Descriptor
783 /* Initialize the number of rx buffers we will have in our queue. */
784 /* <TODO> We may setup ucRxPacketDescriptors by GLUE Layer, and using
785 * this variable directly.
787 /* Allocate memory for the SW receive structures. */
788 prRxCtrl->u4RxCachedSize = CFG_RX_MAX_PKT_NUM * \
789 ALIGN_4(sizeof(SW_RFB_T));
791 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl->pucRxCached,
792 prRxCtrl->u4RxCachedSize,
796 //4 <3> Memory for TX DEscriptor
797 prTxCtrl->u4TxCachedSize = CFG_TX_MAX_PKT_NUM * \
798 ALIGN_4(sizeof(MSDU_INFO_T));
800 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl->pucTxCached,
801 prTxCtrl->u4TxCachedSize,
805 //4 <4> Memory for Common Coalescing Buffer
806 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
807 prAdapter->pucCoalescingBufCached = (PUINT_8)NULL;
809 /* Allocate memory for the common coalescing buffer. */
810 prAdapter->u4CoalescingBufCachedSize = CFG_COALESCING_BUFFER_SIZE > CFG_RX_COALESCING_BUFFER_SIZE ?
811 CFG_COALESCING_BUFFER_SIZE : CFG_RX_COALESCING_BUFFER_SIZE;
813 prAdapter->pucCoalescingBufCached =
814 kalAllocateIOBuffer(prAdapter->u4CoalescingBufCachedSize);
816 if(prAdapter->pucCoalescingBufCached == NULL) {
817 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for coalescing buffer.\n", prAdapter->u4CoalescingBufCachedSize));
820 #endif /* CFG_COALESCING_BUFFER_SIZE */
822 //4 <5> Memory for enhanced interrupt response
823 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
824 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
826 if(prAdapter->prSDIOCtrl == NULL) {
827 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for interrupt response.\n", sizeof(ENHANCE_MODE_DATA_STRUCT_T)));
831 status = WLAN_STATUS_SUCCESS;
836 if(status != WLAN_STATUS_SUCCESS) {
837 nicReleaseAdapterMemory(prAdapter);
842 } /* end of nicAllocateAdapterMemory() */
845 /*----------------------------------------------------------------------------*/
847 * @brief This routine is responsible for releasing the allocated memory by
848 * nicAllocatedAdapterMemory().
850 * @param prAdapter Pointer of Adapter Data Structure
854 /*----------------------------------------------------------------------------*/
856 nicReleaseAdapterMemory (
857 IN P_ADAPTER_T prAdapter
860 P_TX_CTRL_T prTxCtrl;
861 P_RX_CTRL_T prRxCtrl;
864 prTxCtrl = &prAdapter->rTxCtrl;
865 prRxCtrl = &prAdapter->rRxCtrl;
867 //4 <5> Memory for enhanced interrupt response
868 if (prAdapter->prSDIOCtrl) {
869 kalReleaseIOBuffer((PVOID)prAdapter->prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
870 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)NULL;
873 //4 <4> Memory for Common Coalescing Buffer
874 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
875 if (prAdapter->pucCoalescingBufCached) {
876 kalReleaseIOBuffer((PVOID)prAdapter->pucCoalescingBufCached, prAdapter->u4CoalescingBufCachedSize);
877 prAdapter->pucCoalescingBufCached = (PUINT_8)NULL;
879 #endif /* CFG_COALESCING_BUFFER_SIZE */
881 //4 <3> Memory for TX Descriptor
882 if (prTxCtrl->pucTxCached) {
883 kalMemFree((PVOID)prTxCtrl->pucTxCached,
885 prTxCtrl->u4TxCachedSize);
886 prTxCtrl->pucTxCached = (PUINT_8)NULL;
889 //4 <2> Memory for RX Descriptor
890 if (prRxCtrl->pucRxCached) {
891 kalMemFree((PVOID)prRxCtrl->pucRxCached,
893 prRxCtrl->u4RxCachedSize);
894 prRxCtrl->pucRxCached = (PUINT_8)NULL;
897 //4 <1> Memory for Management Memory Pool
898 if (prAdapter->pucMgtBufCached) {
899 kalMemFree((PVOID)prAdapter->pucMgtBufCached,
901 prAdapter->u4MgtBufCachedSize);
902 prAdapter->pucMgtBufCached = (PUINT_8)NULL;
906 /* Check if all allocated memories are free */
907 ASSERT(prAdapter->u4MemFreeDynamicCount ==
908 prAdapter->u4MemAllocDynamicCount);
915 /*----------------------------------------------------------------------------*/
917 * @brief disable global interrupt
919 * @param prAdapter pointer to the Adapter handler
923 /*----------------------------------------------------------------------------*/
925 nicDisableInterrupt (
926 IN P_ADAPTER_T prAdapter
931 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_CLR);
933 prAdapter->fgIsIntEnable = FALSE;
936 /*----------------------------------------------------------------------------*/
938 * @brief enable global interrupt
940 * @param prAdapter pointer to the Adapter handler
944 /*----------------------------------------------------------------------------*/
947 IN P_ADAPTER_T prAdapter
950 BOOLEAN fgIsIntEnableCache;
954 fgIsIntEnableCache = prAdapter->fgIsIntEnable;
956 prAdapter->fgIsIntEnable = TRUE; // NOTE(Kevin): It must be placed before MCR GINT write.
958 /* If need enable INT and also set LPOwn at the same time. */
959 if (prAdapter->fgIsIntEnableWithLPOwnSet) {
960 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE; /* NOTE(Kevin): It's better to place it
961 * before MCR GINT write.
963 /* If INT was enabled, only set LPOwn */
964 if (fgIsIntEnableCache) {
965 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET);
966 prAdapter->fgIsFwOwn = TRUE;
968 /* If INT was not enabled, enable it and also set LPOwn now */
970 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET |
972 prAdapter->fgIsFwOwn = TRUE;
975 /* If INT was not enabled, enable it now */
976 else if (!fgIsIntEnableCache) {
977 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_SET);
981 } /* end of nicEnableInterrupt() */
984 #if CFG_SDIO_INTR_ENHANCE
985 /*----------------------------------------------------------------------------*/
987 * @brief For SDIO enhance mode, set the max rx len and tx status
989 * @param prAdapter a pointer to adapter private data structure.
993 /*----------------------------------------------------------------------------*/
996 IN P_ADAPTER_T prAdapter
1003 //4 <1> Check STATUS Buffer is DW alignment.
1004 ASSERT( IS_ALIGN_4( (UINT_32)&prAdapter->prSDIOCtrl->u4WHISR ) );
1006 //4 <2> Setup STATUS count.
1008 HAL_MCR_RD(prAdapter, MCR_WHCR, &u4Value);
1010 //4 <2.1> Setup the number of maximum RX length to be report
1011 u4Value &= ~(WHCR_MAX_HIF_RX_LEN_NUM);
1012 u4Value |= ((SDIO_MAXIMUM_RX_LEN_NUM << WHCR_OFFSET_MAX_HIF_RX_LEN_NUM));
1014 //4 <2.2> Setup RX enhancement mode
1015 #if CFG_SDIO_RX_ENHANCE
1016 u4Value |= WHCR_RX_ENHANCE_MODE_EN;
1018 u4Value &= ~WHCR_RX_ENHANCE_MODE_EN;
1019 #endif /* CFG_SDIO_RX_AGG */
1021 HAL_MCR_WR(prAdapter, MCR_WHCR, u4Value);
1026 } /* end of nicSDIOInit() */
1028 /*----------------------------------------------------------------------------*/
1030 * @brief Read interrupt status from hardware
1032 * @param prAdapter pointer to the Adapter handler
1033 * @param the interrupts
1038 /*----------------------------------------------------------------------------*/
1040 nicSDIOReadIntStatus (
1041 IN P_ADAPTER_T prAdapter,
1042 OUT PUINT_32 pu4IntStatus
1045 P_SDIO_CTRL_T prSDIOCtrl;
1047 DEBUGFUNC("nicSDIOReadIntStatus");
1050 ASSERT(pu4IntStatus);
1052 prSDIOCtrl = prAdapter->prSDIOCtrl;
1055 HAL_PORT_RD(prAdapter,
1057 sizeof(ENHANCE_MODE_DATA_STRUCT_T),
1058 (PUINT_8)prSDIOCtrl,
1059 sizeof(ENHANCE_MODE_DATA_STRUCT_T));
1061 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
1062 || fgIsBusAccessFailed == TRUE) {
1068 if((prSDIOCtrl->u4WHISR & WHISR_TX_DONE_INT) == 0 &&
1069 (prSDIOCtrl->rTxInfo.au4WTSR[0] | prSDIOCtrl->rTxInfo.au4WTSR[1])) {
1070 prSDIOCtrl->u4WHISR |= WHISR_TX_DONE_INT;
1073 if((prSDIOCtrl->u4WHISR & BIT(31)) == 0 &&
1074 HAL_GET_MAILBOX_READ_CLEAR(prAdapter) == TRUE &&
1075 (prSDIOCtrl->u4RcvMailbox0 != 0 || prSDIOCtrl->u4RcvMailbox1 != 0)) {
1076 prSDIOCtrl->u4WHISR |= BIT(31);
1079 *pu4IntStatus = prSDIOCtrl->u4WHISR;
1082 } /* end of nicSDIOReadIntStatus() */
1085 /*----------------------------------------------------------------------------*/
1087 * @brief The function used to read interrupt status and then invoking
1088 * dispatching procedure for the appropriate functions
1089 * corresponding to specific interrupt bits
1091 * @param prAdapter pointer to the Adapter handler
1093 * @retval WLAN_STATUS_SUCCESS
1094 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1096 /*----------------------------------------------------------------------------*/
1099 IN P_ADAPTER_T prAdapter
1102 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1103 UINT_32 u4IntStatus = 0;
1106 DEBUGFUNC("nicProcessIST");
1107 //DBGLOG(INIT, LOUD, ("\n"));
1111 if (prAdapter->rAcpiState == ACPI_STATE_D3) {
1112 DBGLOG(REQ, WARN, ("Fail in set nicProcessIST! (Adapter not ready). ACPI=D%d, Radio=%d\n",
1113 prAdapter->rAcpiState, prAdapter->fgIsRadioOff));
1114 return WLAN_STATUS_ADAPTER_NOT_READY;
1117 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1118 if(prAdapter->fgIsClockGatingEnabled == TRUE) {
1119 nicDisableClockGating(prAdapter);
1123 for (i = 0; i < CFG_IST_LOOP_COUNT; i++) {
1125 #if CFG_SDIO_INTR_ENHANCE
1126 nicSDIOReadIntStatus(prAdapter, &u4IntStatus);
1128 HAL_MCR_RD(prAdapter, MCR_WHISR, &u4IntStatus);
1129 #endif /* CFG_SDIO_INTR_ENHANCE */
1131 //DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus));
1133 if (u4IntStatus & ~(WHIER_DEFAULT | WHIER_FW_OWN_BACK_INT_EN)) {
1134 DBGLOG(INTR, WARN, ("Un-handled HISR %#x, HISR = %#x (HIER:0x%x)\n",
1135 (u4IntStatus & ~WHIER_DEFAULT), u4IntStatus, WHIER_DEFAULT));
1136 u4IntStatus &= WHIER_DEFAULT;
1139 nicProcessIST_impl(prAdapter, u4IntStatus);
1141 if(u4IntStatus == 0) {
1143 u4Status = WLAN_STATUS_NOT_INDICATING;
1149 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1150 if(prAdapter->fgIsClockGatingEnabled == FALSE) {
1151 nicEnableClockGating(prAdapter);
1156 } /* end of nicProcessIST() */
1159 /*----------------------------------------------------------------------------*/
1161 * @brief The function used to dispatch the appropriate functions for specific
1164 * @param prAdapter pointer to the Adapter handler
1165 * u4IntStatus interrupt status bits
1167 * @retval WLAN_STATUS_SUCCESS
1168 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1170 /*----------------------------------------------------------------------------*/
1172 nicProcessIST_impl (
1173 IN P_ADAPTER_T prAdapter,
1174 IN UINT_32 u4IntStatus
1177 UINT_32 u4IntCount = 0;
1178 P_INT_EVENT_MAP_T prIntEventMap = NULL;
1182 prAdapter->u4IntStatus = u4IntStatus;
1184 /* Process each of the interrupt status consequently */
1185 prIntEventMap = &arIntEventMapTable[0];
1186 for (u4IntCount = 0; u4IntCount < ucIntEventMapSize; prIntEventMap++, u4IntCount++) {
1187 if (prIntEventMap->u4Int & prAdapter->u4IntStatus) {
1188 if(prIntEventMap->u4Event == INT_EVENT_RX &&
1189 prAdapter->fgIsEnterD3ReqIssued == TRUE) {
1192 else if (apfnEventFuncTable[prIntEventMap->u4Event] != NULL) {
1193 apfnEventFuncTable[prIntEventMap->u4Event](prAdapter);
1197 ("Empty INTR handler! ISAR bit#: %ld, event:%d, func: 0x%x\n",
1198 prIntEventMap->u4Int, prIntEventMap->u4Event, apfnEventFuncTable[prIntEventMap->u4Event]));
1200 ASSERT(0); // to trap any NULL interrupt handler
1202 prAdapter->u4IntStatus &= ~prIntEventMap->u4Int;
1206 return WLAN_STATUS_SUCCESS;
1207 } /* end of nicProcessIST_impl() */
1210 /*----------------------------------------------------------------------------*/
1212 * @brief Verify the CHIP ID
1214 * @param prAdapter a pointer to adapter private data structure.
1217 * @retval TRUE CHIP ID is the same as the setting compiled
1218 * @retval FALSE CHIP ID is different from the setting compiled
1220 /*----------------------------------------------------------------------------*/
1223 IN P_ADAPTER_T prAdapter
1230 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4CIR );
1232 DBGLOG(INIT, TRACE,("Chip ID: 0x%x\n", u4CIR & WCIR_CHIP_ID));
1233 DBGLOG(INIT, TRACE,("Revision ID: 0x%x\n", ((u4CIR & WCIR_REVISION_ID) >> 16)));
1235 if ((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV) {
1239 prAdapter->ucRevID = (UINT_8)(((u4CIR & WCIR_REVISION_ID) >> 16) & 0xF) ;
1244 /*----------------------------------------------------------------------------*/
1246 * @brief Initialize the MCR to the appropriate init value, and verify the init
1249 * @param prAdapter a pointer to adapter private data structure.
1253 /*----------------------------------------------------------------------------*/
1256 IN P_ADAPTER_T prAdapter
1262 //4 <0> Initial value
1267 IN P_ADAPTER_T prAdapter
1274 nicPutMailbox(prAdapter, 0, 0x52455345); // RESE
1275 nicPutMailbox(prAdapter, 1, 0x545F5746); // T_WF
1276 nicSetSwIntr(prAdapter, BIT(16));
1281 /*----------------------------------------------------------------------------*/
1283 * @brief Initialize the Adapter soft variable
1285 * @param prAdapter pointer to the Adapter handler
1290 /*----------------------------------------------------------------------------*/
1292 nicInitializeAdapter (
1293 IN P_ADAPTER_T prAdapter
1296 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1300 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE;
1303 if (!nicVerifyChipID(prAdapter)) {
1304 u4Status = WLAN_STATUS_FAILURE;
1309 nicMCRInit(prAdapter);
1311 #if CFG_SDIO_INTR_ENHANCE
1312 nicSDIOInit(prAdapter);
1313 #endif /* CFG_SDIO_INTR_ENHANCE */
1315 HAL_MCR_WR(prAdapter, MCR_WHIER, WHIER_DEFAULT);
1319 nicHifInit(prAdapter);
1328 #if defined(_HIF_SPI)
1329 /*----------------------------------------------------------------------------*/
1331 * \brief Restore the SPI Mode Select to default mode,
1332 * this is important while driver is unload, and this must be last mcr
1333 * since the operation will let the hif use 8bit mode access
1335 * \param[in] prAdapter a pointer to adapter private data structure.
1336 * \param[in] eGPIO2_Mode GPIO2 operation mode
1340 /*----------------------------------------------------------------------------*/
1342 nicRestoreSpiDefMode (
1343 IN P_ADAPTER_T prAdapter
1348 HAL_MCR_WR(prAdapter, MCR_WCSR, SPICSR_8BIT_MODE_DATA);
1353 /*----------------------------------------------------------------------------*/
1355 * @brief Process rx interrupt. When the rx
1356 * Interrupt is asserted, it means there are frames in queue.
1358 * @param prAdapter Pointer to the Adapter structure.
1362 /*----------------------------------------------------------------------------*/
1364 nicProcessAbnormalInterrupt (
1365 IN P_ADAPTER_T prAdapter
1370 HAL_MCR_RD(prAdapter, MCR_WASR, &u4Value);
1371 DBGLOG(REQ, WARN, ("MCR_WASR: 0x%x \n", u4Value));
1374 /*----------------------------------------------------------------------------*/
1378 * @param prAdapter Pointer to the Adapter structure.
1382 /*----------------------------------------------------------------------------*/
1384 nicProcessFwOwnBackInterrupt(
1385 IN P_ADAPTER_T prAdapter
1390 } /* end of nicProcessFwOwnBackInterrupt() */
1392 /*----------------------------------------------------------------------------*/
1396 * @param prAdapter Pointer to the Adapter structure.
1400 /*----------------------------------------------------------------------------*/
1402 nicProcessSoftwareInterrupt(
1403 IN P_ADAPTER_T prAdapter
1410 u4IntrBits = prAdapter->u4IntStatus & BITS(8, 31);
1412 if((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
1413 nicPrintFirmwareAssertInfo(prAdapter);
1414 #if CFG_CHIP_RESET_SUPPORT
1415 glSendResetRequest();
1419 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1420 ASSERT((u4IntrBits & (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT))
1421 != (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT));
1423 if(u4IntrBits & ACK_GATING_ENABLE_D2H_INT) {
1424 prAdapter->fgIsClockGatingEnabled = TRUE;
1427 if(u4IntrBits & ACK_GATING_DISABLE_D2H_INT) {
1428 prAdapter->fgIsClockGatingEnabled = FALSE;
1430 // Indicate Service Thread for TX
1431 if(kalGetTxPendingCmdCount(prAdapter->prGlueInfo) > 0
1432 || wlanGetTxPendingFrameCount(prAdapter) > 0) {
1433 kalSetEvent(prAdapter->prGlueInfo);
1438 DBGLOG(REQ, WARN, ("u4IntrBits: 0x%x \n", u4IntrBits));
1441 } /* end of nicProcessSoftwareInterrupt() */
1445 IN P_ADAPTER_T prAdapter,
1446 IN UINT_32 u4MailboxNum,
1450 if (u4MailboxNum == 0) {
1451 HAL_MCR_WR(prAdapter, MCR_H2DSM0R, u4Data);
1452 } else if (u4MailboxNum == 1) {
1453 HAL_MCR_WR(prAdapter, MCR_H2DSM1R, u4Data);
1461 IN P_ADAPTER_T prAdapter,
1462 IN UINT_32 u4MailboxNum,
1463 OUT PUINT_32 pu4Data
1466 if (u4MailboxNum == 0) {
1467 HAL_MCR_RD(prAdapter, MCR_D2HRM0R, pu4Data);
1468 } else if (u4MailboxNum == 1) {
1469 HAL_MCR_RD(prAdapter, MCR_D2HRM1R, pu4Data);
1477 IN P_ADAPTER_T prAdapter,
1478 IN UINT_32 u4SwIntrBitmap
1482 * SW interrup in HW bit 16 is mapping to SW bit 0 (shift 16bit in HW transparancy)
1483 * SW interrupt valid from b0~b15
1485 ASSERT((u4SwIntrBitmap & BITS(0, 15)) == 0);
1486 // DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap));
1488 HAL_MCR_WR(prAdapter, MCR_WSICR, u4SwIntrBitmap);
1492 /*----------------------------------------------------------------------------*/
1494 * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1495 * with specified sequential number
1497 * @param prAdapter Pointer of ADAPTER_T
1498 * ucSeqNum Sequential Number
1500 * @retval - P_CMD_INFO_T
1502 /*----------------------------------------------------------------------------*/
1504 nicGetPendingCmdInfo (
1505 IN P_ADAPTER_T prAdapter,
1511 P_QUE_T prTempCmdQue = &rTempCmdQue;
1512 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1513 P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T)NULL;
1515 GLUE_SPIN_LOCK_DECLARATION();
1519 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1521 prCmdQue = &prAdapter->rPendingCmdQueue;
1522 QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
1524 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1525 while (prQueueEntry) {
1526 prCmdInfo = (P_CMD_INFO_T)prQueueEntry;
1528 if(prCmdInfo->ucCmdSeqNum == ucSeqNum)
1531 QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
1536 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1538 QUEUE_CONCATENATE_QUEUES(prCmdQue, prTempCmdQue);
1540 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1546 /*----------------------------------------------------------------------------*/
1548 * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1549 * with specified sequential number
1551 * @param prAdapter Pointer of ADAPTER_T
1552 * ucSeqNum Sequential Number
1554 * @retval - P_MSDU_INFO_T
1556 /*----------------------------------------------------------------------------*/
1558 nicGetPendingTxMsduInfo (
1559 IN P_ADAPTER_T prAdapter,
1565 P_QUE_T prTempQue = &rTempQue;
1566 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1567 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1569 GLUE_SPIN_LOCK_DECLARATION();
1573 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1575 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1576 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1578 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1579 while (prQueueEntry) {
1580 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1582 if(prMsduInfo->ucTxSeqNum == ucSeqNum)
1585 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1590 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1592 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1594 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1600 nicGetPendingStaMMPDU (
1601 IN P_ADAPTER_T prAdapter,
1602 IN UINT_8 ucStaRecIdx
1605 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T)NULL;
1606 P_QUE_T prTxingQue = (P_QUE_T)NULL;
1608 P_QUE_T prTempQue = &rTempQue;
1609 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1610 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1612 GLUE_SPIN_LOCK_DECLARATION();
1614 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1616 if (prAdapter == NULL) {
1622 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1623 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1625 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1626 while (prQueueEntry) {
1627 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1629 if ((prMsduInfo->ucStaRecIndex == ucStaRecIdx) && (prMsduInfo->pfTxDoneHandler != NULL)) {
1630 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo,
1631 prMsduInfoListHead);
1632 prMsduInfoListHead = prMsduInfo;
1635 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1641 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1645 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1648 return prMsduInfoListHead;
1649 } /* nicGetPendingStaMMPDU */
1653 nicFreePendingTxMsduInfoByNetwork (
1654 IN P_ADAPTER_T prAdapter,
1655 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
1660 P_QUE_T prTempQue = &rTempQue;
1661 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1662 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T)NULL;
1663 P_MSDU_INFO_T prMsduInfoListTail = (P_MSDU_INFO_T)NULL;
1664 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1666 GLUE_SPIN_LOCK_DECLARATION();
1670 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1672 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1673 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1675 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1676 while (prQueueEntry) {
1677 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1679 if((ENUM_NETWORK_TYPE_INDEX_T)(prMsduInfo->ucNetworkType) == eNetworkType) {
1680 if(prMsduInfoListHead == NULL) {
1681 prMsduInfoListHead = prMsduInfoListTail = prMsduInfo;
1684 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail, prMsduInfo);
1685 prMsduInfoListTail = prMsduInfo;
1689 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1694 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1696 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1698 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1701 if(prMsduInfoListHead) {
1702 nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
1707 } /* end of nicFreePendingTxMsduInfoByNetwork() */
1711 /*----------------------------------------------------------------------------*/
1713 * @brief This procedure is used to retrieve a CMD sequence number atomically
1715 * @param prAdapter Pointer of ADAPTER_T
1719 /*----------------------------------------------------------------------------*/
1721 nicIncreaseCmdSeqNum (
1722 IN P_ADAPTER_T prAdapter
1727 KAL_SPIN_LOCK_DECLARATION();
1731 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1733 prAdapter->ucCmdSeqNum++;
1734 ucRetval = prAdapter->ucCmdSeqNum;
1736 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1742 /*----------------------------------------------------------------------------*/
1744 * @brief This procedure is used to retrieve a TX sequence number atomically
1746 * @param prAdapter Pointer of ADAPTER_T
1750 /*----------------------------------------------------------------------------*/
1752 nicIncreaseTxSeqNum (
1753 IN P_ADAPTER_T prAdapter
1758 KAL_SPIN_LOCK_DECLARATION();
1762 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1764 prAdapter->ucTxSeqNum++;
1765 ucRetval = prAdapter->ucTxSeqNum;
1767 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1774 /*----------------------------------------------------------------------------*/
1776 * @brief This utility function is used to handle
1777 * media state change event
1783 /*----------------------------------------------------------------------------*/
1785 nicMediaStateChange (
1786 IN P_ADAPTER_T prAdapter,
1787 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType,
1788 IN P_EVENT_CONNECTION_STATUS prConnectionStatus
1791 P_GLUE_INFO_T prGlueInfo;
1794 prGlueInfo = prAdapter->prGlueInfo;
1796 switch(eNetworkType) {
1797 case NETWORK_TYPE_AIS_INDEX:
1798 if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_DISCONNECTED) { // disconnected
1799 if(kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
1801 kalIndicateStatusAndComplete(prGlueInfo,
1802 WLAN_STATUS_MEDIA_DISCONNECT,
1806 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1809 /* reset buffered link quality information */
1810 prAdapter->fgIsLinkQualityValid = FALSE;
1811 prAdapter->fgIsLinkRateValid = FALSE;
1813 else if(prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_CONNECTED) { // connected
1814 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1816 // fill information for association result
1817 prAdapter->rWlanInfo.rCurrBssId.rSsid.u4SsidLen
1818 = prConnectionStatus->ucSsidLen;
1819 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.rSsid.aucSsid,
1820 prConnectionStatus->aucSsid,
1821 prConnectionStatus->ucSsidLen);
1822 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
1823 prConnectionStatus->aucBssid,
1825 prAdapter->rWlanInfo.rCurrBssId.u4Privacy
1826 = prConnectionStatus->ucEncryptStatus; // @FIXME
1827 prAdapter->rWlanInfo.rCurrBssId.rRssi
1829 prAdapter->rWlanInfo.rCurrBssId.eNetworkTypeInUse
1830 = PARAM_NETWORK_TYPE_AUTOMODE; //@FIXME
1831 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4BeaconPeriod
1832 = prConnectionStatus->u2BeaconPeriod;
1833 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4ATIMWindow
1834 = prConnectionStatus->u2ATIMWindow;
1835 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4DSConfig
1836 = prConnectionStatus->u4FreqInKHz;
1837 prAdapter->rWlanInfo.ucNetworkType
1838 = prConnectionStatus->ucNetworkType;
1839 prAdapter->rWlanInfo.rCurrBssId.eOpMode
1840 = (ENUM_PARAM_OP_MODE_T) prConnectionStatus->ucInfraMode;
1842 // always indicate to OS according to MSDN (re-association/roaming)
1843 kalIndicateStatusAndComplete(prGlueInfo,
1844 WLAN_STATUS_MEDIA_CONNECT,
1850 #if CFG_ENABLE_BT_OVER_WIFI
1851 case NETWORK_TYPE_BOW_INDEX:
1855 #if CFG_ENABLE_WIFI_DIRECT
1856 case NETWORK_TYPE_P2P_INDEX:
1863 return WLAN_STATUS_SUCCESS;
1864 } /* nicMediaStateChange */
1866 /*----------------------------------------------------------------------------*/
1868 * @brief This utility function is used to convert between
1869 * frequency and channel number
1871 * @param u4ChannelNum
1873 * @retval - Frequency in unit of KHz, 0 for invalid channel number
1875 /*----------------------------------------------------------------------------*/
1877 nicChannelNum2Freq (
1878 UINT_32 u4ChannelNum
1881 UINT_32 u4ChannelInMHz;
1883 if(u4ChannelNum >= 1 && u4ChannelNum <= 13) {
1884 u4ChannelInMHz = 2412 + (u4ChannelNum - 1) * 5;
1886 else if(u4ChannelNum == 14) {
1887 u4ChannelInMHz = 2484;
1889 else if(u4ChannelNum == 133) {
1890 u4ChannelInMHz = 3665; // 802.11y
1892 else if(u4ChannelNum == 137) {
1893 u4ChannelInMHz = 3685; // 802.11y
1895 else if(u4ChannelNum >= 34 && u4ChannelNum <= 165) {
1896 u4ChannelInMHz = 5000 + u4ChannelNum * 5;
1898 else if(u4ChannelNum >= 183 && u4ChannelNum <= 196) {
1899 u4ChannelInMHz = 4000 + u4ChannelNum * 5;
1905 return 1000 * u4ChannelInMHz;
1909 /*----------------------------------------------------------------------------*/
1911 * @brief This utility function is used to convert between
1912 * frequency and channel number
1914 * @param u4FreqInKHz
1916 * @retval - Frequency Number, 0 for invalid freqency
1918 /*----------------------------------------------------------------------------*/
1920 nicFreq2ChannelNum (
1924 switch(u4FreqInKHz) {
1954 return 133; // 802.11y
1956 return 137; // 802.11y
2043 /* firmware command wrapper */
2044 /* NETWORK (WIFISYS) */
2045 /*----------------------------------------------------------------------------*/
2047 * @brief This utility function is used to activate WIFISYS for specified network
2049 * @param prAdapter Pointer of ADAPTER_T
2050 * eNetworkTypeIdx Index of network type
2054 /*----------------------------------------------------------------------------*/
2057 IN P_ADAPTER_T prAdapter,
2058 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2061 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
2062 P_BSS_INFO_T prBssInfo;
2065 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2067 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2068 rCmdActivateCtrl.ucActive = 1;
2070 if (((UINT_8) eNetworkTypeIdx) < NETWORK_TYPE_INDEX_NUM) {
2071 prBssInfo = &prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx];
2072 prBssInfo->fg40mBwAllowed = FALSE;
2073 prBssInfo->fgAssoc40mBwAllowed = FALSE;
2076 return wlanSendSetQueryCmd(prAdapter,
2077 CMD_ID_BSS_ACTIVATE_CTRL,
2083 sizeof(CMD_BSS_ACTIVATE_CTRL),
2084 (PUINT_8)&rCmdActivateCtrl,
2090 /*----------------------------------------------------------------------------*/
2092 * @brief This utility function is used to deactivate WIFISYS for specified network
2094 * @param prAdapter Pointer of ADAPTER_T
2095 * eNetworkTypeIdx Index of network type
2099 /*----------------------------------------------------------------------------*/
2101 nicDeactivateNetwork(
2102 IN P_ADAPTER_T prAdapter,
2103 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2106 WLAN_STATUS u4Status;
2107 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
2110 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2112 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2113 rCmdActivateCtrl.ucActive = 0;
2115 u4Status = wlanSendSetQueryCmd(prAdapter,
2116 CMD_ID_BSS_ACTIVATE_CTRL,
2122 sizeof(CMD_BSS_ACTIVATE_CTRL),
2123 (PUINT_8)&rCmdActivateCtrl,
2127 /* free all correlated station records */
2128 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2129 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2130 nicFreePendingTxMsduInfoByNetwork(prAdapter, eNetworkTypeIdx);
2131 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2138 /*----------------------------------------------------------------------------*/
2140 * @brief This utility function is used to sync bss info with firmware
2141 * when a new BSS has been connected or disconnected
2143 * @param prAdapter Pointer of ADAPTER_T
2144 * eNetworkTypeIdx Index of BSS-INFO type
2148 /*----------------------------------------------------------------------------*/
2151 IN P_ADAPTER_T prAdapter,
2152 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2155 WLAN_STATUS u4Status;
2156 P_BSS_INFO_T prBssInfo;
2157 CMD_SET_BSS_INFO rCmdSetBssInfo;
2160 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2161 DBGLOG(INIT, LOUD, ("nicUpdateBss\n"));
2162 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2164 kalMemZero(&rCmdSetBssInfo, sizeof(CMD_SET_BSS_INFO));
2166 rCmdSetBssInfo.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2167 rCmdSetBssInfo.ucConnectionState = (UINT_8)prBssInfo->eConnectionState;
2168 rCmdSetBssInfo.ucCurrentOPMode = (UINT_8)prBssInfo->eCurrentOPMode;
2169 rCmdSetBssInfo.ucSSIDLen = (UINT_8)prBssInfo->ucSSIDLen;
2170 kalMemCopy(rCmdSetBssInfo.aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
2171 COPY_MAC_ADDR(rCmdSetBssInfo.aucBSSID, prBssInfo->aucBSSID);
2172 rCmdSetBssInfo.ucIsQBSS = (UINT_8)prBssInfo->fgIsQBSS;
2173 rCmdSetBssInfo.ucNonHTBasicPhyType = prBssInfo->ucNonHTBasicPhyType;
2174 rCmdSetBssInfo.u2OperationalRateSet = prBssInfo->u2OperationalRateSet;
2175 rCmdSetBssInfo.u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
2176 rCmdSetBssInfo.ucPhyTypeSet = prBssInfo->ucPhyTypeSet;
2177 #if CFG_ENABLE_WIFI_DIRECT
2178 if(prAdapter->fgIsP2PRegistered) {
2179 COPY_MAC_ADDR(rCmdSetBssInfo.aucOwnMac, prBssInfo->aucOwnMacAddr);
2183 rlmFillSyncCmdParam(&rCmdSetBssInfo.rBssRlmParam, prBssInfo);
2185 rCmdSetBssInfo.fgWapiMode = (UINT_8)FALSE;
2187 if(rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
2188 P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2190 rCmdSetBssInfo.ucAuthMode = (UINT_8)prConnSettings->eAuthMode;
2191 rCmdSetBssInfo.ucEncStatus = (UINT_8)prConnSettings->eEncStatus;
2192 rCmdSetBssInfo.fgWapiMode = (UINT_8)prConnSettings->fgWapiMode;
2194 #if CFG_ENABLE_BT_OVER_WIFI
2195 else if(rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX) {
2196 //P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2197 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2198 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2202 #if CFG_ENABLE_WIFI_DIRECT
2203 if(prAdapter->fgIsP2PRegistered) {
2204 if (prAdapter->rP2pFuncLkr.prKalP2pGetCipher &&
2205 prAdapter->rP2pFuncLkr.prKalP2pGetCipher(prAdapter->prGlueInfo)) {
2206 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2207 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2210 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_OPEN;
2211 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION_DISABLED;
2213 rCmdSetBssInfo.fgIsApMode = prAdapter->rP2pFuncLkr.prP2pFuncIsApMode(prAdapter->rWifiVar.prP2pFsmInfo);
2216 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2217 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2221 if(eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX &&
2222 prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
2223 prBssInfo->prStaRecOfAP != NULL) {
2224 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2226 cnmAisInfraConnectNotify(prAdapter);
2228 #if CFG_ENABLE_WIFI_DIRECT
2229 else if ((prAdapter->fgIsP2PRegistered) &&
2230 (eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) &&
2231 (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) &&
2232 (prBssInfo->prStaRecOfAP != NULL)) {
2233 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2237 #if CFG_ENABLE_BT_OVER_WIFI
2238 else if (eNetworkTypeIdx == NETWORK_TYPE_BOW_INDEX &&
2239 prBssInfo->eCurrentOPMode == OP_MODE_BOW &&
2240 prBssInfo->prStaRecOfAP != NULL) {
2241 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2245 rCmdSetBssInfo.ucStaRecIdxOfAP = 0;
2248 DBGLOG(REQ, TRACE, ("SET_BSS_INFO auth=%d, enc=%d\n", rCmdSetBssInfo.ucAuthMode, rCmdSetBssInfo.ucEncStatus));
2251 u4Status = wlanSendSetQueryCmd(prAdapter,
2252 CMD_ID_SET_BSS_INFO,
2258 sizeof(CMD_SET_BSS_INFO),
2259 (PUINT_8)&rCmdSetBssInfo,
2263 /* if BSS-INFO is going to be disconnected state, free all correlated station records */
2264 if(prBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
2265 /* clear client list */
2266 bssClearClientList(prAdapter, prBssInfo);
2268 /* free all correlated station records */
2269 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2270 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2271 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2272 DBGLOG(INIT, LOUD, ("free all correlated station records\n"));
2279 /* BSS-INFO Indication (PM) */
2280 /*----------------------------------------------------------------------------*/
2282 * @brief This utility function is used to indicate PM that
2283 * a BSS has been created. (for AdHoc / P2P-GO)
2285 * @param prAdapter Pointer of ADAPTER_T
2286 * eNetworkTypeIdx Index of BSS-INFO
2290 /*----------------------------------------------------------------------------*/
2292 nicPmIndicateBssCreated(
2293 IN P_ADAPTER_T prAdapter,
2294 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2297 P_BSS_INFO_T prBssInfo;
2298 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated;
2301 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2303 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2305 rCmdIndicatePmBssCreated.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2306 rCmdIndicatePmBssCreated.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2307 rCmdIndicatePmBssCreated.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2308 rCmdIndicatePmBssCreated.u2AtimWindow = prBssInfo->u2ATIMWindow;
2310 return wlanSendSetQueryCmd(prAdapter,
2311 CMD_ID_INDICATE_PM_BSS_CREATED,
2317 sizeof(CMD_INDICATE_PM_BSS_CREATED),
2318 (PUINT_8)&rCmdIndicatePmBssCreated,
2324 /*----------------------------------------------------------------------------*/
2326 * @brief This utility function is used to indicate PM that
2327 * a BSS has been connected
2329 * @param prAdapter Pointer of ADAPTER_T
2330 * eNetworkTypeIdx Index of BSS-INFO
2334 /*----------------------------------------------------------------------------*/
2336 nicPmIndicateBssConnected(
2337 IN P_ADAPTER_T prAdapter,
2338 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2341 P_BSS_INFO_T prBssInfo;
2342 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected;
2345 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2347 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2349 rCmdIndicatePmBssConnected.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2350 rCmdIndicatePmBssConnected.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2351 rCmdIndicatePmBssConnected.u2AssocId = prBssInfo->u2AssocId;
2352 rCmdIndicatePmBssConnected.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2353 rCmdIndicatePmBssConnected.u2AtimWindow = prBssInfo->u2ATIMWindow;
2355 rCmdIndicatePmBssConnected.ucBmpDeliveryAC = prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC;
2356 rCmdIndicatePmBssConnected.ucBmpTriggerAC = prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC;
2358 //DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x",
2359 //rCmdIndicatePmBssConnected.ucBmpDeliveryAC,
2360 //rCmdIndicatePmBssConnected.ucBmpTriggerAC);
2362 if ((eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX)
2363 #if CFG_ENABLE_WIFI_DIRECT
2364 || ((eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->fgIsP2PRegistered))
2367 if(prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
2368 rCmdIndicatePmBssConnected.fgIsUapsdConnection = (UINT_8)prBssInfo->prStaRecOfAP->fgIsUapsdSupported;
2371 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0; //@FIXME
2375 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0;
2378 return wlanSendSetQueryCmd(prAdapter,
2379 CMD_ID_INDICATE_PM_BSS_CONNECTED,
2385 sizeof(CMD_INDICATE_PM_BSS_CONNECTED),
2386 (PUINT_8)&rCmdIndicatePmBssConnected,
2392 /*----------------------------------------------------------------------------*/
2394 * @brief This utility function is used to indicate PM that
2395 * a BSS has been disconnected
2397 * @param prAdapter Pointer of ADAPTER_T
2398 * eNetworkTypeIdx Index of BSS-INFO
2402 /*----------------------------------------------------------------------------*/
2404 nicPmIndicateBssAbort(
2405 IN P_ADAPTER_T prAdapter,
2406 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2409 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort;
2412 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2414 rCmdIndicatePmBssAbort.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2416 return wlanSendSetQueryCmd(prAdapter,
2417 CMD_ID_INDICATE_PM_BSS_ABORT,
2423 sizeof(CMD_INDICATE_PM_BSS_ABORT),
2424 (PUINT_8)&rCmdIndicatePmBssAbort,
2430 nicConfigPowerSaveProfile (
2431 IN P_ADAPTER_T prAdapter,
2432 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2433 PARAM_POWER_MODE ePwrMode,
2434 BOOLEAN fgEnCmdEvent
2437 DEBUGFUNC("nicConfigPowerSaveProfile");
2438 DBGLOG(INIT, TRACE, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2439 eNetTypeIndex, ePwrMode, fgEnCmdEvent));
2443 if (eNetTypeIndex >= NETWORK_TYPE_INDEX_NUM) {
2445 return WLAN_STATUS_NOT_SUPPORTED;
2448 // prAdapter->rWlanInfo.ePowerSaveMode.ucNetTypeIndex = eNetTypeIndex;
2449 // prAdapter->rWlanInfo.ePowerSaveMode.ucPsProfile = (UINT_8)ePwrMode;
2450 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucNetTypeIndex = eNetTypeIndex;
2451 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucPsProfile = (UINT_8)ePwrMode;
2453 return wlanSendSetQueryCmd(prAdapter,
2454 CMD_ID_POWER_SAVE_MODE,
2458 (fgEnCmdEvent ? nicCmdEventSetCommon : NULL),
2459 (fgEnCmdEvent ? nicOidCmdTimeoutCommon : NULL),
2460 sizeof(CMD_PS_PROFILE_T),
2461 (PUINT_8)&(prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex]),
2463 sizeof(PARAM_POWER_MODE)
2466 } /* end of wlanoidSetAcpiDevicePowerStateMode() */
2468 /*----------------------------------------------------------------------------*/
2470 * @brief This utility function is used to indicate firmware domain
2471 * for beacon generation parameters
2473 * @param prAdapter Pointer of ADAPTER_T
2474 * eIeUpdMethod, Update Method
2475 * eNetTypeIndex Index of Network
2476 * u2Capability Capability
2477 * aucIe Pointer to buffer of IEs
2478 * u2IELen Length of IEs
2480 * @retval - WLAN_STATUS_SUCCESS
2481 * WLAN_STATUS_FAILURE
2482 * WLAN_STATUS_PENDING
2483 * WLAN_STATUS_INVALID_DATA
2485 /*----------------------------------------------------------------------------*/
2487 nicUpdateBeaconIETemplate (
2488 IN P_ADAPTER_T prAdapter,
2489 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod,
2490 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2491 IN UINT_16 u2Capability,
2496 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate;
2497 UINT_16 u2CmdBufLen = 0;
2498 P_GLUE_INFO_T prGlueInfo;
2499 P_CMD_INFO_T prCmdInfo;
2500 P_WIFI_CMD_T prWifiCmd;
2503 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2504 DBGLOG(INIT, LOUD, ("\n"));
2507 prGlueInfo = prAdapter->prGlueInfo;
2509 if (u2IELen > MAX_IE_LENGTH) {
2510 return WLAN_STATUS_INVALID_DATA;
2513 if (eIeUpdMethod == IE_UPD_METHOD_UPDATE_RANDOM
2514 || eIeUpdMethod == IE_UPD_METHOD_UPDATE_ALL) {
2515 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, aucIE) + u2IELen;
2517 else if (eIeUpdMethod == IE_UPD_METHOD_DELETE_ALL) {
2518 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, u2IELen);
2522 return WLAN_STATUS_FAILURE;
2525 // prepare command info
2526 prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u2CmdBufLen));
2528 DBGLOG(INIT, ERROR, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2529 return WLAN_STATUS_FAILURE;
2532 // increase command sequence number
2533 ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
2534 DBGLOG(REQ, TRACE, ("ucCmdSeqNum =%d\n", ucCmdSeqNum));
2536 // Setup common CMD Info Packet
2537 prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
2538 prCmdInfo->eNetworkType = eNetTypeIndex;
2539 prCmdInfo->u2InfoBufLen = (UINT_16)(CMD_HDR_SIZE + u2CmdBufLen);
2540 prCmdInfo->pfCmdDoneHandler = NULL; //@FIXME
2541 prCmdInfo->pfCmdTimeoutHandler = NULL; //@FIXME
2542 prCmdInfo->fgIsOid = FALSE;
2543 prCmdInfo->ucCID = CMD_ID_UPDATE_BEACON_CONTENT;
2544 prCmdInfo->fgSetQuery = TRUE;
2545 prCmdInfo->fgNeedResp = FALSE;
2546 prCmdInfo->fgDriverDomainMCR = FALSE;
2547 prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
2548 prCmdInfo->u4SetInfoLen = u2CmdBufLen;
2549 prCmdInfo->pvInformationBuffer = NULL;
2550 prCmdInfo->u4InformationBufferLength = 0;
2552 // Setup WIFI_CMD_T (no payload)
2553 prWifiCmd = (P_WIFI_CMD_T)(prCmdInfo->pucInfoBuffer);
2554 prWifiCmd->u2TxByteCount_UserPriority = prCmdInfo->u2InfoBufLen;
2555 prWifiCmd->ucCID = prCmdInfo->ucCID;
2556 prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
2557 prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
2559 prCmdBcnUpdate = (P_CMD_BEACON_TEMPLATE_UPDATE)(prWifiCmd->aucBuffer);
2561 // fill beacon updating command
2562 prCmdBcnUpdate->ucUpdateMethod = (UINT_8) eIeUpdMethod;
2563 prCmdBcnUpdate->ucNetTypeIndex = (UINT_8) eNetTypeIndex;
2564 prCmdBcnUpdate->u2Capability = u2Capability;
2565 prCmdBcnUpdate->u2IELen = u2IELen;
2567 kalMemCopy(prCmdBcnUpdate->aucIE, aucIe, u2IELen);
2570 // insert into prCmdQueue
2571 kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T)prCmdInfo);
2573 // wakeup txServiceThread later
2574 GLUE_SET_EVENT(prGlueInfo);
2575 DBGLOG(INIT, LOUD, ("Command ID = 0x%08X\n", prCmdInfo->ucCID));
2576 return WLAN_STATUS_PENDING;
2580 /*----------------------------------------------------------------------------*/
2582 * @brief This utility function is used to initialization PHY related
2585 * @param prAdapter Pointer of ADAPTER_T
2589 /*----------------------------------------------------------------------------*/
2591 nicSetAvailablePhyTypeSet (
2592 IN P_ADAPTER_T prAdapter
2595 P_CONNECTION_SETTINGS_T prConnSettings;
2599 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2601 if (prConnSettings->eDesiredPhyConfig >= PHY_CONFIG_NUM) {
2606 prAdapter->rWifiVar.ucAvailablePhyTypeSet =
2607 aucPhyCfg2PhyTypeSet[prConnSettings->eDesiredPhyConfig];
2609 if (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_BIT_ERP) {
2610 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_ERP_INDEX;
2612 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2613 else /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */ {
2614 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_HR_DSSS_INDEX;
2621 /*----------------------------------------------------------------------------*/
2623 * @brief This utility function is used to update WMM Parms
2625 * @param prAdapter Pointer of ADAPTER_T
2626 * eNetworkTypeIdx Index of BSS-INFO
2630 /*----------------------------------------------------------------------------*/
2632 nicQmUpdateWmmParms(
2633 IN P_ADAPTER_T prAdapter,
2634 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2637 P_BSS_INFO_T prBssInfo;
2638 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms;
2641 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2643 DBGLOG(QM, EVENT, ("sizeof(AC_QUE_PARMS_T): %d \n", sizeof(AC_QUE_PARMS_T)));
2644 DBGLOG(QM, EVENT, ("sizeof(CMD_UPDATE_WMM_PARMS): %d \n", sizeof(CMD_UPDATE_WMM_PARMS_T)));
2645 DBGLOG(QM, EVENT, ("sizeof(WIFI_CMD_T): %d \n", sizeof(WIFI_CMD_T)));
2647 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2648 rCmdUpdateWmmParms.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2649 kalMemCopy(&rCmdUpdateWmmParms.arACQueParms[0], &prBssInfo->arACQueParms[0],
2650 (sizeof(AC_QUE_PARMS_T)*AC_NUM));
2652 rCmdUpdateWmmParms.fgIsQBSS = prBssInfo->fgIsQBSS;
2654 return wlanSendSetQueryCmd(prAdapter,
2655 CMD_ID_UPDATE_WMM_PARMS,
2661 sizeof(CMD_UPDATE_WMM_PARMS_T),
2662 (PUINT_8)&rCmdUpdateWmmParms,
2668 /*----------------------------------------------------------------------------*/
2670 * @brief This utility function is used to update TX power gain corresponding to
2671 * each band/modulation combination
2673 * @param prAdapter Pointer of ADAPTER_T
2674 * prTxPwrParam Pointer of TX power parameters
2676 * @retval WLAN_STATUS_PENDING
2677 * WLAN_STATUS_FAILURE
2679 /*----------------------------------------------------------------------------*/
2682 IN P_ADAPTER_T prAdapter,
2683 IN P_CMD_TX_PWR_T prTxPwrParam
2686 DEBUGFUNC("nicUpdateTxPower");
2690 return wlanSendSetQueryCmd(prAdapter,
2697 sizeof(CMD_TX_PWR_T),
2698 (PUINT_8)prTxPwrParam,
2704 /*----------------------------------------------------------------------------*/
2706 * @brief This utility function is used to update power offset around 5GHz band
2708 * @param prAdapter Pointer of ADAPTER_T
2709 * pr5GPwrOffset Pointer of 5GHz power offset parameter
2711 * @retval WLAN_STATUS_PENDING
2712 * WLAN_STATUS_FAILURE
2714 /*----------------------------------------------------------------------------*/
2717 IN P_ADAPTER_T prAdapter,
2718 IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset
2721 DEBUGFUNC("nicUpdate5GOffset");
2725 return wlanSendSetQueryCmd(prAdapter,
2726 CMD_ID_SET_5G_PWR_OFFSET,
2732 sizeof(CMD_5G_PWR_OFFSET_T),
2733 (PUINT_8)pr5GPwrOffset,
2739 /*----------------------------------------------------------------------------*/
2741 * @brief This utility function is used to update DPD calibration result
2743 * @param prAdapter Pointer of ADAPTER_T
2744 * pr5GPwrOffset Pointer of parameter for DPD calibration result
2746 * @retval WLAN_STATUS_PENDING
2747 * WLAN_STATUS_FAILURE
2749 /*----------------------------------------------------------------------------*/
2752 IN P_ADAPTER_T prAdapter,
2753 IN P_CMD_PWR_PARAM_T prDpdCalResult
2756 DEBUGFUNC("nicUpdateDPD");
2760 return wlanSendSetQueryCmd(prAdapter,
2761 CMD_ID_SET_PWR_PARAM,
2767 sizeof(CMD_PWR_PARAM_T),
2768 (PUINT_8)prDpdCalResult,
2774 /*----------------------------------------------------------------------------*/
2776 * @brief This utility function starts system service such as timer and
2779 * @param prAdapter Pointer of ADAPTER_T
2783 /*----------------------------------------------------------------------------*/
2785 nicInitSystemService (
2786 IN P_ADAPTER_T prAdapter
2791 // <1> Initialize MGMT Memory pool and STA_REC
2792 cnmMemInit(prAdapter);
2793 cnmStaRecInit(prAdapter);
2794 cmdBufInitialize(prAdapter);
2796 // <2> Mailbox Initialization
2797 mboxInitialize(prAdapter);
2799 // <3> Timer Initialization
2800 cnmTimerInitialize(prAdapter);
2806 /*----------------------------------------------------------------------------*/
2808 * @brief This utility function reset some specific system service,
2811 * @param prAdapter Pointer of ADAPTER_T
2815 /*----------------------------------------------------------------------------*/
2817 nicResetSystemService (
2818 IN P_ADAPTER_T prAdapter
2825 /*----------------------------------------------------------------------------*/
2827 * @brief This utility function is used to update WMM Parms
2829 * @param prAdapter Pointer of ADAPTER_T
2833 /*----------------------------------------------------------------------------*/
2835 nicUninitSystemService (
2836 IN P_ADAPTER_T prAdapter
2841 /* Timer Destruction */
2842 cnmTimerDestroy(prAdapter);
2844 /* Mailbox Destruction */
2845 mboxDestroy(prAdapter);
2851 /*----------------------------------------------------------------------------*/
2853 * @brief This utility function is used to update WMM Parms
2855 * @param prAdapter Pointer of ADAPTER_T
2859 /*----------------------------------------------------------------------------*/
2862 IN P_ADAPTER_T prAdapter,
2863 IN P_REG_INFO_T prRegInfo
2868 /* CNM Module - initialization */
2871 /* RLM Module - initialization */
2872 rlmFsmEventInit(prAdapter);
2874 /* SCN Module - initialization */
2877 /* AIS Module - intiailization */
2878 aisInitializeConnectionSettings(prAdapter, prRegInfo);
2879 aisFsmInit(prAdapter);
2881 #if CFG_SUPPORT_ROAMING
2882 /* Roaming Module - intiailization */
2883 roamingFsmInit(prAdapter);
2884 #endif /* CFG_SUPPORT_ROAMING */
2886 #if CFG_SUPPORT_SWCR
2887 swCrDebugInit(prAdapter);
2888 #endif /* CFG_SUPPORT_SWCR */
2894 /*----------------------------------------------------------------------------*/
2896 * @brief This utility function is used to update WMM Parms
2898 * @param prAdapter Pointer of ADAPTER_T
2902 /*----------------------------------------------------------------------------*/
2905 IN P_ADAPTER_T prAdapter
2910 #if CFG_SUPPORT_SWCR
2911 swCrDebugUninit(prAdapter);
2912 #endif /* CFG_SUPPORT_SWCR */
2914 #if CFG_SUPPORT_ROAMING
2915 /* Roaming Module - unintiailization */
2916 roamingFsmUninit(prAdapter);
2917 #endif /* CFG_SUPPORT_ROAMING */
2919 /* AIS Module - unintiailization */
2920 aisFsmUninit(prAdapter);
2922 /* SCN Module - unintiailization */
2923 scnUninit(prAdapter);
2925 /* RLM Module - uninitialization */
2926 rlmFsmEventUninit(prAdapter);
2928 /* CNM Module - uninitialization */
2929 cnmUninit(prAdapter);
2935 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2936 /*----------------------------------------------------------------------------*/
2938 * @brief This utility function is to inform firmware to enable MCU clock gating
2940 * @param prAdapter Pointer of ADAPTER_T
2944 /*----------------------------------------------------------------------------*/
2946 nicEnableClockGating (
2947 IN P_ADAPTER_T prAdapter
2950 UINT_32 i, u4WHISR = 0;
2954 if(prAdapter->fgIsClockGatingEnabled == TRUE) {
2955 return WLAN_STATUS_SUCCESS;
2958 nicSetSwIntr(prAdapter, REQ_GATING_ENABLE_H2D_INT);
2961 while(i < GATING_CONTROL_POLL_LIMIT) {
2962 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
2963 || fgIsBusAccessFailed == TRUE) {
2964 return WLAN_STATUS_FAILURE;
2967 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
2969 if(u4WHISR & ACK_GATING_ENABLE_D2H_INT) {
2970 prAdapter->fgIsClockGatingEnabled = TRUE;
2971 return WLAN_STATUS_SUCCESS;
2976 return WLAN_STATUS_PENDING;
2981 /*----------------------------------------------------------------------------*/
2983 * @brief This utility function is to inform firmware to disable MCU clock gating
2985 * @param prAdapter Pointer of ADAPTER_T
2989 /*----------------------------------------------------------------------------*/
2991 nicDisableClockGating (
2992 IN P_ADAPTER_T prAdapter
2995 UINT_32 i, u4WHISR = 0;
2999 if(prAdapter->fgIsClockGatingEnabled == FALSE) {
3000 return WLAN_STATUS_SUCCESS;
3003 nicSetSwIntr(prAdapter, REQ_GATING_DISABLE_H2D_INT);
3006 while(i < GATING_CONTROL_POLL_LIMIT) {
3007 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
3008 || fgIsBusAccessFailed == TRUE) {
3009 return WLAN_STATUS_FAILURE;
3012 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
3014 if(u4WHISR & ACK_GATING_DISABLE_D2H_INT) {
3015 prAdapter->fgIsClockGatingEnabled = FALSE;
3016 return WLAN_STATUS_SUCCESS;
3021 return WLAN_STATUS_PENDING;
3027 /*----------------------------------------------------------------------------*/
3029 * @brief This function is invoked to buffer scan result
3031 * @param prAdapter Pointer to the Adapter structure.
3032 * @param rMacAddr BSSID
3033 * @param prSsid Pointer to SSID
3034 * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
3035 * @param rRssi Received Strength (-10 ~ -200 dBm)
3036 * @param eNetworkType Network Type (a/b/g)
3037 * @param prConfiguration Network Parameter
3038 * @param eOpMode Infra/Ad-Hoc
3039 * @param rSupportedRates Supported basic rates
3040 * @param u2IELength IE Length
3041 * @param pucIEBuf Pointer to Information Elements(IEs)
3045 /*----------------------------------------------------------------------------*/
3048 IN P_ADAPTER_T prAdapter,
3049 IN PARAM_MAC_ADDRESS rMacAddr,
3050 IN P_PARAM_SSID_T prSsid,
3051 IN UINT_32 u4Privacy,
3052 IN PARAM_RSSI rRssi,
3053 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType,
3054 IN P_PARAM_802_11_CONFIG_T prConfiguration,
3055 IN ENUM_PARAM_OP_MODE_T eOpMode,
3056 IN PARAM_RATES_EX rSupportedRates,
3057 IN UINT_16 u2IELength,
3063 UINT_32 u4IdxWeakest = 0;
3064 PARAM_RSSI rWeakestRssi;
3065 UINT_32 u4BufferSize;
3069 rWeakestRssi = (PARAM_RSSI)INT_MAX;
3070 u4BufferSize = sizeof(prAdapter->rWlanInfo.aucScanIEBuf) / sizeof(prAdapter->rWlanInfo.aucScanIEBuf[0]);
3074 // decide to replace or add
3075 for(i = 0 ; i < prAdapter->rWlanInfo.u4ScanResultNum ; i++) {
3076 // find weakest entry && not connected one
3077 if(UNEQUAL_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, prAdapter->rWlanInfo.rCurrBssId.arMacAddress)
3078 && prAdapter->rWlanInfo.arScanResult[i].rRssi < rWeakestRssi) {
3080 rWeakestRssi = prAdapter->rWlanInfo.arScanResult[i].rRssi;
3083 if(prAdapter->rWlanInfo.arScanResult[i].eOpMode == eOpMode &&
3084 EQUAL_MAC_ADDR(&(prAdapter->rWlanInfo.arScanResult[i].arMacAddress), rMacAddr) &&
3085 (EQUAL_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3086 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3089 || prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen == 0)) {
3093 // free IE buffer then zero
3094 nicFreeScanResultIE(prAdapter, i);
3095 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]), OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3098 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3099 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3100 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3101 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3102 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3105 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3106 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3107 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3108 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3110 sizeof(PARAM_802_11_CONFIG_T));
3111 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3112 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3114 sizeof(PARAM_RATES_EX));
3115 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3117 // IE - allocate buffer and update pointer
3118 if(u2IELength > 0) {
3119 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3120 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3124 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3125 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3127 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3130 // buffer is not enough
3131 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3132 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3133 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3137 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3144 if (bReplace == FALSE) {
3145 if (prAdapter->rWlanInfo.u4ScanResultNum < (CFG_MAX_NUM_BSS_LIST - 1)) {
3146 i = prAdapter->rWlanInfo.u4ScanResultNum;
3149 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3150 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3153 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3154 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3155 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3156 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3157 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3160 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3161 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3162 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3163 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3165 sizeof(PARAM_802_11_CONFIG_T));
3166 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3167 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3169 sizeof(PARAM_RATES_EX));
3170 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3172 // IE - allocate buffer and update pointer
3173 if(u2IELength > 0) {
3174 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3175 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3179 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3180 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3182 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3185 // buffer is not enough
3186 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3187 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3188 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3192 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3195 prAdapter->rWlanInfo.u4ScanResultNum++;
3197 else if(rWeakestRssi != (PARAM_RSSI)INT_MAX) {
3198 // replace weakest one
3201 // free IE buffer then zero
3202 nicFreeScanResultIE(prAdapter, i);
3203 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3204 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3207 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3208 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3209 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3210 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3211 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3214 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3215 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3216 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3217 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3219 sizeof(PARAM_802_11_CONFIG_T));
3220 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3221 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3223 sizeof(PARAM_RATES_EX));
3224 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3226 if(u2IELength > 0) {
3227 // IE - allocate buffer and update pointer
3228 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3229 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3233 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3234 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3236 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3239 // buffer is not enough
3240 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3241 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3242 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3246 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3253 /*----------------------------------------------------------------------------*/
3255 * @brief This function is invoked to free IE buffer for dedicated scan result
3257 * @param prAdapter Pointer to the Adapter structure.
3258 * @param u4Idx Index of Scan Result
3262 /*----------------------------------------------------------------------------*/
3264 nicFreeScanResultIE (
3265 IN P_ADAPTER_T prAdapter,
3270 PUINT_8 pucPivot, pucMovePivot;
3271 UINT_32 u4MoveSize, u4FreeSize, u4ReserveSize;
3274 ASSERT(u4Idx < CFG_MAX_NUM_BSS_LIST);
3276 if(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength == 0
3277 || prAdapter->rWlanInfo.apucScanResultIEs[u4Idx] == NULL) {
3281 u4FreeSize = ALIGN_4(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength);
3283 pucPivot = prAdapter->rWlanInfo.apucScanResultIEs[u4Idx];
3284 pucMovePivot = (PUINT_8)((UINT_32)(prAdapter->rWlanInfo.apucScanResultIEs[u4Idx]) + u4FreeSize);
3286 u4ReserveSize = ((UINT_32)pucPivot) - (UINT_32)(&(prAdapter->rWlanInfo.aucScanIEBuf[0]));
3287 u4MoveSize = prAdapter->rWlanInfo.u4ScanIEBufferUsage - u4ReserveSize - u4FreeSize;
3289 // 1. rest of buffer to move forward
3290 kalMemCopy(pucPivot, pucMovePivot, u4MoveSize);
3292 // 1.1 modify pointers
3293 for(i = 0 ; i < prAdapter->rWlanInfo.u4ScanResultNum ; i++) {
3295 if(prAdapter->rWlanInfo.apucScanResultIEs[i] >= pucMovePivot) {
3296 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3297 (PUINT_8)((UINT_32)(prAdapter->rWlanInfo.apucScanResultIEs[i]) - u4FreeSize);
3302 // 1.2 reset the freed one
3303 prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength = 0;
3304 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3306 // 2. reduce IE buffer usage
3307 prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4FreeSize;
3313 /*----------------------------------------------------------------------------*/
3315 * @brief This function is to hack parameters for WLAN TABLE for
3316 * fixed rate settings
3318 * @param prAdapter Pointer to the Adapter structure.
3319 * @param eRateSetting
3320 * @param pu2DesiredNonHTRateSet,
3321 * @param pu2BSSBasicRateSet,
3323 * @param pucSupMcs32
3324 * @param pu2HtCapInfo
3326 * @return WLAN_STATUS_SUCCESS
3328 /*----------------------------------------------------------------------------*/
3330 nicUpdateRateParams (
3331 IN P_ADAPTER_T prAdapter,
3332 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting,
3333 IN PUINT_8 pucDesiredPhyTypeSet,
3334 IN PUINT_16 pu2DesiredNonHTRateSet,
3335 IN PUINT_16 pu2BSSBasicRateSet,
3336 IN PUINT_8 pucMcsSet,
3337 IN PUINT_8 pucSupMcs32,
3338 IN PUINT_16 pu2HtCapInfo
3342 ASSERT(eRateSetting > FIXED_RATE_NONE && eRateSetting < FIXED_RATE_NUM);
3344 switch(prAdapter->rWifiVar.eRateSetting) {
3346 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3347 *pu2DesiredNonHTRateSet = RATE_SET_BIT_1M;
3348 *pu2BSSBasicRateSet = RATE_SET_BIT_1M;
3355 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3356 *pu2DesiredNonHTRateSet = RATE_SET_BIT_2M;
3357 *pu2BSSBasicRateSet = RATE_SET_BIT_2M;
3363 case FIXED_RATE_5_5M:
3364 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3365 *pu2DesiredNonHTRateSet = RATE_SET_BIT_5_5M;
3366 *pu2BSSBasicRateSet = RATE_SET_BIT_5_5M;
3372 case FIXED_RATE_11M:
3373 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3374 *pu2DesiredNonHTRateSet = RATE_SET_BIT_11M;
3375 *pu2BSSBasicRateSet = RATE_SET_BIT_11M;
3382 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3383 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3385 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3386 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3389 *pu2DesiredNonHTRateSet = RATE_SET_BIT_6M;
3390 *pu2BSSBasicRateSet = RATE_SET_BIT_6M;
3397 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3398 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3400 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3401 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3404 *pu2DesiredNonHTRateSet = RATE_SET_BIT_9M;
3405 *pu2BSSBasicRateSet = RATE_SET_BIT_9M;
3411 case FIXED_RATE_12M:
3412 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3413 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3415 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3416 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3419 *pu2DesiredNonHTRateSet = RATE_SET_BIT_12M;
3420 *pu2BSSBasicRateSet = RATE_SET_BIT_12M;
3426 case FIXED_RATE_18M:
3427 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3428 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3430 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3431 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3434 *pu2DesiredNonHTRateSet = RATE_SET_BIT_18M;
3435 *pu2BSSBasicRateSet = RATE_SET_BIT_18M;
3441 case FIXED_RATE_24M:
3442 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3443 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3445 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3446 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3449 *pu2DesiredNonHTRateSet = RATE_SET_BIT_24M;
3450 *pu2BSSBasicRateSet = RATE_SET_BIT_24M;
3456 case FIXED_RATE_36M:
3457 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3458 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3460 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3461 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3464 *pu2DesiredNonHTRateSet = RATE_SET_BIT_36M;
3465 *pu2BSSBasicRateSet = RATE_SET_BIT_36M;
3471 case FIXED_RATE_48M:
3472 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3473 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3475 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3476 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3479 *pu2DesiredNonHTRateSet = RATE_SET_BIT_48M;
3480 *pu2BSSBasicRateSet = RATE_SET_BIT_48M;
3486 case FIXED_RATE_54M:
3487 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3488 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3490 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3491 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3494 *pu2DesiredNonHTRateSet = RATE_SET_BIT_54M;
3495 *pu2BSSBasicRateSet = RATE_SET_BIT_54M;
3501 case FIXED_RATE_MCS0_20M_800NS:
3502 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3503 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3504 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3505 *pucMcsSet = HT_RATE_MCS0_INDEX;
3507 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3508 | HT_CAP_INFO_SHORT_GI_20M
3509 | HT_CAP_INFO_SHORT_GI_40M
3510 | HT_CAP_INFO_HT_GF);
3513 case FIXED_RATE_MCS1_20M_800NS:
3514 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3515 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3516 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3517 *pucMcsSet = HT_RATE_MCS1_INDEX;
3519 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3520 | HT_CAP_INFO_SHORT_GI_20M
3521 | HT_CAP_INFO_SHORT_GI_40M
3522 | HT_CAP_INFO_HT_GF);
3525 case FIXED_RATE_MCS2_20M_800NS:
3526 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3527 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3528 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3529 *pucMcsSet = HT_RATE_MCS2_INDEX;
3531 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3532 | HT_CAP_INFO_SHORT_GI_20M
3533 | HT_CAP_INFO_SHORT_GI_40M
3534 | HT_CAP_INFO_HT_GF);
3537 case FIXED_RATE_MCS3_20M_800NS:
3538 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3539 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3540 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3541 *pucMcsSet = HT_RATE_MCS3_INDEX;
3543 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3544 | HT_CAP_INFO_SHORT_GI_20M
3545 | HT_CAP_INFO_SHORT_GI_40M
3546 | HT_CAP_INFO_HT_GF);
3549 case FIXED_RATE_MCS4_20M_800NS:
3550 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3551 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3552 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3553 *pucMcsSet = HT_RATE_MCS4_INDEX;
3555 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3556 | HT_CAP_INFO_SHORT_GI_20M
3557 | HT_CAP_INFO_SHORT_GI_40M
3558 | HT_CAP_INFO_HT_GF);
3561 case FIXED_RATE_MCS5_20M_800NS:
3562 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3563 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3564 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3565 *pucMcsSet = HT_RATE_MCS5_INDEX;
3567 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3568 | HT_CAP_INFO_SHORT_GI_20M
3569 | HT_CAP_INFO_SHORT_GI_40M
3570 | HT_CAP_INFO_HT_GF);
3573 case FIXED_RATE_MCS6_20M_800NS:
3574 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3575 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3576 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3577 *pucMcsSet = HT_RATE_MCS6_INDEX;
3579 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3580 | HT_CAP_INFO_SHORT_GI_20M
3581 | HT_CAP_INFO_SHORT_GI_40M
3582 | HT_CAP_INFO_HT_GF);
3585 case FIXED_RATE_MCS7_20M_800NS:
3586 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3587 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3588 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3589 *pucMcsSet = HT_RATE_MCS7_INDEX;
3591 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3592 | HT_CAP_INFO_SHORT_GI_20M
3593 | HT_CAP_INFO_SHORT_GI_40M
3594 | HT_CAP_INFO_HT_GF);
3597 case FIXED_RATE_MCS0_20M_400NS:
3598 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3599 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3600 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3601 *pucMcsSet = HT_RATE_MCS0_INDEX;
3603 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3604 | HT_CAP_INFO_SHORT_GI_40M
3605 | HT_CAP_INFO_HT_GF);
3606 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3609 case FIXED_RATE_MCS1_20M_400NS:
3610 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3611 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3612 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3613 *pucMcsSet = HT_RATE_MCS1_INDEX;
3615 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3616 | HT_CAP_INFO_SHORT_GI_40M
3617 | HT_CAP_INFO_HT_GF);
3618 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3621 case FIXED_RATE_MCS2_20M_400NS:
3622 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3623 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3624 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3625 *pucMcsSet = HT_RATE_MCS2_INDEX;
3627 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3628 | HT_CAP_INFO_SHORT_GI_40M
3629 | HT_CAP_INFO_HT_GF);
3630 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3633 case FIXED_RATE_MCS3_20M_400NS:
3634 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3635 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3636 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3637 *pucMcsSet = HT_RATE_MCS3_INDEX;
3639 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3640 | HT_CAP_INFO_SHORT_GI_40M
3641 | HT_CAP_INFO_HT_GF);
3642 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3645 case FIXED_RATE_MCS4_20M_400NS:
3646 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3647 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3648 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3649 *pucMcsSet = HT_RATE_MCS4_INDEX;
3651 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3652 | HT_CAP_INFO_SHORT_GI_40M
3653 | HT_CAP_INFO_HT_GF);
3654 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3657 case FIXED_RATE_MCS5_20M_400NS:
3658 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3659 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3660 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3661 *pucMcsSet = HT_RATE_MCS5_INDEX;
3663 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3664 | HT_CAP_INFO_SHORT_GI_40M
3665 | HT_CAP_INFO_HT_GF);
3666 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3669 case FIXED_RATE_MCS6_20M_400NS:
3670 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3671 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3672 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3673 *pucMcsSet = HT_RATE_MCS6_INDEX;
3675 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3676 | HT_CAP_INFO_SHORT_GI_40M
3677 | HT_CAP_INFO_HT_GF);
3678 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3681 case FIXED_RATE_MCS7_20M_400NS:
3682 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3683 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3684 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3685 *pucMcsSet = HT_RATE_MCS7_INDEX;
3687 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3688 | HT_CAP_INFO_SHORT_GI_40M
3689 | HT_CAP_INFO_HT_GF);
3690 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3693 case FIXED_RATE_MCS0_40M_800NS:
3694 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3695 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3696 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3697 *pucMcsSet = HT_RATE_MCS0_INDEX;
3699 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3700 | HT_CAP_INFO_SHORT_GI_40M
3701 | HT_CAP_INFO_HT_GF);
3702 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3705 case FIXED_RATE_MCS1_40M_800NS:
3706 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3707 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3708 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3709 *pucMcsSet = HT_RATE_MCS1_INDEX;
3711 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3712 | HT_CAP_INFO_SHORT_GI_40M
3713 | HT_CAP_INFO_HT_GF);
3714 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3717 case FIXED_RATE_MCS2_40M_800NS:
3718 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3719 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3720 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3721 *pucMcsSet = HT_RATE_MCS2_INDEX;
3723 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3724 | HT_CAP_INFO_SHORT_GI_40M
3725 | HT_CAP_INFO_HT_GF);
3726 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3729 case FIXED_RATE_MCS3_40M_800NS:
3730 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3731 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3732 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3733 *pucMcsSet = HT_RATE_MCS3_INDEX;
3735 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3736 | HT_CAP_INFO_SHORT_GI_40M
3737 | HT_CAP_INFO_HT_GF);
3738 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3741 case FIXED_RATE_MCS4_40M_800NS:
3742 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3743 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3744 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3745 *pucMcsSet = HT_RATE_MCS4_INDEX;
3747 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3748 | HT_CAP_INFO_SHORT_GI_40M
3749 | HT_CAP_INFO_HT_GF);
3750 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3753 case FIXED_RATE_MCS5_40M_800NS:
3754 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3755 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3756 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3757 *pucMcsSet = HT_RATE_MCS5_INDEX;
3759 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3760 | HT_CAP_INFO_SHORT_GI_40M
3761 | HT_CAP_INFO_HT_GF);
3762 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3765 case FIXED_RATE_MCS6_40M_800NS:
3766 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3767 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3768 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3769 *pucMcsSet = HT_RATE_MCS6_INDEX;
3771 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3772 | HT_CAP_INFO_SHORT_GI_40M
3773 | HT_CAP_INFO_HT_GF);
3774 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3777 case FIXED_RATE_MCS7_40M_800NS:
3778 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3779 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3780 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3781 *pucMcsSet = HT_RATE_MCS7_INDEX;
3783 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3784 | HT_CAP_INFO_SHORT_GI_40M
3785 | HT_CAP_INFO_HT_GF);
3786 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3789 case FIXED_RATE_MCS32_800NS:
3790 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3791 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3792 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3793 *pucMcsSet = HT_RATE_MCS32_INDEX;
3795 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3796 | HT_CAP_INFO_SHORT_GI_40M
3797 | HT_CAP_INFO_HT_GF);
3798 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3801 case FIXED_RATE_MCS0_40M_400NS:
3802 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3803 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3804 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3805 *pucMcsSet = HT_RATE_MCS0_INDEX;
3807 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3808 | HT_CAP_INFO_HT_GF);
3809 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3810 | HT_CAP_INFO_SHORT_GI_40M);
3813 case FIXED_RATE_MCS1_40M_400NS:
3814 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3815 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3816 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3817 *pucMcsSet = HT_RATE_MCS1_INDEX;
3819 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3820 | HT_CAP_INFO_HT_GF);
3821 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3822 | HT_CAP_INFO_SHORT_GI_40M);
3825 case FIXED_RATE_MCS2_40M_400NS:
3826 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3827 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3828 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3829 *pucMcsSet = HT_RATE_MCS2_INDEX;
3831 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3832 | HT_CAP_INFO_HT_GF);
3833 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3834 | HT_CAP_INFO_SHORT_GI_40M);
3837 case FIXED_RATE_MCS3_40M_400NS:
3838 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3839 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3840 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3841 *pucMcsSet = HT_RATE_MCS3_INDEX;
3843 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3844 | HT_CAP_INFO_HT_GF);
3845 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3846 | HT_CAP_INFO_SHORT_GI_40M);
3849 case FIXED_RATE_MCS4_40M_400NS:
3850 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3851 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3852 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3853 *pucMcsSet = HT_RATE_MCS4_INDEX;
3855 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3856 | HT_CAP_INFO_HT_GF);
3857 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3858 | HT_CAP_INFO_SHORT_GI_40M);
3861 case FIXED_RATE_MCS5_40M_400NS:
3862 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3863 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3864 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3865 *pucMcsSet = HT_RATE_MCS5_INDEX;
3867 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3868 | HT_CAP_INFO_HT_GF);
3869 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3870 | HT_CAP_INFO_SHORT_GI_40M);
3873 case FIXED_RATE_MCS6_40M_400NS:
3874 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3875 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3876 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3877 *pucMcsSet = HT_RATE_MCS6_INDEX;
3879 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3880 | HT_CAP_INFO_HT_GF);
3881 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3882 | HT_CAP_INFO_SHORT_GI_40M);
3885 case FIXED_RATE_MCS7_40M_400NS:
3886 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3887 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3888 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3889 *pucMcsSet = HT_RATE_MCS7_INDEX;
3891 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3892 | HT_CAP_INFO_HT_GF);
3893 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3894 | HT_CAP_INFO_SHORT_GI_40M);
3897 case FIXED_RATE_MCS32_400NS:
3898 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3899 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3900 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3901 *pucMcsSet = HT_RATE_MCS32_INDEX;
3903 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3904 | HT_CAP_INFO_HT_GF);
3905 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
3906 | HT_CAP_INFO_SHORT_GI_40M);
3913 return WLAN_STATUS_SUCCESS;
3916 /*----------------------------------------------------------------------------*/
3918 * @brief This utility function is used to write the register
3920 * @param u4Address Register address
3921 * u4Value the value to be written
3923 * @retval WLAN_STATUS_SUCCESS
3924 * WLAN_STATUS_FAILURE
3926 /*----------------------------------------------------------------------------*/
3930 IN P_ADAPTER_T prAdapter,
3931 IN UINT_32 u4Address,
3935 CMD_ACCESS_REG rCmdAccessReg;
3937 rCmdAccessReg.u4Address = u4Address;
3938 rCmdAccessReg.u4Data = u4Value;
3940 return wlanSendSetQueryCmd(prAdapter,
3947 sizeof(CMD_ACCESS_REG),
3948 (PUINT_8)&rCmdAccessReg,
3955 /*----------------------------------------------------------------------------*/
3957 * @brief This utility function is used to modify the auto rate parameters
3959 * @param u4ArSysParam0 see description below
3965 * @retval WLAN_STATUS_SUCCESS
3966 * WLAN_STATUS_FAILURE
3969 * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
3970 * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
3971 * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
3972 * ArSysParam0[8:15]-> HT rate clear mask
3973 * ArSysParam0[16:31]-> Legacy rate clear mask
3974 * ArSysParam1[0:7]-> Auto Rate check weighting window
3975 * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
3976 * ArSysParam1[16:23]-> Auto Rate v1 PerH
3977 * ArSysParam1[24:31]-> Auto Rate v1 PerL
3981 * Enable auto rate version 1
3983 * ArSysParam0 = 983041,
3984 * Enable auto rate version 1
3985 * Remove CCK 1M, 2M, 5.5M, 11M
3987 * ArSysParam0 = 786433
3988 * Enable auto rate version 1
3989 * Remove CCK 5.5M 11M
3991 /*----------------------------------------------------------------------------*/
3995 nicRlmArUpdateParms(
3996 IN P_ADAPTER_T prAdapter,
3997 IN UINT_32 u4ArSysParam0,
3998 IN UINT_32 u4ArSysParam1,
3999 IN UINT_32 u4ArSysParam2,
4000 IN UINT_32 u4ArSysParam3
4003 UINT_8 ucArVer,ucAbwVer,ucAgiVer;
4004 UINT_16 u2HtClrMask;
4005 UINT_16 u2LegacyClrMask;
4006 UINT_8 ucArCheckWindow;
4009 UINT_8 ucArPerForceRateDownPer;
4011 ucArVer = (UINT_8)(u4ArSysParam0 & BITS(0,3));
4012 ucAbwVer = (UINT_8)((u4ArSysParam0 & BITS(4,5)) >>4);
4013 ucAgiVer = (UINT_8)((u4ArSysParam0 & BITS(6,7)) >>6);
4014 u2HtClrMask = (UINT_16) ((u4ArSysParam0 & BITS(8,15)) >> 8);
4015 u2LegacyClrMask = (UINT_16) ((u4ArSysParam0 & BITS(16,31)) >> 16);
4018 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0,7));
4019 ucArPerForceRateDownPer = (UINT_8) ((u4ArSysParam1 & BITS(8,15)>>8));
4020 ucArPerH = (UINT_8) ((u4ArSysParam1 & BITS(16,23)) >>16);
4021 ucArPerL = (UINT_8) ((u4ArSysParam1 & BITS(24,31)) >>24);
4024 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0,7));
4025 ucArPerForceRateDownPer = (UINT_8) (((u4ArSysParam1>>8) & BITS(0,7)));
4026 ucArPerH = (UINT_8) (((u4ArSysParam1>>16) & BITS(0,7)));
4027 ucArPerL = (UINT_8) (((u4ArSysParam1>>24) & BITS(0,7)));
4030 DBGLOG(INIT, INFO, ("ArParam %u %u %u %u\n", u4ArSysParam0, u4ArSysParam1, u4ArSysParam2, u4ArSysParam3));
4031 DBGLOG(INIT, INFO, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer, ucAbwVer, ucAgiVer));
4032 DBGLOG(INIT, INFO, ("HtMask %x LegacyMask %x\n", u2HtClrMask, u2LegacyClrMask));
4033 DBGLOG(INIT, INFO, ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow, ucArPerForceRateDownPer, ucArPerH, ucArPerL));
4035 #define SWCR_DATA_ADDR(MOD,ADDR) (0x90000000+(MOD<<8)+(ADDR))
4036 #define SWCR_DATA_CMD(CATE,WRITE,INDEX,OPT0,OPT1) ( (CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 <<8) | OPT1 )
4037 #define SWCR_DATA0 0x0
4038 #define SWCR_DATA1 0x4
4039 #define SWCR_DATA2 0x8
4040 #define SWCR_DATA3 0xC
4041 #define SWCR_DATA4 0x10
4042 #define SWCR_WRITE 1
4046 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
4047 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000)*/
4049 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),1);
4050 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,5,0,0));
4053 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),0);
4054 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,5,0,0)) ;
4057 /* ucArVer 0: none 1:PER 2:Rcpi */
4058 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArVer);
4059 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,7,0,0));
4061 /* Candidate rate Ht mask */
4062 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),u2HtClrMask);
4063 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1c,0,0));
4065 /* Candidate rate legacy mask */
4066 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),u2LegacyClrMask);
4067 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1d,0,0));
4070 if(ucArCheckWindow!=0) {
4071 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
4072 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArCheckWindow);
4073 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x14,0,0));
4074 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArCheckWindow);
4075 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0xc,0,0));
4078 if(ucArPerForceRateDownPer !=0) {
4079 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerForceRateDownPer);
4080 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x18,0,0));
4083 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerH);
4084 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1,0,0));
4087 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerL);
4088 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x2,0,0));
4094 return WLAN_STATUS_SUCCESS;
4097 /*----------------------------------------------------------------------------*/
4099 * @brief This utility function is used to enable roaming
4101 * @param u4EnableRoaming
4104 * @retval WLAN_STATUS_SUCCESS
4105 * WLAN_STATUS_FAILURE
4108 * u4EnableRoaming -> Enable Romaing
4111 /*----------------------------------------------------------------------------*/
4113 nicRoamingUpdateParams(
4114 IN P_ADAPTER_T prAdapter,
4115 IN UINT_32 u4EnableRoaming
4118 P_CONNECTION_SETTINGS_T prConnSettings;
4120 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
4121 prConnSettings->fgIsEnableRoaming = ((u4EnableRoaming>0)?(TRUE):(FALSE));
4123 return WLAN_STATUS_SUCCESS;
4126 /*----------------------------------------------------------------------------*/
4128 * \brief dump firmware Assert message
4137 /*----------------------------------------------------------------------------*/
4139 nicPrintFirmwareAssertInfo(
4140 IN P_ADAPTER_T prAdapter
4143 UINT_32 u4MailBox0, u4MailBox1;
4145 UINT_8 aucAssertFile[7];
4148 #if CFG_SDIO_INTR_ENHANCE
4149 u4MailBox0 = prAdapter->prSDIOCtrl->u4RcvMailbox0;
4150 u4MailBox1 = prAdapter->prSDIOCtrl->u4RcvMailbox1;
4152 nicGetMailbox(prAdapter, 0, &u4MailBox0);
4153 nicGetMailbox(prAdapter, 1, &u4MailBox1);
4156 line = u4MailBox0 & 0x0000FFFF;
4158 u4MailBox0 = ((u4MailBox0 >> 16) & 0x0000FFFF);
4160 kalMemCopy(&aucAssertFile[0], &u4MailBox0, 2);
4161 kalMemCopy(&aucAssertFile[2], &u4MailBox1, 4);
4163 aucAssertFile[6] = '\0';
4167 #elif defined(MT5931)
4169 #elif defined(MT6628)
4173 kalPrint("\n[MT%ld][wifi][Firmware] Assert at \"%s\" #%ld\n\n",
4181 /*----------------------------------------------------------------------------*/
4183 * @brief This function is called to update Link Quality information
4185 * @param prAdapter Pointer of Adapter Data Structure
4187 * prEventLinkQuality
4193 /*----------------------------------------------------------------------------*/
4195 nicUpdateLinkQuality(
4196 IN P_ADAPTER_T prAdapter,
4197 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4198 IN P_EVENT_LINK_QUALITY prEventLinkQuality
4202 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4203 ASSERT(prEventLinkQuality);
4205 switch(eNetTypeIdx) {
4206 case NETWORK_TYPE_AIS_INDEX:
4207 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
4208 /* buffer statistics for further query */
4209 if(prAdapter->fgIsLinkQualityValid == FALSE
4210 || (kalGetTimeTick() - prAdapter->rLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4211 nicUpdateRSSI(prAdapter, eNetTypeIdx, prEventLinkQuality->cRssi, prEventLinkQuality->cLinkQuality);
4214 if(prAdapter->fgIsLinkRateValid == FALSE
4215 || (kalGetTimeTick() - prAdapter->rLinkRateUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4216 nicUpdateLinkSpeed(prAdapter, eNetTypeIdx, prEventLinkQuality->u2LinkSpeed);
4219 #if CFG_ENABLE_WIFI_DIRECT
4220 #if CFG_SUPPORT_P2P_RSSI_QUERY
4221 case NETWORK_TYPE_P2P_INDEX:
4222 if (prAdapter->fgIsP2pLinkQualityValid == FALSE
4223 || (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4224 P_EVENT_LINK_QUALITY_EX prEventLQEx = (P_EVENT_LINK_QUALITY_EX)prEventLinkQuality;
4226 nicUpdateRSSI(prAdapter, NETWORK_TYPE_P2P_INDEX, prEventLQEx->cRssiP2P, prEventLQEx->cLinkQualityP2P);
4240 /*----------------------------------------------------------------------------*/
4242 * @brief This function is called to update RSSI and Link Quality information
4244 * @param prAdapter Pointer of Adapter Data Structure
4251 /*----------------------------------------------------------------------------*/
4254 IN P_ADAPTER_T prAdapter,
4255 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4257 IN INT_8 cLinkQuality
4261 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4263 switch(eNetTypeIdx) {
4264 case NETWORK_TYPE_AIS_INDEX:
4265 prAdapter->fgIsLinkQualityValid = TRUE;
4266 prAdapter->rLinkQualityUpdateTime = kalGetTimeTick();
4268 prAdapter->rLinkQuality.cRssi = cRssi;
4269 prAdapter->rLinkQuality.cLinkQuality = cLinkQuality;
4271 /* indicate to glue layer */
4272 kalUpdateRSSI(prAdapter->prGlueInfo,
4273 KAL_NETWORK_TYPE_AIS_INDEX,
4274 prAdapter->rLinkQuality.cRssi,
4275 prAdapter->rLinkQuality.cLinkQuality);
4278 #if CFG_ENABLE_WIFI_DIRECT
4279 #if CFG_SUPPORT_P2P_RSSI_QUERY
4280 case NETWORK_TYPE_P2P_INDEX:
4281 prAdapter->fgIsP2pLinkQualityValid = TRUE;
4282 prAdapter->rP2pLinkQualityUpdateTime = kalGetTimeTick();
4284 prAdapter->rP2pLinkQuality.cRssi= cRssi;
4285 prAdapter->rP2pLinkQuality.cLinkQuality= cLinkQuality;
4287 kalUpdateRSSI(prAdapter->prGlueInfo,
4288 KAL_NETWORK_TYPE_P2P_INDEX,
4303 /*----------------------------------------------------------------------------*/
4305 * @brief This function is called to update Link Quality information
4307 * @param prAdapter Pointer of Adapter Data Structure
4309 * prEventLinkQuality
4315 /*----------------------------------------------------------------------------*/
4318 IN P_ADAPTER_T prAdapter,
4319 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4320 IN UINT_16 u2LinkSpeed
4324 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4326 switch(eNetTypeIdx) {
4327 case NETWORK_TYPE_AIS_INDEX:
4328 /* buffer statistics for further query */
4329 prAdapter->fgIsLinkRateValid = TRUE;
4330 prAdapter->rLinkRateUpdateTime = kalGetTimeTick();
4332 prAdapter->rLinkQuality.u2LinkSpeed = u2LinkSpeed;
4344 #if CFG_SUPPORT_RDD_TEST_MODE
4346 nicUpdateRddTestMode(
4347 IN P_ADAPTER_T prAdapter,
4348 IN P_CMD_RDD_CH_T prRddChParam
4351 DEBUGFUNC("nicUpdateRddTestMode.\n");
4355 // aisFsmScanRequest(prAdapter, NULL);
4357 return wlanSendSetQueryCmd(prAdapter,
4364 sizeof(CMD_RDD_CH_T),
4365 (PUINT_8)prRddChParam,