import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6628 / wlan / nic / nic.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic.c#2 $
3 */
4
5 /*! \file nic.c
6 \brief Functions that provide operation in NIC's (Network Interface Card) point of view.
7
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.
11 */
12
13
14
15 /*
16 ** $Log: nic.c $
17 *
18 * 07 17 2012 yuche.tsai
19 * NULL
20 * Compile no error before trial run.
21 *
22 * 05 02 2012 terry.wu
23 * NULL
24 * Set the default value of AP StaRec index to "STA_REC_INDEX_NOT_FOUND" in update firmware bss command.
25 *
26 * 03 02 2012 terry.wu
27 * NULL
28 * Sync CFG80211 modification from branch 2,2.
29 *
30 * 11 28 2011 cp.wu
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
34 *
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.
38 *
39 * 11 19 2011 yuche.tsai
40 * NULL
41 * Update RSSI for P2P.
42 *
43 * 11 18 2011 yuche.tsai
44 * NULL
45 * CONFIG P2P support RSSI query, default turned off.
46 *
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.
50 *
51 * 11 04 2011 cp.wu
52 * [WCXRP00001079] [MT5931][Driver] Release pending MMPDU only when BSS is being deactivated
53 * pre-check for NULL before calling MMPDU free function
54 *
55 * 11 03 2011 wh.su
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
58 *
59 * 11 01 2011 chinglan.wang
60 * NULL
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..
63 *
64 * 10 11 2011 terry.wu
65 * NULL
66 * Rewrite Assert Dump Function for Portability.
67 *
68 * 09 20 2011 cm.chang
69 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
70 * New CMD definition about RLM parameters
71 *
72 * 08 15 2011 cp.wu
73 * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
74 * reuse firmware download logic of MT6620 for MT6628.
75 *
76 * 08 03 2011 terry.wu
77 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
78 * Reply Probe Rsp in FW for Hotspot Mode.
79 *
80 *
81 *
82 * 08 03 2011 terry.wu
83 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
84 * Reply Probe Rsp in FW for Hotspot Mode.
85 *
86 *
87 * 08 03 2011 terry.wu
88 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
89 * Reply Probe Rsp in FW for Hotspot Mode.
90 *
91 * 08 03 2011 terry.wu
92 * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
93 * Reply Probe Rsp in FW for Hotspot Mode.
94 *
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.
98 *
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.
102 *
103 * 07 11 2011 wh.su
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.
106 *
107 * 06 27 2011 cp.wu
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
109 * 1. correct logic
110 * 2. replace only BSS-DESC which doesn't have a valid SSID.
111 *
112 * 06 27 2011 cp.wu
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
115 *
116 * 05 12 2011 puff.wen
117 * NULL
118 * FW Assert information dump to driver
119 *
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.
123 *
124 * 04 15 2011 cp.wu
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.
127 *
128 * 04 14 2011 cm.chang
129 * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
130 * .
131 *
132 * 04 14 2011 cp.wu
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.
136 *
137 * 04 12 2011 cp.wu
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
140 *
141 * 04 12 2011 wh.su
142 * NULL
143 * enable the p2p check the cipher to set the bssInfo auth mode.
144 *
145 * 04 12 2011 wh.su
146 * NULL
147 * prepare the code for sync the auth mode and encryption status for P2P and BOW.
148 *
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.
152 *
153 * 04 10 2011 george.huang
154 * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
155 * Fix compiler issue.
156 *
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
160 *
161 * 04 08 2011 eddie.chen
162 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
163 * Fix for sigma
164 *
165 * 04 07 2011 cp.wu
166 * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside wlanAdapterStart
167 * .
168 *
169 * 04 07 2011 cp.wu
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.
172 *
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.
175 * .
176 *
177 * 03 21 2011 cp.wu
178 * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
179 * portability improvement
180 *
181 * 03 17 2011 cp.wu
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
184 *
185 * 03 16 2011 cp.wu
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
189 *
190 * The windows part remained the same as before, but added similiar APIs to hide the difference.
191 *
192 * 03 15 2011 cp.wu
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
196 *
197 *
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
201 *
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.
205 *
206 * 03 02 2011 cp.wu
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.
209 *
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.
213 *
214 * 02 01 2011 terry.wu
215 * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
216 * .
217 *
218 * 02 01 2011 cm.chang
219 * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
220 * .
221 *
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
225 *
226 * 01 27 2011 tsaiyuan.hsu
227 * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
228 * add roaming fsm
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.
233 *
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
237 *
238 * 01 24 2011 cp.wu
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
243 *
244 * 01 19 2011 cp.wu
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
247 *
248 * 01 04 2011 cp.wu
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
252 *
253 * 01 04 2011 cp.wu
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
256 *
257 * 12 30 2010 cp.wu
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
260 *
261 * 12 17 2010 cp.wu
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
264 *
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
269 *
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.
273 *
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
277 *
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.
281 *
282 * 11 08 2010 cp.wu
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
285 *
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.
289 *
290 * 10 18 2010 cp.wu
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
294 *
295 * 10 18 2010 cp.wu
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
298 *
299 * 10 12 2010 cp.wu
300 * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
301 * add HT (802.11n) fixed rate support.
302 *
303 * 10 08 2010 cp.wu
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)
306 *
307 * 10 07 2010 cp.wu
308 * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
309 * add firmware download for MT5931.
310 *
311 * 10 05 2010 cp.wu
312 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
313 * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
314 *
315 * 10 04 2010 cp.wu
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
318 *
319 * 09 21 2010 cp.wu
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
322 *
323 * 09 08 2010 cp.wu
324 * NULL
325 * use static memory pool for storing IEs of scanning result.
326 *
327 * 09 06 2010 cp.wu
328 * NULL
329 * Androi/Linux: return current operating channel information
330 *
331 * 09 01 2010 cp.wu
332 * NULL
333 * HIFSYS Clock Source Workaround
334 *
335 * 08 26 2010 yuche.tsai
336 * NULL
337 * Fix someones coding error while enable WIFI_DIRECT.
338 *
339 * 08 25 2010 george.huang
340 * NULL
341 * update OID/ registry control path for PM related settings
342 *
343 * 08 24 2010 cm.chang
344 * NULL
345 * Support RLM initail channel of Ad-hoc, P2P and BOW
346 *
347 * 08 24 2010 chinghwa.yu
348 * NULL
349 * Update BOW for the 1st time.
350 *
351 * 08 23 2010 chinghwa.yu
352 * NULL
353 * Update for BOW.
354 *
355 * 08 20 2010 yuche.tsai
356 * NULL
357 * Add state change indication.
358 *
359 * 08 16 2010 yuche.tsai
360 * NULL
361 * Add support for P2P BSS update info.
362 *
363 * 08 12 2010 cp.wu
364 * NULL
365 * [removing debugging] not to dump beacon content.
366 *
367 * 08 12 2010 cp.wu
368 * NULL
369 * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
370 *
371 * 08 11 2010 cp.wu
372 * NULL
373 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
374 * 2) extending scanning result to 64 instead of 48
375 *
376 * 08 04 2010 yarco.yang
377 * NULL
378 * Add TX_AMPDU and ADDBA_REJECT command
379 *
380 * 08 03 2010 cp.wu
381 * NULL
382 * surpress compilation warning.
383 *
384 * 08 03 2010 cp.wu
385 * NULL
386 * Centralize mgmt/system service procedures into independent calls.
387 *
388 * 07 28 2010 cp.wu
389 * NULL
390 * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
391 * 2) change nicMediaStateChange() API prototype
392 *
393 * 07 28 2010 cp.wu
394 * NULL
395 * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
396 *
397 * 07 24 2010 wh.su
398 *
399 * .support the Wi-Fi RSN
400 *
401 * 07 23 2010 cp.wu
402 *
403 * FIX: structure of CMD_SET_BSS_INFO has been changed but no follow-ups are done.
404 *
405 * 07 22 2010 george.huang
406 *
407 * .
408 *
409 * 07 22 2010 george.huang
410 *
411 * Update fgIsQoS information in BSS INFO by CMD
412 *
413 * 07 19 2010 cp.wu
414 *
415 * [WPD00003833] [MT6620 and MT5931] Driver migration.
416 * Add Ad-Hoc support to AIS-FSM
417 *
418 * 07 14 2010 yarco.yang
419 *
420 * 1. Remove CFG_MQM_MIGRATION
421 * 2. Add CMD_UPDATE_WMM_PARMS command
422 *
423 * 07 08 2010 cp.wu
424 *
425 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
426 *
427 * 07 07 2010 cp.wu
428 * [WPD00003833][MT6620 and MT5931] Driver migration
429 * update prStaRecOfAP with BSS-INFO.
430 *
431 * 07 06 2010 george.huang
432 * [WPD00001556]Basic power managemenet function
433 * Update arguments for nicUpdateBeaconIETemplate()
434 *
435 * 07 06 2010 cp.wu
436 * [WPD00003833][MT6620 and MT5931] Driver migration
437 * STA-REC is maintained by CNM only.
438 *
439 * 07 05 2010 cp.wu
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
444 *
445 * 07 01 2010 cm.chang
446 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
447 * Support sync command of STA_REC
448 *
449 * 06 30 2010 cp.wu
450 * [WPD00003833][MT6620 and MT5931] Driver migration
451 * sync. with CMD/EVENT document ver0.07.
452 *
453 * 06 29 2010 cp.wu
454 * [WPD00003833][MT6620 and MT5931] Driver migration
455 * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
456 *
457 * 06 29 2010 cp.wu
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
465 *
466 * 06 25 2010 george.huang
467 * [WPD00001556]Basic power managemenet function
468 * Create beacon update path, with expose bssUpdateBeaconContent()
469 *
470 * 06 22 2010 cp.wu
471 * [WPD00003833][MT6620 and MT5931] Driver migration
472 * fill fgIsUapsdConnection when indicating BSS-CREATE with AIS-STA mode.
473 *
474 * 06 22 2010 cp.wu
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.
479 *
480 * 06 21 2010 cp.wu
481 * [WPD00003833][MT6620 and MT5931] Driver migration
482 * implement TX_DONE callback path.
483 *
484 * 06 21 2010 wh.su
485 * [WPD00003840][MT6620 5931] Security migration
486 * remove duplicate variable for migration.
487 *
488 * 06 21 2010 cp.wu
489 * [WPD00003833][MT6620 and MT5931] Driver migration
490 * TX descriptors are now allocated once for reducing allocation overhead
491 *
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
495 *
496 * 06 11 2010 cp.wu
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
503 *
504 * 06 10 2010 cp.wu
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)
508 *
509 * 06 06 2010 kevin.huang
510 * [WPD00003832][MT6620 5931] Create driver base
511 * [MT6620 5931] Create driver base
512 *
513 * 04 26 2010 cp.wu
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
517 *
518 * 04 23 2010 cp.wu
519 * [WPD00001943]Create WiFi test driver framework on WinXP
520 * surpress compiler warning
521 *
522 * 04 13 2010 cp.wu
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
528 *
529 * 04 12 2010 cp.wu
530 * [WPD00001943]Create WiFi test driver framework on WinXP
531 * add channel frequency <-> number conversion
532 *
533 * 04 06 2010 cp.wu
534 * [WPD00001943]Create WiFi test driver framework on WinXP
535 * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
536 *
537 * 04 06 2010 cp.wu
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
540 *
541 * 03 19 2010 cp.wu
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
545 *
546 * 03 17 2010 cp.wu
547 * [WPD00001943]Create WiFi test driver framework on WinXP
548 * always process TX interrupt first then RX interrupt.
549 *
550 * 02 25 2010 cp.wu
551 * [WPD00001943]Create WiFi test driver framework on WinXP
552 * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
553 *
554 * 02 23 2010 cp.wu
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
564 ** code clean
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
573 ** prevent warning
574 ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:54:57 GMT mtk01084
575 ** init HIF
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
606 ** Init for develop
607 **
608 */
609
610 /*******************************************************************************
611 * C O M P I L E R F L A G S
612 ********************************************************************************
613 */
614
615 /*******************************************************************************
616 * E X T E R N A L R E F E R E N C E S
617 ********************************************************************************
618 */
619 #include "precomp.h"
620
621
622 /*******************************************************************************
623 * C O N S T A N T S
624 ********************************************************************************
625 */
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 */
636 };
637
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)
643
644 #define GATING_CONTROL_POLL_LIMIT 64
645 #endif
646
647 /*******************************************************************************
648 * D A T A T Y P E S
649 ********************************************************************************
650 */
651
652 /*******************************************************************************
653 * P U B L I C D A T A
654 ********************************************************************************
655 */
656
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}
662 };
663
664 static const UINT_8 ucIntEventMapSize = (sizeof(arIntEventMapTable) / sizeof(INT_EVENT_MAP_T));
665
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 */
671 };
672
673 /*******************************************************************************
674 * P R I V A T E D A T A
675 ********************************************************************************
676 */
677
678 /*******************************************************************************
679 * M A C R O S
680 ********************************************************************************
681 */
682 /*! This macro is used to reduce coding errors inside nicAllocateAdapterMemory()
683 * and also enhance the readability.
684 */
685 #define LOCAL_NIC_ALLOCATE_MEMORY(pucMem, u4Size, eMemType, pucComment) \
686 { \
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)); \
690 break; \
691 } \
692 ASSERT(((UINT_32)pucMem % 4) == 0); \
693 DBGLOG(INIT, INFO, ("Virtual Address = %08lx for %s.\n", (UINT_32)pucMem, pucComment)); \
694 }
695
696
697
698 /*******************************************************************************
699 * F U N C T I O N D E C L A R A T I O N S
700 ********************************************************************************
701 */
702
703 /*******************************************************************************
704 * F U N C T I O N S
705 ********************************************************************************
706 */
707
708
709 /*----------------------------------------------------------------------------*/
710 /*!
711 * @brief This routine is responsible for the allocation of the data structures
712 * inside the Adapter structure, include:
713 * 1. SW_RFB_Ts
714 * 2. Common coalescing buffer for TX PATH.
715 *
716 * @param prAdapter Pointer of Adapter Data Structure
717 *
718 * @retval WLAN_STATUS_SUCCESS - Has enough memory.
719 * @retval WLAN_STATUS_RESOURCES - Memory is not enough.
720 */
721 /*----------------------------------------------------------------------------*/
722 WLAN_STATUS nicAllocateAdapterMemory(IN P_ADAPTER_T prAdapter)
723 {
724 WLAN_STATUS status = WLAN_STATUS_RESOURCES;
725 P_RX_CTRL_T prRxCtrl;
726 P_TX_CTRL_T prTxCtrl;
727
728 DEBUGFUNC("nicAllocateAdapterMemory");
729
730 ASSERT(prAdapter);
731 prRxCtrl = &prAdapter->rRxCtrl;
732 prTxCtrl = &prAdapter->rTxCtrl;
733
734 do {
735 /* 4 <0> Reset all Memory Handler */
736 #if CFG_DBG_MGT_BUF
737 prAdapter->u4MemFreeDynamicCount = 0;
738 prAdapter->u4MemAllocDynamicCount = 0;
739 #endif
740 prAdapter->pucMgtBufCached = (PUINT_8) NULL;
741 prRxCtrl->pucRxCached = (PUINT_8) NULL;
742 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T) NULL;
743
744
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;
748
749 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter->pucMgtBufCached,
750 prAdapter->u4MgtBufCachedSize,
751 VIR_MEM_TYPE, "COMMON MGMT MEMORY POOL");
752
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.
757 */
758 /* Allocate memory for the SW receive structures. */
759 prRxCtrl->u4RxCachedSize = CFG_RX_MAX_PKT_NUM * ALIGN_4(sizeof(SW_RFB_T));
760
761 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl->pucRxCached,
762 prRxCtrl->u4RxCachedSize, VIR_MEM_TYPE, "SW_RFB_T");
763
764 /* 4 <3> Memory for TX DEscriptor */
765 prTxCtrl->u4TxCachedSize = CFG_TX_MAX_PKT_NUM * ALIGN_4(sizeof(MSDU_INFO_T));
766
767 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl->pucTxCached,
768 prTxCtrl->u4TxCachedSize, VIR_MEM_TYPE, "MSDU_INFO_T");
769
770 /* 4 <4> Memory for Common Coalescing Buffer */
771 #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
772 prAdapter->pucCoalescingBufCached = (PUINT_8) NULL;
773
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;
779
780 prAdapter->pucCoalescingBufCached =
781 kalAllocateIOBuffer(prAdapter->u4CoalescingBufCachedSize);
782
783 if (prAdapter->pucCoalescingBufCached == NULL) {
784 DBGLOG(INIT, ERROR,
785 ("Could not allocate %ld bytes for coalescing buffer.\n",
786 prAdapter->u4CoalescingBufCachedSize));
787 break;
788 }
789 #endif /* CFG_COALESCING_BUFFER_SIZE */
790
791 /* 4 <5> Memory for enhanced interrupt response */
792 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
793 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
794
795 if (prAdapter->prSDIOCtrl == NULL) {
796 DBGLOG(INIT, ERROR,
797 ("Could not allocate %u bytes for interrupt response.\n",
798 sizeof(ENHANCE_MODE_DATA_STRUCT_T)));
799 break;
800 }
801
802 status = WLAN_STATUS_SUCCESS;
803
804 }
805 while (FALSE);
806
807 if (status != WLAN_STATUS_SUCCESS) {
808 nicReleaseAdapterMemory(prAdapter);
809 }
810
811 return status;
812
813 } /* end of nicAllocateAdapterMemory() */
814
815
816 /*----------------------------------------------------------------------------*/
817 /*!
818 * @brief This routine is responsible for releasing the allocated memory by
819 * nicAllocatedAdapterMemory().
820 *
821 * @param prAdapter Pointer of Adapter Data Structure
822 *
823 * @return (none)
824 */
825 /*----------------------------------------------------------------------------*/
826 VOID nicReleaseAdapterMemory(IN P_ADAPTER_T prAdapter)
827 {
828 P_TX_CTRL_T prTxCtrl;
829 P_RX_CTRL_T prRxCtrl;
830
831 ASSERT(prAdapter);
832 prTxCtrl = &prAdapter->rTxCtrl;
833 prRxCtrl = &prAdapter->rRxCtrl;
834
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;
840 }
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;
847 }
848 #endif /* CFG_COALESCING_BUFFER_SIZE */
849
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;
854 }
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;
859 }
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;
865 }
866 #if CFG_DBG_MGT_BUF
867 /* Check if all allocated memories are free */
868 ASSERT(prAdapter->u4MemFreeDynamicCount == prAdapter->u4MemAllocDynamicCount);
869 #endif
870
871 return;
872 }
873
874
875 /*----------------------------------------------------------------------------*/
876 /*!
877 * @brief disable global interrupt
878 *
879 * @param prAdapter pointer to the Adapter handler
880 *
881 * @return (none)
882 */
883 /*----------------------------------------------------------------------------*/
884 VOID nicDisableInterrupt(IN P_ADAPTER_T prAdapter)
885 {
886 ASSERT(prAdapter);
887
888 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_CLR);
889
890 prAdapter->fgIsIntEnable = FALSE;
891 }
892
893 /*----------------------------------------------------------------------------*/
894 /*!
895 * @brief enable global interrupt
896 *
897 * @param prAdapter pointer to the Adapter handler
898 *
899 * @return (none)
900 */
901 /*----------------------------------------------------------------------------*/
902 VOID nicEnableInterrupt(IN P_ADAPTER_T prAdapter)
903 {
904 BOOLEAN fgIsIntEnableCache;
905
906
907 ASSERT(prAdapter);
908 fgIsIntEnableCache = prAdapter->fgIsIntEnable;
909
910 prAdapter->fgIsIntEnable = TRUE; /* NOTE(Kevin): It must be placed before MCR GINT write. */
911
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.
916 */
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;
921 }
922 /* If INT was not enabled, enable it and also set LPOwn now */
923 else {
924 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET |
925 WHLPCR_INT_EN_SET);
926 prAdapter->fgIsFwOwn = TRUE;
927 }
928 }
929 /* If INT was not enabled, enable it now */
930 else if (!fgIsIntEnableCache) {
931 HAL_BYTE_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_SET);
932 }
933
934 return;
935 } /* end of nicEnableInterrupt() */
936
937
938 #if CFG_SDIO_INTR_ENHANCE
939 /*----------------------------------------------------------------------------*/
940 /*!
941 * @brief For SDIO enhance mode, set the max rx len and tx status
942 *
943 * @param prAdapter a pointer to adapter private data structure.
944 *
945 * @return - none
946 */
947 /*----------------------------------------------------------------------------*/
948 VOID nicSDIOInit(IN P_ADAPTER_T prAdapter)
949 {
950 UINT_32 u4Value = 0;
951
952 ASSERT(prAdapter);
953
954 /* 4 <1> Check STATUS Buffer is DW alignment. */
955 ASSERT(IS_ALIGN_4((UINT_32) &prAdapter->prSDIOCtrl->u4WHISR));
956
957 /* 4 <2> Setup STATUS count. */
958 {
959 HAL_MCR_RD(prAdapter, MCR_WHCR, &u4Value);
960
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));
964
965 /* 4 <2.2> Setup RX enhancement mode */
966 #if CFG_SDIO_RX_ENHANCE
967 u4Value |= WHCR_RX_ENHANCE_MODE_EN;
968 #else
969 u4Value &= ~WHCR_RX_ENHANCE_MODE_EN;
970 #endif /* CFG_SDIO_RX_AGG */
971
972 HAL_MCR_WR(prAdapter, MCR_WHCR, u4Value);
973 }
974
975 return;
976
977 } /* end of nicSDIOInit() */
978
979 /*----------------------------------------------------------------------------*/
980 /*!
981 * @brief Read interrupt status from hardware
982 *
983 * @param prAdapter pointer to the Adapter handler
984 * @param the interrupts
985 *
986 * @return N/A
987 *
988 */
989 /*----------------------------------------------------------------------------*/
990 VOID nicSDIOReadIntStatus(IN P_ADAPTER_T prAdapter, OUT PUINT_32 pu4IntStatus)
991 {
992 P_SDIO_CTRL_T prSDIOCtrl;
993
994 DEBUGFUNC("nicSDIOReadIntStatus");
995
996 ASSERT(prAdapter);
997 ASSERT(pu4IntStatus);
998
999 prSDIOCtrl = prAdapter->prSDIOCtrl;
1000 ASSERT(prSDIOCtrl);
1001
1002 HAL_PORT_RD(prAdapter,
1003 MCR_WHISR,
1004 sizeof(ENHANCE_MODE_DATA_STRUCT_T),
1005 (PUINT_8) prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
1006
1007 if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
1008 *pu4IntStatus = 0;
1009 return;
1010 }
1011
1012 /* workaround */
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;
1016 }
1017
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);
1022 }
1023
1024 *pu4IntStatus = prSDIOCtrl->u4WHISR;
1025
1026 return;
1027 } /* end of nicSDIOReadIntStatus() */
1028 #endif
1029
1030 /*----------------------------------------------------------------------------*/
1031 /*!
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
1035 *
1036 * @param prAdapter pointer to the Adapter handler
1037 *
1038 * @retval WLAN_STATUS_SUCCESS
1039 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1040 */
1041 /*----------------------------------------------------------------------------*/
1042 WLAN_STATUS nicProcessIST(IN P_ADAPTER_T prAdapter)
1043 {
1044 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1045 UINT_32 u4IntStatus = 0;
1046 UINT_32 i;
1047
1048 DEBUGFUNC("nicProcessIST");
1049 /* DBGLOG(INIT, LOUD, ("\n")); */
1050
1051 ASSERT(prAdapter);
1052
1053 if (prAdapter->rAcpiState == ACPI_STATE_D3) {
1054 DBGLOG(REQ, WARN,
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;
1058 }
1059 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1060 if (prAdapter->fgIsClockGatingEnabled == TRUE) {
1061 nicDisableClockGating(prAdapter);
1062 }
1063 #endif
1064
1065 for (i = 0; i < CFG_IST_LOOP_COUNT; i++) {
1066
1067 #if CFG_SDIO_INTR_ENHANCE
1068 nicSDIOReadIntStatus(prAdapter, &u4IntStatus);
1069 #else
1070 HAL_MCR_RD(prAdapter, MCR_WHISR, &u4IntStatus);
1071 #endif /* CFG_SDIO_INTR_ENHANCE */
1072
1073 /* DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus)); */
1074
1075 if (u4IntStatus & ~(WHIER_DEFAULT | WHIER_FW_OWN_BACK_INT_EN)) {
1076 DBGLOG(INTR, WARN, ("Un-handled HISR %#lx, HISR = %#lx (HIER:0x%lx)\n",
1077 (u4IntStatus & ~WHIER_DEFAULT), u4IntStatus,
1078 WHIER_DEFAULT));
1079 u4IntStatus &= WHIER_DEFAULT;
1080 }
1081
1082 nicProcessIST_impl(prAdapter, u4IntStatus);
1083
1084 if (u4IntStatus == 0) {
1085 if (i == 0) {
1086 u4Status = WLAN_STATUS_NOT_INDICATING;
1087 }
1088 break;
1089 }
1090 }
1091
1092 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1093 if (prAdapter->fgIsClockGatingEnabled == FALSE) {
1094 nicEnableClockGating(prAdapter);
1095 }
1096 #endif
1097
1098 return u4Status;
1099 } /* end of nicProcessIST() */
1100
1101
1102 /*----------------------------------------------------------------------------*/
1103 /*!
1104 * @brief The function used to dispatch the appropriate functions for specific
1105 * interrupt bits
1106 *
1107 * @param prAdapter pointer to the Adapter handler
1108 * u4IntStatus interrupt status bits
1109 *
1110 * @retval WLAN_STATUS_SUCCESS
1111 * @retval WLAN_STATUS_ADAPTER_NOT_READY
1112 */
1113 /*----------------------------------------------------------------------------*/
1114 WLAN_STATUS nicProcessIST_impl(IN P_ADAPTER_T prAdapter, IN UINT_32 u4IntStatus)
1115 {
1116 UINT_32 u4IntCount = 0;
1117 P_INT_EVENT_MAP_T prIntEventMap = NULL;
1118
1119 ASSERT(prAdapter);
1120
1121 prAdapter->u4IntStatus = u4IntStatus;
1122
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) {
1129 /* ignore */
1130 } else if (apfnEventFuncTable[prIntEventMap->u4Event] != NULL) {
1131 apfnEventFuncTable[prIntEventMap->u4Event] (prAdapter);
1132 } else {
1133 DBGLOG(INTR, WARN,
1134 ("Empty INTR handler! ISAR bit#: %lu, event:%lu, func: %p\n",
1135 prIntEventMap->u4Int, prIntEventMap->u4Event,
1136 apfnEventFuncTable[prIntEventMap->u4Event]));
1137
1138 ASSERT(0); /* to trap any NULL interrupt handler */
1139 }
1140 prAdapter->u4IntStatus &= ~prIntEventMap->u4Int;
1141 }
1142 }
1143
1144 return WLAN_STATUS_SUCCESS;
1145 } /* end of nicProcessIST_impl() */
1146
1147
1148 /*----------------------------------------------------------------------------*/
1149 /*!
1150 * @brief Verify the CHIP ID
1151 *
1152 * @param prAdapter a pointer to adapter private data structure.
1153 *
1154 *
1155 * @retval TRUE CHIP ID is the same as the setting compiled
1156 * @retval FALSE CHIP ID is different from the setting compiled
1157 */
1158 /*----------------------------------------------------------------------------*/
1159 BOOL nicVerifyChipID(IN P_ADAPTER_T prAdapter)
1160 {
1161 UINT_32 u4CIR = 0;
1162
1163 ASSERT(prAdapter);
1164
1165 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4CIR);
1166
1167 DBGLOG(INIT, TRACE, ("Chip ID: 0x%lx\n", u4CIR & WCIR_CHIP_ID));
1168 DBGLOG(INIT, TRACE, ("Revision ID: 0x%lx\n", ((u4CIR & WCIR_REVISION_ID) >> 16)));
1169
1170 if ((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV) {
1171 return FALSE;
1172 }
1173
1174 prAdapter->ucRevID = (UINT_8) (((u4CIR & WCIR_REVISION_ID) >> 16) & 0xF);
1175
1176 return TRUE;
1177 }
1178
1179 /*----------------------------------------------------------------------------*/
1180 /*!
1181 * @brief Initialize the MCR to the appropriate init value, and verify the init
1182 * value
1183 *
1184 * @param prAdapter a pointer to adapter private data structure.
1185 *
1186 * @return -
1187 */
1188 /*----------------------------------------------------------------------------*/
1189 VOID nicMCRInit(IN P_ADAPTER_T prAdapter)
1190 {
1191
1192 ASSERT(prAdapter);
1193
1194 /* 4 <0> Initial value */
1195 }
1196
1197 VOID nicHifInit(IN P_ADAPTER_T prAdapter)
1198 {
1199
1200 ASSERT(prAdapter);
1201 #if 0
1202 /* reset event */
1203 nicPutMailbox(prAdapter, 0, 0x52455345); /* RESE */
1204 nicPutMailbox(prAdapter, 1, 0x545F5746); /* T_WF */
1205 nicSetSwIntr(prAdapter, BIT(16));
1206 #endif
1207 }
1208
1209
1210 /*----------------------------------------------------------------------------*/
1211 /*!
1212 * @brief Initialize the Adapter soft variable
1213 *
1214 * @param prAdapter pointer to the Adapter handler
1215 *
1216 * @return (none)
1217 *
1218 */
1219 /*----------------------------------------------------------------------------*/
1220 WLAN_STATUS nicInitializeAdapter(IN P_ADAPTER_T prAdapter)
1221 {
1222 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1223
1224 ASSERT(prAdapter);
1225
1226 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE;
1227
1228 do {
1229 if (!nicVerifyChipID(prAdapter)) {
1230 u4Status = WLAN_STATUS_FAILURE;
1231 break;
1232 }
1233 /* 4 <1> MCR init */
1234 nicMCRInit(prAdapter);
1235
1236 #if CFG_SDIO_INTR_ENHANCE
1237 nicSDIOInit(prAdapter);
1238 #endif /* CFG_SDIO_INTR_ENHANCE */
1239
1240 HAL_MCR_WR(prAdapter, MCR_WHIER, WHIER_DEFAULT);
1241
1242
1243 /* 4 <2> init FW HIF */
1244 nicHifInit(prAdapter);
1245 }
1246 while (FALSE);
1247
1248
1249 return u4Status;
1250 }
1251
1252
1253 #if defined(_HIF_SPI)
1254 /*----------------------------------------------------------------------------*/
1255 /*!
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
1259 *
1260 * \param[in] prAdapter a pointer to adapter private data structure.
1261 * \param[in] eGPIO2_Mode GPIO2 operation mode
1262 *
1263 * \return (none)
1264 */
1265 /*----------------------------------------------------------------------------*/
1266 void nicRestoreSpiDefMode(IN P_ADAPTER_T prAdapter)
1267 {
1268 ASSERT(prAdapter);
1269
1270 HAL_MCR_WR(prAdapter, MCR_WCSR, SPICSR_8BIT_MODE_DATA);
1271
1272 }
1273 #endif
1274
1275 /*----------------------------------------------------------------------------*/
1276 /*!
1277 * @brief Process rx interrupt. When the rx
1278 * Interrupt is asserted, it means there are frames in queue.
1279 *
1280 * @param prAdapter Pointer to the Adapter structure.
1281 *
1282 * @return (none)
1283 */
1284 /*----------------------------------------------------------------------------*/
1285 VOID nicProcessAbnormalInterrupt(IN P_ADAPTER_T prAdapter)
1286 {
1287 UINT_32 u4Value;
1288
1289 HAL_MCR_RD(prAdapter, MCR_WASR, &u4Value);
1290 DBGLOG(REQ, WARN, ("MCR_WASR: 0x%lx\n", u4Value));
1291 }
1292
1293 /*----------------------------------------------------------------------------*/
1294 /*!
1295 * @brief .
1296 *
1297 * @param prAdapter Pointer to the Adapter structure.
1298 *
1299 * @return (none)
1300 */
1301 /*----------------------------------------------------------------------------*/
1302 VOID nicProcessFwOwnBackInterrupt(IN P_ADAPTER_T prAdapter)
1303 {
1304
1305 return;
1306 } /* end of nicProcessFwOwnBackInterrupt() */
1307
1308 /*----------------------------------------------------------------------------*/
1309 /*!
1310 * @brief .
1311 *
1312 * @param prAdapter Pointer to the Adapter structure.
1313 *
1314 * @return (none)
1315 */
1316 /*----------------------------------------------------------------------------*/
1317 VOID nicProcessSoftwareInterrupt(IN P_ADAPTER_T prAdapter)
1318 {
1319 UINT_32 u4IntrBits;
1320
1321 ASSERT(prAdapter);
1322
1323 u4IntrBits = prAdapter->u4IntStatus & BITS(8, 31);
1324
1325 if ((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
1326 nicPrintFirmwareAssertInfo(prAdapter);
1327 #if CFG_CHIP_RESET_SUPPORT
1328 glSendResetRequest();
1329 #endif
1330 }
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));
1334
1335 if (u4IntrBits & ACK_GATING_ENABLE_D2H_INT) {
1336 prAdapter->fgIsClockGatingEnabled = TRUE;
1337 }
1338
1339 if (u4IntrBits & ACK_GATING_DISABLE_D2H_INT) {
1340 prAdapter->fgIsClockGatingEnabled = FALSE;
1341
1342 /* Indicate Service Thread for TX */
1343 if (kalGetTxPendingCmdCount(prAdapter->prGlueInfo) > 0
1344 || wlanGetTxPendingFrameCount(prAdapter) > 0) {
1345 kalSetEvent(prAdapter->prGlueInfo);
1346 }
1347 }
1348 #endif
1349
1350 DBGLOG(REQ, WARN, ("u4IntrBits: 0x%lx\n", u4IntrBits));
1351
1352 return;
1353 } /* end of nicProcessSoftwareInterrupt() */
1354
1355 VOID nicPutMailbox(IN P_ADAPTER_T prAdapter, IN UINT_32 u4MailboxNum, IN UINT_32 u4Data)
1356 {
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);
1361 } else {
1362 ASSERT(0);
1363 }
1364 }
1365
1366 VOID nicGetMailbox(IN P_ADAPTER_T prAdapter, IN UINT_32 u4MailboxNum, OUT PUINT_32 pu4Data)
1367 {
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);
1372 } else {
1373 ASSERT(0);
1374 }
1375 }
1376
1377 VOID nicSetSwIntr(IN P_ADAPTER_T prAdapter, IN UINT_32 u4SwIntrBitmap)
1378 {
1379 /* NOTE:
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
1382 */
1383 ASSERT((u4SwIntrBitmap & BITS(0, 15)) == 0);
1384 /* DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap)); */
1385
1386 HAL_MCR_WR(prAdapter, MCR_WSICR, u4SwIntrBitmap);
1387 }
1388
1389
1390 /*----------------------------------------------------------------------------*/
1391 /*!
1392 * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1393 * with specified sequential number
1394 *
1395 * @param prAdapter Pointer of ADAPTER_T
1396 * ucSeqNum Sequential Number
1397 *
1398 * @retval - P_CMD_INFO_T
1399 */
1400 /*----------------------------------------------------------------------------*/
1401 P_CMD_INFO_T nicGetPendingCmdInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum)
1402 {
1403 P_QUE_T prCmdQue;
1404 QUE_T rTempCmdQue;
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;
1408
1409 GLUE_SPIN_LOCK_DECLARATION();
1410
1411 ASSERT(prAdapter);
1412
1413 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1414
1415 prCmdQue = &prAdapter->rPendingCmdQueue;
1416 QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
1417
1418 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1419 while (prQueueEntry) {
1420 prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
1421
1422 if (prCmdInfo->ucCmdSeqNum == ucSeqNum)
1423 break;
1424 else {
1425 QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
1426
1427 prCmdInfo = NULL;
1428 }
1429
1430 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1431 }
1432 QUEUE_CONCATENATE_QUEUES(prCmdQue, prTempCmdQue);
1433
1434 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1435
1436 return prCmdInfo;
1437 }
1438
1439
1440 /*----------------------------------------------------------------------------*/
1441 /*!
1442 * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1443 * with specified sequential number
1444 *
1445 * @param prAdapter Pointer of ADAPTER_T
1446 * ucSeqNum Sequential Number
1447 *
1448 * @retval - P_MSDU_INFO_T
1449 */
1450 /*----------------------------------------------------------------------------*/
1451 P_MSDU_INFO_T nicGetPendingTxMsduInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum)
1452 {
1453 P_QUE_T prTxingQue;
1454 QUE_T rTempQue;
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;
1458
1459 GLUE_SPIN_LOCK_DECLARATION();
1460
1461 ASSERT(prAdapter);
1462
1463 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1464
1465 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1466 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1467
1468 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1469 while (prQueueEntry) {
1470 prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
1471
1472 if (prMsduInfo->ucTxSeqNum == ucSeqNum)
1473 break;
1474 else {
1475 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1476
1477 prMsduInfo = NULL;
1478 }
1479
1480 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1481 }
1482 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1483
1484 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1485
1486 return prMsduInfo;
1487 }
1488
1489 P_MSDU_INFO_T nicGetPendingStaMMPDU(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx)
1490 {
1491 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T) NULL;
1492 P_QUE_T prTxingQue = (P_QUE_T) NULL;
1493 QUE_T rTempQue;
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;
1497
1498 GLUE_SPIN_LOCK_DECLARATION();
1499
1500 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1501 do {
1502 if (prAdapter == NULL) {
1503
1504 ASSERT(FALSE);
1505 break;
1506 }
1507
1508 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1509 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1510
1511 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1512 while (prQueueEntry) {
1513 prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
1514
1515 if ((prMsduInfo->ucStaRecIndex == ucStaRecIdx)
1516 && (prMsduInfo->pfTxDoneHandler != NULL)) {
1517 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo, prMsduInfoListHead);
1518 prMsduInfoListHead = prMsduInfo;
1519 } else {
1520 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1521
1522 prMsduInfo = NULL;
1523 }
1524
1525
1526 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1527 }
1528
1529 } while (FALSE);
1530 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1531
1532
1533 return prMsduInfoListHead;
1534 } /* nicGetPendingStaMMPDU */
1535
1536
1537 VOID
1538 nicFreePendingTxMsduInfoByNetwork(IN P_ADAPTER_T prAdapter,
1539 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType)
1540 {
1541 P_QUE_T prTxingQue;
1542 QUE_T rTempQue;
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;
1548
1549 GLUE_SPIN_LOCK_DECLARATION();
1550
1551 ASSERT(prAdapter);
1552
1553 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1554
1555 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1556 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1557
1558 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1559 while (prQueueEntry) {
1560 prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
1561
1562 if ((ENUM_NETWORK_TYPE_INDEX_T) (prMsduInfo->ucNetworkType) == eNetworkType) {
1563 if (prMsduInfoListHead == NULL) {
1564 prMsduInfoListHead = prMsduInfoListTail = prMsduInfo;
1565 } else {
1566 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail, prMsduInfo);
1567 prMsduInfoListTail = prMsduInfo;
1568 }
1569 } else {
1570 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1571
1572 prMsduInfo = NULL;
1573 }
1574
1575 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1576 }
1577 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1578
1579 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1580
1581 /* free */
1582 if (prMsduInfoListHead) {
1583 nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
1584 }
1585
1586 return;
1587
1588 } /* end of nicFreePendingTxMsduInfoByNetwork() */
1589
1590
1591
1592 /*----------------------------------------------------------------------------*/
1593 /*!
1594 * @brief This procedure is used to retrieve a CMD sequence number atomically
1595 *
1596 * @param prAdapter Pointer of ADAPTER_T
1597 *
1598 * @retval - UINT_8
1599 */
1600 /*----------------------------------------------------------------------------*/
1601 UINT_8 nicIncreaseCmdSeqNum(IN P_ADAPTER_T prAdapter)
1602 {
1603 UINT_8 ucRetval;
1604
1605 KAL_SPIN_LOCK_DECLARATION();
1606
1607 ASSERT(prAdapter);
1608
1609 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1610
1611 prAdapter->ucCmdSeqNum++;
1612 ucRetval = prAdapter->ucCmdSeqNum;
1613
1614 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1615
1616 return ucRetval;
1617 }
1618
1619
1620 /*----------------------------------------------------------------------------*/
1621 /*!
1622 * @brief This procedure is used to retrieve a TX sequence number atomically
1623 *
1624 * @param prAdapter Pointer of ADAPTER_T
1625 *
1626 * @retval - UINT_8
1627 */
1628 /*----------------------------------------------------------------------------*/
1629 UINT_8 nicIncreaseTxSeqNum(IN P_ADAPTER_T prAdapter)
1630 {
1631 UINT_8 ucRetval;
1632
1633 KAL_SPIN_LOCK_DECLARATION();
1634
1635 ASSERT(prAdapter);
1636
1637 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1638
1639 prAdapter->ucTxSeqNum++;
1640 ucRetval = prAdapter->ucTxSeqNum;
1641
1642 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1643
1644 return ucRetval;
1645 }
1646
1647
1648
1649 /*----------------------------------------------------------------------------*/
1650 /*!
1651 * @brief This utility function is used to handle
1652 * media state change event
1653 *
1654 * @param
1655 *
1656 * @retval
1657 */
1658 /*----------------------------------------------------------------------------*/
1659 WLAN_STATUS
1660 nicMediaStateChange(IN P_ADAPTER_T prAdapter,
1661 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType,
1662 IN P_EVENT_CONNECTION_STATUS prConnectionStatus)
1663 {
1664 P_GLUE_INFO_T prGlueInfo;
1665
1666 ASSERT(prAdapter);
1667 prGlueInfo = prAdapter->prGlueInfo;
1668
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) {
1673
1674 kalIndicateStatusAndComplete(prGlueInfo,
1675 WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
1676
1677 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1678 }
1679
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();
1685
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;
1705
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);
1710 } else {
1711 /* connected -> connected : roaming ? */
1712 kalIndicateStatusAndComplete(prGlueInfo,
1713 WLAN_STATUS_ROAM_OUT_FIND_BEST,
1714 NULL, 0);
1715 }
1716 }
1717 break;
1718
1719 #if CFG_ENABLE_BT_OVER_WIFI
1720 case NETWORK_TYPE_BOW_INDEX:
1721 break;
1722 #endif
1723
1724 #if CFG_ENABLE_WIFI_DIRECT
1725 case NETWORK_TYPE_P2P_INDEX:
1726 break;
1727 #endif
1728 default:
1729 ASSERT(0);
1730 }
1731
1732 return WLAN_STATUS_SUCCESS;
1733 } /* nicMediaStateChange */
1734
1735 /*----------------------------------------------------------------------------*/
1736 /*!
1737 * @brief This utility function is used to convert between
1738 * frequency and channel number
1739 *
1740 * @param u4ChannelNum
1741 *
1742 * @retval - Frequency in unit of KHz, 0 for invalid channel number
1743 */
1744 /*----------------------------------------------------------------------------*/
1745 UINT_32 nicChannelNum2Freq(UINT_32 u4ChannelNum)
1746 {
1747 UINT_32 u4ChannelInMHz;
1748
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;
1761 } else {
1762 u4ChannelInMHz = 0;
1763 }
1764
1765 return 1000 * u4ChannelInMHz;
1766 }
1767
1768
1769 /*----------------------------------------------------------------------------*/
1770 /*!
1771 * @brief This utility function is used to convert between
1772 * frequency and channel number
1773 *
1774 * @param u4FreqInKHz
1775 *
1776 * @retval - Frequency Number, 0 for invalid freqency
1777 */
1778 /*----------------------------------------------------------------------------*/
1779 UINT_32 nicFreq2ChannelNum(UINT_32 u4FreqInKHz)
1780 {
1781 switch (u4FreqInKHz) {
1782 case 2412000:
1783 return 1;
1784 case 2417000:
1785 return 2;
1786 case 2422000:
1787 return 3;
1788 case 2427000:
1789 return 4;
1790 case 2432000:
1791 return 5;
1792 case 2437000:
1793 return 6;
1794 case 2442000:
1795 return 7;
1796 case 2447000:
1797 return 8;
1798 case 2452000:
1799 return 9;
1800 case 2457000:
1801 return 10;
1802 case 2462000:
1803 return 11;
1804 case 2467000:
1805 return 12;
1806 case 2472000:
1807 return 13;
1808 case 2484000:
1809 return 14;
1810 case 3665000:
1811 return 133; /* 802.11y */
1812 case 3685000:
1813 return 137; /* 802.11y */
1814 case 4915000:
1815 return 183;
1816 case 4920000:
1817 return 184;
1818 case 4925000:
1819 return 185;
1820 case 4930000:
1821 return 186;
1822 case 4935000:
1823 return 187;
1824 case 4940000:
1825 return 188;
1826 case 4945000:
1827 return 189;
1828 case 4960000:
1829 return 192;
1830 case 4980000:
1831 return 196;
1832 case 5170000:
1833 return 34;
1834 case 5180000:
1835 return 36;
1836 case 5190000:
1837 return 38;
1838 case 5200000:
1839 return 40;
1840 case 5210000:
1841 return 42;
1842 case 5220000:
1843 return 44;
1844 case 5230000:
1845 return 46;
1846 case 5240000:
1847 return 48;
1848 case 5250000:
1849 return 50;
1850 case 5260000:
1851 return 52;
1852 case 5270000:
1853 return 54;
1854 case 5280000:
1855 return 56;
1856 case 5290000:
1857 return 58;
1858 case 5300000:
1859 return 60;
1860 case 5320000:
1861 return 64;
1862 case 5500000:
1863 return 100;
1864 case 5520000:
1865 return 104;
1866 case 5540000:
1867 return 108;
1868 case 5560000:
1869 return 112;
1870 case 5580000:
1871 return 116;
1872 case 5600000:
1873 return 120;
1874 case 5620000:
1875 return 124;
1876 case 5640000:
1877 return 128;
1878 case 5660000:
1879 return 132;
1880 case 5680000:
1881 return 136;
1882 case 5700000:
1883 return 140;
1884 case 5745000:
1885 return 149;
1886 case 5765000:
1887 return 153;
1888 case 5785000:
1889 return 157;
1890 case 5805000:
1891 return 161;
1892 case 5825000:
1893 return 165;
1894 default:
1895 return 0;
1896 }
1897 }
1898
1899
1900 /* firmware command wrapper */
1901 /* NETWORK (WIFISYS) */
1902 /*----------------------------------------------------------------------------*/
1903 /*!
1904 * @brief This utility function is used to activate WIFISYS for specified network
1905 *
1906 * @param prAdapter Pointer of ADAPTER_T
1907 * eNetworkTypeIdx Index of network type
1908 *
1909 * @retval -
1910 */
1911 /*----------------------------------------------------------------------------*/
1912 WLAN_STATUS
1913 nicActivateNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
1914 {
1915 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
1916 P_BSS_INFO_T prBssInfo;
1917
1918 ASSERT(prAdapter);
1919 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
1920
1921 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
1922 rCmdActivateCtrl.ucActive = 1;
1923
1924 if (((UINT_8) eNetworkTypeIdx) < NETWORK_TYPE_INDEX_NUM) {
1925 prBssInfo = &prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx];
1926 prBssInfo->fg40mBwAllowed = FALSE;
1927 prBssInfo->fgAssoc40mBwAllowed = FALSE;
1928 }
1929
1930 return wlanSendSetQueryCmd(prAdapter,
1931 CMD_ID_BSS_ACTIVATE_CTRL,
1932 TRUE,
1933 FALSE,
1934 FALSE,
1935 NULL,
1936 NULL,
1937 sizeof(CMD_BSS_ACTIVATE_CTRL),
1938 (PUINT_8) & rCmdActivateCtrl, NULL, 0);
1939 }
1940
1941
1942 /*----------------------------------------------------------------------------*/
1943 /*!
1944 * @brief This utility function is used to deactivate WIFISYS for specified network
1945 *
1946 * @param prAdapter Pointer of ADAPTER_T
1947 * eNetworkTypeIdx Index of network type
1948 *
1949 * @retval -
1950 */
1951 /*----------------------------------------------------------------------------*/
1952 WLAN_STATUS
1953 nicDeactivateNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
1954 {
1955 WLAN_STATUS u4Status;
1956 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
1957
1958 ASSERT(prAdapter);
1959 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
1960
1961 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
1962 rCmdActivateCtrl.ucActive = 0;
1963
1964 u4Status = wlanSendSetQueryCmd(prAdapter,
1965 CMD_ID_BSS_ACTIVATE_CTRL,
1966 TRUE,
1967 FALSE,
1968 FALSE,
1969 NULL,
1970 NULL,
1971 sizeof(CMD_BSS_ACTIVATE_CTRL),
1972 (PUINT_8) & rCmdActivateCtrl, NULL, 0);
1973
1974 /* free all correlated station records */
1975 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
1976 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
1977 nicFreePendingTxMsduInfoByNetwork(prAdapter, eNetworkTypeIdx);
1978 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
1979
1980 return u4Status;
1981 }
1982
1983
1984 /* BSS-INFO */
1985 /*----------------------------------------------------------------------------*/
1986 /*!
1987 * @brief This utility function is used to sync bss info with firmware
1988 * when a new BSS has been connected or disconnected
1989 *
1990 * @param prAdapter Pointer of ADAPTER_T
1991 * eNetworkTypeIdx Index of BSS-INFO type
1992 *
1993 * @retval -
1994 */
1995 /*----------------------------------------------------------------------------*/
1996 WLAN_STATUS nicUpdateBss(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
1997 {
1998 WLAN_STATUS u4Status;
1999 P_BSS_INFO_T prBssInfo;
2000 CMD_SET_BSS_INFO rCmdSetBssInfo;
2001
2002 ASSERT(prAdapter);
2003 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2004
2005 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2006
2007 kalMemZero(&rCmdSetBssInfo, sizeof(CMD_SET_BSS_INFO));
2008
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);
2024 }
2025 #endif
2026
2027 rlmFillSyncCmdParam(&rCmdSetBssInfo.rBssRlmParam, prBssInfo);
2028
2029 rCmdSetBssInfo.fgWapiMode = (UINT_8) FALSE;
2030
2031 if (rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
2032 P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2033
2034 rCmdSetBssInfo.ucAuthMode = (UINT_8) prConnSettings->eAuthMode;
2035 rCmdSetBssInfo.ucEncStatus = (UINT_8) prConnSettings->eEncStatus;
2036 rCmdSetBssInfo.fgWapiMode = (UINT_8) prConnSettings->fgWapiMode;
2037 }
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;
2043 }
2044 #endif
2045 else {
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;
2051 } else {
2052 rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_OPEN;
2053 rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION_DISABLED;
2054 }
2055 /* Need the probe response to detect the PBC overlap */
2056 rCmdSetBssInfo.fgIsApMode =
2057 p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo);
2058 }
2059 #else
2060 rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
2061 rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
2062 #endif
2063 }
2064
2065 if (eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX &&
2066 prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
2067 prBssInfo->prStaRecOfAP != NULL) {
2068 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2069
2070 cnmAisInfraConnectNotify(prAdapter);
2071 }
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;
2078 }
2079 #endif
2080
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;
2085 }
2086 #endif
2087 else {
2088 rCmdSetBssInfo.ucStaRecIdxOfAP = STA_REC_INDEX_NOT_FOUND;
2089 }
2090
2091 u4Status = wlanSendSetQueryCmd(prAdapter,
2092 CMD_ID_SET_BSS_INFO,
2093 TRUE,
2094 FALSE,
2095 FALSE,
2096 NULL,
2097 NULL,
2098 sizeof(CMD_SET_BSS_INFO),
2099 (PUINT_8) & rCmdSetBssInfo, NULL, 0);
2100
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);
2105
2106 /* free all correlated station records */
2107 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2108 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2109 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2110 }
2111
2112 return u4Status;
2113 }
2114
2115
2116 /* BSS-INFO Indication (PM) */
2117 /*----------------------------------------------------------------------------*/
2118 /*!
2119 * @brief This utility function is used to indicate PM that
2120 * a BSS has been created. (for AdHoc / P2P-GO)
2121 *
2122 * @param prAdapter Pointer of ADAPTER_T
2123 * eNetworkTypeIdx Index of BSS-INFO
2124 *
2125 * @retval -
2126 */
2127 /*----------------------------------------------------------------------------*/
2128 WLAN_STATUS
2129 nicPmIndicateBssCreated(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2130 {
2131 P_BSS_INFO_T prBssInfo;
2132 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated;
2133
2134 ASSERT(prAdapter);
2135 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2136
2137 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2138
2139 rCmdIndicatePmBssCreated.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2140 rCmdIndicatePmBssCreated.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2141 rCmdIndicatePmBssCreated.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2142 rCmdIndicatePmBssCreated.u2AtimWindow = prBssInfo->u2ATIMWindow;
2143
2144 return wlanSendSetQueryCmd(prAdapter,
2145 CMD_ID_INDICATE_PM_BSS_CREATED,
2146 TRUE,
2147 FALSE,
2148 FALSE,
2149 NULL,
2150 NULL,
2151 sizeof(CMD_INDICATE_PM_BSS_CREATED),
2152 (PUINT_8) & rCmdIndicatePmBssCreated, NULL, 0);
2153 }
2154
2155
2156 /*----------------------------------------------------------------------------*/
2157 /*!
2158 * @brief This utility function is used to indicate PM that
2159 * a BSS has been connected
2160 *
2161 * @param prAdapter Pointer of ADAPTER_T
2162 * eNetworkTypeIdx Index of BSS-INFO
2163 *
2164 * @retval -
2165 */
2166 /*----------------------------------------------------------------------------*/
2167 WLAN_STATUS
2168 nicPmIndicateBssConnected(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2169 {
2170 P_BSS_INFO_T prBssInfo;
2171 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected;
2172
2173 ASSERT(prAdapter);
2174 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2175
2176 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2177
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;
2183
2184 rCmdIndicatePmBssConnected.ucBmpDeliveryAC = prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC;
2185 rCmdIndicatePmBssConnected.ucBmpTriggerAC = prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC;
2186
2187 /* DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x", */
2188 /* rCmdIndicatePmBssConnected.ucBmpDeliveryAC, */
2189 /* rCmdIndicatePmBssConnected.ucBmpTriggerAC); */
2190
2191 if ((eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX)
2192 #if CFG_ENABLE_WIFI_DIRECT
2193 || ((eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->fgIsP2PRegistered))
2194 #endif
2195 ) {
2196 if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
2197 rCmdIndicatePmBssConnected.fgIsUapsdConnection =
2198 (UINT_8) prBssInfo->prStaRecOfAP->fgIsUapsdSupported;
2199 } else {
2200 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0; /* @FIXME */
2201 }
2202 } else {
2203 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0;
2204 }
2205
2206 return wlanSendSetQueryCmd(prAdapter,
2207 CMD_ID_INDICATE_PM_BSS_CONNECTED,
2208 TRUE,
2209 FALSE,
2210 FALSE,
2211 NULL,
2212 NULL,
2213 sizeof(CMD_INDICATE_PM_BSS_CONNECTED),
2214 (PUINT_8) & rCmdIndicatePmBssConnected, NULL, 0);
2215 }
2216
2217
2218 /*----------------------------------------------------------------------------*/
2219 /*!
2220 * @brief This utility function is used to indicate PM that
2221 * a BSS has been disconnected
2222 *
2223 * @param prAdapter Pointer of ADAPTER_T
2224 * eNetworkTypeIdx Index of BSS-INFO
2225 *
2226 * @retval -
2227 */
2228 /*----------------------------------------------------------------------------*/
2229 WLAN_STATUS
2230 nicPmIndicateBssAbort(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2231 {
2232 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort;
2233
2234 ASSERT(prAdapter);
2235 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2236
2237 rCmdIndicatePmBssAbort.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2238
2239 return wlanSendSetQueryCmd(prAdapter,
2240 CMD_ID_INDICATE_PM_BSS_ABORT,
2241 TRUE,
2242 FALSE,
2243 FALSE,
2244 NULL,
2245 NULL,
2246 sizeof(CMD_INDICATE_PM_BSS_ABORT),
2247 (PUINT_8) & rCmdIndicatePmBssAbort, NULL, 0);
2248 }
2249
2250 WLAN_STATUS
2251 nicConfigPowerSaveProfile(IN P_ADAPTER_T prAdapter,
2252 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2253 PARAM_POWER_MODE ePwrMode, BOOLEAN fgEnCmdEvent)
2254 {
2255 DEBUGFUNC("nicConfigPowerSaveProfile");
2256 DBGLOG(INIT, TRACE, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2257 eNetTypeIndex, ePwrMode, fgEnCmdEvent));
2258
2259 ASSERT(prAdapter);
2260
2261 if (eNetTypeIndex >= NETWORK_TYPE_INDEX_NUM) {
2262 ASSERT(0);
2263 return WLAN_STATUS_NOT_SUPPORTED;
2264 }
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;
2269
2270 return wlanSendSetQueryCmd(prAdapter,
2271 CMD_ID_POWER_SAVE_MODE,
2272 TRUE,
2273 FALSE,
2274 (fgEnCmdEvent ? TRUE : FALSE),
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)
2281 );
2282
2283 } /* end of wlanoidSetAcpiDevicePowerStateMode() */
2284
2285 WLAN_STATUS nicEnterCtiaMode(IN P_ADAPTER_T prAdapter, BOOLEAN fgEnterCtia, BOOLEAN fgEnCmdEvent)
2286 {
2287 CMD_SW_DBG_CTRL_T rCmdSwCtrl;
2288 CMD_ACCESS_REG rCmdAccessReg;
2289 WLAN_STATUS rWlanStatus;
2290
2291 DEBUGFUNC("nicEnterCtiaMode");
2292 DBGLOG(INIT, TRACE, ("nicEnterCtiaMode: %d\n", fgEnterCtia));
2293
2294 ASSERT(prAdapter);
2295
2296 rWlanStatus = WLAN_STATUS_SUCCESS;
2297
2298 if (fgEnterCtia) {
2299 /* 1. Disable On-Lin Scan */
2300 prAdapter->fgEnOnlineScan = FALSE;
2301
2302 /* 3. Disable FIFO FULL no ack */
2303 rCmdAccessReg.u4Address = 0x60140028;
2304 rCmdAccessReg.u4Data = 0x904;
2305 wlanSendSetQueryCmd(prAdapter, CMD_ID_ACCESS_REG, TRUE, /* FALSE, */
2306 FALSE, /* TRUE, */
2307 FALSE,
2308 NULL,
2309 NULL,
2310 sizeof(CMD_ACCESS_REG), (PUINT_8) & rCmdAccessReg, NULL, 0);
2311
2312 /* 4. Disable Roaming */
2313 rCmdSwCtrl.u4Id = 0x90000204;
2314 rCmdSwCtrl.u4Data = 0x0;
2315 wlanSendSetQueryCmd(prAdapter,
2316 CMD_ID_SW_DBG_CTRL,
2317 TRUE,
2318 FALSE,
2319 FALSE,
2320 NULL,
2321 NULL,
2322 sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8) & rCmdSwCtrl, NULL, 0);
2323
2324 rCmdSwCtrl.u4Id = 0x90000200;
2325 rCmdSwCtrl.u4Data = 0x820000;
2326 wlanSendSetQueryCmd(prAdapter,
2327 CMD_ID_SW_DBG_CTRL,
2328 TRUE,
2329 FALSE,
2330 FALSE,
2331 NULL,
2332 NULL,
2333 sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8) & rCmdSwCtrl, NULL, 0);
2334
2335 /* Disalbe auto tx power */
2336 rCmdSwCtrl.u4Id = 0xa0100003;
2337 rCmdSwCtrl.u4Data = 0x0;
2338 wlanSendSetQueryCmd(prAdapter,
2339 CMD_ID_SW_DBG_CTRL,
2340 TRUE,
2341 FALSE,
2342 FALSE,
2343 NULL,
2344 NULL,
2345 sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8) & rCmdSwCtrl, NULL, 0);
2346
2347 /* 2. Keep at CAM mode */
2348 {
2349 PARAM_POWER_MODE ePowerMode;
2350
2351 prAdapter->u4CtiaPowerMode = 0;
2352 prAdapter->fgEnCtiaPowerMode = TRUE;
2353
2354 ePowerMode = Param_PowerModeCAM;
2355 rWlanStatus = nicConfigPowerSaveProfile(prAdapter,
2356 NETWORK_TYPE_AIS_INDEX,
2357 ePowerMode, fgEnCmdEvent);
2358 }
2359
2360 /* 5. Disable Beacon Timeout Detection */
2361 prAdapter->fgDisBcnLostDetection = TRUE;
2362 } else {
2363 /* 1. Enaable On-Lin Scan */
2364 prAdapter->fgEnOnlineScan = TRUE;
2365
2366 /* 3. Enable FIFO FULL no ack */
2367 rCmdAccessReg.u4Address = 0x60140028;
2368 rCmdAccessReg.u4Data = 0x905;
2369 wlanSendSetQueryCmd(prAdapter, CMD_ID_ACCESS_REG, TRUE, /* FALSE, */
2370 FALSE, /* TRUE, */
2371 FALSE,
2372 NULL,
2373 NULL,
2374 sizeof(CMD_ACCESS_REG), (PUINT_8) & rCmdAccessReg, NULL, 0);
2375
2376 /* 4. Enable Roaming */
2377 rCmdSwCtrl.u4Id = 0x90000204;
2378 rCmdSwCtrl.u4Data = 0x1;
2379 wlanSendSetQueryCmd(prAdapter,
2380 CMD_ID_SW_DBG_CTRL,
2381 TRUE,
2382 FALSE,
2383 FALSE,
2384 NULL,
2385 NULL,
2386 sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8) & rCmdSwCtrl, NULL, 0);
2387
2388 rCmdSwCtrl.u4Id = 0x90000200;
2389 rCmdSwCtrl.u4Data = 0x820000;
2390 wlanSendSetQueryCmd(prAdapter,
2391 CMD_ID_SW_DBG_CTRL,
2392 TRUE,
2393 FALSE,
2394 FALSE,
2395 NULL,
2396 NULL,
2397 sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8) & rCmdSwCtrl, NULL, 0);
2398
2399 /* Enable auto tx power */
2400 /* */
2401
2402 rCmdSwCtrl.u4Id = 0xa0100003;
2403 rCmdSwCtrl.u4Data = 0x1;
2404 wlanSendSetQueryCmd(prAdapter,
2405 CMD_ID_SW_DBG_CTRL,
2406 TRUE,
2407 FALSE,
2408 FALSE,
2409 NULL,
2410 NULL,
2411 sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8) & rCmdSwCtrl, NULL, 0);
2412
2413
2414 /* 2. Keep at Fast PS */
2415 {
2416 PARAM_POWER_MODE ePowerMode;
2417
2418 prAdapter->u4CtiaPowerMode = 2;
2419 prAdapter->fgEnCtiaPowerMode = TRUE;
2420
2421 ePowerMode = Param_PowerModeFast_PSP;
2422 rWlanStatus = nicConfigPowerSaveProfile(prAdapter,
2423 NETWORK_TYPE_AIS_INDEX,
2424 ePowerMode, fgEnCmdEvent);
2425 }
2426
2427 /* 5. Enable Beacon Timeout Detection */
2428 prAdapter->fgDisBcnLostDetection = FALSE;
2429
2430 }
2431
2432 return rWlanStatus;
2433 } /* end of nicEnterCtiaMode() */
2434
2435 /*----------------------------------------------------------------------------*/
2436 /*!
2437 * @brief This utility function is used to indicate firmware domain
2438 * for beacon generation parameters
2439 *
2440 * @param prAdapter Pointer of ADAPTER_T
2441 * eIeUpdMethod, Update Method
2442 * eNetTypeIndex Index of Network
2443 * u2Capability Capability
2444 * aucIe Pointer to buffer of IEs
2445 * u2IELen Length of IEs
2446 *
2447 * @retval - WLAN_STATUS_SUCCESS
2448 * WLAN_STATUS_FAILURE
2449 * WLAN_STATUS_PENDING
2450 * WLAN_STATUS_INVALID_DATA
2451 */
2452 /*----------------------------------------------------------------------------*/
2453 WLAN_STATUS
2454 nicUpdateBeaconIETemplate(IN P_ADAPTER_T prAdapter,
2455 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod,
2456 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2457 IN UINT_16 u2Capability, IN PUINT_8 aucIe, IN UINT_16 u2IELen)
2458 {
2459 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate;
2460 UINT_16 u2CmdBufLen = 0;
2461 P_GLUE_INFO_T prGlueInfo;
2462 P_CMD_INFO_T prCmdInfo;
2463 P_WIFI_CMD_T prWifiCmd;
2464 UINT_8 ucCmdSeqNum;
2465
2466 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2467 DBGLOG(INIT, LOUD, ("\n"));
2468
2469 printk("nicUpdateBeaconIETemplate\n");
2470
2471 ASSERT(prAdapter);
2472 prGlueInfo = prAdapter->prGlueInfo;
2473
2474 if (u2IELen > MAX_IE_LENGTH) {
2475 return WLAN_STATUS_INVALID_DATA;
2476 }
2477
2478 if (eIeUpdMethod == IE_UPD_METHOD_UPDATE_RANDOM || eIeUpdMethod == IE_UPD_METHOD_UPDATE_ALL) {
2479 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, aucIE) + u2IELen;
2480 } else if (eIeUpdMethod == IE_UPD_METHOD_DELETE_ALL) {
2481 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, u2IELen);
2482 } else {
2483 ASSERT(0);
2484 return WLAN_STATUS_FAILURE;
2485 }
2486
2487 /* prepare command info */
2488 prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u2CmdBufLen));
2489 if (!prCmdInfo) {
2490 DBGLOG(INIT, ERROR, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2491 printk("Allocate CMD_INFO_T ==> FAILED.\n");
2492 return WLAN_STATUS_FAILURE;
2493 }
2494 /* increase command sequence number */
2495 ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
2496 DBGLOG(REQ, TRACE, ("ucCmdSeqNum =%d\n", ucCmdSeqNum));
2497
2498 /* Setup common CMD Info Packet */
2499 prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
2500 prCmdInfo->eNetworkType = eNetTypeIndex;
2501 prCmdInfo->u2InfoBufLen = (UINT_16) (CMD_HDR_SIZE + u2CmdBufLen);
2502 prCmdInfo->pfCmdDoneHandler = NULL; /* @FIXME */
2503 prCmdInfo->pfCmdTimeoutHandler = NULL; /* @FIXME */
2504 prCmdInfo->fgIsOid = FALSE;
2505 prCmdInfo->ucCID = CMD_ID_UPDATE_BEACON_CONTENT;
2506 prCmdInfo->fgSetQuery = TRUE;
2507 prCmdInfo->fgNeedResp = FALSE;
2508 prCmdInfo->fgDriverDomainMCR = FALSE;
2509 prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
2510 prCmdInfo->u4SetInfoLen = u2CmdBufLen;
2511 prCmdInfo->pvInformationBuffer = NULL;
2512 prCmdInfo->u4InformationBufferLength = 0;
2513
2514 /* Setup WIFI_CMD_T (no payload) */
2515 prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
2516 prWifiCmd->u2TxByteCount_UserPriority = prCmdInfo->u2InfoBufLen;
2517 prWifiCmd->ucCID = prCmdInfo->ucCID;
2518 prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
2519 prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
2520
2521 prCmdBcnUpdate = (P_CMD_BEACON_TEMPLATE_UPDATE) (prWifiCmd->aucBuffer);
2522
2523 /* fill beacon updating command */
2524 prCmdBcnUpdate->ucUpdateMethod = (UINT_8) eIeUpdMethod;
2525 prCmdBcnUpdate->ucNetTypeIndex = (UINT_8) eNetTypeIndex;
2526 prCmdBcnUpdate->u2Capability = u2Capability;
2527 prCmdBcnUpdate->u2IELen = u2IELen;
2528 if (u2IELen > 0) {
2529 kalMemCopy(prCmdBcnUpdate->aucIE, aucIe, u2IELen);
2530 }
2531 /* insert into prCmdQueue */
2532 kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T) prCmdInfo);
2533
2534 /* wakeup txServiceThread later */
2535 GLUE_SET_EVENT(prGlueInfo);
2536 return WLAN_STATUS_PENDING;
2537 }
2538
2539
2540 /*----------------------------------------------------------------------------*/
2541 /*!
2542 * @brief This utility function is used to initialization PHY related
2543 * varaibles
2544 *
2545 * @param prAdapter Pointer of ADAPTER_T
2546 *
2547 * @retval none
2548 */
2549 /*----------------------------------------------------------------------------*/
2550 VOID nicSetAvailablePhyTypeSet(IN P_ADAPTER_T prAdapter)
2551 {
2552 P_CONNECTION_SETTINGS_T prConnSettings;
2553
2554 ASSERT(prAdapter);
2555
2556 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2557
2558 if (prConnSettings->eDesiredPhyConfig >= PHY_CONFIG_NUM) {
2559 ASSERT(0);
2560 return;
2561 }
2562
2563 prAdapter->rWifiVar.ucAvailablePhyTypeSet =
2564 aucPhyCfg2PhyTypeSet[prConnSettings->eDesiredPhyConfig];
2565
2566 if (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_BIT_ERP) {
2567 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_ERP_INDEX;
2568 }
2569 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2570 else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
2571
2572 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_HR_DSSS_INDEX;
2573 }
2574
2575 return;
2576 }
2577
2578
2579 /*----------------------------------------------------------------------------*/
2580 /*!
2581 * @brief This utility function is used to update WMM Parms
2582 *
2583 * @param prAdapter Pointer of ADAPTER_T
2584 * eNetworkTypeIdx Index of BSS-INFO
2585 *
2586 * @retval -
2587 */
2588 /*----------------------------------------------------------------------------*/
2589 WLAN_STATUS
2590 nicQmUpdateWmmParms(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
2591 {
2592 P_BSS_INFO_T prBssInfo;
2593 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms;
2594
2595 ASSERT(prAdapter);
2596 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2597
2598 DBGLOG(QM, EVENT, ("sizeof(AC_QUE_PARMS_T): %d\n", sizeof(AC_QUE_PARMS_T)));
2599 DBGLOG(QM, EVENT, ("sizeof(CMD_UPDATE_WMM_PARMS): %d\n", sizeof(CMD_UPDATE_WMM_PARMS_T)));
2600 DBGLOG(QM, EVENT, ("sizeof(WIFI_CMD_T): %d\n", sizeof(WIFI_CMD_T)));
2601
2602 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2603 rCmdUpdateWmmParms.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
2604 kalMemCopy(&rCmdUpdateWmmParms.arACQueParms[0], &prBssInfo->arACQueParms[0],
2605 (sizeof(AC_QUE_PARMS_T) * AC_NUM));
2606
2607 rCmdUpdateWmmParms.fgIsQBSS = prBssInfo->fgIsQBSS;
2608
2609 return wlanSendSetQueryCmd(prAdapter,
2610 CMD_ID_UPDATE_WMM_PARMS,
2611 TRUE,
2612 FALSE,
2613 FALSE,
2614 NULL,
2615 NULL,
2616 sizeof(CMD_UPDATE_WMM_PARMS_T),
2617 (PUINT_8) & rCmdUpdateWmmParms, NULL, 0);
2618 }
2619
2620
2621 /*----------------------------------------------------------------------------*/
2622 /*!
2623 * @brief This utility function is used to update TX power gain corresponding to
2624 * each band/modulation combination
2625 *
2626 * @param prAdapter Pointer of ADAPTER_T
2627 * prTxPwrParam Pointer of TX power parameters
2628 *
2629 * @retval WLAN_STATUS_PENDING
2630 * WLAN_STATUS_FAILURE
2631 */
2632 /*----------------------------------------------------------------------------*/
2633 WLAN_STATUS nicUpdateTxPower(IN P_ADAPTER_T prAdapter, IN P_CMD_TX_PWR_T prTxPwrParam)
2634 {
2635 DEBUGFUNC("nicUpdateTxPower");
2636
2637 ASSERT(prAdapter);
2638
2639 return wlanSendSetQueryCmd(prAdapter,
2640 CMD_ID_SET_TX_PWR,
2641 TRUE,
2642 FALSE,
2643 FALSE,
2644 NULL,
2645 NULL, sizeof(CMD_TX_PWR_T), (PUINT_8) prTxPwrParam, NULL, 0);
2646 }
2647
2648 /*----------------------------------------------------------------------------*/
2649 /*!
2650 * @brief This utility function is used to set auto tx power parameter
2651 *
2652 * @param prAdapter Pointer of ADAPTER_T
2653 * prTxPwrParam Pointer of Auto TX power parameters
2654 *
2655 * @retval WLAN_STATUS_PENDING
2656 * WLAN_STATUS_FAILURE
2657 */
2658 /*----------------------------------------------------------------------------*/
2659 WLAN_STATUS nicSetAutoTxPower(IN P_ADAPTER_T prAdapter, IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam)
2660 {
2661 DEBUGFUNC("nicSetAutoTxPower");
2662
2663 ASSERT(prAdapter);
2664
2665 return wlanSendSetQueryCmd(prAdapter,
2666 CMD_ID_SET_AUTOPWR_CTRL,
2667 TRUE,
2668 FALSE,
2669 FALSE,
2670 NULL,
2671 NULL,
2672 sizeof(CMD_AUTO_POWER_PARAM_T),
2673 (PUINT_8) prAutoPwrParam, NULL, 0);
2674 }
2675
2676
2677 /*----------------------------------------------------------------------------*/
2678 /*!
2679 * @brief This utility function is used to update TX power gain corresponding to
2680 * each band/modulation combination
2681 *
2682 * @param prAdapter Pointer of ADAPTER_T
2683 * prTxPwrParam Pointer of TX power parameters
2684 *
2685 * @retval WLAN_STATUS_PENDING
2686 * WLAN_STATUS_FAILURE
2687 */
2688 /*----------------------------------------------------------------------------*/
2689 WLAN_STATUS nicSetAutoTxPowerControl(IN P_ADAPTER_T prAdapter, IN P_CMD_TX_PWR_T prTxPwrParam)
2690 {
2691 DEBUGFUNC("nicUpdateTxPower");
2692
2693 ASSERT(prAdapter);
2694
2695 return wlanSendSetQueryCmd(prAdapter,
2696 CMD_ID_SET_TX_PWR,
2697 TRUE,
2698 FALSE,
2699 FALSE,
2700 NULL,
2701 NULL, sizeof(CMD_TX_PWR_T), (PUINT_8) prTxPwrParam, NULL, 0);
2702 }
2703
2704
2705 /*----------------------------------------------------------------------------*/
2706 /*!
2707 * @brief This utility function is used to update power offset around 5GHz band
2708 *
2709 * @param prAdapter Pointer of ADAPTER_T
2710 * pr5GPwrOffset Pointer of 5GHz power offset parameter
2711 *
2712 * @retval WLAN_STATUS_PENDING
2713 * WLAN_STATUS_FAILURE
2714 */
2715 /*----------------------------------------------------------------------------*/
2716 WLAN_STATUS nicUpdate5GOffset(IN P_ADAPTER_T prAdapter, IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset)
2717 {
2718 DEBUGFUNC("nicUpdate5GOffset");
2719
2720 ASSERT(prAdapter);
2721
2722 return wlanSendSetQueryCmd(prAdapter,
2723 CMD_ID_SET_5G_PWR_OFFSET,
2724 TRUE,
2725 FALSE,
2726 FALSE,
2727 NULL,
2728 NULL,
2729 sizeof(CMD_5G_PWR_OFFSET_T), (PUINT_8) pr5GPwrOffset, NULL, 0);
2730 }
2731
2732
2733 /*----------------------------------------------------------------------------*/
2734 /*!
2735 * @brief This utility function is used to update DPD calibration result
2736 *
2737 * @param prAdapter Pointer of ADAPTER_T
2738 * pr5GPwrOffset Pointer of parameter for DPD calibration result
2739 *
2740 * @retval WLAN_STATUS_PENDING
2741 * WLAN_STATUS_FAILURE
2742 */
2743 /*----------------------------------------------------------------------------*/
2744 WLAN_STATUS nicUpdateDPD(IN P_ADAPTER_T prAdapter, IN P_CMD_PWR_PARAM_T prDpdCalResult)
2745 {
2746 DEBUGFUNC("nicUpdateDPD");
2747
2748 ASSERT(prAdapter);
2749
2750 return wlanSendSetQueryCmd(prAdapter,
2751 CMD_ID_SET_PWR_PARAM,
2752 TRUE,
2753 FALSE,
2754 FALSE,
2755 NULL,
2756 NULL,
2757 sizeof(CMD_PWR_PARAM_T), (PUINT_8) prDpdCalResult, NULL, 0);
2758 }
2759
2760
2761 /*----------------------------------------------------------------------------*/
2762 /*!
2763 * @brief This utility function starts system service such as timer and
2764 * memory pools
2765 *
2766 * @param prAdapter Pointer of ADAPTER_T
2767 *
2768 * @retval none
2769 */
2770 /*----------------------------------------------------------------------------*/
2771 VOID nicInitSystemService(IN P_ADAPTER_T prAdapter)
2772 {
2773 ASSERT(prAdapter);
2774
2775 /* <1> Initialize MGMT Memory pool and STA_REC */
2776 cnmMemInit(prAdapter);
2777 cnmStaRecInit(prAdapter);
2778 cmdBufInitialize(prAdapter);
2779
2780 /* <2> Mailbox Initialization */
2781 mboxInitialize(prAdapter);
2782
2783 /* <3> Timer Initialization */
2784 cnmTimerInitialize(prAdapter);
2785
2786 return;
2787 }
2788
2789
2790 /*----------------------------------------------------------------------------*/
2791 /*!
2792 * @brief This utility function reset some specific system service,
2793 * such as STA-REC
2794 *
2795 * @param prAdapter Pointer of ADAPTER_T
2796 *
2797 * @retval none
2798 */
2799 /*----------------------------------------------------------------------------*/
2800 VOID nicResetSystemService(IN P_ADAPTER_T prAdapter)
2801 {
2802 ASSERT(prAdapter);
2803 }
2804
2805
2806 /*----------------------------------------------------------------------------*/
2807 /*!
2808 * @brief This utility function is used to update WMM Parms
2809 *
2810 * @param prAdapter Pointer of ADAPTER_T
2811 *
2812 * @retval none
2813 */
2814 /*----------------------------------------------------------------------------*/
2815 VOID nicUninitSystemService(IN P_ADAPTER_T prAdapter)
2816 {
2817 ASSERT(prAdapter);
2818
2819 /* Timer Destruction */
2820 cnmTimerDestroy(prAdapter);
2821
2822 /* Mailbox Destruction */
2823 mboxDestroy(prAdapter);
2824
2825 return;
2826 }
2827
2828
2829 /*----------------------------------------------------------------------------*/
2830 /*!
2831 * @brief This utility function is used to update WMM Parms
2832 *
2833 * @param prAdapter Pointer of ADAPTER_T
2834 *
2835 * @retval none
2836 */
2837 /*----------------------------------------------------------------------------*/
2838 VOID nicInitMGMT(IN P_ADAPTER_T prAdapter, IN P_REG_INFO_T prRegInfo)
2839 {
2840 ASSERT(prAdapter);
2841
2842 /* CNM Module - initialization */
2843 cnmInit(prAdapter);
2844
2845 /* RLM Module - initialization */
2846 rlmFsmEventInit(prAdapter);
2847
2848 /* SCN Module - initialization */
2849 scnInit(prAdapter);
2850
2851 /* AIS Module - intiailization */
2852 aisInitializeConnectionSettings(prAdapter, prRegInfo);
2853 aisFsmInit(prAdapter);
2854
2855 #if CFG_SUPPORT_ROAMING
2856 /* Roaming Module - intiailization */
2857 roamingFsmInit(prAdapter);
2858 #endif /* CFG_SUPPORT_ROAMING */
2859
2860 #if CFG_SUPPORT_SWCR
2861 swCrDebugInit(prAdapter);
2862 #endif /* CFG_SUPPORT_SWCR */
2863
2864 return;
2865 }
2866
2867
2868 /*----------------------------------------------------------------------------*/
2869 /*!
2870 * @brief This utility function is used to update WMM Parms
2871 *
2872 * @param prAdapter Pointer of ADAPTER_T
2873 *
2874 * @retval none
2875 */
2876 /*----------------------------------------------------------------------------*/
2877 VOID nicUninitMGMT(IN P_ADAPTER_T prAdapter)
2878 {
2879 ASSERT(prAdapter);
2880
2881 #if CFG_SUPPORT_SWCR
2882 swCrDebugUninit(prAdapter);
2883 #endif /* CFG_SUPPORT_SWCR */
2884
2885 #if CFG_SUPPORT_ROAMING
2886 /* Roaming Module - unintiailization */
2887 roamingFsmUninit(prAdapter);
2888 #endif /* CFG_SUPPORT_ROAMING */
2889
2890 /* AIS Module - unintiailization */
2891 aisFsmUninit(prAdapter);
2892
2893 /* SCN Module - unintiailization */
2894 scnUninit(prAdapter);
2895
2896 /* RLM Module - uninitialization */
2897 rlmFsmEventUninit(prAdapter);
2898
2899 /* CNM Module - uninitialization */
2900 cnmUninit(prAdapter);
2901
2902 return;
2903 }
2904
2905
2906 #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
2907 /*----------------------------------------------------------------------------*/
2908 /*!
2909 * @brief This utility function is to inform firmware to enable MCU clock gating
2910 *
2911 * @param prAdapter Pointer of ADAPTER_T
2912 *
2913 * @retval none
2914 */
2915 /*----------------------------------------------------------------------------*/
2916 WLAN_STATUS nicEnableClockGating(IN P_ADAPTER_T prAdapter)
2917 {
2918 UINT_32 i, u4WHISR = 0;
2919
2920 ASSERT(prAdapter);
2921
2922 if (prAdapter->fgIsClockGatingEnabled == TRUE) {
2923 return WLAN_STATUS_SUCCESS;
2924 } else {
2925 nicSetSwIntr(prAdapter, REQ_GATING_ENABLE_H2D_INT);
2926
2927 i = 0;
2928 while (i < GATING_CONTROL_POLL_LIMIT) {
2929 if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
2930 || fgIsBusAccessFailed == TRUE) {
2931 return WLAN_STATUS_FAILURE;
2932 }
2933
2934 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8) & u4WHISR);
2935
2936 if (u4WHISR & ACK_GATING_ENABLE_D2H_INT) {
2937 prAdapter->fgIsClockGatingEnabled = TRUE;
2938 return WLAN_STATUS_SUCCESS;
2939 }
2940 }
2941
2942 ASSERT(0);
2943 return WLAN_STATUS_PENDING;
2944 }
2945 }
2946
2947
2948 /*----------------------------------------------------------------------------*/
2949 /*!
2950 * @brief This utility function is to inform firmware to disable MCU clock gating
2951 *
2952 * @param prAdapter Pointer of ADAPTER_T
2953 *
2954 * @retval none
2955 */
2956 /*----------------------------------------------------------------------------*/
2957 WLAN_STATUS nicDisableClockGating(IN P_ADAPTER_T prAdapter)
2958 {
2959 UINT_32 i, u4WHISR = 0;
2960
2961 ASSERT(prAdapter);
2962
2963 if (prAdapter->fgIsClockGatingEnabled == FALSE) {
2964 return WLAN_STATUS_SUCCESS;
2965 } else {
2966 nicSetSwIntr(prAdapter, REQ_GATING_DISABLE_H2D_INT);
2967
2968 i = 0;
2969 while (i < GATING_CONTROL_POLL_LIMIT) {
2970 if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
2971 || fgIsBusAccessFailed == TRUE) {
2972 return WLAN_STATUS_FAILURE;
2973 }
2974
2975 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8) & u4WHISR);
2976
2977 if (u4WHISR & ACK_GATING_DISABLE_D2H_INT) {
2978 prAdapter->fgIsClockGatingEnabled = FALSE;
2979 return WLAN_STATUS_SUCCESS;
2980 }
2981 }
2982
2983 ASSERT(0);
2984 return WLAN_STATUS_PENDING;
2985 }
2986 }
2987 #endif
2988
2989
2990 /*----------------------------------------------------------------------------*/
2991 /*!
2992 * @brief This function is invoked to buffer scan result
2993 *
2994 * @param prAdapter Pointer to the Adapter structure.
2995 * @param rMacAddr BSSID
2996 * @param prSsid Pointer to SSID
2997 * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
2998 * @param rRssi Received Strength (-10 ~ -200 dBm)
2999 * @param eNetworkType Network Type (a/b/g)
3000 * @param prConfiguration Network Parameter
3001 * @param eOpMode Infra/Ad-Hoc
3002 * @param rSupportedRates Supported basic rates
3003 * @param u2IELength IE Length
3004 * @param pucIEBuf Pointer to Information Elements(IEs)
3005 *
3006 * @return (none)
3007 */
3008 /*----------------------------------------------------------------------------*/
3009 VOID
3010 nicAddScanResult(IN P_ADAPTER_T prAdapter,
3011 IN PARAM_MAC_ADDRESS rMacAddr,
3012 IN P_PARAM_SSID_T prSsid,
3013 IN UINT_32 u4Privacy,
3014 IN PARAM_RSSI rRssi,
3015 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType,
3016 IN P_PARAM_802_11_CONFIG_T prConfiguration,
3017 IN ENUM_PARAM_OP_MODE_T eOpMode,
3018 IN PARAM_RATES_EX rSupportedRates, IN UINT_16 u2IELength, IN PUINT_8 pucIEBuf)
3019 {
3020 BOOLEAN bReplace;
3021 UINT_32 i;
3022 UINT_32 u4IdxWeakest = 0;
3023 PARAM_RSSI rWeakestRssi;
3024 UINT_32 u4BufferSize;
3025
3026 ASSERT(prAdapter);
3027
3028 rWeakestRssi = (PARAM_RSSI) INT_MAX;
3029 u4BufferSize =
3030 sizeof(prAdapter->rWlanInfo.aucScanIEBuf) /
3031 sizeof(prAdapter->rWlanInfo.aucScanIEBuf[0]);
3032
3033 bReplace = FALSE;
3034
3035 /* decide to replace or add */
3036 for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
3037 /* find weakest entry && not connected one */
3038 if (UNEQUAL_MAC_ADDR
3039 (prAdapter->rWlanInfo.arScanResult[i].arMacAddress,
3040 prAdapter->rWlanInfo.rCurrBssId.arMacAddress)
3041 && prAdapter->rWlanInfo.arScanResult[i].rRssi < rWeakestRssi) {
3042 u4IdxWeakest = i;
3043 rWeakestRssi = prAdapter->rWlanInfo.arScanResult[i].rRssi;
3044 }
3045
3046 if (prAdapter->rWlanInfo.arScanResult[i].eOpMode == eOpMode &&
3047 EQUAL_MAC_ADDR(&(prAdapter->rWlanInfo.arScanResult[i].arMacAddress), rMacAddr)
3048 &&
3049 (EQUAL_SSID
3050 (prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3051 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen, prSsid->aucSsid,
3052 prSsid->u4SsidLen)
3053 || prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen == 0)) {
3054 /* replace entry */
3055 bReplace = TRUE;
3056
3057 /* free IE buffer then zero */
3058 nicFreeScanResultIE(prAdapter, i);
3059 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3060 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3061
3062 /* then fill buffer */
3063 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3064 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3065 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3066 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3067 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3068 prSsid->aucSsid, prSsid->u4SsidLen);
3069 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3070 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3071 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3072 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3073 prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
3074 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3075 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3076 rSupportedRates, sizeof(PARAM_RATES_EX));
3077 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
3078
3079 /* IE - allocate buffer and update pointer */
3080 if (u2IELength > 0) {
3081 if (ALIGN_4(u2IELength) +
3082 prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3083 kalMemCopy(&
3084 (prAdapter->rWlanInfo.
3085 aucScanIEBuf[prAdapter->rWlanInfo.
3086 u4ScanIEBufferUsage]), pucIEBuf,
3087 u2IELength);
3088
3089 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3090 &(prAdapter->rWlanInfo.
3091 aucScanIEBuf[prAdapter->rWlanInfo.
3092 u4ScanIEBufferUsage]);
3093
3094 prAdapter->rWlanInfo.u4ScanIEBufferUsage +=
3095 ALIGN_4(u2IELength);
3096 } else {
3097 /* buffer is not enough */
3098 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3099 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3100 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3101 }
3102 } else {
3103 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3104 }
3105
3106 break;
3107 }
3108 }
3109
3110 if (bReplace == FALSE) {
3111 if (prAdapter->rWlanInfo.u4ScanResultNum < (CFG_MAX_NUM_BSS_LIST - 1)) {
3112 i = prAdapter->rWlanInfo.u4ScanResultNum;
3113
3114 /* zero */
3115 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3116 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3117
3118 /* then fill buffer */
3119 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3120 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3121 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3122 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3123 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3124 prSsid->aucSsid, prSsid->u4SsidLen);
3125 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3126 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3127 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3128 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3129 prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
3130 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3131 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3132 rSupportedRates, sizeof(PARAM_RATES_EX));
3133 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
3134
3135 /* IE - allocate buffer and update pointer */
3136 if (u2IELength > 0) {
3137 if (ALIGN_4(u2IELength) +
3138 prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3139 kalMemCopy(&
3140 (prAdapter->rWlanInfo.
3141 aucScanIEBuf[prAdapter->rWlanInfo.
3142 u4ScanIEBufferUsage]), pucIEBuf,
3143 u2IELength);
3144
3145 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3146 &(prAdapter->rWlanInfo.
3147 aucScanIEBuf[prAdapter->rWlanInfo.
3148 u4ScanIEBufferUsage]);
3149
3150 prAdapter->rWlanInfo.u4ScanIEBufferUsage +=
3151 ALIGN_4(u2IELength);
3152 } else {
3153 /* buffer is not enough */
3154 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3155 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3156 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3157 }
3158 } else {
3159 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3160 }
3161
3162 prAdapter->rWlanInfo.u4ScanResultNum++;
3163 } else if (rWeakestRssi != (PARAM_RSSI) INT_MAX) {
3164 /* replace weakest one */
3165 i = u4IdxWeakest;
3166
3167 /* free IE buffer then zero */
3168 nicFreeScanResultIE(prAdapter, i);
3169 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3170 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3171
3172 /* then fill buffer */
3173 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3174 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3175 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3176 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3177 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3178 prSsid->aucSsid, prSsid->u4SsidLen);
3179 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3180 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3181 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3182 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3183 prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
3184 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3185 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3186 rSupportedRates, sizeof(PARAM_RATES_EX));
3187 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
3188
3189 if (u2IELength > 0) {
3190 /* IE - allocate buffer and update pointer */
3191 if (ALIGN_4(u2IELength) +
3192 prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3193 kalMemCopy(&
3194 (prAdapter->rWlanInfo.
3195 aucScanIEBuf[prAdapter->rWlanInfo.
3196 u4ScanIEBufferUsage]), pucIEBuf,
3197 u2IELength);
3198
3199 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3200 &(prAdapter->rWlanInfo.
3201 aucScanIEBuf[prAdapter->rWlanInfo.
3202 u4ScanIEBufferUsage]);
3203
3204 prAdapter->rWlanInfo.u4ScanIEBufferUsage +=
3205 ALIGN_4(u2IELength);
3206 } else {
3207 /* buffer is not enough */
3208 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3209 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3210 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3211 }
3212 } else {
3213 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3214 }
3215 }
3216 }
3217 }
3218
3219
3220 /*----------------------------------------------------------------------------*/
3221 /*!
3222 * @brief This function is invoked to free IE buffer for dedicated scan result
3223 *
3224 * @param prAdapter Pointer to the Adapter structure.
3225 * @param u4Idx Index of Scan Result
3226 *
3227 * @return (none)
3228 */
3229 /*----------------------------------------------------------------------------*/
3230 VOID nicFreeScanResultIE(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Idx)
3231 {
3232 UINT_32 i;
3233 PUINT_8 pucPivot, pucMovePivot;
3234 UINT_32 u4MoveSize, u4FreeSize, u4ReserveSize;
3235
3236 ASSERT(prAdapter);
3237 ASSERT(u4Idx < CFG_MAX_NUM_BSS_LIST);
3238
3239 if (prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength == 0
3240 || prAdapter->rWlanInfo.apucScanResultIEs[u4Idx] == NULL) {
3241 return;
3242 }
3243
3244 u4FreeSize = ALIGN_4(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength);
3245
3246 pucPivot = prAdapter->rWlanInfo.apucScanResultIEs[u4Idx];
3247 pucMovePivot =
3248 (PUINT_8) ((UINT_32) (prAdapter->rWlanInfo.apucScanResultIEs[u4Idx]) + u4FreeSize);
3249
3250 u4ReserveSize = ((UINT_32) pucPivot) - (UINT_32) (&(prAdapter->rWlanInfo.aucScanIEBuf[0]));
3251 u4MoveSize = prAdapter->rWlanInfo.u4ScanIEBufferUsage - u4ReserveSize - u4FreeSize;
3252
3253 /* 1. rest of buffer to move forward */
3254 kalMemCopy(pucPivot, pucMovePivot, u4MoveSize);
3255
3256 /* 1.1 modify pointers */
3257 for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
3258 if (i != u4Idx) {
3259 if (prAdapter->rWlanInfo.apucScanResultIEs[i] >= pucMovePivot) {
3260 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3261 (PUINT_8) ((UINT_32) (prAdapter->rWlanInfo.apucScanResultIEs[i])
3262 - u4FreeSize);
3263 }
3264 }
3265 }
3266
3267 /* 1.2 reset the freed one */
3268 prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength = 0;
3269 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3270
3271 /* 2. reduce IE buffer usage */
3272 prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4FreeSize;
3273
3274 return;
3275 }
3276
3277
3278 /*----------------------------------------------------------------------------*/
3279 /*!
3280 * @brief This function is to hack parameters for WLAN TABLE for
3281 * fixed rate settings
3282 *
3283 * @param prAdapter Pointer to the Adapter structure.
3284 * @param eRateSetting
3285 * @param pu2DesiredNonHTRateSet,
3286 * @param pu2BSSBasicRateSet,
3287 * @param pucMcsSet
3288 * @param pucSupMcs32
3289 * @param pu2HtCapInfo
3290 *
3291 * @return WLAN_STATUS_SUCCESS
3292 */
3293 /*----------------------------------------------------------------------------*/
3294 WLAN_STATUS
3295 nicUpdateRateParams(IN P_ADAPTER_T prAdapter,
3296 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting,
3297 IN PUINT_8 pucDesiredPhyTypeSet,
3298 IN PUINT_16 pu2DesiredNonHTRateSet,
3299 IN PUINT_16 pu2BSSBasicRateSet,
3300 IN PUINT_8 pucMcsSet, IN PUINT_8 pucSupMcs32, IN PUINT_16 pu2HtCapInfo)
3301 {
3302 ASSERT(prAdapter);
3303 ASSERT(eRateSetting > FIXED_RATE_NONE && eRateSetting < FIXED_RATE_NUM);
3304
3305 switch (prAdapter->rWifiVar.eRateSetting) {
3306 case FIXED_RATE_1M:
3307 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3308 *pu2DesiredNonHTRateSet = RATE_SET_BIT_1M;
3309 *pu2BSSBasicRateSet = RATE_SET_BIT_1M;
3310 *pucMcsSet = 0;
3311 *pucSupMcs32 = 0;
3312 *pu2HtCapInfo = 0;
3313 break;
3314
3315 case FIXED_RATE_2M:
3316 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3317 *pu2DesiredNonHTRateSet = RATE_SET_BIT_2M;
3318 *pu2BSSBasicRateSet = RATE_SET_BIT_2M;
3319 *pucMcsSet = 0;
3320 *pucSupMcs32 = 0;
3321 *pu2HtCapInfo = 0;
3322 break;
3323
3324 case FIXED_RATE_5_5M:
3325 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3326 *pu2DesiredNonHTRateSet = RATE_SET_BIT_5_5M;
3327 *pu2BSSBasicRateSet = RATE_SET_BIT_5_5M;
3328 *pucMcsSet = 0;
3329 *pucSupMcs32 = 0;
3330 *pu2HtCapInfo = 0;
3331 break;
3332
3333 case FIXED_RATE_11M:
3334 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3335 *pu2DesiredNonHTRateSet = RATE_SET_BIT_11M;
3336 *pu2BSSBasicRateSet = RATE_SET_BIT_11M;
3337 *pucMcsSet = 0;
3338 *pucSupMcs32 = 0;
3339 *pu2HtCapInfo = 0;
3340 break;
3341
3342 case FIXED_RATE_6M:
3343 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3344 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3345 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3346 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3347 }
3348
3349 *pu2DesiredNonHTRateSet = RATE_SET_BIT_6M;
3350 *pu2BSSBasicRateSet = RATE_SET_BIT_6M;
3351 *pucMcsSet = 0;
3352 *pucSupMcs32 = 0;
3353 *pu2HtCapInfo = 0;
3354 break;
3355
3356 case FIXED_RATE_9M:
3357 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3358 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3359 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3360 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3361 }
3362
3363 *pu2DesiredNonHTRateSet = RATE_SET_BIT_9M;
3364 *pu2BSSBasicRateSet = RATE_SET_BIT_9M;
3365 *pucMcsSet = 0;
3366 *pucSupMcs32 = 0;
3367 *pu2HtCapInfo = 0;
3368 break;
3369
3370 case FIXED_RATE_12M:
3371 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3372 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3373 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3374 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3375 }
3376
3377 *pu2DesiredNonHTRateSet = RATE_SET_BIT_12M;
3378 *pu2BSSBasicRateSet = RATE_SET_BIT_12M;
3379 *pucMcsSet = 0;
3380 *pucSupMcs32 = 0;
3381 *pu2HtCapInfo = 0;
3382 break;
3383
3384 case FIXED_RATE_18M:
3385 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3386 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3387 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3388 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3389 }
3390
3391 *pu2DesiredNonHTRateSet = RATE_SET_BIT_18M;
3392 *pu2BSSBasicRateSet = RATE_SET_BIT_18M;
3393 *pucMcsSet = 0;
3394 *pucSupMcs32 = 0;
3395 *pu2HtCapInfo = 0;
3396 break;
3397
3398 case FIXED_RATE_24M:
3399 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3400 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3401 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3402 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3403 }
3404
3405 *pu2DesiredNonHTRateSet = RATE_SET_BIT_24M;
3406 *pu2BSSBasicRateSet = RATE_SET_BIT_24M;
3407 *pucMcsSet = 0;
3408 *pucSupMcs32 = 0;
3409 *pu2HtCapInfo = 0;
3410 break;
3411
3412 case FIXED_RATE_36M:
3413 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3414 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3415 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3416 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3417 }
3418
3419 *pu2DesiredNonHTRateSet = RATE_SET_BIT_36M;
3420 *pu2BSSBasicRateSet = RATE_SET_BIT_36M;
3421 *pucMcsSet = 0;
3422 *pucSupMcs32 = 0;
3423 *pu2HtCapInfo = 0;
3424 break;
3425
3426 case FIXED_RATE_48M:
3427 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3428 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3429 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3430 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3431 }
3432
3433 *pu2DesiredNonHTRateSet = RATE_SET_BIT_48M;
3434 *pu2BSSBasicRateSet = RATE_SET_BIT_48M;
3435 *pucMcsSet = 0;
3436 *pucSupMcs32 = 0;
3437 *pu2HtCapInfo = 0;
3438 break;
3439
3440 case FIXED_RATE_54M:
3441 if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3442 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3443 } else if ((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3444 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3445 }
3446
3447 *pu2DesiredNonHTRateSet = RATE_SET_BIT_54M;
3448 *pu2BSSBasicRateSet = RATE_SET_BIT_54M;
3449 *pucMcsSet = 0;
3450 *pucSupMcs32 = 0;
3451 *pu2HtCapInfo = 0;
3452 break;
3453
3454 case FIXED_RATE_MCS0_20M_800NS:
3455 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3456 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3457 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3458 *pucMcsSet = HT_RATE_MCS0_INDEX;
3459 *pucSupMcs32 = 0;
3460 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3461 | HT_CAP_INFO_SHORT_GI_20M
3462 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3463 break;
3464
3465 case FIXED_RATE_MCS1_20M_800NS:
3466 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3467 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3468 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3469 *pucMcsSet = HT_RATE_MCS1_INDEX;
3470 *pucSupMcs32 = 0;
3471 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3472 | HT_CAP_INFO_SHORT_GI_20M
3473 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3474 break;
3475
3476 case FIXED_RATE_MCS2_20M_800NS:
3477 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3478 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3479 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3480 *pucMcsSet = HT_RATE_MCS2_INDEX;
3481 *pucSupMcs32 = 0;
3482 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3483 | HT_CAP_INFO_SHORT_GI_20M
3484 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3485 break;
3486
3487 case FIXED_RATE_MCS3_20M_800NS:
3488 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3489 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3490 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3491 *pucMcsSet = HT_RATE_MCS3_INDEX;
3492 *pucSupMcs32 = 0;
3493 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3494 | HT_CAP_INFO_SHORT_GI_20M
3495 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3496 break;
3497
3498 case FIXED_RATE_MCS4_20M_800NS:
3499 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3500 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3501 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3502 *pucMcsSet = HT_RATE_MCS4_INDEX;
3503 *pucSupMcs32 = 0;
3504 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3505 | HT_CAP_INFO_SHORT_GI_20M
3506 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3507 break;
3508
3509 case FIXED_RATE_MCS5_20M_800NS:
3510 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3511 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3512 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3513 *pucMcsSet = HT_RATE_MCS5_INDEX;
3514 *pucSupMcs32 = 0;
3515 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3516 | HT_CAP_INFO_SHORT_GI_20M
3517 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3518 break;
3519
3520 case FIXED_RATE_MCS6_20M_800NS:
3521 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3522 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3523 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3524 *pucMcsSet = HT_RATE_MCS6_INDEX;
3525 *pucSupMcs32 = 0;
3526 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3527 | HT_CAP_INFO_SHORT_GI_20M
3528 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3529 break;
3530
3531 case FIXED_RATE_MCS7_20M_800NS:
3532 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3533 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3534 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3535 *pucMcsSet = HT_RATE_MCS7_INDEX;
3536 *pucSupMcs32 = 0;
3537 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3538 | HT_CAP_INFO_SHORT_GI_20M
3539 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3540 break;
3541
3542 case FIXED_RATE_MCS0_20M_400NS:
3543 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3544 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3545 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3546 *pucMcsSet = HT_RATE_MCS0_INDEX;
3547 *pucSupMcs32 = 0;
3548 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3549 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3550 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3551 break;
3552
3553 case FIXED_RATE_MCS1_20M_400NS:
3554 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3555 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3556 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3557 *pucMcsSet = HT_RATE_MCS1_INDEX;
3558 *pucSupMcs32 = 0;
3559 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3560 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3561 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3562 break;
3563
3564 case FIXED_RATE_MCS2_20M_400NS:
3565 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3566 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3567 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3568 *pucMcsSet = HT_RATE_MCS2_INDEX;
3569 *pucSupMcs32 = 0;
3570 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3571 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3572 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3573 break;
3574
3575 case FIXED_RATE_MCS3_20M_400NS:
3576 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3577 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3578 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3579 *pucMcsSet = HT_RATE_MCS3_INDEX;
3580 *pucSupMcs32 = 0;
3581 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3582 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3583 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3584 break;
3585
3586 case FIXED_RATE_MCS4_20M_400NS:
3587 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3588 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3589 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3590 *pucMcsSet = HT_RATE_MCS4_INDEX;
3591 *pucSupMcs32 = 0;
3592 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3593 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3594 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3595 break;
3596
3597 case FIXED_RATE_MCS5_20M_400NS:
3598 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3599 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3600 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3601 *pucMcsSet = HT_RATE_MCS5_INDEX;
3602 *pucSupMcs32 = 0;
3603 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3604 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3605 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3606 break;
3607
3608 case FIXED_RATE_MCS6_20M_400NS:
3609 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3610 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3611 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3612 *pucMcsSet = HT_RATE_MCS6_INDEX;
3613 *pucSupMcs32 = 0;
3614 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3615 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3616 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3617 break;
3618
3619 case FIXED_RATE_MCS7_20M_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_MCS7_INDEX;
3624 *pucSupMcs32 = 0;
3625 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3626 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3627 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3628 break;
3629
3630 case FIXED_RATE_MCS0_40M_800NS:
3631 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3632 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3633 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3634 *pucMcsSet = HT_RATE_MCS0_INDEX;
3635 *pucSupMcs32 = 0;
3636 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3637 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3638 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3639 break;
3640
3641 case FIXED_RATE_MCS1_40M_800NS:
3642 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3643 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3644 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3645 *pucMcsSet = HT_RATE_MCS1_INDEX;
3646 *pucSupMcs32 = 0;
3647 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3648 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3649 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3650 break;
3651
3652 case FIXED_RATE_MCS2_40M_800NS:
3653 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3654 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3655 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3656 *pucMcsSet = HT_RATE_MCS2_INDEX;
3657 *pucSupMcs32 = 0;
3658 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3659 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3660 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3661 break;
3662
3663 case FIXED_RATE_MCS3_40M_800NS:
3664 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3665 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3666 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3667 *pucMcsSet = HT_RATE_MCS3_INDEX;
3668 *pucSupMcs32 = 0;
3669 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3670 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3671 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3672 break;
3673
3674 case FIXED_RATE_MCS4_40M_800NS:
3675 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3676 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3677 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3678 *pucMcsSet = HT_RATE_MCS4_INDEX;
3679 *pucSupMcs32 = 0;
3680 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3681 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3682 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3683 break;
3684
3685 case FIXED_RATE_MCS5_40M_800NS:
3686 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3687 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3688 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3689 *pucMcsSet = HT_RATE_MCS5_INDEX;
3690 *pucSupMcs32 = 0;
3691 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3692 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3693 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3694 break;
3695
3696 case FIXED_RATE_MCS6_40M_800NS:
3697 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3698 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3699 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3700 *pucMcsSet = HT_RATE_MCS6_INDEX;
3701 *pucSupMcs32 = 0;
3702 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3703 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3704 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3705 break;
3706
3707 case FIXED_RATE_MCS7_40M_800NS:
3708 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3709 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3710 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3711 *pucMcsSet = HT_RATE_MCS7_INDEX;
3712 *pucSupMcs32 = 0;
3713 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3714 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3715 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3716 break;
3717
3718 case FIXED_RATE_MCS32_800NS:
3719 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3720 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3721 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3722 *pucMcsSet = HT_RATE_MCS32_INDEX;
3723 *pucSupMcs32 = 1;
3724 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
3725 | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
3726 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
3727 break;
3728
3729 case FIXED_RATE_MCS0_40M_400NS:
3730 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3731 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3732 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3733 *pucMcsSet = HT_RATE_MCS0_INDEX;
3734 *pucSupMcs32 = 0;
3735 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3736 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3737 break;
3738
3739 case FIXED_RATE_MCS1_40M_400NS:
3740 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3741 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3742 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3743 *pucMcsSet = HT_RATE_MCS1_INDEX;
3744 *pucSupMcs32 = 0;
3745 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3746 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3747 break;
3748
3749 case FIXED_RATE_MCS2_40M_400NS:
3750 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3751 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3752 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3753 *pucMcsSet = HT_RATE_MCS2_INDEX;
3754 *pucSupMcs32 = 0;
3755 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3756 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3757 break;
3758
3759 case FIXED_RATE_MCS3_40M_400NS:
3760 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3761 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3762 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3763 *pucMcsSet = HT_RATE_MCS3_INDEX;
3764 *pucSupMcs32 = 0;
3765 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3766 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3767 break;
3768
3769 case FIXED_RATE_MCS4_40M_400NS:
3770 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3771 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3772 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3773 *pucMcsSet = HT_RATE_MCS4_INDEX;
3774 *pucSupMcs32 = 0;
3775 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3776 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3777 break;
3778
3779 case FIXED_RATE_MCS5_40M_400NS:
3780 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3781 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3782 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3783 *pucMcsSet = HT_RATE_MCS5_INDEX;
3784 *pucSupMcs32 = 0;
3785 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3786 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3787 break;
3788
3789 case FIXED_RATE_MCS6_40M_400NS:
3790 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3791 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3792 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3793 *pucMcsSet = HT_RATE_MCS6_INDEX;
3794 *pucSupMcs32 = 0;
3795 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3796 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3797 break;
3798
3799 case FIXED_RATE_MCS7_40M_400NS:
3800 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3801 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3802 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3803 *pucMcsSet = HT_RATE_MCS7_INDEX;
3804 *pucSupMcs32 = 0;
3805 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3806 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3807 break;
3808
3809 case FIXED_RATE_MCS32_400NS:
3810 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3811 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3812 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3813 *pucMcsSet = HT_RATE_MCS32_INDEX;
3814 *pucSupMcs32 = 1;
3815 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
3816 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
3817 break;
3818
3819 default:
3820 ASSERT(0);
3821 }
3822
3823 return WLAN_STATUS_SUCCESS;
3824 }
3825
3826 /*----------------------------------------------------------------------------*/
3827 /*!
3828 * @brief This utility function is used to write the register
3829 *
3830 * @param u4Address Register address
3831 * u4Value the value to be written
3832 *
3833 * @retval WLAN_STATUS_SUCCESS
3834 * WLAN_STATUS_FAILURE
3835 */
3836 /*----------------------------------------------------------------------------*/
3837
3838 WLAN_STATUS nicWriteMcr(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Address, IN UINT_32 u4Value)
3839 {
3840 CMD_ACCESS_REG rCmdAccessReg;
3841
3842 rCmdAccessReg.u4Address = u4Address;
3843 rCmdAccessReg.u4Data = u4Value;
3844
3845 return wlanSendSetQueryCmd(prAdapter,
3846 CMD_ID_ACCESS_REG,
3847 TRUE,
3848 FALSE,
3849 FALSE,
3850 NULL,
3851 NULL,
3852 sizeof(CMD_ACCESS_REG), (PUINT_8) &rCmdAccessReg, NULL, 0);
3853
3854 }
3855
3856 /*----------------------------------------------------------------------------*/
3857 /*!
3858 * @brief This utility function is used to modify the auto rate parameters
3859 *
3860 * @param u4ArSysParam0 see description below
3861 * u4ArSysParam1
3862 * u4ArSysParam2
3863 * u4ArSysParam3
3864 *
3865 *
3866 * @retval WLAN_STATUS_SUCCESS
3867 * WLAN_STATUS_FAILURE
3868 *
3869 * @note
3870 * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
3871 * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
3872 * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
3873 * ArSysParam0[8:15]-> HT rate clear mask
3874 * ArSysParam0[16:31]-> Legacy rate clear mask
3875 * ArSysParam1[0:7]-> Auto Rate check weighting window
3876 * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
3877 * ArSysParam1[16:23]-> Auto Rate v1 PerH
3878 * ArSysParam1[24:31]-> Auto Rate v1 PerL
3879 *
3880 * Examples
3881 * ArSysParam0 = 1,
3882 * Enable auto rate version 1
3883 *
3884 * ArSysParam0 = 983041,
3885 * Enable auto rate version 1
3886 * Remove CCK 1M, 2M, 5.5M, 11M
3887 *
3888 * ArSysParam0 = 786433
3889 * Enable auto rate version 1
3890 * Remove CCK 5.5M 11M
3891 */
3892 /*----------------------------------------------------------------------------*/
3893
3894
3895 WLAN_STATUS
3896 nicRlmArUpdateParms(IN P_ADAPTER_T prAdapter,
3897 IN UINT_32 u4ArSysParam0,
3898 IN UINT_32 u4ArSysParam1, IN UINT_32 u4ArSysParam2, IN UINT_32 u4ArSysParam3)
3899 {
3900 UINT_8 ucArVer, ucAbwVer, ucAgiVer;
3901 UINT_16 u2HtClrMask;
3902 UINT_16 u2LegacyClrMask;
3903 UINT_8 ucArCheckWindow;
3904 UINT_8 ucArPerL;
3905 UINT_8 ucArPerH;
3906 UINT_8 ucArPerForceRateDownPer;
3907
3908 ucArVer = (UINT_8) (u4ArSysParam0 & BITS(0, 3));
3909 ucAbwVer = (UINT_8) ((u4ArSysParam0 & BITS(4, 5)) >> 4);
3910 ucAgiVer = (UINT_8) ((u4ArSysParam0 & BITS(6, 7)) >> 6);
3911 u2HtClrMask = (UINT_16) ((u4ArSysParam0 & BITS(8, 15)) >> 8);
3912 u2LegacyClrMask = (UINT_16) ((u4ArSysParam0 & BITS(16, 31)) >> 16);
3913
3914 #if 0
3915 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0, 7));
3916 ucArPerForceRateDownPer = (UINT_8) ((u4ArSysParam1 & BITS(8, 15) >> 8));
3917 ucArPerH = (UINT_8) ((u4ArSysParam1 & BITS(16, 23)) >> 16);
3918 ucArPerL = (UINT_8) ((u4ArSysParam1 & BITS(24, 31)) >> 24);
3919 #endif
3920
3921 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0, 7));
3922 ucArPerForceRateDownPer = (UINT_8) (((u4ArSysParam1 >> 8) & BITS(0, 7)));
3923 ucArPerH = (UINT_8) (((u4ArSysParam1 >> 16) & BITS(0, 7)));
3924 ucArPerL = (UINT_8) (((u4ArSysParam1 >> 24) & BITS(0, 7)));
3925
3926
3927 DBGLOG(INIT, INFO,
3928 ("ArParam %lu %lu %lu %lu\n", u4ArSysParam0, u4ArSysParam1, u4ArSysParam2,
3929 u4ArSysParam3));
3930 DBGLOG(INIT, INFO, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer, ucAbwVer, ucAgiVer));
3931 DBGLOG(INIT, INFO, ("HtMask %x LegacyMask %x\n", u2HtClrMask, u2LegacyClrMask));
3932 DBGLOG(INIT, INFO,
3933 ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow,
3934 ucArPerForceRateDownPer, ucArPerH, ucArPerL));
3935
3936 #define SWCR_DATA_ADDR(MOD, ADDR) (0x90000000+(MOD<<8)+(ADDR))
3937 #define SWCR_DATA_CMD(CATE, WRITE, INDEX, OPT0, OPT1) ((CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 << 8) | OPT1)
3938 #define SWCR_DATA0 0x0
3939 #define SWCR_DATA1 0x4
3940 #define SWCR_DATA2 0x8
3941 #define SWCR_DATA3 0xC
3942 #define SWCR_DATA4 0x10
3943 #define SWCR_WRITE 1
3944 #define SWCR_READ 0
3945
3946 if (ucArVer > 0) {
3947 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
3948 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000) */
3949
3950 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), 1);
3951 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3952 SWCR_DATA_CMD(0, SWCR_WRITE, 5, 0, 0));
3953 } else {
3954 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), 0);
3955 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3956 SWCR_DATA_CMD(0, SWCR_WRITE, 5, 0, 0));
3957 }
3958
3959 /* ucArVer 0: none 1:PER 2:Rcpi */
3960 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArVer);
3961 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3962 SWCR_DATA_CMD(0, SWCR_WRITE, 7, 0, 0));
3963
3964 /* Candidate rate Ht mask */
3965 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), u2HtClrMask);
3966 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3967 SWCR_DATA_CMD(0, SWCR_WRITE, 0x1c, 0, 0));
3968
3969 /* Candidate rate legacy mask */
3970 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), u2LegacyClrMask);
3971 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3972 SWCR_DATA_CMD(0, SWCR_WRITE, 0x1d, 0, 0));
3973
3974 #if 0
3975 if (ucArCheckWindow != 0) {
3976 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
3977 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArCheckWindow);
3978 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3979 SWCR_DATA_CMD(0, SWCR_WRITE, 0x14, 0, 0));
3980 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArCheckWindow);
3981 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3982 SWCR_DATA_CMD(0, SWCR_WRITE, 0xc, 0, 0));
3983 }
3984
3985 if (ucArPerForceRateDownPer != 0) {
3986 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1),
3987 ucArPerForceRateDownPer);
3988 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3989 SWCR_DATA_CMD(0, SWCR_WRITE, 0x18, 0, 0));
3990 }
3991 if (ucArPerH != 0) {
3992 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerH);
3993 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3994 SWCR_DATA_CMD(0, SWCR_WRITE, 0x1, 0, 0));
3995 }
3996 if (ucArPerL != 0) {
3997 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerL);
3998 nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0),
3999 SWCR_DATA_CMD(0, SWCR_WRITE, 0x2, 0, 0));
4000 }
4001 #endif
4002
4003
4004
4005 return WLAN_STATUS_SUCCESS;
4006 }
4007
4008 /*----------------------------------------------------------------------------*/
4009 /*!
4010 * @brief This utility function is used to enable roaming
4011 *
4012 * @param u4EnableRoaming
4013 *
4014 *
4015 * @retval WLAN_STATUS_SUCCESS
4016 * WLAN_STATUS_FAILURE
4017 *
4018 * @note
4019 * u4EnableRoaming -> Enable Romaing
4020 *
4021 */
4022 /*----------------------------------------------------------------------------*/
4023 WLAN_STATUS nicRoamingUpdateParams(IN P_ADAPTER_T prAdapter, IN UINT_32 u4EnableRoaming)
4024 {
4025 P_CONNECTION_SETTINGS_T prConnSettings;
4026
4027 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
4028 prConnSettings->fgIsEnableRoaming = ((u4EnableRoaming > 0) ? (TRUE) : (FALSE));
4029
4030 return WLAN_STATUS_SUCCESS;
4031 }
4032
4033 /*----------------------------------------------------------------------------*/
4034 /*!
4035 * \brief dump firmware Assert message
4036 *
4037 * \param[in]
4038 * prAdapter
4039 *
4040 * \return
4041 * TRUE
4042 * FALSE
4043 */
4044 /*----------------------------------------------------------------------------*/
4045 VOID nicPrintFirmwareAssertInfo(IN P_ADAPTER_T prAdapter)
4046 {
4047 UINT_32 u4MailBox0, u4MailBox1;
4048 UINT_32 line = 0;
4049 UINT_8 aucAssertFile[7];
4050 UINT_32 u4ChipId;
4051
4052 #if CFG_SDIO_INTR_ENHANCE
4053 u4MailBox0 = prAdapter->prSDIOCtrl->u4RcvMailbox0;
4054 u4MailBox1 = prAdapter->prSDIOCtrl->u4RcvMailbox1;
4055 #else
4056 nicGetMailbox(prAdapter, 0, &u4MailBox0);
4057 nicGetMailbox(prAdapter, 1, &u4MailBox1);
4058 #endif
4059
4060 line = u4MailBox0 & 0x0000FFFF;
4061
4062 u4MailBox0 = ((u4MailBox0 >> 16) & 0x0000FFFF);
4063
4064 kalMemCopy(&aucAssertFile[0], &u4MailBox0, 2);
4065 kalMemCopy(&aucAssertFile[2], &u4MailBox1, 4);
4066
4067 aucAssertFile[6] = '\0';
4068
4069 #if defined(MT6620)
4070 u4ChipId = 6620;
4071 #elif defined(MT5931)
4072 u4ChipId = 5931;
4073 #elif defined(MT6628)
4074 u4ChipId = 6628;
4075 #endif
4076
4077 kalPrint("\n[MT%ld][wifi][Firmware] Assert at \"%s\" #%ld\n\n",
4078 u4ChipId, aucAssertFile, line);
4079
4080 }
4081
4082
4083 /*----------------------------------------------------------------------------*/
4084 /*!
4085 * @brief This function is called to update Link Quality information
4086 *
4087 * @param prAdapter Pointer of Adapter Data Structure
4088 * eNetTypeIdx
4089 * prEventLinkQuality
4090 * cRssi
4091 * cLinkQuality
4092 *
4093 * @return none
4094 */
4095 /*----------------------------------------------------------------------------*/
4096 VOID
4097 nicUpdateLinkQuality(IN P_ADAPTER_T prAdapter,
4098 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4099 IN P_EVENT_LINK_QUALITY prEventLinkQuality)
4100 {
4101 ASSERT(prAdapter);
4102 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4103 ASSERT(prEventLinkQuality);
4104
4105 switch (eNetTypeIdx) {
4106 case NETWORK_TYPE_AIS_INDEX:
4107 if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState ==
4108 PARAM_MEDIA_STATE_CONNECTED) {
4109 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
4110 /* buffer statistics for further query */
4111 if (prAdapter->fgIsLinkQualityValid == FALSE
4112 || (kalGetTimeTick() - prAdapter->rLinkQualityUpdateTime) >
4113 CFG_LINK_QUALITY_VALID_PERIOD) {
4114 nicUpdateRSSI(prAdapter, eNetTypeIdx, prEventLinkQuality->cRssi,
4115 prEventLinkQuality->cLinkQuality);
4116 }
4117
4118 if (prAdapter->fgIsLinkRateValid == FALSE
4119 || (kalGetTimeTick() - prAdapter->rLinkRateUpdateTime) >
4120 CFG_LINK_QUALITY_VALID_PERIOD) {
4121 nicUpdateLinkSpeed(prAdapter, eNetTypeIdx,
4122 prEventLinkQuality->u2LinkSpeed);
4123 }
4124 }
4125 break;
4126 #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
4127 case NETWORK_TYPE_P2P_INDEX:
4128 if (prAdapter->fgIsP2pLinkQualityValid == FALSE
4129 || (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) >
4130 CFG_LINK_QUALITY_VALID_PERIOD) {
4131 P_EVENT_LINK_QUALITY_EX prEventLQEx =
4132 (P_EVENT_LINK_QUALITY_EX) prEventLinkQuality;
4133
4134 nicUpdateRSSI(prAdapter, NETWORK_TYPE_P2P_INDEX, prEventLQEx->cRssiP2P,
4135 prEventLQEx->cLinkQualityP2P);
4136 }
4137 break;
4138 #endif
4139 default:
4140 break;
4141
4142 }
4143
4144 return;
4145 }
4146
4147
4148 /*----------------------------------------------------------------------------*/
4149 /*!
4150 * @brief This function is called to update RSSI and Link Quality information
4151 *
4152 * @param prAdapter Pointer of Adapter Data Structure
4153 * eNetTypeIdx
4154 * cRssi
4155 * cLinkQuality
4156 *
4157 * @return none
4158 */
4159 /*----------------------------------------------------------------------------*/
4160 VOID
4161 nicUpdateRSSI(IN P_ADAPTER_T prAdapter,
4162 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN INT_8 cRssi, IN INT_8 cLinkQuality)
4163 {
4164 ASSERT(prAdapter);
4165 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4166
4167 switch (eNetTypeIdx) {
4168 case NETWORK_TYPE_AIS_INDEX:
4169 if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState ==
4170 PARAM_MEDIA_STATE_CONNECTED) {
4171 prAdapter->fgIsLinkQualityValid = TRUE;
4172 prAdapter->rLinkQualityUpdateTime = kalGetTimeTick();
4173
4174 prAdapter->rLinkQuality.cRssi = cRssi;
4175 prAdapter->rLinkQuality.cLinkQuality = cLinkQuality;
4176
4177 /* indicate to glue layer */
4178 kalUpdateRSSI(prAdapter->prGlueInfo,
4179 KAL_NETWORK_TYPE_AIS_INDEX,
4180 prAdapter->rLinkQuality.cRssi,
4181 prAdapter->rLinkQuality.cLinkQuality);
4182 }
4183
4184 break;
4185 #if CFG_ENABLE_WIFI_DIRECT
4186 #if CFG_SUPPORT_P2P_RSSI_QUERY
4187 case NETWORK_TYPE_P2P_INDEX:
4188 prAdapter->fgIsP2pLinkQualityValid = TRUE;
4189 prAdapter->rP2pLinkQualityUpdateTime = kalGetTimeTick();
4190
4191 prAdapter->rP2pLinkQuality.cRssi = cRssi;
4192 prAdapter->rP2pLinkQuality.cLinkQuality = cLinkQuality;
4193
4194 kalUpdateRSSI(prAdapter->prGlueInfo,
4195 KAL_NETWORK_TYPE_P2P_INDEX, cRssi, cLinkQuality);
4196 break;
4197 #endif
4198 #endif
4199 default:
4200 break;
4201
4202 }
4203
4204 return;
4205 }
4206
4207
4208 /*----------------------------------------------------------------------------*/
4209 /*!
4210 * @brief This function is called to update Link Quality information
4211 *
4212 * @param prAdapter Pointer of Adapter Data Structure
4213 * eNetTypeIdx
4214 * prEventLinkQuality
4215 * cRssi
4216 * cLinkQuality
4217 *
4218 * @return none
4219 */
4220 /*----------------------------------------------------------------------------*/
4221 VOID
4222 nicUpdateLinkSpeed(IN P_ADAPTER_T prAdapter,
4223 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN UINT_16 u2LinkSpeed)
4224 {
4225 ASSERT(prAdapter);
4226 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4227
4228 switch (eNetTypeIdx) {
4229 case NETWORK_TYPE_AIS_INDEX:
4230 if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState ==
4231 PARAM_MEDIA_STATE_CONNECTED) {
4232 /* buffer statistics for further query */
4233 prAdapter->fgIsLinkRateValid = TRUE;
4234 prAdapter->rLinkRateUpdateTime = kalGetTimeTick();
4235
4236 prAdapter->rLinkQuality.u2LinkSpeed = u2LinkSpeed;
4237 }
4238 break;
4239
4240 default:
4241 break;
4242
4243 }
4244
4245 return;
4246 }
4247
4248 #if CFG_SUPPORT_RDD_TEST_MODE
4249 WLAN_STATUS nicUpdateRddTestMode(IN P_ADAPTER_T prAdapter, IN P_CMD_RDD_CH_T prRddChParam)
4250 {
4251 DEBUGFUNC("nicUpdateRddTestMode.\n");
4252
4253 ASSERT(prAdapter);
4254
4255 /* aisFsmScanRequest(prAdapter, NULL); */
4256
4257 return wlanSendSetQueryCmd(prAdapter,
4258 CMD_ID_SET_RDD_CH,
4259 TRUE,
4260 FALSE,
4261 FALSE,
4262 NULL,
4263 NULL, sizeof(CMD_RDD_CH_T), (PUINT_8) prRddChParam, NULL, 0);
4264 }
4265 #endif