2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic.c#2 $
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.
18 * 07 17 2012 yuche.tsai
20 * Compile no error before trial run.
24 * Set the default value of AP StaRec index to "STA_REC_INDEX_NOT_FOUND" in update firmware bss command.
28 * Sync CFG80211 modification from branch 2,2.
31 * [WCXRP00001125] [MT6620 Wi-Fi][Firmware] Strengthen Wi-Fi power off sequence to have a clearroom environment when returining to ROM code
32 * 1. Due to firmware now stops HIF DMA for powering off, do not try to receive any packet from firmware
33 * 2. Take use of prAdapter->fgIsEnterD3ReqIssued for tracking whether it is powering off or not
35 * 11 22 2011 tsaiyuan.hsu
36 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
37 * keep debug counter setting after wake up.
39 * 11 19 2011 yuche.tsai
41 * Update RSSI for P2P.
43 * 11 18 2011 yuche.tsai
45 * CONFIG P2P support RSSI query, default turned off.
47 * 11 07 2011 tsaiyuan.hsu
48 * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
49 * add debug counters and periodically dump counters for debugging.
52 * [WCXRP00001079] [MT5931][Driver] Release pending MMPDU only when BSS is being deactivated
53 * pre-check for NULL before calling MMPDU free function
56 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
57 * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
59 * 11 01 2011 chinglan.wang
61 * Modify the Wi-Fi method of the flush TX queue when disconnect the AP.
62 * 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..
66 * Rewrite Assert Dump Function for Portability.
69 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
70 * New CMD definition about RLM parameters
73 * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
74 * reuse firmware download logic of MT6620 for MT6628.
77 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
78 * Reply Probe Rsp in FW for Hotspot Mode.
83 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
84 * Reply Probe Rsp in FW for Hotspot Mode.
88 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
89 * Reply Probe Rsp in FW for Hotspot Mode.
92 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
93 * Reply Probe Rsp in FW for Hotspot Mode.
95 * 08 02 2011 yuche.tsai
96 * [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a disconnecting device issue.
97 * Fix GO send deauth frame issue.
99 * 07 18 2011 chinghwa.yu
100 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
101 * Add CMD/Event for RDD and BWCS.
104 * [WCXRP00000849] [MT6620 Wi-Fi][Driver] Remove some of the WAPI define for make sure the value is initialize, for customer not enable WAPI
105 * For make sure wapi initial value is set.
108 * [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
110 * 2. replace only BSS-DESC which doesn't have a valid SSID.
113 * [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
114 * allow to have a single BSSID with multiple SSID to be presented in scanning result
116 * 05 12 2011 puff.wen
118 * FW Assert information dump to driver
120 * 04 18 2011 terry.wu
121 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
122 * Remove flag CFG_WIFI_DIRECT_MOVED.
125 * [WCXRP00000651] [MT6620 Wi-Fi][Driver] Refine RSSI buffering mechanism
126 * ROLLBACK due to the special design is to workaround incorrect initial RCPI value coming from firmware domain.
128 * 04 14 2011 cm.chang
129 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
133 * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events
134 * 1. add code to put whole-chip resetting trigger when abnormal firmware assertion is detected
135 * 2. add dummy function for both Win32 and Linux part.
138 * [WCXRP00000635] [MT6620 Wi-Fi][Driver] Clear pending security frames when QM clear pending data frames for dedicated network type
139 * clear pending security frames for dedicated network type when BSS is being deactivated/disconnected
143 * enable the p2p check the cipher to set the bssInfo auth mode.
147 * prepare the code for sync the auth mode and encryption status for P2P and BOW.
149 * 04 11 2011 yuche.tsai
150 * [WCXRP00000627] [Volunteer Patch][MT6620][Driver] Pending MMPUD of P2P Network may crash system issue.
151 * Fix kernel panic issue when MMPDU of P2P is pending in driver.
153 * 04 10 2011 george.huang
154 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
155 * Fix compiler issue.
157 * 04 08 2011 george.huang
158 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
159 * separate settings of P2P and AIS
161 * 04 08 2011 eddie.chen
162 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
166 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
170 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
171 * implementation of internal error handling of nicAllocateAdapterMemory.
173 * 03 31 2011 chinglan.wang
174 * [WCXRP00000613] [MT6620 Wi-Fi] [FW] [Driver] BssInfo can get the security mode which is WPA/WPA2/WAPI or not.
178 * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
179 * portability improvement
182 * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
183 * use pre-allocated buffer for storing enhanced interrupt response as well
186 * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage after system running for a long period
187 * 1. pre-allocate physical continuous buffer while module is being loaded
188 * 2. use pre-allocated physical continuous buffer for TX/RX DMA transfer
190 * The windows part remained the same as before, but added similiar APIs to hide the difference.
193 * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous memory consumption
194 * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
195 * 2. Use common coalescing buffer for both TX/RX directions
198 * 03 10 2011 cm.chang
199 * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
200 * Add some functions to let AIS/Tethering or AIS/BOW be the same channel
202 * 03 07 2011 terry.wu
203 * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
204 * Toggle non-standard debug messages to comments.
207 * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after connection is built.
208 * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
210 * 02 08 2011 terry.wu
211 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
212 * Use kalPrint to print firmware assert info.
214 * 02 01 2011 terry.wu
215 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
218 * 02 01 2011 cm.chang
219 * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
222 * 01 31 2011 terry.wu
223 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
224 * Print firmware ASSERT info at Android kernel log, driver side
226 * 01 27 2011 tsaiyuan.hsu
227 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
229 * 1. not support 11r, only use strength of signal to determine roaming.
230 * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
231 * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
232 * 4. assume that change of link quality in smooth way.
234 * 01 26 2011 cm.chang
235 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
236 * Allocate system RAM if fixed message or mgmt buffer is not available
239 * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
240 * 1. add an extra counter for tracking pending forward frames.
241 * 2. notify TX service thread as well when there is pending forward frame
242 * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
245 * [WCXRP00000372] [MT6620 Wi-Fi][Driver] Check bus access failure inside nicProcessIST()
246 * check bus error and/or card removal when retrieving interrupt status from HAL
249 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
250 * 1) correct typo in scan.c
251 * 2) TX descriptors, RX descriptos and management buffer should use virtually continous buffer instead of physically contineous one
254 * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease physically continous memory demands
255 * separate kalMemAlloc() into virtually-continous and physically-continous type to ease slab system pressure
258 * [WCXRP00000327] [MT6620 Wi-Fi][Driver] Improve HEC WHQA 6972 workaround coverage in driver side
259 * host driver not to set FW-own when there is still pending interrupts
262 * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
263 * before BSS disconnection is indicated to firmware, all correlated peer should be cleared and freed
265 * 12 07 2010 cm.chang
266 * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
267 * 1. BSSINFO include RLM parameter
268 * 2. free all sta records when network is disconnected
270 * 12 02 2010 eddie.chen
271 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
272 * Add more control value but dont use it now.
274 * 11 30 2010 eddie.chen
275 * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
276 * Add auto rate check window in registry
278 * 11 10 2010 eddie.chen
279 * [WCXRP00000156] [MT6620][FW] Change Auto rate window to 64 and add throughput swcr
280 * Use autorate parameter 1 as phy rate mask.
283 * [WCXRP00000166] [MT6620 Wi-Fi][Driver] use SDIO CMD52 for enabling/disabling interrupt to reduce transaction period
284 * change to use CMD52 for enabling/disabling interrupt to reduce SDIO transaction time
286 * 10 26 2010 eddie.chen
287 * [WCXRP00000134] [MT6620 Wi-Fi][Driver] Add a registry to enable auto rate for SQA test by using E1 EVB
288 * Add auto rate parameter in registry.
291 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
292 * 1. remove redundant variables in STA_REC structure
293 * 2. add STA-REC uninitialization routine for clearing pending events
296 * [WCXRP00000103] [MT6620 Wi-Fi][Driver] Driver crashed when using WZC to connect to AP#B with connection with AP#A
297 * reset ptrs when IEs are going to be dropped
300 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
301 * add HT (802.11n) fixed rate support.
304 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
305 * adding fixed rate support for distance test. (from registry setting)
308 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
309 * add firmware download for MT5931.
312 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
313 * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
316 * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by ENUM_NETWORK_TYPE_INDEX_T only
317 * remove ENUM_NETWORK_TYPE_T definitions
320 * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS associated
321 * Do a complete reset with STA-REC null checking for RF test re-entry
325 * use static memory pool for storing IEs of scanning result.
329 * Androi/Linux: return current operating channel information
333 * HIFSYS Clock Source Workaround
335 * 08 26 2010 yuche.tsai
337 * Fix someones coding error while enable WIFI_DIRECT.
339 * 08 25 2010 george.huang
341 * update OID/ registry control path for PM related settings
343 * 08 24 2010 cm.chang
345 * Support RLM initail channel of Ad-hoc, P2P and BOW
347 * 08 24 2010 chinghwa.yu
349 * Update BOW for the 1st time.
351 * 08 23 2010 chinghwa.yu
355 * 08 20 2010 yuche.tsai
357 * Add state change indication.
359 * 08 16 2010 yuche.tsai
361 * Add support for P2P BSS update info.
365 * [removing debugging] not to dump beacon content.
369 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
373 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
374 * 2) extending scanning result to 64 instead of 48
376 * 08 04 2010 yarco.yang
378 * Add TX_AMPDU and ADDBA_REJECT command
382 * surpress compilation warning.
386 * Centralize mgmt/system service procedures into independent calls.
390 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
391 * 2) change nicMediaStateChange() API prototype
395 * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
399 * .support the Wi-Fi RSN
403 * FIX: structure of CMD_SET_BSS_INFO has been changed but no follow-ups are done.
405 * 07 22 2010 george.huang
409 * 07 22 2010 george.huang
411 * Update fgIsQoS information in BSS INFO by CMD
415 * [WPD00003833] [MT6620 and MT5931] Driver migration.
416 * Add Ad-Hoc support to AIS-FSM
418 * 07 14 2010 yarco.yang
420 * 1. Remove CFG_MQM_MIGRATION
421 * 2. Add CMD_UPDATE_WMM_PARMS command
425 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
428 * [WPD00003833][MT6620 and MT5931] Driver migration
429 * update prStaRecOfAP with BSS-INFO.
431 * 07 06 2010 george.huang
432 * [WPD00001556]Basic power managemenet function
433 * Update arguments for nicUpdateBeaconIETemplate()
436 * [WPD00003833][MT6620 and MT5931] Driver migration
437 * STA-REC is maintained by CNM only.
440 * [WPD00003833][MT6620 and MT5931] Driver migration
441 * 1) ignore RSN checking when RSN is not turned on.
442 * 2) set STA-REC deactivation callback as NULL
443 * 3) add variable initialization API based on PHY configuration
445 * 07 01 2010 cm.chang
446 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
447 * Support sync command of STA_REC
450 * [WPD00003833][MT6620 and MT5931] Driver migration
451 * sync. with CMD/EVENT document ver0.07.
454 * [WPD00003833][MT6620 and MT5931] Driver migration
455 * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
458 * [WPD00003833][MT6620 and MT5931] Driver migration
459 * 1) sync to. CMD/EVENT document v0.03
460 * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
461 * 3) send command packet to indicate FW-PM after
462 * a) 1st beacon is received after AIS has connected to an AP
463 * b) IBSS-ALONE has been created
464 * c) IBSS-MERGE has occured
466 * 06 25 2010 george.huang
467 * [WPD00001556]Basic power managemenet function
468 * Create beacon update path, with expose bssUpdateBeaconContent()
471 * [WPD00003833][MT6620 and MT5931] Driver migration
472 * fill fgIsUapsdConnection when indicating BSS-CREATE with AIS-STA mode.
475 * [WPD00003833][MT6620 and MT5931] Driver migration
476 * 1) add command warpper for STA-REC/BSS-INFO sync.
477 * 2) enhance command packet sending procedure for non-oid part
478 * 3) add command packet definitions for STA-REC/BSS-INFO sync.
481 * [WPD00003833][MT6620 and MT5931] Driver migration
482 * implement TX_DONE callback path.
485 * [WPD00003840][MT6620 5931] Security migration
486 * remove duplicate variable for migration.
489 * [WPD00003833][MT6620 and MT5931] Driver migration
490 * TX descriptors are now allocated once for reducing allocation overhead
492 * 06 18 2010 cm.chang
493 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
494 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
497 * [WPD00003833][MT6620 and MT5931] Driver migration
498 * 1) migrate assoc.c.
499 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
500 * 3) add configuration options for CNM_MEM and RSN modules
501 * 4) add data path for management frames
502 * 5) eliminate rPacketInfo of MSDU_INFO_T
505 * [WPD00003833][MT6620 and MT5931] Driver migration
506 * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
507 * 2) when disconnected, indicate nic directly (no event is needed)
509 * 06 06 2010 kevin.huang
510 * [WPD00003832][MT6620 5931] Create driver base
511 * [MT6620 5931] Create driver base
514 * [WPD00001943]Create WiFi test driver framework on WinXP
515 * 1) surpress compiler warning
516 * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
519 * [WPD00001943]Create WiFi test driver framework on WinXP
520 * surpress compiler warning
523 * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
524 * add framework for BT-over-Wi-Fi support.
525 * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
526 * * * * * * * * * * * * * 2) command sequence number is now increased atomically
527 * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
530 * [WPD00001943]Create WiFi test driver framework on WinXP
531 * add channel frequency <-> number conversion
534 * [WPD00001943]Create WiFi test driver framework on WinXP
535 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
538 * [WPD00003827][MT6620 Wi-Fi] Chariot fail and following ping fail, no pkt send from driver
539 * correct nicProcessIST_impl() for interrupt status brought up by RX enhanced response
542 * [WPD00001943]Create WiFi test driver framework on WinXP
543 * 1) add ACPI D0/D3 state switching support
544 * * * * * * * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
547 * [WPD00001943]Create WiFi test driver framework on WinXP
548 * always process TX interrupt first then RX interrupt.
551 * [WPD00001943]Create WiFi test driver framework on WinXP
552 * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
555 * [WPD00001943]Create WiFi test driver framework on WinXP
556 * add checksum offloading support.
557 ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-12-16 18:03:43 GMT mtk02752
558 ** handling enhanced response which fields are fetched at different moments
559 ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-12-15 17:00:29 GMT mtk02752
560 ** if RX enhanced response is used, D2H interrupt status should be coming from buffered result as well
561 ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-12-15 12:01:55 GMT mtk02752
562 ** 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
563 ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-12-10 16:52:52 GMT mtk02752
565 ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-11-24 20:51:01 GMT mtk02752
566 ** integrate with SD1 by invoking qmHandleMailboxRxMessage()
567 ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-16 17:32:33 GMT mtk02752
568 ** prepare code for invoking rxHandleMailboxRxMessage()
569 ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-11 10:36:08 GMT mtk01084
570 ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-09 22:56:41 GMT mtk01084
571 ** modify HW access routines
572 ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-10-30 18:17:20 GMT mtk01084
574 ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:54:57 GMT mtk01084
576 ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-10-23 16:08:30 GMT mtk01084
577 ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-10-13 21:59:12 GMT mtk01084
578 ** update for new HW design
579 ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-09-09 17:26:15 GMT mtk01084
580 ** modify for CFG_TEST_WITH_MT5921
581 ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-05-19 10:55:22 GMT mtk01461
582 ** Unmask the unused HISR
583 ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-05-18 15:59:13 GMT mtk01084
584 ** remove debug purpose code
585 ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-05-18 14:05:02 GMT mtk01084
586 ** update for WIFI ownback part on initial
587 ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-05-04 21:32:57 GMT mtk01084
588 ** add temporarily code to set driver own on adapter initialization
589 ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-28 10:35:41 GMT mtk01461
590 ** Add init of TX aggregation and fix RX STATUS is DW align for SDIO_STATUS_ENHANCE mode
591 ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-24 21:12:10 GMT mtk01104
592 ** Add function nicRestoreSpiDefMode()
593 ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-21 09:43:31 GMT mtk01461
594 ** Revise for MTK coding style - nicInitializeAdapter()
595 ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-17 19:52:47 GMT mtk01461
596 ** Update allocate Adapter Memory for MGMT Memory pool
597 ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:57:08 GMT mtk01461
598 ** Refine the order of release memory from pucRxCoalescingBufCached
599 ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-19 18:32:57 GMT mtk01084
600 ** update for basic power management functions
601 ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 21:00:14 GMT mtk01426
602 ** Add CFG_SDIO_RX_ENHANCE support
603 ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-16 09:10:27 GMT mtk01461
604 ** Update TX PATH API
605 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:25:59 GMT mtk01426
610 /*******************************************************************************
611 * C O M P I L E R F L A G S
612 ********************************************************************************
615 /*******************************************************************************
616 * E X T E R N A L R E F E R E N C E S
617 ********************************************************************************
622 /*******************************************************************************
624 ********************************************************************************
626 const UINT_8 aucPhyCfg2PhyTypeSet[PHY_CONFIG_NUM] =
628 PHY_TYPE_SET_802_11ABG, /* PHY_CONFIG_802_11ABG */
629 PHY_TYPE_SET_802_11BG, /* PHY_CONFIG_802_11BG */
630 PHY_TYPE_SET_802_11G, /* PHY_CONFIG_802_11G */
631 PHY_TYPE_SET_802_11A, /* PHY_CONFIG_802_11A */
632 PHY_TYPE_SET_802_11B, /* PHY_CONFIG_802_11B */
633 PHY_TYPE_SET_802_11ABGN, /* PHY_CONFIG_802_11ABGN */
634 PHY_TYPE_SET_802_11BGN, /* PHY_CONFIG_802_11BGN */
635 PHY_TYPE_SET_802_11AN, /* PHY_CONFIG_802_11AN */
636 PHY_TYPE_SET_802_11GN /* PHY_CONFIG_802_11GN */
639 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
640 #define REQ_GATING_ENABLE_H2D_INT BIT(31)
641 #define REQ_GATING_DISABLE_H2D_INT BIT(30)
642 #define ACK_GATING_ENABLE_D2H_INT BIT(31)
643 #define ACK_GATING_DISABLE_D2H_INT BIT(30)
645 #define GATING_CONTROL_POLL_LIMIT 64
648 /*******************************************************************************
650 ********************************************************************************
653 /*******************************************************************************
654 * P U B L I C D A T A
655 ********************************************************************************
658 static INT_EVENT_MAP_T arIntEventMapTable[] = {
659 {WHISR_ABNORMAL_INT, INT_EVENT_ABNORMAL},
660 {WHISR_D2H_SW_INT, INT_EVENT_SW_INT},
661 {WHISR_TX_DONE_INT, INT_EVENT_TX},
662 {(WHISR_RX0_DONE_INT | WHISR_RX1_DONE_INT), INT_EVENT_RX}
665 static const UINT_8 ucIntEventMapSize = (sizeof(arIntEventMapTable) / sizeof(INT_EVENT_MAP_T));
667 static IST_EVENT_FUNCTION apfnEventFuncTable[] = {
668 nicProcessAbnormalInterrupt, /*!< INT_EVENT_ABNORMAL */
669 nicProcessSoftwareInterrupt, /*!< INT_EVENT_SW_INT */
670 nicProcessTxInterrupt, /*!< INT_EVENT_TX */
671 nicProcessRxInterrupt, /*!< INT_EVENT_RX */
673 /*******************************************************************************
674 * P R I V A T E D A T A
675 ********************************************************************************
678 /*******************************************************************************
680 ********************************************************************************
682 /*! This macro is used to reduce coding errors inside nicAllocateAdapterMemory()
683 * and also enhance the readability.
685 #define LOCAL_NIC_ALLOCATE_MEMORY(pucMem, u4Size, eMemType, pucComment) \
687 DBGLOG(INIT, INFO, ("Allocating %ld bytes for %s.\n", u4Size, pucComment)); \
688 if ((pucMem = (PUINT_8)kalMemAlloc(u4Size, eMemType)) == (PUINT_8)NULL) { \
689 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for %s.\n", u4Size, pucComment)); \
692 ASSERT(((UINT_32)pucMem % 4) == 0); \
693 DBGLOG(INIT, INFO, ("Virtual Address = %08lx for %s.\n", (UINT_32)pucMem, pucComment)); \
698 /*******************************************************************************
699 * F U N C T I O N D E C L A R A T I O N S
700 ********************************************************************************
703 /*******************************************************************************
705 ********************************************************************************
709 /*----------------------------------------------------------------------------*/
711 * @brief This routine is responsible for the allocation of the data structures
712 * inside the Adapter structure, include:
714 * 2. Common coalescing buffer for TX PATH.
716 * @param prAdapter Pointer of Adapter Data Structure
718 * @retval WLAN_STATUS_SUCCESS - Has enough memory.
719 * @retval WLAN_STATUS_RESOURCES - Memory is not enough.
721 /*----------------------------------------------------------------------------*/
723 nicAllocateAdapterMemory (
724 IN P_ADAPTER_T prAdapter
727 WLAN_STATUS status = WLAN_STATUS_RESOURCES;
728 P_RX_CTRL_T prRxCtrl;
729 P_TX_CTRL_T prTxCtrl;
731 DEBUGFUNC("nicAllocateAdapterMemory");
734 prRxCtrl = &prAdapter->rRxCtrl;
735 prTxCtrl = &prAdapter->rTxCtrl;
738 //4 <0> Reset all Memory Handler
740 prAdapter->u4MemFreeDynamicCount = 0;
741 prAdapter->u4MemAllocDynamicCount = 0;
743 prAdapter->pucMgtBufCached = (PUINT_8)NULL;
744 prRxCtrl->pucRxCached = (PUINT_8)NULL;
745 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)NULL;
748 //4 <1> Memory for Management Memory Pool and CMD_INFO_T
749 /* Allocate memory for the CMD_INFO_T and its MGMT memory pool. */
750 prAdapter->u4MgtBufCachedSize = MGT_BUFFER_SIZE;
752 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter->pucMgtBufCached,
753 prAdapter->u4MgtBufCachedSize,
755 "COMMON MGMT MEMORY POOL");
757 //4 <2> Memory for RX Descriptor
758 /* Initialize the number of rx buffers we will have in our queue. */
759 /* <TODO> We may setup ucRxPacketDescriptors by GLUE Layer, and using
760 * this variable directly.
762 /* Allocate memory for the SW receive structures. */
763 prRxCtrl->u4RxCachedSize = CFG_RX_MAX_PKT_NUM * \
764 ALIGN_4(sizeof(SW_RFB_T));
766 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl->pucRxCached,
767 prRxCtrl->u4RxCachedSize,
771 //4 <3> Memory for TX DEscriptor
772 prTxCtrl->u4TxCachedSize = CFG_TX_MAX_PKT_NUM * \
773 ALIGN_4(sizeof(MSDU_INFO_T));
775 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl->pucTxCached,
776 prTxCtrl->u4TxCachedSize,
780 //4 <4> Memory for Common Coalescing Buffer
781 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
782 prAdapter->pucCoalescingBufCached = (PUINT_8)NULL;
784 /* Allocate memory for the common coalescing buffer. */
785 prAdapter->u4CoalescingBufCachedSize = CFG_COALESCING_BUFFER_SIZE > CFG_RX_COALESCING_BUFFER_SIZE ?
786 CFG_COALESCING_BUFFER_SIZE : CFG_RX_COALESCING_BUFFER_SIZE;
788 prAdapter->pucCoalescingBufCached =
789 kalAllocateIOBuffer(prAdapter->u4CoalescingBufCachedSize);
791 if(prAdapter->pucCoalescingBufCached == NULL) {
792 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for coalescing buffer.\n", prAdapter->u4CoalescingBufCachedSize));
795 #endif /* CFG_COALESCING_BUFFER_SIZE */
797 //4 <5> Memory for enhanced interrupt response
798 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
799 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
801 if(prAdapter->prSDIOCtrl == NULL) {
802 DBGLOG(INIT, ERROR, ("Could not allocate %ld bytes for interrupt response.\n", sizeof(ENHANCE_MODE_DATA_STRUCT_T)));
806 status = WLAN_STATUS_SUCCESS;
811 if(status != WLAN_STATUS_SUCCESS) {
812 nicReleaseAdapterMemory(prAdapter);
817 } /* end of nicAllocateAdapterMemory() */
820 /*----------------------------------------------------------------------------*/
822 * @brief This routine is responsible for releasing the allocated memory by
823 * nicAllocatedAdapterMemory().
825 * @param prAdapter Pointer of Adapter Data Structure
829 /*----------------------------------------------------------------------------*/
831 nicReleaseAdapterMemory (
832 IN P_ADAPTER_T prAdapter
835 P_TX_CTRL_T prTxCtrl;
836 P_RX_CTRL_T prRxCtrl;
839 prTxCtrl = &prAdapter->rTxCtrl;
840 prRxCtrl = &prAdapter->rRxCtrl;
842 //4 <5> Memory for enhanced interrupt response
843 if (prAdapter->prSDIOCtrl) {
844 kalReleaseIOBuffer((PVOID)prAdapter->prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
845 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)NULL;
848 //4 <4> Memory for Common Coalescing Buffer
849 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
850 if (prAdapter->pucCoalescingBufCached) {
851 kalReleaseIOBuffer((PVOID)prAdapter->pucCoalescingBufCached, prAdapter->u4CoalescingBufCachedSize);
852 prAdapter->pucCoalescingBufCached = (PUINT_8)NULL;
854 #endif /* CFG_COALESCING_BUFFER_SIZE */
856 //4 <3> Memory for TX Descriptor
857 if (prTxCtrl->pucTxCached) {
858 kalMemFree((PVOID)prTxCtrl->pucTxCached,
860 prTxCtrl->u4TxCachedSize);
861 prTxCtrl->pucTxCached = (PUINT_8)NULL;
864 //4 <2> Memory for RX Descriptor
865 if (prRxCtrl->pucRxCached) {
866 kalMemFree((PVOID)prRxCtrl->pucRxCached,
868 prRxCtrl->u4RxCachedSize);
869 prRxCtrl->pucRxCached = (PUINT_8)NULL;
872 //4 <1> Memory for Management Memory Pool
873 if (prAdapter->pucMgtBufCached) {
874 kalMemFree((PVOID)prAdapter->pucMgtBufCached,
876 prAdapter->u4MgtBufCachedSize);
877 prAdapter->pucMgtBufCached = (PUINT_8)NULL;
881 /* Check if all allocated memories are free */
882 ASSERT(prAdapter->u4MemFreeDynamicCount ==
883 prAdapter->u4MemAllocDynamicCount);
890 /*----------------------------------------------------------------------------*/
892 * @brief disable global interrupt
894 * @param prAdapter pointer to the Adapter handler
898 /*----------------------------------------------------------------------------*/
900 nicDisableInterrupt (
901 IN P_ADAPTER_T prAdapter
906 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_CLR);
908 prAdapter->fgIsIntEnable = FALSE;
911 /*----------------------------------------------------------------------------*/
913 * @brief enable global interrupt
915 * @param prAdapter pointer to the Adapter handler
919 /*----------------------------------------------------------------------------*/
922 IN P_ADAPTER_T prAdapter
925 BOOLEAN fgIsIntEnableCache;
929 fgIsIntEnableCache = prAdapter->fgIsIntEnable;
931 prAdapter->fgIsIntEnable = TRUE; // NOTE(Kevin): It must be placed before MCR GINT write.
933 /* If need enable INT and also set LPOwn at the same time. */
934 if (prAdapter->fgIsIntEnableWithLPOwnSet) {
935 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE; /* NOTE(Kevin): It's better to place it
936 * before MCR GINT write.
938 /* If INT was enabled, only set LPOwn */
939 if (fgIsIntEnableCache) {
940 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET);
941 prAdapter->fgIsFwOwn = TRUE;
943 /* If INT was not enabled, enable it and also set LPOwn now */
945 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET |
947 prAdapter->fgIsFwOwn = TRUE;
950 /* If INT was not enabled, enable it now */
951 else if (!fgIsIntEnableCache) {
952 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_SET);
956 } /* end of nicEnableInterrupt() */
959 #if CFG_SDIO_INTR_ENHANCE
960 /*----------------------------------------------------------------------------*/
962 * @brief For SDIO enhance mode, set the max rx len and tx status
964 * @param prAdapter a pointer to adapter private data structure.
968 /*----------------------------------------------------------------------------*/
971 IN P_ADAPTER_T prAdapter
978 //4 <1> Check STATUS Buffer is DW alignment.
979 ASSERT( IS_ALIGN_4( (UINT_32)&prAdapter->prSDIOCtrl->u4WHISR ) );
981 //4 <2> Setup STATUS count.
983 HAL_MCR_RD(prAdapter, MCR_WHCR, &u4Value);
985 //4 <2.1> Setup the number of maximum RX length to be report
986 u4Value &= ~(WHCR_MAX_HIF_RX_LEN_NUM);
987 u4Value |= ((SDIO_MAXIMUM_RX_LEN_NUM << WHCR_OFFSET_MAX_HIF_RX_LEN_NUM));
989 //4 <2.2> Setup RX enhancement mode
990 #if CFG_SDIO_RX_ENHANCE
991 u4Value |= WHCR_RX_ENHANCE_MODE_EN;
993 u4Value &= ~WHCR_RX_ENHANCE_MODE_EN;
994 #endif /* CFG_SDIO_RX_AGG */
996 HAL_MCR_WR(prAdapter, MCR_WHCR, u4Value);
1001 } /* end of nicSDIOInit() */
1003 /*----------------------------------------------------------------------------*/
1005 * @brief Read interrupt status from hardware
1007 * @param prAdapter pointer to the Adapter handler
1008 * @param the interrupts
1013 /*----------------------------------------------------------------------------*/
1015 nicSDIOReadIntStatus (
1016 IN P_ADAPTER_T prAdapter,
1017 OUT PUINT_32 pu4IntStatus
1020 P_SDIO_CTRL_T prSDIOCtrl;
1022 DEBUGFUNC("nicSDIOReadIntStatus");
1025 ASSERT(pu4IntStatus);
1027 prSDIOCtrl = prAdapter->prSDIOCtrl;
1030 HAL_PORT_RD(prAdapter,
1032 sizeof(ENHANCE_MODE_DATA_STRUCT_T),
1033 (PUINT_8)prSDIOCtrl,
1034 sizeof(ENHANCE_MODE_DATA_STRUCT_T));
1036 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
1037 || fgIsBusAccessFailed == TRUE) {
1043 if((prSDIOCtrl->u4WHISR & WHISR_TX_DONE_INT) == 0 &&
1044 (prSDIOCtrl->rTxInfo.au4WTSR[0] | prSDIOCtrl->rTxInfo.au4WTSR[1])) {
1045 prSDIOCtrl->u4WHISR |= WHISR_TX_DONE_INT;
1048 if((prSDIOCtrl->u4WHISR & BIT(31)) == 0 &&
1049 HAL_GET_MAILBOX_READ_CLEAR(prAdapter) == TRUE &&
1050 (prSDIOCtrl->u4RcvMailbox0 != 0 || prSDIOCtrl->u4RcvMailbox1 != 0)) {
1051 prSDIOCtrl->u4WHISR |= BIT(31);
1054 *pu4IntStatus = prSDIOCtrl->u4WHISR;
1057 } /* end of nicSDIOReadIntStatus() */
1060 /*----------------------------------------------------------------------------*/
1062 * @brief The function used to read interrupt status and then invoking
1063 * dispatching procedure for the appropriate functions
1064 * corresponding to specific interrupt bits
1066 * @param prAdapter pointer to the Adapter handler
1068 * @retval WLAN_STATUS_SUCCESS
1069 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1071 /*----------------------------------------------------------------------------*/
1074 IN P_ADAPTER_T prAdapter
1077 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1078 UINT_32 u4IntStatus = 0;
1081 DEBUGFUNC("nicProcessIST");
1082 //DBGLOG(INIT, LOUD, ("\n"));
1086 if (prAdapter->rAcpiState == ACPI_STATE_D3) {
1087 DBGLOG(REQ, WARN, ("Fail in set nicProcessIST! (Adapter not ready). ACPI=D%d, Radio=%d\n",
1088 prAdapter->rAcpiState, prAdapter->fgIsRadioOff));
1089 return WLAN_STATUS_ADAPTER_NOT_READY;
1092 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1093 if(prAdapter->fgIsClockGatingEnabled == TRUE) {
1094 nicDisableClockGating(prAdapter);
1098 for (i = 0; i < CFG_IST_LOOP_COUNT; i++) {
1100 #if CFG_SDIO_INTR_ENHANCE
1101 nicSDIOReadIntStatus(prAdapter, &u4IntStatus);
1103 HAL_MCR_RD(prAdapter, MCR_WHISR, &u4IntStatus);
1104 #endif /* CFG_SDIO_INTR_ENHANCE */
1106 //DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus));
1108 if (u4IntStatus & ~(WHIER_DEFAULT | WHIER_FW_OWN_BACK_INT_EN)) {
1109 DBGLOG(INTR, WARN, ("Un-handled HISR %#x, HISR = %#x (HIER:0x%x)\n",
1110 (u4IntStatus & ~WHIER_DEFAULT), u4IntStatus, WHIER_DEFAULT));
1111 u4IntStatus &= WHIER_DEFAULT;
1114 nicProcessIST_impl(prAdapter, u4IntStatus);
1116 if(u4IntStatus == 0) {
1118 u4Status = WLAN_STATUS_NOT_INDICATING;
1124 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1125 if(prAdapter->fgIsClockGatingEnabled == FALSE) {
1126 nicEnableClockGating(prAdapter);
1131 } /* end of nicProcessIST() */
1134 /*----------------------------------------------------------------------------*/
1136 * @brief The function used to dispatch the appropriate functions for specific
1139 * @param prAdapter pointer to the Adapter handler
1140 * u4IntStatus interrupt status bits
1142 * @retval WLAN_STATUS_SUCCESS
1143 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1145 /*----------------------------------------------------------------------------*/
1147 nicProcessIST_impl (
1148 IN P_ADAPTER_T prAdapter,
1149 IN UINT_32 u4IntStatus
1152 UINT_32 u4IntCount = 0;
1153 P_INT_EVENT_MAP_T prIntEventMap = NULL;
1157 prAdapter->u4IntStatus = u4IntStatus;
1159 /* Process each of the interrupt status consequently */
1160 prIntEventMap = &arIntEventMapTable[0];
1161 for (u4IntCount = 0; u4IntCount < ucIntEventMapSize; prIntEventMap++, u4IntCount++) {
1162 if (prIntEventMap->u4Int & prAdapter->u4IntStatus) {
1163 if(prIntEventMap->u4Event == INT_EVENT_RX &&
1164 prAdapter->fgIsEnterD3ReqIssued == TRUE) {
1167 else if (apfnEventFuncTable[prIntEventMap->u4Event] != NULL) {
1168 apfnEventFuncTable[prIntEventMap->u4Event](prAdapter);
1172 ("Empty INTR handler! ISAR bit#: %ld, event:%d, func: 0x%x\n",
1173 prIntEventMap->u4Int, prIntEventMap->u4Event, apfnEventFuncTable[prIntEventMap->u4Event]));
1175 ASSERT(0); // to trap any NULL interrupt handler
1177 prAdapter->u4IntStatus &= ~prIntEventMap->u4Int;
1181 return WLAN_STATUS_SUCCESS;
1182 } /* end of nicProcessIST_impl() */
1185 /*----------------------------------------------------------------------------*/
1187 * @brief Verify the CHIP ID
1189 * @param prAdapter a pointer to adapter private data structure.
1192 * @retval TRUE CHIP ID is the same as the setting compiled
1193 * @retval FALSE CHIP ID is different from the setting compiled
1195 /*----------------------------------------------------------------------------*/
1198 IN P_ADAPTER_T prAdapter
1205 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4CIR );
1207 DBGLOG(INIT, TRACE,("Chip ID: 0x%x\n", u4CIR & WCIR_CHIP_ID));
1208 DBGLOG(INIT, TRACE,("Revision ID: 0x%x\n", ((u4CIR & WCIR_REVISION_ID) >> 16)));
1210 if ((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV) {
1214 prAdapter->ucRevID = (UINT_8)(((u4CIR & WCIR_REVISION_ID) >> 16) & 0xF) ;
1219 /*----------------------------------------------------------------------------*/
1221 * @brief Initialize the MCR to the appropriate init value, and verify the init
1224 * @param prAdapter a pointer to adapter private data structure.
1228 /*----------------------------------------------------------------------------*/
1231 IN P_ADAPTER_T prAdapter
1237 //4 <0> Initial value
1242 IN P_ADAPTER_T prAdapter
1249 nicPutMailbox(prAdapter, 0, 0x52455345); // RESE
1250 nicPutMailbox(prAdapter, 1, 0x545F5746); // T_WF
1251 nicSetSwIntr(prAdapter, BIT(16));
1256 /*----------------------------------------------------------------------------*/
1258 * @brief Initialize the Adapter soft variable
1260 * @param prAdapter pointer to the Adapter handler
1265 /*----------------------------------------------------------------------------*/
1267 nicInitializeAdapter (
1268 IN P_ADAPTER_T prAdapter
1271 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1275 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE;
1278 if (!nicVerifyChipID(prAdapter)) {
1279 u4Status = WLAN_STATUS_FAILURE;
1284 nicMCRInit(prAdapter);
1286 #if CFG_SDIO_INTR_ENHANCE
1287 nicSDIOInit(prAdapter);
1288 #endif /* CFG_SDIO_INTR_ENHANCE */
1290 HAL_MCR_WR(prAdapter, MCR_WHIER, WHIER_DEFAULT);
1294 nicHifInit(prAdapter);
1303 #if defined(_HIF_SPI)
1304 /*----------------------------------------------------------------------------*/
1306 * \brief Restore the SPI Mode Select to default mode,
1307 * this is important while driver is unload, and this must be last mcr
1308 * since the operation will let the hif use 8bit mode access
1310 * \param[in] prAdapter a pointer to adapter private data structure.
1311 * \param[in] eGPIO2_Mode GPIO2 operation mode
1315 /*----------------------------------------------------------------------------*/
1317 nicRestoreSpiDefMode (
1318 IN P_ADAPTER_T prAdapter
1323 HAL_MCR_WR(prAdapter, MCR_WCSR, SPICSR_8BIT_MODE_DATA);
1328 /*----------------------------------------------------------------------------*/
1330 * @brief Process rx interrupt. When the rx
1331 * Interrupt is asserted, it means there are frames in queue.
1333 * @param prAdapter Pointer to the Adapter structure.
1337 /*----------------------------------------------------------------------------*/
1339 nicProcessAbnormalInterrupt (
1340 IN P_ADAPTER_T prAdapter
1345 HAL_MCR_RD(prAdapter, MCR_WASR, &u4Value);
1346 DBGLOG(REQ, WARN, ("MCR_WASR: 0x%x \n", u4Value));
1349 /*----------------------------------------------------------------------------*/
1353 * @param prAdapter Pointer to the Adapter structure.
1357 /*----------------------------------------------------------------------------*/
1359 nicProcessFwOwnBackInterrupt(
1360 IN P_ADAPTER_T prAdapter
1365 } /* end of nicProcessFwOwnBackInterrupt() */
1367 /*----------------------------------------------------------------------------*/
1371 * @param prAdapter Pointer to the Adapter structure.
1375 /*----------------------------------------------------------------------------*/
1377 nicProcessSoftwareInterrupt(
1378 IN P_ADAPTER_T prAdapter
1385 u4IntrBits = prAdapter->u4IntStatus & BITS(8, 31);
1387 if((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
1388 nicPrintFirmwareAssertInfo(prAdapter);
1389 #if CFG_CHIP_RESET_SUPPORT
1390 glSendResetRequest();
1394 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1395 ASSERT((u4IntrBits & (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT))
1396 != (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT));
1398 if(u4IntrBits & ACK_GATING_ENABLE_D2H_INT) {
1399 prAdapter->fgIsClockGatingEnabled = TRUE;
1402 if(u4IntrBits & ACK_GATING_DISABLE_D2H_INT) {
1403 prAdapter->fgIsClockGatingEnabled = FALSE;
1405 // Indicate Service Thread for TX
1406 if(kalGetTxPendingCmdCount(prAdapter->prGlueInfo) > 0
1407 || wlanGetTxPendingFrameCount(prAdapter) > 0) {
1408 kalSetEvent(prAdapter->prGlueInfo);
1413 DBGLOG(REQ, WARN, ("u4IntrBits: 0x%x \n", u4IntrBits));
1416 } /* end of nicProcessSoftwareInterrupt() */
1420 IN P_ADAPTER_T prAdapter,
1421 IN UINT_32 u4MailboxNum,
1425 if (u4MailboxNum == 0) {
1426 HAL_MCR_WR(prAdapter, MCR_H2DSM0R, u4Data);
1427 } else if (u4MailboxNum == 1) {
1428 HAL_MCR_WR(prAdapter, MCR_H2DSM1R, u4Data);
1436 IN P_ADAPTER_T prAdapter,
1437 IN UINT_32 u4MailboxNum,
1438 OUT PUINT_32 pu4Data
1441 if (u4MailboxNum == 0) {
1442 HAL_MCR_RD(prAdapter, MCR_D2HRM0R, pu4Data);
1443 } else if (u4MailboxNum == 1) {
1444 HAL_MCR_RD(prAdapter, MCR_D2HRM1R, pu4Data);
1452 IN P_ADAPTER_T prAdapter,
1453 IN UINT_32 u4SwIntrBitmap
1457 * SW interrup in HW bit 16 is mapping to SW bit 0 (shift 16bit in HW transparancy)
1458 * SW interrupt valid from b0~b15
1460 ASSERT((u4SwIntrBitmap & BITS(0, 15)) == 0);
1461 // DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap));
1463 HAL_MCR_WR(prAdapter, MCR_WSICR, u4SwIntrBitmap);
1467 /*----------------------------------------------------------------------------*/
1469 * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1470 * with specified sequential number
1472 * @param prAdapter Pointer of ADAPTER_T
1473 * ucSeqNum Sequential Number
1475 * @retval - P_CMD_INFO_T
1477 /*----------------------------------------------------------------------------*/
1479 nicGetPendingCmdInfo (
1480 IN P_ADAPTER_T prAdapter,
1486 P_QUE_T prTempCmdQue = &rTempCmdQue;
1487 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1488 P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T)NULL;
1490 GLUE_SPIN_LOCK_DECLARATION();
1494 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1496 prCmdQue = &prAdapter->rPendingCmdQueue;
1497 QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
1499 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1500 while (prQueueEntry) {
1501 prCmdInfo = (P_CMD_INFO_T)prQueueEntry;
1503 if(prCmdInfo->ucCmdSeqNum == ucSeqNum)
1506 QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
1511 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1513 QUEUE_CONCATENATE_QUEUES(prCmdQue, prTempCmdQue);
1515 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1521 /*----------------------------------------------------------------------------*/
1523 * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1524 * with specified sequential number
1526 * @param prAdapter Pointer of ADAPTER_T
1527 * ucSeqNum Sequential Number
1529 * @retval - P_MSDU_INFO_T
1531 /*----------------------------------------------------------------------------*/
1533 nicGetPendingTxMsduInfo (
1534 IN P_ADAPTER_T prAdapter,
1540 P_QUE_T prTempQue = &rTempQue;
1541 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1542 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1544 GLUE_SPIN_LOCK_DECLARATION();
1548 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1550 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1551 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1553 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1554 while (prQueueEntry) {
1555 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1557 if(prMsduInfo->ucTxSeqNum == ucSeqNum)
1560 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1565 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1567 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1569 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1575 nicGetPendingStaMMPDU (
1576 IN P_ADAPTER_T prAdapter,
1577 IN UINT_8 ucStaRecIdx
1580 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T)NULL;
1581 P_QUE_T prTxingQue = (P_QUE_T)NULL;
1583 P_QUE_T prTempQue = &rTempQue;
1584 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1585 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1587 GLUE_SPIN_LOCK_DECLARATION();
1589 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1591 if (prAdapter == NULL) {
1597 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1598 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1600 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1601 while (prQueueEntry) {
1602 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1604 if ((prMsduInfo->ucStaRecIndex == ucStaRecIdx) && (prMsduInfo->pfTxDoneHandler != NULL)) {
1605 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo,
1606 prMsduInfoListHead);
1607 prMsduInfoListHead = prMsduInfo;
1610 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1616 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1620 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1623 return prMsduInfoListHead;
1624 } /* nicGetPendingStaMMPDU */
1628 nicFreePendingTxMsduInfoByNetwork (
1629 IN P_ADAPTER_T prAdapter,
1630 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
1635 P_QUE_T prTempQue = &rTempQue;
1636 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1637 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T)NULL;
1638 P_MSDU_INFO_T prMsduInfoListTail = (P_MSDU_INFO_T)NULL;
1639 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1641 GLUE_SPIN_LOCK_DECLARATION();
1645 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1647 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1648 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1650 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1651 while (prQueueEntry) {
1652 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1654 if((ENUM_NETWORK_TYPE_INDEX_T)(prMsduInfo->ucNetworkType) == eNetworkType) {
1655 if(prMsduInfoListHead == NULL) {
1656 prMsduInfoListHead = prMsduInfoListTail = prMsduInfo;
1659 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail, prMsduInfo);
1660 prMsduInfoListTail = prMsduInfo;
1664 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1669 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1671 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1673 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1676 if(prMsduInfoListHead) {
1677 nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
1682 } /* end of nicFreePendingTxMsduInfoByNetwork() */
1686 /*----------------------------------------------------------------------------*/
1688 * @brief This procedure is used to retrieve a CMD sequence number atomically
1690 * @param prAdapter Pointer of ADAPTER_T
1694 /*----------------------------------------------------------------------------*/
1696 nicIncreaseCmdSeqNum (
1697 IN P_ADAPTER_T prAdapter
1702 KAL_SPIN_LOCK_DECLARATION();
1706 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1708 prAdapter->ucCmdSeqNum++;
1709 ucRetval = prAdapter->ucCmdSeqNum;
1711 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1717 /*----------------------------------------------------------------------------*/
1719 * @brief This procedure is used to retrieve a TX sequence number atomically
1721 * @param prAdapter Pointer of ADAPTER_T
1725 /*----------------------------------------------------------------------------*/
1727 nicIncreaseTxSeqNum (
1728 IN P_ADAPTER_T prAdapter
1733 KAL_SPIN_LOCK_DECLARATION();
1737 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1739 prAdapter->ucTxSeqNum++;
1740 ucRetval = prAdapter->ucTxSeqNum;
1742 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1749 /*----------------------------------------------------------------------------*/
1751 * @brief This utility function is used to handle
1752 * media state change event
1758 /*----------------------------------------------------------------------------*/
1760 nicMediaStateChange (
1761 IN P_ADAPTER_T prAdapter,
1762 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType,
1763 IN P_EVENT_CONNECTION_STATUS prConnectionStatus
1766 P_GLUE_INFO_T prGlueInfo;
1769 prGlueInfo = prAdapter->prGlueInfo;
1771 switch(eNetworkType) {
1772 case NETWORK_TYPE_AIS_INDEX:
1773 if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_DISCONNECTED) { // disconnected
1774 if(kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
1776 kalIndicateStatusAndComplete(prGlueInfo,
1777 WLAN_STATUS_MEDIA_DISCONNECT,
1781 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1784 /* reset buffered link quality information */
1785 prAdapter->fgIsLinkQualityValid = FALSE;
1786 prAdapter->fgIsLinkRateValid = FALSE;
1788 else if(prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_CONNECTED) { // connected
1789 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1791 // fill information for association result
1792 prAdapter->rWlanInfo.rCurrBssId.rSsid.u4SsidLen
1793 = prConnectionStatus->ucSsidLen;
1794 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.rSsid.aucSsid,
1795 prConnectionStatus->aucSsid,
1796 prConnectionStatus->ucSsidLen);
1797 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
1798 prConnectionStatus->aucBssid,
1800 prAdapter->rWlanInfo.rCurrBssId.u4Privacy
1801 = prConnectionStatus->ucEncryptStatus; // @FIXME
1802 prAdapter->rWlanInfo.rCurrBssId.rRssi
1804 prAdapter->rWlanInfo.rCurrBssId.eNetworkTypeInUse
1805 = PARAM_NETWORK_TYPE_AUTOMODE; //@FIXME
1806 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4BeaconPeriod
1807 = prConnectionStatus->u2BeaconPeriod;
1808 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4ATIMWindow
1809 = prConnectionStatus->u2ATIMWindow;
1810 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4DSConfig
1811 = prConnectionStatus->u4FreqInKHz;
1812 prAdapter->rWlanInfo.ucNetworkType
1813 = prConnectionStatus->ucNetworkType;
1814 prAdapter->rWlanInfo.rCurrBssId.eOpMode
1815 = (ENUM_PARAM_OP_MODE_T) prConnectionStatus->ucInfraMode;
1817 // always indicate to OS according to MSDN (re-association/roaming)
1818 if(kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_CONNECTED) {
1819 kalIndicateStatusAndComplete(prGlueInfo,
1820 WLAN_STATUS_MEDIA_CONNECT,
1825 /* connected -> connected : roaming ? */
1826 kalIndicateStatusAndComplete(prGlueInfo,
1827 WLAN_STATUS_ROAM_OUT_FIND_BEST,
1834 #if CFG_ENABLE_BT_OVER_WIFI
1835 case NETWORK_TYPE_BOW_INDEX:
1839 #if CFG_ENABLE_WIFI_DIRECT
1840 case NETWORK_TYPE_P2P_INDEX:
1847 return WLAN_STATUS_SUCCESS;
1848 } /* nicMediaStateChange */
1850 /*----------------------------------------------------------------------------*/
1852 * @brief This utility function is used to convert between
1853 * frequency and channel number
1855 * @param u4ChannelNum
1857 * @retval - Frequency in unit of KHz, 0 for invalid channel number
1859 /*----------------------------------------------------------------------------*/
1861 nicChannelNum2Freq (
1862 UINT_32 u4ChannelNum
1865 UINT_32 u4ChannelInMHz;
1867 if(u4ChannelNum >= 1 && u4ChannelNum <= 13) {
1868 u4ChannelInMHz = 2412 + (u4ChannelNum - 1) * 5;
1870 else if(u4ChannelNum == 14) {
1871 u4ChannelInMHz = 2484;
1873 else if(u4ChannelNum == 133) {
1874 u4ChannelInMHz = 3665; // 802.11y
1876 else if(u4ChannelNum == 137) {
1877 u4ChannelInMHz = 3685; // 802.11y
1879 else if(u4ChannelNum >= 34 && u4ChannelNum <= 165) {
1880 u4ChannelInMHz = 5000 + u4ChannelNum * 5;
1882 else if(u4ChannelNum >= 183 && u4ChannelNum <= 196) {
1883 u4ChannelInMHz = 4000 + u4ChannelNum * 5;
1889 return 1000 * u4ChannelInMHz;
1893 /*----------------------------------------------------------------------------*/
1895 * @brief This utility function is used to convert between
1896 * frequency and channel number
1898 * @param u4FreqInKHz
1900 * @retval - Frequency Number, 0 for invalid freqency
1902 /*----------------------------------------------------------------------------*/
1904 nicFreq2ChannelNum (
1908 switch(u4FreqInKHz) {
1938 return 133; // 802.11y
1940 return 137; // 802.11y
2027 /* firmware command wrapper */
2028 /* NETWORK (WIFISYS) */
2029 /*----------------------------------------------------------------------------*/
2031 * @brief This utility function is used to activate WIFISYS for specified network
2033 * @param prAdapter Pointer of ADAPTER_T
2034 * eNetworkTypeIdx Index of network type
2038 /*----------------------------------------------------------------------------*/
2041 IN P_ADAPTER_T prAdapter,
2042 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2045 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
2046 P_BSS_INFO_T prBssInfo;
2049 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2051 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2052 rCmdActivateCtrl.ucActive = 1;
2054 if (((UINT_8) eNetworkTypeIdx) < NETWORK_TYPE_INDEX_NUM) {
2055 prBssInfo = &prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx];
2056 prBssInfo->fg40mBwAllowed = FALSE;
2057 prBssInfo->fgAssoc40mBwAllowed = FALSE;
2060 return wlanSendSetQueryCmd(prAdapter,
2061 CMD_ID_BSS_ACTIVATE_CTRL,
2067 sizeof(CMD_BSS_ACTIVATE_CTRL),
2068 (PUINT_8)&rCmdActivateCtrl,
2074 /*----------------------------------------------------------------------------*/
2076 * @brief This utility function is used to deactivate WIFISYS for specified network
2078 * @param prAdapter Pointer of ADAPTER_T
2079 * eNetworkTypeIdx Index of network type
2083 /*----------------------------------------------------------------------------*/
2085 nicDeactivateNetwork(
2086 IN P_ADAPTER_T prAdapter,
2087 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2090 WLAN_STATUS u4Status;
2091 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
2094 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2096 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2097 rCmdActivateCtrl.ucActive = 0;
2099 u4Status = wlanSendSetQueryCmd(prAdapter,
2100 CMD_ID_BSS_ACTIVATE_CTRL,
2106 sizeof(CMD_BSS_ACTIVATE_CTRL),
2107 (PUINT_8)&rCmdActivateCtrl,
2111 /* free all correlated station records */
2112 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2113 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2114 nicFreePendingTxMsduInfoByNetwork(prAdapter, eNetworkTypeIdx);
2115 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2122 /*----------------------------------------------------------------------------*/
2124 * @brief This utility function is used to sync bss info with firmware
2125 * when a new BSS has been connected or disconnected
2127 * @param prAdapter Pointer of ADAPTER_T
2128 * eNetworkTypeIdx Index of BSS-INFO type
2132 /*----------------------------------------------------------------------------*/
2135 IN P_ADAPTER_T prAdapter,
2136 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2139 WLAN_STATUS u4Status;
2140 P_BSS_INFO_T prBssInfo;
2141 CMD_SET_BSS_INFO rCmdSetBssInfo;
2144 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2146 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2148 kalMemZero(&rCmdSetBssInfo, sizeof(CMD_SET_BSS_INFO));
2150 rCmdSetBssInfo.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2151 rCmdSetBssInfo.ucConnectionState = (UINT_8)prBssInfo->eConnectionState;
2152 rCmdSetBssInfo.ucCurrentOPMode = (UINT_8)prBssInfo->eCurrentOPMode;
2153 rCmdSetBssInfo.ucSSIDLen = (UINT_8)prBssInfo->ucSSIDLen;
2154 kalMemCopy(rCmdSetBssInfo.aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
2155 COPY_MAC_ADDR(rCmdSetBssInfo.aucBSSID, prBssInfo->aucBSSID);
2156 rCmdSetBssInfo.ucIsQBSS = (UINT_8)prBssInfo->fgIsQBSS;
2157 rCmdSetBssInfo.ucNonHTBasicPhyType = prBssInfo->ucNonHTBasicPhyType;
2158 rCmdSetBssInfo.u2OperationalRateSet = prBssInfo->u2OperationalRateSet;
2159 rCmdSetBssInfo.u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
2160 rCmdSetBssInfo.ucPhyTypeSet = prBssInfo->ucPhyTypeSet;
2161 #if CFG_ENABLE_WIFI_DIRECT
2162 if(prAdapter->fgIsP2PRegistered) {
2163 COPY_MAC_ADDR(rCmdSetBssInfo.aucOwnMac, prBssInfo->aucOwnMacAddr);
2167 rlmFillSyncCmdParam(&rCmdSetBssInfo.rBssRlmParam, prBssInfo);
2169 rCmdSetBssInfo.fgWapiMode = (UINT_8)FALSE;
2171 if(rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
2172 P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2174 rCmdSetBssInfo.ucAuthMode = (UINT_8)prConnSettings->eAuthMode;
2175 rCmdSetBssInfo.ucEncStatus = (UINT_8)prConnSettings->eEncStatus;
2176 rCmdSetBssInfo.fgWapiMode = (UINT_8)prConnSettings->fgWapiMode;
2178 #if CFG_ENABLE_BT_OVER_WIFI
2179 else if(rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX) {
2180 //P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2181 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2182 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2186 #if CFG_ENABLE_WIFI_DIRECT
2187 if(prAdapter->fgIsP2PRegistered) {
2188 if (kalP2PGetCipher(prAdapter->prGlueInfo)) {
2189 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2190 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2193 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_OPEN;
2194 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION_DISABLED;
2196 /* Need the probe response to detect the PBC overlap */
2197 rCmdSetBssInfo.fgIsApMode = p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo);
2200 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2201 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2205 if(eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX &&
2206 prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
2207 prBssInfo->prStaRecOfAP != NULL) {
2208 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2210 cnmAisInfraConnectNotify(prAdapter);
2212 #if CFG_ENABLE_WIFI_DIRECT
2213 else if ((prAdapter->fgIsP2PRegistered) &&
2214 (eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) &&
2215 (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) &&
2216 (prBssInfo->prStaRecOfAP != NULL)) {
2217 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2221 #if CFG_ENABLE_BT_OVER_WIFI
2222 else if (eNetworkTypeIdx == NETWORK_TYPE_BOW_INDEX &&
2223 prBssInfo->eCurrentOPMode == OP_MODE_BOW &&
2224 prBssInfo->prStaRecOfAP != NULL) {
2225 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2229 rCmdSetBssInfo.ucStaRecIdxOfAP = STA_REC_INDEX_NOT_FOUND;
2232 u4Status = wlanSendSetQueryCmd(prAdapter,
2233 CMD_ID_SET_BSS_INFO,
2239 sizeof(CMD_SET_BSS_INFO),
2240 (PUINT_8)&rCmdSetBssInfo,
2244 /* if BSS-INFO is going to be disconnected state, free all correlated station records */
2245 if(prBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
2246 /* clear client list */
2247 bssClearClientList(prAdapter, prBssInfo);
2249 /* free all correlated station records */
2250 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2251 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2252 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2259 /* BSS-INFO Indication (PM) */
2260 /*----------------------------------------------------------------------------*/
2262 * @brief This utility function is used to indicate PM that
2263 * a BSS has been created. (for AdHoc / P2P-GO)
2265 * @param prAdapter Pointer of ADAPTER_T
2266 * eNetworkTypeIdx Index of BSS-INFO
2270 /*----------------------------------------------------------------------------*/
2272 nicPmIndicateBssCreated(
2273 IN P_ADAPTER_T prAdapter,
2274 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2277 P_BSS_INFO_T prBssInfo;
2278 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated;
2281 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2283 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2285 rCmdIndicatePmBssCreated.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2286 rCmdIndicatePmBssCreated.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2287 rCmdIndicatePmBssCreated.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2288 rCmdIndicatePmBssCreated.u2AtimWindow = prBssInfo->u2ATIMWindow;
2290 return wlanSendSetQueryCmd(prAdapter,
2291 CMD_ID_INDICATE_PM_BSS_CREATED,
2297 sizeof(CMD_INDICATE_PM_BSS_CREATED),
2298 (PUINT_8)&rCmdIndicatePmBssCreated,
2304 /*----------------------------------------------------------------------------*/
2306 * @brief This utility function is used to indicate PM that
2307 * a BSS has been connected
2309 * @param prAdapter Pointer of ADAPTER_T
2310 * eNetworkTypeIdx Index of BSS-INFO
2314 /*----------------------------------------------------------------------------*/
2316 nicPmIndicateBssConnected(
2317 IN P_ADAPTER_T prAdapter,
2318 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2321 P_BSS_INFO_T prBssInfo;
2322 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected;
2325 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2327 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2329 rCmdIndicatePmBssConnected.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2330 rCmdIndicatePmBssConnected.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2331 rCmdIndicatePmBssConnected.u2AssocId = prBssInfo->u2AssocId;
2332 rCmdIndicatePmBssConnected.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2333 rCmdIndicatePmBssConnected.u2AtimWindow = prBssInfo->u2ATIMWindow;
2335 rCmdIndicatePmBssConnected.ucBmpDeliveryAC = prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC;
2336 rCmdIndicatePmBssConnected.ucBmpTriggerAC = prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC;
2338 //DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x",
2339 //rCmdIndicatePmBssConnected.ucBmpDeliveryAC,
2340 //rCmdIndicatePmBssConnected.ucBmpTriggerAC);
2342 if ((eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX)
2343 #if CFG_ENABLE_WIFI_DIRECT
2344 || ((eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->fgIsP2PRegistered))
2347 if(prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
2348 rCmdIndicatePmBssConnected.fgIsUapsdConnection = (UINT_8)prBssInfo->prStaRecOfAP->fgIsUapsdSupported;
2351 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0; //@FIXME
2355 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0;
2358 return wlanSendSetQueryCmd(prAdapter,
2359 CMD_ID_INDICATE_PM_BSS_CONNECTED,
2365 sizeof(CMD_INDICATE_PM_BSS_CONNECTED),
2366 (PUINT_8)&rCmdIndicatePmBssConnected,
2372 /*----------------------------------------------------------------------------*/
2374 * @brief This utility function is used to indicate PM that
2375 * a BSS has been disconnected
2377 * @param prAdapter Pointer of ADAPTER_T
2378 * eNetworkTypeIdx Index of BSS-INFO
2382 /*----------------------------------------------------------------------------*/
2384 nicPmIndicateBssAbort(
2385 IN P_ADAPTER_T prAdapter,
2386 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2389 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort;
2392 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2394 rCmdIndicatePmBssAbort.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2396 return wlanSendSetQueryCmd(prAdapter,
2397 CMD_ID_INDICATE_PM_BSS_ABORT,
2403 sizeof(CMD_INDICATE_PM_BSS_ABORT),
2404 (PUINT_8)&rCmdIndicatePmBssAbort,
2410 nicConfigPowerSaveProfile (
2411 IN P_ADAPTER_T prAdapter,
2412 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2413 PARAM_POWER_MODE ePwrMode,
2414 BOOLEAN fgEnCmdEvent
2417 DEBUGFUNC("nicConfigPowerSaveProfile");
2418 DBGLOG(INIT, TRACE, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2419 eNetTypeIndex, ePwrMode, fgEnCmdEvent));
2423 if (eNetTypeIndex >= NETWORK_TYPE_INDEX_NUM) {
2425 return WLAN_STATUS_NOT_SUPPORTED;
2428 // prAdapter->rWlanInfo.ePowerSaveMode.ucNetTypeIndex = eNetTypeIndex;
2429 // prAdapter->rWlanInfo.ePowerSaveMode.ucPsProfile = (UINT_8)ePwrMode;
2430 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucNetTypeIndex = eNetTypeIndex;
2431 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucPsProfile = (UINT_8)ePwrMode;
2433 return wlanSendSetQueryCmd(prAdapter,
2434 CMD_ID_POWER_SAVE_MODE,
2437 (fgEnCmdEvent ? TRUE : FALSE),
2438 (fgEnCmdEvent ? nicCmdEventSetCommon : NULL),
2439 (fgEnCmdEvent ? nicOidCmdTimeoutCommon : NULL),
2440 sizeof(CMD_PS_PROFILE_T),
2441 (PUINT_8)&(prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex]),
2443 sizeof(PARAM_POWER_MODE)
2446 } /* end of wlanoidSetAcpiDevicePowerStateMode() */
2450 IN P_ADAPTER_T prAdapter,
2451 BOOLEAN fgEnterCtia,
2452 BOOLEAN fgEnCmdEvent
2455 CMD_SW_DBG_CTRL_T rCmdSwCtrl;
2456 CMD_ACCESS_REG rCmdAccessReg;
2457 WLAN_STATUS rWlanStatus;
2459 DEBUGFUNC("nicEnterCtiaMode");
2460 DBGLOG(INIT, TRACE, ("nicEnterCtiaMode: %d\n", fgEnterCtia));
2464 rWlanStatus = WLAN_STATUS_SUCCESS;
2467 // 1. Disable On-Lin Scan
2468 prAdapter->fgEnOnlineScan = FALSE;
2470 // 3. Disable FIFO FULL no ack
2471 rCmdAccessReg.u4Address = 0x60140028;
2472 rCmdAccessReg.u4Data = 0x904;
2473 wlanSendSetQueryCmd(prAdapter,
2480 sizeof(CMD_ACCESS_REG),
2481 (PUINT_8)&rCmdAccessReg,
2486 // 4. Disable Roaming
2487 rCmdSwCtrl.u4Id = 0x90000204;
2488 rCmdSwCtrl.u4Data = 0x0;
2489 wlanSendSetQueryCmd(prAdapter,
2496 sizeof(CMD_SW_DBG_CTRL_T),
2497 (PUINT_8)&rCmdSwCtrl,
2502 rCmdSwCtrl.u4Id = 0x90000200;
2503 rCmdSwCtrl.u4Data = 0x820000;
2504 wlanSendSetQueryCmd(prAdapter,
2511 sizeof(CMD_SW_DBG_CTRL_T),
2512 (PUINT_8)&rCmdSwCtrl,
2517 // Disalbe auto tx power
2518 rCmdSwCtrl.u4Id = 0xa0100003;
2519 rCmdSwCtrl.u4Data = 0x0;
2520 wlanSendSetQueryCmd(prAdapter,
2527 sizeof(CMD_SW_DBG_CTRL_T),
2528 (PUINT_8)&rCmdSwCtrl,
2533 // 2. Keep at CAM mode
2535 PARAM_POWER_MODE ePowerMode;
2537 prAdapter->u4CtiaPowerMode = 0;
2538 prAdapter->fgEnCtiaPowerMode = TRUE;
2540 ePowerMode = Param_PowerModeCAM;
2541 rWlanStatus = nicConfigPowerSaveProfile(
2543 NETWORK_TYPE_AIS_INDEX,
2548 // 5. Disable Beacon Timeout Detection
2549 prAdapter->fgDisBcnLostDetection = TRUE;
2552 // 1. Enaable On-Lin Scan
2553 prAdapter->fgEnOnlineScan = TRUE;
2555 // 3. Enable FIFO FULL no ack
2556 rCmdAccessReg.u4Address = 0x60140028;
2557 rCmdAccessReg.u4Data = 0x905;
2558 wlanSendSetQueryCmd(prAdapter,
2565 sizeof(CMD_ACCESS_REG),
2566 (PUINT_8)&rCmdAccessReg,
2571 // 4. Enable Roaming
2572 rCmdSwCtrl.u4Id = 0x90000204;
2573 rCmdSwCtrl.u4Data = 0x1;
2574 wlanSendSetQueryCmd(prAdapter,
2581 sizeof(CMD_SW_DBG_CTRL_T),
2582 (PUINT_8)&rCmdSwCtrl,
2587 rCmdSwCtrl.u4Id = 0x90000200;
2588 rCmdSwCtrl.u4Data = 0x820000;
2589 wlanSendSetQueryCmd(prAdapter,
2596 sizeof(CMD_SW_DBG_CTRL_T),
2597 (PUINT_8)&rCmdSwCtrl,
2602 // Enable auto tx power
2605 rCmdSwCtrl.u4Id = 0xa0100003;
2606 rCmdSwCtrl.u4Data = 0x1;
2607 wlanSendSetQueryCmd(prAdapter,
2614 sizeof(CMD_SW_DBG_CTRL_T),
2615 (PUINT_8)&rCmdSwCtrl,
2621 // 2. Keep at Fast PS
2623 PARAM_POWER_MODE ePowerMode;
2625 prAdapter->u4CtiaPowerMode = 2;
2626 prAdapter->fgEnCtiaPowerMode = TRUE;
2628 ePowerMode = Param_PowerModeFast_PSP;
2629 rWlanStatus = nicConfigPowerSaveProfile(
2631 NETWORK_TYPE_AIS_INDEX,
2636 // 5. Enable Beacon Timeout Detection
2637 prAdapter->fgDisBcnLostDetection = FALSE;
2642 } /* end of nicEnterCtiaMode() */
2644 /*----------------------------------------------------------------------------*/
2646 * @brief This utility function is used to indicate firmware domain
2647 * for beacon generation parameters
2649 * @param prAdapter Pointer of ADAPTER_T
2650 * eIeUpdMethod, Update Method
2651 * eNetTypeIndex Index of Network
2652 * u2Capability Capability
2653 * aucIe Pointer to buffer of IEs
2654 * u2IELen Length of IEs
2656 * @retval - WLAN_STATUS_SUCCESS
2657 * WLAN_STATUS_FAILURE
2658 * WLAN_STATUS_PENDING
2659 * WLAN_STATUS_INVALID_DATA
2661 /*----------------------------------------------------------------------------*/
2663 nicUpdateBeaconIETemplate (
2664 IN P_ADAPTER_T prAdapter,
2665 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod,
2666 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2667 IN UINT_16 u2Capability,
2672 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate;
2673 UINT_16 u2CmdBufLen = 0;
2674 P_GLUE_INFO_T prGlueInfo;
2675 P_CMD_INFO_T prCmdInfo;
2676 P_WIFI_CMD_T prWifiCmd;
2679 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2680 DBGLOG(INIT, LOUD, ("\n"));
2682 printk("nicUpdateBeaconIETemplate\n");
2685 prGlueInfo = prAdapter->prGlueInfo;
2687 if (u2IELen > MAX_IE_LENGTH) {
2688 return WLAN_STATUS_INVALID_DATA;
2691 if (eIeUpdMethod == IE_UPD_METHOD_UPDATE_RANDOM
2692 || eIeUpdMethod == IE_UPD_METHOD_UPDATE_ALL) {
2693 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, aucIE) + u2IELen;
2695 else if (eIeUpdMethod == IE_UPD_METHOD_DELETE_ALL) {
2696 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, u2IELen);
2700 return WLAN_STATUS_FAILURE;
2703 // prepare command info
2704 prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u2CmdBufLen));
2706 DBGLOG(INIT, ERROR, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2707 printk("Allocate CMD_INFO_T ==> FAILED.\n");
2708 return WLAN_STATUS_FAILURE;
2711 // increase command sequence number
2712 ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
2713 DBGLOG(REQ, TRACE, ("ucCmdSeqNum =%d\n", ucCmdSeqNum));
2715 // Setup common CMD Info Packet
2716 prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
2717 prCmdInfo->eNetworkType = eNetTypeIndex;
2718 prCmdInfo->u2InfoBufLen = (UINT_16)(CMD_HDR_SIZE + u2CmdBufLen);
2719 prCmdInfo->pfCmdDoneHandler = NULL; //@FIXME
2720 prCmdInfo->pfCmdTimeoutHandler = NULL; //@FIXME
2721 prCmdInfo->fgIsOid = FALSE;
2722 prCmdInfo->ucCID = CMD_ID_UPDATE_BEACON_CONTENT;
2723 prCmdInfo->fgSetQuery = TRUE;
2724 prCmdInfo->fgNeedResp = FALSE;
2725 prCmdInfo->fgDriverDomainMCR = FALSE;
2726 prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
2727 prCmdInfo->u4SetInfoLen = u2CmdBufLen;
2728 prCmdInfo->pvInformationBuffer = NULL;
2729 prCmdInfo->u4InformationBufferLength = 0;
2731 // Setup WIFI_CMD_T (no payload)
2732 prWifiCmd = (P_WIFI_CMD_T)(prCmdInfo->pucInfoBuffer);
2733 prWifiCmd->u2TxByteCount_UserPriority = prCmdInfo->u2InfoBufLen;
2734 prWifiCmd->ucCID = prCmdInfo->ucCID;
2735 prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
2736 prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
2738 prCmdBcnUpdate = (P_CMD_BEACON_TEMPLATE_UPDATE)(prWifiCmd->aucBuffer);
2740 // fill beacon updating command
2741 prCmdBcnUpdate->ucUpdateMethod = (UINT_8) eIeUpdMethod;
2742 prCmdBcnUpdate->ucNetTypeIndex = (UINT_8) eNetTypeIndex;
2743 prCmdBcnUpdate->u2Capability = u2Capability;
2744 prCmdBcnUpdate->u2IELen = u2IELen;
2746 kalMemCopy(prCmdBcnUpdate->aucIE, aucIe, u2IELen);
2749 // insert into prCmdQueue
2750 kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T)prCmdInfo);
2752 // wakeup txServiceThread later
2753 GLUE_SET_EVENT(prGlueInfo);
2754 return WLAN_STATUS_PENDING;
2758 /*----------------------------------------------------------------------------*/
2760 * @brief This utility function is used to initialization PHY related
2763 * @param prAdapter Pointer of ADAPTER_T
2767 /*----------------------------------------------------------------------------*/
2769 nicSetAvailablePhyTypeSet (
2770 IN P_ADAPTER_T prAdapter
2773 P_CONNECTION_SETTINGS_T prConnSettings;
2777 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2779 if (prConnSettings->eDesiredPhyConfig >= PHY_CONFIG_NUM) {
2784 prAdapter->rWifiVar.ucAvailablePhyTypeSet =
2785 aucPhyCfg2PhyTypeSet[prConnSettings->eDesiredPhyConfig];
2787 if (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_BIT_ERP) {
2788 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_ERP_INDEX;
2790 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2791 else /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */ {
2792 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_HR_DSSS_INDEX;
2799 /*----------------------------------------------------------------------------*/
2801 * @brief This utility function is used to update WMM Parms
2803 * @param prAdapter Pointer of ADAPTER_T
2804 * eNetworkTypeIdx Index of BSS-INFO
2808 /*----------------------------------------------------------------------------*/
2810 nicQmUpdateWmmParms(
2811 IN P_ADAPTER_T prAdapter,
2812 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2815 P_BSS_INFO_T prBssInfo;
2816 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms;
2819 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2821 DBGLOG(QM, EVENT, ("sizeof(AC_QUE_PARMS_T): %d \n", sizeof(AC_QUE_PARMS_T)));
2822 DBGLOG(QM, EVENT, ("sizeof(CMD_UPDATE_WMM_PARMS): %d \n", sizeof(CMD_UPDATE_WMM_PARMS_T)));
2823 DBGLOG(QM, EVENT, ("sizeof(WIFI_CMD_T): %d \n", sizeof(WIFI_CMD_T)));
2825 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2826 rCmdUpdateWmmParms.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2827 kalMemCopy(&rCmdUpdateWmmParms.arACQueParms[0], &prBssInfo->arACQueParms[0],
2828 (sizeof(AC_QUE_PARMS_T)*AC_NUM));
2830 rCmdUpdateWmmParms.fgIsQBSS = prBssInfo->fgIsQBSS;
2832 return wlanSendSetQueryCmd(prAdapter,
2833 CMD_ID_UPDATE_WMM_PARMS,
2839 sizeof(CMD_UPDATE_WMM_PARMS_T),
2840 (PUINT_8)&rCmdUpdateWmmParms,
2846 /*----------------------------------------------------------------------------*/
2848 * @brief This utility function is used to update TX power gain corresponding to
2849 * each band/modulation combination
2851 * @param prAdapter Pointer of ADAPTER_T
2852 * prTxPwrParam Pointer of TX power parameters
2854 * @retval WLAN_STATUS_PENDING
2855 * WLAN_STATUS_FAILURE
2857 /*----------------------------------------------------------------------------*/
2860 IN P_ADAPTER_T prAdapter,
2861 IN P_CMD_TX_PWR_T prTxPwrParam
2864 DEBUGFUNC("nicUpdateTxPower");
2868 return wlanSendSetQueryCmd(prAdapter,
2875 sizeof(CMD_TX_PWR_T),
2876 (PUINT_8)prTxPwrParam,
2881 /*----------------------------------------------------------------------------*/
2883 * @brief This utility function is used to set auto tx power parameter
2885 * @param prAdapter Pointer of ADAPTER_T
2886 * prTxPwrParam Pointer of Auto TX power parameters
2888 * @retval WLAN_STATUS_PENDING
2889 * WLAN_STATUS_FAILURE
2891 /*----------------------------------------------------------------------------*/
2894 IN P_ADAPTER_T prAdapter,
2895 IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam
2898 DEBUGFUNC("nicSetAutoTxPower");
2902 return wlanSendSetQueryCmd(prAdapter,
2903 CMD_ID_SET_AUTOPWR_CTRL,
2909 sizeof(CMD_AUTO_POWER_PARAM_T),
2910 (PUINT_8)prAutoPwrParam,
2916 /*----------------------------------------------------------------------------*/
2918 * @brief This utility function is used to update TX power gain corresponding to
2919 * each band/modulation combination
2921 * @param prAdapter Pointer of ADAPTER_T
2922 * prTxPwrParam Pointer of TX power parameters
2924 * @retval WLAN_STATUS_PENDING
2925 * WLAN_STATUS_FAILURE
2927 /*----------------------------------------------------------------------------*/
2929 nicSetAutoTxPowerControl(
2930 IN P_ADAPTER_T prAdapter,
2931 IN P_CMD_TX_PWR_T prTxPwrParam
2934 DEBUGFUNC("nicUpdateTxPower");
2938 return wlanSendSetQueryCmd(prAdapter,
2945 sizeof(CMD_TX_PWR_T),
2946 (PUINT_8)prTxPwrParam,
2952 /*----------------------------------------------------------------------------*/
2954 * @brief This utility function is used to update power offset around 5GHz band
2956 * @param prAdapter Pointer of ADAPTER_T
2957 * pr5GPwrOffset Pointer of 5GHz power offset parameter
2959 * @retval WLAN_STATUS_PENDING
2960 * WLAN_STATUS_FAILURE
2962 /*----------------------------------------------------------------------------*/
2965 IN P_ADAPTER_T prAdapter,
2966 IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset
2969 DEBUGFUNC("nicUpdate5GOffset");
2973 return wlanSendSetQueryCmd(prAdapter,
2974 CMD_ID_SET_5G_PWR_OFFSET,
2980 sizeof(CMD_5G_PWR_OFFSET_T),
2981 (PUINT_8)pr5GPwrOffset,
2987 /*----------------------------------------------------------------------------*/
2989 * @brief This utility function is used to update DPD calibration result
2991 * @param prAdapter Pointer of ADAPTER_T
2992 * pr5GPwrOffset Pointer of parameter for DPD calibration result
2994 * @retval WLAN_STATUS_PENDING
2995 * WLAN_STATUS_FAILURE
2997 /*----------------------------------------------------------------------------*/
3000 IN P_ADAPTER_T prAdapter,
3001 IN P_CMD_PWR_PARAM_T prDpdCalResult
3004 DEBUGFUNC("nicUpdateDPD");
3008 return wlanSendSetQueryCmd(prAdapter,
3009 CMD_ID_SET_PWR_PARAM,
3015 sizeof(CMD_PWR_PARAM_T),
3016 (PUINT_8)prDpdCalResult,
3022 /*----------------------------------------------------------------------------*/
3024 * @brief This utility function starts system service such as timer and
3027 * @param prAdapter Pointer of ADAPTER_T
3031 /*----------------------------------------------------------------------------*/
3033 nicInitSystemService (
3034 IN P_ADAPTER_T prAdapter
3039 // <1> Initialize MGMT Memory pool and STA_REC
3040 cnmMemInit(prAdapter);
3041 cnmStaRecInit(prAdapter);
3042 cmdBufInitialize(prAdapter);
3044 // <2> Mailbox Initialization
3045 mboxInitialize(prAdapter);
3047 // <3> Timer Initialization
3048 cnmTimerInitialize(prAdapter);
3054 /*----------------------------------------------------------------------------*/
3056 * @brief This utility function reset some specific system service,
3059 * @param prAdapter Pointer of ADAPTER_T
3063 /*----------------------------------------------------------------------------*/
3065 nicResetSystemService (
3066 IN P_ADAPTER_T prAdapter
3073 /*----------------------------------------------------------------------------*/
3075 * @brief This utility function is used to update WMM Parms
3077 * @param prAdapter Pointer of ADAPTER_T
3081 /*----------------------------------------------------------------------------*/
3083 nicUninitSystemService (
3084 IN P_ADAPTER_T prAdapter
3089 /* Timer Destruction */
3090 cnmTimerDestroy(prAdapter);
3092 /* Mailbox Destruction */
3093 mboxDestroy(prAdapter);
3099 /*----------------------------------------------------------------------------*/
3101 * @brief This utility function is used to update WMM Parms
3103 * @param prAdapter Pointer of ADAPTER_T
3107 /*----------------------------------------------------------------------------*/
3110 IN P_ADAPTER_T prAdapter,
3111 IN P_REG_INFO_T prRegInfo
3116 /* CNM Module - initialization */
3119 /* RLM Module - initialization */
3120 rlmFsmEventInit(prAdapter);
3122 /* SCN Module - initialization */
3125 /* AIS Module - intiailization */
3126 aisInitializeConnectionSettings(prAdapter, prRegInfo);
3127 aisFsmInit(prAdapter);
3129 #if CFG_SUPPORT_ROAMING
3130 /* Roaming Module - intiailization */
3131 roamingFsmInit(prAdapter);
3132 #endif /* CFG_SUPPORT_ROAMING */
3134 #if CFG_SUPPORT_SWCR
3135 swCrDebugInit(prAdapter);
3136 #endif /* CFG_SUPPORT_SWCR */
3142 /*----------------------------------------------------------------------------*/
3144 * @brief This utility function is used to update WMM Parms
3146 * @param prAdapter Pointer of ADAPTER_T
3150 /*----------------------------------------------------------------------------*/
3153 IN P_ADAPTER_T prAdapter
3158 #if CFG_SUPPORT_SWCR
3159 swCrDebugUninit(prAdapter);
3160 #endif /* CFG_SUPPORT_SWCR */
3162 #if CFG_SUPPORT_ROAMING
3163 /* Roaming Module - unintiailization */
3164 roamingFsmUninit(prAdapter);
3165 #endif /* CFG_SUPPORT_ROAMING */
3167 /* AIS Module - unintiailization */
3168 aisFsmUninit(prAdapter);
3170 /* SCN Module - unintiailization */
3171 scnUninit(prAdapter);
3173 /* RLM Module - uninitialization */
3174 rlmFsmEventUninit(prAdapter);
3176 /* CNM Module - uninitialization */
3177 cnmUninit(prAdapter);
3183 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
3184 /*----------------------------------------------------------------------------*/
3186 * @brief This utility function is to inform firmware to enable MCU clock gating
3188 * @param prAdapter Pointer of ADAPTER_T
3192 /*----------------------------------------------------------------------------*/
3194 nicEnableClockGating (
3195 IN P_ADAPTER_T prAdapter
3198 UINT_32 i, u4WHISR = 0;
3202 if(prAdapter->fgIsClockGatingEnabled == TRUE) {
3203 return WLAN_STATUS_SUCCESS;
3206 nicSetSwIntr(prAdapter, REQ_GATING_ENABLE_H2D_INT);
3209 while(i < GATING_CONTROL_POLL_LIMIT) {
3210 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
3211 || fgIsBusAccessFailed == TRUE) {
3212 return WLAN_STATUS_FAILURE;
3215 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
3217 if(u4WHISR & ACK_GATING_ENABLE_D2H_INT) {
3218 prAdapter->fgIsClockGatingEnabled = TRUE;
3219 return WLAN_STATUS_SUCCESS;
3224 return WLAN_STATUS_PENDING;
3229 /*----------------------------------------------------------------------------*/
3231 * @brief This utility function is to inform firmware to disable MCU clock gating
3233 * @param prAdapter Pointer of ADAPTER_T
3237 /*----------------------------------------------------------------------------*/
3239 nicDisableClockGating (
3240 IN P_ADAPTER_T prAdapter
3243 UINT_32 i, u4WHISR = 0;
3247 if(prAdapter->fgIsClockGatingEnabled == FALSE) {
3248 return WLAN_STATUS_SUCCESS;
3251 nicSetSwIntr(prAdapter, REQ_GATING_DISABLE_H2D_INT);
3254 while(i < GATING_CONTROL_POLL_LIMIT) {
3255 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
3256 || fgIsBusAccessFailed == TRUE) {
3257 return WLAN_STATUS_FAILURE;
3260 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
3262 if(u4WHISR & ACK_GATING_DISABLE_D2H_INT) {
3263 prAdapter->fgIsClockGatingEnabled = FALSE;
3264 return WLAN_STATUS_SUCCESS;
3269 return WLAN_STATUS_PENDING;
3275 /*----------------------------------------------------------------------------*/
3277 * @brief This function is invoked to buffer scan result
3279 * @param prAdapter Pointer to the Adapter structure.
3280 * @param rMacAddr BSSID
3281 * @param prSsid Pointer to SSID
3282 * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
3283 * @param rRssi Received Strength (-10 ~ -200 dBm)
3284 * @param eNetworkType Network Type (a/b/g)
3285 * @param prConfiguration Network Parameter
3286 * @param eOpMode Infra/Ad-Hoc
3287 * @param rSupportedRates Supported basic rates
3288 * @param u2IELength IE Length
3289 * @param pucIEBuf Pointer to Information Elements(IEs)
3293 /*----------------------------------------------------------------------------*/
3296 IN P_ADAPTER_T prAdapter,
3297 IN PARAM_MAC_ADDRESS rMacAddr,
3298 IN P_PARAM_SSID_T prSsid,
3299 IN UINT_32 u4Privacy,
3300 IN PARAM_RSSI rRssi,
3301 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType,
3302 IN P_PARAM_802_11_CONFIG_T prConfiguration,
3303 IN ENUM_PARAM_OP_MODE_T eOpMode,
3304 IN PARAM_RATES_EX rSupportedRates,
3305 IN UINT_16 u2IELength,
3311 UINT_32 u4IdxWeakest = 0;
3312 PARAM_RSSI rWeakestRssi;
3313 UINT_32 u4BufferSize;
3317 rWeakestRssi = (PARAM_RSSI)INT_MAX;
3318 u4BufferSize = sizeof(prAdapter->rWlanInfo.aucScanIEBuf) / sizeof(prAdapter->rWlanInfo.aucScanIEBuf[0]);
3322 // decide to replace or add
3323 for(i = 0 ; i < prAdapter->rWlanInfo.u4ScanResultNum ; i++) {
3324 // find weakest entry && not connected one
3325 if(UNEQUAL_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, prAdapter->rWlanInfo.rCurrBssId.arMacAddress)
3326 && prAdapter->rWlanInfo.arScanResult[i].rRssi < rWeakestRssi) {
3328 rWeakestRssi = prAdapter->rWlanInfo.arScanResult[i].rRssi;
3331 if(prAdapter->rWlanInfo.arScanResult[i].eOpMode == eOpMode &&
3332 EQUAL_MAC_ADDR(&(prAdapter->rWlanInfo.arScanResult[i].arMacAddress), rMacAddr) &&
3333 (EQUAL_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3334 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3337 || prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen == 0)) {
3341 // free IE buffer then zero
3342 nicFreeScanResultIE(prAdapter, i);
3343 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]), OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3346 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3347 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3348 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3349 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3350 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3353 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3354 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3355 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3356 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3358 sizeof(PARAM_802_11_CONFIG_T));
3359 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3360 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3362 sizeof(PARAM_RATES_EX));
3363 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3365 // IE - allocate buffer and update pointer
3366 if(u2IELength > 0) {
3367 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3368 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3372 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3373 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3375 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3378 // buffer is not enough
3379 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3380 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3381 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3385 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3392 if (bReplace == FALSE) {
3393 if (prAdapter->rWlanInfo.u4ScanResultNum < (CFG_MAX_NUM_BSS_LIST - 1)) {
3394 i = prAdapter->rWlanInfo.u4ScanResultNum;
3397 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3398 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3401 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3402 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3403 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3404 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3405 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3408 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3409 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3410 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3411 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3413 sizeof(PARAM_802_11_CONFIG_T));
3414 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3415 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3417 sizeof(PARAM_RATES_EX));
3418 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3420 // IE - allocate buffer and update pointer
3421 if(u2IELength > 0) {
3422 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3423 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3427 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3428 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3430 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3433 // buffer is not enough
3434 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3435 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3436 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3440 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3443 prAdapter->rWlanInfo.u4ScanResultNum++;
3445 else if(rWeakestRssi != (PARAM_RSSI)INT_MAX) {
3446 // replace weakest one
3449 // free IE buffer then zero
3450 nicFreeScanResultIE(prAdapter, i);
3451 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3452 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3455 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3456 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3457 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3458 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3459 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3462 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3463 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3464 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3465 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3467 sizeof(PARAM_802_11_CONFIG_T));
3468 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3469 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3471 sizeof(PARAM_RATES_EX));
3472 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3474 if(u2IELength > 0) {
3475 // IE - allocate buffer and update pointer
3476 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3477 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3481 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3482 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3484 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3487 // buffer is not enough
3488 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3489 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3490 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3494 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3501 /*----------------------------------------------------------------------------*/
3503 * @brief This function is invoked to free IE buffer for dedicated scan result
3505 * @param prAdapter Pointer to the Adapter structure.
3506 * @param u4Idx Index of Scan Result
3510 /*----------------------------------------------------------------------------*/
3512 nicFreeScanResultIE (
3513 IN P_ADAPTER_T prAdapter,
3518 PUINT_8 pucPivot, pucMovePivot;
3519 UINT_32 u4MoveSize, u4FreeSize, u4ReserveSize;
3522 ASSERT(u4Idx < CFG_MAX_NUM_BSS_LIST);
3524 if(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength == 0
3525 || prAdapter->rWlanInfo.apucScanResultIEs[u4Idx] == NULL) {
3529 u4FreeSize = ALIGN_4(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength);
3531 pucPivot = prAdapter->rWlanInfo.apucScanResultIEs[u4Idx];
3532 pucMovePivot = (PUINT_8)((UINT_32)(prAdapter->rWlanInfo.apucScanResultIEs[u4Idx]) + u4FreeSize);
3534 u4ReserveSize = ((UINT_32)pucPivot) - (UINT_32)(&(prAdapter->rWlanInfo.aucScanIEBuf[0]));
3535 u4MoveSize = prAdapter->rWlanInfo.u4ScanIEBufferUsage - u4ReserveSize - u4FreeSize;
3537 // 1. rest of buffer to move forward
3538 kalMemCopy(pucPivot, pucMovePivot, u4MoveSize);
3540 // 1.1 modify pointers
3541 for(i = 0 ; i < prAdapter->rWlanInfo.u4ScanResultNum ; i++) {
3543 if(prAdapter->rWlanInfo.apucScanResultIEs[i] >= pucMovePivot) {
3544 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3545 (PUINT_8)((UINT_32)(prAdapter->rWlanInfo.apucScanResultIEs[i]) - u4FreeSize);
3550 // 1.2 reset the freed one
3551 prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength = 0;
3552 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3554 // 2. reduce IE buffer usage
3555 prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4FreeSize;
3561 /*----------------------------------------------------------------------------*/
3563 * @brief This function is to hack parameters for WLAN TABLE for
3564 * fixed rate settings
3566 * @param prAdapter Pointer to the Adapter structure.
3567 * @param eRateSetting
3568 * @param pu2DesiredNonHTRateSet,
3569 * @param pu2BSSBasicRateSet,
3571 * @param pucSupMcs32
3572 * @param pu2HtCapInfo
3574 * @return WLAN_STATUS_SUCCESS
3576 /*----------------------------------------------------------------------------*/
3578 nicUpdateRateParams (
3579 IN P_ADAPTER_T prAdapter,
3580 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting,
3581 IN PUINT_8 pucDesiredPhyTypeSet,
3582 IN PUINT_16 pu2DesiredNonHTRateSet,
3583 IN PUINT_16 pu2BSSBasicRateSet,
3584 IN PUINT_8 pucMcsSet,
3585 IN PUINT_8 pucSupMcs32,
3586 IN PUINT_16 pu2HtCapInfo
3590 ASSERT(eRateSetting > FIXED_RATE_NONE && eRateSetting < FIXED_RATE_NUM);
3592 switch(prAdapter->rWifiVar.eRateSetting) {
3594 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3595 *pu2DesiredNonHTRateSet = RATE_SET_BIT_1M;
3596 *pu2BSSBasicRateSet = RATE_SET_BIT_1M;
3603 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3604 *pu2DesiredNonHTRateSet = RATE_SET_BIT_2M;
3605 *pu2BSSBasicRateSet = RATE_SET_BIT_2M;
3611 case FIXED_RATE_5_5M:
3612 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3613 *pu2DesiredNonHTRateSet = RATE_SET_BIT_5_5M;
3614 *pu2BSSBasicRateSet = RATE_SET_BIT_5_5M;
3620 case FIXED_RATE_11M:
3621 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3622 *pu2DesiredNonHTRateSet = RATE_SET_BIT_11M;
3623 *pu2BSSBasicRateSet = RATE_SET_BIT_11M;
3630 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3631 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3633 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3634 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3637 *pu2DesiredNonHTRateSet = RATE_SET_BIT_6M;
3638 *pu2BSSBasicRateSet = RATE_SET_BIT_6M;
3645 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3646 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3648 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3649 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3652 *pu2DesiredNonHTRateSet = RATE_SET_BIT_9M;
3653 *pu2BSSBasicRateSet = RATE_SET_BIT_9M;
3659 case FIXED_RATE_12M:
3660 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3661 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3663 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3664 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3667 *pu2DesiredNonHTRateSet = RATE_SET_BIT_12M;
3668 *pu2BSSBasicRateSet = RATE_SET_BIT_12M;
3674 case FIXED_RATE_18M:
3675 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3676 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3678 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3679 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3682 *pu2DesiredNonHTRateSet = RATE_SET_BIT_18M;
3683 *pu2BSSBasicRateSet = RATE_SET_BIT_18M;
3689 case FIXED_RATE_24M:
3690 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3691 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3693 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3694 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3697 *pu2DesiredNonHTRateSet = RATE_SET_BIT_24M;
3698 *pu2BSSBasicRateSet = RATE_SET_BIT_24M;
3704 case FIXED_RATE_36M:
3705 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3706 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3708 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3709 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3712 *pu2DesiredNonHTRateSet = RATE_SET_BIT_36M;
3713 *pu2BSSBasicRateSet = RATE_SET_BIT_36M;
3719 case FIXED_RATE_48M:
3720 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3721 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3723 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3724 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3727 *pu2DesiredNonHTRateSet = RATE_SET_BIT_48M;
3728 *pu2BSSBasicRateSet = RATE_SET_BIT_48M;
3734 case FIXED_RATE_54M:
3735 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3736 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3738 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3739 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3742 *pu2DesiredNonHTRateSet = RATE_SET_BIT_54M;
3743 *pu2BSSBasicRateSet = RATE_SET_BIT_54M;
3749 case FIXED_RATE_MCS0_20M_800NS:
3750 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3751 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3752 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3753 *pucMcsSet = HT_RATE_MCS0_INDEX;
3755 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3756 | HT_CAP_INFO_SHORT_GI_20M
3757 | HT_CAP_INFO_SHORT_GI_40M
3758 | HT_CAP_INFO_HT_GF);
3761 case FIXED_RATE_MCS1_20M_800NS:
3762 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3763 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3764 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3765 *pucMcsSet = HT_RATE_MCS1_INDEX;
3767 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3768 | HT_CAP_INFO_SHORT_GI_20M
3769 | HT_CAP_INFO_SHORT_GI_40M
3770 | HT_CAP_INFO_HT_GF);
3773 case FIXED_RATE_MCS2_20M_800NS:
3774 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3775 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3776 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3777 *pucMcsSet = HT_RATE_MCS2_INDEX;
3779 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3780 | HT_CAP_INFO_SHORT_GI_20M
3781 | HT_CAP_INFO_SHORT_GI_40M
3782 | HT_CAP_INFO_HT_GF);
3785 case FIXED_RATE_MCS3_20M_800NS:
3786 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3787 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3788 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3789 *pucMcsSet = HT_RATE_MCS3_INDEX;
3791 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3792 | HT_CAP_INFO_SHORT_GI_20M
3793 | HT_CAP_INFO_SHORT_GI_40M
3794 | HT_CAP_INFO_HT_GF);
3797 case FIXED_RATE_MCS4_20M_800NS:
3798 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3799 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3800 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3801 *pucMcsSet = HT_RATE_MCS4_INDEX;
3803 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3804 | HT_CAP_INFO_SHORT_GI_20M
3805 | HT_CAP_INFO_SHORT_GI_40M
3806 | HT_CAP_INFO_HT_GF);
3809 case FIXED_RATE_MCS5_20M_800NS:
3810 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3811 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3812 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3813 *pucMcsSet = HT_RATE_MCS5_INDEX;
3815 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3816 | HT_CAP_INFO_SHORT_GI_20M
3817 | HT_CAP_INFO_SHORT_GI_40M
3818 | HT_CAP_INFO_HT_GF);
3821 case FIXED_RATE_MCS6_20M_800NS:
3822 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3823 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3824 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3825 *pucMcsSet = HT_RATE_MCS6_INDEX;
3827 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3828 | HT_CAP_INFO_SHORT_GI_20M
3829 | HT_CAP_INFO_SHORT_GI_40M
3830 | HT_CAP_INFO_HT_GF);
3833 case FIXED_RATE_MCS7_20M_800NS:
3834 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3835 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3836 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3837 *pucMcsSet = HT_RATE_MCS7_INDEX;
3839 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3840 | HT_CAP_INFO_SHORT_GI_20M
3841 | HT_CAP_INFO_SHORT_GI_40M
3842 | HT_CAP_INFO_HT_GF);
3845 case FIXED_RATE_MCS0_20M_400NS:
3846 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3847 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3848 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3849 *pucMcsSet = HT_RATE_MCS0_INDEX;
3851 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3852 | HT_CAP_INFO_SHORT_GI_40M
3853 | HT_CAP_INFO_HT_GF);
3854 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3857 case FIXED_RATE_MCS1_20M_400NS:
3858 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3859 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3860 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3861 *pucMcsSet = HT_RATE_MCS1_INDEX;
3863 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3864 | HT_CAP_INFO_SHORT_GI_40M
3865 | HT_CAP_INFO_HT_GF);
3866 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3869 case FIXED_RATE_MCS2_20M_400NS:
3870 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3871 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3872 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3873 *pucMcsSet = HT_RATE_MCS2_INDEX;
3875 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3876 | HT_CAP_INFO_SHORT_GI_40M
3877 | HT_CAP_INFO_HT_GF);
3878 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3881 case FIXED_RATE_MCS3_20M_400NS:
3882 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3883 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3884 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3885 *pucMcsSet = HT_RATE_MCS3_INDEX;
3887 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3888 | HT_CAP_INFO_SHORT_GI_40M
3889 | HT_CAP_INFO_HT_GF);
3890 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3893 case FIXED_RATE_MCS4_20M_400NS:
3894 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3895 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3896 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3897 *pucMcsSet = HT_RATE_MCS4_INDEX;
3899 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3900 | HT_CAP_INFO_SHORT_GI_40M
3901 | HT_CAP_INFO_HT_GF);
3902 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3905 case FIXED_RATE_MCS5_20M_400NS:
3906 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3907 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3908 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3909 *pucMcsSet = HT_RATE_MCS5_INDEX;
3911 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3912 | HT_CAP_INFO_SHORT_GI_40M
3913 | HT_CAP_INFO_HT_GF);
3914 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3917 case FIXED_RATE_MCS6_20M_400NS:
3918 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3919 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3920 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3921 *pucMcsSet = HT_RATE_MCS6_INDEX;
3923 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3924 | HT_CAP_INFO_SHORT_GI_40M
3925 | HT_CAP_INFO_HT_GF);
3926 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3929 case FIXED_RATE_MCS7_20M_400NS:
3930 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3931 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3932 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3933 *pucMcsSet = HT_RATE_MCS7_INDEX;
3935 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3936 | HT_CAP_INFO_SHORT_GI_40M
3937 | HT_CAP_INFO_HT_GF);
3938 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3941 case FIXED_RATE_MCS0_40M_800NS:
3942 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3943 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3944 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3945 *pucMcsSet = HT_RATE_MCS0_INDEX;
3947 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3948 | HT_CAP_INFO_SHORT_GI_40M
3949 | HT_CAP_INFO_HT_GF);
3950 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3953 case FIXED_RATE_MCS1_40M_800NS:
3954 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3955 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3956 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3957 *pucMcsSet = HT_RATE_MCS1_INDEX;
3959 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3960 | HT_CAP_INFO_SHORT_GI_40M
3961 | HT_CAP_INFO_HT_GF);
3962 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3965 case FIXED_RATE_MCS2_40M_800NS:
3966 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3967 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3968 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3969 *pucMcsSet = HT_RATE_MCS2_INDEX;
3971 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3972 | HT_CAP_INFO_SHORT_GI_40M
3973 | HT_CAP_INFO_HT_GF);
3974 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3977 case FIXED_RATE_MCS3_40M_800NS:
3978 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3979 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3980 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3981 *pucMcsSet = HT_RATE_MCS3_INDEX;
3983 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3984 | HT_CAP_INFO_SHORT_GI_40M
3985 | HT_CAP_INFO_HT_GF);
3986 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3989 case FIXED_RATE_MCS4_40M_800NS:
3990 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3991 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3992 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3993 *pucMcsSet = HT_RATE_MCS4_INDEX;
3995 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3996 | HT_CAP_INFO_SHORT_GI_40M
3997 | HT_CAP_INFO_HT_GF);
3998 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4001 case FIXED_RATE_MCS5_40M_800NS:
4002 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4003 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4004 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4005 *pucMcsSet = HT_RATE_MCS5_INDEX;
4007 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4008 | HT_CAP_INFO_SHORT_GI_40M
4009 | HT_CAP_INFO_HT_GF);
4010 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4013 case FIXED_RATE_MCS6_40M_800NS:
4014 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4015 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4016 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4017 *pucMcsSet = HT_RATE_MCS6_INDEX;
4019 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4020 | HT_CAP_INFO_SHORT_GI_40M
4021 | HT_CAP_INFO_HT_GF);
4022 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4025 case FIXED_RATE_MCS7_40M_800NS:
4026 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4027 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4028 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4029 *pucMcsSet = HT_RATE_MCS7_INDEX;
4031 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4032 | HT_CAP_INFO_SHORT_GI_40M
4033 | HT_CAP_INFO_HT_GF);
4034 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4037 case FIXED_RATE_MCS32_800NS:
4038 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4039 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4040 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4041 *pucMcsSet = HT_RATE_MCS32_INDEX;
4043 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4044 | HT_CAP_INFO_SHORT_GI_40M
4045 | HT_CAP_INFO_HT_GF);
4046 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4049 case FIXED_RATE_MCS0_40M_400NS:
4050 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4051 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4052 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4053 *pucMcsSet = HT_RATE_MCS0_INDEX;
4055 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4056 | HT_CAP_INFO_HT_GF);
4057 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4058 | HT_CAP_INFO_SHORT_GI_40M);
4061 case FIXED_RATE_MCS1_40M_400NS:
4062 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4063 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4064 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4065 *pucMcsSet = HT_RATE_MCS1_INDEX;
4067 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4068 | HT_CAP_INFO_HT_GF);
4069 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4070 | HT_CAP_INFO_SHORT_GI_40M);
4073 case FIXED_RATE_MCS2_40M_400NS:
4074 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4075 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4076 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4077 *pucMcsSet = HT_RATE_MCS2_INDEX;
4079 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4080 | HT_CAP_INFO_HT_GF);
4081 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4082 | HT_CAP_INFO_SHORT_GI_40M);
4085 case FIXED_RATE_MCS3_40M_400NS:
4086 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4087 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4088 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4089 *pucMcsSet = HT_RATE_MCS3_INDEX;
4091 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4092 | HT_CAP_INFO_HT_GF);
4093 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4094 | HT_CAP_INFO_SHORT_GI_40M);
4097 case FIXED_RATE_MCS4_40M_400NS:
4098 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4099 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4100 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4101 *pucMcsSet = HT_RATE_MCS4_INDEX;
4103 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4104 | HT_CAP_INFO_HT_GF);
4105 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4106 | HT_CAP_INFO_SHORT_GI_40M);
4109 case FIXED_RATE_MCS5_40M_400NS:
4110 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4111 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4112 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4113 *pucMcsSet = HT_RATE_MCS5_INDEX;
4115 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4116 | HT_CAP_INFO_HT_GF);
4117 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4118 | HT_CAP_INFO_SHORT_GI_40M);
4121 case FIXED_RATE_MCS6_40M_400NS:
4122 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4123 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4124 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4125 *pucMcsSet = HT_RATE_MCS6_INDEX;
4127 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4128 | HT_CAP_INFO_HT_GF);
4129 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4130 | HT_CAP_INFO_SHORT_GI_40M);
4133 case FIXED_RATE_MCS7_40M_400NS:
4134 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4135 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4136 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4137 *pucMcsSet = HT_RATE_MCS7_INDEX;
4139 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4140 | HT_CAP_INFO_HT_GF);
4141 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4142 | HT_CAP_INFO_SHORT_GI_40M);
4145 case FIXED_RATE_MCS32_400NS:
4146 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4147 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4148 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4149 *pucMcsSet = HT_RATE_MCS32_INDEX;
4151 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4152 | HT_CAP_INFO_HT_GF);
4153 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4154 | HT_CAP_INFO_SHORT_GI_40M);
4161 return WLAN_STATUS_SUCCESS;
4164 /*----------------------------------------------------------------------------*/
4166 * @brief This utility function is used to write the register
4168 * @param u4Address Register address
4169 * u4Value the value to be written
4171 * @retval WLAN_STATUS_SUCCESS
4172 * WLAN_STATUS_FAILURE
4174 /*----------------------------------------------------------------------------*/
4178 IN P_ADAPTER_T prAdapter,
4179 IN UINT_32 u4Address,
4183 CMD_ACCESS_REG rCmdAccessReg;
4185 rCmdAccessReg.u4Address = u4Address;
4186 rCmdAccessReg.u4Data = u4Value;
4188 return wlanSendSetQueryCmd(prAdapter,
4195 sizeof(CMD_ACCESS_REG),
4196 (PUINT_8)&rCmdAccessReg,
4203 /*----------------------------------------------------------------------------*/
4205 * @brief This utility function is used to modify the auto rate parameters
4207 * @param u4ArSysParam0 see description below
4213 * @retval WLAN_STATUS_SUCCESS
4214 * WLAN_STATUS_FAILURE
4217 * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
4218 * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
4219 * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
4220 * ArSysParam0[8:15]-> HT rate clear mask
4221 * ArSysParam0[16:31]-> Legacy rate clear mask
4222 * ArSysParam1[0:7]-> Auto Rate check weighting window
4223 * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
4224 * ArSysParam1[16:23]-> Auto Rate v1 PerH
4225 * ArSysParam1[24:31]-> Auto Rate v1 PerL
4229 * Enable auto rate version 1
4231 * ArSysParam0 = 983041,
4232 * Enable auto rate version 1
4233 * Remove CCK 1M, 2M, 5.5M, 11M
4235 * ArSysParam0 = 786433
4236 * Enable auto rate version 1
4237 * Remove CCK 5.5M 11M
4239 /*----------------------------------------------------------------------------*/
4243 nicRlmArUpdateParms(
4244 IN P_ADAPTER_T prAdapter,
4245 IN UINT_32 u4ArSysParam0,
4246 IN UINT_32 u4ArSysParam1,
4247 IN UINT_32 u4ArSysParam2,
4248 IN UINT_32 u4ArSysParam3
4251 UINT_8 ucArVer,ucAbwVer,ucAgiVer;
4252 UINT_16 u2HtClrMask;
4253 UINT_16 u2LegacyClrMask;
4254 UINT_8 ucArCheckWindow;
4257 UINT_8 ucArPerForceRateDownPer;
4259 ucArVer = (UINT_8)(u4ArSysParam0 & BITS(0,3));
4260 ucAbwVer = (UINT_8)((u4ArSysParam0 & BITS(4,5)) >>4);
4261 ucAgiVer = (UINT_8)((u4ArSysParam0 & BITS(6,7)) >>6);
4262 u2HtClrMask = (UINT_16) ((u4ArSysParam0 & BITS(8,15)) >> 8);
4263 u2LegacyClrMask = (UINT_16) ((u4ArSysParam0 & BITS(16,31)) >> 16);
4266 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0,7));
4267 ucArPerForceRateDownPer = (UINT_8) ((u4ArSysParam1 & BITS(8,15)>>8));
4268 ucArPerH = (UINT_8) ((u4ArSysParam1 & BITS(16,23)) >>16);
4269 ucArPerL = (UINT_8) ((u4ArSysParam1 & BITS(24,31)) >>24);
4272 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0,7));
4273 ucArPerForceRateDownPer = (UINT_8) (((u4ArSysParam1>>8) & BITS(0,7)));
4274 ucArPerH = (UINT_8) (((u4ArSysParam1>>16) & BITS(0,7)));
4275 ucArPerL = (UINT_8) (((u4ArSysParam1>>24) & BITS(0,7)));
4278 DBGLOG(INIT, INFO, ("ArParam %u %u %u %u\n", u4ArSysParam0, u4ArSysParam1, u4ArSysParam2, u4ArSysParam3));
4279 DBGLOG(INIT, INFO, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer, ucAbwVer, ucAgiVer));
4280 DBGLOG(INIT, INFO, ("HtMask %x LegacyMask %x\n", u2HtClrMask, u2LegacyClrMask));
4281 DBGLOG(INIT, INFO, ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow, ucArPerForceRateDownPer, ucArPerH, ucArPerL));
4283 #define SWCR_DATA_ADDR(MOD,ADDR) (0x90000000+(MOD<<8)+(ADDR))
4284 #define SWCR_DATA_CMD(CATE,WRITE,INDEX,OPT0,OPT1) ( (CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 <<8) | OPT1 )
4285 #define SWCR_DATA0 0x0
4286 #define SWCR_DATA1 0x4
4287 #define SWCR_DATA2 0x8
4288 #define SWCR_DATA3 0xC
4289 #define SWCR_DATA4 0x10
4290 #define SWCR_WRITE 1
4294 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
4295 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000)*/
4297 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),1);
4298 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,5,0,0));
4301 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),0);
4302 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,5,0,0)) ;
4305 /* ucArVer 0: none 1:PER 2:Rcpi */
4306 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArVer);
4307 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,7,0,0));
4309 /* Candidate rate Ht mask */
4310 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),u2HtClrMask);
4311 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1c,0,0));
4313 /* Candidate rate legacy mask */
4314 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),u2LegacyClrMask);
4315 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1d,0,0));
4318 if(ucArCheckWindow!=0) {
4319 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
4320 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArCheckWindow);
4321 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x14,0,0));
4322 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArCheckWindow);
4323 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0xc,0,0));
4326 if(ucArPerForceRateDownPer !=0) {
4327 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerForceRateDownPer);
4328 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x18,0,0));
4331 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerH);
4332 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1,0,0));
4335 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerL);
4336 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x2,0,0));
4342 return WLAN_STATUS_SUCCESS;
4345 /*----------------------------------------------------------------------------*/
4347 * @brief This utility function is used to enable roaming
4349 * @param u4EnableRoaming
4352 * @retval WLAN_STATUS_SUCCESS
4353 * WLAN_STATUS_FAILURE
4356 * u4EnableRoaming -> Enable Romaing
4359 /*----------------------------------------------------------------------------*/
4361 nicRoamingUpdateParams(
4362 IN P_ADAPTER_T prAdapter,
4363 IN UINT_32 u4EnableRoaming
4366 P_CONNECTION_SETTINGS_T prConnSettings;
4368 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
4369 prConnSettings->fgIsEnableRoaming = ((u4EnableRoaming>0)?(TRUE):(FALSE));
4371 return WLAN_STATUS_SUCCESS;
4374 /*----------------------------------------------------------------------------*/
4376 * \brief dump firmware Assert message
4385 /*----------------------------------------------------------------------------*/
4387 nicPrintFirmwareAssertInfo(
4388 IN P_ADAPTER_T prAdapter
4391 UINT_32 u4MailBox0, u4MailBox1;
4393 UINT_8 aucAssertFile[7];
4396 #if CFG_SDIO_INTR_ENHANCE
4397 u4MailBox0 = prAdapter->prSDIOCtrl->u4RcvMailbox0;
4398 u4MailBox1 = prAdapter->prSDIOCtrl->u4RcvMailbox1;
4400 nicGetMailbox(prAdapter, 0, &u4MailBox0);
4401 nicGetMailbox(prAdapter, 1, &u4MailBox1);
4404 line = u4MailBox0 & 0x0000FFFF;
4406 u4MailBox0 = ((u4MailBox0 >> 16) & 0x0000FFFF);
4408 kalMemCopy(&aucAssertFile[0], &u4MailBox0, 2);
4409 kalMemCopy(&aucAssertFile[2], &u4MailBox1, 4);
4411 aucAssertFile[6] = '\0';
4415 #elif defined(MT5931)
4417 #elif defined(MT6628)
4421 kalPrint("\n[MT%ld][wifi][Firmware] Assert at \"%s\" #%ld\n\n",
4429 /*----------------------------------------------------------------------------*/
4431 * @brief This function is called to update Link Quality information
4433 * @param prAdapter Pointer of Adapter Data Structure
4435 * prEventLinkQuality
4441 /*----------------------------------------------------------------------------*/
4443 nicUpdateLinkQuality(
4444 IN P_ADAPTER_T prAdapter,
4445 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4446 IN P_EVENT_LINK_QUALITY prEventLinkQuality
4450 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4451 ASSERT(prEventLinkQuality);
4453 switch(eNetTypeIdx) {
4454 case NETWORK_TYPE_AIS_INDEX:
4455 if(prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
4456 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
4457 /* buffer statistics for further query */
4458 if(prAdapter->fgIsLinkQualityValid == FALSE
4459 || (kalGetTimeTick() - prAdapter->rLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4460 nicUpdateRSSI(prAdapter, eNetTypeIdx, prEventLinkQuality->cRssi, prEventLinkQuality->cLinkQuality);
4463 if(prAdapter->fgIsLinkRateValid == FALSE
4464 || (kalGetTimeTick() - prAdapter->rLinkRateUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4465 nicUpdateLinkSpeed(prAdapter, eNetTypeIdx, prEventLinkQuality->u2LinkSpeed);
4469 #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
4470 case NETWORK_TYPE_P2P_INDEX:
4471 if (prAdapter->fgIsP2pLinkQualityValid == FALSE
4472 || (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4473 P_EVENT_LINK_QUALITY_EX prEventLQEx = (P_EVENT_LINK_QUALITY_EX)prEventLinkQuality;
4475 nicUpdateRSSI(prAdapter, NETWORK_TYPE_P2P_INDEX, prEventLQEx->cRssiP2P, prEventLQEx->cLinkQualityP2P);
4488 /*----------------------------------------------------------------------------*/
4490 * @brief This function is called to update RSSI and Link Quality information
4492 * @param prAdapter Pointer of Adapter Data Structure
4499 /*----------------------------------------------------------------------------*/
4502 IN P_ADAPTER_T prAdapter,
4503 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4505 IN INT_8 cLinkQuality
4509 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4511 switch(eNetTypeIdx) {
4512 case NETWORK_TYPE_AIS_INDEX:
4513 if(prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
4514 prAdapter->fgIsLinkQualityValid = TRUE;
4515 prAdapter->rLinkQualityUpdateTime = kalGetTimeTick();
4517 prAdapter->rLinkQuality.cRssi = cRssi;
4518 prAdapter->rLinkQuality.cLinkQuality = cLinkQuality;
4520 /* indicate to glue layer */
4521 kalUpdateRSSI(prAdapter->prGlueInfo,
4522 KAL_NETWORK_TYPE_AIS_INDEX,
4523 prAdapter->rLinkQuality.cRssi,
4524 prAdapter->rLinkQuality.cLinkQuality);
4528 #if CFG_ENABLE_WIFI_DIRECT
4529 #if CFG_SUPPORT_P2P_RSSI_QUERY
4530 case NETWORK_TYPE_P2P_INDEX:
4531 prAdapter->fgIsP2pLinkQualityValid = TRUE;
4532 prAdapter->rP2pLinkQualityUpdateTime = kalGetTimeTick();
4534 prAdapter->rP2pLinkQuality.cRssi= cRssi;
4535 prAdapter->rP2pLinkQuality.cLinkQuality= cLinkQuality;
4537 kalUpdateRSSI(prAdapter->prGlueInfo,
4538 KAL_NETWORK_TYPE_P2P_INDEX,
4553 /*----------------------------------------------------------------------------*/
4555 * @brief This function is called to update Link Quality information
4557 * @param prAdapter Pointer of Adapter Data Structure
4559 * prEventLinkQuality
4565 /*----------------------------------------------------------------------------*/
4568 IN P_ADAPTER_T prAdapter,
4569 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4570 IN UINT_16 u2LinkSpeed
4574 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4576 switch(eNetTypeIdx) {
4577 case NETWORK_TYPE_AIS_INDEX:
4578 if(prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
4579 /* buffer statistics for further query */
4580 prAdapter->fgIsLinkRateValid = TRUE;
4581 prAdapter->rLinkRateUpdateTime = kalGetTimeTick();
4583 prAdapter->rLinkQuality.u2LinkSpeed = u2LinkSpeed;
4595 #if CFG_SUPPORT_RDD_TEST_MODE
4597 nicUpdateRddTestMode(
4598 IN P_ADAPTER_T prAdapter,
4599 IN P_CMD_RDD_CH_T prRddChParam
4602 DEBUGFUNC("nicUpdateRddTestMode.\n");
4606 // aisFsmScanRequest(prAdapter, NULL);
4608 return wlanSendSetQueryCmd(prAdapter,
4615 sizeof(CMD_RDD_CH_T),
4616 (PUINT_8)prRddChParam,