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
] = {
627 PHY_TYPE_SET_802_11ABG
, /* PHY_CONFIG_802_11ABG */
628 PHY_TYPE_SET_802_11BG
, /* PHY_CONFIG_802_11BG */
629 PHY_TYPE_SET_802_11G
, /* PHY_CONFIG_802_11G */
630 PHY_TYPE_SET_802_11A
, /* PHY_CONFIG_802_11A */
631 PHY_TYPE_SET_802_11B
, /* PHY_CONFIG_802_11B */
632 PHY_TYPE_SET_802_11ABGN
, /* PHY_CONFIG_802_11ABGN */
633 PHY_TYPE_SET_802_11BGN
, /* PHY_CONFIG_802_11BGN */
634 PHY_TYPE_SET_802_11AN
, /* PHY_CONFIG_802_11AN */
635 PHY_TYPE_SET_802_11GN
/* PHY_CONFIG_802_11GN */
638 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
639 #define REQ_GATING_ENABLE_H2D_INT BIT(31)
640 #define REQ_GATING_DISABLE_H2D_INT BIT(30)
641 #define ACK_GATING_ENABLE_D2H_INT BIT(31)
642 #define ACK_GATING_DISABLE_D2H_INT BIT(30)
644 #define GATING_CONTROL_POLL_LIMIT 64
647 /*******************************************************************************
649 ********************************************************************************
652 /*******************************************************************************
653 * P U B L I C D A T A
654 ********************************************************************************
657 static INT_EVENT_MAP_T arIntEventMapTable
[] = {
658 {WHISR_ABNORMAL_INT
, INT_EVENT_ABNORMAL
},
659 {WHISR_D2H_SW_INT
, INT_EVENT_SW_INT
},
660 {WHISR_TX_DONE_INT
, INT_EVENT_TX
},
661 {(WHISR_RX0_DONE_INT
| WHISR_RX1_DONE_INT
), INT_EVENT_RX
}
664 static const UINT_8 ucIntEventMapSize
= (sizeof(arIntEventMapTable
) / sizeof(INT_EVENT_MAP_T
));
666 static IST_EVENT_FUNCTION apfnEventFuncTable
[] = {
667 nicProcessAbnormalInterrupt
, /*!< INT_EVENT_ABNORMAL */
668 nicProcessSoftwareInterrupt
, /*!< INT_EVENT_SW_INT */
669 nicProcessTxInterrupt
, /*!< INT_EVENT_TX */
670 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 /*----------------------------------------------------------------------------*/
722 WLAN_STATUS
nicAllocateAdapterMemory(IN P_ADAPTER_T prAdapter
)
724 WLAN_STATUS status
= WLAN_STATUS_RESOURCES
;
725 P_RX_CTRL_T prRxCtrl
;
726 P_TX_CTRL_T prTxCtrl
;
728 DEBUGFUNC("nicAllocateAdapterMemory");
731 prRxCtrl
= &prAdapter
->rRxCtrl
;
732 prTxCtrl
= &prAdapter
->rTxCtrl
;
735 /* 4 <0> Reset all Memory Handler */
737 prAdapter
->u4MemFreeDynamicCount
= 0;
738 prAdapter
->u4MemAllocDynamicCount
= 0;
740 prAdapter
->pucMgtBufCached
= (PUINT_8
) NULL
;
741 prRxCtrl
->pucRxCached
= (PUINT_8
) NULL
;
742 prAdapter
->prSDIOCtrl
= (P_SDIO_CTRL_T
) NULL
;
745 /* 4 <1> Memory for Management Memory Pool and CMD_INFO_T */
746 /* Allocate memory for the CMD_INFO_T and its MGMT memory pool. */
747 prAdapter
->u4MgtBufCachedSize
= MGT_BUFFER_SIZE
;
749 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter
->pucMgtBufCached
,
750 prAdapter
->u4MgtBufCachedSize
,
751 VIR_MEM_TYPE
, "COMMON MGMT MEMORY POOL");
753 /* 4 <2> Memory for RX Descriptor */
754 /* Initialize the number of rx buffers we will have in our queue. */
755 /* <TODO> We may setup ucRxPacketDescriptors by GLUE Layer, and using
756 * this variable directly.
758 /* Allocate memory for the SW receive structures. */
759 prRxCtrl
->u4RxCachedSize
= CFG_RX_MAX_PKT_NUM
* ALIGN_4(sizeof(SW_RFB_T
));
761 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl
->pucRxCached
,
762 prRxCtrl
->u4RxCachedSize
, VIR_MEM_TYPE
, "SW_RFB_T");
764 /* 4 <3> Memory for TX DEscriptor */
765 prTxCtrl
->u4TxCachedSize
= CFG_TX_MAX_PKT_NUM
* ALIGN_4(sizeof(MSDU_INFO_T
));
767 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl
->pucTxCached
,
768 prTxCtrl
->u4TxCachedSize
, VIR_MEM_TYPE
, "MSDU_INFO_T");
770 /* 4 <4> Memory for Common Coalescing Buffer */
771 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
772 prAdapter
->pucCoalescingBufCached
= (PUINT_8
) NULL
;
774 /* Allocate memory for the common coalescing buffer. */
775 prAdapter
->u4CoalescingBufCachedSize
=
776 CFG_COALESCING_BUFFER_SIZE
>
777 CFG_RX_COALESCING_BUFFER_SIZE
? CFG_COALESCING_BUFFER_SIZE
:
778 CFG_RX_COALESCING_BUFFER_SIZE
;
780 prAdapter
->pucCoalescingBufCached
=
781 kalAllocateIOBuffer(prAdapter
->u4CoalescingBufCachedSize
);
783 if (prAdapter
->pucCoalescingBufCached
== NULL
) {
785 ("Could not allocate %ld bytes for coalescing buffer.\n",
786 prAdapter
->u4CoalescingBufCachedSize
));
789 #endif /* CFG_COALESCING_BUFFER_SIZE */
791 /* 4 <5> Memory for enhanced interrupt response */
792 prAdapter
->prSDIOCtrl
= (P_SDIO_CTRL_T
)
793 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T
));
795 if (prAdapter
->prSDIOCtrl
== NULL
) {
797 ("Could not allocate %ld bytes for interrupt response.\n",
798 sizeof(ENHANCE_MODE_DATA_STRUCT_T
)));
802 status
= WLAN_STATUS_SUCCESS
;
807 if (status
!= WLAN_STATUS_SUCCESS
) {
808 nicReleaseAdapterMemory(prAdapter
);
813 } /* end of nicAllocateAdapterMemory() */
816 /*----------------------------------------------------------------------------*/
818 * @brief This routine is responsible for releasing the allocated memory by
819 * nicAllocatedAdapterMemory().
821 * @param prAdapter Pointer of Adapter Data Structure
825 /*----------------------------------------------------------------------------*/
826 VOID
nicReleaseAdapterMemory(IN P_ADAPTER_T prAdapter
)
828 P_TX_CTRL_T prTxCtrl
;
829 P_RX_CTRL_T prRxCtrl
;
832 prTxCtrl
= &prAdapter
->rTxCtrl
;
833 prRxCtrl
= &prAdapter
->rRxCtrl
;
835 /* 4 <5> Memory for enhanced interrupt response */
836 if (prAdapter
->prSDIOCtrl
) {
837 kalReleaseIOBuffer((PVOID
) prAdapter
->prSDIOCtrl
,
838 sizeof(ENHANCE_MODE_DATA_STRUCT_T
));
839 prAdapter
->prSDIOCtrl
= (P_SDIO_CTRL_T
) NULL
;
841 /* 4 <4> Memory for Common Coalescing Buffer */
842 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
843 if (prAdapter
->pucCoalescingBufCached
) {
844 kalReleaseIOBuffer((PVOID
) prAdapter
->pucCoalescingBufCached
,
845 prAdapter
->u4CoalescingBufCachedSize
);
846 prAdapter
->pucCoalescingBufCached
= (PUINT_8
) NULL
;
848 #endif /* CFG_COALESCING_BUFFER_SIZE */
850 /* 4 <3> Memory for TX Descriptor */
851 if (prTxCtrl
->pucTxCached
) {
852 kalMemFree((PVOID
) prTxCtrl
->pucTxCached
, VIR_MEM_TYPE
, prTxCtrl
->u4TxCachedSize
);
853 prTxCtrl
->pucTxCached
= (PUINT_8
) NULL
;
855 /* 4 <2> Memory for RX Descriptor */
856 if (prRxCtrl
->pucRxCached
) {
857 kalMemFree((PVOID
) prRxCtrl
->pucRxCached
, VIR_MEM_TYPE
, prRxCtrl
->u4RxCachedSize
);
858 prRxCtrl
->pucRxCached
= (PUINT_8
) NULL
;
860 /* 4 <1> Memory for Management Memory Pool */
861 if (prAdapter
->pucMgtBufCached
) {
862 kalMemFree((PVOID
) prAdapter
->pucMgtBufCached
,
863 VIR_MEM_TYPE
, prAdapter
->u4MgtBufCachedSize
);
864 prAdapter
->pucMgtBufCached
= (PUINT_8
) NULL
;
867 /* Check if all allocated memories are free */
868 ASSERT(prAdapter
->u4MemFreeDynamicCount
== prAdapter
->u4MemAllocDynamicCount
);
875 /*----------------------------------------------------------------------------*/
877 * @brief disable global interrupt
879 * @param prAdapter pointer to the Adapter handler
883 /*----------------------------------------------------------------------------*/
884 VOID
nicDisableInterrupt(IN P_ADAPTER_T prAdapter
)
888 HAL_BYTE_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_INT_EN_CLR
);
890 prAdapter
->fgIsIntEnable
= FALSE
;
893 /*----------------------------------------------------------------------------*/
895 * @brief enable global interrupt
897 * @param prAdapter pointer to the Adapter handler
901 /*----------------------------------------------------------------------------*/
902 VOID
nicEnableInterrupt(IN P_ADAPTER_T prAdapter
)
904 BOOLEAN fgIsIntEnableCache
;
908 fgIsIntEnableCache
= prAdapter
->fgIsIntEnable
;
910 prAdapter
->fgIsIntEnable
= TRUE
; /* NOTE(Kevin): It must be placed before MCR GINT write. */
912 /* If need enable INT and also set LPOwn at the same time. */
913 if (prAdapter
->fgIsIntEnableWithLPOwnSet
) {
914 prAdapter
->fgIsIntEnableWithLPOwnSet
= FALSE
; /* NOTE(Kevin): It's better to place it
915 * before MCR GINT write.
917 /* If INT was enabled, only set LPOwn */
918 if (fgIsIntEnableCache
) {
919 HAL_MCR_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_FW_OWN_REQ_SET
);
920 prAdapter
->fgIsFwOwn
= TRUE
;
922 /* If INT was not enabled, enable it and also set LPOwn now */
924 HAL_MCR_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_FW_OWN_REQ_SET
|
926 prAdapter
->fgIsFwOwn
= TRUE
;
929 /* If INT was not enabled, enable it now */
930 else if (!fgIsIntEnableCache
) {
931 HAL_BYTE_WR(prAdapter
, MCR_WHLPCR
, WHLPCR_INT_EN_SET
);
935 } /* end of nicEnableInterrupt() */
938 #if CFG_SDIO_INTR_ENHANCE
939 /*----------------------------------------------------------------------------*/
941 * @brief For SDIO enhance mode, set the max rx len and tx status
943 * @param prAdapter a pointer to adapter private data structure.
947 /*----------------------------------------------------------------------------*/
948 VOID
nicSDIOInit(IN P_ADAPTER_T prAdapter
)
954 /* 4 <1> Check STATUS Buffer is DW alignment. */
955 ASSERT(IS_ALIGN_4((UINT_32
) &prAdapter
->prSDIOCtrl
->u4WHISR
));
957 /* 4 <2> Setup STATUS count. */
959 HAL_MCR_RD(prAdapter
, MCR_WHCR
, &u4Value
);
961 /* 4 <2.1> Setup the number of maximum RX length to be report */
962 u4Value
&= ~(WHCR_MAX_HIF_RX_LEN_NUM
);
963 u4Value
|= ((SDIO_MAXIMUM_RX_LEN_NUM
<< WHCR_OFFSET_MAX_HIF_RX_LEN_NUM
));
965 /* 4 <2.2> Setup RX enhancement mode */
966 #if CFG_SDIO_RX_ENHANCE
967 u4Value
|= WHCR_RX_ENHANCE_MODE_EN
;
969 u4Value
&= ~WHCR_RX_ENHANCE_MODE_EN
;
970 #endif /* CFG_SDIO_RX_AGG */
972 HAL_MCR_WR(prAdapter
, MCR_WHCR
, u4Value
);
977 } /* end of nicSDIOInit() */
979 /*----------------------------------------------------------------------------*/
981 * @brief Read interrupt status from hardware
983 * @param prAdapter pointer to the Adapter handler
984 * @param the interrupts
989 /*----------------------------------------------------------------------------*/
990 VOID
nicSDIOReadIntStatus(IN P_ADAPTER_T prAdapter
, OUT PUINT_32 pu4IntStatus
)
992 P_SDIO_CTRL_T prSDIOCtrl
;
994 DEBUGFUNC("nicSDIOReadIntStatus");
997 ASSERT(pu4IntStatus
);
999 prSDIOCtrl
= prAdapter
->prSDIOCtrl
;
1002 HAL_PORT_RD(prAdapter
,
1004 sizeof(ENHANCE_MODE_DATA_STRUCT_T
),
1005 (PUINT_8
) prSDIOCtrl
, sizeof(ENHANCE_MODE_DATA_STRUCT_T
));
1007 if (kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
|| fgIsBusAccessFailed
== TRUE
) {
1013 if ((prSDIOCtrl
->u4WHISR
& WHISR_TX_DONE_INT
) == 0 &&
1014 (prSDIOCtrl
->rTxInfo
.au4WTSR
[0] | prSDIOCtrl
->rTxInfo
.au4WTSR
[1])) {
1015 prSDIOCtrl
->u4WHISR
|= WHISR_TX_DONE_INT
;
1018 if ((prSDIOCtrl
->u4WHISR
& BIT(31)) == 0 &&
1019 HAL_GET_MAILBOX_READ_CLEAR(prAdapter
) == TRUE
&&
1020 (prSDIOCtrl
->u4RcvMailbox0
!= 0 || prSDIOCtrl
->u4RcvMailbox1
!= 0)) {
1021 prSDIOCtrl
->u4WHISR
|= BIT(31);
1024 *pu4IntStatus
= prSDIOCtrl
->u4WHISR
;
1027 } /* end of nicSDIOReadIntStatus() */
1030 /*----------------------------------------------------------------------------*/
1032 * @brief The function used to read interrupt status and then invoking
1033 * dispatching procedure for the appropriate functions
1034 * corresponding to specific interrupt bits
1036 * @param prAdapter pointer to the Adapter handler
1038 * @retval WLAN_STATUS_SUCCESS
1039 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1041 /*----------------------------------------------------------------------------*/
1042 WLAN_STATUS
nicProcessIST(IN P_ADAPTER_T prAdapter
)
1044 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
1045 UINT_32 u4IntStatus
= 0;
1048 DEBUGFUNC("nicProcessIST");
1049 /* DBGLOG(INIT, LOUD, ("\n")); */
1053 if (prAdapter
->rAcpiState
== ACPI_STATE_D3
) {
1055 ("Fail in set nicProcessIST! (Adapter not ready). ACPI=D%d, Radio=%d\n",
1056 prAdapter
->rAcpiState
, prAdapter
->fgIsRadioOff
));
1057 return WLAN_STATUS_ADAPTER_NOT_READY
;
1059 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1060 if (prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
1061 nicDisableClockGating(prAdapter
);
1065 for (i
= 0; i
< CFG_IST_LOOP_COUNT
; i
++) {
1067 #if CFG_SDIO_INTR_ENHANCE
1068 nicSDIOReadIntStatus(prAdapter
, &u4IntStatus
);
1070 HAL_MCR_RD(prAdapter
, MCR_WHISR
, &u4IntStatus
);
1071 #endif /* CFG_SDIO_INTR_ENHANCE */
1073 /* DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus)); */
1075 if (u4IntStatus
& ~(WHIER_DEFAULT
| WHIER_FW_OWN_BACK_INT_EN
)) {
1076 DBGLOG(INTR
, WARN
, ("Un-handled HISR %#x, HISR = %#x (HIER:0x%x)\n",
1077 (u4IntStatus
& ~WHIER_DEFAULT
), u4IntStatus
,
1079 u4IntStatus
&= WHIER_DEFAULT
;
1082 nicProcessIST_impl(prAdapter
, u4IntStatus
);
1084 if (u4IntStatus
== 0) {
1086 u4Status
= WLAN_STATUS_NOT_INDICATING
;
1092 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1093 if (prAdapter
->fgIsClockGatingEnabled
== FALSE
) {
1094 nicEnableClockGating(prAdapter
);
1099 } /* end of nicProcessIST() */
1102 /*----------------------------------------------------------------------------*/
1104 * @brief The function used to dispatch the appropriate functions for specific
1107 * @param prAdapter pointer to the Adapter handler
1108 * u4IntStatus interrupt status bits
1110 * @retval WLAN_STATUS_SUCCESS
1111 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1113 /*----------------------------------------------------------------------------*/
1114 WLAN_STATUS
nicProcessIST_impl(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4IntStatus
)
1116 UINT_32 u4IntCount
= 0;
1117 P_INT_EVENT_MAP_T prIntEventMap
= NULL
;
1121 prAdapter
->u4IntStatus
= u4IntStatus
;
1123 /* Process each of the interrupt status consequently */
1124 prIntEventMap
= &arIntEventMapTable
[0];
1125 for (u4IntCount
= 0; u4IntCount
< ucIntEventMapSize
; prIntEventMap
++, u4IntCount
++) {
1126 if (prIntEventMap
->u4Int
& prAdapter
->u4IntStatus
) {
1127 if (prIntEventMap
->u4Event
== INT_EVENT_RX
&&
1128 prAdapter
->fgIsEnterD3ReqIssued
== TRUE
) {
1130 } else if (apfnEventFuncTable
[prIntEventMap
->u4Event
] != NULL
) {
1131 apfnEventFuncTable
[prIntEventMap
->u4Event
] (prAdapter
);
1134 ("Empty INTR handler! ISAR bit#: %ld, event:%d, func: 0x%x\n",
1135 prIntEventMap
->u4Int
, prIntEventMap
->u4Event
,
1136 apfnEventFuncTable
[prIntEventMap
->u4Event
]));
1138 ASSERT(0); /* to trap any NULL interrupt handler */
1140 prAdapter
->u4IntStatus
&= ~prIntEventMap
->u4Int
;
1144 return WLAN_STATUS_SUCCESS
;
1145 } /* end of nicProcessIST_impl() */
1148 /*----------------------------------------------------------------------------*/
1150 * @brief Verify the CHIP ID
1152 * @param prAdapter a pointer to adapter private data structure.
1155 * @retval TRUE CHIP ID is the same as the setting compiled
1156 * @retval FALSE CHIP ID is different from the setting compiled
1158 /*----------------------------------------------------------------------------*/
1159 BOOL
nicVerifyChipID(IN P_ADAPTER_T prAdapter
)
1165 HAL_MCR_RD(prAdapter
, MCR_WCIR
, &u4CIR
);
1167 DBGLOG(INIT
, TRACE
, ("Chip ID: 0x%x\n", u4CIR
& WCIR_CHIP_ID
));
1168 DBGLOG(INIT
, TRACE
, ("Revision ID: 0x%x\n", ((u4CIR
& WCIR_REVISION_ID
) >> 16)));
1170 if ((u4CIR
& WCIR_CHIP_ID
) != MTK_CHIP_REV
) {
1174 prAdapter
->ucRevID
= (UINT_8
) (((u4CIR
& WCIR_REVISION_ID
) >> 16) & 0xF);
1179 /*----------------------------------------------------------------------------*/
1181 * @brief Initialize the MCR to the appropriate init value, and verify the init
1184 * @param prAdapter a pointer to adapter private data structure.
1188 /*----------------------------------------------------------------------------*/
1189 VOID
nicMCRInit(IN P_ADAPTER_T prAdapter
)
1194 /* 4 <0> Initial value */
1197 VOID
nicHifInit(IN P_ADAPTER_T prAdapter
)
1203 nicPutMailbox(prAdapter
, 0, 0x52455345); /* RESE */
1204 nicPutMailbox(prAdapter
, 1, 0x545F5746); /* T_WF */
1205 nicSetSwIntr(prAdapter
, BIT(16));
1210 /*----------------------------------------------------------------------------*/
1212 * @brief Initialize the Adapter soft variable
1214 * @param prAdapter pointer to the Adapter handler
1219 /*----------------------------------------------------------------------------*/
1220 WLAN_STATUS
nicInitializeAdapter(IN P_ADAPTER_T prAdapter
)
1222 WLAN_STATUS u4Status
= WLAN_STATUS_SUCCESS
;
1226 prAdapter
->fgIsIntEnableWithLPOwnSet
= FALSE
;
1229 if (!nicVerifyChipID(prAdapter
)) {
1230 u4Status
= WLAN_STATUS_FAILURE
;
1233 /* 4 <1> MCR init */
1234 nicMCRInit(prAdapter
);
1236 #if CFG_SDIO_INTR_ENHANCE
1237 nicSDIOInit(prAdapter
);
1238 #endif /* CFG_SDIO_INTR_ENHANCE */
1240 HAL_MCR_WR(prAdapter
, MCR_WHIER
, WHIER_DEFAULT
);
1243 /* 4 <2> init FW HIF */
1244 nicHifInit(prAdapter
);
1253 #if defined(_HIF_SPI)
1254 /*----------------------------------------------------------------------------*/
1256 * \brief Restore the SPI Mode Select to default mode,
1257 * this is important while driver is unload, and this must be last mcr
1258 * since the operation will let the hif use 8bit mode access
1260 * \param[in] prAdapter a pointer to adapter private data structure.
1261 * \param[in] eGPIO2_Mode GPIO2 operation mode
1265 /*----------------------------------------------------------------------------*/
1266 void nicRestoreSpiDefMode(IN P_ADAPTER_T prAdapter
)
1270 HAL_MCR_WR(prAdapter
, MCR_WCSR
, SPICSR_8BIT_MODE_DATA
);
1275 /*----------------------------------------------------------------------------*/
1277 * @brief Process rx interrupt. When the rx
1278 * Interrupt is asserted, it means there are frames in queue.
1280 * @param prAdapter Pointer to the Adapter structure.
1284 /*----------------------------------------------------------------------------*/
1285 VOID
nicProcessAbnormalInterrupt(IN P_ADAPTER_T prAdapter
)
1289 HAL_MCR_RD(prAdapter
, MCR_WASR
, &u4Value
);
1290 DBGLOG(REQ
, WARN
, ("MCR_WASR: 0x%x\n", u4Value
));
1293 /*----------------------------------------------------------------------------*/
1297 * @param prAdapter Pointer to the Adapter structure.
1301 /*----------------------------------------------------------------------------*/
1302 VOID
nicProcessFwOwnBackInterrupt(IN P_ADAPTER_T prAdapter
)
1306 } /* end of nicProcessFwOwnBackInterrupt() */
1308 /*----------------------------------------------------------------------------*/
1312 * @param prAdapter Pointer to the Adapter structure.
1316 /*----------------------------------------------------------------------------*/
1317 VOID
nicProcessSoftwareInterrupt(IN P_ADAPTER_T prAdapter
)
1323 u4IntrBits
= prAdapter
->u4IntStatus
& BITS(8, 31);
1325 if ((u4IntrBits
& WHISR_D2H_SW_ASSERT_INFO_INT
) != 0) {
1326 nicPrintFirmwareAssertInfo(prAdapter
);
1327 #if CFG_CHIP_RESET_SUPPORT
1328 glSendResetRequest();
1331 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1332 ASSERT((u4IntrBits
& (ACK_GATING_ENABLE_D2H_INT
| ACK_GATING_DISABLE_D2H_INT
))
1333 != (ACK_GATING_ENABLE_D2H_INT
| ACK_GATING_DISABLE_D2H_INT
));
1335 if (u4IntrBits
& ACK_GATING_ENABLE_D2H_INT
) {
1336 prAdapter
->fgIsClockGatingEnabled
= TRUE
;
1339 if (u4IntrBits
& ACK_GATING_DISABLE_D2H_INT
) {
1340 prAdapter
->fgIsClockGatingEnabled
= FALSE
;
1342 /* Indicate Service Thread for TX */
1343 if (kalGetTxPendingCmdCount(prAdapter
->prGlueInfo
) > 0
1344 || wlanGetTxPendingFrameCount(prAdapter
) > 0) {
1345 kalSetEvent(prAdapter
->prGlueInfo
);
1350 DBGLOG(REQ
, WARN
, ("u4IntrBits: 0x%x\n", u4IntrBits
));
1353 } /* end of nicProcessSoftwareInterrupt() */
1355 VOID
nicPutMailbox(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4MailboxNum
, IN UINT_32 u4Data
)
1357 if (u4MailboxNum
== 0) {
1358 HAL_MCR_WR(prAdapter
, MCR_H2DSM0R
, u4Data
);
1359 } else if (u4MailboxNum
== 1) {
1360 HAL_MCR_WR(prAdapter
, MCR_H2DSM1R
, u4Data
);
1366 VOID
nicGetMailbox(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4MailboxNum
, OUT PUINT_32 pu4Data
)
1368 if (u4MailboxNum
== 0) {
1369 HAL_MCR_RD(prAdapter
, MCR_D2HRM0R
, pu4Data
);
1370 } else if (u4MailboxNum
== 1) {
1371 HAL_MCR_RD(prAdapter
, MCR_D2HRM1R
, pu4Data
);
1377 VOID
nicSetSwIntr(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4SwIntrBitmap
)
1380 * SW interrup in HW bit 16 is mapping to SW bit 0 (shift 16bit in HW transparancy)
1381 * SW interrupt valid from b0~b15
1383 ASSERT((u4SwIntrBitmap
& BITS(0, 15)) == 0);
1384 /* DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap)); */
1386 HAL_MCR_WR(prAdapter
, MCR_WSICR
, u4SwIntrBitmap
);
1390 /*----------------------------------------------------------------------------*/
1392 * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1393 * with specified sequential number
1395 * @param prAdapter Pointer of ADAPTER_T
1396 * ucSeqNum Sequential Number
1398 * @retval - P_CMD_INFO_T
1400 /*----------------------------------------------------------------------------*/
1401 P_CMD_INFO_T
nicGetPendingCmdInfo(IN P_ADAPTER_T prAdapter
, IN UINT_8 ucSeqNum
)
1405 P_QUE_T prTempCmdQue
= &rTempCmdQue
;
1406 P_QUE_ENTRY_T prQueueEntry
= (P_QUE_ENTRY_T
) NULL
;
1407 P_CMD_INFO_T prCmdInfo
= (P_CMD_INFO_T
) NULL
;
1409 GLUE_SPIN_LOCK_DECLARATION();
1413 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
1415 prCmdQue
= &prAdapter
->rPendingCmdQueue
;
1416 QUEUE_MOVE_ALL(prTempCmdQue
, prCmdQue
);
1418 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1419 while (prQueueEntry
) {
1420 prCmdInfo
= (P_CMD_INFO_T
) prQueueEntry
;
1422 if (prCmdInfo
->ucCmdSeqNum
== ucSeqNum
)
1425 QUEUE_INSERT_TAIL(prCmdQue
, prQueueEntry
);
1430 QUEUE_REMOVE_HEAD(prTempCmdQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1432 QUEUE_CONCATENATE_QUEUES(prCmdQue
, prTempCmdQue
);
1434 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_PENDING
);
1440 /*----------------------------------------------------------------------------*/
1442 * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1443 * with specified sequential number
1445 * @param prAdapter Pointer of ADAPTER_T
1446 * ucSeqNum Sequential Number
1448 * @retval - P_MSDU_INFO_T
1450 /*----------------------------------------------------------------------------*/
1451 P_MSDU_INFO_T
nicGetPendingTxMsduInfo(IN P_ADAPTER_T prAdapter
, IN UINT_8 ucSeqNum
)
1455 P_QUE_T prTempQue
= &rTempQue
;
1456 P_QUE_ENTRY_T prQueueEntry
= (P_QUE_ENTRY_T
) NULL
;
1457 P_MSDU_INFO_T prMsduInfo
= (P_MSDU_INFO_T
) NULL
;
1459 GLUE_SPIN_LOCK_DECLARATION();
1463 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1465 prTxingQue
= &(prAdapter
->rTxCtrl
.rTxMgmtTxingQueue
);
1466 QUEUE_MOVE_ALL(prTempQue
, prTxingQue
);
1468 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1469 while (prQueueEntry
) {
1470 prMsduInfo
= (P_MSDU_INFO_T
) prQueueEntry
;
1472 if (prMsduInfo
->ucTxSeqNum
== ucSeqNum
)
1475 QUEUE_INSERT_TAIL(prTxingQue
, prQueueEntry
);
1480 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1482 QUEUE_CONCATENATE_QUEUES(prTxingQue
, prTempQue
);
1484 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1489 P_MSDU_INFO_T
nicGetPendingStaMMPDU(IN P_ADAPTER_T prAdapter
, IN UINT_8 ucStaRecIdx
)
1491 P_MSDU_INFO_T prMsduInfoListHead
= (P_MSDU_INFO_T
) NULL
;
1492 P_QUE_T prTxingQue
= (P_QUE_T
) NULL
;
1494 P_QUE_T prTempQue
= &rTempQue
;
1495 P_QUE_ENTRY_T prQueueEntry
= (P_QUE_ENTRY_T
) NULL
;
1496 P_MSDU_INFO_T prMsduInfo
= (P_MSDU_INFO_T
) NULL
;
1498 GLUE_SPIN_LOCK_DECLARATION();
1500 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1502 if (prAdapter
== NULL
) {
1508 prTxingQue
= &(prAdapter
->rTxCtrl
.rTxMgmtTxingQueue
);
1509 QUEUE_MOVE_ALL(prTempQue
, prTxingQue
);
1511 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1512 while (prQueueEntry
) {
1513 prMsduInfo
= (P_MSDU_INFO_T
) prQueueEntry
;
1515 if ((prMsduInfo
->ucStaRecIndex
== ucStaRecIdx
)
1516 && (prMsduInfo
->pfTxDoneHandler
!= NULL
)) {
1517 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo
, prMsduInfoListHead
);
1518 prMsduInfoListHead
= prMsduInfo
;
1520 QUEUE_INSERT_TAIL(prTxingQue
, prQueueEntry
);
1526 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1530 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1533 return prMsduInfoListHead
;
1534 } /* nicGetPendingStaMMPDU */
1538 nicFreePendingTxMsduInfoByNetwork(IN P_ADAPTER_T prAdapter
,
1539 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
)
1543 P_QUE_T prTempQue
= &rTempQue
;
1544 P_QUE_ENTRY_T prQueueEntry
= (P_QUE_ENTRY_T
) NULL
;
1545 P_MSDU_INFO_T prMsduInfoListHead
= (P_MSDU_INFO_T
) NULL
;
1546 P_MSDU_INFO_T prMsduInfoListTail
= (P_MSDU_INFO_T
) NULL
;
1547 P_MSDU_INFO_T prMsduInfo
= (P_MSDU_INFO_T
) NULL
;
1549 GLUE_SPIN_LOCK_DECLARATION();
1553 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1555 prTxingQue
= &(prAdapter
->rTxCtrl
.rTxMgmtTxingQueue
);
1556 QUEUE_MOVE_ALL(prTempQue
, prTxingQue
);
1558 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1559 while (prQueueEntry
) {
1560 prMsduInfo
= (P_MSDU_INFO_T
) prQueueEntry
;
1562 if ((ENUM_NETWORK_TYPE_INDEX_T
) (prMsduInfo
->ucNetworkType
) == eNetworkType
) {
1563 if (prMsduInfoListHead
== NULL
) {
1564 prMsduInfoListHead
= prMsduInfoListTail
= prMsduInfo
;
1566 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail
, prMsduInfo
);
1567 prMsduInfoListTail
= prMsduInfo
;
1570 QUEUE_INSERT_TAIL(prTxingQue
, prQueueEntry
);
1575 QUEUE_REMOVE_HEAD(prTempQue
, prQueueEntry
, P_QUE_ENTRY_T
);
1577 QUEUE_CONCATENATE_QUEUES(prTxingQue
, prTempQue
);
1579 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TXING_MGMT_LIST
);
1582 if (prMsduInfoListHead
) {
1583 nicTxFreeMsduInfoPacket(prAdapter
, prMsduInfoListHead
);
1588 } /* end of nicFreePendingTxMsduInfoByNetwork() */
1592 /*----------------------------------------------------------------------------*/
1594 * @brief This procedure is used to retrieve a CMD sequence number atomically
1596 * @param prAdapter Pointer of ADAPTER_T
1600 /*----------------------------------------------------------------------------*/
1601 UINT_8
nicIncreaseCmdSeqNum(IN P_ADAPTER_T prAdapter
)
1605 KAL_SPIN_LOCK_DECLARATION();
1609 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_SEQ_NUM
);
1611 prAdapter
->ucCmdSeqNum
++;
1612 ucRetval
= prAdapter
->ucCmdSeqNum
;
1614 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_CMD_SEQ_NUM
);
1620 /*----------------------------------------------------------------------------*/
1622 * @brief This procedure is used to retrieve a TX sequence number atomically
1624 * @param prAdapter Pointer of ADAPTER_T
1628 /*----------------------------------------------------------------------------*/
1629 UINT_8
nicIncreaseTxSeqNum(IN P_ADAPTER_T prAdapter
)
1633 KAL_SPIN_LOCK_DECLARATION();
1637 KAL_ACQUIRE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TX_SEQ_NUM
);
1639 prAdapter
->ucTxSeqNum
++;
1640 ucRetval
= prAdapter
->ucTxSeqNum
;
1642 KAL_RELEASE_SPIN_LOCK(prAdapter
, SPIN_LOCK_TX_SEQ_NUM
);
1649 /*----------------------------------------------------------------------------*/
1651 * @brief This utility function is used to handle
1652 * media state change event
1658 /*----------------------------------------------------------------------------*/
1660 nicMediaStateChange(IN P_ADAPTER_T prAdapter
,
1661 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
,
1662 IN P_EVENT_CONNECTION_STATUS prConnectionStatus
)
1664 P_GLUE_INFO_T prGlueInfo
;
1667 prGlueInfo
= prAdapter
->prGlueInfo
;
1669 switch (eNetworkType
) {
1670 case NETWORK_TYPE_AIS_INDEX
:
1671 if (prConnectionStatus
->ucMediaStatus
== PARAM_MEDIA_STATE_DISCONNECTED
) { /* disconnected */
1672 if (kalGetMediaStateIndicated(prGlueInfo
) != PARAM_MEDIA_STATE_DISCONNECTED
) {
1674 kalIndicateStatusAndComplete(prGlueInfo
,
1675 WLAN_STATUS_MEDIA_DISCONNECT
, NULL
, 0);
1677 prAdapter
->rWlanInfo
.u4SysTime
= kalGetTimeTick();
1680 /* reset buffered link quality information */
1681 prAdapter
->fgIsLinkQualityValid
= FALSE
;
1682 prAdapter
->fgIsLinkRateValid
= FALSE
;
1683 } else if (prConnectionStatus
->ucMediaStatus
== PARAM_MEDIA_STATE_CONNECTED
) { /* connected */
1684 prAdapter
->rWlanInfo
.u4SysTime
= kalGetTimeTick();
1686 /* fill information for association result */
1687 prAdapter
->rWlanInfo
.rCurrBssId
.rSsid
.u4SsidLen
1688 = prConnectionStatus
->ucSsidLen
;
1689 kalMemCopy(prAdapter
->rWlanInfo
.rCurrBssId
.rSsid
.aucSsid
,
1690 prConnectionStatus
->aucSsid
, prConnectionStatus
->ucSsidLen
);
1691 kalMemCopy(prAdapter
->rWlanInfo
.rCurrBssId
.arMacAddress
,
1692 prConnectionStatus
->aucBssid
, MAC_ADDR_LEN
);
1693 prAdapter
->rWlanInfo
.rCurrBssId
.u4Privacy
= prConnectionStatus
->ucEncryptStatus
; /* @FIXME */
1694 prAdapter
->rWlanInfo
.rCurrBssId
.rRssi
= 0; /* @FIXME */
1695 prAdapter
->rWlanInfo
.rCurrBssId
.eNetworkTypeInUse
= PARAM_NETWORK_TYPE_AUTOMODE
; /* @FIXME */
1696 prAdapter
->rWlanInfo
.rCurrBssId
.rConfiguration
.u4BeaconPeriod
1697 = prConnectionStatus
->u2BeaconPeriod
;
1698 prAdapter
->rWlanInfo
.rCurrBssId
.rConfiguration
.u4ATIMWindow
1699 = prConnectionStatus
->u2ATIMWindow
;
1700 prAdapter
->rWlanInfo
.rCurrBssId
.rConfiguration
.u4DSConfig
1701 = prConnectionStatus
->u4FreqInKHz
;
1702 prAdapter
->rWlanInfo
.ucNetworkType
= prConnectionStatus
->ucNetworkType
;
1703 prAdapter
->rWlanInfo
.rCurrBssId
.eOpMode
1704 = (ENUM_PARAM_OP_MODE_T
) prConnectionStatus
->ucInfraMode
;
1706 /* always indicate to OS according to MSDN (re-association/roaming) */
1707 if (kalGetMediaStateIndicated(prGlueInfo
) != PARAM_MEDIA_STATE_CONNECTED
) {
1708 kalIndicateStatusAndComplete(prGlueInfo
,
1709 WLAN_STATUS_MEDIA_CONNECT
, NULL
, 0);
1711 /* connected -> connected : roaming ? */
1712 kalIndicateStatusAndComplete(prGlueInfo
,
1713 WLAN_STATUS_ROAM_OUT_FIND_BEST
,
1719 #if CFG_ENABLE_BT_OVER_WIFI
1720 case NETWORK_TYPE_BOW_INDEX
:
1724 #if CFG_ENABLE_WIFI_DIRECT
1725 case NETWORK_TYPE_P2P_INDEX
:
1732 return WLAN_STATUS_SUCCESS
;
1733 } /* nicMediaStateChange */
1735 /*----------------------------------------------------------------------------*/
1737 * @brief This utility function is used to convert between
1738 * frequency and channel number
1740 * @param u4ChannelNum
1742 * @retval - Frequency in unit of KHz, 0 for invalid channel number
1744 /*----------------------------------------------------------------------------*/
1745 UINT_32
nicChannelNum2Freq(UINT_32 u4ChannelNum
)
1747 UINT_32 u4ChannelInMHz
;
1749 if (u4ChannelNum
>= 1 && u4ChannelNum
<= 13) {
1750 u4ChannelInMHz
= 2412 + (u4ChannelNum
- 1) * 5;
1751 } else if (u4ChannelNum
== 14) {
1752 u4ChannelInMHz
= 2484;
1753 } else if (u4ChannelNum
== 133) {
1754 u4ChannelInMHz
= 3665; /* 802.11y */
1755 } else if (u4ChannelNum
== 137) {
1756 u4ChannelInMHz
= 3685; /* 802.11y */
1757 } else if (u4ChannelNum
>= 34 && u4ChannelNum
<= 165) {
1758 u4ChannelInMHz
= 5000 + u4ChannelNum
* 5;
1759 } else if (u4ChannelNum
>= 183 && u4ChannelNum
<= 196) {
1760 u4ChannelInMHz
= 4000 + u4ChannelNum
* 5;
1765 return 1000 * u4ChannelInMHz
;
1769 /*----------------------------------------------------------------------------*/
1771 * @brief This utility function is used to convert between
1772 * frequency and channel number
1774 * @param u4FreqInKHz
1776 * @retval - Frequency Number, 0 for invalid freqency
1778 /*----------------------------------------------------------------------------*/
1779 UINT_32
nicFreq2ChannelNum(UINT_32 u4FreqInKHz
)
1781 switch (u4FreqInKHz
) {
1811 return 133; /* 802.11y */
1813 return 137; /* 802.11y */
1900 /* firmware command wrapper */
1901 /* NETWORK (WIFISYS) */
1902 /*----------------------------------------------------------------------------*/
1904 * @brief This utility function is used to activate WIFISYS for specified network
1906 * @param prAdapter Pointer of ADAPTER_T
1907 * eNetworkTypeIdx Index of network type
1911 /*----------------------------------------------------------------------------*/
1913 nicActivateNetwork(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
1915 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl
;
1916 P_BSS_INFO_T prBssInfo
;
1919 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
1921 rCmdActivateCtrl
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
1922 rCmdActivateCtrl
.ucActive
= 1;
1924 if (((UINT_8
) eNetworkTypeIdx
) < NETWORK_TYPE_INDEX_NUM
) {
1925 prBssInfo
= &prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
];
1926 prBssInfo
->fg40mBwAllowed
= FALSE
;
1927 prBssInfo
->fgAssoc40mBwAllowed
= FALSE
;
1930 return wlanSendSetQueryCmd(prAdapter
,
1931 CMD_ID_BSS_ACTIVATE_CTRL
,
1937 sizeof(CMD_BSS_ACTIVATE_CTRL
),
1938 (PUINT_8
) & rCmdActivateCtrl
, NULL
, 0);
1942 /*----------------------------------------------------------------------------*/
1944 * @brief This utility function is used to deactivate WIFISYS for specified network
1946 * @param prAdapter Pointer of ADAPTER_T
1947 * eNetworkTypeIdx Index of network type
1951 /*----------------------------------------------------------------------------*/
1953 nicDeactivateNetwork(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
1955 WLAN_STATUS u4Status
;
1956 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl
;
1959 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
1961 rCmdActivateCtrl
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
1962 rCmdActivateCtrl
.ucActive
= 0;
1964 u4Status
= wlanSendSetQueryCmd(prAdapter
,
1965 CMD_ID_BSS_ACTIVATE_CTRL
,
1971 sizeof(CMD_BSS_ACTIVATE_CTRL
),
1972 (PUINT_8
) & rCmdActivateCtrl
, NULL
, 0);
1974 /* free all correlated station records */
1975 cnmStaFreeAllStaByNetType(prAdapter
, eNetworkTypeIdx
, FALSE
);
1976 qmFreeAllByNetType(prAdapter
, eNetworkTypeIdx
);
1977 nicFreePendingTxMsduInfoByNetwork(prAdapter
, eNetworkTypeIdx
);
1978 kalClearSecurityFramesByNetType(prAdapter
->prGlueInfo
, eNetworkTypeIdx
);
1985 /*----------------------------------------------------------------------------*/
1987 * @brief This utility function is used to sync bss info with firmware
1988 * when a new BSS has been connected or disconnected
1990 * @param prAdapter Pointer of ADAPTER_T
1991 * eNetworkTypeIdx Index of BSS-INFO type
1995 /*----------------------------------------------------------------------------*/
1996 WLAN_STATUS
nicUpdateBss(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
1998 WLAN_STATUS u4Status
;
1999 P_BSS_INFO_T prBssInfo
;
2000 CMD_SET_BSS_INFO rCmdSetBssInfo
;
2003 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2005 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2007 kalMemZero(&rCmdSetBssInfo
, sizeof(CMD_SET_BSS_INFO
));
2009 rCmdSetBssInfo
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2010 rCmdSetBssInfo
.ucConnectionState
= (UINT_8
) prBssInfo
->eConnectionState
;
2011 rCmdSetBssInfo
.ucCurrentOPMode
= (UINT_8
) prBssInfo
->eCurrentOPMode
;
2012 rCmdSetBssInfo
.ucSSIDLen
= (UINT_8
) prBssInfo
->ucSSIDLen
;
2013 kalMemCopy(rCmdSetBssInfo
.aucSSID
, prBssInfo
->aucSSID
, prBssInfo
->ucSSIDLen
);
2014 COPY_MAC_ADDR(rCmdSetBssInfo
.aucBSSID
, prBssInfo
->aucBSSID
);
2015 rCmdSetBssInfo
.ucIsQBSS
= (UINT_8
) prBssInfo
->fgIsQBSS
;
2016 rCmdSetBssInfo
.ucNonHTBasicPhyType
= prBssInfo
->ucNonHTBasicPhyType
;
2017 rCmdSetBssInfo
.u2OperationalRateSet
= prBssInfo
->u2OperationalRateSet
;
2018 rCmdSetBssInfo
.u2BSSBasicRateSet
= prBssInfo
->u2BSSBasicRateSet
;
2019 rCmdSetBssInfo
.ucPhyTypeSet
= prBssInfo
->ucPhyTypeSet
;
2020 rCmdSetBssInfo
.fgHiddenSsidMode
= prBssInfo
->eHiddenSsidType
;
2021 #if CFG_ENABLE_WIFI_DIRECT
2022 if (prAdapter
->fgIsP2PRegistered
) {
2023 COPY_MAC_ADDR(rCmdSetBssInfo
.aucOwnMac
, prBssInfo
->aucOwnMacAddr
);
2027 rlmFillSyncCmdParam(&rCmdSetBssInfo
.rBssRlmParam
, prBssInfo
);
2029 rCmdSetBssInfo
.fgWapiMode
= (UINT_8
) FALSE
;
2031 if (rCmdSetBssInfo
.ucNetTypeIndex
== NETWORK_TYPE_AIS_INDEX
) {
2032 P_CONNECTION_SETTINGS_T prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2034 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) prConnSettings
->eAuthMode
;
2035 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) prConnSettings
->eEncStatus
;
2036 rCmdSetBssInfo
.fgWapiMode
= (UINT_8
) prConnSettings
->fgWapiMode
;
2038 #if CFG_ENABLE_BT_OVER_WIFI
2039 else if (rCmdSetBssInfo
.ucNetTypeIndex
== NETWORK_TYPE_BOW_INDEX
) {
2040 /* P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings); */
2041 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) AUTH_MODE_WPA2_PSK
;
2042 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) ENUM_ENCRYPTION3_KEY_ABSENT
;
2046 #if CFG_ENABLE_WIFI_DIRECT
2047 if (prAdapter
->fgIsP2PRegistered
) {
2048 if (kalP2PGetCipher(prAdapter
->prGlueInfo
)) {
2049 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) AUTH_MODE_WPA2_PSK
;
2050 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) ENUM_ENCRYPTION3_KEY_ABSENT
;
2052 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) AUTH_MODE_OPEN
;
2053 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) ENUM_ENCRYPTION_DISABLED
;
2055 /* Need the probe response to detect the PBC overlap */
2056 rCmdSetBssInfo
.fgIsApMode
=
2057 p2pFuncIsAPMode(prAdapter
->rWifiVar
.prP2pFsmInfo
);
2060 rCmdSetBssInfo
.ucAuthMode
= (UINT_8
) AUTH_MODE_WPA2_PSK
;
2061 rCmdSetBssInfo
.ucEncStatus
= (UINT_8
) ENUM_ENCRYPTION3_KEY_ABSENT
;
2065 if (eNetworkTypeIdx
== NETWORK_TYPE_AIS_INDEX
&&
2066 prBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
&&
2067 prBssInfo
->prStaRecOfAP
!= NULL
) {
2068 rCmdSetBssInfo
.ucStaRecIdxOfAP
= prBssInfo
->prStaRecOfAP
->ucIndex
;
2070 cnmAisInfraConnectNotify(prAdapter
);
2072 #if CFG_ENABLE_WIFI_DIRECT
2073 else if ((prAdapter
->fgIsP2PRegistered
) &&
2074 (eNetworkTypeIdx
== NETWORK_TYPE_P2P_INDEX
) &&
2075 (prBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
) &&
2076 (prBssInfo
->prStaRecOfAP
!= NULL
)) {
2077 rCmdSetBssInfo
.ucStaRecIdxOfAP
= prBssInfo
->prStaRecOfAP
->ucIndex
;
2081 #if CFG_ENABLE_BT_OVER_WIFI
2082 else if (eNetworkTypeIdx
== NETWORK_TYPE_BOW_INDEX
&&
2083 prBssInfo
->eCurrentOPMode
== OP_MODE_BOW
&& prBssInfo
->prStaRecOfAP
!= NULL
) {
2084 rCmdSetBssInfo
.ucStaRecIdxOfAP
= prBssInfo
->prStaRecOfAP
->ucIndex
;
2088 rCmdSetBssInfo
.ucStaRecIdxOfAP
= STA_REC_INDEX_NOT_FOUND
;
2091 u4Status
= wlanSendSetQueryCmd(prAdapter
,
2092 CMD_ID_SET_BSS_INFO
,
2098 sizeof(CMD_SET_BSS_INFO
),
2099 (PUINT_8
) & rCmdSetBssInfo
, NULL
, 0);
2101 /* if BSS-INFO is going to be disconnected state, free all correlated station records */
2102 if (prBssInfo
->eConnectionState
== PARAM_MEDIA_STATE_DISCONNECTED
) {
2103 /* clear client list */
2104 bssClearClientList(prAdapter
, prBssInfo
);
2106 /* free all correlated station records */
2107 cnmStaFreeAllStaByNetType(prAdapter
, eNetworkTypeIdx
, FALSE
);
2108 qmFreeAllByNetType(prAdapter
, eNetworkTypeIdx
);
2109 kalClearSecurityFramesByNetType(prAdapter
->prGlueInfo
, eNetworkTypeIdx
);
2116 /* BSS-INFO Indication (PM) */
2117 /*----------------------------------------------------------------------------*/
2119 * @brief This utility function is used to indicate PM that
2120 * a BSS has been created. (for AdHoc / P2P-GO)
2122 * @param prAdapter Pointer of ADAPTER_T
2123 * eNetworkTypeIdx Index of BSS-INFO
2127 /*----------------------------------------------------------------------------*/
2129 nicPmIndicateBssCreated(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2131 P_BSS_INFO_T prBssInfo
;
2132 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated
;
2135 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2137 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2139 rCmdIndicatePmBssCreated
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2140 rCmdIndicatePmBssCreated
.ucDtimPeriod
= prBssInfo
->ucDTIMPeriod
;
2141 rCmdIndicatePmBssCreated
.u2BeaconInterval
= prBssInfo
->u2BeaconInterval
;
2142 rCmdIndicatePmBssCreated
.u2AtimWindow
= prBssInfo
->u2ATIMWindow
;
2144 return wlanSendSetQueryCmd(prAdapter
,
2145 CMD_ID_INDICATE_PM_BSS_CREATED
,
2151 sizeof(CMD_INDICATE_PM_BSS_CREATED
),
2152 (PUINT_8
) & rCmdIndicatePmBssCreated
, NULL
, 0);
2156 /*----------------------------------------------------------------------------*/
2158 * @brief This utility function is used to indicate PM that
2159 * a BSS has been connected
2161 * @param prAdapter Pointer of ADAPTER_T
2162 * eNetworkTypeIdx Index of BSS-INFO
2166 /*----------------------------------------------------------------------------*/
2168 nicPmIndicateBssConnected(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2170 P_BSS_INFO_T prBssInfo
;
2171 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected
;
2174 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2176 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2178 rCmdIndicatePmBssConnected
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2179 rCmdIndicatePmBssConnected
.ucDtimPeriod
= prBssInfo
->ucDTIMPeriod
;
2180 rCmdIndicatePmBssConnected
.u2AssocId
= prBssInfo
->u2AssocId
;
2181 rCmdIndicatePmBssConnected
.u2BeaconInterval
= prBssInfo
->u2BeaconInterval
;
2182 rCmdIndicatePmBssConnected
.u2AtimWindow
= prBssInfo
->u2ATIMWindow
;
2184 rCmdIndicatePmBssConnected
.ucBmpDeliveryAC
= prBssInfo
->rPmProfSetupInfo
.ucBmpDeliveryAC
;
2185 rCmdIndicatePmBssConnected
.ucBmpTriggerAC
= prBssInfo
->rPmProfSetupInfo
.ucBmpTriggerAC
;
2187 /* DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x", */
2188 /* rCmdIndicatePmBssConnected.ucBmpDeliveryAC, */
2189 /* rCmdIndicatePmBssConnected.ucBmpTriggerAC); */
2191 if ((eNetworkTypeIdx
== NETWORK_TYPE_AIS_INDEX
)
2192 #if CFG_ENABLE_WIFI_DIRECT
2193 || ((eNetworkTypeIdx
== NETWORK_TYPE_P2P_INDEX
) && (prAdapter
->fgIsP2PRegistered
))
2196 if (prBssInfo
->eCurrentOPMode
== OP_MODE_INFRASTRUCTURE
) {
2197 rCmdIndicatePmBssConnected
.fgIsUapsdConnection
=
2198 (UINT_8
) prBssInfo
->prStaRecOfAP
->fgIsUapsdSupported
;
2200 rCmdIndicatePmBssConnected
.fgIsUapsdConnection
= 0; /* @FIXME */
2203 rCmdIndicatePmBssConnected
.fgIsUapsdConnection
= 0;
2206 return wlanSendSetQueryCmd(prAdapter
,
2207 CMD_ID_INDICATE_PM_BSS_CONNECTED
,
2213 sizeof(CMD_INDICATE_PM_BSS_CONNECTED
),
2214 (PUINT_8
) & rCmdIndicatePmBssConnected
, NULL
, 0);
2218 /*----------------------------------------------------------------------------*/
2220 * @brief This utility function is used to indicate PM that
2221 * a BSS has been disconnected
2223 * @param prAdapter Pointer of ADAPTER_T
2224 * eNetworkTypeIdx Index of BSS-INFO
2228 /*----------------------------------------------------------------------------*/
2230 nicPmIndicateBssAbort(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2232 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort
;
2235 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2237 rCmdIndicatePmBssAbort
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2239 return wlanSendSetQueryCmd(prAdapter
,
2240 CMD_ID_INDICATE_PM_BSS_ABORT
,
2246 sizeof(CMD_INDICATE_PM_BSS_ABORT
),
2247 (PUINT_8
) & rCmdIndicatePmBssAbort
, NULL
, 0);
2251 nicConfigPowerSaveProfile(IN P_ADAPTER_T prAdapter
,
2252 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
2253 PARAM_POWER_MODE ePwrMode
, BOOLEAN fgEnCmdEvent
)
2255 DEBUGFUNC("nicConfigPowerSaveProfile");
2256 DBGLOG(INIT
, TRACE
, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2257 eNetTypeIndex
, ePwrMode
, fgEnCmdEvent
));
2261 if (eNetTypeIndex
>= NETWORK_TYPE_INDEX_NUM
) {
2263 return WLAN_STATUS_NOT_SUPPORTED
;
2265 /* prAdapter->rWlanInfo.ePowerSaveMode.ucNetTypeIndex = eNetTypeIndex; */
2266 /* prAdapter->rWlanInfo.ePowerSaveMode.ucPsProfile = (UINT_8)ePwrMode; */
2267 prAdapter
->rWlanInfo
.arPowerSaveMode
[eNetTypeIndex
].ucNetTypeIndex
= eNetTypeIndex
;
2268 prAdapter
->rWlanInfo
.arPowerSaveMode
[eNetTypeIndex
].ucPsProfile
= (UINT_8
) ePwrMode
;
2270 return wlanSendSetQueryCmd(prAdapter
,
2271 CMD_ID_POWER_SAVE_MODE
,
2275 (fgEnCmdEvent
? nicCmdEventSetCommon
: NULL
),
2276 (fgEnCmdEvent
? nicOidCmdTimeoutCommon
: NULL
),
2277 sizeof(CMD_PS_PROFILE_T
),
2278 (PUINT_8
) & (prAdapter
->rWlanInfo
.
2279 arPowerSaveMode
[eNetTypeIndex
]), NULL
,
2280 sizeof(PARAM_POWER_MODE
)
2283 } /* end of wlanoidSetAcpiDevicePowerStateMode() */
2285 /*----------------------------------------------------------------------------*/
2287 * @brief This utility function is used to indicate firmware domain
2288 * for beacon generation parameters
2290 * @param prAdapter Pointer of ADAPTER_T
2291 * eIeUpdMethod, Update Method
2292 * eNetTypeIndex Index of Network
2293 * u2Capability Capability
2294 * aucIe Pointer to buffer of IEs
2295 * u2IELen Length of IEs
2297 * @retval - WLAN_STATUS_SUCCESS
2298 * WLAN_STATUS_FAILURE
2299 * WLAN_STATUS_PENDING
2300 * WLAN_STATUS_INVALID_DATA
2302 /*----------------------------------------------------------------------------*/
2304 nicUpdateBeaconIETemplate(IN P_ADAPTER_T prAdapter
,
2305 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod
,
2306 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
,
2307 IN UINT_16 u2Capability
, IN PUINT_8 aucIe
, IN UINT_16 u2IELen
)
2309 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate
;
2310 UINT_16 u2CmdBufLen
= 0;
2311 P_GLUE_INFO_T prGlueInfo
;
2312 P_CMD_INFO_T prCmdInfo
;
2313 P_WIFI_CMD_T prWifiCmd
;
2316 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2317 DBGLOG(INIT
, LOUD
, ("\n"));
2319 printk("nicUpdateBeaconIETemplate\n");
2322 prGlueInfo
= prAdapter
->prGlueInfo
;
2324 if (u2IELen
> MAX_IE_LENGTH
) {
2325 return WLAN_STATUS_INVALID_DATA
;
2328 if (eIeUpdMethod
== IE_UPD_METHOD_UPDATE_RANDOM
|| eIeUpdMethod
== IE_UPD_METHOD_UPDATE_ALL
) {
2329 u2CmdBufLen
= OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE
, aucIE
) + u2IELen
;
2330 } else if (eIeUpdMethod
== IE_UPD_METHOD_DELETE_ALL
) {
2331 u2CmdBufLen
= OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE
, u2IELen
);
2334 return WLAN_STATUS_FAILURE
;
2337 /* prepare command info */
2338 prCmdInfo
= cmdBufAllocateCmdInfo(prAdapter
, (CMD_HDR_SIZE
+ u2CmdBufLen
));
2340 DBGLOG(INIT
, ERROR
, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2341 printk("Allocate CMD_INFO_T ==> FAILED.\n");
2342 return WLAN_STATUS_FAILURE
;
2344 /* increase command sequence number */
2345 ucCmdSeqNum
= nicIncreaseCmdSeqNum(prAdapter
);
2346 DBGLOG(REQ
, TRACE
, ("ucCmdSeqNum =%d\n", ucCmdSeqNum
));
2348 /* Setup common CMD Info Packet */
2349 prCmdInfo
->eCmdType
= COMMAND_TYPE_NETWORK_IOCTL
;
2350 prCmdInfo
->eNetworkType
= eNetTypeIndex
;
2351 prCmdInfo
->u2InfoBufLen
= (UINT_16
) (CMD_HDR_SIZE
+ u2CmdBufLen
);
2352 prCmdInfo
->pfCmdDoneHandler
= NULL
; /* @FIXME */
2353 prCmdInfo
->pfCmdTimeoutHandler
= NULL
; /* @FIXME */
2354 prCmdInfo
->fgIsOid
= FALSE
;
2355 prCmdInfo
->ucCID
= CMD_ID_UPDATE_BEACON_CONTENT
;
2356 prCmdInfo
->fgSetQuery
= TRUE
;
2357 prCmdInfo
->fgNeedResp
= FALSE
;
2358 prCmdInfo
->fgDriverDomainMCR
= FALSE
;
2359 prCmdInfo
->ucCmdSeqNum
= ucCmdSeqNum
;
2360 prCmdInfo
->u4SetInfoLen
= u2CmdBufLen
;
2361 prCmdInfo
->pvInformationBuffer
= NULL
;
2362 prCmdInfo
->u4InformationBufferLength
= 0;
2364 /* Setup WIFI_CMD_T (no payload) */
2365 prWifiCmd
= (P_WIFI_CMD_T
) (prCmdInfo
->pucInfoBuffer
);
2366 prWifiCmd
->u2TxByteCount_UserPriority
= prCmdInfo
->u2InfoBufLen
;
2367 prWifiCmd
->ucCID
= prCmdInfo
->ucCID
;
2368 prWifiCmd
->ucSetQuery
= prCmdInfo
->fgSetQuery
;
2369 prWifiCmd
->ucSeqNum
= prCmdInfo
->ucCmdSeqNum
;
2371 prCmdBcnUpdate
= (P_CMD_BEACON_TEMPLATE_UPDATE
) (prWifiCmd
->aucBuffer
);
2373 /* fill beacon updating command */
2374 prCmdBcnUpdate
->ucUpdateMethod
= (UINT_8
) eIeUpdMethod
;
2375 prCmdBcnUpdate
->ucNetTypeIndex
= (UINT_8
) eNetTypeIndex
;
2376 prCmdBcnUpdate
->u2Capability
= u2Capability
;
2377 prCmdBcnUpdate
->u2IELen
= u2IELen
;
2379 kalMemCopy(prCmdBcnUpdate
->aucIE
, aucIe
, u2IELen
);
2381 /* insert into prCmdQueue */
2382 kalEnqueueCommand(prGlueInfo
, (P_QUE_ENTRY_T
) prCmdInfo
);
2384 /* wakeup txServiceThread later */
2385 GLUE_SET_EVENT(prGlueInfo
);
2386 return WLAN_STATUS_PENDING
;
2390 /*----------------------------------------------------------------------------*/
2392 * @brief This utility function is used to initialization PHY related
2395 * @param prAdapter Pointer of ADAPTER_T
2399 /*----------------------------------------------------------------------------*/
2400 VOID
nicSetAvailablePhyTypeSet(IN P_ADAPTER_T prAdapter
)
2402 P_CONNECTION_SETTINGS_T prConnSettings
;
2406 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
2408 if (prConnSettings
->eDesiredPhyConfig
>= PHY_CONFIG_NUM
) {
2413 prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
=
2414 aucPhyCfg2PhyTypeSet
[prConnSettings
->eDesiredPhyConfig
];
2416 if (prAdapter
->rWifiVar
.ucAvailablePhyTypeSet
& PHY_TYPE_BIT_ERP
) {
2417 prAdapter
->rWifiVar
.eNonHTBasicPhyType2G4
= PHY_TYPE_ERP_INDEX
;
2419 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2420 else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
2422 prAdapter
->rWifiVar
.eNonHTBasicPhyType2G4
= PHY_TYPE_HR_DSSS_INDEX
;
2429 /*----------------------------------------------------------------------------*/
2431 * @brief This utility function is used to update WMM Parms
2433 * @param prAdapter Pointer of ADAPTER_T
2434 * eNetworkTypeIdx Index of BSS-INFO
2438 /*----------------------------------------------------------------------------*/
2440 nicQmUpdateWmmParms(IN P_ADAPTER_T prAdapter
, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
)
2442 P_BSS_INFO_T prBssInfo
;
2443 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms
;
2446 ASSERT(eNetworkTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
2448 DBGLOG(QM
, EVENT
, ("sizeof(AC_QUE_PARMS_T): %d\n", sizeof(AC_QUE_PARMS_T
)));
2449 DBGLOG(QM
, EVENT
, ("sizeof(CMD_UPDATE_WMM_PARMS): %d\n", sizeof(CMD_UPDATE_WMM_PARMS_T
)));
2450 DBGLOG(QM
, EVENT
, ("sizeof(WIFI_CMD_T): %d\n", sizeof(WIFI_CMD_T
)));
2452 prBssInfo
= &(prAdapter
->rWifiVar
.arBssInfo
[eNetworkTypeIdx
]);
2453 rCmdUpdateWmmParms
.ucNetTypeIndex
= (UINT_8
) eNetworkTypeIdx
;
2454 kalMemCopy(&rCmdUpdateWmmParms
.arACQueParms
[0], &prBssInfo
->arACQueParms
[0],
2455 (sizeof(AC_QUE_PARMS_T
) * AC_NUM
));
2457 rCmdUpdateWmmParms
.fgIsQBSS
= prBssInfo
->fgIsQBSS
;
2459 return wlanSendSetQueryCmd(prAdapter
,
2460 CMD_ID_UPDATE_WMM_PARMS
,
2466 sizeof(CMD_UPDATE_WMM_PARMS_T
),
2467 (PUINT_8
) & rCmdUpdateWmmParms
, NULL
, 0);
2471 /*----------------------------------------------------------------------------*/
2473 * @brief This utility function is used to update TX power gain corresponding to
2474 * each band/modulation combination
2476 * @param prAdapter Pointer of ADAPTER_T
2477 * prTxPwrParam Pointer of TX power parameters
2479 * @retval WLAN_STATUS_PENDING
2480 * WLAN_STATUS_FAILURE
2482 /*----------------------------------------------------------------------------*/
2483 WLAN_STATUS
nicUpdateTxPower(IN P_ADAPTER_T prAdapter
, IN P_CMD_TX_PWR_T prTxPwrParam
)
2485 DEBUGFUNC("nicUpdateTxPower");
2489 return wlanSendSetQueryCmd(prAdapter
,
2495 NULL
, sizeof(CMD_TX_PWR_T
), (PUINT_8
) prTxPwrParam
, NULL
, 0);
2498 /*----------------------------------------------------------------------------*/
2500 * @brief This utility function is used to set auto tx power parameter
2502 * @param prAdapter Pointer of ADAPTER_T
2503 * prTxPwrParam Pointer of Auto TX power parameters
2505 * @retval WLAN_STATUS_PENDING
2506 * WLAN_STATUS_FAILURE
2508 /*----------------------------------------------------------------------------*/
2509 WLAN_STATUS
nicSetAutoTxPower(IN P_ADAPTER_T prAdapter
, IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam
)
2511 DEBUGFUNC("nicSetAutoTxPower");
2515 return wlanSendSetQueryCmd(prAdapter
,
2516 CMD_ID_SET_AUTOPWR_CTRL
,
2522 sizeof(CMD_AUTO_POWER_PARAM_T
),
2523 (PUINT_8
) prAutoPwrParam
, NULL
, 0);
2527 /*----------------------------------------------------------------------------*/
2529 * @brief This utility function is used to update TX power gain corresponding to
2530 * each band/modulation combination
2532 * @param prAdapter Pointer of ADAPTER_T
2533 * prTxPwrParam Pointer of TX power parameters
2535 * @retval WLAN_STATUS_PENDING
2536 * WLAN_STATUS_FAILURE
2538 /*----------------------------------------------------------------------------*/
2539 WLAN_STATUS
nicSetAutoTxPowerControl(IN P_ADAPTER_T prAdapter
, IN P_CMD_TX_PWR_T prTxPwrParam
)
2541 DEBUGFUNC("nicUpdateTxPower");
2545 return wlanSendSetQueryCmd(prAdapter
,
2551 NULL
, sizeof(CMD_TX_PWR_T
), (PUINT_8
) prTxPwrParam
, NULL
, 0);
2555 /*----------------------------------------------------------------------------*/
2557 * @brief This utility function is used to update power offset around 5GHz band
2559 * @param prAdapter Pointer of ADAPTER_T
2560 * pr5GPwrOffset Pointer of 5GHz power offset parameter
2562 * @retval WLAN_STATUS_PENDING
2563 * WLAN_STATUS_FAILURE
2565 /*----------------------------------------------------------------------------*/
2566 WLAN_STATUS
nicUpdate5GOffset(IN P_ADAPTER_T prAdapter
, IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset
)
2568 DEBUGFUNC("nicUpdate5GOffset");
2572 return wlanSendSetQueryCmd(prAdapter
,
2573 CMD_ID_SET_5G_PWR_OFFSET
,
2579 sizeof(CMD_5G_PWR_OFFSET_T
), (PUINT_8
) pr5GPwrOffset
, NULL
, 0);
2583 /*----------------------------------------------------------------------------*/
2585 * @brief This utility function is used to update DPD calibration result
2587 * @param prAdapter Pointer of ADAPTER_T
2588 * pr5GPwrOffset Pointer of parameter for DPD calibration result
2590 * @retval WLAN_STATUS_PENDING
2591 * WLAN_STATUS_FAILURE
2593 /*----------------------------------------------------------------------------*/
2594 WLAN_STATUS
nicUpdateDPD(IN P_ADAPTER_T prAdapter
, IN P_CMD_PWR_PARAM_T prDpdCalResult
)
2596 DEBUGFUNC("nicUpdateDPD");
2600 return wlanSendSetQueryCmd(prAdapter
,
2601 CMD_ID_SET_PWR_PARAM
,
2607 sizeof(CMD_PWR_PARAM_T
), (PUINT_8
) prDpdCalResult
, NULL
, 0);
2611 /*----------------------------------------------------------------------------*/
2613 * @brief This utility function starts system service such as timer and
2616 * @param prAdapter Pointer of ADAPTER_T
2620 /*----------------------------------------------------------------------------*/
2621 VOID
nicInitSystemService(IN P_ADAPTER_T prAdapter
)
2625 /* <1> Initialize MGMT Memory pool and STA_REC */
2626 cnmMemInit(prAdapter
);
2627 cnmStaRecInit(prAdapter
);
2628 cmdBufInitialize(prAdapter
);
2630 /* <2> Mailbox Initialization */
2631 mboxInitialize(prAdapter
);
2633 /* <3> Timer Initialization */
2634 cnmTimerInitialize(prAdapter
);
2640 /*----------------------------------------------------------------------------*/
2642 * @brief This utility function reset some specific system service,
2645 * @param prAdapter Pointer of ADAPTER_T
2649 /*----------------------------------------------------------------------------*/
2650 VOID
nicResetSystemService(IN P_ADAPTER_T prAdapter
)
2656 /*----------------------------------------------------------------------------*/
2658 * @brief This utility function is used to update WMM Parms
2660 * @param prAdapter Pointer of ADAPTER_T
2664 /*----------------------------------------------------------------------------*/
2665 VOID
nicUninitSystemService(IN P_ADAPTER_T prAdapter
)
2669 /* Timer Destruction */
2670 cnmTimerDestroy(prAdapter
);
2672 /* Mailbox Destruction */
2673 mboxDestroy(prAdapter
);
2679 /*----------------------------------------------------------------------------*/
2681 * @brief This utility function is used to update WMM Parms
2683 * @param prAdapter Pointer of ADAPTER_T
2687 /*----------------------------------------------------------------------------*/
2688 VOID
nicInitMGMT(IN P_ADAPTER_T prAdapter
, IN P_REG_INFO_T prRegInfo
)
2692 /* CNM Module - initialization */
2695 /* RLM Module - initialization */
2696 rlmFsmEventInit(prAdapter
);
2698 /* SCN Module - initialization */
2701 /* AIS Module - intiailization */
2702 aisInitializeConnectionSettings(prAdapter
, prRegInfo
);
2703 aisFsmInit(prAdapter
);
2705 #if CFG_SUPPORT_ROAMING
2706 /* Roaming Module - intiailization */
2707 roamingFsmInit(prAdapter
);
2708 #endif /* CFG_SUPPORT_ROAMING */
2710 #if CFG_SUPPORT_SWCR
2711 swCrDebugInit(prAdapter
);
2712 #endif /* CFG_SUPPORT_SWCR */
2718 /*----------------------------------------------------------------------------*/
2720 * @brief This utility function is used to update WMM Parms
2722 * @param prAdapter Pointer of ADAPTER_T
2726 /*----------------------------------------------------------------------------*/
2727 VOID
nicUninitMGMT(IN P_ADAPTER_T prAdapter
)
2731 #if CFG_SUPPORT_SWCR
2732 swCrDebugUninit(prAdapter
);
2733 #endif /* CFG_SUPPORT_SWCR */
2735 #if CFG_SUPPORT_ROAMING
2736 /* Roaming Module - unintiailization */
2737 roamingFsmUninit(prAdapter
);
2738 #endif /* CFG_SUPPORT_ROAMING */
2740 /* AIS Module - unintiailization */
2741 aisFsmUninit(prAdapter
);
2743 /* SCN Module - unintiailization */
2744 scnUninit(prAdapter
);
2746 /* RLM Module - uninitialization */
2747 rlmFsmEventUninit(prAdapter
);
2749 /* CNM Module - uninitialization */
2750 cnmUninit(prAdapter
);
2756 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2757 /*----------------------------------------------------------------------------*/
2759 * @brief This utility function is to inform firmware to enable MCU clock gating
2761 * @param prAdapter Pointer of ADAPTER_T
2765 /*----------------------------------------------------------------------------*/
2766 WLAN_STATUS
nicEnableClockGating(IN P_ADAPTER_T prAdapter
)
2768 UINT_32 i
, u4WHISR
= 0;
2772 if (prAdapter
->fgIsClockGatingEnabled
== TRUE
) {
2773 return WLAN_STATUS_SUCCESS
;
2775 nicSetSwIntr(prAdapter
, REQ_GATING_ENABLE_H2D_INT
);
2778 while (i
< GATING_CONTROL_POLL_LIMIT
) {
2779 if (kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
2780 || fgIsBusAccessFailed
== TRUE
) {
2781 return WLAN_STATUS_FAILURE
;
2784 HAL_READ_INTR_STATUS(prAdapter
, sizeof(UINT_32
), (PUINT_8
) & u4WHISR
);
2786 if (u4WHISR
& ACK_GATING_ENABLE_D2H_INT
) {
2787 prAdapter
->fgIsClockGatingEnabled
= TRUE
;
2788 return WLAN_STATUS_SUCCESS
;
2793 return WLAN_STATUS_PENDING
;
2798 /*----------------------------------------------------------------------------*/
2800 * @brief This utility function is to inform firmware to disable MCU clock gating
2802 * @param prAdapter Pointer of ADAPTER_T
2806 /*----------------------------------------------------------------------------*/
2807 WLAN_STATUS
nicDisableClockGating(IN P_ADAPTER_T prAdapter
)
2809 UINT_32 i
, u4WHISR
= 0;
2813 if (prAdapter
->fgIsClockGatingEnabled
== FALSE
) {
2814 return WLAN_STATUS_SUCCESS
;
2816 nicSetSwIntr(prAdapter
, REQ_GATING_DISABLE_H2D_INT
);
2819 while (i
< GATING_CONTROL_POLL_LIMIT
) {
2820 if (kalIsCardRemoved(prAdapter
->prGlueInfo
) == TRUE
2821 || fgIsBusAccessFailed
== TRUE
) {
2822 return WLAN_STATUS_FAILURE
;
2825 HAL_READ_INTR_STATUS(prAdapter
, sizeof(UINT_32
), (PUINT_8
) & u4WHISR
);
2827 if (u4WHISR
& ACK_GATING_DISABLE_D2H_INT
) {
2828 prAdapter
->fgIsClockGatingEnabled
= FALSE
;
2829 return WLAN_STATUS_SUCCESS
;
2834 return WLAN_STATUS_PENDING
;
2840 /*----------------------------------------------------------------------------*/
2842 * @brief This function is invoked to buffer scan result
2844 * @param prAdapter Pointer to the Adapter structure.
2845 * @param rMacAddr BSSID
2846 * @param prSsid Pointer to SSID
2847 * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
2848 * @param rRssi Received Strength (-10 ~ -200 dBm)
2849 * @param eNetworkType Network Type (a/b/g)
2850 * @param prConfiguration Network Parameter
2851 * @param eOpMode Infra/Ad-Hoc
2852 * @param rSupportedRates Supported basic rates
2853 * @param u2IELength IE Length
2854 * @param pucIEBuf Pointer to Information Elements(IEs)
2858 /*----------------------------------------------------------------------------*/
2860 nicAddScanResult(IN P_ADAPTER_T prAdapter
,
2861 IN PARAM_MAC_ADDRESS rMacAddr
,
2862 IN P_PARAM_SSID_T prSsid
,
2863 IN UINT_32 u4Privacy
,
2864 IN PARAM_RSSI rRssi
,
2865 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType
,
2866 IN P_PARAM_802_11_CONFIG_T prConfiguration
,
2867 IN ENUM_PARAM_OP_MODE_T eOpMode
,
2868 IN PARAM_RATES_EX rSupportedRates
, IN UINT_16 u2IELength
, IN PUINT_8 pucIEBuf
)
2872 UINT_32 u4IdxWeakest
= 0;
2873 PARAM_RSSI rWeakestRssi
;
2874 UINT_32 u4BufferSize
;
2878 rWeakestRssi
= (PARAM_RSSI
) INT_MAX
;
2880 sizeof(prAdapter
->rWlanInfo
.aucScanIEBuf
) /
2881 sizeof(prAdapter
->rWlanInfo
.aucScanIEBuf
[0]);
2885 /* decide to replace or add */
2886 for (i
= 0; i
< prAdapter
->rWlanInfo
.u4ScanResultNum
; i
++) {
2887 /* find weakest entry && not connected one */
2888 if (UNEQUAL_MAC_ADDR
2889 (prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
,
2890 prAdapter
->rWlanInfo
.rCurrBssId
.arMacAddress
)
2891 && prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
< rWeakestRssi
) {
2893 rWeakestRssi
= prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
;
2896 if (prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
== eOpMode
&&
2897 EQUAL_MAC_ADDR(&(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
), rMacAddr
)
2900 (prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
2901 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
, prSsid
->aucSsid
,
2903 || prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
== 0)) {
2907 /* free IE buffer then zero */
2908 nicFreeScanResultIE(prAdapter
, i
);
2909 kalMemZero(&(prAdapter
->rWlanInfo
.arScanResult
[i
]),
2910 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
2912 /* then fill buffer */
2913 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
=
2914 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
) + u2IELength
;
2915 COPY_MAC_ADDR(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
, rMacAddr
);
2916 COPY_SSID(prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
2917 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
,
2918 prSsid
->aucSsid
, prSsid
->u4SsidLen
);
2919 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Privacy
= u4Privacy
;
2920 prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
= rRssi
;
2921 prAdapter
->rWlanInfo
.arScanResult
[i
].eNetworkTypeInUse
= eNetworkType
;
2922 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[i
].rConfiguration
),
2923 prConfiguration
, sizeof(PARAM_802_11_CONFIG_T
));
2924 prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
= eOpMode
;
2925 kalMemCopy((prAdapter
->rWlanInfo
.arScanResult
[i
].rSupportedRates
),
2926 rSupportedRates
, sizeof(PARAM_RATES_EX
));
2927 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= (UINT_32
) u2IELength
;
2929 /* IE - allocate buffer and update pointer */
2930 if (u2IELength
> 0) {
2931 if (ALIGN_4(u2IELength
) +
2932 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
<= u4BufferSize
) {
2934 (prAdapter
->rWlanInfo
.
2935 aucScanIEBuf
[prAdapter
->rWlanInfo
.
2936 u4ScanIEBufferUsage
]), pucIEBuf
,
2939 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
2940 &(prAdapter
->rWlanInfo
.
2941 aucScanIEBuf
[prAdapter
->rWlanInfo
.
2942 u4ScanIEBufferUsage
]);
2944 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
+=
2945 ALIGN_4(u2IELength
);
2947 /* buffer is not enough */
2948 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
-= u2IELength
;
2949 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= 0;
2950 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
2953 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
2960 if (bReplace
== FALSE
) {
2961 if (prAdapter
->rWlanInfo
.u4ScanResultNum
< (CFG_MAX_NUM_BSS_LIST
- 1)) {
2962 i
= prAdapter
->rWlanInfo
.u4ScanResultNum
;
2965 kalMemZero(&(prAdapter
->rWlanInfo
.arScanResult
[i
]),
2966 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
2968 /* then fill buffer */
2969 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
=
2970 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
) + u2IELength
;
2971 COPY_MAC_ADDR(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
, rMacAddr
);
2972 COPY_SSID(prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
2973 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
,
2974 prSsid
->aucSsid
, prSsid
->u4SsidLen
);
2975 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Privacy
= u4Privacy
;
2976 prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
= rRssi
;
2977 prAdapter
->rWlanInfo
.arScanResult
[i
].eNetworkTypeInUse
= eNetworkType
;
2978 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[i
].rConfiguration
),
2979 prConfiguration
, sizeof(PARAM_802_11_CONFIG_T
));
2980 prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
= eOpMode
;
2981 kalMemCopy((prAdapter
->rWlanInfo
.arScanResult
[i
].rSupportedRates
),
2982 rSupportedRates
, sizeof(PARAM_RATES_EX
));
2983 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= (UINT_32
) u2IELength
;
2985 /* IE - allocate buffer and update pointer */
2986 if (u2IELength
> 0) {
2987 if (ALIGN_4(u2IELength
) +
2988 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
<= u4BufferSize
) {
2990 (prAdapter
->rWlanInfo
.
2991 aucScanIEBuf
[prAdapter
->rWlanInfo
.
2992 u4ScanIEBufferUsage
]), pucIEBuf
,
2995 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
2996 &(prAdapter
->rWlanInfo
.
2997 aucScanIEBuf
[prAdapter
->rWlanInfo
.
2998 u4ScanIEBufferUsage
]);
3000 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
+=
3001 ALIGN_4(u2IELength
);
3003 /* buffer is not enough */
3004 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
-= u2IELength
;
3005 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= 0;
3006 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3009 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3012 prAdapter
->rWlanInfo
.u4ScanResultNum
++;
3013 } else if (rWeakestRssi
!= (PARAM_RSSI
) INT_MAX
) {
3014 /* replace weakest one */
3017 /* free IE buffer then zero */
3018 nicFreeScanResultIE(prAdapter
, i
);
3019 kalMemZero(&(prAdapter
->rWlanInfo
.arScanResult
[i
]),
3020 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
));
3022 /* then fill buffer */
3023 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
=
3024 OFFSET_OF(PARAM_BSSID_EX_T
, aucIEs
) + u2IELength
;
3025 COPY_MAC_ADDR(prAdapter
->rWlanInfo
.arScanResult
[i
].arMacAddress
, rMacAddr
);
3026 COPY_SSID(prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.aucSsid
,
3027 prAdapter
->rWlanInfo
.arScanResult
[i
].rSsid
.u4SsidLen
,
3028 prSsid
->aucSsid
, prSsid
->u4SsidLen
);
3029 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Privacy
= u4Privacy
;
3030 prAdapter
->rWlanInfo
.arScanResult
[i
].rRssi
= rRssi
;
3031 prAdapter
->rWlanInfo
.arScanResult
[i
].eNetworkTypeInUse
= eNetworkType
;
3032 kalMemCopy(&(prAdapter
->rWlanInfo
.arScanResult
[i
].rConfiguration
),
3033 prConfiguration
, sizeof(PARAM_802_11_CONFIG_T
));
3034 prAdapter
->rWlanInfo
.arScanResult
[i
].eOpMode
= eOpMode
;
3035 kalMemCopy((prAdapter
->rWlanInfo
.arScanResult
[i
].rSupportedRates
),
3036 rSupportedRates
, sizeof(PARAM_RATES_EX
));
3037 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= (UINT_32
) u2IELength
;
3039 if (u2IELength
> 0) {
3040 /* IE - allocate buffer and update pointer */
3041 if (ALIGN_4(u2IELength
) +
3042 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
<= u4BufferSize
) {
3044 (prAdapter
->rWlanInfo
.
3045 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3046 u4ScanIEBufferUsage
]), pucIEBuf
,
3049 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
3050 &(prAdapter
->rWlanInfo
.
3051 aucScanIEBuf
[prAdapter
->rWlanInfo
.
3052 u4ScanIEBufferUsage
]);
3054 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
+=
3055 ALIGN_4(u2IELength
);
3057 /* buffer is not enough */
3058 prAdapter
->rWlanInfo
.arScanResult
[i
].u4Length
-= u2IELength
;
3059 prAdapter
->rWlanInfo
.arScanResult
[i
].u4IELength
= 0;
3060 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3063 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3070 /*----------------------------------------------------------------------------*/
3072 * @brief This function is invoked to free IE buffer for dedicated scan result
3074 * @param prAdapter Pointer to the Adapter structure.
3075 * @param u4Idx Index of Scan Result
3079 /*----------------------------------------------------------------------------*/
3080 VOID
nicFreeScanResultIE(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4Idx
)
3083 PUINT_8 pucPivot
, pucMovePivot
;
3084 UINT_32 u4MoveSize
, u4FreeSize
, u4ReserveSize
;
3087 ASSERT(u4Idx
< CFG_MAX_NUM_BSS_LIST
);
3089 if (prAdapter
->rWlanInfo
.arScanResult
[u4Idx
].u4IELength
== 0
3090 || prAdapter
->rWlanInfo
.apucScanResultIEs
[u4Idx
] == NULL
) {
3094 u4FreeSize
= ALIGN_4(prAdapter
->rWlanInfo
.arScanResult
[u4Idx
].u4IELength
);
3096 pucPivot
= prAdapter
->rWlanInfo
.apucScanResultIEs
[u4Idx
];
3098 (PUINT_8
) ((UINT_32
) (prAdapter
->rWlanInfo
.apucScanResultIEs
[u4Idx
]) + u4FreeSize
);
3100 u4ReserveSize
= ((UINT_32
) pucPivot
) - (UINT_32
) (&(prAdapter
->rWlanInfo
.aucScanIEBuf
[0]));
3101 u4MoveSize
= prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
- u4ReserveSize
- u4FreeSize
;
3103 /* 1. rest of buffer to move forward */
3104 kalMemCopy(pucPivot
, pucMovePivot
, u4MoveSize
);
3106 /* 1.1 modify pointers */
3107 for (i
= 0; i
< prAdapter
->rWlanInfo
.u4ScanResultNum
; i
++) {
3109 if (prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] >= pucMovePivot
) {
3110 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] =
3111 (PUINT_8
) ((UINT_32
) (prAdapter
->rWlanInfo
.apucScanResultIEs
[i
])
3117 /* 1.2 reset the freed one */
3118 prAdapter
->rWlanInfo
.arScanResult
[u4Idx
].u4IELength
= 0;
3119 prAdapter
->rWlanInfo
.apucScanResultIEs
[i
] = NULL
;
3121 /* 2. reduce IE buffer usage */
3122 prAdapter
->rWlanInfo
.u4ScanIEBufferUsage
-= u4FreeSize
;
3128 /*----------------------------------------------------------------------------*/
3130 * @brief This function is to hack parameters for WLAN TABLE for
3131 * fixed rate settings
3133 * @param prAdapter Pointer to the Adapter structure.
3134 * @param eRateSetting
3135 * @param pu2DesiredNonHTRateSet,
3136 * @param pu2BSSBasicRateSet,
3138 * @param pucSupMcs32
3139 * @param pu2HtCapInfo
3141 * @return WLAN_STATUS_SUCCESS
3143 /*----------------------------------------------------------------------------*/
3145 nicUpdateRateParams(IN P_ADAPTER_T prAdapter
,
3146 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting
,
3147 IN PUINT_8 pucDesiredPhyTypeSet
,
3148 IN PUINT_16 pu2DesiredNonHTRateSet
,
3149 IN PUINT_16 pu2BSSBasicRateSet
,
3150 IN PUINT_8 pucMcsSet
, IN PUINT_8 pucSupMcs32
, IN PUINT_16 pu2HtCapInfo
)
3153 ASSERT(eRateSetting
> FIXED_RATE_NONE
&& eRateSetting
< FIXED_RATE_NUM
);
3155 switch (prAdapter
->rWifiVar
.eRateSetting
) {
3157 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3158 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_1M
;
3159 *pu2BSSBasicRateSet
= RATE_SET_BIT_1M
;
3166 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3167 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_2M
;
3168 *pu2BSSBasicRateSet
= RATE_SET_BIT_2M
;
3174 case FIXED_RATE_5_5M
:
3175 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3176 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_5_5M
;
3177 *pu2BSSBasicRateSet
= RATE_SET_BIT_5_5M
;
3183 case FIXED_RATE_11M
:
3184 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HR_DSSS
;
3185 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_11M
;
3186 *pu2BSSBasicRateSet
= RATE_SET_BIT_11M
;
3193 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3194 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3195 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3196 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3199 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_6M
;
3200 *pu2BSSBasicRateSet
= RATE_SET_BIT_6M
;
3207 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3208 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3209 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3210 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3213 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_9M
;
3214 *pu2BSSBasicRateSet
= RATE_SET_BIT_9M
;
3220 case FIXED_RATE_12M
:
3221 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3222 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3223 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3224 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3227 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_12M
;
3228 *pu2BSSBasicRateSet
= RATE_SET_BIT_12M
;
3234 case FIXED_RATE_18M
:
3235 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3236 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3237 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3238 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3241 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_18M
;
3242 *pu2BSSBasicRateSet
= RATE_SET_BIT_18M
;
3248 case FIXED_RATE_24M
:
3249 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3250 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3251 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3252 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3255 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_24M
;
3256 *pu2BSSBasicRateSet
= RATE_SET_BIT_24M
;
3262 case FIXED_RATE_36M
:
3263 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3264 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3265 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3266 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3269 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_36M
;
3270 *pu2BSSBasicRateSet
= RATE_SET_BIT_36M
;
3276 case FIXED_RATE_48M
:
3277 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3278 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3279 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3280 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3283 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_48M
;
3284 *pu2BSSBasicRateSet
= RATE_SET_BIT_48M
;
3290 case FIXED_RATE_54M
:
3291 if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_ERP
) {
3292 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_ERP
;
3293 } else if ((*pucDesiredPhyTypeSet
) | PHY_TYPE_BIT_OFDM
) {
3294 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_OFDM
;
3297 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_54M
;
3298 *pu2BSSBasicRateSet
= RATE_SET_BIT_54M
;
3304 case FIXED_RATE_MCS0_20M_800NS
:
3305 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3306 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3307 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3308 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3310 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3311 | HT_CAP_INFO_SHORT_GI_20M
3312 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3315 case FIXED_RATE_MCS1_20M_800NS
:
3316 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3317 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3318 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3319 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3321 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3322 | HT_CAP_INFO_SHORT_GI_20M
3323 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3326 case FIXED_RATE_MCS2_20M_800NS
:
3327 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3328 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3329 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3330 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3332 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3333 | HT_CAP_INFO_SHORT_GI_20M
3334 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3337 case FIXED_RATE_MCS3_20M_800NS
:
3338 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3339 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3340 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3341 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3343 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3344 | HT_CAP_INFO_SHORT_GI_20M
3345 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3348 case FIXED_RATE_MCS4_20M_800NS
:
3349 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3350 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3351 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3352 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3354 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3355 | HT_CAP_INFO_SHORT_GI_20M
3356 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3359 case FIXED_RATE_MCS5_20M_800NS
:
3360 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3361 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3362 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3363 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3365 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3366 | HT_CAP_INFO_SHORT_GI_20M
3367 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3370 case FIXED_RATE_MCS6_20M_800NS
:
3371 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3372 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3373 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3374 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3376 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3377 | HT_CAP_INFO_SHORT_GI_20M
3378 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3381 case FIXED_RATE_MCS7_20M_800NS
:
3382 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3383 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3384 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3385 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3387 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3388 | HT_CAP_INFO_SHORT_GI_20M
3389 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3392 case FIXED_RATE_MCS0_20M_400NS
:
3393 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3394 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3395 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3396 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3398 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3399 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3400 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3403 case FIXED_RATE_MCS1_20M_400NS
:
3404 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3405 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3406 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3407 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3409 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3410 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3411 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3414 case FIXED_RATE_MCS2_20M_400NS
:
3415 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3416 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3417 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3418 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3420 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3421 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3422 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3425 case FIXED_RATE_MCS3_20M_400NS
:
3426 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3427 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3428 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3429 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3431 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3432 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3433 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3436 case FIXED_RATE_MCS4_20M_400NS
:
3437 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3438 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3439 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3440 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3442 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3443 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3444 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3447 case FIXED_RATE_MCS5_20M_400NS
:
3448 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3449 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3450 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3451 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3453 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3454 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3455 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3458 case FIXED_RATE_MCS6_20M_400NS
:
3459 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3460 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3461 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3462 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3464 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3465 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3466 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3469 case FIXED_RATE_MCS7_20M_400NS
:
3470 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3471 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3472 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3473 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3475 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3476 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3477 (*pu2HtCapInfo
) |= HT_CAP_INFO_SHORT_GI_20M
;
3480 case FIXED_RATE_MCS0_40M_800NS
:
3481 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3482 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3483 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3484 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3486 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3487 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3488 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3491 case FIXED_RATE_MCS1_40M_800NS
:
3492 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3493 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3494 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3495 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3497 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3498 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3499 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3502 case FIXED_RATE_MCS2_40M_800NS
:
3503 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3504 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3505 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3506 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3508 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3509 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3510 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3513 case FIXED_RATE_MCS3_40M_800NS
:
3514 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3515 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3516 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3517 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3519 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3520 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3521 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3524 case FIXED_RATE_MCS4_40M_800NS
:
3525 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3526 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3527 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3528 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3530 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3531 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3532 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3535 case FIXED_RATE_MCS5_40M_800NS
:
3536 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3537 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3538 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3539 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3541 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3542 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3543 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3546 case FIXED_RATE_MCS6_40M_800NS
:
3547 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3548 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3549 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3550 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3552 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3553 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3554 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3557 case FIXED_RATE_MCS7_40M_800NS
:
3558 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3559 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3560 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3561 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3563 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3564 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3565 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3568 case FIXED_RATE_MCS32_800NS
:
3569 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3570 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3571 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3572 *pucMcsSet
= HT_RATE_MCS32_INDEX
;
3574 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
3575 | HT_CAP_INFO_SHORT_GI_40M
| HT_CAP_INFO_HT_GF
);
3576 (*pu2HtCapInfo
) |= HT_CAP_INFO_SUP_CHNL_WIDTH
;
3579 case FIXED_RATE_MCS0_40M_400NS
:
3580 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3581 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3582 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3583 *pucMcsSet
= HT_RATE_MCS0_INDEX
;
3585 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3586 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3589 case FIXED_RATE_MCS1_40M_400NS
:
3590 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3591 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3592 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3593 *pucMcsSet
= HT_RATE_MCS1_INDEX
;
3595 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3596 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3599 case FIXED_RATE_MCS2_40M_400NS
:
3600 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3601 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3602 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3603 *pucMcsSet
= HT_RATE_MCS2_INDEX
;
3605 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3606 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3609 case FIXED_RATE_MCS3_40M_400NS
:
3610 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3611 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3612 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3613 *pucMcsSet
= HT_RATE_MCS3_INDEX
;
3615 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3616 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3619 case FIXED_RATE_MCS4_40M_400NS
:
3620 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3621 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3622 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3623 *pucMcsSet
= HT_RATE_MCS4_INDEX
;
3625 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3626 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3629 case FIXED_RATE_MCS5_40M_400NS
:
3630 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3631 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3632 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3633 *pucMcsSet
= HT_RATE_MCS5_INDEX
;
3635 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3636 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3639 case FIXED_RATE_MCS6_40M_400NS
:
3640 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3641 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3642 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3643 *pucMcsSet
= HT_RATE_MCS6_INDEX
;
3645 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3646 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3649 case FIXED_RATE_MCS7_40M_400NS
:
3650 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3651 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3652 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3653 *pucMcsSet
= HT_RATE_MCS7_INDEX
;
3655 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3656 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3659 case FIXED_RATE_MCS32_400NS
:
3660 *pucDesiredPhyTypeSet
= PHY_TYPE_BIT_HT
;
3661 *pu2DesiredNonHTRateSet
= RATE_SET_BIT_HT_PHY
;
3662 *pu2BSSBasicRateSet
= RATE_SET_BIT_HT_PHY
;
3663 *pucMcsSet
= HT_RATE_MCS32_INDEX
;
3665 (*pu2HtCapInfo
) &= ~(HT_CAP_INFO_SHORT_GI_20M
| HT_CAP_INFO_HT_GF
);
3666 (*pu2HtCapInfo
) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
| HT_CAP_INFO_SHORT_GI_40M
);
3673 return WLAN_STATUS_SUCCESS
;
3676 /*----------------------------------------------------------------------------*/
3678 * @brief This utility function is used to write the register
3680 * @param u4Address Register address
3681 * u4Value the value to be written
3683 * @retval WLAN_STATUS_SUCCESS
3684 * WLAN_STATUS_FAILURE
3686 /*----------------------------------------------------------------------------*/
3688 WLAN_STATUS
nicWriteMcr(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4Address
, IN UINT_32 u4Value
)
3690 CMD_ACCESS_REG rCmdAccessReg
;
3692 rCmdAccessReg
.u4Address
= u4Address
;
3693 rCmdAccessReg
.u4Data
= u4Value
;
3695 return wlanSendSetQueryCmd(prAdapter
,
3702 sizeof(CMD_ACCESS_REG
), (PUINT_8
) &rCmdAccessReg
, NULL
, 0);
3706 /*----------------------------------------------------------------------------*/
3708 * @brief This utility function is used to modify the auto rate parameters
3710 * @param u4ArSysParam0 see description below
3716 * @retval WLAN_STATUS_SUCCESS
3717 * WLAN_STATUS_FAILURE
3720 * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
3721 * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
3722 * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
3723 * ArSysParam0[8:15]-> HT rate clear mask
3724 * ArSysParam0[16:31]-> Legacy rate clear mask
3725 * ArSysParam1[0:7]-> Auto Rate check weighting window
3726 * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
3727 * ArSysParam1[16:23]-> Auto Rate v1 PerH
3728 * ArSysParam1[24:31]-> Auto Rate v1 PerL
3732 * Enable auto rate version 1
3734 * ArSysParam0 = 983041,
3735 * Enable auto rate version 1
3736 * Remove CCK 1M, 2M, 5.5M, 11M
3738 * ArSysParam0 = 786433
3739 * Enable auto rate version 1
3740 * Remove CCK 5.5M 11M
3742 /*----------------------------------------------------------------------------*/
3746 nicRlmArUpdateParms(IN P_ADAPTER_T prAdapter
,
3747 IN UINT_32 u4ArSysParam0
,
3748 IN UINT_32 u4ArSysParam1
, IN UINT_32 u4ArSysParam2
, IN UINT_32 u4ArSysParam3
)
3750 UINT_8 ucArVer
, ucAbwVer
, ucAgiVer
;
3751 UINT_16 u2HtClrMask
;
3752 UINT_16 u2LegacyClrMask
;
3753 UINT_8 ucArCheckWindow
;
3756 UINT_8 ucArPerForceRateDownPer
;
3758 ucArVer
= (UINT_8
) (u4ArSysParam0
& BITS(0, 3));
3759 ucAbwVer
= (UINT_8
) ((u4ArSysParam0
& BITS(4, 5)) >> 4);
3760 ucAgiVer
= (UINT_8
) ((u4ArSysParam0
& BITS(6, 7)) >> 6);
3761 u2HtClrMask
= (UINT_16
) ((u4ArSysParam0
& BITS(8, 15)) >> 8);
3762 u2LegacyClrMask
= (UINT_16
) ((u4ArSysParam0
& BITS(16, 31)) >> 16);
3765 ucArCheckWindow
= (UINT_8
) (u4ArSysParam1
& BITS(0, 7));
3766 ucArPerForceRateDownPer
= (UINT_8
) ((u4ArSysParam1
& BITS(8, 15) >> 8));
3767 ucArPerH
= (UINT_8
) ((u4ArSysParam1
& BITS(16, 23)) >> 16);
3768 ucArPerL
= (UINT_8
) ((u4ArSysParam1
& BITS(24, 31)) >> 24);
3771 ucArCheckWindow
= (UINT_8
) (u4ArSysParam1
& BITS(0, 7));
3772 ucArPerForceRateDownPer
= (UINT_8
) (((u4ArSysParam1
>> 8) & BITS(0, 7)));
3773 ucArPerH
= (UINT_8
) (((u4ArSysParam1
>> 16) & BITS(0, 7)));
3774 ucArPerL
= (UINT_8
) (((u4ArSysParam1
>> 24) & BITS(0, 7)));
3778 ("ArParam %u %u %u %u\n", u4ArSysParam0
, u4ArSysParam1
, u4ArSysParam2
,
3780 DBGLOG(INIT
, INFO
, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer
, ucAbwVer
, ucAgiVer
));
3781 DBGLOG(INIT
, INFO
, ("HtMask %x LegacyMask %x\n", u2HtClrMask
, u2LegacyClrMask
));
3783 ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow
,
3784 ucArPerForceRateDownPer
, ucArPerH
, ucArPerL
));
3786 #define SWCR_DATA_ADDR(MOD, ADDR) (0x90000000+(MOD<<8)+(ADDR))
3787 #define SWCR_DATA_CMD(CATE, WRITE, INDEX, OPT0, OPT1) ((CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 << 8) | OPT1)
3788 #define SWCR_DATA0 0x0
3789 #define SWCR_DATA1 0x4
3790 #define SWCR_DATA2 0x8
3791 #define SWCR_DATA3 0xC
3792 #define SWCR_DATA4 0x10
3793 #define SWCR_WRITE 1
3797 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
3798 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000) */
3800 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), 1);
3801 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3802 SWCR_DATA_CMD(0, SWCR_WRITE
, 5, 0, 0));
3804 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), 0);
3805 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3806 SWCR_DATA_CMD(0, SWCR_WRITE
, 5, 0, 0));
3809 /* ucArVer 0: none 1:PER 2:Rcpi */
3810 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArVer
);
3811 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3812 SWCR_DATA_CMD(0, SWCR_WRITE
, 7, 0, 0));
3814 /* Candidate rate Ht mask */
3815 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), u2HtClrMask
);
3816 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3817 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x1c, 0, 0));
3819 /* Candidate rate legacy mask */
3820 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), u2LegacyClrMask
);
3821 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3822 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x1d, 0, 0));
3825 if (ucArCheckWindow
!= 0) {
3826 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
3827 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArCheckWindow
);
3828 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3829 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x14, 0, 0));
3830 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArCheckWindow
);
3831 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3832 SWCR_DATA_CMD(0, SWCR_WRITE
, 0xc, 0, 0));
3835 if (ucArPerForceRateDownPer
!= 0) {
3836 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
),
3837 ucArPerForceRateDownPer
);
3838 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3839 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x18, 0, 0));
3841 if (ucArPerH
!= 0) {
3842 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArPerH
);
3843 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3844 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x1, 0, 0));
3846 if (ucArPerL
!= 0) {
3847 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1
), ucArPerL
);
3848 nicWriteMcr(prAdapter
, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0
),
3849 SWCR_DATA_CMD(0, SWCR_WRITE
, 0x2, 0, 0));
3855 return WLAN_STATUS_SUCCESS
;
3858 /*----------------------------------------------------------------------------*/
3860 * @brief This utility function is used to enable roaming
3862 * @param u4EnableRoaming
3865 * @retval WLAN_STATUS_SUCCESS
3866 * WLAN_STATUS_FAILURE
3869 * u4EnableRoaming -> Enable Romaing
3872 /*----------------------------------------------------------------------------*/
3873 WLAN_STATUS
nicRoamingUpdateParams(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4EnableRoaming
)
3875 P_CONNECTION_SETTINGS_T prConnSettings
;
3877 prConnSettings
= &(prAdapter
->rWifiVar
.rConnSettings
);
3878 prConnSettings
->fgIsEnableRoaming
= ((u4EnableRoaming
> 0) ? (TRUE
) : (FALSE
));
3880 return WLAN_STATUS_SUCCESS
;
3883 /*----------------------------------------------------------------------------*/
3885 * \brief dump firmware Assert message
3894 /*----------------------------------------------------------------------------*/
3895 VOID
nicPrintFirmwareAssertInfo(IN P_ADAPTER_T prAdapter
)
3897 UINT_32 u4MailBox0
, u4MailBox1
;
3899 UINT_8 aucAssertFile
[7];
3902 #if CFG_SDIO_INTR_ENHANCE
3903 u4MailBox0
= prAdapter
->prSDIOCtrl
->u4RcvMailbox0
;
3904 u4MailBox1
= prAdapter
->prSDIOCtrl
->u4RcvMailbox1
;
3906 nicGetMailbox(prAdapter
, 0, &u4MailBox0
);
3907 nicGetMailbox(prAdapter
, 1, &u4MailBox1
);
3910 line
= u4MailBox0
& 0x0000FFFF;
3912 u4MailBox0
= ((u4MailBox0
>> 16) & 0x0000FFFF);
3914 kalMemCopy(&aucAssertFile
[0], &u4MailBox0
, 2);
3915 kalMemCopy(&aucAssertFile
[2], &u4MailBox1
, 4);
3917 aucAssertFile
[6] = '\0';
3921 #elif defined(MT5931)
3923 #elif defined(MT6628)
3927 kalPrint("\n[MT%ld][wifi][Firmware] Assert at \"%s\" #%ld\n\n",
3928 u4ChipId
, aucAssertFile
, line
);
3933 /*----------------------------------------------------------------------------*/
3935 * @brief This function is called to update Link Quality information
3937 * @param prAdapter Pointer of Adapter Data Structure
3939 * prEventLinkQuality
3945 /*----------------------------------------------------------------------------*/
3947 nicUpdateLinkQuality(IN P_ADAPTER_T prAdapter
,
3948 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx
,
3949 IN P_EVENT_LINK_QUALITY prEventLinkQuality
)
3952 ASSERT(eNetTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
3953 ASSERT(prEventLinkQuality
);
3955 switch (eNetTypeIdx
) {
3956 case NETWORK_TYPE_AIS_INDEX
:
3957 if (prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIdx
].eConnectionState
==
3958 PARAM_MEDIA_STATE_CONNECTED
) {
3959 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
3960 /* buffer statistics for further query */
3961 if (prAdapter
->fgIsLinkQualityValid
== FALSE
3962 || (kalGetTimeTick() - prAdapter
->rLinkQualityUpdateTime
) >
3963 CFG_LINK_QUALITY_VALID_PERIOD
) {
3964 nicUpdateRSSI(prAdapter
, eNetTypeIdx
, prEventLinkQuality
->cRssi
,
3965 prEventLinkQuality
->cLinkQuality
);
3968 if (prAdapter
->fgIsLinkRateValid
== FALSE
3969 || (kalGetTimeTick() - prAdapter
->rLinkRateUpdateTime
) >
3970 CFG_LINK_QUALITY_VALID_PERIOD
) {
3971 nicUpdateLinkSpeed(prAdapter
, eNetTypeIdx
,
3972 prEventLinkQuality
->u2LinkSpeed
);
3976 #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
3977 case NETWORK_TYPE_P2P_INDEX
:
3978 if (prAdapter
->fgIsP2pLinkQualityValid
== FALSE
3979 || (kalGetTimeTick() - prAdapter
->rP2pLinkQualityUpdateTime
) >
3980 CFG_LINK_QUALITY_VALID_PERIOD
) {
3981 P_EVENT_LINK_QUALITY_EX prEventLQEx
=
3982 (P_EVENT_LINK_QUALITY_EX
) prEventLinkQuality
;
3984 nicUpdateRSSI(prAdapter
, NETWORK_TYPE_P2P_INDEX
, prEventLQEx
->cRssiP2P
,
3985 prEventLQEx
->cLinkQualityP2P
);
3998 /*----------------------------------------------------------------------------*/
4000 * @brief This function is called to update RSSI and Link Quality information
4002 * @param prAdapter Pointer of Adapter Data Structure
4009 /*----------------------------------------------------------------------------*/
4011 nicUpdateRSSI(IN P_ADAPTER_T prAdapter
,
4012 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx
, IN INT_8 cRssi
, IN INT_8 cLinkQuality
)
4015 ASSERT(eNetTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
4017 switch (eNetTypeIdx
) {
4018 case NETWORK_TYPE_AIS_INDEX
:
4019 if (prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIdx
].eConnectionState
==
4020 PARAM_MEDIA_STATE_CONNECTED
) {
4021 prAdapter
->fgIsLinkQualityValid
= TRUE
;
4022 prAdapter
->rLinkQualityUpdateTime
= kalGetTimeTick();
4024 prAdapter
->rLinkQuality
.cRssi
= cRssi
;
4025 prAdapter
->rLinkQuality
.cLinkQuality
= cLinkQuality
;
4027 /* indicate to glue layer */
4028 kalUpdateRSSI(prAdapter
->prGlueInfo
,
4029 KAL_NETWORK_TYPE_AIS_INDEX
,
4030 prAdapter
->rLinkQuality
.cRssi
,
4031 prAdapter
->rLinkQuality
.cLinkQuality
);
4035 #if CFG_ENABLE_WIFI_DIRECT
4036 #if CFG_SUPPORT_P2P_RSSI_QUERY
4037 case NETWORK_TYPE_P2P_INDEX
:
4038 prAdapter
->fgIsP2pLinkQualityValid
= TRUE
;
4039 prAdapter
->rP2pLinkQualityUpdateTime
= kalGetTimeTick();
4041 prAdapter
->rP2pLinkQuality
.cRssi
= cRssi
;
4042 prAdapter
->rP2pLinkQuality
.cLinkQuality
= cLinkQuality
;
4044 kalUpdateRSSI(prAdapter
->prGlueInfo
,
4045 KAL_NETWORK_TYPE_P2P_INDEX
, cRssi
, cLinkQuality
);
4058 /*----------------------------------------------------------------------------*/
4060 * @brief This function is called to update Link Quality information
4062 * @param prAdapter Pointer of Adapter Data Structure
4064 * prEventLinkQuality
4070 /*----------------------------------------------------------------------------*/
4072 nicUpdateLinkSpeed(IN P_ADAPTER_T prAdapter
,
4073 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx
, IN UINT_16 u2LinkSpeed
)
4076 ASSERT(eNetTypeIdx
< NETWORK_TYPE_INDEX_NUM
);
4078 switch (eNetTypeIdx
) {
4079 case NETWORK_TYPE_AIS_INDEX
:
4080 if (prAdapter
->rWifiVar
.arBssInfo
[eNetTypeIdx
].eConnectionState
==
4081 PARAM_MEDIA_STATE_CONNECTED
) {
4082 /* buffer statistics for further query */
4083 prAdapter
->fgIsLinkRateValid
= TRUE
;
4084 prAdapter
->rLinkRateUpdateTime
= kalGetTimeTick();
4086 prAdapter
->rLinkQuality
.u2LinkSpeed
= u2LinkSpeed
;
4098 #if CFG_SUPPORT_RDD_TEST_MODE
4099 WLAN_STATUS
nicUpdateRddTestMode(IN P_ADAPTER_T prAdapter
, IN P_CMD_RDD_CH_T prRddChParam
)
4101 DEBUGFUNC("nicUpdateRddTestMode.\n");
4105 /* aisFsmScanRequest(prAdapter, NULL); */
4107 return wlanSendSetQueryCmd(prAdapter
,
4113 NULL
, sizeof(CMD_RDD_CH_T
), (PUINT_8
) prRddChParam
, NULL
, 0);