import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / conn_soc / drv_wlan / mt_wifi / wlan / nic / nic.c
CommitLineData
6fa3eb70
S
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*/
626const UINT_8 aucPhyCfg2PhyTypeSet[PHY_CONFIG_NUM] =
627{
628 PHY_TYPE_SET_802_11ABG, /* PHY_CONFIG_802_11ABG */
629 PHY_TYPE_SET_802_11BG, /* PHY_CONFIG_802_11BG */
630 PHY_TYPE_SET_802_11G, /* PHY_CONFIG_802_11G */
631 PHY_TYPE_SET_802_11A, /* PHY_CONFIG_802_11A */
632 PHY_TYPE_SET_802_11B, /* PHY_CONFIG_802_11B */
633 PHY_TYPE_SET_802_11ABGN, /* PHY_CONFIG_802_11ABGN */
634 PHY_TYPE_SET_802_11BGN, /* PHY_CONFIG_802_11BGN */
635 PHY_TYPE_SET_802_11AN, /* PHY_CONFIG_802_11AN */
636 PHY_TYPE_SET_802_11GN /* PHY_CONFIG_802_11GN */
637};
638
639#if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
640 #define REQ_GATING_ENABLE_H2D_INT BIT(31)
641 #define REQ_GATING_DISABLE_H2D_INT BIT(30)
642 #define ACK_GATING_ENABLE_D2H_INT BIT(31)
643 #define ACK_GATING_DISABLE_D2H_INT BIT(30)
644
645 #define GATING_CONTROL_POLL_LIMIT 64
646#endif
647
648/*******************************************************************************
649* D A T A T Y P E S
650********************************************************************************
651*/
652
653/*******************************************************************************
654* P U B L I C D A T A
655********************************************************************************
656*/
657
658static INT_EVENT_MAP_T arIntEventMapTable[] = {
659 {WHISR_ABNORMAL_INT, INT_EVENT_ABNORMAL},
660 {WHISR_D2H_SW_INT, INT_EVENT_SW_INT},
661 {WHISR_TX_DONE_INT, INT_EVENT_TX},
662 {(WHISR_RX0_DONE_INT | WHISR_RX1_DONE_INT), INT_EVENT_RX}
663};
664
665static const UINT_8 ucIntEventMapSize = (sizeof(arIntEventMapTable) / sizeof(INT_EVENT_MAP_T));
666
667static IST_EVENT_FUNCTION apfnEventFuncTable[] = {
668 nicProcessAbnormalInterrupt, /*!< INT_EVENT_ABNORMAL */
669 nicProcessSoftwareInterrupt, /*!< INT_EVENT_SW_INT */
670 nicProcessTxInterrupt, /*!< INT_EVENT_TX */
671 nicProcessRxInterrupt, /*!< INT_EVENT_RX */
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 %u bytes for %s.\n", u4Size, pucComment)); \
688 if ((pucMem = (PUINT_8)kalMemAlloc(u4Size, eMemType)) == (PUINT_8)NULL) { \
689 DBGLOG(INIT, ERROR, ("Could not allocate %u bytes for %s.\n", u4Size, pucComment)); \
690 break; \
691 } \
692 ASSERT(((ULONG)pucMem % 4) == 0); \
693 DBGLOG(INIT, INFO, ("Virtual Address = %p for %s.\n", 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
708VOID
709HifRegDump(
710 P_ADAPTER_T prAdapter
711 )
712{
713 UINT_32 i;
714 UINT_32 RegVal;
715
716
717 for(i=0; i<=0x58; i+=4)
718 {
719 if ((i != MCR_WTDR0) && (i != MCR_WTDR1) &&
720 (i != MCR_WRDR0) && (i != MCR_WRDR1))
721 {
722 HAL_MCR_RD(prAdapter, i, &RegVal);
723 printk("HIF Reg 0x%x = 0x%x\n", i, RegVal);
724 }
725 }
726 printk("\n\n");
727}
728
729
730BOOLEAN
731HifIsFwOwn(
732 P_ADAPTER_T prAdapter
733 )
734{
735 return prAdapter->fgIsFwOwn;
736}
737
738
739/*----------------------------------------------------------------------------*/
740/*!
741* @brief This routine is responsible for the allocation of the data structures
742* inside the Adapter structure, include:
743* 1. SW_RFB_Ts
744* 2. Common coalescing buffer for TX PATH.
745*
746* @param prAdapter Pointer of Adapter Data Structure
747*
748* @retval WLAN_STATUS_SUCCESS - Has enough memory.
749* @retval WLAN_STATUS_RESOURCES - Memory is not enough.
750*/
751/*----------------------------------------------------------------------------*/
752WLAN_STATUS
753nicAllocateAdapterMemory (
754 IN P_ADAPTER_T prAdapter
755 )
756{
757 WLAN_STATUS status = WLAN_STATUS_RESOURCES;
758 P_RX_CTRL_T prRxCtrl;
759 P_TX_CTRL_T prTxCtrl;
760
761 DEBUGFUNC("nicAllocateAdapterMemory");
762
763 ASSERT(prAdapter);
764 prRxCtrl = &prAdapter->rRxCtrl;
765 prTxCtrl = &prAdapter->rTxCtrl;
766
767 do {
768 //4 <0> Reset all Memory Handler
769 #if CFG_DBG_MGT_BUF
770 prAdapter->u4MemFreeDynamicCount = 0;
771 prAdapter->u4MemAllocDynamicCount = 0;
772 #endif
773 prAdapter->pucMgtBufCached = (PUINT_8)NULL;
774 prRxCtrl->pucRxCached = (PUINT_8)NULL;
775 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)NULL;
776
777
778 //4 <1> Memory for Management Memory Pool and CMD_INFO_T
779 /* Allocate memory for the CMD_INFO_T and its MGMT memory pool. */
780 prAdapter->u4MgtBufCachedSize = MGT_BUFFER_SIZE;
781
782 LOCAL_NIC_ALLOCATE_MEMORY(prAdapter->pucMgtBufCached,
783 prAdapter->u4MgtBufCachedSize,
784 VIR_MEM_TYPE,
785 "COMMON MGMT MEMORY POOL");
786
787 //4 <2> Memory for RX Descriptor
788 /* Initialize the number of rx buffers we will have in our queue. */
789 /* <TODO> We may setup ucRxPacketDescriptors by GLUE Layer, and using
790 * this variable directly.
791 */
792 /* Allocate memory for the SW receive structures. */
793 prRxCtrl->u4RxCachedSize = CFG_RX_MAX_PKT_NUM * \
794 ALIGN_4(sizeof(SW_RFB_T));
795
796 LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl->pucRxCached,
797 prRxCtrl->u4RxCachedSize,
798 VIR_MEM_TYPE,
799 "SW_RFB_T");
800
801 //4 <3> Memory for TX DEscriptor
802 prTxCtrl->u4TxCachedSize = CFG_TX_MAX_PKT_NUM * \
803 ALIGN_4(sizeof(MSDU_INFO_T));
804
805 LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl->pucTxCached,
806 prTxCtrl->u4TxCachedSize,
807 VIR_MEM_TYPE,
808 "MSDU_INFO_T");
809
810 //4 <4> Memory for Common Coalescing Buffer
811#if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
812 prAdapter->pucCoalescingBufCached = (PUINT_8)NULL;
813
814 /* Allocate memory for the common coalescing buffer. */
815 prAdapter->u4CoalescingBufCachedSize = CFG_COALESCING_BUFFER_SIZE > CFG_RX_COALESCING_BUFFER_SIZE ?
816 CFG_COALESCING_BUFFER_SIZE : CFG_RX_COALESCING_BUFFER_SIZE;
817
818 prAdapter->pucCoalescingBufCached =
819 kalAllocateIOBuffer(prAdapter->u4CoalescingBufCachedSize);
820
821 if(prAdapter->pucCoalescingBufCached == NULL) {
822 DBGLOG(INIT, ERROR, ("Could not allocate %u bytes for coalescing buffer.\n", prAdapter->u4CoalescingBufCachedSize));
823 break;
824 }
825#endif /* CFG_COALESCING_BUFFER_SIZE */
826
827 //4 <5> Memory for enhanced interrupt response
828 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
829 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
830
831 if(prAdapter->prSDIOCtrl == NULL) {
832 DBGLOG(INIT, ERROR, ("Could not allocate %zu bytes for interrupt response.\n", sizeof(ENHANCE_MODE_DATA_STRUCT_T)));
833 break;
834 }
835
836 status = WLAN_STATUS_SUCCESS;
837
838 }
839 while(FALSE);
840
841 if(status != WLAN_STATUS_SUCCESS) {
842 nicReleaseAdapterMemory(prAdapter);
843 }
844
845 return status;
846
847} /* end of nicAllocateAdapterMemory() */
848
849
850/*----------------------------------------------------------------------------*/
851/*!
852* @brief This routine is responsible for releasing the allocated memory by
853* nicAllocatedAdapterMemory().
854*
855* @param prAdapter Pointer of Adapter Data Structure
856*
857* @return (none)
858*/
859/*----------------------------------------------------------------------------*/
860VOID
861nicReleaseAdapterMemory (
862 IN P_ADAPTER_T prAdapter
863 )
864{
865 P_TX_CTRL_T prTxCtrl;
866 P_RX_CTRL_T prRxCtrl;
867
868 ASSERT(prAdapter);
869 prTxCtrl = &prAdapter->rTxCtrl;
870 prRxCtrl = &prAdapter->rRxCtrl;
871
872 //4 <5> Memory for enhanced interrupt response
873 if (prAdapter->prSDIOCtrl) {
874 kalReleaseIOBuffer((PVOID)prAdapter->prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
875 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)NULL;
876 }
877
878 //4 <4> Memory for Common Coalescing Buffer
879#if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
880 if (prAdapter->pucCoalescingBufCached) {
881 kalReleaseIOBuffer((PVOID)prAdapter->pucCoalescingBufCached, prAdapter->u4CoalescingBufCachedSize);
882 prAdapter->pucCoalescingBufCached = (PUINT_8)NULL;
883 }
884#endif /* CFG_COALESCING_BUFFER_SIZE */
885
886 //4 <3> Memory for TX Descriptor
887 if (prTxCtrl->pucTxCached) {
888 kalMemFree((PVOID)prTxCtrl->pucTxCached,
889 VIR_MEM_TYPE,
890 prTxCtrl->u4TxCachedSize);
891 prTxCtrl->pucTxCached = (PUINT_8)NULL;
892 }
893
894 //4 <2> Memory for RX Descriptor
895 if (prRxCtrl->pucRxCached) {
896 kalMemFree((PVOID)prRxCtrl->pucRxCached,
897 VIR_MEM_TYPE,
898 prRxCtrl->u4RxCachedSize);
899 prRxCtrl->pucRxCached = (PUINT_8)NULL;
900 }
901
902 //4 <1> Memory for Management Memory Pool
903 if (prAdapter->pucMgtBufCached) {
904 kalMemFree((PVOID)prAdapter->pucMgtBufCached,
905 VIR_MEM_TYPE,
906 prAdapter->u4MgtBufCachedSize);
907 prAdapter->pucMgtBufCached = (PUINT_8)NULL;
908 }
909
910#if CFG_DBG_MGT_BUF
911 /* Check if all allocated memories are free */
912 ASSERT(prAdapter->u4MemFreeDynamicCount ==
913 prAdapter->u4MemAllocDynamicCount);
914#endif
915
916 return;
917}
918
919
920/*----------------------------------------------------------------------------*/
921/*!
922* @brief disable global interrupt
923*
924* @param prAdapter pointer to the Adapter handler
925*
926* @return (none)
927*/
928/*----------------------------------------------------------------------------*/
929VOID
930nicDisableInterrupt (
931 IN P_ADAPTER_T prAdapter
932 )
933{
934 ASSERT(prAdapter);
935
936 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_CLR);
937
938 prAdapter->fgIsIntEnable = FALSE;
939}
940
941/*----------------------------------------------------------------------------*/
942/*!
943* @brief enable global interrupt
944*
945* @param prAdapter pointer to the Adapter handler
946*
947* @return (none)
948*/
949/*----------------------------------------------------------------------------*/
950VOID
951nicEnableInterrupt (
952 IN P_ADAPTER_T prAdapter
953 )
954{
955 BOOLEAN fgIsIntEnableCache;
956
957
958 ASSERT(prAdapter);
959 fgIsIntEnableCache = prAdapter->fgIsIntEnable;
960
961 prAdapter->fgIsIntEnable = TRUE; // NOTE(Kevin): It must be placed before MCR GINT write.
962
963 /* If need enable INT and also set LPOwn at the same time. */
964 if (prAdapter->fgIsIntEnableWithLPOwnSet) {
965 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE; /* NOTE(Kevin): It's better to place it
966 * before MCR GINT write.
967 */
968 /* If INT was enabled, only set LPOwn */
969 if (fgIsIntEnableCache) {
970 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET);
971 prAdapter->fgIsFwOwn = TRUE;
972 }
973 /* If INT was not enabled, enable it and also set LPOwn now */
974 else {
975 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET |
976 WHLPCR_INT_EN_SET);
977 prAdapter->fgIsFwOwn = TRUE;
978 }
979 }
980 /* If INT was not enabled, enable it now */
981 else if (!fgIsIntEnableCache) {
982 HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_SET);
983 }
984
985 return;
986} /* end of nicEnableInterrupt() */
987
988
989#if CFG_SDIO_INTR_ENHANCE
990/*----------------------------------------------------------------------------*/
991/*!
992* @brief For SDIO enhance mode, set the max rx len and tx status
993*
994* @param prAdapter a pointer to adapter private data structure.
995*
996* @return - none
997*/
998/*----------------------------------------------------------------------------*/
999VOID
1000nicSDIOInit (
1001 IN P_ADAPTER_T prAdapter
1002 )
1003{
1004 UINT_32 u4Value = 0;
1005
1006 ASSERT(prAdapter);
1007
1008 //4 <1> Check STATUS Buffer is DW alignment.
1009 ASSERT( IS_ALIGN_4( (ULONG)&prAdapter->prSDIOCtrl->u4WHISR ) );
1010
1011 //4 <2> Setup STATUS count.
1012 {
1013 HAL_MCR_RD(prAdapter, MCR_WHCR, &u4Value);
1014
1015 //4 <2.1> Setup the number of maximum RX length to be report
1016 u4Value &= ~(WHCR_MAX_HIF_RX_LEN_NUM);
1017 u4Value |= ((SDIO_MAXIMUM_RX_LEN_NUM << WHCR_OFFSET_MAX_HIF_RX_LEN_NUM));
1018
1019 //4 <2.2> Setup RX enhancement mode
1020#if CFG_SDIO_RX_ENHANCE
1021 u4Value |= WHCR_RX_ENHANCE_MODE_EN;
1022#else
1023 u4Value &= ~WHCR_RX_ENHANCE_MODE_EN;
1024#endif /* CFG_SDIO_RX_AGG */
1025
1026 HAL_MCR_WR(prAdapter, MCR_WHCR, u4Value);
1027 }
1028
1029 return;
1030
1031} /* end of nicSDIOInit() */
1032
1033/*----------------------------------------------------------------------------*/
1034/*!
1035* @brief Read interrupt status from hardware
1036*
1037* @param prAdapter pointer to the Adapter handler
1038* @param the interrupts
1039*
1040* @return N/A
1041*
1042*/
1043/*----------------------------------------------------------------------------*/
1044VOID
1045nicSDIOReadIntStatus (
1046 IN P_ADAPTER_T prAdapter,
1047 OUT PUINT_32 pu4IntStatus
1048 )
1049{
1050 P_SDIO_CTRL_T prSDIOCtrl;
1051
1052 DEBUGFUNC("nicSDIOReadIntStatus");
1053
1054 ASSERT(prAdapter);
1055 ASSERT(pu4IntStatus);
1056
1057 /*
1058 prSDIOCtrl is from IO buffer.
1059 prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
1060 kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
1061 */
1062 prSDIOCtrl = prAdapter->prSDIOCtrl;
1063 ASSERT(prSDIOCtrl);
1064
1065 HAL_PORT_RD(prAdapter,
1066 MCR_WHISR,
1067 sizeof(ENHANCE_MODE_DATA_STRUCT_T),
1068 (PUINT_8)prSDIOCtrl,
1069 sizeof(ENHANCE_MODE_DATA_STRUCT_T));
1070
1071 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
1072 || fgIsBusAccessFailed == TRUE) {
1073 *pu4IntStatus = 0;
1074 return;
1075 }
1076
1077 /* workaround */
1078 if((prSDIOCtrl->u4WHISR & WHISR_TX_DONE_INT) == 0 &&
1079 (prSDIOCtrl->rTxInfo.au4WTSR[0] | prSDIOCtrl->rTxInfo.au4WTSR[1])) {
1080 prSDIOCtrl->u4WHISR |= WHISR_TX_DONE_INT;
1081 }
1082
1083 if((prSDIOCtrl->u4WHISR & BIT(31)) == 0 &&
1084 HAL_GET_MAILBOX_READ_CLEAR(prAdapter) == TRUE &&
1085 (prSDIOCtrl->u4RcvMailbox0 != 0 || prSDIOCtrl->u4RcvMailbox1 != 0)) {
1086 prSDIOCtrl->u4WHISR |= BIT(31);
1087 }
1088
1089 *pu4IntStatus = prSDIOCtrl->u4WHISR;
1090
1091 return;
1092} /* end of nicSDIOReadIntStatus() */
1093#endif
1094
1095/*----------------------------------------------------------------------------*/
1096/*!
1097* @brief The function used to read interrupt status and then invoking
1098* dispatching procedure for the appropriate functions
1099* corresponding to specific interrupt bits
1100*
1101* @param prAdapter pointer to the Adapter handler
1102*
1103* @retval WLAN_STATUS_SUCCESS
1104* @retval WLAN_STATUS_ADAPTER_NOT_READY
1105*/
1106/*----------------------------------------------------------------------------*/
1107WLAN_STATUS
1108nicProcessIST (
1109 IN P_ADAPTER_T prAdapter
1110 )
1111{
1112 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1113 UINT_32 u4IntStatus = 0;
1114 UINT_32 i;
1115
1116 DEBUGFUNC("nicProcessIST");
1117 //DBGLOG(INIT, LOUD, ("\n"));
1118
1119 ASSERT(prAdapter);
1120
1121 if (prAdapter->rAcpiState == ACPI_STATE_D3) {
1122 DBGLOG(REQ, WARN, ("Fail in set nicProcessIST! (Adapter not ready). ACPI=D%d, Radio=%d\n",
1123 prAdapter->rAcpiState, prAdapter->fgIsRadioOff));
1124 return WLAN_STATUS_ADAPTER_NOT_READY;
1125 }
1126
1127#if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1128 if(prAdapter->fgIsClockGatingEnabled == TRUE) {
1129 nicDisableClockGating(prAdapter);
1130 }
1131#endif
1132
1133 for (i = 0; i < CFG_IST_LOOP_COUNT; i++) { /* CFG_IST_LOOP_COUNT = 1 */
1134
1135#if CFG_SDIO_INTR_ENHANCE
1136 nicSDIOReadIntStatus(prAdapter, &u4IntStatus);
1137#else
1138 HAL_MCR_RD(prAdapter, MCR_WHISR, &u4IntStatus);
1139#endif /* CFG_SDIO_INTR_ENHANCE */
1140
1141// DBGLOG(INIT, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus));
1142
1143 if (u4IntStatus & ~(WHIER_DEFAULT | WHIER_FW_OWN_BACK_INT_EN)) {
1144 DBGLOG(INTR, WARN, ("Un-handled HISR %#x, HISR = %#x (HIER:0x%x)\n",
1145 (UINT_32)(u4IntStatus & ~WHIER_DEFAULT), u4IntStatus, (UINT_32)WHIER_DEFAULT));
1146 u4IntStatus &= WHIER_DEFAULT;
1147 }
1148
1149 nicProcessIST_impl(prAdapter, u4IntStatus);
1150
1151 if(u4IntStatus == 0) {
1152 if(i == 0) {
1153 u4Status = WLAN_STATUS_NOT_INDICATING;
1154 }
1155 break;
1156 }
1157 }
1158
1159#if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1160 if(prAdapter->fgIsClockGatingEnabled == FALSE) {
1161 nicEnableClockGating(prAdapter);
1162 }
1163#endif
1164
1165 return u4Status;
1166} /* end of nicProcessIST() */
1167
1168
1169/*----------------------------------------------------------------------------*/
1170/*!
1171* @brief The function used to dispatch the appropriate functions for specific
1172* interrupt bits
1173*
1174* @param prAdapter pointer to the Adapter handler
1175* u4IntStatus interrupt status bits
1176*
1177* @retval WLAN_STATUS_SUCCESS
1178* @retval WLAN_STATUS_ADAPTER_NOT_READY
1179*/
1180/*----------------------------------------------------------------------------*/
1181WLAN_STATUS
1182nicProcessIST_impl (
1183 IN P_ADAPTER_T prAdapter,
1184 IN UINT_32 u4IntStatus
1185 )
1186{
1187 UINT_32 u4IntCount = 0;
1188 P_INT_EVENT_MAP_T prIntEventMap = NULL;
1189
1190 ASSERT(prAdapter);
1191
1192 prAdapter->u4IntStatus = u4IntStatus;
1193
1194 /* Process each of the interrupt status consequently */
1195 prIntEventMap = &arIntEventMapTable[0];
1196 for (u4IntCount = 0; u4IntCount < ucIntEventMapSize; prIntEventMap++, u4IntCount++) {
1197 if (prIntEventMap->u4Int & prAdapter->u4IntStatus) {
1198 if(prIntEventMap->u4Event == INT_EVENT_RX &&
1199 prAdapter->fgIsEnterD3ReqIssued == TRUE) {
1200 // ignore
1201 }
1202 else if (apfnEventFuncTable[prIntEventMap->u4Event] != NULL) {
1203 apfnEventFuncTable[prIntEventMap->u4Event](prAdapter);
1204 }
1205 else {
1206 DBGLOG(INTR , WARN,
1207 ("Empty INTR handler! ISAR bit#: %u, event:%u, func: %p\n",
1208 prIntEventMap->u4Int, prIntEventMap->u4Event, apfnEventFuncTable[prIntEventMap->u4Event]));
1209
1210 ASSERT(0); // to trap any NULL interrupt handler
1211 }
1212 prAdapter->u4IntStatus &= ~prIntEventMap->u4Int;
1213 }
1214 }
1215
1216 return WLAN_STATUS_SUCCESS;
1217} /* end of nicProcessIST_impl() */
1218
1219
1220/*----------------------------------------------------------------------------*/
1221/*!
1222* @brief Verify the CHIP ID
1223*
1224* @param prAdapter a pointer to adapter private data structure.
1225*
1226*
1227* @retval TRUE CHIP ID is the same as the setting compiled
1228* @retval FALSE CHIP ID is different from the setting compiled
1229*/
1230/*----------------------------------------------------------------------------*/
1231BOOLEAN
1232nicVerifyChipID (
1233 IN P_ADAPTER_T prAdapter
1234 )
1235{
1236 UINT_32 u4CIR = 0;
1237
1238 ASSERT(prAdapter);
1239
1240 HAL_MCR_RD(prAdapter, MCR_WCIR, &u4CIR );
1241
1242 DBGLOG(INIT, TRACE,("Chip ID: 0x%x\n", (UINT_32)(u4CIR & WCIR_CHIP_ID)));
1243 DBGLOG(INIT, TRACE,("Revision ID: 0x%x\n", (UINT_32)((u4CIR & WCIR_REVISION_ID) >> 16)));
1244
1245#if 0
1246 if (((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV_72) &&
1247 ((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV_82)) {
1248 return FALSE;
1249 }
1250#endif
1251
1252 prAdapter->ucRevID = (UINT_8)(((u4CIR & WCIR_REVISION_ID) >> 16) & 0xF) ;
1253
1254 return TRUE;
1255}
1256
1257/*----------------------------------------------------------------------------*/
1258/*!
1259* @brief Initialize the MCR to the appropriate init value, and verify the init
1260* value
1261*
1262* @param prAdapter a pointer to adapter private data structure.
1263*
1264* @return -
1265*/
1266/*----------------------------------------------------------------------------*/
1267VOID
1268nicMCRInit (
1269 IN P_ADAPTER_T prAdapter
1270 )
1271{
1272
1273 ASSERT(prAdapter);
1274
1275 //4 <0> Initial value
1276}
1277
1278VOID
1279nicHifInit (
1280 IN P_ADAPTER_T prAdapter
1281 )
1282{
1283
1284 ASSERT(prAdapter);
1285#if 0
1286 /* reset event */
1287 nicPutMailbox(prAdapter, 0, 0x52455345); // RESE
1288 nicPutMailbox(prAdapter, 1, 0x545F5746); // T_WF
1289 nicSetSwIntr(prAdapter, BIT(16));
1290#endif
1291}
1292
1293
1294/*----------------------------------------------------------------------------*/
1295/*!
1296* @brief Initialize the Adapter soft variable
1297*
1298* @param prAdapter pointer to the Adapter handler
1299*
1300* @return (none)
1301*
1302*/
1303/*----------------------------------------------------------------------------*/
1304WLAN_STATUS
1305nicInitializeAdapter (
1306 IN P_ADAPTER_T prAdapter
1307 )
1308{
1309 WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
1310
1311 ASSERT(prAdapter);
1312
1313 prAdapter->fgIsIntEnableWithLPOwnSet = FALSE;
1314
1315 do {
1316 if (!nicVerifyChipID(prAdapter)) {
1317 u4Status = WLAN_STATUS_FAILURE;
1318 break;
1319 }
1320
1321 //4 <1> MCR init
1322 nicMCRInit(prAdapter);
1323
1324 #if CFG_SDIO_INTR_ENHANCE
1325 nicSDIOInit(prAdapter);
1326 #endif /* CFG_SDIO_INTR_ENHANCE */
1327
1328 HAL_MCR_WR(prAdapter, MCR_WHIER, WHIER_DEFAULT);
1329
1330
1331 //4 <2> init FW HIF
1332 nicHifInit(prAdapter);
1333 }
1334 while (FALSE);
1335
1336
1337 return u4Status;
1338}
1339
1340
1341#if defined(_HIF_SPI)
1342/*----------------------------------------------------------------------------*/
1343/*!
1344* \brief Restore the SPI Mode Select to default mode,
1345* this is important while driver is unload, and this must be last mcr
1346* since the operation will let the hif use 8bit mode access
1347*
1348* \param[in] prAdapter a pointer to adapter private data structure.
1349* \param[in] eGPIO2_Mode GPIO2 operation mode
1350*
1351* \return (none)
1352*/
1353/*----------------------------------------------------------------------------*/
1354void
1355nicRestoreSpiDefMode (
1356 IN P_ADAPTER_T prAdapter
1357 )
1358{
1359 ASSERT(prAdapter);
1360
1361 HAL_MCR_WR(prAdapter, MCR_WCSR, SPICSR_8BIT_MODE_DATA);
1362
1363}
1364#endif
1365
1366/*----------------------------------------------------------------------------*/
1367/*!
1368* @brief Process rx interrupt. When the rx
1369* Interrupt is asserted, it means there are frames in queue.
1370*
1371* @param prAdapter Pointer to the Adapter structure.
1372*
1373* @return (none)
1374*/
1375/*----------------------------------------------------------------------------*/
1376VOID
1377nicProcessAbnormalInterrupt (
1378 IN P_ADAPTER_T prAdapter
1379 )
1380{
1381 UINT_32 u4Value;
1382
1383 HAL_MCR_RD(prAdapter, MCR_WASR, &u4Value);
1384 DBGLOG(REQ, WARN, ("MCR_WASR: 0x%x \n", u4Value));
1385}
1386
1387/*----------------------------------------------------------------------------*/
1388/*!
1389* @brief .
1390*
1391* @param prAdapter Pointer to the Adapter structure.
1392*
1393* @return (none)
1394*/
1395/*----------------------------------------------------------------------------*/
1396VOID
1397nicProcessFwOwnBackInterrupt(
1398 IN P_ADAPTER_T prAdapter
1399 )
1400{
1401
1402 return;
1403} /* end of nicProcessFwOwnBackInterrupt() */
1404
1405/*----------------------------------------------------------------------------*/
1406/*!
1407* @brief .
1408*
1409* @param prAdapter Pointer to the Adapter structure.
1410*
1411* @return (none)
1412*/
1413/*----------------------------------------------------------------------------*/
1414VOID
1415nicProcessSoftwareInterrupt(
1416 IN P_ADAPTER_T prAdapter
1417 )
1418{
1419 UINT_32 u4IntrBits;
1420
1421 ASSERT(prAdapter);
1422
1423 u4IntrBits = prAdapter->u4IntStatus & BITS(8, 31);
1424
1425 if((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
1426 nicPrintFirmwareAssertInfo(prAdapter);
1427#if CFG_CHIP_RESET_SUPPORT
1428 glSendResetRequest();
1429#endif
1430 }
1431
1432#if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
1433 ASSERT((u4IntrBits & (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT))
1434 != (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT));
1435
1436 if(u4IntrBits & ACK_GATING_ENABLE_D2H_INT) {
1437 prAdapter->fgIsClockGatingEnabled = TRUE;
1438 }
1439
1440 if(u4IntrBits & ACK_GATING_DISABLE_D2H_INT) {
1441 prAdapter->fgIsClockGatingEnabled = FALSE;
1442
1443 // Indicate Service Thread for TX
1444 if(kalGetTxPendingCmdCount(prAdapter->prGlueInfo) > 0
1445 || wlanGetTxPendingFrameCount(prAdapter) > 0) {
1446 kalSetEvent(prAdapter->prGlueInfo);
1447 }
1448 }
1449#endif
1450
1451 DBGLOG(REQ, WARN, ("u4IntrBits: 0x%x \n", u4IntrBits));
1452
1453 return;
1454} /* end of nicProcessSoftwareInterrupt() */
1455
1456VOID
1457nicPutMailbox (
1458 IN P_ADAPTER_T prAdapter,
1459 IN UINT_32 u4MailboxNum,
1460 IN UINT_32 u4Data
1461 )
1462{
1463 if (u4MailboxNum == 0) {
1464 HAL_MCR_WR(prAdapter, MCR_H2DSM0R, u4Data);
1465 } else if (u4MailboxNum == 1) {
1466 HAL_MCR_WR(prAdapter, MCR_H2DSM1R, u4Data);
1467 } else {
1468 ASSERT(0);
1469 }
1470}
1471
1472VOID
1473nicGetMailbox (
1474 IN P_ADAPTER_T prAdapter,
1475 IN UINT_32 u4MailboxNum,
1476 OUT PUINT_32 pu4Data
1477 )
1478{
1479 if (u4MailboxNum == 0) {
1480 HAL_MCR_RD(prAdapter, MCR_D2HRM0R, pu4Data);
1481 } else if (u4MailboxNum == 1) {
1482 HAL_MCR_RD(prAdapter, MCR_D2HRM1R, pu4Data);
1483 } else {
1484 ASSERT(0);
1485 }
1486}
1487
1488VOID
1489nicSetSwIntr (
1490 IN P_ADAPTER_T prAdapter,
1491 IN UINT_32 u4SwIntrBitmap
1492 )
1493{
1494 /* NOTE:
1495 * SW interrup in HW bit 16 is mapping to SW bit 0 (shift 16bit in HW transparancy)
1496 * SW interrupt valid from b0~b15
1497 */
1498 ASSERT((u4SwIntrBitmap & BITS(0, 15)) == 0);
1499// DBGLOG(INIT, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap));
1500
1501 HAL_MCR_WR(prAdapter, MCR_WSICR, u4SwIntrBitmap);
1502}
1503
1504
1505/*----------------------------------------------------------------------------*/
1506/*!
1507* @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
1508* with specified sequential number
1509*
1510* @param prAdapter Pointer of ADAPTER_T
1511* ucSeqNum Sequential Number
1512*
1513* @retval - P_CMD_INFO_T
1514*/
1515/*----------------------------------------------------------------------------*/
1516P_CMD_INFO_T
1517nicGetPendingCmdInfo (
1518 IN P_ADAPTER_T prAdapter,
1519 IN UINT_8 ucSeqNum
1520 )
1521{
1522 P_QUE_T prCmdQue;
1523 QUE_T rTempCmdQue;
1524 P_QUE_T prTempCmdQue = &rTempCmdQue;
1525 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1526 P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T)NULL;
1527
1528 GLUE_SPIN_LOCK_DECLARATION();
1529
1530 ASSERT(prAdapter);
1531
1532 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1533
1534 prCmdQue = &prAdapter->rPendingCmdQueue;
1535 QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
1536
1537 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1538 while (prQueueEntry) {
1539 prCmdInfo = (P_CMD_INFO_T)prQueueEntry;
1540
1541 if(prCmdInfo->ucCmdSeqNum == ucSeqNum)
1542 break;
1543 else {
1544 QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
1545
1546 prCmdInfo = NULL;
1547 }
1548
1549 QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
1550 }
1551 QUEUE_CONCATENATE_QUEUES(prCmdQue, prTempCmdQue);
1552
1553 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
1554
1555 return prCmdInfo;
1556}
1557
1558
1559/*----------------------------------------------------------------------------*/
1560/*!
1561* @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
1562* with specified sequential number
1563*
1564* @param prAdapter Pointer of ADAPTER_T
1565* ucSeqNum Sequential Number
1566*
1567* @retval - P_MSDU_INFO_T
1568*/
1569/*----------------------------------------------------------------------------*/
1570P_MSDU_INFO_T
1571nicGetPendingTxMsduInfo (
1572 IN P_ADAPTER_T prAdapter,
1573 IN UINT_8 ucSeqNum
1574 )
1575{
1576 P_QUE_T prTxingQue;
1577 QUE_T rTempQue;
1578 P_QUE_T prTempQue = &rTempQue;
1579 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1580 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1581
1582 GLUE_SPIN_LOCK_DECLARATION();
1583
1584 ASSERT(prAdapter);
1585
1586 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1587
1588 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1589 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1590
1591 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1592 while (prQueueEntry) {
1593 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1594
1595 if(prMsduInfo->ucTxSeqNum == ucSeqNum)
1596 break;
1597 else {
1598 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1599
1600 prMsduInfo = NULL;
1601 }
1602
1603 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1604 }
1605 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1606
1607 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1608
1609 return prMsduInfo;
1610}
1611
1612P_MSDU_INFO_T
1613nicGetPendingStaMMPDU (
1614 IN P_ADAPTER_T prAdapter,
1615 IN UINT_8 ucStaRecIdx
1616 )
1617{
1618 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T)NULL;
1619 P_QUE_T prTxingQue = (P_QUE_T)NULL;
1620 QUE_T rTempQue;
1621 P_QUE_T prTempQue = &rTempQue;
1622 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1623 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1624
1625 GLUE_SPIN_LOCK_DECLARATION();
1626
1627 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1628 do {
1629 if (prAdapter == NULL) {
1630
1631 ASSERT(FALSE);
1632 break;
1633 }
1634
1635 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1636 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1637
1638 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1639 while (prQueueEntry) {
1640 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1641
1642 if ((prMsduInfo->ucStaRecIndex == ucStaRecIdx) && (prMsduInfo->pfTxDoneHandler != NULL)) {
1643 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo,
1644 prMsduInfoListHead);
1645 prMsduInfoListHead = prMsduInfo;
1646 }
1647 else {
1648 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1649
1650 prMsduInfo = NULL;
1651 }
1652
1653
1654 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1655 }
1656
1657 } while (FALSE);
1658 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1659
1660
1661 return prMsduInfoListHead;
1662} /* nicGetPendingStaMMPDU */
1663
1664
1665VOID
1666nicFreePendingTxMsduInfoByNetwork (
1667 IN P_ADAPTER_T prAdapter,
1668 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType
1669 )
1670{
1671 P_QUE_T prTxingQue;
1672 QUE_T rTempQue;
1673 P_QUE_T prTempQue = &rTempQue;
1674 P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T)NULL;
1675 P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T)NULL;
1676 P_MSDU_INFO_T prMsduInfoListTail = (P_MSDU_INFO_T)NULL;
1677 P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T)NULL;
1678
1679 GLUE_SPIN_LOCK_DECLARATION();
1680
1681 ASSERT(prAdapter);
1682
1683 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1684
1685 prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
1686 QUEUE_MOVE_ALL(prTempQue, prTxingQue);
1687
1688 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1689 while (prQueueEntry) {
1690 prMsduInfo = (P_MSDU_INFO_T)prQueueEntry;
1691
1692 if((ENUM_NETWORK_TYPE_INDEX_T)(prMsduInfo->ucNetworkType) == eNetworkType) {
1693 if(prMsduInfoListHead == NULL) {
1694 prMsduInfoListHead = prMsduInfoListTail = prMsduInfo;
1695 }
1696 else {
1697 QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail, prMsduInfo);
1698 prMsduInfoListTail = prMsduInfo;
1699 }
1700 }
1701 else {
1702 QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
1703
1704 prMsduInfo = NULL;
1705 }
1706
1707 QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
1708 }
1709 QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
1710
1711 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
1712
1713 /* free */
1714 if(prMsduInfoListHead) {
1715 nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
1716 }
1717
1718 return;
1719
1720} /* end of nicFreePendingTxMsduInfoByNetwork() */
1721
1722
1723
1724/*----------------------------------------------------------------------------*/
1725/*!
1726* @brief This procedure is used to retrieve a CMD sequence number atomically
1727*
1728* @param prAdapter Pointer of ADAPTER_T
1729*
1730* @retval - UINT_8
1731*/
1732/*----------------------------------------------------------------------------*/
1733UINT_8
1734nicIncreaseCmdSeqNum (
1735 IN P_ADAPTER_T prAdapter
1736 )
1737{
1738 UINT_8 ucRetval;
1739
1740 KAL_SPIN_LOCK_DECLARATION();
1741
1742 ASSERT(prAdapter);
1743
1744 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1745
1746 prAdapter->ucCmdSeqNum++;
1747 ucRetval = prAdapter->ucCmdSeqNum;
1748
1749 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
1750
1751 return ucRetval;
1752}
1753
1754
1755/*----------------------------------------------------------------------------*/
1756/*!
1757* @brief This procedure is used to retrieve a TX sequence number atomically
1758*
1759* @param prAdapter Pointer of ADAPTER_T
1760*
1761* @retval - UINT_8
1762*/
1763/*----------------------------------------------------------------------------*/
1764UINT_8
1765nicIncreaseTxSeqNum (
1766 IN P_ADAPTER_T prAdapter
1767 )
1768{
1769 UINT_8 ucRetval;
1770
1771 KAL_SPIN_LOCK_DECLARATION();
1772
1773 ASSERT(prAdapter);
1774
1775 KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1776
1777 prAdapter->ucTxSeqNum++;
1778 ucRetval = prAdapter->ucTxSeqNum;
1779
1780 KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
1781
1782 return ucRetval;
1783}
1784
1785
1786
1787/*----------------------------------------------------------------------------*/
1788/*!
1789* @brief This utility function is used to handle
1790* media state change event
1791*
1792* @param
1793*
1794* @retval
1795*/
1796/*----------------------------------------------------------------------------*/
1797WLAN_STATUS
1798nicMediaStateChange (
1799 IN P_ADAPTER_T prAdapter,
1800 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType,
1801 IN P_EVENT_CONNECTION_STATUS prConnectionStatus
1802 )
1803{
1804 P_GLUE_INFO_T prGlueInfo;
1805
1806 ASSERT(prAdapter);
1807 prGlueInfo = prAdapter->prGlueInfo;
1808
1809 switch(eNetworkType) {
1810 case NETWORK_TYPE_AIS_INDEX:
1811 if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_DISCONNECTED) { // disconnected
1812 if(kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
1813
1814 DBGLOG(INIT, TRACE, ("DisByMC\n"));
1815 kalIndicateStatusAndComplete(prGlueInfo,
1816 WLAN_STATUS_MEDIA_DISCONNECT,
1817 NULL,
1818 0);
1819
1820 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1821 }
1822
1823 /* reset buffered link quality information */
1824 prAdapter->fgIsLinkQualityValid = FALSE;
1825 prAdapter->fgIsLinkRateValid = FALSE;
1826 }
1827 else if(prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_CONNECTED) { // connected
1828 prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
1829
1830 // fill information for association result
1831 prAdapter->rWlanInfo.rCurrBssId.rSsid.u4SsidLen
1832 = prConnectionStatus->ucSsidLen;
1833 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.rSsid.aucSsid,
1834 prConnectionStatus->aucSsid,
1835 prConnectionStatus->ucSsidLen);
1836 kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
1837 prConnectionStatus->aucBssid,
1838 MAC_ADDR_LEN);
1839 prAdapter->rWlanInfo.rCurrBssId.u4Privacy
1840 = prConnectionStatus->ucEncryptStatus; // @FIXME
1841 prAdapter->rWlanInfo.rCurrBssId.rRssi
1842 = 0; //@FIXME
1843 prAdapter->rWlanInfo.rCurrBssId.eNetworkTypeInUse
1844 = PARAM_NETWORK_TYPE_AUTOMODE; //@FIXME
1845 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4BeaconPeriod
1846 = prConnectionStatus->u2BeaconPeriod;
1847 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4ATIMWindow
1848 = prConnectionStatus->u2ATIMWindow;
1849 prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4DSConfig
1850 = prConnectionStatus->u4FreqInKHz;
1851 prAdapter->rWlanInfo.ucNetworkType
1852 = prConnectionStatus->ucNetworkType;
1853 prAdapter->rWlanInfo.rCurrBssId.eOpMode
1854 = (ENUM_PARAM_OP_MODE_T) prConnectionStatus->ucInfraMode;
1855
1856 // always indicate to OS according to MSDN (re-association/roaming)
1857 if(kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_CONNECTED) {
1858 kalIndicateStatusAndComplete(prGlueInfo,
1859 WLAN_STATUS_MEDIA_CONNECT,
1860 NULL,
1861 0);
1862 }
1863 else {
1864 /* connected -> connected : roaming ? */
1865 kalIndicateStatusAndComplete(prGlueInfo,
1866 WLAN_STATUS_ROAM_OUT_FIND_BEST,
1867 NULL,
1868 0);
1869 }
1870 }
1871 break;
1872
1873#if CFG_ENABLE_BT_OVER_WIFI
1874 case NETWORK_TYPE_BOW_INDEX:
1875 break;
1876#endif
1877
1878#if CFG_ENABLE_WIFI_DIRECT
1879 case NETWORK_TYPE_P2P_INDEX:
1880 break;
1881#endif
1882 default:
1883 ASSERT(0);
1884 }
1885
1886 return WLAN_STATUS_SUCCESS;
1887} /* nicMediaStateChange */
1888
1889/*----------------------------------------------------------------------------*/
1890/*!
1891* @brief This utility function is used to convert between
1892* frequency and channel number
1893*
1894* @param u4ChannelNum
1895*
1896* @retval - Frequency in unit of KHz, 0 for invalid channel number
1897*/
1898/*----------------------------------------------------------------------------*/
1899UINT_32
1900nicChannelNum2Freq (
1901 UINT_32 u4ChannelNum
1902 )
1903{
1904 UINT_32 u4ChannelInMHz;
1905
1906 if(u4ChannelNum >= 1 && u4ChannelNum <= 13) {
1907 u4ChannelInMHz = 2412 + (u4ChannelNum - 1) * 5;
1908 }
1909 else if(u4ChannelNum == 14) {
1910 u4ChannelInMHz = 2484;
1911 }
1912 else if(u4ChannelNum == 133) {
1913 u4ChannelInMHz = 3665; // 802.11y
1914 }
1915 else if(u4ChannelNum == 137) {
1916 u4ChannelInMHz = 3685; // 802.11y
1917 }
1918 else if(u4ChannelNum >= 34 && u4ChannelNum <= 165) {
1919 u4ChannelInMHz = 5000 + u4ChannelNum * 5;
1920 }
1921 else if(u4ChannelNum >= 183 && u4ChannelNum <= 196) {
1922 u4ChannelInMHz = 4000 + u4ChannelNum * 5;
1923 }
1924 else {
1925 u4ChannelInMHz = 0;
1926 }
1927
1928 return 1000 * u4ChannelInMHz;
1929}
1930
1931
1932/*----------------------------------------------------------------------------*/
1933/*!
1934* @brief This utility function is used to convert between
1935* frequency and channel number
1936*
1937* @param u4FreqInKHz
1938*
1939* @retval - Frequency Number, 0 for invalid freqency
1940*/
1941/*----------------------------------------------------------------------------*/
1942UINT_32
1943nicFreq2ChannelNum (
1944 UINT_32 u4FreqInKHz
1945 )
1946{
1947 switch(u4FreqInKHz) {
1948 case 2412000:
1949 return 1;
1950 case 2417000:
1951 return 2;
1952 case 2422000:
1953 return 3;
1954 case 2427000:
1955 return 4;
1956 case 2432000:
1957 return 5;
1958 case 2437000:
1959 return 6;
1960 case 2442000:
1961 return 7;
1962 case 2447000:
1963 return 8;
1964 case 2452000:
1965 return 9;
1966 case 2457000:
1967 return 10;
1968 case 2462000:
1969 return 11;
1970 case 2467000:
1971 return 12;
1972 case 2472000:
1973 return 13;
1974 case 2484000:
1975 return 14;
1976 case 3665000:
1977 return 133; // 802.11y
1978 case 3685000:
1979 return 137; // 802.11y
1980 case 4915000:
1981 return 183;
1982 case 4920000:
1983 return 184;
1984 case 4925000:
1985 return 185;
1986 case 4930000:
1987 return 186;
1988 case 4935000:
1989 return 187;
1990 case 4940000:
1991 return 188;
1992 case 4945000:
1993 return 189;
1994 case 4960000:
1995 return 192;
1996 case 4980000:
1997 return 196;
1998 case 5170000:
1999 return 34;
2000 case 5180000:
2001 return 36;
2002 case 5190000:
2003 return 38;
2004 case 5200000:
2005 return 40;
2006 case 5210000:
2007 return 42;
2008 case 5220000:
2009 return 44;
2010 case 5230000:
2011 return 46;
2012 case 5240000:
2013 return 48;
2014 case 5250000:
2015 return 50;
2016 case 5260000:
2017 return 52;
2018 case 5270000:
2019 return 54;
2020 case 5280000:
2021 return 56;
2022 case 5290000:
2023 return 58;
2024 case 5300000:
2025 return 60;
2026 case 5320000:
2027 return 64;
2028 case 5500000:
2029 return 100;
2030 case 5520000:
2031 return 104;
2032 case 5540000:
2033 return 108;
2034 case 5560000:
2035 return 112;
2036 case 5580000:
2037 return 116;
2038 case 5600000:
2039 return 120;
2040 case 5620000:
2041 return 124;
2042 case 5640000:
2043 return 128;
2044 case 5660000:
2045 return 132;
2046 case 5680000:
2047 return 136;
2048 case 5700000:
2049 return 140;
2050 case 5745000:
2051 return 149;
2052 case 5765000:
2053 return 153;
2054 case 5785000:
2055 return 157;
2056 case 5805000:
2057 return 161;
2058 case 5825000:
2059 return 165;
2060 default:
2061 return 0;
2062 }
2063}
2064
2065
2066/* firmware command wrapper */
2067/* NETWORK (WIFISYS) */
2068/*----------------------------------------------------------------------------*/
2069/*!
2070* @brief This utility function is used to activate WIFISYS for specified network
2071*
2072* @param prAdapter Pointer of ADAPTER_T
2073* eNetworkTypeIdx Index of network type
2074*
2075* @retval -
2076*/
2077/*----------------------------------------------------------------------------*/
2078WLAN_STATUS
2079nicActivateNetwork(
2080 IN P_ADAPTER_T prAdapter,
2081 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2082 )
2083{
2084 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
2085 P_BSS_INFO_T prBssInfo;
2086
2087 ASSERT(prAdapter);
2088 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2089
2090 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2091 rCmdActivateCtrl.ucActive = 1;
2092
2093 if (((UINT_8) eNetworkTypeIdx) < NETWORK_TYPE_INDEX_NUM) {
2094 prBssInfo = &prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx];
2095 prBssInfo->fg40mBwAllowed = FALSE;
2096 prBssInfo->fgAssoc40mBwAllowed = FALSE;
2097 }
2098
2099 return wlanSendSetQueryCmd(prAdapter,
2100 CMD_ID_BSS_ACTIVATE_CTRL,
2101 TRUE,
2102 FALSE,
2103 FALSE,
2104 NULL,
2105 NULL,
2106 sizeof(CMD_BSS_ACTIVATE_CTRL),
2107 (PUINT_8)&rCmdActivateCtrl,
2108 NULL,
2109 0);
2110}
2111
2112
2113/*----------------------------------------------------------------------------*/
2114/*!
2115* @brief This utility function is used to deactivate WIFISYS for specified network
2116*
2117* @param prAdapter Pointer of ADAPTER_T
2118* eNetworkTypeIdx Index of network type
2119*
2120* @retval -
2121*/
2122/*----------------------------------------------------------------------------*/
2123WLAN_STATUS
2124nicDeactivateNetwork(
2125 IN P_ADAPTER_T prAdapter,
2126 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2127 )
2128{
2129 WLAN_STATUS u4Status;
2130 CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
2131
2132 ASSERT(prAdapter);
2133 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2134
2135 rCmdActivateCtrl.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2136 rCmdActivateCtrl.ucActive = 0;
2137
2138 u4Status = wlanSendSetQueryCmd(prAdapter,
2139 CMD_ID_BSS_ACTIVATE_CTRL,
2140 TRUE,
2141 FALSE,
2142 FALSE,
2143 NULL,
2144 NULL,
2145 sizeof(CMD_BSS_ACTIVATE_CTRL),
2146 (PUINT_8)&rCmdActivateCtrl,
2147 NULL,
2148 0);
2149
2150 /* free all correlated station records */
2151 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2152 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2153 nicFreePendingTxMsduInfoByNetwork(prAdapter, eNetworkTypeIdx);
2154 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2155
2156 return u4Status;
2157}
2158
2159
2160/* BSS-INFO */
2161/*----------------------------------------------------------------------------*/
2162/*!
2163* @brief This utility function is used to sync bss info with firmware
2164* when a new BSS has been connected or disconnected
2165*
2166* @param prAdapter Pointer of ADAPTER_T
2167* eNetworkTypeIdx Index of BSS-INFO type
2168*
2169* @retval -
2170*/
2171/*----------------------------------------------------------------------------*/
2172WLAN_STATUS
2173nicUpdateBss(
2174 IN P_ADAPTER_T prAdapter,
2175 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2176 )
2177{
2178 WLAN_STATUS u4Status;
2179 P_BSS_INFO_T prBssInfo;
2180 CMD_SET_BSS_INFO rCmdSetBssInfo;
2181
2182 ASSERT(prAdapter);
2183 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2184
2185 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2186
2187 kalMemZero(&rCmdSetBssInfo, sizeof(CMD_SET_BSS_INFO));
2188
2189 rCmdSetBssInfo.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2190 rCmdSetBssInfo.ucConnectionState = (UINT_8)prBssInfo->eConnectionState;
2191 rCmdSetBssInfo.ucCurrentOPMode = (UINT_8)prBssInfo->eCurrentOPMode;
2192 rCmdSetBssInfo.ucSSIDLen = (UINT_8)prBssInfo->ucSSIDLen;
2193 kalMemCopy(rCmdSetBssInfo.aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
2194 COPY_MAC_ADDR(rCmdSetBssInfo.aucBSSID, prBssInfo->aucBSSID);
2195 rCmdSetBssInfo.ucIsQBSS = (UINT_8)prBssInfo->fgIsQBSS;
2196 rCmdSetBssInfo.ucNonHTBasicPhyType = prBssInfo->ucNonHTBasicPhyType;
2197 rCmdSetBssInfo.u2OperationalRateSet = prBssInfo->u2OperationalRateSet;
2198 rCmdSetBssInfo.u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
2199 rCmdSetBssInfo.ucPhyTypeSet = prBssInfo->ucPhyTypeSet;
2200 rCmdSetBssInfo.fgHiddenSsidMode = prBssInfo->eHiddenSsidType;
2201#if CFG_ENABLE_WIFI_DIRECT
2202 if(prAdapter->fgIsP2PRegistered) {
2203 COPY_MAC_ADDR(rCmdSetBssInfo.aucOwnMac, prBssInfo->aucOwnMacAddr);
2204 }
2205#endif
2206
2207 rlmFillSyncCmdParam(&rCmdSetBssInfo.rBssRlmParam, prBssInfo);
2208
2209 rCmdSetBssInfo.fgWapiMode = (UINT_8)FALSE;
2210
2211 if(rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
2212 P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2213
2214 rCmdSetBssInfo.ucAuthMode = (UINT_8)prConnSettings->eAuthMode;
2215 rCmdSetBssInfo.ucEncStatus = (UINT_8)prConnSettings->eEncStatus;
2216 rCmdSetBssInfo.fgWapiMode = (UINT_8)prConnSettings->fgWapiMode;
2217 }
2218#if CFG_ENABLE_BT_OVER_WIFI
2219 else if(rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX) {
2220 //P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2221 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2222 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2223 }
2224#endif
2225 else {
2226#if CFG_ENABLE_WIFI_DIRECT
2227 if(prAdapter->fgIsP2PRegistered) {
2228 if (kalP2PGetCipher(prAdapter->prGlueInfo)) {
2229 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2230 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2231 }
2232 else {
2233 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_OPEN;
2234 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION_DISABLED;
2235 }
2236 /* Need the probe response to detect the PBC overlap */
2237 rCmdSetBssInfo.fgIsApMode = p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo);
2238 }
2239#else
2240 rCmdSetBssInfo.ucAuthMode = (UINT_8)AUTH_MODE_WPA2_PSK;
2241 rCmdSetBssInfo.ucEncStatus = (UINT_8)ENUM_ENCRYPTION3_KEY_ABSENT;
2242#endif
2243 }
2244
2245 if(eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX &&
2246 prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
2247 prBssInfo->prStaRecOfAP != NULL) {
2248 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2249
2250 cnmAisInfraConnectNotify(prAdapter);
2251 }
2252#if CFG_ENABLE_WIFI_DIRECT
2253 else if ((prAdapter->fgIsP2PRegistered) &&
2254 (eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) &&
2255 (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) &&
2256 (prBssInfo->prStaRecOfAP != NULL)) {
2257 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2258 }
2259#endif
2260
2261#if CFG_ENABLE_BT_OVER_WIFI
2262 else if (eNetworkTypeIdx == NETWORK_TYPE_BOW_INDEX &&
2263 prBssInfo->eCurrentOPMode == OP_MODE_BOW &&
2264 prBssInfo->prStaRecOfAP != NULL) {
2265 rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
2266 }
2267#endif
2268 else {
2269 rCmdSetBssInfo.ucStaRecIdxOfAP = STA_REC_INDEX_NOT_FOUND;
2270 }
2271
2272 u4Status = wlanSendSetQueryCmd(prAdapter,
2273 CMD_ID_SET_BSS_INFO,
2274 TRUE,
2275 FALSE,
2276 FALSE,
2277 NULL,
2278 NULL,
2279 sizeof(CMD_SET_BSS_INFO),
2280 (PUINT_8)&rCmdSetBssInfo,
2281 NULL,
2282 0);
2283
2284 /* if BSS-INFO is going to be disconnected state, free all correlated station records */
2285 if(prBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
2286 /* clear client list */
2287 bssClearClientList(prAdapter, prBssInfo);
2288
2289 /* free all correlated station records */
2290 cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
2291 qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
2292 kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
2293#if CFG_ENABLE_GTK_FRAME_FILTER
2294 if (prBssInfo->prIpV4NetAddrList) {
2295 FREE_IPV4_NETWORK_ADDR_LIST(prBssInfo->prIpV4NetAddrList);
2296 }
2297#endif
2298 }
2299
2300 return u4Status;
2301}
2302
2303
2304/* BSS-INFO Indication (PM) */
2305/*----------------------------------------------------------------------------*/
2306/*!
2307* @brief This utility function is used to indicate PM that
2308* a BSS has been created. (for AdHoc / P2P-GO)
2309*
2310* @param prAdapter Pointer of ADAPTER_T
2311* eNetworkTypeIdx Index of BSS-INFO
2312*
2313* @retval -
2314*/
2315/*----------------------------------------------------------------------------*/
2316WLAN_STATUS
2317nicPmIndicateBssCreated(
2318 IN P_ADAPTER_T prAdapter,
2319 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2320 )
2321{
2322 P_BSS_INFO_T prBssInfo;
2323 CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated;
2324
2325 ASSERT(prAdapter);
2326 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2327
2328 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2329
2330 rCmdIndicatePmBssCreated.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2331 rCmdIndicatePmBssCreated.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2332 rCmdIndicatePmBssCreated.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2333 rCmdIndicatePmBssCreated.u2AtimWindow = prBssInfo->u2ATIMWindow;
2334
2335 return wlanSendSetQueryCmd(prAdapter,
2336 CMD_ID_INDICATE_PM_BSS_CREATED,
2337 TRUE,
2338 FALSE,
2339 FALSE,
2340 NULL,
2341 NULL,
2342 sizeof(CMD_INDICATE_PM_BSS_CREATED),
2343 (PUINT_8)&rCmdIndicatePmBssCreated,
2344 NULL,
2345 0);
2346}
2347
2348
2349/*----------------------------------------------------------------------------*/
2350/*!
2351* @brief This utility function is used to indicate PM that
2352* a BSS has been connected
2353*
2354* @param prAdapter Pointer of ADAPTER_T
2355* eNetworkTypeIdx Index of BSS-INFO
2356*
2357* @retval -
2358*/
2359/*----------------------------------------------------------------------------*/
2360WLAN_STATUS
2361nicPmIndicateBssConnected(
2362 IN P_ADAPTER_T prAdapter,
2363 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2364 )
2365{
2366 P_BSS_INFO_T prBssInfo;
2367 CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected;
2368
2369 ASSERT(prAdapter);
2370 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2371
2372 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2373
2374 rCmdIndicatePmBssConnected.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2375 rCmdIndicatePmBssConnected.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
2376 rCmdIndicatePmBssConnected.u2AssocId = prBssInfo->u2AssocId;
2377 rCmdIndicatePmBssConnected.u2BeaconInterval = prBssInfo->u2BeaconInterval;
2378 rCmdIndicatePmBssConnected.u2AtimWindow = prBssInfo->u2ATIMWindow;
2379
2380 rCmdIndicatePmBssConnected.ucBmpDeliveryAC = prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC;
2381 rCmdIndicatePmBssConnected.ucBmpTriggerAC = prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC;
2382
2383 //DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x",
2384 //rCmdIndicatePmBssConnected.ucBmpDeliveryAC,
2385 //rCmdIndicatePmBssConnected.ucBmpTriggerAC);
2386
2387 if ((eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX)
2388#if CFG_ENABLE_WIFI_DIRECT
2389 || ((eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->fgIsP2PRegistered))
2390#endif
2391 ) {
2392 if(prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
2393 rCmdIndicatePmBssConnected.fgIsUapsdConnection = (UINT_8)prBssInfo->prStaRecOfAP->fgIsUapsdSupported;
2394 }
2395 else {
2396 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0; //@FIXME
2397 }
2398 }
2399 else {
2400 rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0;
2401 }
2402
2403 return wlanSendSetQueryCmd(prAdapter,
2404 CMD_ID_INDICATE_PM_BSS_CONNECTED,
2405 TRUE,
2406 FALSE,
2407 FALSE,
2408 NULL,
2409 NULL,
2410 sizeof(CMD_INDICATE_PM_BSS_CONNECTED),
2411 (PUINT_8)&rCmdIndicatePmBssConnected,
2412 NULL,
2413 0);
2414}
2415
2416
2417/*----------------------------------------------------------------------------*/
2418/*!
2419* @brief This utility function is used to indicate PM that
2420* a BSS has been disconnected
2421*
2422* @param prAdapter Pointer of ADAPTER_T
2423* eNetworkTypeIdx Index of BSS-INFO
2424*
2425* @retval -
2426*/
2427/*----------------------------------------------------------------------------*/
2428WLAN_STATUS
2429nicPmIndicateBssAbort(
2430 IN P_ADAPTER_T prAdapter,
2431 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2432 )
2433{
2434 CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort;
2435
2436 ASSERT(prAdapter);
2437 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2438
2439 rCmdIndicatePmBssAbort.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2440
2441 return wlanSendSetQueryCmd(prAdapter,
2442 CMD_ID_INDICATE_PM_BSS_ABORT,
2443 TRUE,
2444 FALSE,
2445 FALSE,
2446 NULL,
2447 NULL,
2448 sizeof(CMD_INDICATE_PM_BSS_ABORT),
2449 (PUINT_8)&rCmdIndicatePmBssAbort,
2450 NULL,
2451 0);
2452}
2453
2454WLAN_STATUS
2455nicConfigPowerSaveProfile (
2456 IN P_ADAPTER_T prAdapter,
2457 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2458 PARAM_POWER_MODE ePwrMode,
2459 BOOLEAN fgEnCmdEvent
2460 )
2461{
2462 DEBUGFUNC("nicConfigPowerSaveProfile");
2463 DBGLOG(INIT, TRACE, ("eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
2464 eNetTypeIndex, ePwrMode, fgEnCmdEvent));
2465
2466 ASSERT(prAdapter);
2467
2468 if (eNetTypeIndex >= NETWORK_TYPE_INDEX_NUM) {
2469 ASSERT(0);
2470 return WLAN_STATUS_NOT_SUPPORTED;
2471 }
2472
2473// prAdapter->rWlanInfo.ePowerSaveMode.ucNetTypeIndex = eNetTypeIndex;
2474// prAdapter->rWlanInfo.ePowerSaveMode.ucPsProfile = (UINT_8)ePwrMode;
2475 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucNetTypeIndex = eNetTypeIndex;
2476 prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucPsProfile = (UINT_8)ePwrMode;
2477
2478 return wlanSendSetQueryCmd(prAdapter,
2479 CMD_ID_POWER_SAVE_MODE,
2480 TRUE,
2481 FALSE,
2482 (fgEnCmdEvent ? TRUE : FALSE),
2483 (fgEnCmdEvent ? nicCmdEventSetCommon : NULL),
2484 (fgEnCmdEvent ? nicOidCmdTimeoutCommon : NULL),
2485 sizeof(CMD_PS_PROFILE_T),
2486 (PUINT_8)&(prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex]),
2487 NULL,
2488 sizeof(PARAM_POWER_MODE)
2489 );
2490
2491} /* end of wlanoidSetAcpiDevicePowerStateMode() */
2492
2493WLAN_STATUS
2494nicEnterCtiaMode (
2495 IN P_ADAPTER_T prAdapter,
2496 BOOLEAN fgEnterCtia,
2497 BOOLEAN fgEnCmdEvent
2498 )
2499{
2500 CMD_SW_DBG_CTRL_T rCmdSwCtrl;
2501 CMD_ACCESS_REG rCmdAccessReg;
2502 WLAN_STATUS rWlanStatus;
2503
2504 DEBUGFUNC("nicEnterCtiaMode");
2505 DBGLOG(INIT, TRACE, ("nicEnterCtiaMode: %d\n", fgEnterCtia));
2506
2507 ASSERT(prAdapter);
2508
2509 rWlanStatus = WLAN_STATUS_SUCCESS;
2510
2511 if (fgEnterCtia) {
2512 // 1. Disable On-Lin Scan
2513 prAdapter->fgEnOnlineScan = FALSE;
2514
2515 // 3. Disable FIFO FULL no ack
2516 rCmdAccessReg.u4Address = 0x60140028;
2517 rCmdAccessReg.u4Data = 0x904;
2518 wlanSendSetQueryCmd(prAdapter,
2519 CMD_ID_ACCESS_REG,
2520 TRUE, //FALSE,
2521 FALSE, //TRUE,
2522 FALSE,
2523 NULL,
2524 NULL,
2525 sizeof(CMD_ACCESS_REG),
2526 (PUINT_8)&rCmdAccessReg,
2527 NULL,
2528 0
2529 );
2530
2531 // 4. Disable Roaming
2532 rCmdSwCtrl.u4Id = 0x90000204;
2533 rCmdSwCtrl.u4Data = 0x0;
2534 wlanSendSetQueryCmd(prAdapter,
2535 CMD_ID_SW_DBG_CTRL,
2536 TRUE,
2537 FALSE,
2538 FALSE,
2539 NULL,
2540 NULL,
2541 sizeof(CMD_SW_DBG_CTRL_T),
2542 (PUINT_8)&rCmdSwCtrl,
2543 NULL,
2544 0
2545 );
2546
2547 rCmdSwCtrl.u4Id = 0x90000200;
2548 rCmdSwCtrl.u4Data = 0x820000;
2549 wlanSendSetQueryCmd(prAdapter,
2550 CMD_ID_SW_DBG_CTRL,
2551 TRUE,
2552 FALSE,
2553 FALSE,
2554 NULL,
2555 NULL,
2556 sizeof(CMD_SW_DBG_CTRL_T),
2557 (PUINT_8)&rCmdSwCtrl,
2558 NULL,
2559 0
2560 );
2561
2562 // Disalbe auto tx power
2563 rCmdSwCtrl.u4Id = 0xa0100003;
2564 rCmdSwCtrl.u4Data = 0x0;
2565 wlanSendSetQueryCmd(prAdapter,
2566 CMD_ID_SW_DBG_CTRL,
2567 TRUE,
2568 FALSE,
2569 FALSE,
2570 NULL,
2571 NULL,
2572 sizeof(CMD_SW_DBG_CTRL_T),
2573 (PUINT_8)&rCmdSwCtrl,
2574 NULL,
2575 0
2576 );
2577
2578 // 2. Keep at CAM mode
2579 {
2580 PARAM_POWER_MODE ePowerMode;
2581
2582 prAdapter->u4CtiaPowerMode = 0;
2583 prAdapter->fgEnCtiaPowerMode = TRUE;
2584
2585 ePowerMode = Param_PowerModeCAM;
2586 rWlanStatus = nicConfigPowerSaveProfile(
2587 prAdapter,
2588 NETWORK_TYPE_AIS_INDEX,
2589 ePowerMode,
2590 fgEnCmdEvent);
2591 }
2592
2593 // 5. Disable Beacon Timeout Detection
2594 prAdapter->fgDisBcnLostDetection = TRUE;
2595 }
2596 else {
2597 // 1. Enaable On-Lin Scan
2598 prAdapter->fgEnOnlineScan = TRUE;
2599
2600 // 3. Enable FIFO FULL no ack
2601 rCmdAccessReg.u4Address = 0x60140028;
2602 rCmdAccessReg.u4Data = 0x905;
2603 wlanSendSetQueryCmd(prAdapter,
2604 CMD_ID_ACCESS_REG,
2605 TRUE, //FALSE,
2606 FALSE, //TRUE,
2607 FALSE,
2608 NULL,
2609 NULL,
2610 sizeof(CMD_ACCESS_REG),
2611 (PUINT_8)&rCmdAccessReg,
2612 NULL,
2613 0
2614 );
2615
2616 // 4. Enable Roaming
2617 rCmdSwCtrl.u4Id = 0x90000204;
2618 rCmdSwCtrl.u4Data = 0x1;
2619 wlanSendSetQueryCmd(prAdapter,
2620 CMD_ID_SW_DBG_CTRL,
2621 TRUE,
2622 FALSE,
2623 FALSE,
2624 NULL,
2625 NULL,
2626 sizeof(CMD_SW_DBG_CTRL_T),
2627 (PUINT_8)&rCmdSwCtrl,
2628 NULL,
2629 0
2630 );
2631
2632 rCmdSwCtrl.u4Id = 0x90000200;
2633 rCmdSwCtrl.u4Data = 0x820000;
2634 wlanSendSetQueryCmd(prAdapter,
2635 CMD_ID_SW_DBG_CTRL,
2636 TRUE,
2637 FALSE,
2638 FALSE,
2639 NULL,
2640 NULL,
2641 sizeof(CMD_SW_DBG_CTRL_T),
2642 (PUINT_8)&rCmdSwCtrl,
2643 NULL,
2644 0
2645 );
2646
2647 // Enable auto tx power
2648 //
2649
2650 rCmdSwCtrl.u4Id = 0xa0100003;
2651 rCmdSwCtrl.u4Data = 0x1;
2652 wlanSendSetQueryCmd(prAdapter,
2653 CMD_ID_SW_DBG_CTRL,
2654 TRUE,
2655 FALSE,
2656 FALSE,
2657 NULL,
2658 NULL,
2659 sizeof(CMD_SW_DBG_CTRL_T),
2660 (PUINT_8)&rCmdSwCtrl,
2661 NULL,
2662 0
2663 );
2664
2665
2666 // 2. Keep at Fast PS
2667 {
2668 PARAM_POWER_MODE ePowerMode;
2669
2670 prAdapter->u4CtiaPowerMode = 2;
2671 prAdapter->fgEnCtiaPowerMode = TRUE;
2672
2673 ePowerMode = Param_PowerModeFast_PSP;
2674 rWlanStatus = nicConfigPowerSaveProfile(
2675 prAdapter,
2676 NETWORK_TYPE_AIS_INDEX,
2677 ePowerMode,
2678 fgEnCmdEvent);
2679 }
2680
2681 // 5. Enable Beacon Timeout Detection
2682 prAdapter->fgDisBcnLostDetection = FALSE;
2683
2684 }
2685
2686 return rWlanStatus;
2687} /* end of nicEnterCtiaMode() */
2688
2689/*----------------------------------------------------------------------------*/
2690/*!
2691* @brief This utility function is used to indicate firmware domain
2692* for beacon generation parameters
2693*
2694* @param prAdapter Pointer of ADAPTER_T
2695* eIeUpdMethod, Update Method
2696* eNetTypeIndex Index of Network
2697* u2Capability Capability
2698* aucIe Pointer to buffer of IEs
2699* u2IELen Length of IEs
2700*
2701* @retval - WLAN_STATUS_SUCCESS
2702* WLAN_STATUS_FAILURE
2703* WLAN_STATUS_PENDING
2704* WLAN_STATUS_INVALID_DATA
2705*/
2706/*----------------------------------------------------------------------------*/
2707WLAN_STATUS
2708nicUpdateBeaconIETemplate (
2709 IN P_ADAPTER_T prAdapter,
2710 IN ENUM_IE_UPD_METHOD_T eIeUpdMethod,
2711 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
2712 IN UINT_16 u2Capability,
2713 IN PUINT_8 aucIe,
2714 IN UINT_16 u2IELen
2715 )
2716{
2717 P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate;
2718 UINT_16 u2CmdBufLen = 0;
2719 P_GLUE_INFO_T prGlueInfo;
2720 P_CMD_INFO_T prCmdInfo;
2721 P_WIFI_CMD_T prWifiCmd;
2722 UINT_8 ucCmdSeqNum;
2723
2724 DEBUGFUNC("wlanUpdateBeaconIETemplate");
2725 DBGLOG(INIT, LOUD, ("\n"));
2726
2727 printk("nicUpdateBeaconIETemplate\n");
2728
2729 ASSERT(prAdapter);
2730 prGlueInfo = prAdapter->prGlueInfo;
2731
2732 if (u2IELen > MAX_IE_LENGTH) {
2733 return WLAN_STATUS_INVALID_DATA;
2734 }
2735
2736 if (eIeUpdMethod == IE_UPD_METHOD_UPDATE_RANDOM
2737 || eIeUpdMethod == IE_UPD_METHOD_UPDATE_ALL) {
2738 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, aucIE) + u2IELen;
2739 }
2740 else if (eIeUpdMethod == IE_UPD_METHOD_DELETE_ALL) {
2741 u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, u2IELen);
2742 }
2743 else {
2744 ASSERT(0);
2745 return WLAN_STATUS_FAILURE;
2746 }
2747
2748 // prepare command info
2749 prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u2CmdBufLen));
2750 if (!prCmdInfo) {
2751 DBGLOG(INIT, ERROR, ("Allocate CMD_INFO_T ==> FAILED.\n"));
2752 printk("Allocate CMD_INFO_T ==> FAILED.\n");
2753 return WLAN_STATUS_FAILURE;
2754 }
2755
2756 // increase command sequence number
2757 ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
2758 DBGLOG(REQ, TRACE, ("ucCmdSeqNum =%d\n", ucCmdSeqNum));
2759
2760 // Setup common CMD Info Packet
2761 prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
2762 prCmdInfo->eNetworkType = eNetTypeIndex;
2763 prCmdInfo->u2InfoBufLen = (UINT_16)(CMD_HDR_SIZE + u2CmdBufLen);
2764 prCmdInfo->pfCmdDoneHandler = NULL; //@FIXME
2765 prCmdInfo->pfCmdTimeoutHandler = NULL; //@FIXME
2766 prCmdInfo->fgIsOid = FALSE;
2767 prCmdInfo->ucCID = CMD_ID_UPDATE_BEACON_CONTENT;
2768 prCmdInfo->fgSetQuery = TRUE;
2769 prCmdInfo->fgNeedResp = FALSE;
2770 prCmdInfo->fgDriverDomainMCR = FALSE;
2771 prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
2772 prCmdInfo->u4SetInfoLen = u2CmdBufLen;
2773 prCmdInfo->pvInformationBuffer = NULL;
2774 prCmdInfo->u4InformationBufferLength = 0;
2775
2776 // Setup WIFI_CMD_T (no payload)
2777 prWifiCmd = (P_WIFI_CMD_T)(prCmdInfo->pucInfoBuffer);
2778 prWifiCmd->u2TxByteCount_UserPriority = prCmdInfo->u2InfoBufLen;
2779 prWifiCmd->ucCID = prCmdInfo->ucCID;
2780 prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
2781 prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
2782
2783 prCmdBcnUpdate = (P_CMD_BEACON_TEMPLATE_UPDATE)(prWifiCmd->aucBuffer);
2784
2785 // fill beacon updating command
2786 prCmdBcnUpdate->ucUpdateMethod = (UINT_8) eIeUpdMethod;
2787 prCmdBcnUpdate->ucNetTypeIndex = (UINT_8) eNetTypeIndex;
2788 prCmdBcnUpdate->u2Capability = u2Capability;
2789 prCmdBcnUpdate->u2IELen = u2IELen;
2790 if(u2IELen > 0 ) {
2791 kalMemCopy(prCmdBcnUpdate->aucIE, aucIe, u2IELen);
2792 }
2793
2794 // insert into prCmdQueue
2795 kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T)prCmdInfo);
2796
2797 // wakeup txServiceThread later
2798 GLUE_SET_EVENT(prGlueInfo);
2799 return WLAN_STATUS_PENDING;
2800}
2801
2802
2803/*----------------------------------------------------------------------------*/
2804/*!
2805* @brief This utility function is used to initialization PHY related
2806* varaibles
2807*
2808* @param prAdapter Pointer of ADAPTER_T
2809*
2810* @retval none
2811*/
2812/*----------------------------------------------------------------------------*/
2813VOID
2814nicSetAvailablePhyTypeSet (
2815 IN P_ADAPTER_T prAdapter
2816 )
2817{
2818 P_CONNECTION_SETTINGS_T prConnSettings;
2819
2820 ASSERT(prAdapter);
2821
2822 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2823
2824 if (prConnSettings->eDesiredPhyConfig >= PHY_CONFIG_NUM) {
2825 ASSERT(0);
2826 return;
2827 }
2828
2829 prAdapter->rWifiVar.ucAvailablePhyTypeSet =
2830 aucPhyCfg2PhyTypeSet[prConnSettings->eDesiredPhyConfig];
2831
2832 if (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_BIT_ERP) {
2833 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_ERP_INDEX;
2834 }
2835 /* NOTE(Kevin): Because we don't have N only mode, TBD */
2836 else /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */ {
2837 prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_HR_DSSS_INDEX;
2838 }
2839
2840 return;
2841}
2842
2843
2844/*----------------------------------------------------------------------------*/
2845/*!
2846* @brief This utility function is used to update WMM Parms
2847*
2848* @param prAdapter Pointer of ADAPTER_T
2849* eNetworkTypeIdx Index of BSS-INFO
2850*
2851* @retval -
2852*/
2853/*----------------------------------------------------------------------------*/
2854WLAN_STATUS
2855nicQmUpdateWmmParms(
2856 IN P_ADAPTER_T prAdapter,
2857 IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx
2858 )
2859{
2860 P_BSS_INFO_T prBssInfo;
2861 CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms;
2862
2863 ASSERT(prAdapter);
2864 ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
2865
2866 DBGLOG(QM, EVENT, ("sizeof(AC_QUE_PARMS_T): %zu \n", sizeof(AC_QUE_PARMS_T)));
2867 DBGLOG(QM, EVENT, ("sizeof(CMD_UPDATE_WMM_PARMS): %zu \n", sizeof(CMD_UPDATE_WMM_PARMS_T)));
2868 DBGLOG(QM, EVENT, ("sizeof(WIFI_CMD_T): %zu \n", sizeof(WIFI_CMD_T)));
2869
2870 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
2871 rCmdUpdateWmmParms.ucNetTypeIndex = (UINT_8)eNetworkTypeIdx;
2872 kalMemCopy(&rCmdUpdateWmmParms.arACQueParms[0], &prBssInfo->arACQueParms[0],
2873 (sizeof(AC_QUE_PARMS_T)*AC_NUM));
2874
2875 rCmdUpdateWmmParms.fgIsQBSS = prBssInfo->fgIsQBSS;
2876
2877 return wlanSendSetQueryCmd(prAdapter,
2878 CMD_ID_UPDATE_WMM_PARMS,
2879 TRUE,
2880 FALSE,
2881 FALSE,
2882 NULL,
2883 NULL,
2884 sizeof(CMD_UPDATE_WMM_PARMS_T),
2885 (PUINT_8)&rCmdUpdateWmmParms,
2886 NULL,
2887 0);
2888}
2889
2890
2891/*----------------------------------------------------------------------------*/
2892/*!
2893* @brief This utility function is used to update TX power gain corresponding to
2894* each band/modulation combination
2895*
2896* @param prAdapter Pointer of ADAPTER_T
2897* prTxPwrParam Pointer of TX power parameters
2898*
2899* @retval WLAN_STATUS_PENDING
2900* WLAN_STATUS_FAILURE
2901*/
2902/*----------------------------------------------------------------------------*/
2903WLAN_STATUS
2904nicUpdateTxPower(
2905 IN P_ADAPTER_T prAdapter,
2906 IN P_CMD_TX_PWR_T prTxPwrParam
2907 )
2908{
2909 DEBUGFUNC("nicUpdateTxPower");
2910
2911 ASSERT(prAdapter);
2912
2913 return wlanSendSetQueryCmd(prAdapter,
2914 CMD_ID_SET_TX_PWR,
2915 TRUE,
2916 FALSE,
2917 FALSE,
2918 NULL,
2919 NULL,
2920 sizeof(CMD_TX_PWR_T),
2921 (PUINT_8)prTxPwrParam,
2922 NULL,
2923 0);
2924}
2925
2926/*----------------------------------------------------------------------------*/
2927/*!
2928* @brief This utility function is used to set auto tx power parameter
2929*
2930* @param prAdapter Pointer of ADAPTER_T
2931* prTxPwrParam Pointer of Auto TX power parameters
2932*
2933* @retval WLAN_STATUS_PENDING
2934* WLAN_STATUS_FAILURE
2935*/
2936/*----------------------------------------------------------------------------*/
2937WLAN_STATUS
2938nicSetAutoTxPower(
2939 IN P_ADAPTER_T prAdapter,
2940 IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam
2941 )
2942{
2943 DEBUGFUNC("nicSetAutoTxPower");
2944
2945 ASSERT(prAdapter);
2946
2947 return wlanSendSetQueryCmd(prAdapter,
2948 CMD_ID_SET_AUTOPWR_CTRL,
2949 TRUE,
2950 FALSE,
2951 FALSE,
2952 NULL,
2953 NULL,
2954 sizeof(CMD_AUTO_POWER_PARAM_T),
2955 (PUINT_8)prAutoPwrParam,
2956 NULL,
2957 0);
2958}
2959
2960
2961/*----------------------------------------------------------------------------*/
2962/*!
2963* @brief This utility function is used to update TX power gain corresponding to
2964* each band/modulation combination
2965*
2966* @param prAdapter Pointer of ADAPTER_T
2967* prTxPwrParam Pointer of TX power parameters
2968*
2969* @retval WLAN_STATUS_PENDING
2970* WLAN_STATUS_FAILURE
2971*/
2972/*----------------------------------------------------------------------------*/
2973WLAN_STATUS
2974nicSetAutoTxPowerControl(
2975 IN P_ADAPTER_T prAdapter,
2976 IN P_CMD_TX_PWR_T prTxPwrParam
2977 )
2978{
2979 DEBUGFUNC("nicUpdateTxPower");
2980
2981 ASSERT(prAdapter);
2982
2983 return wlanSendSetQueryCmd(prAdapter,
2984 CMD_ID_SET_TX_PWR,
2985 TRUE,
2986 FALSE,
2987 FALSE,
2988 NULL,
2989 NULL,
2990 sizeof(CMD_TX_PWR_T),
2991 (PUINT_8)prTxPwrParam,
2992 NULL,
2993 0);
2994}
2995
2996
2997/*----------------------------------------------------------------------------*/
2998/*!
2999* @brief This utility function is used to update power offset around 5GHz band
3000*
3001* @param prAdapter Pointer of ADAPTER_T
3002* pr5GPwrOffset Pointer of 5GHz power offset parameter
3003*
3004* @retval WLAN_STATUS_PENDING
3005* WLAN_STATUS_FAILURE
3006*/
3007/*----------------------------------------------------------------------------*/
3008WLAN_STATUS
3009nicUpdate5GOffset(
3010 IN P_ADAPTER_T prAdapter,
3011 IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset
3012 )
3013{
3014 DEBUGFUNC("nicUpdate5GOffset");
3015
3016 ASSERT(prAdapter);
3017
3018 return wlanSendSetQueryCmd(prAdapter,
3019 CMD_ID_SET_5G_PWR_OFFSET,
3020 TRUE,
3021 FALSE,
3022 FALSE,
3023 NULL,
3024 NULL,
3025 sizeof(CMD_5G_PWR_OFFSET_T),
3026 (PUINT_8)pr5GPwrOffset,
3027 NULL,
3028 0);
3029}
3030
3031
3032/*----------------------------------------------------------------------------*/
3033/*!
3034* @brief This utility function is used to update DPD calibration result
3035*
3036* @param prAdapter Pointer of ADAPTER_T
3037* pr5GPwrOffset Pointer of parameter for DPD calibration result
3038*
3039* @retval WLAN_STATUS_PENDING
3040* WLAN_STATUS_FAILURE
3041*/
3042/*----------------------------------------------------------------------------*/
3043WLAN_STATUS
3044nicUpdateDPD(
3045 IN P_ADAPTER_T prAdapter,
3046 IN P_CMD_PWR_PARAM_T prDpdCalResult
3047 )
3048{
3049 DEBUGFUNC("nicUpdateDPD");
3050
3051 ASSERT(prAdapter);
3052
3053 return wlanSendSetQueryCmd(prAdapter,
3054 CMD_ID_SET_PWR_PARAM,
3055 TRUE,
3056 FALSE,
3057 FALSE,
3058 NULL,
3059 NULL,
3060 sizeof(CMD_PWR_PARAM_T),
3061 (PUINT_8)prDpdCalResult,
3062 NULL,
3063 0);
3064}
3065
3066
3067/*----------------------------------------------------------------------------*/
3068/*!
3069* @brief This utility function starts system service such as timer and
3070* memory pools
3071*
3072* @param prAdapter Pointer of ADAPTER_T
3073*
3074* @retval none
3075*/
3076/*----------------------------------------------------------------------------*/
3077VOID
3078nicInitSystemService (
3079 IN P_ADAPTER_T prAdapter
3080 )
3081{
3082 ASSERT(prAdapter);
3083
3084 // <1> Initialize MGMT Memory pool and STA_REC
3085 cnmMemInit(prAdapter);
3086 cnmStaRecInit(prAdapter);
3087 cmdBufInitialize(prAdapter);
3088
3089 // <2> Mailbox Initialization
3090 mboxInitialize(prAdapter);
3091
3092 // <3> Timer Initialization
3093 cnmTimerInitialize(prAdapter);
3094
3095 return;
3096}
3097
3098
3099/*----------------------------------------------------------------------------*/
3100/*!
3101* @brief This utility function reset some specific system service,
3102* such as STA-REC
3103*
3104* @param prAdapter Pointer of ADAPTER_T
3105*
3106* @retval none
3107*/
3108/*----------------------------------------------------------------------------*/
3109VOID
3110nicResetSystemService (
3111 IN P_ADAPTER_T prAdapter
3112 )
3113{
3114 ASSERT(prAdapter);
3115}
3116
3117
3118/*----------------------------------------------------------------------------*/
3119/*!
3120* @brief This utility function is used to update WMM Parms
3121*
3122* @param prAdapter Pointer of ADAPTER_T
3123*
3124* @retval none
3125*/
3126/*----------------------------------------------------------------------------*/
3127VOID
3128nicUninitSystemService (
3129 IN P_ADAPTER_T prAdapter
3130 )
3131{
3132 ASSERT(prAdapter);
3133
3134 /* Timer Destruction */
3135 cnmTimerDestroy(prAdapter);
3136
3137 /* Mailbox Destruction */
3138 mboxDestroy(prAdapter);
3139
3140 return;
3141}
3142
3143
3144/*----------------------------------------------------------------------------*/
3145/*!
3146* @brief This utility function is used to update WMM Parms
3147*
3148* @param prAdapter Pointer of ADAPTER_T
3149*
3150* @retval none
3151*/
3152/*----------------------------------------------------------------------------*/
3153VOID
3154nicInitMGMT (
3155 IN P_ADAPTER_T prAdapter,
3156 IN P_REG_INFO_T prRegInfo
3157 )
3158{
3159 ASSERT(prAdapter);
3160
3161 /* CNM Module - initialization */
3162 cnmInit(prAdapter);
3163
3164 /* RLM Module - initialization */
3165 rlmFsmEventInit(prAdapter);
3166
3167 /* SCN Module - initialization */
3168 scnInit(prAdapter);
3169
3170 /* AIS Module - intiailization */
3171 aisInitializeConnectionSettings(prAdapter, prRegInfo);
3172 aisFsmInit(prAdapter);
3173
3174#if CFG_SUPPORT_ROAMING
3175 /* Roaming Module - intiailization */
3176 roamingFsmInit(prAdapter);
3177#endif /* CFG_SUPPORT_ROAMING */
3178
3179#if CFG_SUPPORT_SWCR
3180 swCrDebugInit(prAdapter);
3181#endif /* CFG_SUPPORT_SWCR */
3182
3183#if (CFG_SUPPORT_TDLS == 1)
3184 TdlsexInit(prAdapter);
3185#endif /* CFG_SUPPORT_TDLS */
3186
3187 return;
3188}
3189
3190
3191/*----------------------------------------------------------------------------*/
3192/*!
3193* @brief This utility function is used to update WMM Parms
3194*
3195* @param prAdapter Pointer of ADAPTER_T
3196*
3197* @retval none
3198*/
3199/*----------------------------------------------------------------------------*/
3200VOID
3201nicUninitMGMT (
3202 IN P_ADAPTER_T prAdapter
3203 )
3204{
3205 ASSERT(prAdapter);
3206
3207#if CFG_SUPPORT_SWCR
3208 swCrDebugUninit(prAdapter);
3209#endif /* CFG_SUPPORT_SWCR */
3210
3211#if CFG_SUPPORT_ROAMING
3212 /* Roaming Module - unintiailization */
3213 roamingFsmUninit(prAdapter);
3214#endif /* CFG_SUPPORT_ROAMING */
3215
3216 /* AIS Module - unintiailization */
3217 aisFsmUninit(prAdapter);
3218
3219 /* SCN Module - unintiailization */
3220 scnUninit(prAdapter);
3221
3222 /* RLM Module - uninitialization */
3223 rlmFsmEventUninit(prAdapter);
3224
3225 /* CNM Module - uninitialization */
3226 cnmUninit(prAdapter);
3227
3228#if (CFG_SUPPORT_TDLS == 1)
3229 TdlsexUninit(prAdapter);
3230#endif /* CFG_SUPPORT_TDLS */
3231 return;
3232}
3233
3234
3235#if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
3236/*----------------------------------------------------------------------------*/
3237/*!
3238* @brief This utility function is to inform firmware to enable MCU clock gating
3239*
3240* @param prAdapter Pointer of ADAPTER_T
3241*
3242* @retval none
3243*/
3244/*----------------------------------------------------------------------------*/
3245WLAN_STATUS
3246nicEnableClockGating (
3247 IN P_ADAPTER_T prAdapter
3248 )
3249{
3250 UINT_32 i, u4WHISR = 0;
3251
3252 ASSERT(prAdapter);
3253
3254 if(prAdapter->fgIsClockGatingEnabled == TRUE) {
3255 return WLAN_STATUS_SUCCESS;
3256 }
3257 else {
3258 nicSetSwIntr(prAdapter, REQ_GATING_ENABLE_H2D_INT);
3259
3260 i = 0;
3261 while(i < GATING_CONTROL_POLL_LIMIT) {
3262 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
3263 || fgIsBusAccessFailed == TRUE) {
3264 return WLAN_STATUS_FAILURE;
3265 }
3266
3267 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
3268
3269 if(u4WHISR & ACK_GATING_ENABLE_D2H_INT) {
3270 prAdapter->fgIsClockGatingEnabled = TRUE;
3271 return WLAN_STATUS_SUCCESS;
3272 }
3273 }
3274
3275 ASSERT(0);
3276 return WLAN_STATUS_PENDING;
3277 }
3278}
3279
3280
3281/*----------------------------------------------------------------------------*/
3282/*!
3283* @brief This utility function is to inform firmware to disable MCU clock gating
3284*
3285* @param prAdapter Pointer of ADAPTER_T
3286*
3287* @retval none
3288*/
3289/*----------------------------------------------------------------------------*/
3290WLAN_STATUS
3291nicDisableClockGating (
3292 IN P_ADAPTER_T prAdapter
3293 )
3294{
3295 UINT_32 i, u4WHISR = 0;
3296
3297 ASSERT(prAdapter);
3298
3299 if(prAdapter->fgIsClockGatingEnabled == FALSE) {
3300 return WLAN_STATUS_SUCCESS;
3301 }
3302 else {
3303 nicSetSwIntr(prAdapter, REQ_GATING_DISABLE_H2D_INT);
3304
3305 i = 0;
3306 while(i < GATING_CONTROL_POLL_LIMIT) {
3307 if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
3308 || fgIsBusAccessFailed == TRUE) {
3309 return WLAN_STATUS_FAILURE;
3310 }
3311
3312 HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
3313
3314 if(u4WHISR & ACK_GATING_DISABLE_D2H_INT) {
3315 prAdapter->fgIsClockGatingEnabled = FALSE;
3316 return WLAN_STATUS_SUCCESS;
3317 }
3318 }
3319
3320 ASSERT(0);
3321 return WLAN_STATUS_PENDING;
3322 }
3323}
3324#endif
3325
3326
3327/*----------------------------------------------------------------------------*/
3328/*!
3329* @brief This function is invoked to buffer scan result
3330*
3331* @param prAdapter Pointer to the Adapter structure.
3332* @param rMacAddr BSSID
3333* @param prSsid Pointer to SSID
3334* @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
3335* @param rRssi Received Strength (-10 ~ -200 dBm)
3336* @param eNetworkType Network Type (a/b/g)
3337* @param prConfiguration Network Parameter
3338* @param eOpMode Infra/Ad-Hoc
3339* @param rSupportedRates Supported basic rates
3340* @param u2IELength IE Length
3341* @param pucIEBuf Pointer to Information Elements(IEs)
3342*
3343* @return (none)
3344*/
3345/*----------------------------------------------------------------------------*/
3346VOID
3347nicAddScanResult (
3348 IN P_ADAPTER_T prAdapter,
3349 IN PARAM_MAC_ADDRESS rMacAddr,
3350 IN P_PARAM_SSID_T prSsid,
3351 IN UINT_32 u4Privacy,
3352 IN PARAM_RSSI rRssi,
3353 IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType,
3354 IN P_PARAM_802_11_CONFIG_T prConfiguration,
3355 IN ENUM_PARAM_OP_MODE_T eOpMode,
3356 IN PARAM_RATES_EX rSupportedRates,
3357 IN UINT_16 u2IELength,
3358 IN PUINT_8 pucIEBuf
3359 )
3360{
3361 BOOLEAN bReplace;
3362 UINT_32 i;
3363 UINT_32 u4IdxWeakest = 0;
3364 PARAM_RSSI rWeakestRssi;
3365 UINT_32 u4BufferSize;
3366
3367 ASSERT(prAdapter);
3368
3369 rWeakestRssi = (PARAM_RSSI)INT_MAX;
3370 u4BufferSize = sizeof(prAdapter->rWlanInfo.aucScanIEBuf) / sizeof(prAdapter->rWlanInfo.aucScanIEBuf[0]);
3371
3372 bReplace = FALSE;
3373
3374 // decide to replace or add
3375 for(i = 0 ; i < prAdapter->rWlanInfo.u4ScanResultNum ; i++) {
3376 // find weakest entry && not connected one
3377 if(UNEQUAL_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, prAdapter->rWlanInfo.rCurrBssId.arMacAddress)
3378 && prAdapter->rWlanInfo.arScanResult[i].rRssi < rWeakestRssi) {
3379 u4IdxWeakest = i;
3380 rWeakestRssi = prAdapter->rWlanInfo.arScanResult[i].rRssi;
3381 }
3382
3383 if(prAdapter->rWlanInfo.arScanResult[i].eOpMode == eOpMode &&
3384 EQUAL_MAC_ADDR(&(prAdapter->rWlanInfo.arScanResult[i].arMacAddress), rMacAddr) &&
3385 (EQUAL_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3386 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3387 prSsid->aucSsid,
3388 prSsid->u4SsidLen)
3389 || prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen == 0)) {
3390 // replace entry
3391 bReplace = TRUE;
3392
3393 // free IE buffer then zero
3394 nicFreeScanResultIE(prAdapter, i);
3395 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]), OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3396
3397 // then fill buffer
3398 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3399 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3400 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3401 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3402 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3403 prSsid->aucSsid,
3404 prSsid->u4SsidLen);
3405 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3406 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3407 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3408 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3409 prConfiguration,
3410 sizeof(PARAM_802_11_CONFIG_T));
3411 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3412 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3413 rSupportedRates,
3414 sizeof(PARAM_RATES_EX));
3415 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3416
3417 // IE - allocate buffer and update pointer
3418 if(u2IELength > 0) {
3419 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3420 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3421 pucIEBuf,
3422 u2IELength);
3423
3424 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3425 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3426
3427 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3428 }
3429 else {
3430 // buffer is not enough
3431 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3432 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3433 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3434 }
3435 }
3436 else {
3437 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3438 }
3439
3440 break;
3441 }
3442 }
3443
3444 if (bReplace == FALSE) {
3445 if (prAdapter->rWlanInfo.u4ScanResultNum < (CFG_MAX_NUM_BSS_LIST - 1)) {
3446 i = prAdapter->rWlanInfo.u4ScanResultNum;
3447
3448 // zero
3449 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3450 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3451
3452 // then fill buffer
3453 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3454 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3455 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3456 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3457 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3458 prSsid->aucSsid,
3459 prSsid->u4SsidLen);
3460 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3461 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3462 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3463 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3464 prConfiguration,
3465 sizeof(PARAM_802_11_CONFIG_T));
3466 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3467 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3468 rSupportedRates,
3469 sizeof(PARAM_RATES_EX));
3470 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3471
3472 // IE - allocate buffer and update pointer
3473 if(u2IELength > 0) {
3474 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3475 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3476 pucIEBuf,
3477 u2IELength);
3478
3479 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3480 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3481
3482 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3483 }
3484 else {
3485 // buffer is not enough
3486 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3487 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3488 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3489 }
3490 }
3491 else {
3492 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3493 }
3494
3495 prAdapter->rWlanInfo.u4ScanResultNum++;
3496 }
3497 else if(rWeakestRssi != (PARAM_RSSI)INT_MAX) {
3498 // replace weakest one
3499 i = u4IdxWeakest;
3500
3501 // free IE buffer then zero
3502 nicFreeScanResultIE(prAdapter, i);
3503 kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]),
3504 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
3505
3506 // then fill buffer
3507 prAdapter->rWlanInfo.arScanResult[i].u4Length =
3508 OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
3509 COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
3510 COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
3511 prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
3512 prSsid->aucSsid,
3513 prSsid->u4SsidLen);
3514 prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
3515 prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
3516 prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
3517 kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
3518 prConfiguration,
3519 sizeof(PARAM_802_11_CONFIG_T));
3520 prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
3521 kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
3522 rSupportedRates,
3523 sizeof(PARAM_RATES_EX));
3524 prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32)u2IELength;
3525
3526 if(u2IELength > 0) {
3527 // IE - allocate buffer and update pointer
3528 if(ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
3529 kalMemCopy(&(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
3530 pucIEBuf,
3531 u2IELength);
3532
3533 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3534 &(prAdapter->rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
3535
3536 prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
3537 }
3538 else {
3539 // buffer is not enough
3540 prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
3541 prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
3542 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3543 }
3544 }
3545 else {
3546 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3547 }
3548 }
3549 }
3550}
3551
3552
3553/*----------------------------------------------------------------------------*/
3554/*!
3555* @brief This function is invoked to free IE buffer for dedicated scan result
3556*
3557* @param prAdapter Pointer to the Adapter structure.
3558* @param u4Idx Index of Scan Result
3559*
3560* @return (none)
3561*/
3562/*----------------------------------------------------------------------------*/
3563VOID
3564nicFreeScanResultIE (
3565 IN P_ADAPTER_T prAdapter,
3566 IN UINT_32 u4Idx
3567 )
3568{
3569 UINT_32 i;
3570 PUINT_8 pucPivot, pucMovePivot;
3571 UINT_32 u4MoveSize, u4FreeSize, u4ReserveSize;
3572
3573 ASSERT(prAdapter);
3574 ASSERT(u4Idx < CFG_MAX_NUM_BSS_LIST);
3575
3576 if(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength == 0
3577 || prAdapter->rWlanInfo.apucScanResultIEs[u4Idx] == NULL) {
3578 return;
3579 }
3580
3581 u4FreeSize = ALIGN_4(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength);
3582
3583 pucPivot = prAdapter->rWlanInfo.apucScanResultIEs[u4Idx];
3584 pucMovePivot = (PUINT_8)((ULONG)(prAdapter->rWlanInfo.apucScanResultIEs[u4Idx]) + u4FreeSize);
3585
3586 u4ReserveSize = ((ULONG)pucPivot) - (ULONG)(&(prAdapter->rWlanInfo.aucScanIEBuf[0]));
3587 u4MoveSize = prAdapter->rWlanInfo.u4ScanIEBufferUsage - u4ReserveSize - u4FreeSize;
3588
3589 // 1. rest of buffer to move forward
3590 kalMemCopy(pucPivot, pucMovePivot, u4MoveSize);
3591
3592 // 1.1 modify pointers
3593 for(i = 0 ; i < prAdapter->rWlanInfo.u4ScanResultNum ; i++) {
3594 if(i != u4Idx) {
3595 if(prAdapter->rWlanInfo.apucScanResultIEs[i] >= pucMovePivot) {
3596 prAdapter->rWlanInfo.apucScanResultIEs[i] =
3597 (PUINT_8)((ULONG)(prAdapter->rWlanInfo.apucScanResultIEs[i]) - u4FreeSize);
3598 }
3599 }
3600 }
3601
3602 // 1.2 reset the freed one
3603 prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength = 0;
3604 prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
3605
3606 // 2. reduce IE buffer usage
3607 prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4FreeSize;
3608
3609 return;
3610}
3611
3612
3613/*----------------------------------------------------------------------------*/
3614/*!
3615* @brief This function is to hack parameters for WLAN TABLE for
3616* fixed rate settings
3617*
3618* @param prAdapter Pointer to the Adapter structure.
3619* @param eRateSetting
3620* @param pu2DesiredNonHTRateSet,
3621* @param pu2BSSBasicRateSet,
3622* @param pucMcsSet
3623* @param pucSupMcs32
3624* @param pu2HtCapInfo
3625*
3626* @return WLAN_STATUS_SUCCESS
3627*/
3628/*----------------------------------------------------------------------------*/
3629WLAN_STATUS
3630nicUpdateRateParams (
3631 IN P_ADAPTER_T prAdapter,
3632 IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting,
3633 IN PUINT_8 pucDesiredPhyTypeSet,
3634 IN PUINT_16 pu2DesiredNonHTRateSet,
3635 IN PUINT_16 pu2BSSBasicRateSet,
3636 IN PUINT_8 pucMcsSet,
3637 IN PUINT_8 pucSupMcs32,
3638 IN PUINT_16 pu2HtCapInfo
3639 )
3640{
3641 ASSERT(prAdapter);
3642 ASSERT(eRateSetting > FIXED_RATE_NONE && eRateSetting < FIXED_RATE_NUM);
3643
3644 switch(prAdapter->rWifiVar.eRateSetting) {
3645 case FIXED_RATE_1M:
3646 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3647 *pu2DesiredNonHTRateSet = RATE_SET_BIT_1M;
3648 *pu2BSSBasicRateSet = RATE_SET_BIT_1M;
3649 *pucMcsSet = 0;
3650 *pucSupMcs32 = 0;
3651 *pu2HtCapInfo = 0;
3652 break;
3653
3654 case FIXED_RATE_2M:
3655 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3656 *pu2DesiredNonHTRateSet = RATE_SET_BIT_2M;
3657 *pu2BSSBasicRateSet = RATE_SET_BIT_2M;
3658 *pucMcsSet = 0;
3659 *pucSupMcs32 = 0;
3660 *pu2HtCapInfo = 0;
3661 break;
3662
3663 case FIXED_RATE_5_5M:
3664 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3665 *pu2DesiredNonHTRateSet = RATE_SET_BIT_5_5M;
3666 *pu2BSSBasicRateSet = RATE_SET_BIT_5_5M;
3667 *pucMcsSet = 0;
3668 *pucSupMcs32 = 0;
3669 *pu2HtCapInfo = 0;
3670 break;
3671
3672 case FIXED_RATE_11M:
3673 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
3674 *pu2DesiredNonHTRateSet = RATE_SET_BIT_11M;
3675 *pu2BSSBasicRateSet = RATE_SET_BIT_11M;
3676 *pucMcsSet = 0;
3677 *pucSupMcs32 = 0;
3678 *pu2HtCapInfo = 0;
3679 break;
3680
3681 case FIXED_RATE_6M:
3682 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3683 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3684 }
3685 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3686 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3687 }
3688
3689 *pu2DesiredNonHTRateSet = RATE_SET_BIT_6M;
3690 *pu2BSSBasicRateSet = RATE_SET_BIT_6M;
3691 *pucMcsSet = 0;
3692 *pucSupMcs32 = 0;
3693 *pu2HtCapInfo = 0;
3694 break;
3695
3696 case FIXED_RATE_9M:
3697 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3698 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3699 }
3700 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3701 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3702 }
3703
3704 *pu2DesiredNonHTRateSet = RATE_SET_BIT_9M;
3705 *pu2BSSBasicRateSet = RATE_SET_BIT_9M;
3706 *pucMcsSet = 0;
3707 *pucSupMcs32 = 0;
3708 *pu2HtCapInfo = 0;
3709 break;
3710
3711 case FIXED_RATE_12M:
3712 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3713 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3714 }
3715 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3716 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3717 }
3718
3719 *pu2DesiredNonHTRateSet = RATE_SET_BIT_12M;
3720 *pu2BSSBasicRateSet = RATE_SET_BIT_12M;
3721 *pucMcsSet = 0;
3722 *pucSupMcs32 = 0;
3723 *pu2HtCapInfo = 0;
3724 break;
3725
3726 case FIXED_RATE_18M:
3727 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3728 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3729 }
3730 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3731 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3732 }
3733
3734 *pu2DesiredNonHTRateSet = RATE_SET_BIT_18M;
3735 *pu2BSSBasicRateSet = RATE_SET_BIT_18M;
3736 *pucMcsSet = 0;
3737 *pucSupMcs32 = 0;
3738 *pu2HtCapInfo = 0;
3739 break;
3740
3741 case FIXED_RATE_24M:
3742 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3743 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3744 }
3745 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3746 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3747 }
3748
3749 *pu2DesiredNonHTRateSet = RATE_SET_BIT_24M;
3750 *pu2BSSBasicRateSet = RATE_SET_BIT_24M;
3751 *pucMcsSet = 0;
3752 *pucSupMcs32 = 0;
3753 *pu2HtCapInfo = 0;
3754 break;
3755
3756 case FIXED_RATE_36M:
3757 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3758 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3759 }
3760 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3761 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3762 }
3763
3764 *pu2DesiredNonHTRateSet = RATE_SET_BIT_36M;
3765 *pu2BSSBasicRateSet = RATE_SET_BIT_36M;
3766 *pucMcsSet = 0;
3767 *pucSupMcs32 = 0;
3768 *pu2HtCapInfo = 0;
3769 break;
3770
3771 case FIXED_RATE_48M:
3772 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3773 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3774 }
3775 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3776 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3777 }
3778
3779 *pu2DesiredNonHTRateSet = RATE_SET_BIT_48M;
3780 *pu2BSSBasicRateSet = RATE_SET_BIT_48M;
3781 *pucMcsSet = 0;
3782 *pucSupMcs32 = 0;
3783 *pu2HtCapInfo = 0;
3784 break;
3785
3786 case FIXED_RATE_54M:
3787 if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_ERP) {
3788 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
3789 }
3790 else if((*pucDesiredPhyTypeSet) | PHY_TYPE_BIT_OFDM) {
3791 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
3792 }
3793
3794 *pu2DesiredNonHTRateSet = RATE_SET_BIT_54M;
3795 *pu2BSSBasicRateSet = RATE_SET_BIT_54M;
3796 *pucMcsSet = 0;
3797 *pucSupMcs32 = 0;
3798 *pu2HtCapInfo = 0;
3799 break;
3800
3801 case FIXED_RATE_MCS0_20M_800NS:
3802 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3803 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3804 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3805 *pucMcsSet = HT_RATE_MCS0_INDEX;
3806 *pucSupMcs32 = 0;
3807 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3808 | HT_CAP_INFO_SHORT_GI_20M
3809 | HT_CAP_INFO_SHORT_GI_40M
3810 | HT_CAP_INFO_HT_GF);
3811 break;
3812
3813 case FIXED_RATE_MCS1_20M_800NS:
3814 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3815 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3816 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3817 *pucMcsSet = HT_RATE_MCS1_INDEX;
3818 *pucSupMcs32 = 0;
3819 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3820 | HT_CAP_INFO_SHORT_GI_20M
3821 | HT_CAP_INFO_SHORT_GI_40M
3822 | HT_CAP_INFO_HT_GF);
3823 break;
3824
3825 case FIXED_RATE_MCS2_20M_800NS:
3826 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3827 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3828 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3829 *pucMcsSet = HT_RATE_MCS2_INDEX;
3830 *pucSupMcs32 = 0;
3831 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3832 | HT_CAP_INFO_SHORT_GI_20M
3833 | HT_CAP_INFO_SHORT_GI_40M
3834 | HT_CAP_INFO_HT_GF);
3835 break;
3836
3837 case FIXED_RATE_MCS3_20M_800NS:
3838 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3839 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3840 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3841 *pucMcsSet = HT_RATE_MCS3_INDEX;
3842 *pucSupMcs32 = 0;
3843 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3844 | HT_CAP_INFO_SHORT_GI_20M
3845 | HT_CAP_INFO_SHORT_GI_40M
3846 | HT_CAP_INFO_HT_GF);
3847 break;
3848
3849 case FIXED_RATE_MCS4_20M_800NS:
3850 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3851 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3852 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3853 *pucMcsSet = HT_RATE_MCS4_INDEX;
3854 *pucSupMcs32 = 0;
3855 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3856 | HT_CAP_INFO_SHORT_GI_20M
3857 | HT_CAP_INFO_SHORT_GI_40M
3858 | HT_CAP_INFO_HT_GF);
3859 break;
3860
3861 case FIXED_RATE_MCS5_20M_800NS:
3862 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3863 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3864 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3865 *pucMcsSet = HT_RATE_MCS5_INDEX;
3866 *pucSupMcs32 = 0;
3867 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3868 | HT_CAP_INFO_SHORT_GI_20M
3869 | HT_CAP_INFO_SHORT_GI_40M
3870 | HT_CAP_INFO_HT_GF);
3871 break;
3872
3873 case FIXED_RATE_MCS6_20M_800NS:
3874 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3875 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3876 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3877 *pucMcsSet = HT_RATE_MCS6_INDEX;
3878 *pucSupMcs32 = 0;
3879 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3880 | HT_CAP_INFO_SHORT_GI_20M
3881 | HT_CAP_INFO_SHORT_GI_40M
3882 | HT_CAP_INFO_HT_GF);
3883 break;
3884
3885 case FIXED_RATE_MCS7_20M_800NS:
3886 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3887 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3888 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3889 *pucMcsSet = HT_RATE_MCS7_INDEX;
3890 *pucSupMcs32 = 0;
3891 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3892 | HT_CAP_INFO_SHORT_GI_20M
3893 | HT_CAP_INFO_SHORT_GI_40M
3894 | HT_CAP_INFO_HT_GF);
3895 break;
3896
3897 case FIXED_RATE_MCS0_20M_400NS:
3898 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3899 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3900 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3901 *pucMcsSet = HT_RATE_MCS0_INDEX;
3902 *pucSupMcs32 = 0;
3903 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3904 | HT_CAP_INFO_SHORT_GI_40M
3905 | HT_CAP_INFO_HT_GF);
3906 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3907 break;
3908
3909 case FIXED_RATE_MCS1_20M_400NS:
3910 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3911 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3912 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3913 *pucMcsSet = HT_RATE_MCS1_INDEX;
3914 *pucSupMcs32 = 0;
3915 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3916 | HT_CAP_INFO_SHORT_GI_40M
3917 | HT_CAP_INFO_HT_GF);
3918 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3919 break;
3920
3921 case FIXED_RATE_MCS2_20M_400NS:
3922 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3923 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3924 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3925 *pucMcsSet = HT_RATE_MCS2_INDEX;
3926 *pucSupMcs32 = 0;
3927 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3928 | HT_CAP_INFO_SHORT_GI_40M
3929 | HT_CAP_INFO_HT_GF);
3930 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3931 break;
3932
3933 case FIXED_RATE_MCS3_20M_400NS:
3934 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3935 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3936 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3937 *pucMcsSet = HT_RATE_MCS3_INDEX;
3938 *pucSupMcs32 = 0;
3939 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3940 | HT_CAP_INFO_SHORT_GI_40M
3941 | HT_CAP_INFO_HT_GF);
3942 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3943 break;
3944
3945 case FIXED_RATE_MCS4_20M_400NS:
3946 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3947 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3948 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3949 *pucMcsSet = HT_RATE_MCS4_INDEX;
3950 *pucSupMcs32 = 0;
3951 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3952 | HT_CAP_INFO_SHORT_GI_40M
3953 | HT_CAP_INFO_HT_GF);
3954 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3955 break;
3956
3957 case FIXED_RATE_MCS5_20M_400NS:
3958 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3959 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3960 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3961 *pucMcsSet = HT_RATE_MCS5_INDEX;
3962 *pucSupMcs32 = 0;
3963 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3964 | HT_CAP_INFO_SHORT_GI_40M
3965 | HT_CAP_INFO_HT_GF);
3966 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3967 break;
3968
3969 case FIXED_RATE_MCS6_20M_400NS:
3970 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3971 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3972 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3973 *pucMcsSet = HT_RATE_MCS6_INDEX;
3974 *pucSupMcs32 = 0;
3975 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3976 | HT_CAP_INFO_SHORT_GI_40M
3977 | HT_CAP_INFO_HT_GF);
3978 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3979 break;
3980
3981 case FIXED_RATE_MCS7_20M_400NS:
3982 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3983 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3984 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3985 *pucMcsSet = HT_RATE_MCS7_INDEX;
3986 *pucSupMcs32 = 0;
3987 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
3988 | HT_CAP_INFO_SHORT_GI_40M
3989 | HT_CAP_INFO_HT_GF);
3990 (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
3991 break;
3992
3993 case FIXED_RATE_MCS0_40M_800NS:
3994 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
3995 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
3996 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
3997 *pucMcsSet = HT_RATE_MCS0_INDEX;
3998 *pucSupMcs32 = 0;
3999 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4000 | HT_CAP_INFO_SHORT_GI_40M
4001 | HT_CAP_INFO_HT_GF);
4002 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4003 break;
4004
4005 case FIXED_RATE_MCS1_40M_800NS:
4006 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4007 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4008 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4009 *pucMcsSet = HT_RATE_MCS1_INDEX;
4010 *pucSupMcs32 = 0;
4011 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4012 | HT_CAP_INFO_SHORT_GI_40M
4013 | HT_CAP_INFO_HT_GF);
4014 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4015 break;
4016
4017 case FIXED_RATE_MCS2_40M_800NS:
4018 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4019 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4020 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4021 *pucMcsSet = HT_RATE_MCS2_INDEX;
4022 *pucSupMcs32 = 0;
4023 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4024 | HT_CAP_INFO_SHORT_GI_40M
4025 | HT_CAP_INFO_HT_GF);
4026 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4027 break;
4028
4029 case FIXED_RATE_MCS3_40M_800NS:
4030 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4031 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4032 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4033 *pucMcsSet = HT_RATE_MCS3_INDEX;
4034 *pucSupMcs32 = 0;
4035 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4036 | HT_CAP_INFO_SHORT_GI_40M
4037 | HT_CAP_INFO_HT_GF);
4038 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4039 break;
4040
4041 case FIXED_RATE_MCS4_40M_800NS:
4042 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4043 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4044 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4045 *pucMcsSet = HT_RATE_MCS4_INDEX;
4046 *pucSupMcs32 = 0;
4047 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4048 | HT_CAP_INFO_SHORT_GI_40M
4049 | HT_CAP_INFO_HT_GF);
4050 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4051 break;
4052
4053 case FIXED_RATE_MCS5_40M_800NS:
4054 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4055 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4056 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4057 *pucMcsSet = HT_RATE_MCS5_INDEX;
4058 *pucSupMcs32 = 0;
4059 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4060 | HT_CAP_INFO_SHORT_GI_40M
4061 | HT_CAP_INFO_HT_GF);
4062 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4063 break;
4064
4065 case FIXED_RATE_MCS6_40M_800NS:
4066 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4067 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4068 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4069 *pucMcsSet = HT_RATE_MCS6_INDEX;
4070 *pucSupMcs32 = 0;
4071 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4072 | HT_CAP_INFO_SHORT_GI_40M
4073 | HT_CAP_INFO_HT_GF);
4074 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4075 break;
4076
4077 case FIXED_RATE_MCS7_40M_800NS:
4078 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4079 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4080 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4081 *pucMcsSet = HT_RATE_MCS7_INDEX;
4082 *pucSupMcs32 = 0;
4083 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4084 | HT_CAP_INFO_SHORT_GI_40M
4085 | HT_CAP_INFO_HT_GF);
4086 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4087 break;
4088
4089 case FIXED_RATE_MCS32_800NS:
4090 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4091 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4092 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4093 *pucMcsSet = HT_RATE_MCS32_INDEX;
4094 *pucSupMcs32 = 1;
4095 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4096 | HT_CAP_INFO_SHORT_GI_40M
4097 | HT_CAP_INFO_HT_GF);
4098 (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
4099 break;
4100
4101 case FIXED_RATE_MCS0_40M_400NS:
4102 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4103 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4104 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4105 *pucMcsSet = HT_RATE_MCS0_INDEX;
4106 *pucSupMcs32 = 0;
4107 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4108 | HT_CAP_INFO_HT_GF);
4109 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4110 | HT_CAP_INFO_SHORT_GI_40M);
4111 break;
4112
4113 case FIXED_RATE_MCS1_40M_400NS:
4114 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4115 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4116 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4117 *pucMcsSet = HT_RATE_MCS1_INDEX;
4118 *pucSupMcs32 = 0;
4119 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4120 | HT_CAP_INFO_HT_GF);
4121 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4122 | HT_CAP_INFO_SHORT_GI_40M);
4123 break;
4124
4125 case FIXED_RATE_MCS2_40M_400NS:
4126 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4127 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4128 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4129 *pucMcsSet = HT_RATE_MCS2_INDEX;
4130 *pucSupMcs32 = 0;
4131 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4132 | HT_CAP_INFO_HT_GF);
4133 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4134 | HT_CAP_INFO_SHORT_GI_40M);
4135 break;
4136
4137 case FIXED_RATE_MCS3_40M_400NS:
4138 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4139 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4140 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4141 *pucMcsSet = HT_RATE_MCS3_INDEX;
4142 *pucSupMcs32 = 0;
4143 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4144 | HT_CAP_INFO_HT_GF);
4145 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4146 | HT_CAP_INFO_SHORT_GI_40M);
4147 break;
4148
4149 case FIXED_RATE_MCS4_40M_400NS:
4150 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4151 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4152 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4153 *pucMcsSet = HT_RATE_MCS4_INDEX;
4154 *pucSupMcs32 = 0;
4155 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4156 | HT_CAP_INFO_HT_GF);
4157 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4158 | HT_CAP_INFO_SHORT_GI_40M);
4159 break;
4160
4161 case FIXED_RATE_MCS5_40M_400NS:
4162 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4163 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4164 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4165 *pucMcsSet = HT_RATE_MCS5_INDEX;
4166 *pucSupMcs32 = 0;
4167 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4168 | HT_CAP_INFO_HT_GF);
4169 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4170 | HT_CAP_INFO_SHORT_GI_40M);
4171 break;
4172
4173 case FIXED_RATE_MCS6_40M_400NS:
4174 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4175 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4176 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4177 *pucMcsSet = HT_RATE_MCS6_INDEX;
4178 *pucSupMcs32 = 0;
4179 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4180 | HT_CAP_INFO_HT_GF);
4181 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4182 | HT_CAP_INFO_SHORT_GI_40M);
4183 break;
4184
4185 case FIXED_RATE_MCS7_40M_400NS:
4186 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4187 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4188 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4189 *pucMcsSet = HT_RATE_MCS7_INDEX;
4190 *pucSupMcs32 = 0;
4191 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4192 | HT_CAP_INFO_HT_GF);
4193 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4194 | HT_CAP_INFO_SHORT_GI_40M);
4195 break;
4196
4197 case FIXED_RATE_MCS32_400NS:
4198 *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
4199 *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
4200 *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
4201 *pucMcsSet = HT_RATE_MCS32_INDEX;
4202 *pucSupMcs32 = 1;
4203 (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M
4204 | HT_CAP_INFO_HT_GF);
4205 (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH
4206 | HT_CAP_INFO_SHORT_GI_40M);
4207 break;
4208
4209 default:
4210 ASSERT(0);
4211 }
4212
4213 return WLAN_STATUS_SUCCESS;
4214}
4215
4216/*----------------------------------------------------------------------------*/
4217/*!
4218* @brief This utility function is used to write the register
4219*
4220* @param u4Address Register address
4221* u4Value the value to be written
4222*
4223* @retval WLAN_STATUS_SUCCESS
4224* WLAN_STATUS_FAILURE
4225*/
4226/*----------------------------------------------------------------------------*/
4227
4228WLAN_STATUS
4229nicWriteMcr (
4230 IN P_ADAPTER_T prAdapter,
4231 IN UINT_32 u4Address,
4232 IN UINT_32 u4Value
4233 )
4234{
4235 CMD_ACCESS_REG rCmdAccessReg;
4236
4237 rCmdAccessReg.u4Address = u4Address;
4238 rCmdAccessReg.u4Data = u4Value;
4239
4240 return wlanSendSetQueryCmd(prAdapter,
4241 CMD_ID_ACCESS_REG,
4242 TRUE,
4243 FALSE,
4244 FALSE,
4245 NULL,
4246 NULL,
4247 sizeof(CMD_ACCESS_REG),
4248 (PUINT_8)&rCmdAccessReg,
4249 NULL,
4250 0
4251 );
4252
4253}
4254
4255/*----------------------------------------------------------------------------*/
4256/*!
4257* @brief This utility function is used to modify the auto rate parameters
4258*
4259* @param u4ArSysParam0 see description below
4260* u4ArSysParam1
4261* u4ArSysParam2
4262* u4ArSysParam3
4263*
4264*
4265* @retval WLAN_STATUS_SUCCESS
4266* WLAN_STATUS_FAILURE
4267*
4268* @note
4269* ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
4270* ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
4271* ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
4272* ArSysParam0[8:15]-> HT rate clear mask
4273* ArSysParam0[16:31]-> Legacy rate clear mask
4274* ArSysParam1[0:7]-> Auto Rate check weighting window
4275* ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
4276* ArSysParam1[16:23]-> Auto Rate v1 PerH
4277* ArSysParam1[24:31]-> Auto Rate v1 PerL
4278*
4279* Examples
4280* ArSysParam0 = 1,
4281* Enable auto rate version 1
4282*
4283* ArSysParam0 = 983041,
4284* Enable auto rate version 1
4285* Remove CCK 1M, 2M, 5.5M, 11M
4286*
4287* ArSysParam0 = 786433
4288* Enable auto rate version 1
4289* Remove CCK 5.5M 11M
4290*/
4291/*----------------------------------------------------------------------------*/
4292
4293
4294WLAN_STATUS
4295nicRlmArUpdateParms(
4296 IN P_ADAPTER_T prAdapter,
4297 IN UINT_32 u4ArSysParam0,
4298 IN UINT_32 u4ArSysParam1,
4299 IN UINT_32 u4ArSysParam2,
4300 IN UINT_32 u4ArSysParam3
4301 )
4302{
4303 UINT_8 ucArVer,ucAbwVer,ucAgiVer;
4304 UINT_16 u2HtClrMask;
4305 UINT_16 u2LegacyClrMask;
4306 UINT_8 ucArCheckWindow;
4307 UINT_8 ucArPerL;
4308 UINT_8 ucArPerH;
4309 UINT_8 ucArPerForceRateDownPer;
4310
4311 ucArVer = (UINT_8)(u4ArSysParam0 & BITS(0,3));
4312 ucAbwVer = (UINT_8)((u4ArSysParam0 & BITS(4,5)) >>4);
4313 ucAgiVer = (UINT_8)((u4ArSysParam0 & BITS(6,7)) >>6);
4314 u2HtClrMask = (UINT_16) ((u4ArSysParam0 & BITS(8,15)) >> 8);
4315 u2LegacyClrMask = (UINT_16) ((u4ArSysParam0 & BITS(16,31)) >> 16);
4316
4317#if 0
4318 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0,7));
4319 ucArPerForceRateDownPer = (UINT_8) ((u4ArSysParam1 & BITS(8,15)>>8));
4320 ucArPerH = (UINT_8) ((u4ArSysParam1 & BITS(16,23)) >>16);
4321 ucArPerL = (UINT_8) ((u4ArSysParam1 & BITS(24,31)) >>24);
4322#endif
4323
4324 ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0,7));
4325 ucArPerForceRateDownPer = (UINT_8) (((u4ArSysParam1>>8) & BITS(0,7)));
4326 ucArPerH = (UINT_8) (((u4ArSysParam1>>16) & BITS(0,7)));
4327 ucArPerL = (UINT_8) (((u4ArSysParam1>>24) & BITS(0,7)));
4328
4329
4330 DBGLOG(INIT, INFO, ("ArParam %u %u %u %u\n", u4ArSysParam0, u4ArSysParam1, u4ArSysParam2, u4ArSysParam3));
4331 DBGLOG(INIT, INFO, ("ArVer %u AbwVer %u AgiVer %u\n", ucArVer, ucAbwVer, ucAgiVer));
4332 DBGLOG(INIT, INFO, ("HtMask %x LegacyMask %x\n", u2HtClrMask, u2LegacyClrMask));
4333 DBGLOG(INIT, INFO, ("CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow, ucArPerForceRateDownPer, ucArPerH, ucArPerL));
4334
4335#define SWCR_DATA_ADDR(MOD,ADDR) (0x90000000+(MOD<<8)+(ADDR))
4336#define SWCR_DATA_CMD(CATE,WRITE,INDEX,OPT0,OPT1) ( (CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 <<8) | OPT1 )
4337#define SWCR_DATA0 0x0
4338#define SWCR_DATA1 0x4
4339#define SWCR_DATA2 0x8
4340#define SWCR_DATA3 0xC
4341#define SWCR_DATA4 0x10
4342#define SWCR_WRITE 1
4343#define SWCR_READ 0
4344
4345 if(ucArVer > 0) {
4346 /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
4347 /* dummy = WiFi.WriteMCR(&h90000100, &h00850000)*/
4348
4349 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),1);
4350 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,5,0,0));
4351 }
4352 else {
4353 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),0);
4354 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,5,0,0)) ;
4355 }
4356
4357 /* ucArVer 0: none 1:PER 2:Rcpi */
4358 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArVer);
4359 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,7,0,0));
4360
4361 /* Candidate rate Ht mask */
4362 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),u2HtClrMask);
4363 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1c,0,0));
4364
4365 /* Candidate rate legacy mask */
4366 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),u2LegacyClrMask);
4367 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1d,0,0));
4368
4369#if 0
4370 if(ucArCheckWindow!=0) {
4371 /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
4372 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArCheckWindow);
4373 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x14,0,0));
4374 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArCheckWindow);
4375 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0xc,0,0));
4376 }
4377
4378 if(ucArPerForceRateDownPer !=0) {
4379 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerForceRateDownPer);
4380 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x18,0,0));
4381 }
4382 if(ucArPerH !=0) {
4383 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerH);
4384 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x1,0,0));
4385 }
4386 if(ucArPerL !=0) {
4387 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA1),ucArPerL);
4388 nicWriteMcr (prAdapter, SWCR_DATA_ADDR(1/*MOD*/,SWCR_DATA0),SWCR_DATA_CMD(0,SWCR_WRITE,0x2,0,0));
4389 }
4390#endif
4391
4392
4393
4394 return WLAN_STATUS_SUCCESS;
4395}
4396
4397/*----------------------------------------------------------------------------*/
4398/*!
4399* @brief This utility function is used to enable roaming
4400*
4401* @param u4EnableRoaming
4402*
4403*
4404* @retval WLAN_STATUS_SUCCESS
4405* WLAN_STATUS_FAILURE
4406*
4407* @note
4408* u4EnableRoaming -> Enable Romaing
4409*
4410*/
4411/*----------------------------------------------------------------------------*/
4412WLAN_STATUS
4413nicRoamingUpdateParams(
4414 IN P_ADAPTER_T prAdapter,
4415 IN UINT_32 u4EnableRoaming
4416 )
4417{
4418 P_CONNECTION_SETTINGS_T prConnSettings;
4419
4420 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
4421 prConnSettings->fgIsEnableRoaming = ((u4EnableRoaming>0)?(TRUE):(FALSE));
4422
4423 return WLAN_STATUS_SUCCESS;
4424}
4425
4426/*----------------------------------------------------------------------------*/
4427/*!
4428* \brief dump firmware Assert message
4429*
4430* \param[in]
4431* prAdapter
4432*
4433* \return
4434* TRUE
4435* FALSE
4436*/
4437/*----------------------------------------------------------------------------*/
4438VOID
4439nicPrintFirmwareAssertInfo(
4440 IN P_ADAPTER_T prAdapter
4441 )
4442{
4443 UINT_32 u4MailBox0, u4MailBox1;
4444 UINT_32 line = 0;
4445 UINT_8 aucAssertFile[7];
4446 UINT_32 u4ChipId;
4447
4448#if CFG_SDIO_INTR_ENHANCE
4449 u4MailBox0 = prAdapter->prSDIOCtrl->u4RcvMailbox0;
4450 u4MailBox1 = prAdapter->prSDIOCtrl->u4RcvMailbox1;
4451#else
4452 nicGetMailbox(prAdapter, 0, &u4MailBox0);
4453 nicGetMailbox(prAdapter, 1, &u4MailBox1);
4454#endif
4455
4456 line = u4MailBox0 & 0x0000FFFF;
4457
4458 u4MailBox0 = ((u4MailBox0 >> 16) & 0x0000FFFF);
4459
4460 kalMemCopy(&aucAssertFile[0], &u4MailBox0, 2);
4461 kalMemCopy(&aucAssertFile[2], &u4MailBox1, 4);
4462
4463 aucAssertFile[6] = '\0';
4464
4465#if defined(MT6620)
4466 u4ChipId = 6620;
4467#elif defined(MT5931)
4468 u4ChipId = 5931;
4469#elif defined(MT6628)
4470 u4ChipId = 6582;
4471#endif
4472
4473 kalPrint("\n[MT%u][wifi][Firmware] Assert at \"%s\" #%u\n\n",
4474 u4ChipId,
4475 aucAssertFile,
4476 line);
4477
4478}
4479
4480
4481/*----------------------------------------------------------------------------*/
4482/*!
4483* @brief This function is called to update Link Quality information
4484*
4485* @param prAdapter Pointer of Adapter Data Structure
4486* eNetTypeIdx
4487* prEventLinkQuality
4488* cRssi
4489* cLinkQuality
4490*
4491* @return none
4492*/
4493/*----------------------------------------------------------------------------*/
4494VOID
4495nicUpdateLinkQuality(
4496 IN P_ADAPTER_T prAdapter,
4497 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4498 IN P_EVENT_LINK_QUALITY prEventLinkQuality
4499 )
4500{
4501 ASSERT(prAdapter);
4502 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4503 ASSERT(prEventLinkQuality);
4504
4505 switch(eNetTypeIdx) {
4506 case NETWORK_TYPE_AIS_INDEX:
4507 if(prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
4508 /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
4509 /* buffer statistics for further query */
4510 if(prAdapter->fgIsLinkQualityValid == FALSE
4511 || (kalGetTimeTick() - prAdapter->rLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4512 nicUpdateRSSI(prAdapter, eNetTypeIdx, prEventLinkQuality->cRssi, prEventLinkQuality->cLinkQuality);
4513 }
4514
4515 if(prAdapter->fgIsLinkRateValid == FALSE
4516 || (kalGetTimeTick() - prAdapter->rLinkRateUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4517 nicUpdateLinkSpeed(prAdapter, eNetTypeIdx, prEventLinkQuality->u2LinkSpeed);
4518 }
4519 }
4520 break;
4521#if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
4522 case NETWORK_TYPE_P2P_INDEX:
4523 if (prAdapter->fgIsP2pLinkQualityValid == FALSE
4524 || (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
4525 P_EVENT_LINK_QUALITY_EX prEventLQEx = (P_EVENT_LINK_QUALITY_EX)prEventLinkQuality;
4526
4527 nicUpdateRSSI(prAdapter, NETWORK_TYPE_P2P_INDEX, prEventLQEx->cRssiP2P, prEventLQEx->cLinkQualityP2P);
4528 }
4529 break;
4530#endif
4531 default:
4532 break;
4533
4534 }
4535
4536 return;
4537}
4538
4539
4540/*----------------------------------------------------------------------------*/
4541/*!
4542* @brief This function is called to update RSSI and Link Quality information
4543*
4544* @param prAdapter Pointer of Adapter Data Structure
4545* eNetTypeIdx
4546* cRssi
4547* cLinkQuality
4548*
4549* @return none
4550*/
4551/*----------------------------------------------------------------------------*/
4552VOID
4553nicUpdateRSSI(
4554 IN P_ADAPTER_T prAdapter,
4555 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4556 IN INT_8 cRssi,
4557 IN INT_8 cLinkQuality
4558 )
4559{
4560 ASSERT(prAdapter);
4561 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4562
4563 switch(eNetTypeIdx) {
4564 case NETWORK_TYPE_AIS_INDEX:
4565 if(prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
4566 prAdapter->fgIsLinkQualityValid = TRUE;
4567 prAdapter->rLinkQualityUpdateTime = kalGetTimeTick();
4568
4569 prAdapter->rLinkQuality.cRssi = cRssi;
4570 prAdapter->rLinkQuality.cLinkQuality = cLinkQuality;
4571
4572 /* indicate to glue layer */
4573 kalUpdateRSSI(prAdapter->prGlueInfo,
4574 KAL_NETWORK_TYPE_AIS_INDEX,
4575 prAdapter->rLinkQuality.cRssi,
4576 prAdapter->rLinkQuality.cLinkQuality);
4577 }
4578
4579 break;
4580#if CFG_ENABLE_WIFI_DIRECT
4581#if CFG_SUPPORT_P2P_RSSI_QUERY
4582 case NETWORK_TYPE_P2P_INDEX:
4583 prAdapter->fgIsP2pLinkQualityValid = TRUE;
4584 prAdapter->rP2pLinkQualityUpdateTime = kalGetTimeTick();
4585
4586 prAdapter->rP2pLinkQuality.cRssi= cRssi;
4587 prAdapter->rP2pLinkQuality.cLinkQuality= cLinkQuality;
4588
4589 kalUpdateRSSI(prAdapter->prGlueInfo,
4590 KAL_NETWORK_TYPE_P2P_INDEX,
4591 cRssi,
4592 cLinkQuality);
4593 break;
4594#endif
4595#endif
4596 default:
4597 break;
4598
4599 }
4600
4601 return;
4602}
4603
4604
4605/*----------------------------------------------------------------------------*/
4606/*!
4607* @brief This function is called to update Link Quality information
4608*
4609* @param prAdapter Pointer of Adapter Data Structure
4610* eNetTypeIdx
4611* prEventLinkQuality
4612* cRssi
4613* cLinkQuality
4614*
4615* @return none
4616*/
4617/*----------------------------------------------------------------------------*/
4618VOID
4619nicUpdateLinkSpeed(
4620 IN P_ADAPTER_T prAdapter,
4621 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx,
4622 IN UINT_16 u2LinkSpeed
4623 )
4624{
4625 ASSERT(prAdapter);
4626 ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
4627
4628 switch(eNetTypeIdx) {
4629 case NETWORK_TYPE_AIS_INDEX:
4630 if(prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
4631 /* buffer statistics for further query */
4632 prAdapter->fgIsLinkRateValid = TRUE;
4633 prAdapter->rLinkRateUpdateTime = kalGetTimeTick();
4634
4635 prAdapter->rLinkQuality.u2LinkSpeed = u2LinkSpeed;
4636 }
4637 break;
4638
4639 default:
4640 break;
4641
4642 }
4643
4644 return;
4645}
4646
4647#if CFG_SUPPORT_RDD_TEST_MODE
4648WLAN_STATUS
4649nicUpdateRddTestMode(
4650 IN P_ADAPTER_T prAdapter,
4651 IN P_CMD_RDD_CH_T prRddChParam
4652 )
4653{
4654 DEBUGFUNC("nicUpdateRddTestMode.\n");
4655
4656 ASSERT(prAdapter);
4657
4658// aisFsmScanRequest(prAdapter, NULL);
4659
4660 return wlanSendSetQueryCmd(prAdapter,
4661 CMD_ID_SET_RDD_CH,
4662 TRUE,
4663 FALSE,
4664 FALSE,
4665 NULL,
4666 NULL,
4667 sizeof(CMD_RDD_CH_T),
4668 (PUINT_8)prRddChParam,
4669 NULL,
4670 0);
4671}
4672#endif
4673