import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6628 / wlan / mgmt / bss.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/bss.c#3 $
3 */
4
5 /*! \file "bss.c"
6 \brief This file contains the functions for creating BSS(AP)/IBSS(AdHoc).
7
8 This file contains the functions for BSS(AP)/IBSS(AdHoc). We may create a BSS/IBSS
9 network, or merge with exist IBSS network and sending Beacon Frame or reply
10 the Probe Response Frame for received Probe Request Frame.
11 */
12
13
14
15 /*
16 ** $Log: bss.c $
17 **
18 ** 08 30 2012 chinglan.wang
19 ** [ALPS00349664] [6577JB][WIFI] Phone can not connect to AP secured with AES via WPS in 802.11n Only
20 ** .
21 **
22 ** 07 26 2012 yuche.tsai
23 ** [ALPS00324337] [ALPS.JB][Hot-Spot] Driver update for Hot-Spot
24 ** Update driver code of ALPS.JB for hot-spot.
25 *
26 * 07 17 2012 yuche.tsai
27 * NULL
28 * Let netdev bring up.
29 *
30 * 07 17 2012 yuche.tsai
31 * NULL
32 * Compile no error before trial run.
33 *
34 * 06 14 2012 chinglan.wang
35 * NULL
36 * Fix the losing of the HT IE in assoc request..
37 *
38 * 06 13 2012 yuche.tsai
39 * NULL
40 * Update maintrunk driver.
41 * Add support for driver compose assoc request frame.
42 *
43 * 03 08 2012 yuche.tsai
44 * NULL
45 * Fix FW assert when start Hot-Spot.
46 *
47 * 03 02 2012 terry.wu
48 * NULL
49 * Snc CFG80211 modification for ICS migration from branch 2.2.
50 *
51 * 01 20 2012 chinglan.wang
52 * 03 02 2012 terry.wu
53 * NULL
54 * Fix the WPA-PSK TKIP and WPA2-PSK AES security mode bug.
55 *
56 * NULL
57 * Sync CFG80211 modification from branch 2,2.
58 *
59 * 01 15 2012 yuche.tsai
60 * NULL
61 * Fix wrong basic rate issue.
62 *
63 * 01 13 2012 yuche.tsai
64 * NULL
65 * WiFi Hot Spot Tethering for ICS ALPHA testing version.
66 *
67 * 11 03 2011 cm.chang
68 * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
69 * Always set short slot time to TRUE initially in AP mode
70 *
71 * 11 03 2011 wh.su
72 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
73 * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
74 *
75 * 09 14 2011 yuche.tsai
76 * NULL
77 * Add P2P IE in assoc response.
78 *
79 * 04 18 2011 terry.wu
80 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
81 * Remove flag CFG_WIFI_DIRECT_MOVED.
82 *
83 * 04 12 2011 eddie.chen
84 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
85 * Fix the sta index in processing security frame
86 * Simple flow control for TC4 to avoid mgt frames for PS STA to occupy the TC4
87 * Add debug message.
88 *
89 * 04 08 2011 eddie.chen
90 * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
91 * Fix for sigma
92 *
93 * 03 29 2011 eddie.chen
94 * [WCXRP00000608] [MT6620 Wi-Fi][DRV] Change wmm parameters in beacon
95 * Change wmm parameters in beacon.
96 *
97 * 03 29 2011 yuche.tsai
98 * [WCXRP00000607] [Volunteer Patch][MT6620][Driver] Coding Style Fix for klocwork scan.
99 * Fix klocwork issue.
100 *
101 * 03 19 2011 yuche.tsai
102 * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
103 * Make assoc req to append P2P IE if wifi direct is enabled.
104 *
105 * 03 11 2011 chinglan.wang
106 * [WCXRP00000537] [MT6620 Wi-Fi][Driver] Can not connect to 802.11b/g/n mixed AP with WEP security.
107 * .
108 *
109 * 03 03 2011 george.huang
110 * [WCXRP00000508] [MT6620 Wi-Fi][Driver] aware of beacon MSDU will be free, after BSS deactivated
111 * .
112 *
113 * 03 03 2011 george.huang
114 * [WCXRP00000508] [MT6620 Wi-Fi][Driver] aware of beacon MSDU will be free, after BSS deactivated
115 * modify to handle if beacon MSDU been released when BSS deactivated
116 *
117 * 03 02 2011 wh.su
118 * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
119 * add code to let the beacon and probe response for Auto GO WSC .
120 *
121 * 03 02 2011 wh.su
122 * [WCXRP00000448] [MT6620 Wi-Fi][Driver] Fixed WSC IE not send out at probe request
123 * Add code to send beacon and probe response WSC IE at Auto GO.
124 *
125 * 02 17 2011 eddie.chen
126 * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
127 * 1) Chnage GetFrameAction decision when BSS is absent.
128 * 2) Check channel and resource in processing ProbeRequest
129 *
130 * 02 12 2011 yuche.tsai
131 * [WCXRP00000441] [Volunteer Patch][MT6620][Driver] BoW can not create desired station type when Hot Spot is enabled.
132 * bss should create station record type according to callers input.
133 *
134 * 02 11 2011 terry.wu
135 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
136 * In p2p link function, check networktype before calling p2p function.
137 *
138 * 02 11 2011 terry.wu
139 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
140 * Modify p2p link function to avoid assert.
141 *
142 * 01 26 2011 cm.chang
143 * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
144 * .
145 *
146 * 01 25 2011 yuche.tsai
147 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
148 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
149 *
150 * 01 25 2011 eddie.chen
151 * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
152 * Fix the compile error in windows.
153 *
154 * 01 24 2011 eddie.chen
155 * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
156 * Add destination decision in AP mode.
157 *
158 * 01 24 2011 terry.wu
159 * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
160 * .Fix typo and missing entry
161 *
162 * 12 30 2010 eddie.chen
163 * [WCXRP00000322] Add WMM IE in beacon,
164
165 Add per station flow control when STA is in PS
166
167
168 * Fix prBssInfo->aucCWminLog to prBssInfo->aucCWminLogForBcast
169 *
170 * 12 29 2010 eddie.chen
171 * [WCXRP00000322] Add WMM IE in beacon,
172
173 Add per station flow control when STA is in PS
174
175
176 * Add WMM parameter for broadcast.
177 *
178 * 12 29 2010 eddie.chen
179 * [WCXRP00000322] Add WMM IE in beacon,
180 Add per station flow control when STA is in PS
181
182 * 1) PS flow control event
183 *
184 * 2) WMM IE in beacon, assoc resp, probe resp
185 *
186 * 11 29 2010 cp.wu
187 * [WCXRP00000210] [MT6620 Wi-Fi][Driver][FW] Set RCPI value in STA_REC for initial TX rate selection of auto-rate algorithm
188 * update ucRcpi of STA_RECORD_T for AIS when
189 * 1) Beacons for IBSS merge is received
190 * 2) Associate Response for a connecting peer is received
191 *
192 * 10 18 2010 cp.wu
193 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
194 * use definition macro to replace hard-coded constant
195 *
196 * 10 08 2010 wh.su
197 * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
198 * update the frog's new p2p state machine.
199 *
200 * 09 28 2010 wh.su
201 * NULL
202 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
203 *
204 * 09 27 2010 chinghwa.yu
205 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
206 * Update BCM/BoW design and settings.
207 *
208 * 09 16 2010 cm.chang
209 * NULL
210 * Change conditional compiling options for BOW
211 *
212 * 09 10 2010 cm.chang
213 * NULL
214 * Always update Beacon content if FW sync OBSS info
215 *
216 * 09 07 2010 wh.su
217 * NULL
218 * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
219 *
220 * 09 03 2010 kevin.huang
221 * NULL
222 * Refine #include sequence and solve recursive/nested #include issue
223 *
224 * 08 31 2010 kevin.huang
225 * NULL
226 * Use LINK LIST operation to process SCAN result
227 *
228 * 08 30 2010 cp.wu
229 * NULL
230 * eliminate klockwork errors
231 *
232 * 08 29 2010 yuche.tsai
233 * NULL
234 * Finish SLT TX/RX & Rate Changing Support.
235 *
236 * 08 24 2010 cm.chang
237 * NULL
238 * Support RLM initail channel of Ad-hoc, P2P and BOW
239 *
240 * 08 16 2010 yuche.tsai
241 * NULL
242 * Before composing Beacon IE, assign network type index for msdu info,
243 * this information is needed by RLM module while composing some RLM related IE field.
244 *
245 * 08 16 2010 cp.wu
246 * NULL
247 * Replace CFG_SUPPORT_BOW by CFG_ENABLE_BT_OVER_WIFI.
248 * There is no CFG_SUPPORT_BOW in driver domain source.
249 *
250 * 08 16 2010 kevin.huang
251 * NULL
252 * Refine AAA functions
253 *
254 * 08 12 2010 kevin.huang
255 * NULL
256 * Fix undefined pucDestAddr in bssUpdateBeaconContent()
257 *
258 * 08 12 2010 kevin.huang
259 * NULL
260 * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
261 *
262 * 08 11 2010 cp.wu
263 * NULL
264 * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
265 * 2) extending scanning result to 64 instead of 48
266 *
267 * 08 02 2010 yuche.tsai
268 * NULL
269 * P2P Group Negotiation Code Check in.
270 *
271 * 08 02 2010 george.huang
272 * NULL
273 * add WMM-PS test related OID/ CMD handlers
274 *
275 * 07 26 2010 yuche.tsai
276 *
277 * Add support to RX probe response for P2P.
278 *
279 * 07 20 2010 cp.wu
280 *
281 * 1) bugfix: do not stop timer for join after switched into normal_tr state, for providing chance for DHCP handshasking
282 * 2) modify rsnPerformPolicySelection() invoking
283 *
284 * 07 19 2010 wh.su
285 *
286 * update for security supporting.
287 *
288 * 07 19 2010 cp.wu
289 *
290 * [WPD00003833] [MT6620 and MT5931] Driver migration.
291 * when IBSS is being merged-in, send command packet to PM for connected indication
292 *
293 * 07 19 2010 cp.wu
294 *
295 * [WPD00003833] [MT6620 and MT5931] Driver migration.
296 * Add Ad-Hoc support to AIS-FSM
297 *
298 * 07 14 2010 yarco.yang
299 *
300 * 1. Remove CFG_MQM_MIGRATION
301 * 2. Add CMD_UPDATE_WMM_PARMS command
302 *
303 * 07 08 2010 cp.wu
304 *
305 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
306 *
307 * 07 06 2010 george.huang
308 * [WPD00001556]Basic power managemenet function
309 * Update arguments for nicUpdateBeaconIETemplate()
310 *
311 * 06 29 2010 cp.wu
312 * [WPD00003833][MT6620 and MT5931] Driver migration
313 * 1) sync to. CMD/EVENT document v0.03
314 * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
315 * 3) send command packet to indicate FW-PM after
316 * a) 1st beacon is received after AIS has connected to an AP
317 * b) IBSS-ALONE has been created
318 * c) IBSS-MERGE has occured
319 *
320 * 06 28 2010 cp.wu
321 * [WPD00003833][MT6620 and MT5931] Driver migration
322 * send MMPDU in basic rate.
323 *
324 * 06 25 2010 george.huang
325 * [WPD00001556]Basic power managemenet function
326 * Create beacon update path, with expose bssUpdateBeaconContent()
327 *
328 * 06 21 2010 yuche.tsai
329 * [WPD00003839][MT6620 5931][P2P] Feature migration
330 * Fix compile error while enable WIFI_DIRECT support.
331 *
332 * 06 21 2010 yarco.yang
333 * [WPD00003837][MT6620]Data Path Refine
334 * Support CFG_MQM_MIGRATION flag
335 *
336 * 06 21 2010 cp.wu
337 * [WPD00003833][MT6620 and MT5931] Driver migration
338 * enable RX management frame handling.
339 *
340 * 06 21 2010 cp.wu
341 * [WPD00003833][MT6620 and MT5931] Driver migration
342 * specify correct value for management frames.
343 *
344 * 06 18 2010 cm.chang
345 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
346 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
347 *
348 * 06 15 2010 cp.wu
349 * [WPD00003833][MT6620 and MT5931] Driver migration
350 * correct when ADHOC support is turned on.
351 *
352 * 06 15 2010 cp.wu
353 * [WPD00003833][MT6620 and MT5931] Driver migration
354 * add scan.c.
355 *
356 * 06 14 2010 cp.wu
357 * [WPD00003833][MT6620 and MT5931] Driver migration
358 * add management dispatching function table.
359 *
360 * 06 11 2010 cp.wu
361 * [WPD00003833][MT6620 and MT5931] Driver migration
362 * auth.c is migrated.
363 *
364 * 06 11 2010 cp.wu
365 * [WPD00003833][MT6620 and MT5931] Driver migration
366 * fix compilation error when WIFI_DIRECT is turned on
367 *
368 * 06 11 2010 cp.wu
369 * [WPD00003833][MT6620 and MT5931] Driver migration
370 * add bss.c.
371 *
372 * 06 04 2010 george.huang
373 * [BORA00000678][MT6620]WiFi LP integration
374 * [PM] Support U-APSD for STA mode
375 *
376 * 05 28 2010 kevin.huang
377 * [BORA00000794][WIFISYS][New Feature]Power Management Support
378 * Add ClientList handling API - bssClearClientList, bssAddStaRecToClientList
379 *
380 * 05 24 2010 kevin.huang
381 * [BORA00000794][WIFISYS][New Feature]Power Management Support
382 * Update bssProcessProbeRequest() to avoid redundant SSID IE {0,0} for IOT.
383 *
384 * 05 21 2010 kevin.huang
385 * [BORA00000794][WIFISYS][New Feature]Power Management Support
386 * Refine txmInitWtblTxRateTable() - set TX initial rate according to AP's operation rate set
387 *
388 * 05 18 2010 cm.chang
389 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
390 * Ad-hoc Beacon should not carry HT OP and OBSS IEs
391 *
392 * 05 14 2010 kevin.huang
393 * [BORA00000794][WIFISYS][New Feature]Power Management Support
394 * Use TX MGMT Frame API for sending PS NULL frame to avoid the TX Burst Mechanism in TX FW Frame API
395 *
396 * 05 14 2010 kevin.huang
397 * [BORA00000794][WIFISYS][New Feature]Power Management Support
398 * Seperate Beacon and ProbeResp IE array
399 *
400 * 05 12 2010 kevin.huang
401 * [BORA00000794][WIFISYS][New Feature]Power Management Support
402 * Add Power Management - Legacy PS-POLL support.
403 *
404 * 04 28 2010 tehuang.liu
405 * [BORA00000605][WIFISYS] Phase3 Integration
406 * Removed the use of compiling flag MQM_WMM_PARSING
407 *
408 * 04 27 2010 kevin.huang
409 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
410 * Add Set Slot Time and Beacon Timeout Support for AdHoc Mode
411 *
412 * 04 24 2010 cm.chang
413 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
414 * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
415 *
416 * 04 22 2010 cm.chang
417 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
418 * First draft code to support protection in AP mode
419 *
420 * 04 20 2010 kevin.huang
421 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
422 * Fix restart Beacon Timeout Func after connection diagnosis
423 *
424 * 04 19 2010 kevin.huang
425 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
426 * Add Beacon Timeout Support and will send Null frame to diagnose connection
427 *
428 * 04 16 2010 wh.su
429 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
430 * adding the wpa-none for ibss beacon.
431 *
432 * 04 15 2010 wh.su
433 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
434 * fixed the protected bit at cap info for ad-hoc.
435 *
436 * 03 18 2010 kevin.huang
437 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
438 * Rename the CFG flags
439 *
440 * 03 16 2010 kevin.huang
441 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
442 * Add AdHoc Mode
443 *
444 * 02 26 2010 kevin.huang
445 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
446 * Update outgoing beacon's TX data rate
447 *
448 * 02 23 2010 kevin.huang
449 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
450 * Add DTIM count update while TX Beacon
451 *
452 * 02 05 2010 kevin.huang
453 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
454 * Modify code due to define - BAND_24G and specific BSS_INFO_T was changed
455 *
456 * 02 05 2010 kevin.huang
457 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
458 * Revise data structure to share the same BSS_INFO_T for avoiding coding error
459 *
460 * 02 04 2010 kevin.huang
461 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
462 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
463 */
464
465 /*******************************************************************************
466 * C O M P I L E R F L A G S
467 ********************************************************************************
468 */
469
470 /*******************************************************************************
471 * E X T E R N A L R E F E R E N C E S
472 ********************************************************************************
473 */
474 #include "precomp.h"
475
476 /*******************************************************************************
477 * C O N S T A N T S
478 ********************************************************************************
479 */
480
481 /*******************************************************************************
482 * D A T A T Y P E S
483 ********************************************************************************
484 */
485 /*******************************************************************************
486 * P U B L I C D A T A
487 ********************************************************************************
488 */
489 #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
490 APPEND_VAR_IE_ENTRY_T txBcnIETable[] = {
491 {(ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE} /* 50 */
492 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE} /* 42 */
493 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE} /* 45 */
494 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE} /* 61 */
495 #if CFG_ENABLE_WIFI_DIRECT
496 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE} /* 74 */
497 #endif
498 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE} /* 127 */
499 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE} /* 221 */
500 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE} /* 221 */
501 #if CFG_ENABLE_WIFI_DIRECT
502 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWPAIE} /* 221 */
503 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE} /* 48 */
504 #if 0 /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) */
505 , {0, p2pFuncCalculateExtra_IELenForBeacon, p2pFuncGenerateExtra_IEForBeacon} /* 221 */
506 #else
507 , {0, p2pFuncCalculateP2p_IELenForBeacon, p2pFuncGenerateP2p_IEForBeacon} /* 221 */
508 , {0, p2pFuncCalculateWSC_IELenForBeacon, p2pFuncGenerateWSC_IEForBeacon} /* 221 */
509 #endif
510 #endif /* CFG_ENABLE_WIFI_DIRECT */
511 };
512
513
514 APPEND_VAR_IE_ENTRY_T txProbRspIETable[] = {
515 {(ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE} /* 50 */
516 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE} /* 42 */
517 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE} /* 45 */
518 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE} /* 61 */
519 #if CFG_ENABLE_WIFI_DIRECT
520 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE} /* 48 */
521 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE} /* 74 */
522 #endif
523 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE} /* 127 */
524 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE} /* 221 */
525 , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE} /* 221 */
526 };
527
528 #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
529
530
531 /*******************************************************************************
532 * P R I V A T E D A T A
533 ********************************************************************************
534 */
535
536 /*******************************************************************************
537 * M A C R O S
538 ********************************************************************************
539 */
540
541
542 /*******************************************************************************
543 * F U N C T I O N D E C L A R A T I O N S
544 ********************************************************************************
545 */
546
547 /*******************************************************************************
548 * F U N C T I O N S
549 ********************************************************************************
550 */
551 /*----------------------------------------------------------------------------*/
552 /* Routines for all Operation Modes */
553 /*----------------------------------------------------------------------------*/
554 /*----------------------------------------------------------------------------*/
555 /*!
556 * @brief This function will create or reset a STA_RECORD_T by given BSS_DESC_T for
557 * Infrastructure or AdHoc Mode.
558 *
559 * @param[in] prAdapter Pointer to the Adapter structure.
560 * @param[in] eStaType Assign STA Type for this STA_RECORD_T
561 * @param[in] eNetTypeIndex Assign Net Type Index for this STA_RECORD_T
562 * @param[in] prBssDesc Received Beacon/ProbeResp from this STA
563 *
564 * @retval Pointer to STA_RECORD_T
565 */
566 /*----------------------------------------------------------------------------*/
567 P_STA_RECORD_T
568 bssCreateStaRecFromBssDesc(IN P_ADAPTER_T prAdapter,
569 IN ENUM_STA_TYPE_T eStaType,
570 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex, IN P_BSS_DESC_T prBssDesc)
571 {
572 P_STA_RECORD_T prStaRec;
573 UINT_8 ucNonHTPhyTypeSet;
574
575
576 ASSERT(prBssDesc);
577
578 /* 4 <1> Get a valid STA_RECORD_T */
579 prStaRec = cnmGetStaRecByAddress(prAdapter, (UINT_8) eNetTypeIndex, prBssDesc->aucSrcAddr);
580 if (!prStaRec) {
581
582 prStaRec = cnmStaRecAlloc(prAdapter, (UINT_8) eNetTypeIndex);
583
584 /* TODO(Kevin): Error handling of allocation of STA_RECORD_T for
585 * exhausted case and do removal of unused STA_RECORD_T.
586 */
587
588 if (!prStaRec) {
589 ASSERT(FALSE);
590 return NULL;
591 }
592
593 ASSERT(prStaRec);
594
595 prStaRec->ucJoinFailureCount = 0;
596 /* TODO(Kevin): If this is an old entry, we may also reset the ucJoinFailureCount to 0.
597 */
598
599 COPY_MAC_ADDR(prStaRec->aucMacAddr, prBssDesc->aucSrcAddr);
600 }
601
602 /* 4 <2> Setup STA TYPE and NETWORK */
603 prStaRec->eStaType = eStaType;
604
605 prStaRec->ucNetTypeIndex = eNetTypeIndex;
606
607
608 /* 4 <3> Update information from BSS_DESC_T to current P_STA_RECORD_T */
609 prStaRec->u2CapInfo = prBssDesc->u2CapInfo;
610
611 prStaRec->u2OperationalRateSet = prBssDesc->u2OperationalRateSet;
612 prStaRec->u2BSSBasicRateSet = prBssDesc->u2BSSBasicRateSet;
613
614 prStaRec->ucPhyTypeSet = prBssDesc->ucPhyTypeSet;
615
616 if (!((prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_ENABLED) ||
617 (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_KEY_ABSENT) ||
618 (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION_DISABLED) ||
619 (prAdapter->prGlueInfo->u2WSCAssocInfoIELen) ||
620 (prAdapter->prGlueInfo->u2WapiAssocInfoIESz))) {
621 DBGLOG(BSS, INFO, ("Ignore the HT Bit for TKIP as pairwise cipher configed!\n"));
622 prStaRec->ucPhyTypeSet &= ~PHY_TYPE_BIT_HT;
623 }
624
625 prStaRec->ucDesiredPhyTypeSet =
626 prStaRec->ucPhyTypeSet & prAdapter->rWifiVar.ucAvailablePhyTypeSet;
627
628 ucNonHTPhyTypeSet = prStaRec->ucDesiredPhyTypeSet & PHY_TYPE_SET_802_11ABG;
629
630 /* Check for Target BSS's non HT Phy Types */
631 if (ucNonHTPhyTypeSet) {
632
633 if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_ERP) {
634 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_ERP_INDEX;
635 } else if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_OFDM) {
636 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_OFDM_INDEX;
637 } else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
638
639 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
640 }
641
642 prStaRec->fgHasBasicPhyType = TRUE;
643 } else {
644 /* Use mandatory for 11N only BSS */
645 ASSERT(prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N);
646
647 {
648 /* TODO(Kevin): which value should we set for 11n ? ERP ? */
649 prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
650 }
651
652 prStaRec->fgHasBasicPhyType = FALSE;
653 }
654
655 /* Update non HT Desired Rate Set */
656 {
657 P_CONNECTION_SETTINGS_T prConnSettings;
658
659
660 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
661
662 prStaRec->u2DesiredNonHTRateSet =
663 (prStaRec->u2OperationalRateSet & prConnSettings->u2DesiredNonHTRateSet);
664 }
665
666 /* 4 <4> Update information from BSS_DESC_T to current P_STA_RECORD_T */
667 if (IS_AP_STA(prStaRec)) {
668 /* do not need to parse IE for DTIM,
669 * which have been parsed before inserting into BSS_DESC_T
670 */
671 if (prBssDesc->ucDTIMPeriod) {
672 prStaRec->ucDTIMPeriod = prBssDesc->ucDTIMPeriod;
673 } else {
674 prStaRec->ucDTIMPeriod = 0; /* Means that TIM was not parsed. */
675 }
676 }
677
678 /* 4 <5> Update default value */
679 prStaRec->fgDiagnoseConnection = FALSE;
680
681
682 /* 4 <6> Update default value for other Modules */
683 /* Determine fgIsWmmSupported and fgIsUapsdSupported in STA_REC */
684 mqmProcessScanResult(prAdapter, prBssDesc, prStaRec);
685
686 return prStaRec;
687
688 } /* end of bssCreateStaRecFromBssDesc() */
689
690
691 /*----------------------------------------------------------------------------*/
692 /*!
693 * @brief This function will compose the Null Data frame.
694 *
695 * @param[in] prAdapter Pointer to the Adapter structure.
696 * @param[in] pucBuffer Pointer to the frame buffer.
697 * @param[in] prStaRec Pointer to the STA_RECORD_T.
698 *
699 * @return (none)
700 */
701 /*----------------------------------------------------------------------------*/
702 VOID bssComposeNullFrame(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, IN P_STA_RECORD_T prStaRec)
703 {
704 P_WLAN_MAC_HEADER_T prNullFrame;
705 P_BSS_INFO_T prBssInfo;
706 UINT_16 u2FrameCtrl;
707
708
709 ASSERT(pucBuffer);
710 ASSERT(prStaRec);
711 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
712
713 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
714
715 ASSERT(prBssInfo);
716
717 prNullFrame = (P_WLAN_MAC_HEADER_T) pucBuffer;
718
719 /* 4 <1> Decide the Frame Control Field */
720 u2FrameCtrl = MAC_FRAME_NULL;
721
722 if (IS_AP_STA(prStaRec)) {
723 u2FrameCtrl |= MASK_FC_TO_DS;
724
725 if (prStaRec->fgSetPwrMgtBit) {
726 u2FrameCtrl |= MASK_FC_PWR_MGT;
727 }
728 } else if (IS_CLIENT_STA(prStaRec)) {
729 u2FrameCtrl |= MASK_FC_FROM_DS;
730 } else if (IS_DLS_STA(prStaRec)) {
731 /* TODO(Kevin) */
732 } else {
733 /* NOTE(Kevin): We won't send Null frame for IBSS */
734 ASSERT(0);
735 return;
736 }
737
738 /* 4 <2> Compose the Null frame */
739 /* Fill the Frame Control field. */
740 /* WLAN_SET_FIELD_16(&prNullFrame->u2FrameCtrl, u2FrameCtrl); */
741 prNullFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
742
743 /* Fill the Address 1 field with Target Peer Address. */
744 COPY_MAC_ADDR(prNullFrame->aucAddr1, prStaRec->aucMacAddr);
745
746 /* Fill the Address 2 field with our MAC Address. */
747 COPY_MAC_ADDR(prNullFrame->aucAddr2, prBssInfo->aucOwnMacAddr);
748
749 /* Fill the Address 3 field with Target BSSID. */
750 COPY_MAC_ADDR(prNullFrame->aucAddr3, prBssInfo->aucBSSID);
751
752 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
753 prNullFrame->u2SeqCtrl = 0;
754
755 return;
756
757 } /* end of bssComposeNullFrameHeader() */
758
759
760 /*----------------------------------------------------------------------------*/
761 /*!
762 * @brief This function will compose the QoS Null Data frame.
763 *
764 * @param[in] prAdapter Pointer to the Adapter structure.
765 * @param[in] pucBuffer Pointer to the frame buffer.
766 * @param[in] prStaRec Pointer to the STA_RECORD_T.
767 * @param[in] ucUP User Priority.
768 * @param[in] fgSetEOSP Set the EOSP bit.
769 *
770 * @return (none)
771 */
772 /*----------------------------------------------------------------------------*/
773 VOID
774 bssComposeQoSNullFrame(IN P_ADAPTER_T prAdapter,
775 IN PUINT_8 pucBuffer,
776 IN P_STA_RECORD_T prStaRec, IN UINT_8 ucUP, IN BOOLEAN fgSetEOSP)
777 {
778 P_WLAN_MAC_HEADER_QOS_T prQoSNullFrame;
779 P_BSS_INFO_T prBssInfo;
780 UINT_16 u2FrameCtrl;
781 UINT_16 u2QosControl;
782
783
784 ASSERT(pucBuffer);
785 ASSERT(prStaRec);
786 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
787
788 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
789
790 ASSERT(prBssInfo);
791
792 prQoSNullFrame = (P_WLAN_MAC_HEADER_QOS_T) pucBuffer;
793
794 /* 4 <1> Decide the Frame Control Field */
795 u2FrameCtrl = MAC_FRAME_QOS_NULL;
796
797 if (IS_AP_STA(prStaRec)) {
798 u2FrameCtrl |= MASK_FC_TO_DS;
799
800 if (prStaRec->fgSetPwrMgtBit) {
801 u2FrameCtrl |= MASK_FC_PWR_MGT;
802 }
803 } else if (IS_CLIENT_STA(prStaRec)) {
804 u2FrameCtrl |= MASK_FC_FROM_DS;
805 } else if (IS_DLS_STA(prStaRec)) {
806 /* TODO(Kevin) */
807 } else {
808 /* NOTE(Kevin): We won't send QoS Null frame for IBSS */
809 ASSERT(0);
810 return;
811 }
812
813 /* 4 <2> Compose the QoS Null frame */
814 /* Fill the Frame Control field. */
815 /* WLAN_SET_FIELD_16(&prQoSNullFrame->u2FrameCtrl, u2FrameCtrl); */
816 prQoSNullFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
817
818 /* Fill the Address 1 field with Target Peer Address. */
819 COPY_MAC_ADDR(prQoSNullFrame->aucAddr1, prStaRec->aucMacAddr);
820
821 /* Fill the Address 2 field with our MAC Address. */
822 COPY_MAC_ADDR(prQoSNullFrame->aucAddr2, prBssInfo->aucOwnMacAddr);
823
824 /* Fill the Address 3 field with Target BSSID. */
825 COPY_MAC_ADDR(prQoSNullFrame->aucAddr3, prBssInfo->aucBSSID);
826
827 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
828 prQoSNullFrame->u2SeqCtrl = 0;
829
830 u2QosControl = (UINT_16) (ucUP & WMM_QC_UP_MASK);
831
832 if (fgSetEOSP) {
833 u2QosControl |= WMM_QC_EOSP;
834 }
835 /* WLAN_SET_FIELD_16(&prQoSNullFrame->u2QosCtrl, u2QosControl); */
836 prQoSNullFrame->u2QosCtrl = u2QosControl; /* NOTE(Kevin): Optimized for ARM */
837
838 return;
839
840 } /* end of bssComposeQoSNullFrameHeader() */
841
842
843 /*----------------------------------------------------------------------------*/
844 /*!
845 * @brief Send the Null Frame
846 *
847 * @param[in] prAdapter Pointer to the Adapter structure.
848 * @param[in] prStaRec Pointer to the STA_RECORD_T
849 * @param[in] pfTxDoneHandler TX Done call back function
850 *
851 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
852 * @retval WLAN_STATUS_SUCCESS Succe]ss.
853 */
854 /*----------------------------------------------------------------------------*/
855 WLAN_STATUS
856 bssSendNullFrame(IN P_ADAPTER_T prAdapter,
857 IN P_STA_RECORD_T prStaRec, IN PFN_TX_DONE_HANDLER pfTxDoneHandler)
858 {
859 P_MSDU_INFO_T prMsduInfo;
860 UINT_16 u2EstimatedFrameLen;
861
862
863 /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
864 /* Init with MGMT Header Length */
865 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_LEN;
866
867 /* Allocate a MSDU_INFO_T */
868 if ((prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
869 DBGLOG(BSS, WARN, ("No PKT_INFO_T for sending Null Frame.\n"));
870 return WLAN_STATUS_RESOURCES;
871 }
872 /* 4 <2> Compose Null frame in MSDU_INfO_T. */
873 bssComposeNullFrame(prAdapter,
874 (PUINT_8) ((UINT_32) prMsduInfo->prPacket + MAC_TX_RESERVED_FIELD),
875 prStaRec);
876 #if 0
877 /* 4 <3> Update information of MSDU_INFO_T */
878 TXM_SET_DATA_PACKET(
879 /* STA_REC ptr */ prStaRec,
880 /* MSDU_INFO ptr */ prMsduInfo,
881 /* MAC HDR ptr */
882 (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD),
883 /* MAC HDR length */ WLAN_MAC_HEADER_LEN,
884 /* PAYLOAD ptr */
885 (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD +
886 WLAN_MAC_HEADER_LEN),
887 /* PAYLOAD length */ 0,
888 /* Network Type Index */ (UINT_8) prStaRec->ucNetTypeIndex,
889 /* TID */ 0 /* BE: AC1 */ ,
890 /* Flag 802.11 */ TRUE,
891 /* Pkt arrival time */ 0 /* TODO: Obtain the system time */ ,
892 /* Resource TC */ 0 /* Irrelevant */ ,
893 /* Flag 802.1x */ FALSE,
894 /* TX-done callback */ pfTxDoneHandler,
895 /* PS forwarding type */ PS_FORWARDING_TYPE_NON_PS,
896 /* PS Session ID */ 0 /* Irrelevant */ ,
897 /* Flag fixed rate */ TRUE,
898 /* Fixed tx rate */
899 g_aprBssInfo[prStaRec->ucNetTypeIndex]->ucHwDefaultFixedRateCode,
900 /* Fixed-rate retry */
901 BSS_DEFAULT_CONN_TEST_NULL_FRAME_RETRY_LIMIT,
902 /* PAL LLH */ 0 /* Irrelevant */ ,
903 /* ACL SN */ 0 /* Irrelevant */ ,
904 /* Flag No Ack */ FALSE
905 );
906
907 /* Terminate with a NULL pointer */
908 NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo, NULL);
909
910 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
911
912 /* Indicate the packet to TXM */
913 /* 4 <4> Inform TXM to send this Null frame. */
914 txmSendFwDataPackets(prMsduInfo);
915 #endif
916
917 prMsduInfo->eSrc = TX_PACKET_MGMT;
918 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_DATA;
919 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
920 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
921 prMsduInfo->ucMacHeaderLength = WLAN_MAC_HEADER_LEN;
922 prMsduInfo->fgIs802_1x = FALSE;
923 prMsduInfo->fgIs802_11 = TRUE;
924 prMsduInfo->u2FrameLength = WLAN_MAC_HEADER_LEN;
925 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
926 prMsduInfo->pfTxDoneHandler = pfTxDoneHandler;
927 prMsduInfo->fgIsBasicRate = FALSE;
928
929 /* 4 <4> Inform TXM to send this Null frame. */
930 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
931
932 return WLAN_STATUS_SUCCESS;
933
934 } /* end of bssSendNullFrame() */
935
936
937 /*----------------------------------------------------------------------------*/
938 /*!
939 * @brief Send the QoS Null Frame
940 *
941 * @param[in] prAdapter Pointer to the Adapter structure.
942 * @param[in] prStaRec Pointer to the STA_RECORD_T
943 * @param[in] pfTxDoneHandler TX Done call back function
944 *
945 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
946 * @retval WLAN_STATUS_SUCCESS Success.
947 */
948 /*----------------------------------------------------------------------------*/
949 WLAN_STATUS
950 bssSendQoSNullFrame(IN P_ADAPTER_T prAdapter,
951 IN P_STA_RECORD_T prStaRec,
952 IN UINT_8 ucUP, IN PFN_TX_DONE_HANDLER pfTxDoneHandler)
953 {
954 P_MSDU_INFO_T prMsduInfo;
955 UINT_16 u2EstimatedFrameLen;
956
957
958 /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
959 /* Init with MGMT Header Length */
960 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_QOS_LEN;
961
962 /* Allocate a MSDU_INFO_T */
963 if ((prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
964 DBGLOG(BSS, WARN, ("No PKT_INFO_T for sending Null Frame.\n"));
965 return WLAN_STATUS_RESOURCES;
966 }
967 /* 4 <2> Compose Null frame in MSDU_INfO_T. */
968 bssComposeQoSNullFrame(prAdapter,
969 (PUINT_8) ((UINT_32) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
970 prStaRec, ucUP, FALSE);
971 #if 0
972 /* 4 <3> Update information of MSDU_INFO_T */
973 TXM_SET_DATA_PACKET(
974 /* STA_REC ptr */ prStaRec,
975 /* MSDU_INFO ptr */ prMsduInfo,
976 /* MAC HDR ptr */
977 (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD),
978 /* MAC HDR length */ WLAN_MAC_HEADER_QOS_LEN,
979 /* PAYLOAD ptr */
980 (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD +
981 WLAN_MAC_HEADER_QOS_LEN),
982 /* PAYLOAD length */ 0,
983 /* Network Type Index */ (UINT_8) prStaRec->ucNetTypeIndex,
984 /* TID */ 0 /* BE: AC1 */ ,
985 /* Flag 802.11 */ TRUE,
986 /* Pkt arrival time */ 0 /* TODO: Obtain the system time */ ,
987 /* Resource TC */ 0 /* Irrelevant */ ,
988 /* Flag 802.1x */ FALSE,
989 /* TX-done callback */ pfTxDoneHandler,
990 /* PS forwarding type */ PS_FORWARDING_TYPE_NON_PS,
991 /* PS Session ID */ 0 /* Irrelevant */ ,
992 /* Flag fixed rate */ TRUE,
993 /* Fixed tx rate */
994 g_aprBssInfo[prStaRec->ucNetTypeIndex]->ucHwDefaultFixedRateCode,
995 /* Fixed-rate retry */ TXM_DEFAULT_DATA_FRAME_RETRY_LIMIT,
996 /* PAL LLH */ 0 /* Irrelevant */ ,
997 /* ACL SN */ 0 /* Irrelevant */ ,
998 /* Flag No Ack */ FALSE
999 );
1000
1001 /* Terminate with a NULL pointer */
1002 NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo, NULL);
1003
1004 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1005
1006 /* Indicate the packet to TXM */
1007 /* 4 <4> Inform TXM to send this Null frame. */
1008 txmSendFwDataPackets(prMsduInfo);
1009 #endif
1010
1011 prMsduInfo->eSrc = TX_PACKET_MGMT;
1012 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
1013 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
1014 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
1015 prMsduInfo->ucMacHeaderLength = WLAN_MAC_HEADER_QOS_LEN;
1016 prMsduInfo->fgIs802_1x = FALSE;
1017 prMsduInfo->fgIs802_11 = TRUE;
1018 prMsduInfo->u2FrameLength = WLAN_MAC_HEADER_QOS_LEN;
1019 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
1020 prMsduInfo->pfTxDoneHandler = pfTxDoneHandler;
1021 prMsduInfo->fgIsBasicRate = TRUE;
1022
1023 /* 4 <4> Inform TXM to send this Null frame. */
1024 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
1025
1026 return WLAN_STATUS_SUCCESS;
1027
1028 } /* end of bssSendQoSNullFrame() */
1029
1030
1031 #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
1032 /*----------------------------------------------------------------------------*/
1033 /* Routines for both IBSS(AdHoc) and BSS(AP) */
1034 /*----------------------------------------------------------------------------*/
1035 /*----------------------------------------------------------------------------*/
1036 /*!
1037 * @brief This function is used to generate Information Elements of Extended
1038 * Support Rate
1039 *
1040 * @param[in] prAdapter Pointer to the Adapter structure.
1041 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1042 *
1043 * @return (none)
1044 */
1045 /*----------------------------------------------------------------------------*/
1046 VOID bssGenerateExtSuppRate_IE(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
1047 {
1048 P_BSS_INFO_T prBssInfo;
1049 PUINT_8 pucBuffer;
1050 UINT_8 ucExtSupRatesLen;
1051
1052
1053 ASSERT(prMsduInfo);
1054
1055 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType]);
1056 ASSERT(prBssInfo);
1057
1058 pucBuffer = (PUINT_8) ((UINT_32) prMsduInfo->prPacket +
1059 (UINT_32) prMsduInfo->u2FrameLength);
1060 ASSERT(pucBuffer);
1061
1062 if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) {
1063
1064 ucExtSupRatesLen = prBssInfo->ucAllSupportedRatesLen - ELEM_MAX_LEN_SUP_RATES;
1065 } else {
1066 ucExtSupRatesLen = 0;
1067 }
1068
1069 /* Fill the Extended Supported Rates element. */
1070 if (ucExtSupRatesLen) {
1071
1072 EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
1073 EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
1074
1075 kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
1076 &prBssInfo->aucAllSupportedRates[ELEM_MAX_LEN_SUP_RATES],
1077 ucExtSupRatesLen);
1078
1079 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1080 }
1081
1082 return;
1083 } /* end of bssGenerateExtSuppRate_IE() */
1084
1085
1086 /*----------------------------------------------------------------------------*/
1087 /*!
1088 * @brief This function is used to compose Common Information Elements for Beacon
1089 * or Probe Response Frame.
1090 *
1091 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1092 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
1093 * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
1094 *
1095 * @return (none)
1096 */
1097 /*----------------------------------------------------------------------------*/
1098 VOID
1099 bssBuildBeaconProbeRespFrameCommonIEs(IN P_MSDU_INFO_T prMsduInfo,
1100 IN P_BSS_INFO_T prBssInfo, IN PUINT_8 pucDestAddr)
1101 {
1102 PUINT_8 pucBuffer;
1103 UINT_8 ucSupRatesLen;
1104
1105
1106 ASSERT(prMsduInfo);
1107 ASSERT(prBssInfo);
1108
1109 pucBuffer = (PUINT_8) ((UINT_32) prMsduInfo->prPacket +
1110 (UINT_32) prMsduInfo->u2FrameLength);
1111 ASSERT(pucBuffer);
1112
1113 /* Compose the frame body of the Probe Response frame. */
1114 /* 4 <1> Fill the SSID element. */
1115 SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
1116 if (prBssInfo->eHiddenSsidType == ENUM_HIDDEN_SSID_LEN) {
1117 if ((!pucDestAddr) && /* For Beacon only */
1118 (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)) {
1119 SSID_IE(pucBuffer)->ucLength = 0;
1120 } else { /* Probe response */
1121 SSID_IE(pucBuffer)->ucLength = prBssInfo->ucSSIDLen;
1122 if (prBssInfo->ucSSIDLen) {
1123 kalMemCopy(SSID_IE(pucBuffer)->aucSSID, prBssInfo->aucSSID,
1124 prBssInfo->ucSSIDLen);
1125 }
1126 }
1127 }
1128 else {
1129 SSID_IE(pucBuffer)->ucLength = prBssInfo->ucSSIDLen;
1130 if (prBssInfo->ucSSIDLen) {
1131 kalMemCopy(SSID_IE(pucBuffer)->aucSSID, prBssInfo->aucSSID,
1132 prBssInfo->ucSSIDLen);
1133 }
1134 }
1135
1136 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1137 pucBuffer += IE_SIZE(pucBuffer);
1138
1139
1140 /* 4 <2> Fill the Supported Rates element. */
1141 if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) {
1142
1143 ucSupRatesLen = ELEM_MAX_LEN_SUP_RATES;
1144 } else {
1145 ucSupRatesLen = prBssInfo->ucAllSupportedRatesLen;
1146 }
1147
1148 if (ucSupRatesLen) {
1149 SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
1150 SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
1151 kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates,
1152 prBssInfo->aucAllSupportedRates, ucSupRatesLen);
1153
1154 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1155 pucBuffer += IE_SIZE(pucBuffer);
1156 }
1157
1158 /* 4 <3> Fill the DS Parameter Set element. */
1159 if (prBssInfo->eBand == BAND_2G4) {
1160 DS_PARAM_IE(pucBuffer)->ucId = ELEM_ID_DS_PARAM_SET;
1161 DS_PARAM_IE(pucBuffer)->ucLength = ELEM_MAX_LEN_DS_PARAMETER_SET;
1162 DS_PARAM_IE(pucBuffer)->ucCurrChnl = prBssInfo->ucPrimaryChannel;
1163
1164 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1165 pucBuffer += IE_SIZE(pucBuffer);
1166 }
1167
1168 /* 4 <4> IBSS Parameter Set element, ID: 6 */
1169 if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
1170 IBSS_PARAM_IE(pucBuffer)->ucId = ELEM_ID_IBSS_PARAM_SET;
1171 IBSS_PARAM_IE(pucBuffer)->ucLength = ELEM_MAX_LEN_IBSS_PARAMETER_SET;
1172 WLAN_SET_FIELD_16(&(IBSS_PARAM_IE(pucBuffer)->u2ATIMWindow),
1173 prBssInfo->u2ATIMWindow);
1174
1175 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1176 pucBuffer += IE_SIZE(pucBuffer);
1177 }
1178
1179 /* 4 <5> TIM element, ID: 5 */
1180 if ((!pucDestAddr) && /* For Beacon only. */
1181 (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)) {
1182
1183 #if CFG_ENABLE_WIFI_DIRECT
1184 /*no fgIsP2PRegistered protect */
1185 if (prBssInfo->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
1186 #if 0
1187 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
1188 UINT_8 ucBitmapControl = 0;
1189 UINT_32 u4N1, u4N2;
1190
1191
1192 prP2pSpecificBssInfo = &(prAdapter->rWifiVar.rP2pSpecificBssInfo);
1193
1194 /* Clear existing value. */
1195 prP2pSpecificBssInfo->ucBitmapCtrl = 0;
1196 kalMemZero(prP2pSpecificBssInfo->aucPartialVirtualBitmap,
1197 sizeof(prP2pSpecificBssInfo->aucPartialVirtualBitmap));
1198
1199
1200 /* IEEE 802.11 2007 - 7.3.2.6 */
1201 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
1202 TIM_IE(pucBuffer)->ucDTIMCount = prBssInfo->ucDTIMCount;
1203 TIM_IE(pucBuffer)->ucDTIMPeriod = prBssInfo->ucDTIMPeriod;
1204
1205 /* Setup DTIM Count for next TBTT. */
1206 if (prBssInfo->ucDTIMCount == 0) {
1207 /* 3 *** pmQueryBufferedBCAST(); */
1208 }
1209 /* 3 *** pmQueryBufferedPSNode(); */
1210 /* TODO(Kevin): Call PM Module here to loop all STA_RECORD_Ts and it
1211 * will call bssSetTIMBitmap to toggle the Bitmap.
1212 */
1213
1214 /* Set Virtual Bitmap for UCAST */
1215 u4N1 = (prP2pSpecificBssInfo->u2SmallestAID >> 4) << 1; /* Find the largest even number. */
1216 u4N2 = prP2pSpecificBssInfo->u2LargestAID >> 3; /* Find the smallest number. */
1217
1218 ASSERT(u4N2 >= u4N1);
1219
1220 kalMemCopy(TIM_IE(pucBuffer)->aucPartialVirtualMap,
1221 &prP2pSpecificBssInfo->aucPartialVirtualBitmap[u4N1],
1222 ((u4N2 - u4N1) + 1));
1223
1224 /* Set Virtual Bitmap for BMCAST */
1225 /* BMC bit only indicated when DTIM count == 0. */
1226 if (prBssInfo->ucDTIMCount == 0) {
1227 ucBitmapControl = prP2pSpecificBssInfo->ucBitmapCtrl;
1228 }
1229 TIM_IE(pucBuffer)->ucBitmapControl = ucBitmapControl | (UINT_8) u4N1;
1230
1231 TIM_IE(pucBuffer)->ucLength = ((u4N2 - u4N1) + 4);
1232
1233 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1234 #else
1235
1236 /* IEEE 802.11 2007 - 7.3.2.6 */
1237 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
1238 TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP) /*((u4N2 - u4N1) + 4) */; /* NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only) */
1239 TIM_IE(pucBuffer)->ucDTIMCount = 0 /*prBssInfo->ucDTIMCount */; /* will be overwrite by FW */
1240 TIM_IE(pucBuffer)->ucDTIMPeriod = prBssInfo->ucDTIMPeriod;
1241 TIM_IE(pucBuffer)->ucBitmapControl = 0 /*ucBitmapControl | (UINT_8)u4N1 */; /* will be overwrite by FW */
1242
1243 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1244
1245 #endif
1246
1247 } else
1248 #endif /* CFG_ENABLE_WIFI_DIRECT */
1249 {
1250 /* NOTE(Kevin): 1. AIS - Didn't Support AP Mode.
1251 * 2. BOW - Didn't Support BCAST and PS.
1252 */
1253 }
1254
1255
1256
1257 }
1258
1259 return;
1260 } /* end of bssBuildBeaconProbeRespFrameCommonIEs() */
1261
1262
1263 /*----------------------------------------------------------------------------*/
1264 /*!
1265 * @brief This function will compose the Beacon/Probe Response frame header and
1266 * its fixed fields.
1267 *
1268 * @param[in] pucBuffer Pointer to the frame buffer.
1269 * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
1270 * @param[in] pucOwnMACAddress Given Our MAC Address.
1271 * @param[in] pucBSSID Given BSSID of the BSS.
1272 * @param[in] u2BeaconInterval Given Beacon Interval.
1273 * @param[in] u2CapInfo Given Capability Info.
1274 *
1275 * @return (none)
1276 */
1277 /*----------------------------------------------------------------------------*/
1278 VOID
1279 bssComposeBeaconProbeRespFrameHeaderAndFF(IN PUINT_8 pucBuffer,
1280 IN PUINT_8 pucDestAddr,
1281 IN PUINT_8 pucOwnMACAddress,
1282 IN PUINT_8 pucBSSID,
1283 IN UINT_16 u2BeaconInterval, IN UINT_16 u2CapInfo)
1284 {
1285 P_WLAN_BEACON_FRAME_T prBcnProbRspFrame;
1286 UINT_8 aucBCAddr[] = BC_MAC_ADDR;
1287 UINT_16 u2FrameCtrl;
1288
1289 DEBUGFUNC("bssComposeBeaconProbeRespFrameHeaderAndFF");
1290 /* DBGLOG(INIT, LOUD, ("\n")); */
1291
1292
1293 ASSERT(pucBuffer);
1294 ASSERT(pucOwnMACAddress);
1295 ASSERT(pucBSSID);
1296
1297 prBcnProbRspFrame = (P_WLAN_BEACON_FRAME_T) pucBuffer;
1298
1299 /* 4 <1> Compose the frame header of the Beacon /ProbeResp frame. */
1300 /* Fill the Frame Control field. */
1301 if (pucDestAddr) {
1302 u2FrameCtrl = MAC_FRAME_PROBE_RSP;
1303 } else {
1304 u2FrameCtrl = MAC_FRAME_BEACON;
1305 pucDestAddr = aucBCAddr;
1306 }
1307 /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2FrameCtrl, u2FrameCtrl); */
1308 prBcnProbRspFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
1309
1310 /* Fill the DA field with BCAST MAC ADDR or TA of ProbeReq. */
1311 COPY_MAC_ADDR(prBcnProbRspFrame->aucDestAddr, pucDestAddr);
1312
1313 /* Fill the SA field with our MAC Address. */
1314 COPY_MAC_ADDR(prBcnProbRspFrame->aucSrcAddr, pucOwnMACAddress);
1315
1316 /* Fill the BSSID field with current BSSID. */
1317 COPY_MAC_ADDR(prBcnProbRspFrame->aucBSSID, pucBSSID);
1318
1319 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
1320 prBcnProbRspFrame->u2SeqCtrl = 0;
1321
1322
1323 /* 4 <2> Compose the frame body's common fixed field part of the Beacon /ProbeResp frame. */
1324 /* MAC will update TimeStamp field */
1325
1326 /* Fill the Beacon Interval field. */
1327 /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2BeaconInterval, u2BeaconInterval); */
1328 prBcnProbRspFrame->u2BeaconInterval = u2BeaconInterval; /* NOTE(Kevin): Optimized for ARM */
1329
1330 /* Fill the Capability Information field. */
1331 /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2CapInfo, u2CapInfo); */
1332 prBcnProbRspFrame->u2CapInfo = u2CapInfo; /* NOTE(Kevin): Optimized for ARM */
1333
1334 return;
1335 } /* end of bssComposeBeaconProbeRespFrameHeaderAndFF() */
1336
1337
1338 /*----------------------------------------------------------------------------*/
1339 /*!
1340 * @brief Update the Beacon Frame Template to FW for AIS AdHoc and P2P GO.
1341 *
1342 * @param[in] prAdapter Pointer to the Adapter structure.
1343 * @param[in] eNetTypeIndex Specify which network reply the Probe Response.
1344 *
1345 * @retval WLAN_STATUS_SUCCESS Success.
1346 */
1347 /*----------------------------------------------------------------------------*/
1348 WLAN_STATUS
1349 bssUpdateBeaconContent(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex)
1350 {
1351 P_BSS_INFO_T prBssInfo;
1352 P_MSDU_INFO_T prMsduInfo;
1353 P_WLAN_BEACON_FRAME_T prBcnFrame;
1354 UINT_32 i;
1355
1356 DEBUGFUNC("bssUpdateBeaconContent");
1357 DBGLOG(INIT, LOUD, ("\n"));
1358
1359 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1360
1361 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1362
1363 /* 4 <1> Allocate a PKT_INFO_T for Beacon Frame */
1364 /* Allocate a MSDU_INFO_T */
1365 /* For Beacon */
1366 prMsduInfo = prBssInfo->prBeacon;
1367
1368 /* beacon prMsduInfo will be NULLify once BSS deactivated, so skip if it is */
1369 if (prMsduInfo == NULL) {
1370 return WLAN_STATUS_SUCCESS;
1371 }
1372 /* 4 <2> Compose header */
1373 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8)
1374 ((UINT_32) (prMsduInfo->prPacket) +
1375 MAC_TX_RESERVED_FIELD), NULL,
1376 prBssInfo->aucOwnMacAddr, prBssInfo->aucBSSID,
1377 prBssInfo->u2BeaconInterval,
1378 prBssInfo->u2CapInfo);
1379
1380
1381 prMsduInfo->u2FrameLength = (WLAN_MAC_MGMT_HEADER_LEN +
1382 (TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN +
1383 CAP_INFO_FIELD_LEN));
1384
1385 prMsduInfo->ucNetworkType = eNetTypeIndex;
1386
1387 /* 4 <3> Compose the frame body's Common IEs of the Beacon frame. */
1388 bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo, prBssInfo, NULL);
1389
1390
1391 /* 4 <4> Compose IEs in MSDU_INFO_T */
1392
1393 /* Append IE for Beacon */
1394 for (i = 0; i < sizeof(txBcnIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
1395 if (txBcnIETable[i].pfnAppendIE) {
1396 txBcnIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
1397 }
1398 }
1399
1400 prBcnFrame = (P_WLAN_BEACON_FRAME_T) prMsduInfo->prPacket;
1401
1402 return nicUpdateBeaconIETemplate(prAdapter,
1403 IE_UPD_METHOD_UPDATE_ALL,
1404 eNetTypeIndex,
1405 prBssInfo->u2CapInfo,
1406 (PUINT_8) prBcnFrame->aucInfoElem,
1407 prMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T,
1408 aucInfoElem));
1409
1410
1411 } /* end of bssUpdateBeaconContent() */
1412
1413
1414 /*----------------------------------------------------------------------------*/
1415 /*!
1416 * @brief Send the Beacon Frame(for BOW) or Probe Response Frame according to the given
1417 * Destination Address.
1418 *
1419 * @param[in] prAdapter Pointer to the Adapter structure.
1420 * @param[in] eNetTypeIndex Specify which network reply the Probe Response.
1421 * @param[in] pucDestAddr Pointer to the Destination Address to reply
1422 * @param[in] u4ControlFlags Control flags for information on Probe Response.
1423 *
1424 * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
1425 * @retval WLAN_STATUS_SUCCESS Success.
1426 */
1427 /*----------------------------------------------------------------------------*/
1428 WLAN_STATUS
1429 bssSendBeaconProbeResponse(IN P_ADAPTER_T prAdapter,
1430 IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
1431 IN PUINT_8 pucDestAddr, IN UINT_32 u4ControlFlags)
1432 {
1433 P_BSS_INFO_T prBssInfo;
1434 P_MSDU_INFO_T prMsduInfo;
1435 UINT_16 u2EstimatedFrameLen;
1436 UINT_16 u2EstimatedFixedIELen;
1437 UINT_16 u2EstimatedExtraIELen;
1438 P_APPEND_VAR_IE_ENTRY_T prIeArray = NULL;
1439 UINT_32 u4IeArraySize = 0;
1440 UINT_32 i;
1441
1442
1443 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1444
1445 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1446
1447
1448 if (!pucDestAddr) { /* For Beacon */
1449 prIeArray = &txBcnIETable[0];
1450 u4IeArraySize = sizeof(txBcnIETable) / sizeof(APPEND_VAR_IE_ENTRY_T);
1451 } else {
1452 prIeArray = &txProbRspIETable[0];
1453 u4IeArraySize = sizeof(txProbRspIETable) / sizeof(APPEND_VAR_IE_ENTRY_T);
1454 }
1455
1456
1457 /* 4 <1> Allocate a PKT_INFO_T for Beacon /Probe Response Frame */
1458 /* Allocate a MSDU_INFO_T */
1459
1460 /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Fields */
1461 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD +
1462 WLAN_MAC_MGMT_HEADER_LEN +
1463 TIMESTAMP_FIELD_LEN +
1464 BEACON_INTERVAL_FIELD_LEN +
1465 CAP_INFO_FIELD_LEN +
1466 (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) +
1467 (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) +
1468 (ELEM_HDR_LEN + ELEM_MAX_LEN_DS_PARAMETER_SET) +
1469 (ELEM_HDR_LEN + ELEM_MAX_LEN_IBSS_PARAMETER_SET) +
1470 (ELEM_HDR_LEN + (3 + MAX_LEN_TIM_PARTIAL_BMP));
1471
1472 /* + Extra IE Length */
1473 u2EstimatedExtraIELen = 0;
1474
1475 for (i = 0; i < u4IeArraySize; i++) {
1476 u2EstimatedFixedIELen = prIeArray[i].u2EstimatedFixedIELen;
1477
1478 if (u2EstimatedFixedIELen) {
1479 u2EstimatedExtraIELen += u2EstimatedFixedIELen;
1480 } else {
1481 ASSERT(prIeArray[i].pfnCalculateVariableIELen);
1482
1483 u2EstimatedExtraIELen += (UINT_16)
1484 prIeArray[i].pfnCalculateVariableIELen(prAdapter, eNetTypeIndex, NULL);
1485 }
1486 }
1487
1488 u2EstimatedFrameLen += u2EstimatedExtraIELen;
1489
1490 if ((prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
1491 DBGLOG(BSS, WARN, ("No PKT_INFO_T for sending %s.\n",
1492 ((!pucDestAddr) ? "Beacon" : "Probe Response")));
1493 return WLAN_STATUS_RESOURCES;
1494 }
1495
1496 /* 4 <2> Compose Beacon/Probe Response frame header and fixed fields in MSDU_INfO_T. */
1497 /* Compose Header and Fixed Field */
1498 #if CFG_ENABLE_WIFI_DIRECT
1499 if (u4ControlFlags & BSS_PROBE_RESP_USE_P2P_DEV_ADDR) {
1500 if (prAdapter->fgIsP2PRegistered) {
1501 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8)
1502 ((UINT_32) (prMsduInfo->prPacket)
1503 + MAC_TX_RESERVED_FIELD),
1504 pucDestAddr,
1505 prAdapter->rWifiVar.
1506 aucDeviceAddress,
1507 prAdapter->rWifiVar.
1508 aucDeviceAddress,
1509 DOT11_BEACON_PERIOD_DEFAULT,
1510 (prBssInfo->
1511 u2CapInfo & ~(CAP_INFO_ESS |
1512 CAP_INFO_IBSS)));
1513 }
1514 } else
1515 #endif /* CFG_ENABLE_WIFI_DIRECT */
1516 {
1517 bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8)
1518 ((UINT_32) (prMsduInfo->prPacket) +
1519 MAC_TX_RESERVED_FIELD), pucDestAddr,
1520 prBssInfo->aucOwnMacAddr,
1521 prBssInfo->aucBSSID,
1522 prBssInfo->u2BeaconInterval,
1523 prBssInfo->u2CapInfo);
1524 }
1525
1526
1527 /* 4 <3> Update information of MSDU_INFO_T */
1528 prMsduInfo->eSrc = TX_PACKET_MGMT;
1529 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
1530 prMsduInfo->ucStaRecIndex = 0xFF;
1531 prMsduInfo->ucNetworkType = (UINT_8) eNetTypeIndex;
1532 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
1533 prMsduInfo->fgIs802_1x = FALSE;
1534 prMsduInfo->fgIs802_11 = TRUE;
1535 prMsduInfo->u2FrameLength = (WLAN_MAC_MGMT_HEADER_LEN +
1536 TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN +
1537 CAP_INFO_FIELD_LEN);
1538 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
1539 prMsduInfo->pfTxDoneHandler = NULL;
1540 prMsduInfo->fgIsBasicRate = TRUE;
1541
1542
1543 /* 4 <4> Compose the frame body's Common IEs of the Beacon/ProbeResp frame. */
1544 bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo, prBssInfo, pucDestAddr);
1545
1546
1547 /* 4 <5> Compose IEs in MSDU_INFO_T */
1548
1549 /* Append IE */
1550 for (i = 0; i < u4IeArraySize; i++) {
1551 if (prIeArray[i].pfnAppendIE) {
1552 prIeArray[i].pfnAppendIE(prAdapter, prMsduInfo);
1553 }
1554 }
1555
1556 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1557
1558 /* 4 <6> Inform TXM to send this Beacon /Probe Response frame. */
1559 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
1560
1561 return WLAN_STATUS_SUCCESS;
1562
1563 } /* end of bssSendBeaconProbeResponse() */
1564
1565
1566 /*----------------------------------------------------------------------------*/
1567 /*!
1568 * @brief This function will process the Rx Probe Request Frame and then send
1569 * back the corresponding Probe Response Frame if the specified conditions
1570 * were matched.
1571 *
1572 * @param[in] prAdapter Pointer to the Adapter structure.
1573 * @param[in] prSwRfb Pointer to SW RFB data structure.
1574 *
1575 * @retval WLAN_STATUS_SUCCESS Always return success
1576 */
1577 /*----------------------------------------------------------------------------*/
1578 WLAN_STATUS bssProcessProbeRequest(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
1579 {
1580 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
1581 P_BSS_INFO_T prBssInfo;
1582 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
1583 UINT_8 aucBCBSSID[] = BC_BSSID;
1584 BOOLEAN fgIsBcBssid;
1585 BOOLEAN fgReplyProbeResp;
1586 UINT_32 u4CtrlFlagsForProbeResp = 0;
1587 ENUM_BAND_T eBand;
1588 UINT_8 ucHwChannelNum;
1589
1590
1591 ASSERT(prSwRfb);
1592
1593 /* 4 <1> Parse Probe Req and Get BSSID */
1594 prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
1595
1596 if (EQUAL_MAC_ADDR(aucBCBSSID, prMgtHdr->aucBSSID)) {
1597 fgIsBcBssid = TRUE;
1598 } else {
1599 fgIsBcBssid = FALSE;
1600 }
1601
1602
1603 /* 4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent) */
1604 for (eNetTypeIndex = NETWORK_TYPE_AIS_INDEX; eNetTypeIndex < NETWORK_TYPE_INDEX_NUM;
1605 eNetTypeIndex++) {
1606
1607 if (!IS_NET_ACTIVE(prAdapter, eNetTypeIndex)) {
1608 continue;
1609 }
1610
1611 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1612
1613 if ((!fgIsBcBssid) && UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prMgtHdr->aucBSSID)) {
1614 continue;
1615 }
1616
1617 eBand = HIF_RX_HDR_GET_RF_BAND(prSwRfb->prHifRxHdr);
1618 ucHwChannelNum = HIF_RX_HDR_GET_CHNL_NUM(prSwRfb->prHifRxHdr);
1619
1620 if (prBssInfo->eBand != eBand) {
1621 continue;
1622 }
1623
1624 if (prBssInfo->ucPrimaryChannel != ucHwChannelNum) {
1625 continue;
1626 }
1627
1628 fgReplyProbeResp = FALSE;
1629
1630 if (NETWORK_TYPE_AIS_INDEX == eNetTypeIndex) {
1631
1632 #if CFG_SUPPORT_ADHOC
1633 fgReplyProbeResp =
1634 aisValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
1635 #endif
1636 }
1637 #if CFG_ENABLE_WIFI_DIRECT
1638 else if ((prAdapter->fgIsP2PRegistered) &&
1639 (NETWORK_TYPE_P2P_INDEX == eNetTypeIndex)) {
1640
1641 fgReplyProbeResp =
1642 p2pFuncValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
1643 }
1644 #endif
1645 #if CFG_ENABLE_BT_OVER_WIFI
1646 else if (NETWORK_TYPE_BOW_INDEX == eNetTypeIndex) {
1647
1648 fgReplyProbeResp =
1649 bowValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
1650 }
1651 #endif
1652
1653 if (fgReplyProbeResp) {
1654 if (nicTxGetFreeCmdCount(prAdapter) > (CFG_TX_MAX_CMD_PKT_NUM / 2)) {
1655 /* Resource margin is enough */
1656 bssSendBeaconProbeResponse(prAdapter, eNetTypeIndex,
1657 prMgtHdr->aucSrcAddr,
1658 u4CtrlFlagsForProbeResp);
1659 }
1660 }
1661 }
1662
1663 return WLAN_STATUS_SUCCESS;
1664
1665 } /* end of bssProcessProbeRequest() */
1666
1667
1668 #if 0 /* NOTE(Kevin): condition check should move to P2P_FSM.c */
1669 /*----------------------------------------------------------------------------*/
1670 /*!
1671 * @brief This function will process the Rx Probe Request Frame and then send
1672 * back the corresponding Probe Response Frame if the specified conditions
1673 * were matched.
1674 *
1675 * @param[in] prSwRfb Pointer to SW RFB data structure.
1676 *
1677 * @retval WLAN_STATUS_SUCCESS Always return success
1678 */
1679 /*----------------------------------------------------------------------------*/
1680 WLAN_STATUS bssProcessProbeRequest(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
1681 {
1682 P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
1683 P_BSS_INFO_T prBssInfo;
1684 P_IE_SSID_T prIeSsid = (P_IE_SSID_T) NULL;
1685 P_IE_SUPPORTED_RATE_T prIeSupportedRate = (P_IE_SUPPORTED_RATE_T) NULL;
1686 P_IE_EXT_SUPPORTED_RATE_T prIeExtSupportedRate = (P_IE_EXT_SUPPORTED_RATE_T) NULL;
1687 PUINT_8 pucIE;
1688 UINT_16 u2IELength;
1689 UINT_16 u2Offset = 0;
1690 UINT_8 aucBCBSSID[] = BC_BSSID;
1691 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
1692 BOOLEAN fgReplyProbeResp;
1693 #if CFG_ENABLE_WIFI_DIRECT
1694 BOOLEAN fgP2PTargetDeviceFound;
1695 UINT_8 aucP2PWildcardSSID[] = P2P_WILDCARD_SSID;
1696 #endif
1697
1698 ASSERT(prSwRfb);
1699
1700 /* 4 <1> Parse Probe Req and Get SSID IE ptr */
1701 prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
1702
1703 u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
1704 pucIE = (PUINT_8) ((UINT_32) prSwRfb->pvHeader + prSwRfb->u2HeaderLen);
1705
1706 prIeSsid = (P_IE_SSID_T) NULL;
1707
1708 IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
1709 switch (IE_ID(pucIE)) {
1710 case ELEM_ID_SSID:
1711 if ((!prIeSsid) && (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID)) {
1712 prIeSsid = (P_IE_SSID_T) pucIE;
1713 }
1714 break;
1715
1716 case ELEM_ID_SUP_RATES:
1717 /* NOTE(Kevin): Buffalo WHR-G54S's supported rate set IE exceed 8.
1718 * IE_LEN(pucIE) == 12, "1(B), 2(B), 5.5(B), 6(B), 9(B), 11(B),
1719 * 12(B), 18(B), 24(B), 36(B), 48(B), 54(B)"
1720 */
1721 /* if (IE_LEN(pucIE) <= ELEM_MAX_LEN_SUP_RATES) { */
1722 if (IE_LEN(pucIE) <= RATE_NUM) {
1723 prIeSupportedRate = SUP_RATES_IE(pucIE);
1724 }
1725 break;
1726
1727 case ELEM_ID_EXTENDED_SUP_RATES:
1728 prIeExtSupportedRate = EXT_SUP_RATES_IE(pucIE);
1729 break;
1730
1731 #if CFG_ENABLE_WIFI_DIRECT
1732 /* TODO: P2P IE & WCS IE parsing for P2P. */
1733 case ELEM_ID_P2P:
1734
1735 break;
1736 #endif
1737
1738 /* no default */
1739 }
1740 } /* end of IE_FOR_EACH */
1741
1742 /* 4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent) */
1743 for (eNetTypeIndex = NETWORK_TYPE_AIS_INDEX; eNetTypeIndex < NETWORK_TYPE_INDEX_NUM;
1744 eNetTypeIndex++) {
1745
1746 if (!IS_NET_ACTIVE(prAdapter, eNetTypeIndex)) {
1747 continue;
1748 }
1749
1750 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
1751
1752 if (UNEQUAL_MAC_ADDR(aucBCBSSID, prMgtHdr->aucBSSID) &&
1753 UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prMgtHdr->aucBSSID)) {
1754 /* BSSID not Wildcard BSSID. */
1755 continue;
1756 }
1757
1758 fgReplyProbeResp = FALSE;
1759
1760 if (NETWORK_TYPE_AIS_INDEX == eNetTypeIndex) {
1761
1762 if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
1763
1764 /* TODO(Kevin): Check if we are IBSS Master. */
1765 if (TRUE) {
1766
1767 if (prIeSsid) {
1768 if ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
1769 EQUAL_SSID(prBssInfo->aucSSID,
1770 prBssInfo->ucSSIDLen,
1771 prIeSsid->aucSSID,
1772 prIeSsid->ucLength)) {
1773 fgReplyProbeResp = TRUE;
1774 }
1775 }
1776 }
1777 }
1778 }
1779 #if CFG_ENABLE_WIFI_DIRECT
1780 else if (NETWORK_TYPE_P2P_INDEX == eNetTypeIndex) {
1781
1782 /* TODO(Kevin): Move following lines to p2p_fsm.c */
1783
1784 if ((prIeSsid) &&
1785 ((prIeSsid->ucLength == BC_SSID_LEN) ||
1786 (EQUAL_SSID(aucP2PWildcardSSID,
1787 P2P_WILDCARD_SSID_LEN,
1788 prIeSsid->aucSSID, prIeSsid->ucLength)))) {
1789 /* if (p2pFsmRunEventRxProbeRequestFrame(prAdapter, prMgtHdr->aucSrcAddr, pucIE, u2IELength)) { */
1790 if (p2pFsmRunEventRxProbeRequestFrame(prAdapter, prSwRfb)) {
1791 /* Extand channel request time & cancel scan request. */
1792 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
1793
1794 /* TODO: RX probe request may not caused by LISTEN state. */
1795 /* TODO: It can be GO. */
1796 /* Generally speaking, cancel a non-exist scan request is fine.
1797 * We can check P2P FSM here for only LISTEN state.
1798 */
1799
1800 P_MSG_SCN_SCAN_CANCEL prScanCancelMsg;
1801
1802 prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
1803
1804 /* Abort JOIN process. */
1805 prScanCancelMsg =
1806 (P_MSG_SCN_SCAN_CANCEL) cnmMemAlloc(prAdapter,
1807 RAM_TYPE_MSG,
1808 sizeof
1809 (MSG_SCN_SCAN_CANCEL));
1810 if (!prScanCancelMsg) {
1811 ASSERT(0); /* Can't abort SCN FSM */
1812 continue;
1813 }
1814
1815 prScanCancelMsg->rMsgHdr.eMsgId = MID_P2P_SCN_SCAN_CANCEL;
1816 prScanCancelMsg->ucSeqNum = prP2pFsmInfo->ucSeqNumOfScnMsg;
1817 prScanCancelMsg->ucNetTypeIndex =
1818 (UINT_8) NETWORK_TYPE_P2P_INDEX;
1819 prScanCancelMsg->fgIsChannelExt = TRUE;
1820
1821 mboxSendMsg(prAdapter,
1822 MBOX_ID_0,
1823 (P_MSG_HDR_T) prScanCancelMsg,
1824 MSG_SEND_METHOD_BUF);
1825 }
1826 } else {
1827 /* 1. Probe Request without SSID.
1828 * 2. Probe Request with SSID not Wildcard SSID & not P2P Wildcard SSID.
1829 */
1830 continue;
1831 }
1832
1833 #if 0 /* Frog */
1834 if (prAdapter->rWifiVar.prP2pFsmInfo->eCurrentState == P2P_STATE_LISTEN) {
1835 /* P2P 2.4.1 - P2P Devices shall not respond to Probe Request frames which only contain 11b rates only. */
1836 if (prIeSupportedRate || prIeExtSupportedRate) {
1837 UINT_16 u2OperationalRateSet, u2BSSBasicRateSet;
1838 BOOLEAN fgIsUnknownBssBasicRate;
1839
1840 rateGetRateSetFromIEs(prIeSupportedRate, prIeExtSupportedRate, &u2OperationalRateSet, &u2BSSBasicRateSet, /* Ignore any Basic Bit */
1841 &fgIsUnknownBssBasicRate);
1842
1843 if (u2OperationalRateSet & ~RATE_SET_HR_DSSS) {
1844 continue;
1845 }
1846 }
1847 }
1848 /* TODO: Check channel time before first check point to: */
1849 /* If Target device is selected:
1850 * 1. Send XXXX request frame.
1851 * else
1852 * 1. Send Probe Response frame.
1853 */
1854
1855 if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
1856 /* TODO(Kevin): During PROVISION state, can we reply Probe Response ? */
1857
1858 /* TODO(Kevin):
1859 * If we are GO, accept legacy client --> accept Wildcard SSID
1860 * If we are in Listen State, accept only P2P Device --> check P2P IE and WPS IE
1861 */
1862 if (TRUE /* We are GO */) {
1863 if (prIeSsid) {
1864 UINT_8 aucSSID[] = P2P_WILDCARD_SSID;
1865
1866 if ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
1867 EQUAL_SSID(prBssInfo->aucSSID,
1868 prBssInfo->ucSSIDLen,
1869 prIeSsid->aucSSID,
1870 prIeSsid->ucLength)
1871 || EQUAL_SSID(aucSSID, P2P_WILDCARD_SSID_LEN,
1872 prIeSsid->aucSSID,
1873 prIeSsid->ucLength)) {
1874 fgReplyProbeResp = TRUE;
1875 }
1876 }
1877 }
1878 /* else if (FALSE /* We are in Listen State */) { */
1879 /* } */
1880
1881 /* TODO(Kevin): Check P2P IE and WPS IE */
1882 }
1883 #endif
1884 }
1885 #endif
1886 #if CFG_ENABLE_BT_OVER_WIFI
1887 else if (NETWORK_TYPE_BOW_INDEX == eNetTypeIndex) {
1888
1889 if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
1890 /* TODO(Kevin): TBD */
1891 }
1892 }
1893 #endif
1894 else {
1895 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1896 }
1897
1898 if (fgReplyProbeResp) {
1899 bssSendBeaconProbeResponse(prAdapter, eNetTypeIndex, prMgtHdr->aucSrcAddr);
1900 }
1901
1902 }
1903
1904 return WLAN_STATUS_SUCCESS;
1905
1906 } /* end of bssProcessProbeRequest() */
1907 #endif
1908
1909
1910 /*----------------------------------------------------------------------------*/
1911 /*!
1912 * @brief This function is used to clear the client list for AdHoc or AP Mode
1913 *
1914 * @param[in] prAdapter Pointer to the Adapter structure.
1915 * @param[in] prBssInfo Given related BSS_INFO_T.
1916 *
1917 * @return (none)
1918 */
1919 /*----------------------------------------------------------------------------*/
1920 VOID bssClearClientList(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
1921 {
1922 P_LINK_T prStaRecOfClientList;
1923
1924
1925 ASSERT(prBssInfo);
1926
1927 prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
1928
1929 if (!LINK_IS_EMPTY(prStaRecOfClientList)) {
1930 P_STA_RECORD_T prPeerStaRec;
1931
1932 LINK_FOR_EACH_ENTRY(prPeerStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
1933 cnmStaRecChangeState(prAdapter, prPeerStaRec, STA_STATE_1);
1934 }
1935
1936 LINK_INITIALIZE(prStaRecOfClientList);
1937 }
1938
1939 return;
1940 } /* end of bssClearClientList() */
1941
1942
1943
1944 /*----------------------------------------------------------------------------*/
1945 /*!
1946 * @brief This function is used to Add a STA_RECORD_T to the client list for AdHoc or AP Mode
1947 *
1948 * @param[in] prAdapter Pointer to the Adapter structure.
1949 * @param[in] prBssInfo Given related BSS_INFO_T.
1950 * @param[in] prStaRec Pointer to the STA_RECORD_T
1951 *
1952 * @return (none)
1953 */
1954 /*----------------------------------------------------------------------------*/
1955 VOID
1956 bssAddStaRecToClientList(IN P_ADAPTER_T prAdapter,
1957 IN P_BSS_INFO_T prBssInfo, IN P_STA_RECORD_T prStaRec)
1958 {
1959 P_LINK_T prStaRecOfClientList;
1960
1961
1962 ASSERT(prBssInfo);
1963
1964 prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
1965
1966 if (!LINK_IS_EMPTY(prStaRecOfClientList)) {
1967 P_STA_RECORD_T prCurrStaRec;
1968
1969 LINK_FOR_EACH_ENTRY(prCurrStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
1970
1971 if (prCurrStaRec == prStaRec) {
1972 DBGLOG(BSS, WARN,
1973 ("Current Client List already contains that STA_RECORD_T["
1974 MACSTR "]\n", MAC2STR(prStaRec->aucMacAddr)));
1975 return;
1976 }
1977 }
1978 }
1979
1980 LINK_INSERT_TAIL(prStaRecOfClientList, &prStaRec->rLinkEntry);
1981
1982 return;
1983 } /* end of bssAddStaRecToClientList() */
1984
1985
1986 /*----------------------------------------------------------------------------*/
1987 /*!
1988 * @brief This function is used to Remove a STA_RECORD_T from the client list for AdHoc or AP Mode
1989 *
1990 * @param[in] prAdapter Pointer to the Adapter structure.
1991 * @param[in] prStaRec Pointer to the STA_RECORD_T
1992 *
1993 * @return (none)
1994 */
1995 /*----------------------------------------------------------------------------*/
1996 VOID
1997 bssRemoveStaRecFromClientList(IN P_ADAPTER_T prAdapter,
1998 IN P_BSS_INFO_T prBssInfo, IN P_STA_RECORD_T prStaRec)
1999 {
2000 P_LINK_T prStaRecOfClientList;
2001
2002
2003 ASSERT(prBssInfo);
2004
2005 prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
2006
2007 if (!LINK_IS_EMPTY(prStaRecOfClientList)) {
2008 P_STA_RECORD_T prCurrStaRec;
2009
2010 LINK_FOR_EACH_ENTRY(prCurrStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
2011
2012 if (prCurrStaRec == prStaRec) {
2013
2014 LINK_REMOVE_KNOWN_ENTRY(prStaRecOfClientList,
2015 &prStaRec->rLinkEntry);
2016
2017 return;
2018 }
2019 }
2020 }
2021
2022 DBGLOG(BSS, INFO,
2023 ("Current Client List didn't contain that STA_RECORD_T[" MACSTR
2024 "] before removing.\n", MAC2STR(prStaRec->aucMacAddr)));
2025
2026 return;
2027 } /* end of bssRemoveStaRecFromClientList() */
2028 #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
2029
2030
2031 #if CFG_SUPPORT_ADHOC
2032 /*----------------------------------------------------------------------------*/
2033 /* Routines for IBSS(AdHoc) only */
2034 /*----------------------------------------------------------------------------*/
2035 /*----------------------------------------------------------------------------*/
2036 /*!
2037 * @brief This function is used to process Beacons from current Ad-Hoc network peers.
2038 * We also process Beacons from other Ad-Hoc network during SCAN. If it has
2039 * the same SSID and we'll decide to merge into it if it has a larger TSF.
2040 *
2041 * @param[in] prAdapter Pointer to the Adapter structure.
2042 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2043 * @param[in] prBSSDesc Pointer to the BSS Descriptor.
2044 *
2045 * @return (none)
2046 */
2047 /*----------------------------------------------------------------------------*/
2048 VOID
2049 ibssProcessMatchedBeacon(IN P_ADAPTER_T prAdapter,
2050 IN P_BSS_INFO_T prBssInfo, IN P_BSS_DESC_T prBssDesc, IN UINT_8 ucRCPI)
2051 {
2052 P_STA_RECORD_T prStaRec = NULL;
2053
2054 BOOLEAN fgIsCheckCapability = FALSE;
2055 BOOLEAN fgIsCheckTSF = FALSE;
2056 BOOLEAN fgIsGoingMerging = FALSE;
2057 BOOLEAN fgIsSameBSSID;
2058
2059
2060 ASSERT(prBssInfo);
2061 ASSERT(prBssDesc);
2062
2063 /* 4 <1> Process IBSS Beacon only after we create or merge with other IBSS. */
2064 if (!prBssInfo->fgIsBeaconActivated) {
2065 return;
2066 }
2067 /* 4 <2> Get the STA_RECORD_T of TA. */
2068 prStaRec = cnmGetStaRecByAddress(prAdapter,
2069 (UINT_8) NETWORK_TYPE_AIS_INDEX, prBssDesc->aucSrcAddr);
2070
2071 fgIsSameBSSID = UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID) ? FALSE : TRUE;
2072
2073
2074 /* 4 <3> IBSS Merge Decision Flow for Processing Beacon. */
2075 if (fgIsSameBSSID) {
2076
2077 /* Same BSSID:
2078 * Case I. This is a new TA and it has decide to merged with us.
2079 * a) If fgIsMerging == FALSE - we will send msg to notify AIS.
2080 * b) If fgIsMerging == TRUE - already notify AIS.
2081 * Case II. This is an old TA and we've already merged together.
2082 */
2083 if (!prStaRec) {
2084
2085 /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
2086 fgIsCheckCapability = TRUE;
2087
2088 /* If check is passed, then we perform merging with this new IBSS */
2089 fgIsGoingMerging = TRUE;
2090
2091 } else {
2092
2093 ASSERT((prStaRec->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) &&
2094 IS_ADHOC_STA(prStaRec));
2095
2096 if (prStaRec->ucStaState != STA_STATE_3) {
2097
2098 if (!prStaRec->fgIsMerging) {
2099
2100 /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
2101 fgIsCheckCapability = TRUE;
2102
2103 /* If check is passed, then we perform merging with this new IBSS */
2104 fgIsGoingMerging = TRUE;
2105 } else {
2106 /* For Case II - Update rExpirationTime of Sta Record */
2107 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
2108 }
2109 } else {
2110 /* For Case II - Update rExpirationTime of Sta Record */
2111 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
2112 }
2113
2114 }
2115 } else {
2116
2117 /* Unequal BSSID:
2118 * Case III. This is a new TA and we need to compare the TSF and get the winner.
2119 * Case IV. This is an old TA and it merge into a new IBSS before we do the same thing.
2120 * We need to compare the TSF to get the winner.
2121 * Case V. This is an old TA and it restart a new IBSS. We also need to
2122 * compare the TSF to get the winner.
2123 */
2124
2125 /* For Case III, IV & V - We'll always check this new IBSS's capability first
2126 * before merging into new IBSS.
2127 */
2128 fgIsCheckCapability = TRUE;
2129
2130 /* If check is passed, we need to perform TSF check to decide the major BSSID */
2131 fgIsCheckTSF = TRUE;
2132
2133 /* For Case IV & V - We won't update rExpirationTime of Sta Record */
2134 }
2135
2136
2137 /* 4 <7> Check this BSS_DESC_T's capability. */
2138 if (fgIsCheckCapability) {
2139 BOOLEAN fgIsCapabilityMatched = FALSE;
2140
2141 do {
2142 if (!
2143 (prBssDesc->
2144 ucPhyTypeSet & (prAdapter->rWifiVar.ucAvailablePhyTypeSet))) {
2145 DBGLOG(BSS, LOUD,
2146 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2147 " - Unsupported Phy.\n", MAC2STR(prBssDesc->aucSrcAddr)));
2148
2149 break;
2150 }
2151
2152 if (prBssDesc->fgIsUnknownBssBasicRate) {
2153 DBGLOG(BSS, LOUD,
2154 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2155 " - Unknown Basic Rate.\n",
2156 MAC2STR(prBssDesc->aucSrcAddr)));
2157
2158 break;
2159 }
2160
2161 if (ibssCheckCapabilityForAdHocMode(prAdapter, prBssDesc) ==
2162 WLAN_STATUS_FAILURE) {
2163 DBGLOG(BSS, LOUD,
2164 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2165 " - Capability is not matched.\n",
2166 MAC2STR(prBssDesc->aucSrcAddr)));
2167
2168 break;
2169 }
2170
2171 fgIsCapabilityMatched = TRUE;
2172 }
2173 while (FALSE);
2174
2175 if (!fgIsCapabilityMatched) {
2176
2177 if (prStaRec) {
2178 /* For Case II - We merge this STA_RECORD in RX Path.
2179 * Case IV & V - They change their BSSID after we merge with them.
2180 */
2181
2182 DBGLOG(BSS, LOUD,
2183 ("IBSS MERGE: Ignore Peer MAC: " MACSTR
2184 " - Capability is not matched.\n",
2185 MAC2STR(prBssDesc->aucSrcAddr)));
2186 }
2187
2188 return;
2189 }
2190
2191 DBGLOG(BSS, LOUD,
2192 ("IBSS MERGE: Peer MAC: " MACSTR " - Check capability was passed.\n",
2193 MAC2STR(prBssDesc->aucSrcAddr)));
2194 }
2195
2196
2197 if (fgIsCheckTSF) {
2198 #if CFG_SLT_SUPPORT
2199 fgIsGoingMerging = TRUE;
2200 #else
2201 if (prBssDesc->fgIsLargerTSF) {
2202 fgIsGoingMerging = TRUE;
2203 } else {
2204 return;
2205 }
2206 #endif
2207 }
2208
2209
2210 if (fgIsGoingMerging) {
2211 P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg;
2212
2213
2214 /* 4 <1> We will merge with to this BSS immediately. */
2215 prBssDesc->fgIsConnecting = TRUE;
2216 prBssDesc->fgIsConnected = FALSE;
2217
2218 /* 4 <2> Setup corresponding STA_RECORD_T */
2219 prStaRec = bssCreateStaRecFromBssDesc(prAdapter,
2220 STA_TYPE_ADHOC_PEER,
2221 NETWORK_TYPE_AIS_INDEX, prBssDesc);
2222
2223 if (!prStaRec) {
2224 /* no memory ? */
2225 return;
2226 }
2227
2228 prStaRec->fgIsMerging = TRUE;
2229
2230 /* update RCPI */
2231 prStaRec->ucRCPI = ucRCPI;
2232
2233 /* 4 <3> Send Merge Msg to CNM to obtain the channel privilege. */
2234 prAisIbssPeerFoundMsg = (P_MSG_AIS_IBSS_PEER_FOUND_T)
2235 cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_AIS_IBSS_PEER_FOUND_T));
2236
2237 if (!prAisIbssPeerFoundMsg) {
2238
2239 ASSERT(0); /* Can't send Merge Msg */
2240 return;
2241 }
2242
2243 prAisIbssPeerFoundMsg->rMsgHdr.eMsgId = MID_SCN_AIS_FOUND_IBSS;
2244 prAisIbssPeerFoundMsg->ucNetTypeIndex = (UINT_8) NETWORK_TYPE_AIS_INDEX;
2245 prAisIbssPeerFoundMsg->prStaRec = prStaRec;
2246
2247 /* Inform AIS to do STATE TRANSITION
2248 * For Case I - If AIS in IBSS_ALONE, let it jump to NORMAL_TR after we know the new member.
2249 * For Case III, IV - Now this new BSSID wins the TSF, follow it.
2250 */
2251 if (fgIsSameBSSID) {
2252 prAisIbssPeerFoundMsg->fgIsMergeIn = TRUE;
2253 } else {
2254 #if CFG_SLT_SUPPORT
2255 prAisIbssPeerFoundMsg->fgIsMergeIn = TRUE;
2256 #else
2257 prAisIbssPeerFoundMsg->fgIsMergeIn =
2258 (prBssDesc->fgIsLargerTSF) ? FALSE : TRUE;
2259 #endif
2260 }
2261
2262 mboxSendMsg(prAdapter,
2263 MBOX_ID_0, (P_MSG_HDR_T) prAisIbssPeerFoundMsg, MSG_SEND_METHOD_BUF);
2264
2265 }
2266
2267 return;
2268 } /* end of ibssProcessMatchedBeacon() */
2269
2270
2271 /*----------------------------------------------------------------------------*/
2272 /*!
2273 * @brief This function will check the Capability for Ad-Hoc to decide if we are
2274 * able to merge with(same capability).
2275 *
2276 * @param[in] prBSSDesc Pointer to the BSS Descriptor.
2277 *
2278 * @retval WLAN_STATUS_FAILURE Can't pass the check of Capability.
2279 * @retval WLAN_STATUS_SUCCESS Pass the check of Capability.
2280 */
2281 /*----------------------------------------------------------------------------*/
2282 WLAN_STATUS ibssCheckCapabilityForAdHocMode(IN P_ADAPTER_T prAdapter, IN P_BSS_DESC_T prBssDesc)
2283 {
2284 P_CONNECTION_SETTINGS_T prConnSettings;
2285 WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
2286
2287
2288 ASSERT(prBssDesc);
2289 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
2290
2291 do {
2292 /* 4 <1> Check the BSS Basic Rate Set for current AdHoc Mode */
2293 if ((prConnSettings->eAdHocMode == AD_HOC_MODE_11B) &&
2294 (prBssDesc->u2BSSBasicRateSet & ~RATE_SET_HR_DSSS)) {
2295 break;
2296 } else if ((prConnSettings->eAdHocMode == AD_HOC_MODE_11A) &&
2297 (prBssDesc->u2BSSBasicRateSet & ~RATE_SET_OFDM)) {
2298 break;
2299 }
2300 /* 4 <2> Check the Short Slot Time. */
2301 #if 0 /* Do not check ShortSlotTime until Wi-Fi define such policy */
2302 if (prConnSettings->eAdHocMode == AD_HOC_MODE_11G) {
2303 if (((prConnSettings->fgIsShortSlotTimeOptionEnable) &&
2304 !(prBssDesc->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME)) ||
2305 (!(prConnSettings->fgIsShortSlotTimeOptionEnable) &&
2306 (prBssDesc->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME))) {
2307 break;
2308 }
2309 }
2310 #endif
2311
2312 /* 4 <3> Check the ATIM window setting. */
2313 if (prBssDesc->u2ATIMWindow) {
2314 DBGLOG(BSS, INFO, ("AdHoc PS was not supported(ATIM Window: %d)\n",
2315 prBssDesc->u2ATIMWindow));
2316 break;
2317 }
2318 #if CFG_RSN_MIGRATION
2319 /* 4 <4> Check the Security setting. */
2320 if (!rsnPerformPolicySelection(prAdapter, prBssDesc)) {
2321 break;
2322 }
2323 #endif
2324
2325 rStatus = WLAN_STATUS_SUCCESS;
2326 }
2327 while (FALSE);
2328
2329 return rStatus;
2330
2331 } /* end of ibssCheckCapabilityForAdHocMode() */
2332
2333
2334 /*----------------------------------------------------------------------------*/
2335 /*!
2336 * @brief This function will initial the BSS_INFO_T for IBSS Mode.
2337 *
2338 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2339 *
2340 * @return (none)
2341 */
2342 /*----------------------------------------------------------------------------*/
2343 VOID ibssInitForAdHoc(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
2344 {
2345 UINT_8 ucLowestBasicRateIndex;
2346 UINT_8 aucBSSID[MAC_ADDR_LEN];
2347 PUINT_16 pu2BSSID = (PUINT_16) &aucBSSID[0];
2348 UINT_32 i;
2349
2350
2351 ASSERT(prBssInfo);
2352 ASSERT(prBssInfo->eCurrentOPMode == OP_MODE_IBSS);
2353
2354
2355 /* 4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
2356 prBssInfo->ucNonHTBasicPhyType = (UINT_8)
2357 rNonHTAdHocModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
2358 prBssInfo->u2BSSBasicRateSet =
2359 rNonHTAdHocModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
2360
2361
2362 prBssInfo->u2OperationalRateSet =
2363 rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
2364
2365 rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
2366 prBssInfo->u2BSSBasicRateSet,
2367 prBssInfo->aucAllSupportedRates,
2368 &prBssInfo->ucAllSupportedRatesLen);
2369
2370 /* 4 <2> Setup BSSID */
2371 if (!prBssInfo->fgHoldSameBssidForIBSS) {
2372
2373 for (i = 0; i < sizeof(aucBSSID) / sizeof(UINT_16); i++) {
2374 pu2BSSID[i] = (UINT_16) (kalRandomNumber() & 0xFFFF);
2375 }
2376
2377 aucBSSID[0] &= ~0x01; /* 7.1.3.3.3 - The individual/group bit of the address is set to 0. */
2378 aucBSSID[0] |= 0x02; /* 7.1.3.3.3 - The universal/local bit of the address is set to 1. */
2379
2380 COPY_MAC_ADDR(prBssInfo->aucBSSID, aucBSSID);
2381 }
2382
2383 /* 4 <3> Setup Capability - Short Preamble */
2384 if (rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].fgIsShortPreambleOptionImplemented && ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
2385 (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO))) {
2386
2387 prBssInfo->fgIsShortPreambleAllowed = TRUE;
2388 prBssInfo->fgUseShortPreamble = TRUE;
2389 } else {
2390 prBssInfo->fgIsShortPreambleAllowed = FALSE;
2391 prBssInfo->fgUseShortPreamble = FALSE;
2392 }
2393
2394
2395 /* 4 <4> Setup Capability - Short Slot Time */
2396 /* 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0. */
2397 prBssInfo->fgUseShortSlotTime = FALSE; /* Set to FALSE for AdHoc */
2398
2399
2400 /* 4 <5> Compoase Capability */
2401 prBssInfo->u2CapInfo = CAP_INFO_IBSS;
2402
2403 if (prBssInfo->fgIsProtection) {
2404 prBssInfo->u2CapInfo |= CAP_INFO_PRIVACY;
2405 }
2406
2407 if (prBssInfo->fgIsShortPreambleAllowed) {
2408 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
2409 }
2410
2411 if (prBssInfo->fgUseShortSlotTime) {
2412 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
2413 }
2414
2415 /* 4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
2416 rateGetLowestRateIndexFromRateSet(prBssInfo->u2BSSBasicRateSet, &ucLowestBasicRateIndex);
2417
2418 prBssInfo->ucHwDefaultFixedRateCode =
2419 aucRateIndex2RateCode[PREAMBLE_DEFAULT_LONG_NONE][ucLowestBasicRateIndex];
2420
2421 return;
2422 } /* end of ibssInitForAdHoc() */
2423
2424 #endif /* CFG_SUPPORT_ADHOC */
2425
2426
2427 #if CFG_SUPPORT_AAA
2428
2429 /*----------------------------------------------------------------------------*/
2430 /* Routines for BSS(AP) only */
2431 /*----------------------------------------------------------------------------*/
2432 /*----------------------------------------------------------------------------*/
2433 /*!
2434 * @brief This function will initial the BSS_INFO_T for AP Mode.
2435 *
2436 * @param[in] prBssInfo Given related BSS_INFO_T.
2437 *
2438 * @return (none)
2439 */
2440 /*----------------------------------------------------------------------------*/
2441 VOID bssInitForAP(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN BOOLEAN fgIsRateUpdate)
2442 {
2443 UINT_8 ucLowestBasicRateIndex;
2444
2445 P_AC_QUE_PARMS_T prACQueParms;
2446
2447 ENUM_WMM_ACI_T eAci;
2448
2449 UINT_8 auCWminLog2ForBcast[WMM_AC_INDEX_NUM] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/ };
2450 UINT_8 auCWmaxLog2ForBcast[WMM_AC_INDEX_NUM] = { 10, 10, 4, 3 };
2451 UINT_8 auAifsForBcast[WMM_AC_INDEX_NUM] = { 3, 7, 2, 2 };
2452 UINT_8 auTxopForBcast[WMM_AC_INDEX_NUM] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
2453
2454 UINT_8 auCWminLog2[WMM_AC_INDEX_NUM] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/ };
2455 UINT_8 auCWmaxLog2[WMM_AC_INDEX_NUM] = { 7, 10, 4, 3 };
2456 UINT_8 auAifs[WMM_AC_INDEX_NUM] = { 3, 7, 1, 1 };
2457 UINT_8 auTxop[WMM_AC_INDEX_NUM] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
2458
2459 DEBUGFUNC("bssInitForAP");
2460 DBGLOG(BSS, LOUD, ("\n"));
2461
2462 ASSERT(prBssInfo);
2463 ASSERT((prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)
2464 || (prBssInfo->eCurrentOPMode == OP_MODE_BOW));
2465
2466 #if 0
2467 prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled = TRUE;
2468 prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode = CONFIG_BW_20M;
2469 prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode = CONFIG_BW_20M;
2470 #endif
2471
2472
2473 /* 4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
2474 prBssInfo->ucNonHTBasicPhyType = (UINT_8)
2475 rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
2476 prBssInfo->u2BSSBasicRateSet =
2477 rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
2478
2479
2480 prBssInfo->u2OperationalRateSet =
2481 rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
2482
2483 if (fgIsRateUpdate) {
2484 rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
2485 prBssInfo->u2BSSBasicRateSet,
2486 prBssInfo->aucAllSupportedRates,
2487 &prBssInfo->ucAllSupportedRatesLen);
2488 }
2489 /* 4 <2> Setup BSSID */
2490 COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssInfo->aucOwnMacAddr);
2491
2492
2493 /* 4 <3> Setup Capability - Short Preamble */
2494 if (rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].fgIsShortPreambleOptionImplemented && ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
2495 (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO))) {
2496
2497 prBssInfo->fgIsShortPreambleAllowed = TRUE;
2498 prBssInfo->fgUseShortPreamble = TRUE;
2499 } else {
2500 prBssInfo->fgIsShortPreambleAllowed = FALSE;
2501 prBssInfo->fgUseShortPreamble = FALSE;
2502 }
2503
2504
2505 /* 4 <4> Setup Capability - Short Slot Time */
2506 prBssInfo->fgUseShortSlotTime = TRUE;
2507
2508 /* 4 <5> Compoase Capability */
2509 prBssInfo->u2CapInfo = CAP_INFO_ESS;
2510
2511 if (prBssInfo->fgIsProtection) {
2512 prBssInfo->u2CapInfo |= CAP_INFO_PRIVACY;
2513 }
2514
2515 if (prBssInfo->fgIsShortPreambleAllowed) {
2516 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
2517 }
2518
2519 if (prBssInfo->fgUseShortSlotTime) {
2520 prBssInfo->u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
2521 }
2522
2523 /* 4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
2524 rateGetLowestRateIndexFromRateSet(prBssInfo->u2BSSBasicRateSet, &ucLowestBasicRateIndex);
2525
2526 prBssInfo->ucHwDefaultFixedRateCode =
2527 aucRateIndex2RateCode[PREAMBLE_DEFAULT_LONG_NONE][ucLowestBasicRateIndex];
2528
2529
2530 /* 4 <7> Fill the EDCA */
2531
2532 prACQueParms = prBssInfo->arACQueParmsForBcast;
2533
2534 for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
2535
2536 prACQueParms[eAci].fgIsACMSet = FALSE;
2537 prACQueParms[eAci].u2Aifsn = auAifsForBcast[eAci];
2538 prACQueParms[eAci].u2CWmin = BIT(auCWminLog2ForBcast[eAci]) - 1;
2539 prACQueParms[eAci].u2CWmax = BIT(auCWmaxLog2ForBcast[eAci]) - 1;
2540 prACQueParms[eAci].u2TxopLimit = auTxopForBcast[eAci];
2541
2542 prBssInfo->aucCWminLog2ForBcast[eAci] = auCWminLog2ForBcast[eAci]; /* used to send WMM IE */
2543 prBssInfo->aucCWmaxLog2ForBcast[eAci] = auCWmaxLog2ForBcast[eAci];
2544
2545 DBGLOG(BSS, INFO,
2546 ("Bcast: eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
2547 eAci, prACQueParms[eAci].fgIsACMSet, prACQueParms[eAci].u2Aifsn,
2548 prACQueParms[eAci].u2CWmin, prACQueParms[eAci].u2CWmax,
2549 prACQueParms[eAci].u2TxopLimit));
2550
2551 }
2552
2553 prACQueParms = prBssInfo->arACQueParms;
2554
2555 for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
2556
2557 prACQueParms[eAci].fgIsACMSet = FALSE;
2558 prACQueParms[eAci].u2Aifsn = auAifs[eAci];
2559 prACQueParms[eAci].u2CWmin = BIT(auCWminLog2[eAci]) - 1;
2560 prACQueParms[eAci].u2CWmax = BIT(auCWmaxLog2[eAci]) - 1;
2561 prACQueParms[eAci].u2TxopLimit = auTxop[eAci];
2562
2563 DBGLOG(BSS, INFO,
2564 ("eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
2565 eAci, prACQueParms[eAci].fgIsACMSet, prACQueParms[eAci].u2Aifsn,
2566 prACQueParms[eAci].u2CWmin, prACQueParms[eAci].u2CWmax,
2567 prACQueParms[eAci].u2TxopLimit));
2568 }
2569
2570 /* Note: Caller should update the EDCA setting to HW by nicQmUpdateWmmParms() it there is no AIS network */
2571 /* Note: In E2, only 4 HW queues. The the Edca parameters should be folow by AIS network */
2572 /* Note: In E3, 8 HW queues. the Wmm parameters should be updated to right queues according to BSS */
2573
2574
2575 return;
2576 } /* end of bssInitForAP() */
2577
2578 #if 0
2579 /*----------------------------------------------------------------------------*/
2580 /*!
2581 * @brief Update DTIM Count
2582 *
2583 * @param[in] eNetTypeIndex Specify which network to update
2584 *
2585 * @return (none)
2586 */
2587 /*----------------------------------------------------------------------------*/
2588 VOID bssUpdateDTIMCount(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex)
2589 {
2590 P_BSS_INFO_T prBssInfo;
2591
2592
2593 ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
2594
2595 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
2596
2597 if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
2598
2599 /* Setup DTIM Count for next TBTT. */
2600 if (prBssInfo->ucDTIMCount > 0) {
2601 prBssInfo->ucDTIMCount--;
2602 } else {
2603
2604 ASSERT(prBssInfo->ucDTIMPeriod > 0);
2605
2606 prBssInfo->ucDTIMCount = prBssInfo->ucDTIMPeriod - 1;
2607 }
2608 }
2609
2610 return;
2611 } /* end of bssUpdateDTIMIE() */
2612
2613
2614 /*----------------------------------------------------------------------------*/
2615 /*!
2616 * @brief This function is used to set the Virtual Bitmap in TIM Information Elements
2617 *
2618 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
2619 * @param[in] u2AssocId The association id to set in Virtual Bitmap.
2620 *
2621 * @return (none)
2622 */
2623 /*----------------------------------------------------------------------------*/
2624 VOID bssSetTIMBitmap(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN UINT_16 u2AssocId)
2625 {
2626
2627 ASSERT(prBssInfo);
2628
2629 if (prBssInfo->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
2630 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
2631
2632
2633 prP2pSpecificBssInfo = &(prAdapter->rWifiVar.rP2pSpecificBssInfo);
2634
2635 /* Use Association ID == 0 for BMCAST indication */
2636 if (u2AssocId == 0) {
2637
2638 prP2pSpecificBssInfo->ucBitmapCtrl |= (UINT_8) BIT(0);
2639 } else {
2640 PUINT_8 pucPartialVirtualBitmap;
2641 UINT_8 ucBitmapToSet;
2642
2643
2644 pucPartialVirtualBitmap = &prP2pSpecificBssInfo->aucPartialVirtualBitmap[(u2AssocId >> 3)]; /* (u2AssocId / 8) */
2645 ucBitmapToSet = (UINT_8) BIT((u2AssocId % 8));
2646
2647 if (*pucPartialVirtualBitmap & ucBitmapToSet) {
2648 /* The virtual bitmap has been set */
2649 return;
2650 }
2651
2652 *pucPartialVirtualBitmap |= ucBitmapToSet;
2653
2654 /* Update u2SmallestAID and u2LargestAID */
2655 if ((u2AssocId < prP2pSpecificBssInfo->u2SmallestAID) ||
2656 (prP2pSpecificBssInfo->u2SmallestAID == 0)) {
2657 prP2pSpecificBssInfo->u2SmallestAID = u2AssocId;
2658 }
2659
2660 if ((u2AssocId > prP2pSpecificBssInfo->u2LargestAID) ||
2661 (prP2pSpecificBssInfo->u2LargestAID == 0)) {
2662 prP2pSpecificBssInfo->u2LargestAID = u2AssocId;
2663 }
2664 }
2665 }
2666
2667 return;
2668 } /* end of bssSetTIMBitmap() */
2669 #endif
2670
2671 #endif /* CFG_SUPPORT_AAA */
2672
2673
2674 VOID bssCreateStaRecFromAuth(IN P_ADAPTER_T prAdapter)
2675 {
2676
2677 }
2678
2679
2680 VOID bssUpdateStaRecFromAssocReq(IN P_ADAPTER_T prAdapter)
2681 {
2682
2683 }