blob: 9833e9169f0a035189e4a81d84d653ea2affab1f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Jeff Johnson295189b2012-06-20 16:38:30 -070041/**
42 * \file limSendManagementFrames.c
43 *
44 * \brief Code for preparing and sending 802.11 Management frames
45 *
46 * Copyright (C) 2005-2007 Airgo Networks, Incorporated
47 *
48 */
49
50#include "sirApi.h"
51#include "aniGlobal.h"
52#include "sirMacProtDef.h"
53#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
54#include "halDataStruct.h"
55#endif
56#include "cfgApi.h"
57#include "utilsApi.h"
58#include "limTypes.h"
59#include "limUtils.h"
60#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070061#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "dot11f.h"
63#include "limStaHashApi.h"
64#include "schApi.h"
65#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080066#include "limAssocUtils.h"
67#include "limFT.h"
68
Jeff Johnson295189b2012-06-20 16:38:30 -070069#if defined WLAN_FEATURE_VOWIFI
70#include "rrmApi.h"
71#endif
72
73#ifdef FEATURE_WLAN_CCX
74#include <limCcxparserApi.h>
75#endif
76#include "wlan_qct_wda.h"
77#ifdef WLAN_FEATURE_11W
78#include "dot11fdefs.h"
79#endif
80
81
82////////////////////////////////////////////////////////////////////////
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084
85/**
86 *
87 * \brief This function is called by various LIM modules to prepare the
88 * 802.11 frame MAC header
89 *
90 *
91 * \param pMac Pointer to Global MAC structure
92 *
93 * \param pBD Pointer to the frame buffer that needs to be populate
94 *
95 * \param type Type of the frame
96 *
97 * \param subType Subtype of the frame
98 *
99 * \return eHalStatus
100 *
101 *
102 * The pFrameBuf argument points to the beginning of the frame buffer to
103 * which - a) The 802.11 MAC header is set b) Following this MAC header
104 * will be the MGMT frame payload The payload itself is populated by the
105 * caller API
106 *
107 *
108 */
109
110tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
111 tANI_U8* pBD,
112 tANI_U8 type,
113 tANI_U8 subType,
114 tSirMacAddr peerAddr ,tSirMacAddr selfMacAddr)
115{
116 tSirRetStatus statusCode = eSIR_SUCCESS;
117 tpSirMacMgmtHdr pMacHdr;
118
119 /// Prepare MAC management header
120 pMacHdr = (tpSirMacMgmtHdr) (pBD);
121
122 // Prepare FC
123 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
124 pMacHdr->fc.type = type;
125 pMacHdr->fc.subType = subType;
126
127 // Prepare Address 1
128 palCopyMemory( pMac->hHdd,
129 (tANI_U8 *) pMacHdr->da,
130 (tANI_U8 *) peerAddr,
131 sizeof( tSirMacAddr ));
132
133 // Prepare Address 2
134 #if 0
135 if ((statusCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMacHdr->sa,
136 &cfgLen)) != eSIR_SUCCESS)
137 {
138 // Could not get STA_ID from CFG. Log error.
139 limLog( pMac, LOGP,
140 FL("Failed to retrive STA_ID\n"));
141 return statusCode;
142 }
143 #endif// TO SUPPORT BT-AMP
144 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
145
146 // Prepare Address 3
147 palCopyMemory( pMac->hHdd,
148 (tANI_U8 *) pMacHdr->bssId,
149 (tANI_U8 *) peerAddr,
150 sizeof( tSirMacAddr ));
151 return statusCode;
152} /*** end limPopulateMacHeader() ***/
153
154/**
155 * \brief limSendProbeReqMgmtFrame
156 *
157 *
158 * \param pMac Pointer to Global MAC structure
159 *
160 * \param pSsid SSID to be sent in Probe Request frame
161 *
162 * \param bssid BSSID to be sent in Probe Request frame
163 *
164 * \param nProbeDelay probe delay to be used before sending Probe Request
165 * frame
166 *
167 * \param nChannelNum Channel # on which the Probe Request is going out
168 *
169 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
170 *
171 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
172 *
173 * This function is called by various LIM modules to send Probe Request frame
174 * during active scan/learn phase.
175 * Probe request is sent out in the following scenarios:
176 * --heartbeat failure: session needed
177 * --join req: session needed
178 * --foreground scan: no session
179 * --background scan: no session
180 * --schBeaconProcessing: to get EDCA parameters: session needed
181 *
182 *
183 */
184tSirRetStatus
185limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
186 tSirMacSSid *pSsid,
187 tSirMacAddr bssid,
188 tANI_U8 nChannelNum,
189 tSirMacAddr SelfMacAddr,
190 tANI_U32 dot11mode,
191 tANI_U32 nAdditionalIELen,
192 tANI_U8 *pAdditionalIE)
193{
194 tDot11fProbeRequest pr;
195 tANI_U32 nStatus, nBytes, nPayload;
196 tSirRetStatus nSirStatus;
197 tANI_U8 *pFrame;
198 void *pPacket;
199 eHalStatus halstatus;
200 tpPESession psessionEntry;
201 tANI_U8 sessionId;
202#ifdef WLAN_FEATURE_P2P
203 tANI_U8 *p2pIe = NULL;
204#endif
205 tANI_U8 txFlag = 0;
206
207#ifndef GEN4_SCAN
208 return eSIR_FAILURE;
209#endif
210
211#if defined ( ANI_DVT_DEBUG )
212 return eSIR_FAILURE;
213#endif
214
215 /*
216 * session context may or may not be present, when probe request needs to be sent out.
217 * following cases exist:
218 * --heartbeat failure: session needed
219 * --join req: session needed
220 * --foreground scan: no session
221 * --background scan: no session
222 * --schBeaconProcessing: to get EDCA parameters: session needed
223 * If session context does not exist, some IEs will be populated from CFGs,
224 * e.g. Supported and Extended rate set IEs
225 */
226 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
227
228 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
229 // and then hand it off to 'dot11fPackProbeRequest' (for
230 // serialization). We start by zero-initializing the structure:
231 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
232
233 // & delegating to assorted helpers:
234 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
235
236#ifdef WLAN_FEATURE_P2P
237 if( nAdditionalIELen && pAdditionalIE )
238 {
239 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
240 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700241 /* Don't include 11b rate only when device is doing P2P Search */
242 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
243 ( p2pIe != NULL ) &&
244 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
245 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
246 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
247 ( ( psessionEntry != NULL ) &&
248 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
249 )
250 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 {
252 /* In the below API pass channel number > 14, do that it fills only
253 * 11a rates in supported rates */
254 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
255 }
256 else
257 {
258#endif
259 PopulateDot11fSuppRates( pMac, nChannelNum,
260 &pr.SuppRates,psessionEntry);
261
262 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
263 {
264 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
265 }
266#ifdef WLAN_FEATURE_P2P
267 }
268#endif
269
270#if defined WLAN_FEATURE_VOWIFI
271 //Table 7-14 in IEEE Std. 802.11k-2008 says
272 //DS params "can" be present in RRM is disabled and "is" present if
273 //RRM is enabled. It should be ok even if we add it into probe req when
274 //RRM is not enabled.
275 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
276 //Call RRM module to get the tx power for management used.
277 {
278 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
279 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
280 }
281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700282
283 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700284 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700286 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700288 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700290 } else { //psessionEntry == NULL
291 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700293 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 }
295 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800296
297 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
298 if( nChannelNum <= SIR_11B_CHANNEL_END)
299 {
300 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
301 pr.HTCaps.shortGI40MHz = 0;
302 }
303
Jeff Johnsone7245742012-09-05 17:12:55 -0700304#ifdef WLAN_FEATURE_11AC
305 if (psessionEntry != NULL ) {
306 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
307 //Include HT Capability IE
308 if (psessionEntry->vhtCapability)
309 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700310 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
311 }
312 } else {
313 if (IS_DOT11_MODE_VHT(dot11mode))
314 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700315 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
316 }
317 }
318#endif
319
Jeff Johnson295189b2012-06-20 16:38:30 -0700320
321 // That's it-- now we pack it. First, how much space are we going to
322 // need?
323 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
324 if ( DOT11F_FAILED( nStatus ) )
325 {
326 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
327 "or a Probe Request (0x%08x).\n"), nStatus );
328 // We'll fall back on the worst case scenario:
329 nPayload = sizeof( tDot11fProbeRequest );
330 }
331 else if ( DOT11F_WARNED( nStatus ) )
332 {
333 limLog( pMac, LOGW, FL("There were warnings while calculating"
334 "the packed size for a Probe Request ("
335 "0x%08x).\n"), nStatus );
336 }
337
338 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
339
340 // Ok-- try to allocate some memory:
341 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
342 ( tANI_U16 )nBytes, ( void** ) &pFrame,
343 ( void** ) &pPacket );
344 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
345 {
346 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
347 "be Request.\n"), nBytes );
348 return eSIR_MEM_ALLOC_FAILED;
349 }
350
351 // Paranoia:
352 palZeroMemory( pMac->hHdd, pFrame, nBytes );
353
354 // Next, we fill out the buffer descriptor:
355 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
356 SIR_MAC_MGMT_PROBE_REQ, bssid ,SelfMacAddr);
357 if ( eSIR_SUCCESS != nSirStatus )
358 {
359 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
360 "tor for a Probe Request (%d).\n"),
361 nSirStatus );
362 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
363 ( void* ) pFrame, ( void* ) pPacket );
364 return nSirStatus; // allocated!
365 }
366
367 // That done, pack the Probe Request:
368 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
369 sizeof( tSirMacMgmtHdr ),
370 nPayload, &nPayload );
371 if ( DOT11F_FAILED( nStatus ) )
372 {
373 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x).\n"),
374 nStatus );
375 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
376 return eSIR_FAILURE; // allocated!
377 }
378 else if ( DOT11F_WARNED( nStatus ) )
379 {
380 limLog( pMac, LOGW, FL("There were warnings while packing a P"
381 "robe Request (0x%08x).\n") );
382 }
383
384 // Append any AddIE if present.
385 if( nAdditionalIELen )
386 {
387 palCopyMemory( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
388 pAdditionalIE, nAdditionalIELen );
389 nPayload += nAdditionalIELen;
390 }
391
392 /* If this probe request is sent during P2P Search State, then we need
393 * to send it at OFDM rate.
394 */
395 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
396#ifdef WLAN_FEATURE_P2P
397 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
398 pMac->lim.gpLimMlmScanReq->p2pSearch )
399#endif
400 )
401 {
402 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
403 }
404
405
406 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
407 HAL_TXRX_FRM_802_11_MGMT,
408 ANI_TXDIR_TODS,
409 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
410 limTxComplete, pFrame, txFlag );
411 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
412 {
413 limLog( pMac, LOGE, FL("could not send Probe Request frame!\n" ));
414 //Pkt will be freed up by the callback
415 return eSIR_FAILURE;
416 }
417
418 return eSIR_SUCCESS;
419} // End limSendProbeReqMgmtFrame.
420
421#ifdef WLAN_FEATURE_P2P
422tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
423 tANI_U8* addIE, tANI_U16 *addnIELen,
424 tANI_U8 probeReqP2pIe)
425{
426 /* If Probe request doesn't have P2P IE, then take out P2P IE
427 from additional IE */
428 if(!probeReqP2pIe)
429 {
430 tANI_U8* tempbuf = NULL;
431 tANI_U16 tempLen = 0;
432 int left = *addnIELen;
433 v_U8_t *ptr = addIE;
434 v_U8_t elem_id, elem_len;
435
436 if(NULL == addIE)
437 {
438 PELOGE(limLog(pMac, LOGE,
439 FL(" NULL addIE pointer"));)
440 return eSIR_FAILURE;
441 }
442
443 if( (palAllocateMemory(pMac->hHdd, (void**)&tempbuf,
Jeff Johnson43971f52012-07-17 12:26:56 -0700444 left)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 {
446 PELOGE(limLog(pMac, LOGE,
447 FL("Unable to allocate memory to store addn IE"));)
448 return eSIR_MEM_ALLOC_FAILED;
449 }
450
451 while(left >= 2)
452 {
453 elem_id = ptr[0];
454 elem_len = ptr[1];
455 left -= 2;
456 if(elem_len > left)
457 {
458 limLog( pMac, LOGE,
459 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
460 elem_id,elem_len,left);
461 palFreeMemory(pMac->hHdd, tempbuf);
462 return eSIR_FAILURE;
463 }
464 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
465 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
466 {
467 palCopyMemory ( pMac->hHdd, tempbuf + tempLen, &ptr[0], elem_len + 2);
468 tempLen += (elem_len + 2);
469 }
470 left -= elem_len;
471 ptr += (elem_len + 2);
472 }
473 palCopyMemory ( pMac->hHdd, addIE, tempbuf, tempLen);
474 *addnIELen = tempLen;
475 palFreeMemory(pMac->hHdd, tempbuf);
476 }
477 return eSIR_SUCCESS;
478}
479#endif
480
481void
482limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
483 tSirMacAddr peerMacAddr,
484 tpAniSSID pSsid,
485 short nStaId,
486 tANI_U8 nKeepAlive,
487 tpPESession psessionEntry,
488 tANI_U8 probeReqP2pIe)
489{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700490 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 tSirRetStatus nSirStatus;
492 tANI_U32 cfg, nPayload, nBytes, nStatus;
493 tpSirMacMgmtHdr pMacHdr;
494 tANI_U8 *pFrame;
495 void *pPacket;
496 eHalStatus halstatus;
497 tANI_U32 addnIEPresent;
498 tANI_U32 addnIE1Len=0;
499 tANI_U32 addnIE2Len=0;
500 tANI_U32 addnIE3Len=0;
501 tANI_U16 totalAddnIeLen = 0;
502 tANI_U32 wpsApEnable=0, tmp;
503 tANI_U8 txFlag = 0;
504 tANI_U8 *addIE = NULL;
505#ifdef WLAN_FEATURE_P2P
506 tANI_U8 *pP2pIe = NULL;
507 tANI_U8 noaLen = 0;
508 tANI_U8 total_noaLen = 0;
509 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
510 + SIR_P2P_IE_HEADER_LEN];
511 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
512#endif
513
514 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
515 {
516 return; // in this case.
517 }
518
519 if(NULL == psessionEntry)
520 {
521 return;
522 }
523
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700524 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
525 (void **)&pFrm, sizeof(tDot11fProbeResponse)))
526 {
527 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendProbeRspMgmtFrame\n") );
528 return;
529 }
530
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 // Fill out 'frm', after which we'll just hand the struct off to
532 // 'dot11fPackProbeResponse'.
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700533 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700534
535 // Timestamp to be updated by TFP, below.
536
537 // Beacon Interval:
538#ifdef WLAN_SOFTAP_FEATURE
539 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
540 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700541 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 }
543 else
544 {
545#endif
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800546 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
547 if (eSIR_SUCCESS != nSirStatus)
548 {
549 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d).\n"),
550 nSirStatus );
551 return;
552 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700553 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -0700554#ifdef WLAN_SOFTAP_FEATURE
555 }
556#endif
557
558
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700559 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
560 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700562 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700564 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
565 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
567#ifdef ANI_PRODUCT_TYPE_AP
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700568 PopulateDot11fCFParams( pMac, &pFrm->Capabilities, &pFrm->CFParams );
Jeff Johnson295189b2012-06-20 16:38:30 -0700569#endif // AP Image
570
571#ifdef WLAN_SOFTAP_FEATURE
572 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
573 {
574 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
575 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700576 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 }
578 }
579 else
580 {
581#endif
582 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
583 limLog(pMac, LOGP,"Failed to cfg get id %d\n", WNI_CFG_WPS_ENABLE );
584
585 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
586
587 if (wpsApEnable)
588 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700589 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 }
591
592 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
593 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700594 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
596 }
597
598 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
599 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700600 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
602 }
603#ifdef WLAN_SOFTAP_FEATURE
604 }
605#endif
606
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700607 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
608 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700609
610#ifdef ANI_PRODUCT_TYPE_AP
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 if( pSessionEntry->lim11hEnable )
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700613 PopulateDot11fPowerConstraints( pMac, &pFrm->PowerConstraints );
614 PopulateDot11fTPCReport( pMac, &pFrm->TPCReport, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
616 // If .11h isenabled & channel switching is not already started and
617 // we're in either PRIMARY_ONLY or PRIMARY_AND_SECONDARY state, then
618 // populate 802.11h channel switch IE
619 if (( pMac->lim.gLimChannelSwitch.switchCount != 0 ) &&
620 ( pMac->lim.gLimChannelSwitch.state ==
621 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY ||
622 pMac->lim.gLimChannelSwitch.state ==
623 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY ) )
624 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700625 PopulateDot11fChanSwitchAnn( pMac, &pFrm->ChanSwitchAnn, psessionEntry );
626 PopulateDot11fExtChanSwitchAnn(pMac, &pFrm->ExtChanSwitchAnn, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 }
628 }
629#endif
630
631 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700632 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700633
634
635 // N.B. In earlier implementations, the RSN IE would be placed in
636 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
637 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700638 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700639
640 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700641 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700643 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700644#ifdef WLAN_SOFTAP_FEATURE
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700645 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700646#else
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700647 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -0700648#endif
649 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700650#ifdef WLAN_FEATURE_11AC
651 if(psessionEntry->vhtCapability)
652 {
653 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response\n"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700654 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
655 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700656 // we do not support multi users yet
657 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700658 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700659 }
660#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700661
662 if ( psessionEntry->pLimStartBssReq )
663 {
664 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700665 &pFrm->WPA );
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 PopulateDot11fRSN( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 &pFrm->RSN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 }
669
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700670 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700671
672#if defined(FEATURE_WLAN_WAPI)
673 if( psessionEntry->pLimStartBssReq )
674 {
675 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700676 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678
679#endif // defined(FEATURE_WLAN_WAPI)
680
681
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 if ( DOT11F_FAILED( nStatus ) )
684 {
685 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
686 "or a Probe Response (0x%08x).\n"),
687 nStatus );
688 // We'll fall back on the worst case scenario:
689 nPayload = sizeof( tDot11fProbeResponse );
690 }
691 else if ( DOT11F_WARNED( nStatus ) )
692 {
693 limLog( pMac, LOGW, FL("There were warnings while calculating"
694 "the packed size for a Probe Response "
695 "(0x%08x).\n"), nStatus );
696 }
697
698 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
699
700 addnIEPresent = false;
701
702#ifdef WLAN_FEATURE_P2P
703 if( pMac->lim.gpLimRemainOnChanReq )
704 {
705 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
706 }
707 //Only use CFG for non-listen mode. This CFG is not working for concurrency
708 //In listening mode, probe rsp IEs is passed in the message from SME to PE
709 else
710#endif
711 {
712
713 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
714 &addnIEPresent) != eSIR_SUCCESS)
715 {
716 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700717 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 return;
719 }
720 }
721
722 if (addnIEPresent)
723 {
724 if( (palAllocateMemory(pMac->hHdd, (void**)&addIE,
Jeff Johnson43971f52012-07-17 12:26:56 -0700725 WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3 )) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 {
727 PELOGE(limLog(pMac, LOGE,
728 FL("Unable to allocate memory to store addn IE"));)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700729 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 return;
731 }
732
733 //Probe rsp IE available
734 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
735 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
736 {
737 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
738 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700739 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 return;
741 }
742 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
743 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
744 {
745 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
746 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
747 &addnIE1Len) )
748 {
749 limLog(pMac, LOGP,
750 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
751 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700752 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 return;
754 }
755 }
756
757 //Probe rsp IE available
758 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
759 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
760 {
761 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
762 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700763 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 return;
765 }
766 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
767 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
768 {
769 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
770 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
771 &addnIE2Len) )
772 {
773 limLog(pMac, LOGP,
774 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
775 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700776 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 return;
778 }
779 }
780
781 //Probe rsp IE available
782 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
783 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
784 {
785 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
786 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700787 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 return;
789 }
790 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
791 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
792 {
793 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
794 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
795 &addIE[addnIE1Len + addnIE2Len],
796 &addnIE3Len) )
797 {
798 limLog(pMac, LOGP,
799 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
800 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700801 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 return;
803 }
804 }
805 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
806
807#ifdef WLAN_FEATURE_P2P
808 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
809 {
810 limLog(pMac, LOGP,
811 FL("Unable to get final Additional IE for Probe Req"));
812 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700813 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 return;
815 }
816 nBytes = nBytes + totalAddnIeLen;
817
818 if (probeReqP2pIe)
819 {
820 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
821 if (pP2pIe != NULL)
822 {
823 //get NoA attribute stream P2P IE
824 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
825 if (noaLen != 0)
826 {
827 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
828 &noaStream[0], noaLen);
829 nBytes = nBytes + total_noaLen;
830 }
831 }
832 }
833#endif
834 }
835
836 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
837 ( tANI_U16 )nBytes, ( void** ) &pFrame,
838 ( void** ) &pPacket );
839 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
840 {
841 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
842 "be Response.\n"), nBytes );
843 if ( addIE != NULL )
844 {
845 palFreeMemory(pMac->hHdd, addIE);
846 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700847 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 return;
849 }
850
851 // Paranoia:
852 palZeroMemory( pMac->hHdd, pFrame, nBytes );
853
854 // Next, we fill out the buffer descriptor:
855 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
856 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
857 if ( eSIR_SUCCESS != nSirStatus )
858 {
859 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
860 "tor for a Probe Response (%d).\n"),
861 nSirStatus );
862 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
863 ( void* ) pFrame, ( void* ) pPacket );
864 if ( addIE != NULL )
865 {
866 palFreeMemory(pMac->hHdd, addIE);
867 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700868 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 return;
870 }
871
872 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
873
874 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
875
876 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700877 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 nPayload, &nPayload );
879 if ( DOT11F_FAILED( nStatus ) )
880 {
881 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x).\n"),
882 nStatus );
883 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
884 if ( addIE != NULL )
885 {
886 palFreeMemory(pMac->hHdd, addIE);
887 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700888 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 return; // allocated!
890 }
891 else if ( DOT11F_WARNED( nStatus ) )
892 {
893 limLog( pMac, LOGW, FL("There were warnings while packing a P"
894 "robe Response (0x%08x).\n") );
895 }
896
897 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
898 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
899
900 pMac->sys.probeRespond++;
901
902#ifdef WLAN_FEATURE_P2P
903 if( pMac->lim.gpLimRemainOnChanReq )
904 {
905 palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
906 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
907 }
908#endif
909
910 if ( addnIEPresent )
911 {
912 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -0700913 &addIE[0], totalAddnIeLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 {
915 limLog(pMac, LOGP, FL("Additional Probe Rp IE request failed while Appending: %x"),halstatus);
916 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
917 ( void* ) pFrame, ( void* ) pPacket );
918 if ( addIE != NULL )
919 {
920 palFreeMemory(pMac->hHdd, addIE);
921 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700922 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 return;
924 }
925 }
926#ifdef WLAN_FEATURE_P2P
927 if (noaLen != 0)
928 {
929 if (palCopyMemory ( pMac->hHdd, &pFrame[nBytes - (total_noaLen)],
Jeff Johnson43971f52012-07-17 12:26:56 -0700930 &noaIe[0], total_noaLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 {
932 limLog(pMac, LOGE,
933 FL("Not able to insert NoA because of length constraint"));
934 }
935 }
936#endif
937
938 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
939#ifdef WLAN_FEATURE_P2P
940 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
941 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
942#endif
943 )
944 {
945 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
946 }
947
948 // Queue Probe Response frame in high priority WQ
949 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
950 ( tANI_U16 ) nBytes,
951 HAL_TXRX_FRM_802_11_MGMT,
952 ANI_TXDIR_TODS,
953 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
954 limTxComplete, pFrame, txFlag );
955 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
956 {
957 limLog( pMac, LOGE, FL("Could not send Probe Response.\n") );
958 //Pkt will be freed up by the callback
959 }
960
961 if ( addIE != NULL )
962 {
963 palFreeMemory(pMac->hHdd, addIE);
964 }
965
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700966 palFreeMemory(pMac->hHdd, pFrm);
967 return;
968
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970} // End limSendProbeRspMgmtFrame.
971
972void
973limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
974 tSirMacAddr peerMacAddr,
975 tSirAddtsReqInfo *pAddTS,
976 tpPESession psessionEntry)
977{
978 tANI_U16 i;
979 tANI_U8 *pFrame;
980 tSirRetStatus nSirStatus;
981 tDot11fAddTSRequest AddTSReq;
982 tDot11fWMMAddTSRequest WMMAddTSReq;
983 tANI_U32 nPayload, nBytes, nStatus;
984 tpSirMacMgmtHdr pMacHdr;
985 void *pPacket;
986#ifdef FEATURE_WLAN_CCX
987 tANI_U32 phyMode;
988#endif
989 eHalStatus halstatus;
990 tANI_U8 txFlag = 0;
991
992 if(NULL == psessionEntry)
993 {
994 return;
995 }
996
997 if ( ! pAddTS->wmeTspecPresent )
998 {
999 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSReq, sizeof( AddTSReq ) );
1000
1001 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1002 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1003 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1004 if ( pAddTS->lleTspecPresent )
1005 {
1006 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1007 }
1008 else
1009 {
1010 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1011 }
1012
1013 if ( pAddTS->lleTspecPresent )
1014 {
1015 AddTSReq.num_WMMTCLAS = 0;
1016 AddTSReq.num_TCLAS = pAddTS->numTclas;
1017 for ( i = 0; i < pAddTS->numTclas; ++i)
1018 {
1019 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1020 &AddTSReq.TCLAS[i] );
1021 }
1022 }
1023 else
1024 {
1025 AddTSReq.num_TCLAS = 0;
1026 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1027 for ( i = 0; i < pAddTS->numTclas; ++i)
1028 {
1029 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1030 &AddTSReq.WMMTCLAS[i] );
1031 }
1032 }
1033
1034 if ( pAddTS->tclasProcPresent )
1035 {
1036 if ( pAddTS->lleTspecPresent )
1037 {
1038 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1039 AddTSReq.TCLASSPROC.present = 1;
1040 }
1041 else
1042 {
1043 AddTSReq.WMMTCLASPROC.version = 1;
1044 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1045 AddTSReq.WMMTCLASPROC.present = 1;
1046 }
1047 }
1048
1049 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1050 if ( DOT11F_FAILED( nStatus ) )
1051 {
1052 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1053 "or an Add TS Request (0x%08x).\n"),
1054 nStatus );
1055 // We'll fall back on the worst case scenario:
1056 nPayload = sizeof( tDot11fAddTSRequest );
1057 }
1058 else if ( DOT11F_WARNED( nStatus ) )
1059 {
1060 limLog( pMac, LOGW, FL("There were warnings while calculating"
1061 "the packed size for an Add TS Request"
1062 " (0x%08x).\n"), nStatus );
1063 }
1064 }
1065 else
1066 {
1067 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ) );
1068
1069 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1070 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1071 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1072
1073 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1074 WMMAddTSReq.StatusCode.statusCode = 0;
1075
1076 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1077#ifdef FEATURE_WLAN_CCX
1078 limGetPhyMode(pMac, &phyMode, psessionEntry);
1079
1080 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1081 {
1082 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1083 }
1084 else
1085 {
1086 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1087 }
1088 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1089#endif
1090 // fillWmeTspecIE
1091
1092 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1093 if ( DOT11F_FAILED( nStatus ) )
1094 {
1095 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1096 "or a WMM Add TS Request (0x%08x).\n"),
1097 nStatus );
1098 // We'll fall back on the worst case scenario:
1099 nPayload = sizeof( tDot11fAddTSRequest );
1100 }
1101 else if ( DOT11F_WARNED( nStatus ) )
1102 {
1103 limLog( pMac, LOGW, FL("There were warnings while calculating"
1104 "the packed size for a WMM Add TS Requ"
1105 "est (0x%08x).\n"), nStatus );
1106 }
1107 }
1108
1109 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1110
1111 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1112 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1113 ( void** ) &pPacket );
1114 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1115 {
1116 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1117 "d TS Request.\n"), nBytes );
1118 return;
1119 }
1120
1121 // Paranoia:
1122 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1123
1124 // Next, we fill out the buffer descriptor:
1125 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1126 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1127 if ( eSIR_SUCCESS != nSirStatus )
1128 {
1129 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1130 "tor for an Add TS Request (%d).\n"),
1131 nSirStatus );
1132 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1133 ( void* ) pFrame, ( void* ) pPacket );
1134 return;
1135 }
1136
1137 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1138
1139 #if 0
1140 cfgLen = SIR_MAC_ADDR_LENGTH;
1141 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1142 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1143 {
1144 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1145 "e sending an Add TS Request.\n") );
1146 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1147 ( void* ) pFrame, ( void* ) pPacket );
1148 return;
1149 }
1150 #endif //TO SUPPORT BT-AMP
1151
1152 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1153
1154 // That done, pack the struct:
1155 if ( ! pAddTS->wmeTspecPresent )
1156 {
1157 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1158 pFrame + sizeof(tSirMacMgmtHdr),
1159 nPayload, &nPayload );
1160 if ( DOT11F_FAILED( nStatus ) )
1161 {
1162 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
1163 "(0x%08x).\n"),
1164 nStatus );
1165 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1166 return; // allocated!
1167 }
1168 else if ( DOT11F_WARNED( nStatus ) )
1169 {
1170 limLog( pMac, LOGW, FL("There were warnings while packing"
1171 "an Add TS Request (0x%08x).\n") );
1172 }
1173 }
1174 else
1175 {
1176 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1177 pFrame + sizeof(tSirMacMgmtHdr),
1178 nPayload, &nPayload );
1179 if ( DOT11F_FAILED( nStatus ) )
1180 {
1181 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
1182 "st (0x%08x).\n"),
1183 nStatus );
1184 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1185 return; // allocated!
1186 }
1187 else if ( DOT11F_WARNED( nStatus ) )
1188 {
1189 limLog( pMac, LOGW, FL("There were warnings while packing"
1190 "a WMM Add TS Request (0x%08x).\n") );
1191 }
1192 }
1193
1194 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1195 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1196
1197 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
1198#ifdef WLAN_FEATURE_P2P
1199 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1200 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
1201#endif
1202 )
1203 {
1204 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1205 }
1206
1207 // Queue Addts Response frame in high priority WQ
1208 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1209 HAL_TXRX_FRM_802_11_MGMT,
1210 ANI_TXDIR_TODS,
1211 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1212 limTxComplete, pFrame, txFlag );
1213 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1214 {
1215 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
1216 " (%X) ***\n" ), halstatus );
1217 //Pkt will be freed up by the callback
1218 }
1219
1220} // End limSendAddtsReqActionFrame.
1221
1222/* Added ANI_PRODUCT_TYPE_CLIENT for BT-AMP Support */
1223#ifdef ANI_PRODUCT_TYPE_AP
1224
1225void
1226limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1227 tANI_U16 statusCode,
1228 tANI_U16 aid,
1229 tSirMacAddr peerMacAddr,
1230 tANI_U8 subType,
1231 tpDphHashNode pSta,
1232 tpPESession psessionEntry)
1233{
1234 tDot11fAssocResponse frm;
1235 tANI_U8 *pFrame, *macAddr;
1236 tpSirMacMgmtHdr pMacHdr;
1237 tSirRetStatus nSirStatus;
1238 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1239 tHalBitVal qosMode, wmeMode;
1240 tANI_U32 nPayload, nBytes, nStatus, cfgLen;
1241 void *pPacket;
1242 eHalStatus halstatus;
1243 tUpdateBeaconParams beaconParams;
1244 tANI_U32 wpsApEnable=0, tmp;
1245 tANI_U8 txFlag = 0;
1246
1247 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
1248
1249 limGetQosMode(pMac, &qosMode);
1250 limGetWmeMode(pMac, &wmeMode);
1251
1252 // An Add TS IE is added only if the AP supports it and the requesting
1253 // STA sent a traffic spec.
1254 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1255
1256 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry);
1257
1258 frm.Status.status = statusCode;
1259
1260 frm.AID.associd = aid | LIM_AID_MASK;
1261
1262 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates );
1263
1264 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
1265 limLog(pMac, LOGP,"Failed to cfg get id %d\n", WNI_CFG_WPS_ENABLE );
1266
1267 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
1268
1269 if (wpsApEnable)
1270 {
1271 PopulateDot11fWscInAssocRes(pMac, &frm.WscAssocRes);
1272 }
1273
1274 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1275 &frm.ExtSuppRates, psessionEntry );
1276
1277 if ( NULL != pSta )
1278 {
1279 if ( eHAL_SET == qosMode )
1280 {
1281 if ( pSta->lleEnabled )
1282 {
1283 lleMode = 1;
1284 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1285 {
1286 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1287
1288// FramesToDo:...
1289// if ( fAddTS )
1290// {
1291// tANI_U8 *pAf = pBody;
1292// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1293// tANI_U32 tlen;
1294// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1295// &tlen, bufLen - frameLen);
1296// } // End if on Add TS.
1297 }
1298 } // End if on .11e enabled in 'pSta'.
1299 } // End if on QOS Mode on.
1300
1301 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1302 {
1303 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1304 {
1305 PopulateDot11fWMMParams( pMac, &frm.WMMParams );
1306
1307 if ( pSta->wsmEnabled )
1308 {
1309 PopulateDot11fWMMCaps(&frm.WMMCaps );
1310 }
1311 }
1312 }
1313
1314 if ( pSta->aniPeer )
1315 {
1316 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1317 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1318 {
1319 edcaInclude = 1;
1320 }
1321
1322 } // End if on Airgo peer.
1323
1324 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001325 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001327 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
1328 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 }
1330 } // End if on non-NULL 'pSta'.
1331
1332
1333 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1334 limDecideApProtection(pMac, peerMacAddr, &beaconParams);
1335 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams);
1336 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams);
1337
1338 //Send message to HAL about beacon parameter change.
1339 if(beaconParams.paramChangeBitmap)
1340 {
1341 schSetFixedBeaconFields(pMac,psessionEntry);
1342 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1343 }
1344
1345 // Allocate a buffer for this frame:
1346 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1347 if ( DOT11F_FAILED( nStatus ) )
1348 {
1349 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1350 "or an Association Response (0x%08x).\n"),
1351 nStatus );
1352 return;
1353 }
1354 else if ( DOT11F_WARNED( nStatus ) )
1355 {
1356 limLog( pMac, LOGW, FL("There were warnings while calculating"
1357 "the packed size for an Association Re"
1358 "sponse (0x%08x).\n"), nStatus );
1359 }
1360
1361 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1362
1363 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1364 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1365 ( void** ) &pPacket );
1366 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1367 {
1368 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP.\n"));
1369 return;
1370 }
1371
1372 // Paranoia:
1373 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1374
1375 // Next, we fill out the buffer descriptor:
1376 nSirStatus = limPopulateMacHeader( pMac,
1377 pFrame,
1378 SIR_MAC_MGMT_FRAME,
1379 ( LIM_ASSOC == subType ) ?
1380 SIR_MAC_MGMT_ASSOC_RSP :
1381 SIR_MAC_MGMT_REASSOC_RSP,
1382 peerMacAddr);
1383 if ( eSIR_SUCCESS != nSirStatus )
1384 {
1385 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1386 "tor for an Association Response (%d).\n"),
1387 nSirStatus );
1388 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1389 ( void* ) pFrame, ( void* ) pPacket );
1390 return;
1391 }
1392
1393 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1394
1395
1396 cfgLen = SIR_MAC_ADDR_LENGTH;
1397 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1398 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1399 {
1400 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1401 "e sending an Association Response.\n") );
1402 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1403 return; // allocated!
1404 }
1405
1406 nStatus = dot11fPackAssocResponse( pMac, &frm,
1407 pFrame + sizeof( tSirMacMgmtHdr ),
1408 nPayload, &nPayload );
1409 if ( DOT11F_FAILED( nStatus ) )
1410 {
1411 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x).\n"),
1412 nStatus );
1413 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1414 ( void* ) pFrame, ( void* ) pPacket );
1415 return; // allocated!
1416 }
1417 else if ( DOT11F_WARNED( nStatus ) )
1418 {
1419 limLog( pMac, LOGW, FL("There were warnings while packing an "
1420 "Association Response (0x%08x).\n") );
1421 }
1422
1423 macAddr = pMacHdr->da;
1424
1425 if (subType == LIM_ASSOC)
1426 limLog(pMac, LOG1,
1427 FL("*** Sending Assoc Resp status %d aid %d to "),
1428 statusCode, aid);
1429 else
1430 limLog(pMac, LOG1,
1431 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1432 statusCode, aid);
1433 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
1434
1435 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
1436#ifdef WLAN_FEATURE_P2P
1437 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1438 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
1439#endif
1440 )
1441 {
1442 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1443 }
1444
1445 /// Queue Association Response frame in high priority WQ
1446 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1447 HAL_TXRX_FRM_802_11_MGMT,
1448 ANI_TXDIR_TODS,
1449 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1450 limTxComplete, pFrame, txFlag );
1451 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1452 {
1453 limLog(pMac, LOGE,
1454 FL("*** Could not Send Re/AssocRsp, retCode=%X ***\n"),
1455 nSirStatus);
1456
1457 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1458 (void *) pFrame, (void *) pPacket );
1459 }
1460
1461 // update the ANI peer station count
1462 //FIXME_PROTECTION : take care of different type of station
1463 // counter inside this function.
1464 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1465
1466} // End limSendAssocRspMgmtFrame.
1467
1468
1469#endif // ANI_PRODUCT_TYPE_AP
1470
1471
1472void
1473limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1474 tANI_U16 statusCode,
1475 tANI_U16 aid,
1476 tSirMacAddr peerMacAddr,
1477 tANI_U8 subType,
1478 tpDphHashNode pSta,tpPESession psessionEntry)
1479{
1480 static tDot11fAssocResponse frm;
1481 tANI_U8 *pFrame, *macAddr;
1482 tpSirMacMgmtHdr pMacHdr;
1483 tSirRetStatus nSirStatus;
1484 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1485 tHalBitVal qosMode, wmeMode;
1486 tANI_U32 nPayload, nBytes, nStatus;
1487 void *pPacket;
1488 eHalStatus halstatus;
1489 tUpdateBeaconParams beaconParams;
1490 tANI_U8 txFlag = 0;
1491 tANI_U32 addnIEPresent = false;
1492 tANI_U32 addnIELen=0;
1493 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1494 tpSirAssocReq pAssocReq = NULL;
1495
1496 if(NULL == psessionEntry)
1497 {
1498 return;
1499 }
1500
1501 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
1502
1503 limGetQosMode(psessionEntry, &qosMode);
1504 limGetWmeMode(psessionEntry, &wmeMode);
1505
1506 // An Add TS IE is added only if the AP supports it and the requesting
1507 // STA sent a traffic spec.
1508 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1509
1510 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1511
1512 frm.Status.status = statusCode;
1513
1514 frm.AID.associd = aid | LIM_AID_MASK;
1515
1516 if ( NULL == pSta )
1517 {
1518 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1519 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1520 }
1521 else
1522 {
1523 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1524 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1525 }
1526
1527#ifdef WLAN_SOFTAP_FEATURE
1528 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1529 {
1530 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1531 {
1532 pAssocReq =
1533 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
1534#ifdef WLAN_FEATURE_P2P
1535 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1536 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1537 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1538 }
1539#endif
1540 }
1541 }
1542#endif
1543
1544 if ( NULL != pSta )
1545 {
1546 if ( eHAL_SET == qosMode )
1547 {
1548 if ( pSta->lleEnabled )
1549 {
1550 lleMode = 1;
1551 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1552 {
1553 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1554
1555// FramesToDo:...
1556// if ( fAddTS )
1557// {
1558// tANI_U8 *pAf = pBody;
1559// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1560// tANI_U32 tlen;
1561// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1562// &tlen, bufLen - frameLen);
1563// } // End if on Add TS.
1564 }
1565 } // End if on .11e enabled in 'pSta'.
1566 } // End if on QOS Mode on.
1567
1568 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1569 {
1570 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1571 {
1572
1573#ifdef WLAN_SOFTAP_FEATURE
1574 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
1575#else
1576 PopulateDot11fWMMParams( pMac, &frm.WMMParams );
1577#endif
1578
1579 if ( pSta->wsmEnabled )
1580 {
1581 PopulateDot11fWMMCaps(&frm.WMMCaps );
1582 }
1583 }
1584 }
1585
1586 if ( pSta->aniPeer )
1587 {
1588 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1589 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1590 {
1591 edcaInclude = 1;
1592 }
1593
1594 } // End if on Airgo peer.
1595
1596 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001597 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001599 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001600#ifdef WLAN_SOFTAP_FEATURE
1601 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
1602#else
1603 PopulateDot11fHTInfo( pMac, &frm.HTInfo );
1604#endif
1605 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001606
1607#ifdef WLAN_FEATURE_11AC
1608 if( pSta->mlmStaContext.vhtCapability &&
1609 psessionEntry->vhtCapability )
1610 {
1611 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response\n"));
1612 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1613 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001614 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001615 }
1616#endif
1617
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 } // End if on non-NULL 'pSta'.
1619
1620
1621 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1622
1623#ifdef WLAN_SOFTAP_FEATURE
1624 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1625 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1626 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1627 }
1628#endif
1629
1630 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1631 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1632
1633 beaconParams.bssIdx = psessionEntry->bssIdx;
1634
1635 //Send message to HAL about beacon parameter change.
1636 if(beaconParams.paramChangeBitmap)
1637 {
1638 schSetFixedBeaconFields(pMac,psessionEntry);
1639 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1640 }
1641
1642 // Allocate a buffer for this frame:
1643 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1644 if ( DOT11F_FAILED( nStatus ) )
1645 {
1646 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1647 "or an Association Response (0x%08x).\n"),
1648 nStatus );
1649 return;
1650 }
1651 else if ( DOT11F_WARNED( nStatus ) )
1652 {
1653 limLog( pMac, LOGW, FL("There were warnings while calculating"
1654 "the packed size for an Association Re"
1655 "sponse (0x%08x).\n"), nStatus );
1656 }
1657
1658 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1659
1660 if ( pAssocReq != NULL )
1661 {
1662 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1663 &addnIEPresent) != eSIR_SUCCESS)
1664 {
1665 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1666 return;
1667 }
1668
1669 if (addnIEPresent)
1670 {
1671 //Assoc rsp IE available
1672 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1673 &addnIELen) != eSIR_SUCCESS)
1674 {
1675 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1676 return;
1677 }
1678
1679 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1680 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1681 {
1682 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1683 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1684 {
1685 nBytes = nBytes + addnIELen;
1686 }
1687 }
1688 }
1689 }
1690
1691 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1692 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1693 ( void** ) &pPacket );
1694 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1695 {
1696 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP.\n"));
1697 return;
1698 }
1699
1700 // Paranoia:
1701 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1702
1703 // Next, we fill out the buffer descriptor:
1704 nSirStatus = limPopulateMacHeader( pMac,
1705 pFrame,
1706 SIR_MAC_MGMT_FRAME,
1707 ( LIM_ASSOC == subType ) ?
1708 SIR_MAC_MGMT_ASSOC_RSP :
1709 SIR_MAC_MGMT_REASSOC_RSP,
1710 peerMacAddr,psessionEntry->selfMacAddr);
1711 if ( eSIR_SUCCESS != nSirStatus )
1712 {
1713 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1714 "tor for an Association Response (%d).\n"),
1715 nSirStatus );
1716 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1717 ( void* ) pFrame, ( void* ) pPacket );
1718 return;
1719 }
1720
1721 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1722
1723 #if 0
1724 cfgLen = SIR_MAC_ADDR_LENGTH;
1725 if ( eSIR_SUCCESS != cfgGetStr( pMac, WNI_CFG_BSSID,
1726 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1727 {
1728 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1729 "e sending an Association Response.\n") );
1730 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1731 return; // allocated!
1732 }
1733 #endif //TO SUPPORT BT-AMP
1734 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1735
1736 nStatus = dot11fPackAssocResponse( pMac, &frm,
1737 pFrame + sizeof( tSirMacMgmtHdr ),
1738 nPayload, &nPayload );
1739 if ( DOT11F_FAILED( nStatus ) )
1740 {
1741 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x).\n"),
1742 nStatus );
1743 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1744 ( void* ) pFrame, ( void* ) pPacket );
1745 return; // allocated!
1746 }
1747 else if ( DOT11F_WARNED( nStatus ) )
1748 {
1749 limLog( pMac, LOGW, FL("There were warnings while packing an "
1750 "Association Response (0x%08x).\n") );
1751 }
1752
1753 macAddr = pMacHdr->da;
1754
1755 if (subType == LIM_ASSOC)
1756 {
1757 PELOG1(limLog(pMac, LOG1,
1758 FL("*** Sending Assoc Resp status %d aid %d to "),
1759 statusCode, aid);)
1760 }
1761 else{
1762 PELOG1(limLog(pMac, LOG1,
1763 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1764 statusCode, aid);)
1765 }
1766 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1767
1768 if ( addnIEPresent )
1769 {
1770 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -07001771 &addIE[0], addnIELen ) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 {
1773 limLog(pMac, LOGP, FL("Additional Assoc IEs request failed while Appending: %x\n"),halstatus);
1774 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1775 ( void* ) pFrame, ( void* ) pPacket );
1776 return;
1777 }
1778 }
1779
1780 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
1781#ifdef WLAN_FEATURE_P2P
1782 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1783 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
1784#endif
1785 )
1786 {
1787 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1788 }
1789
1790 /// Queue Association Response frame in high priority WQ
1791 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1792 HAL_TXRX_FRM_802_11_MGMT,
1793 ANI_TXDIR_TODS,
1794 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1795 limTxComplete, pFrame, txFlag );
1796 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1797 {
1798 limLog(pMac, LOGE,
1799 FL("*** Could not Send Re/AssocRsp, retCode=%X ***\n"),
1800 nSirStatus);
1801
1802 //Pkt will be freed up by the callback
1803 }
1804
1805 // update the ANI peer station count
1806 //FIXME_PROTECTION : take care of different type of station
1807 // counter inside this function.
1808 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1809
1810} // End limSendAssocRspMgmtFrame.
1811
1812
1813
1814void
1815limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1816 tSirMacAddr peer,
1817 tANI_U16 nStatusCode,
1818 tSirAddtsReqInfo *pAddTS,
1819 tSirMacScheduleIE *pSchedule,
1820 tpPESession psessionEntry)
1821{
1822 tANI_U8 *pFrame;
1823 tpSirMacMgmtHdr pMacHdr;
1824 tDot11fAddTSResponse AddTSRsp;
1825 tDot11fWMMAddTSResponse WMMAddTSRsp;
1826 tSirRetStatus nSirStatus;
1827 tANI_U32 i, nBytes, nPayload, nStatus;
1828 void *pPacket;
1829 eHalStatus halstatus;
1830 tANI_U8 txFlag = 0;
1831
1832 if(NULL == psessionEntry)
1833 {
1834 return;
1835 }
1836
1837 if ( ! pAddTS->wmeTspecPresent )
1838 {
1839 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ) );
1840
1841 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1842 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1843 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1844 AddTSRsp.Status.status = nStatusCode;
1845
1846 // The TsDelay information element is only filled in for a specific
1847 // status code:
1848 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1849 {
1850 if ( pAddTS->wsmTspecPresent )
1851 {
1852 AddTSRsp.WMMTSDelay.version = 1;
1853 AddTSRsp.WMMTSDelay.delay = 10;
1854 AddTSRsp.WMMTSDelay.present = 1;
1855 }
1856 else
1857 {
1858 AddTSRsp.TSDelay.delay = 10;
1859 AddTSRsp.TSDelay.present = 1;
1860 }
1861 }
1862
1863 if ( pAddTS->wsmTspecPresent )
1864 {
1865 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1866 }
1867 else
1868 {
1869 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1870 }
1871
1872 if ( pAddTS->wsmTspecPresent )
1873 {
1874 AddTSRsp.num_WMMTCLAS = 0;
1875 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1876 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1877 {
1878 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1879 &AddTSRsp.TCLAS[i] );
1880 }
1881 }
1882 else
1883 {
1884 AddTSRsp.num_TCLAS = 0;
1885 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1886 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1887 {
1888 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1889 &AddTSRsp.WMMTCLAS[i] );
1890 }
1891 }
1892
1893 if ( pAddTS->tclasProcPresent )
1894 {
1895 if ( pAddTS->wsmTspecPresent )
1896 {
1897 AddTSRsp.WMMTCLASPROC.version = 1;
1898 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1899 AddTSRsp.WMMTCLASPROC.present = 1;
1900 }
1901 else
1902 {
1903 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1904 AddTSRsp.TCLASSPROC.present = 1;
1905 }
1906 }
1907
1908 // schedule element is included only if requested in the tspec and we are
1909 // using hcca (or both edca and hcca)
1910 // 11e-D8.0 is inconsistent on whether the schedule element is included
1911 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1912 // pg 46, line 17-18 says something else. So just include it and let the
1913 // sta figure it out
1914 if ((pSchedule != NULL) &&
1915 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1916 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1917 {
1918 if ( pAddTS->wsmTspecPresent )
1919 {
1920 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1921 }
1922 else
1923 {
1924 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1925 }
1926 }
1927
1928 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1929 if ( DOT11F_FAILED( nStatus ) )
1930 {
1931 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1932 "ze for an Add TS Response (0x%08x).\n"),
1933 nStatus );
1934 // We'll fall back on the worst case scenario:
1935 nPayload = sizeof( tDot11fAddTSResponse );
1936 }
1937 else if ( DOT11F_WARNED( nStatus ) )
1938 {
1939 limLog( pMac, LOGW, FL("There were warnings while calcula"
1940 "tingthe packed size for an Add TS"
1941 " Response (0x%08x).\n"), nStatus );
1942 }
1943 }
1944 else
1945 {
1946 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ) );
1947
1948 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1949 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1950 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1951 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1952
1953 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1954
1955 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1956 if ( DOT11F_FAILED( nStatus ) )
1957 {
1958 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1959 "ze for a WMM Add TS Response (0x%08x).\n"),
1960 nStatus );
1961 // We'll fall back on the worst case scenario:
1962 nPayload = sizeof( tDot11fWMMAddTSResponse );
1963 }
1964 else if ( DOT11F_WARNED( nStatus ) )
1965 {
1966 limLog( pMac, LOGW, FL("There were warnings while calcula"
1967 "tingthe packed size for a WMM Add"
1968 "TS Response (0x%08x).\n"), nStatus );
1969 }
1970 }
1971
1972 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1973
1974 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1975 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1976 {
1977 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1978 "d TS Response.\n"), nBytes );
1979 return;
1980 }
1981
1982 // Paranoia:
1983 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1984
1985 // Next, we fill out the buffer descriptor:
1986 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1987 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1988 if ( eSIR_SUCCESS != nSirStatus )
1989 {
1990 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1991 "tor for an Add TS Response (%d).\n"),
1992 nSirStatus );
1993 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1994 return; // allocated!
1995 }
1996
1997 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1998
1999
2000 #if 0
2001 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2002 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2003 {
2004 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
2005 "e sending an Add TS Response.\n") );
2006 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2007 return; // allocated!
2008 }
2009 #endif //TO SUPPORT BT-AMP
2010 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
2011
2012 // That done, pack the struct:
2013 if ( ! pAddTS->wmeTspecPresent )
2014 {
2015 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
2016 pFrame + sizeof( tSirMacMgmtHdr ),
2017 nPayload, &nPayload );
2018 if ( DOT11F_FAILED( nStatus ) )
2019 {
2020 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
2021 "(0x%08x).\n"),
2022 nStatus );
2023 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2024 return;
2025 }
2026 else if ( DOT11F_WARNED( nStatus ) )
2027 {
2028 limLog( pMac, LOGW, FL("There were warnings while packing"
2029 "an Add TS Response (0x%08x).\n") );
2030 }
2031 }
2032 else
2033 {
2034 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2035 pFrame + sizeof( tSirMacMgmtHdr ),
2036 nPayload, &nPayload );
2037 if ( DOT11F_FAILED( nStatus ) )
2038 {
2039 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
2040 "(0x%08x).\n"),
2041 nStatus );
2042 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2043 return;
2044 }
2045 else if ( DOT11F_WARNED( nStatus ) )
2046 {
2047 limLog( pMac, LOGW, FL("There were warnings while packing"
2048 "a WMM Add TS Response (0x%08x).\n") );
2049 }
2050 }
2051
2052 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
2053 nStatusCode );
2054 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
2055
2056 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2057#ifdef WLAN_FEATURE_P2P
2058 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2059 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2060#endif
2061 )
2062 {
2063 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2064 }
2065
2066 // Queue the frame in high priority WQ:
2067 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2068 HAL_TXRX_FRM_802_11_MGMT,
2069 ANI_TXDIR_TODS,
2070 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2071 limTxComplete, pFrame, txFlag );
2072 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2073 {
2074 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!\n"),
2075 nSirStatus );
2076 //Pkt will be freed up by the callback
2077 }
2078
2079} // End limSendAddtsRspActionFrame.
2080
2081void
2082limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2083 tSirMacAddr peer,
2084 tANI_U8 wmmTspecPresent,
2085 tSirMacTSInfo *pTsinfo,
2086 tSirMacTspecIE *pTspecIe,
2087 tpPESession psessionEntry)
2088{
2089 tANI_U8 *pFrame;
2090 tpSirMacMgmtHdr pMacHdr;
2091 tDot11fDelTS DelTS;
2092 tDot11fWMMDelTS WMMDelTS;
2093 tSirRetStatus nSirStatus;
2094 tANI_U32 nBytes, nPayload, nStatus;
2095 void *pPacket;
2096 eHalStatus halstatus;
2097 tANI_U8 txFlag = 0;
2098
2099 if(NULL == psessionEntry)
2100 {
2101 return;
2102 }
2103
2104 if ( ! wmmTspecPresent )
2105 {
2106 palZeroMemory( pMac->hHdd, ( tANI_U8* )&DelTS, sizeof( DelTS ) );
2107
2108 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2109 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2110 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2111
2112 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2113 if ( DOT11F_FAILED( nStatus ) )
2114 {
2115 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
2116 "ze for a Del TS (0x%08x).\n"),
2117 nStatus );
2118 // We'll fall back on the worst case scenario:
2119 nPayload = sizeof( tDot11fDelTS );
2120 }
2121 else if ( DOT11F_WARNED( nStatus ) )
2122 {
2123 limLog( pMac, LOGW, FL("There were warnings while calcula"
2124 "ting the packed size for a Del TS"
2125 " (0x%08x).\n"), nStatus );
2126 }
2127 }
2128 else
2129 {
2130 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ) );
2131
2132 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2133 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2134 WMMDelTS.DialogToken.token = 0;
2135 WMMDelTS.StatusCode.statusCode = 0;
2136 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2137 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2138 if ( DOT11F_FAILED( nStatus ) )
2139 {
2140 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
2141 "ze for a WMM Del TS (0x%08x).\n"),
2142 nStatus );
2143 // We'll fall back on the worst case scenario:
2144 nPayload = sizeof( tDot11fDelTS );
2145 }
2146 else if ( DOT11F_WARNED( nStatus ) )
2147 {
2148 limLog( pMac, LOGW, FL("There were warnings while calcula"
2149 "ting the packed size for a WMM De"
2150 "l TS (0x%08x).\n"), nStatus );
2151 }
2152 }
2153
2154 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2155
2156 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2157 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2158 {
2159 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
2160 "d TS Response.\n"), nBytes );
2161 return;
2162 }
2163
2164 // Paranoia:
2165 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2166
2167 // Next, we fill out the buffer descriptor:
2168 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2169 SIR_MAC_MGMT_ACTION, peer,
2170 psessionEntry->selfMacAddr);
2171 if ( eSIR_SUCCESS != nSirStatus )
2172 {
2173 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2174 "tor for an Add TS Response (%d).\n"),
2175 nSirStatus );
2176 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2177 return; // allocated!
2178 }
2179
2180 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2181
2182 #if 0
2183
2184 cfgLen = SIR_MAC_ADDR_LENGTH;
2185 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2186 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2187 {
2188 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
2189 "e sending an Add TS Response.\n") );
2190 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2191 return; // allocated!
2192 }
2193 #endif //TO SUPPORT BT-AMP
2194 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2195
2196 // That done, pack the struct:
2197 if ( !wmmTspecPresent )
2198 {
2199 nStatus = dot11fPackDelTS( pMac, &DelTS,
2200 pFrame + sizeof( tSirMacMgmtHdr ),
2201 nPayload, &nPayload );
2202 if ( DOT11F_FAILED( nStatus ) )
2203 {
2204 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x).\n"),
2205 nStatus );
2206 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2207 return; // allocated!
2208 }
2209 else if ( DOT11F_WARNED( nStatus ) )
2210 {
2211 limLog( pMac, LOGW, FL("There were warnings while packing"
2212 "a Del TS frame (0x%08x).\n") );
2213 }
2214 }
2215 else
2216 {
2217 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2218 pFrame + sizeof( tSirMacMgmtHdr ),
2219 nPayload, &nPayload );
2220 if ( DOT11F_FAILED( nStatus ) )
2221 {
2222 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x).\n"),
2223 nStatus );
2224 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2225 return; // allocated!
2226 }
2227 else if ( DOT11F_WARNED( nStatus ) )
2228 {
2229 limLog( pMac, LOGW, FL("There were warnings while packing"
2230 "a WMM Del TS frame (0x%08x).\n") );
2231 }
2232 }
2233
2234 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2235 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2236
2237 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2238#ifdef WLAN_FEATURE_P2P
2239 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2240 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2241#endif
2242 )
2243 {
2244 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2245 }
2246
2247 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2248 HAL_TXRX_FRM_802_11_MGMT,
2249 ANI_TXDIR_TODS,
2250 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2251 limTxComplete, pFrame, txFlag );
2252 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2253 {
2254 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!\n"),
2255 nSirStatus );
2256 //Pkt will be freed up by the callback
2257 }
2258
2259} // End limSendDeltsReqActionFrame.
2260
2261void
2262limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2263 tLimMlmAssocReq *pMlmAssocReq,
2264 tpPESession psessionEntry)
2265{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002266 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 tANI_U16 caps;
2268 tANI_U8 *pFrame;
2269 tSirRetStatus nSirStatus;
2270 tLimMlmAssocCnf mlmAssocCnf;
2271 tANI_U32 nBytes, nPayload, nStatus;
2272 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2273 void *pPacket;
2274 eHalStatus halstatus;
2275 tANI_U16 nAddIELen;
2276 tANI_U8 *pAddIE;
2277 tANI_U8 *wpsIe = NULL;
2278#if defined WLAN_FEATURE_VOWIFI
2279 tANI_U8 PowerCapsPopulated = FALSE;
2280#endif
2281 tANI_U8 txFlag = 0;
2282
2283 if(NULL == psessionEntry)
2284 {
2285 return;
2286 }
2287
2288 if(NULL == psessionEntry->pLimJoinReq)
2289 {
2290 return;
2291 }
2292
2293 /* check this early to avoid unncessary operation */
2294 if(NULL == psessionEntry->pLimJoinReq)
2295 {
2296 return;
2297 }
2298 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2299 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2300
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002301 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
2302 (void **)&pFrm, sizeof(tDot11fAssocRequest)))
2303 {
2304 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendAssocReqMgmtFrame\n") );
2305 return;
2306 }
2307
2308
2309 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
2311 caps = pMlmAssocReq->capabilityInfo;
2312 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2313 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2314#if defined(FEATURE_WLAN_WAPI)
2315 /* CR: 262463 :
2316 According to WAPI standard:
2317 7.3.1.4 Capability Information field
2318 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2319 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2320 Reassociation management frames. */
2321 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2322 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2323#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002324 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002325
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002326 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2327 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002329 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002330
2331 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2332 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2333
2334 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2335 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2336
2337 // We prefer .11e asociations:
2338 if ( fQosEnabled ) fWmeEnabled = false;
2339
2340 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2341 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2342
2343 if ( psessionEntry->lim11hEnable &&
2344 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2345 {
2346#if defined WLAN_FEATURE_VOWIFI
2347 PowerCapsPopulated = TRUE;
2348
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002349 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002351 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002352
2353 }
2354
2355#if defined WLAN_FEATURE_VOWIFI
2356 if( pMac->rrm.rrmPEContext.rrmEnable &&
2357 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2358 {
2359 if (PowerCapsPopulated == FALSE)
2360 {
2361 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002362 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 }
2364 }
2365#endif
2366
2367 if ( fQosEnabled &&
2368 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002369 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002370
2371 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002372 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
2374#if defined WLAN_FEATURE_VOWIFI
2375 if( pMac->rrm.rrmPEContext.rrmEnable &&
2376 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2377 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002378 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 }
2380#endif
2381 // The join request *should* contain zero or one of the WPA and RSN
2382 // IEs. The payload send along with the request is a
2383 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2384
2385 // typedef struct sSirRSNie
2386 // {
2387 // tANI_U16 length;
2388 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2389 // } tSirRSNie, *tpSirRSNie;
2390
2391 // So, we should be able to make the following two calls harmlessly,
2392 // since they do nothing if they don't find the given IE in the
2393 // bytestream with which they're provided.
2394
2395 // The net effect of this will be to faithfully transmit whatever
2396 // security IE is in the join request.
2397
2398 // *However*, if we're associating for the purpose of WPS
2399 // enrollment, and we've been configured to indicate that by
2400 // eliding the WPA or RSN IE, we just skip this:
2401 if( nAddIELen && pAddIE )
2402 {
2403 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2404 }
2405 if ( NULL == wpsIe )
2406 {
2407 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002408 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002410 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002411#if defined(FEATURE_WLAN_WAPI)
2412 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002414#endif // defined(FEATURE_WLAN_WAPI)
2415 }
2416
2417 // include WME EDCA IE as well
2418 if ( fWmeEnabled )
2419 {
2420 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2421 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002422 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 }
2424
2425 if ( fWsmEnabled &&
2426 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2427 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002428 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 }
2430 }
2431
2432 //Populate HT IEs, when operating in 11n or Taurus modes AND
2433 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002434 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 pMac->lim.htCapabilityPresentInBeacon)
2436 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002437 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002438#ifdef DISABLE_GF_FOR_INTEROP
2439
2440 /*
2441 * To resolve the interop problem with Broadcom AP,
2442 * where TQ STA could not pass traffic with GF enabled,
2443 * TQ STA will do Greenfield only with TQ AP, for
2444 * everybody else it will be turned off.
2445 */
2446
2447 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2448 {
2449 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002450 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 }
2452#endif
2453
2454 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002455#ifdef WLAN_FEATURE_11AC
2456 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002457 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002458 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002459 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002460 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2461 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002462 }
2463#endif
2464
Jeff Johnson295189b2012-06-20 16:38:30 -07002465
2466#if defined WLAN_FEATURE_VOWIFI_11R
2467 if (psessionEntry->pLimJoinReq->is11Rconnection)
2468 {
2469#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002470 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2472 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2473 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2474#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002475 PopulateMDIE( pMac, &pFrm->MobilityDomain, psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 }
2477 else
2478 {
2479 // No 11r IEs dont send any MDIE
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002480 limLog( pMac, LOG1, FL("mdie not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 }
2482#endif
2483
2484#ifdef FEATURE_WLAN_CCX
2485 // For CCX Associations fill the CCX IEs
2486 if (psessionEntry->isCCXconnection)
2487 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002488 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
2489 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 }
2491#endif
2492
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002493 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 if ( DOT11F_FAILED( nStatus ) )
2495 {
2496 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2497 "or an Association Request (0x%08x).\n"),
2498 nStatus );
2499 // We'll fall back on the worst case scenario:
2500 nPayload = sizeof( tDot11fAssocRequest );
2501 }
2502 else if ( DOT11F_WARNED( nStatus ) )
2503 {
2504 limLog( pMac, LOGW, FL("There were warnings while calculating"
2505 "the packed size for an Association Re "
2506 "quest(0x%08x).\n"), nStatus );
2507 }
2508
2509 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2510
2511 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2512 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2513 ( void** ) &pPacket );
2514 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2515 {
2516 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
2517 "sociation Request.\n"), nBytes );
2518
2519 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002520 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002521
2522
2523 /* Update PE session id*/
2524 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2525
2526 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2527
2528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2529 ( void* ) pFrame, ( void* ) pPacket );
2530
2531 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2532 ( tANI_U32* ) &mlmAssocCnf);
2533
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002534 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 return;
2536 }
2537
2538 // Paranoia:
2539 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2540
2541 // Next, we fill out the buffer descriptor:
2542 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2543 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2544 if ( eSIR_SUCCESS != nSirStatus )
2545 {
2546 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2547 "tor for an Association Request (%d).\n"),
2548 nSirStatus );
2549 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002550 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 return;
2552 }
2553
2554
2555 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002556 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 sizeof(tSirMacMgmtHdr),
2558 nPayload, &nPayload );
2559 if ( DOT11F_FAILED( nStatus ) )
2560 {
2561 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
2562 "8x).\n"),
2563 nStatus );
2564 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2565 ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002566 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 return;
2568 }
2569 else if ( DOT11F_WARNED( nStatus ) )
2570 {
2571 limLog( pMac, LOGW, FL("There were warnings while packing a P"
2572 "robe Response (0x%08x).\n") );
2573 }
2574
2575 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
2576 "to \n"),
2577 nBytes );)
2578 // limPrintMacAddr( pMac, bssid, LOG1 );
2579
2580 if( psessionEntry->assocReq != NULL )
2581 {
2582 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2583 psessionEntry->assocReq = NULL;
2584 }
2585
2586 if( nAddIELen )
2587 {
2588 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2589 pAddIE,
2590 nAddIELen );
2591 nPayload += nAddIELen;
2592 }
2593
Jeff Johnson43971f52012-07-17 12:26:56 -07002594 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2595 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 {
2597 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2598 }
2599 else
2600 {
2601 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2602 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2603 psessionEntry->assocReqLen = nPayload;
2604 }
2605
2606 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
2607#ifdef WLAN_FEATURE_P2P
2608 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2609 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
2610#endif
2611 )
2612 {
2613 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2614 }
2615
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002616#ifdef WLAN_FEATURE_P2P
Ganesh K08bce952012-12-13 15:04:41 -08002617 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2618 {
2619 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2620 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002621#endif
2622
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2624 HAL_TXRX_FRM_802_11_MGMT,
2625 ANI_TXDIR_TODS,
2626 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2627 limTxComplete, pFrame, txFlag );
2628 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2629 {
2630 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!\n"),
2631 halstatus );
2632 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002633 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 return;
2635 }
2636
2637 // Free up buffer allocated for mlmAssocReq
2638 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmAssocReq );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002639 palFreeMemory(pMac->hHdd, pFrm);
2640 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641} // End limSendAssocReqMgmtFrame
2642
2643
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002644#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002645/*------------------------------------------------------------------------------------
2646 *
2647 * Send Reassoc Req with FTIEs.
2648 *
2649 *-----------------------------------------------------------------------------------
2650 */
2651void
2652limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2653 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2654{
2655 static tDot11fReAssocRequest frm;
2656 tANI_U16 caps;
2657 tANI_U8 *pFrame;
2658 tSirRetStatus nSirStatus;
2659 tANI_U32 nBytes, nPayload, nStatus;
2660 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2661 void *pPacket;
2662 eHalStatus halstatus;
2663#if defined WLAN_FEATURE_VOWIFI
2664 tANI_U8 PowerCapsPopulated = FALSE;
2665#endif
2666 tANI_U16 ft_ies_length = 0;
2667 tANI_U8 *pBody;
2668 tANI_U16 nAddIELen;
2669 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002670#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 tANI_U8 *wpsIe = NULL;
2672#endif
2673 tANI_U8 txFlag = 0;
2674
2675 if (NULL == psessionEntry)
2676 {
2677 return;
2678 }
2679
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 /* check this early to avoid unncessary operation */
2681 if(NULL == psessionEntry->pLimReAssocReq)
2682 {
2683 return;
2684 }
2685 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2686 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002687 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2688 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002689
2690 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2691
2692 caps = pMlmReassocReq->capabilityInfo;
2693 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2694 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2695#if defined(FEATURE_WLAN_WAPI)
2696 /* CR: 262463 :
2697 According to WAPI standard:
2698 7.3.1.4 Capability Information field
2699 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2700 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2701 Reassociation management frames. */
2702 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2703 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2704#endif
2705 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2706
2707 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2708
2709 // Get the old bssid of the older AP.
2710 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2711 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2712
2713 PopulateDot11fSSID2( pMac, &frm.SSID );
2714 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2715 &frm.SuppRates,psessionEntry);
2716
2717 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2718 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2719
2720 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2721 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2722
2723 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2724 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2725
2726 if ( psessionEntry->lim11hEnable &&
2727 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2728 {
2729#if defined WLAN_FEATURE_VOWIFI
2730 PowerCapsPopulated = TRUE;
2731
2732 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2733 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2734#endif
2735 }
2736
2737#if defined WLAN_FEATURE_VOWIFI
2738 if( pMac->rrm.rrmPEContext.rrmEnable &&
2739 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2740 {
2741 if (PowerCapsPopulated == FALSE)
2742 {
2743 PowerCapsPopulated = TRUE;
2744 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2745 }
2746 }
2747#endif
2748
2749 if ( fQosEnabled &&
2750 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2751 {
2752 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2753 }
2754
2755 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2756 &frm.ExtSuppRates, psessionEntry );
2757
2758#if defined WLAN_FEATURE_VOWIFI
2759 if( pMac->rrm.rrmPEContext.rrmEnable &&
2760 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2761 {
2762 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2763 }
2764#endif
2765
2766 // Ideally this should be enabled for 11r also. But 11r does
2767 // not follow the usual norm of using the Opaque object
2768 // for rsnie and fties. Instead we just add
2769 // the rsnie and fties at the end of the pack routine for 11r.
2770 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002771#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 //
2773 // The join request *should* contain zero or one of the WPA and RSN
2774 // IEs. The payload send along with the request is a
2775 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2776
2777 // typedef struct sSirRSNie
2778 // {
2779 // tANI_U16 length;
2780 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2781 // } tSirRSNie, *tpSirRSNie;
2782
2783 // So, we should be able to make the following two calls harmlessly,
2784 // since they do nothing if they don't find the given IE in the
2785 // bytestream with which they're provided.
2786
2787 // The net effect of this will be to faithfully transmit whatever
2788 // security IE is in the join request.
2789
2790 // *However*, if we're associating for the purpose of WPS
2791 // enrollment, and we've been configured to indicate that by
2792 // eliding the WPA or RSN IE, we just skip this:
2793 if (!psessionEntry->is11Rconnection)
2794 {
2795 if( nAddIELen && pAddIE )
2796 {
2797 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2798 }
2799 if ( NULL == wpsIe )
2800 {
2801 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2802 &frm.RSNOpaque );
2803 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2804 &frm.WPAOpaque );
2805 }
2806
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002807#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 if(psessionEntry->pLimReAssocReq->cckmIE.length)
2809 {
2810 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2811 &frm.CCXCckmOpaque );
2812 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002813#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 }
2815
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002816#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 // For CCX Associations fill the CCX IEs
2818 if (psessionEntry->isCCXconnection)
2819 {
2820 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
2821 PopulateDot11fCCXVersion(&frm.CCXVersion);
2822 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002823#endif //FEATURE_WLAN_CCX
2824#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002825
2826 // include WME EDCA IE as well
2827 if ( fWmeEnabled )
2828 {
2829 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2830 {
2831 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2832 }
2833
2834 if ( fWsmEnabled &&
2835 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2836 {
2837 PopulateDot11fWMMCaps( &frm.WMMCaps );
2838 }
2839#ifdef FEATURE_WLAN_CCX
2840 if (psessionEntry->isCCXconnection)
2841 {
2842 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2843
2844 // Populate the TSRS IE if TSPEC is included in the reassoc request
2845 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2846 {
2847 tANI_U32 phyMode;
2848 tSirMacCCXTSRSIE tsrsIE;
2849 limGetPhyMode(pMac, &phyMode, psessionEntry);
2850
2851 tsrsIE.tsid = 0;
2852 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2853 {
2854 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2855 }
2856 else
2857 {
2858 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2859 }
2860 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2861 }
2862 }
2863#endif
2864 }
2865
Jeff Johnsone7245742012-09-05 17:12:55 -07002866 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 pMac->lim.htCapabilityPresentInBeacon)
2868 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002869 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 }
2871
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002872#if defined WLAN_FEATURE_VOWIFI_11R
2873 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length) )
2874 {
2875 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2876 }
2877#endif
2878
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2880 if ( DOT11F_FAILED( nStatus ) )
2881 {
2882 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2883 "or a Re-Association Request (0x%08x).\n"),
2884 nStatus );
2885 // We'll fall back on the worst case scenario:
2886 nPayload = sizeof( tDot11fReAssocRequest );
2887 }
2888 else if ( DOT11F_WARNED( nStatus ) )
2889 {
2890 limLog( pMac, LOGW, FL("There were warnings while calculating"
2891 "the packed size for a Re-Association Re "
2892 "quest(0x%08x).\n"), nStatus );
2893 }
2894
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002895 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002896
2897#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002898 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2900#endif
2901
2902#if defined WLAN_FEATURE_VOWIFI_11R
2903 if (psessionEntry->is11Rconnection)
2904 {
2905 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2906 }
2907#endif
2908
2909 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2910 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2911 ( void** ) &pPacket );
2912 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2913 {
2914 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002915 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
2917 "sociation Request.\n"), nBytes );
2918 goto end;
2919 }
2920
2921 // Paranoia:
2922 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2923
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002924#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002925 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002926#endif
2927 // Next, we fill out the buffer descriptor:
2928 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2929 SIR_MAC_MGMT_REASSOC_REQ,
2930 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2931 if ( eSIR_SUCCESS != nSirStatus )
2932 {
2933 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2934 "tor for an Association Request (%d).\n"),
2935 nSirStatus );
2936 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2937 goto end;
2938 }
2939
2940
2941 // That done, pack the ReAssoc Request:
2942 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2943 sizeof(tSirMacMgmtHdr),
2944 nPayload, &nPayload );
2945 if ( DOT11F_FAILED( nStatus ) )
2946 {
2947 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
2948 "st (0x%08x).\n"),
2949 nStatus );
2950 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2951 goto end;
2952 }
2953 else if ( DOT11F_WARNED( nStatus ) )
2954 {
2955 limLog( pMac, LOGW, FL("There were warnings while packing a R"
2956 "e-Association Request (0x%08x).\n") );
2957 }
2958
2959 PELOG3(limLog( pMac, LOG3,
2960 FL("*** Sending Re-Association Request length %d %d to \n"),
2961 nBytes, nPayload );)
2962 if( psessionEntry->assocReq != NULL )
2963 {
2964 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2965 psessionEntry->assocReq = NULL;
2966 }
2967
2968 if( nAddIELen )
2969 {
2970 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2971 pAddIE,
2972 nAddIELen );
2973 nPayload += nAddIELen;
2974 }
2975
Jeff Johnson43971f52012-07-17 12:26:56 -07002976 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2977 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 {
2979 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002980 }
2981 else
2982 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2984 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2985 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002987
2988 if (psessionEntry->is11Rconnection)
2989 {
2990 {
2991 int i = 0;
2992
2993 pBody = pFrame + nBytes;
2994 for (i=0; i<ft_ies_length; i++)
2995 {
2996 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2997 pBody++;
2998 }
2999 }
3000 }
3001
3002#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003003 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3004 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 (tANI_U8 *)pFrame,
3006 (nBytes + ft_ies_length));)
3007#endif
3008
3009
3010 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3011#ifdef WLAN_FEATURE_P2P
3012 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3013 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3014#endif
3015 )
3016 {
3017 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3018 }
3019
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003020 if( NULL != psessionEntry->assocReq )
3021 {
3022 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3023 psessionEntry->assocReq = NULL;
3024 }
3025
3026 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3027 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
3028 {
3029 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003030 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003031 }
3032 else
3033 {
3034 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3035 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3036 (ft_ies_length));
3037 psessionEntry->assocReqLen = (ft_ies_length);
3038 }
3039
3040
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3042 HAL_TXRX_FRM_802_11_MGMT,
3043 ANI_TXDIR_TODS,
3044 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3045 limTxComplete, pFrame, txFlag );
3046 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3047 {
3048 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3049 "(%X)!\n"),
3050 nSirStatus );
3051 //Pkt will be freed up by the callback
3052 goto end;
3053 }
3054
3055end:
3056 // Free up buffer allocated for mlmAssocReq
3057 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3058 psessionEntry->pLimMlmReassocReq = NULL;
3059
3060}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003061
3062void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3063 tLimMlmReassocReq *pMlmReassocReq,
3064 tpPESession psessionEntry)
3065{
3066 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3067 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3068 if(NULL == pTmpMlmReassocReq)
3069 {
3070 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
3071 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
3072 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
3073 }
3074
3075 // Prepare and send Reassociation request frame
3076 // start reassoc timer.
3077 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3078 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003079 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003080 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3081 != TX_SUCCESS)
3082 {
3083 // Could not start reassoc failure timer.
3084 // Log error
3085 limLog(pMac, LOGP,
3086 FL("could not start Reassociation failure timer\n"));
3087 // Return Reassoc confirm with
3088 // Resources Unavailable
3089 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3090 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3091 goto end;
3092 }
3093
3094 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3095 return;
3096
3097end:
3098 // Free up buffer allocated for reassocReq
3099 if (pMlmReassocReq != NULL)
3100 {
3101 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
3102 pMlmReassocReq = NULL;
3103 }
3104 if (pTmpMlmReassocReq != NULL)
3105 {
3106 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
3107 pTmpMlmReassocReq = NULL;
3108 }
3109 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3110 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3111 /* Update PE sessio Id*/
3112 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3113
3114 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3115}
3116
Jeff Johnson295189b2012-06-20 16:38:30 -07003117#endif /* WLAN_FEATURE_VOWIFI_11R */
3118
3119
3120void
3121limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3122 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3123{
3124 static tDot11fReAssocRequest frm;
3125 tANI_U16 caps;
3126 tANI_U8 *pFrame;
3127 tSirRetStatus nSirStatus;
3128 tANI_U32 nBytes, nPayload, nStatus;
3129 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3130 void *pPacket;
3131 eHalStatus halstatus;
3132 tANI_U16 nAddIELen;
3133 tANI_U8 *pAddIE;
3134 tANI_U8 *wpsIe = NULL;
3135 tANI_U8 txFlag = 0;
3136#if defined WLAN_FEATURE_VOWIFI
3137 tANI_U8 PowerCapsPopulated = FALSE;
3138#endif
3139
3140 if(NULL == psessionEntry)
3141 {
3142 return;
3143 }
3144
3145 /* check this early to avoid unncessary operation */
3146 if(NULL == psessionEntry->pLimReAssocReq)
3147 {
3148 return;
3149 }
3150 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3151 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3152
3153 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3154
3155 caps = pMlmReassocReq->capabilityInfo;
3156 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3157 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3158#if defined(FEATURE_WLAN_WAPI)
3159 /* CR: 262463 :
3160 According to WAPI standard:
3161 7.3.1.4 Capability Information field
3162 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3163 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3164 Reassociation management frames. */
3165 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3166 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3167#endif
3168 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3169
3170 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3171
3172 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
3173 ( tANI_U8* )psessionEntry->bssId, 6 );
3174
3175 PopulateDot11fSSID2( pMac, &frm.SSID );
3176 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3177 &frm.SuppRates,psessionEntry);
3178
3179 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3180 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3181
3182 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3183 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3184
3185 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3186 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3187
3188
3189 if ( psessionEntry->lim11hEnable &&
3190 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3191 {
3192#if defined WLAN_FEATURE_VOWIFI
3193 PowerCapsPopulated = TRUE;
3194 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3195 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3196#endif
3197 }
3198
3199#if defined WLAN_FEATURE_VOWIFI
3200 if( pMac->rrm.rrmPEContext.rrmEnable &&
3201 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3202 {
3203 if (PowerCapsPopulated == FALSE)
3204 {
3205 PowerCapsPopulated = TRUE;
3206 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3207 }
3208 }
3209#endif
3210
3211 if ( fQosEnabled &&
3212 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3213 {
3214 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3215 }
3216
3217 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3218 &frm.ExtSuppRates, psessionEntry );
3219
3220#if defined WLAN_FEATURE_VOWIFI
3221 if( pMac->rrm.rrmPEContext.rrmEnable &&
3222 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3223 {
3224 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3225 }
3226#endif
3227 // The join request *should* contain zero or one of the WPA and RSN
3228 // IEs. The payload send along with the request is a
3229 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3230
3231 // typedef struct sSirRSNie
3232 // {
3233 // tANI_U16 length;
3234 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3235 // } tSirRSNie, *tpSirRSNie;
3236
3237 // So, we should be able to make the following two calls harmlessly,
3238 // since they do nothing if they don't find the given IE in the
3239 // bytestream with which they're provided.
3240
3241 // The net effect of this will be to faithfully transmit whatever
3242 // security IE is in the join request.
3243
3244 // *However*, if we're associating for the purpose of WPS
3245 // enrollment, and we've been configured to indicate that by
3246 // eliding the WPA or RSN IE, we just skip this:
3247 if( nAddIELen && pAddIE )
3248 {
3249 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3250 }
3251 if ( NULL == wpsIe )
3252 {
3253 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3254 &frm.RSNOpaque );
3255 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3256 &frm.WPAOpaque );
3257#if defined(FEATURE_WLAN_WAPI)
3258 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3259 &frm.WAPIOpaque );
3260#endif // defined(FEATURE_WLAN_WAPI)
3261 }
3262
3263 // include WME EDCA IE as well
3264 if ( fWmeEnabled )
3265 {
3266 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3267 {
3268 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3269 }
3270
3271 if ( fWsmEnabled &&
3272 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3273 {
3274 PopulateDot11fWMMCaps( &frm.WMMCaps );
3275 }
3276 }
3277
Jeff Johnsone7245742012-09-05 17:12:55 -07003278 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 pMac->lim.htCapabilityPresentInBeacon)
3280 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003281 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003283#ifdef WLAN_FEATURE_11AC
3284 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003285 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003286 {
3287 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request\n"));
3288 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07003289 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07003290 }
3291#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003292
3293 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3294 if ( DOT11F_FAILED( nStatus ) )
3295 {
3296 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3297 "or a Re-Association Request (0x%08x).\n"),
3298 nStatus );
3299 // We'll fall back on the worst case scenario:
3300 nPayload = sizeof( tDot11fReAssocRequest );
3301 }
3302 else if ( DOT11F_WARNED( nStatus ) )
3303 {
3304 limLog( pMac, LOGW, FL("There were warnings while calculating"
3305 "the packed size for a Re-Association Re "
3306 "quest(0x%08x).\n"), nStatus );
3307 }
3308
3309 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3310
3311 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3312 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3313 ( void** ) &pPacket );
3314 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3315 {
3316 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003317 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
3319 "sociation Request.\n"), nBytes );
3320 goto end;
3321 }
3322
3323 // Paranoia:
3324 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3325
3326 // Next, we fill out the buffer descriptor:
3327 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3328 SIR_MAC_MGMT_REASSOC_REQ,
3329 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3330 if ( eSIR_SUCCESS != nSirStatus )
3331 {
3332 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3333 "tor for an Association Request (%d).\n"),
3334 nSirStatus );
3335 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3336 goto end;
3337 }
3338
3339
3340 // That done, pack the Probe Request:
3341 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3342 sizeof(tSirMacMgmtHdr),
3343 nPayload, &nPayload );
3344 if ( DOT11F_FAILED( nStatus ) )
3345 {
3346 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
3347 "st (0x%08x).\n"),
3348 nStatus );
3349 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3350 goto end;
3351 }
3352 else if ( DOT11F_WARNED( nStatus ) )
3353 {
3354 limLog( pMac, LOGW, FL("There were warnings while packing a R"
3355 "e-Association Request (0x%08x).\n") );
3356 }
3357
3358 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
3359 "to \n"),
3360 nBytes );)
3361
3362 if( psessionEntry->assocReq != NULL )
3363 {
3364 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3365 psessionEntry->assocReq = NULL;
3366 }
3367
3368 if( nAddIELen )
3369 {
3370 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3371 pAddIE,
3372 nAddIELen );
3373 nPayload += nAddIELen;
3374 }
3375
Jeff Johnson43971f52012-07-17 12:26:56 -07003376 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3377 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 {
3379 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003380 }
3381 else
3382 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3384 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3385 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003387
3388 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3389#ifdef WLAN_FEATURE_P2P
3390 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3391 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3392#endif
3393 )
3394 {
3395 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3396 }
3397
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003398#ifdef WLAN_FEATURE_P2P
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003399 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003400 {
3401 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3402 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003403#endif
3404
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3406 HAL_TXRX_FRM_802_11_MGMT,
3407 ANI_TXDIR_TODS,
3408 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3409 limTxComplete, pFrame, txFlag );
3410 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3411 {
3412 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3413 "(%X)!\n"),
3414 nSirStatus );
3415 //Pkt will be freed up by the callback
3416 goto end;
3417 }
3418
3419end:
3420 // Free up buffer allocated for mlmAssocReq
3421 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3422 psessionEntry->pLimMlmReassocReq = NULL;
3423
3424} // limSendReassocReqMgmtFrame
3425
3426/**
3427 * \brief Send an Authentication frame
3428 *
3429 *
3430 * \param pMac Pointer to Global MAC structure
3431 *
3432 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3433 * to be sent
3434 *
3435 * \param peerMacAddr MAC address of the peer entity to which Authentication
3436 * frame is destined
3437 *
3438 * \param wepBit Indicates whether wep bit to be set in FC while sending
3439 * Authentication frame3
3440 *
3441 *
3442 * This function is called by limProcessMlmMessages(). Authentication frame
3443 * is formatted and sent when this function is called.
3444 *
3445 *
3446 */
3447
3448void
3449limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3450 tpSirMacAuthFrameBody pAuthFrameBody,
3451 tSirMacAddr peerMacAddr,
3452 tANI_U8 wepBit,
3453 tpPESession psessionEntry
3454 )
3455{
3456 tANI_U8 *pFrame, *pBody;
3457 tANI_U32 frameLen = 0, bodyLen = 0;
3458 tpSirMacMgmtHdr pMacHdr;
3459 tANI_U16 i;
3460 void *pPacket;
3461 eHalStatus halstatus;
3462 tANI_U8 txFlag = 0;
3463
3464 if(NULL == psessionEntry)
3465 {
3466 return;
3467 }
3468
3469 if (wepBit == LIM_WEP_IN_FC)
3470 {
3471 /// Auth frame3 to be sent with encrypted framebody
3472 /**
3473 * Allocate buffer for Authenticaton frame of size equal
3474 * to management frame header length plus 2 bytes each for
3475 * auth algorithm number, transaction number, status code,
3476 * 128 bytes for challenge text and 4 bytes each for
3477 * IV & ICV.
3478 */
3479
3480 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3481
3482 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3483 } // if (wepBit == LIM_WEP_IN_FC)
3484 else
3485 {
3486 switch (pAuthFrameBody->authTransactionSeqNumber)
3487 {
3488 case SIR_MAC_AUTH_FRAME_1:
3489 /**
3490 * Allocate buffer for Authenticaton frame of size
3491 * equal to management frame header length plus 2 bytes
3492 * each for auth algorithm number, transaction number
3493 * and status code.
3494 */
3495
3496 frameLen = sizeof(tSirMacMgmtHdr) +
3497 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3498 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3499
3500#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003501 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3502 {
3503 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003505 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
3506 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d\n"),
3507 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003509 else
3510 {
3511 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!\n"));
3512 frameLen += (2+SIR_MDIE_SIZE);
3513 }
3514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003515#endif
3516 break;
3517
3518 case SIR_MAC_AUTH_FRAME_2:
3519 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3520 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3521 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3522 {
3523 /**
3524 * Allocate buffer for Authenticaton frame of size
3525 * equal to management frame header length plus
3526 * 2 bytes each for auth algorithm number,
3527 * transaction number and status code.
3528 */
3529
3530 frameLen = sizeof(tSirMacMgmtHdr) +
3531 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3532 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3533 }
3534 else
3535 {
3536 // Shared Key algorithm with challenge text
3537 // to be sent
3538 /**
3539 * Allocate buffer for Authenticaton frame of size
3540 * equal to management frame header length plus
3541 * 2 bytes each for auth algorithm number,
3542 * transaction number, status code and 128 bytes
3543 * for challenge text.
3544 */
3545
3546 frameLen = sizeof(tSirMacMgmtHdr) +
3547 sizeof(tSirMacAuthFrame);
3548 bodyLen = sizeof(tSirMacAuthFrameBody);
3549 }
3550
3551 break;
3552
3553 case SIR_MAC_AUTH_FRAME_3:
3554 /// Auth frame3 to be sent without encrypted framebody
3555 /**
3556 * Allocate buffer for Authenticaton frame of size equal
3557 * to management frame header length plus 2 bytes each
3558 * for auth algorithm number, transaction number and
3559 * status code.
3560 */
3561
3562 frameLen = sizeof(tSirMacMgmtHdr) +
3563 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3564 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3565
3566 break;
3567
3568 case SIR_MAC_AUTH_FRAME_4:
3569 /**
3570 * Allocate buffer for Authenticaton frame of size equal
3571 * to management frame header length plus 2 bytes each
3572 * for auth algorithm number, transaction number and
3573 * status code.
3574 */
3575
3576 frameLen = sizeof(tSirMacMgmtHdr) +
3577 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3578 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3579
3580 break;
3581 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3582 } // end if (wepBit == LIM_WEP_IN_FC)
3583
3584
3585 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3586
3587 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3588 {
3589 // Log error
3590 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame\n"));
3591
3592 return;
3593 }
3594
3595 for (i = 0; i < frameLen; i++)
3596 pFrame[i] = 0;
3597
3598 // Prepare BD
3599 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3600 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3601 {
3602 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3603 return;
3604 }
3605
3606 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3607 pMacHdr->fc.wep = wepBit;
3608
3609 // Prepare BSSId
3610 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3611 {
3612 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3613 (tANI_U8 *) psessionEntry->bssId,
3614 sizeof( tSirMacAddr ));
3615 }
3616
3617 /// Prepare Authentication frame body
3618 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3619
3620 if (wepBit == LIM_WEP_IN_FC)
3621 {
3622 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3623
3624 PELOG1(limLog(pMac, LOG1,
3625 FL("*** Sending Auth seq# 3 status %d (%d) to\n"),
3626 pAuthFrameBody->authStatusCode,
3627 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3628
3629 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3630 }
3631 else
3632 {
3633 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3634 pBody += sizeof(tANI_U16);
3635 bodyLen -= sizeof(tANI_U16);
3636
3637 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3638 pBody += sizeof(tANI_U16);
3639 bodyLen -= sizeof(tANI_U16);
3640
3641 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3642 pBody += sizeof(tANI_U16);
3643 bodyLen -= sizeof(tANI_U16);
3644
3645 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
3646
3647#if defined WLAN_FEATURE_VOWIFI_11R
3648 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3649 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3650 {
3651
3652 {
3653 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3655 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003656#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3658 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3659 (tANI_U8 *)pBody,
3660 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003661#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003662 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3663 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003664 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3665 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003666 }
3667 }
3668 else
3669 {
3670 /* MDID attr is 54*/
3671 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003673 *pBody = SIR_MDIE_SIZE;
3674 pBody++;
3675 for(i=0;i<SIR_MDIE_SIZE;i++)
3676 {
3677 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3678 pBody++;
3679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 }
3681 }
3682 }
3683#endif
3684
3685 PELOG1(limLog(pMac, LOG1,
3686 FL("*** Sending Auth seq# %d status %d (%d) to "),
3687 pAuthFrameBody->authTransactionSeqNumber,
3688 pAuthFrameBody->authStatusCode,
3689 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3690
3691 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3692 }
3693 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3694
3695 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
3696#ifdef WLAN_FEATURE_P2P
3697 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3698 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
3699#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003700#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3701 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3702 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 )
3705 {
3706 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3707 }
3708
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003709#ifdef WLAN_FEATURE_P2P
Ganesh K08bce952012-12-13 15:04:41 -08003710 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3711 {
3712 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3713 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003714#endif
3715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 /// Queue Authentication frame in high priority WQ
3717 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3718 HAL_TXRX_FRM_802_11_MGMT,
3719 ANI_TXDIR_TODS,
3720 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3721 limTxComplete, pFrame, txFlag );
3722 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3723 {
3724 limLog(pMac, LOGE,
3725 FL("*** Could not send Auth frame, retCode=%X ***\n"),
3726 halstatus);
3727
3728 //Pkt will be freed up by the callback
3729 }
3730
3731 return;
3732} /*** end limSendAuthMgmtFrame() ***/
3733
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003734eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3735{
3736 tANI_U16 aid;
3737 tpDphHashNode pStaDs;
3738 tLimMlmDeauthReq *pMlmDeauthReq;
3739 tLimMlmDeauthCnf mlmDeauthCnf;
3740 tpPESession psessionEntry;
3741
3742 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3743 if (pMlmDeauthReq)
3744 {
3745 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3746 {
3747 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3748 }
3749
3750 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3751 {
3752
3753 PELOGE(limLog(pMac, LOGE,
3754 FL("session does not exist for given sessionId\n"));)
3755 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3756 goto end;
3757 }
3758
3759 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3760 if (pStaDs == NULL)
3761 {
3762 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3763 goto end;
3764 }
3765
3766
3767 /// Receive path cleanup with dummy packet
3768 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3769 /// Free up buffer allocated for mlmDeauthReq
3770 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3771 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3772 }
3773 return eHAL_STATUS_SUCCESS;
3774end:
3775 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3776 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3777 sizeof(tSirMacAddr));
3778 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3779 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3780 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3781
3782 // Free up buffer allocated
3783 // for mlmDeauthReq
3784 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3785
3786 limPostSmeMessage(pMac,
3787 LIM_MLM_DEAUTH_CNF,
3788 (tANI_U32 *) &mlmDeauthCnf);
3789 return eHAL_STATUS_SUCCESS;
3790}
3791
3792eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3793{
3794 tANI_U16 aid;
3795 tpDphHashNode pStaDs;
3796 tLimMlmDisassocCnf mlmDisassocCnf;
3797 tpPESession psessionEntry;
3798 tLimMlmDisassocReq *pMlmDisassocReq;
3799
3800 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3801 if (pMlmDisassocReq)
3802 {
3803 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3804 {
3805 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3806 }
3807
3808 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3809 {
3810
3811 PELOGE(limLog(pMac, LOGE,
3812 FL("session does not exist for given sessionId\n"));)
3813 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3814 goto end;
3815 }
3816
3817 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3818 if (pStaDs == NULL)
3819 {
3820 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3821 goto end;
3822 }
3823
3824 /// Receive path cleanup with dummy packet
3825 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3826 {
3827 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3828 goto end;
3829 }
3830
3831#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003832 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3833 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003834#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003835 (psessionEntry->isCCXconnection ) ||
3836#endif
3837#ifdef FEATURE_WLAN_LFR
3838 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003839#endif
3840 (psessionEntry->is11Rconnection )) &&
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003841 (pMlmDisassocReq->reasonCode !=
3842 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003843 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003844 PELOGE(limLog(pMac, LOGE,
3845 FL("FT Preauth Session (%p,%d) Cleanup\n"),
3846 psessionEntry, psessionEntry->peSessionId););
3847 limFTCleanup(pMac);
3848 }
3849 else
3850 {
3851 PELOGE(limLog(pMac, LOGE,
3852 FL("No FT Preauth Session Cleanup in role %d"
3853#ifdef FEATURE_WLAN_CCX
3854 " isCCX %d"
3855#endif
3856#ifdef FEATURE_WLAN_LFR
3857 " isLFR %d"
3858#endif
3859 " is11r %d reason %d\n"),
3860 psessionEntry->limSystemRole,
3861#ifdef FEATURE_WLAN_CCX
3862 psessionEntry->isCCXconnection,
3863#endif
3864#ifdef FEATURE_WLAN_LFR
3865 psessionEntry->isFastRoamIniFeatureEnabled,
3866#endif
3867 psessionEntry->is11Rconnection,
3868 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003869 }
3870#endif
3871
3872 /// Free up buffer allocated for mlmDisassocReq
3873 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3874 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3875 return eHAL_STATUS_SUCCESS;
3876 }
3877 else
3878 {
3879 return eHAL_STATUS_SUCCESS;
3880 }
3881end:
3882 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3883 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3884 sizeof(tSirMacAddr));
3885 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3886 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3887
3888 /* Update PE session ID*/
3889 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3890
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003891 if(pMlmDisassocReq != NULL)
3892 {
3893 /// Free up buffer allocated for mlmDisassocReq
3894 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3895 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3896 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003897
3898 limPostSmeMessage(pMac,
3899 LIM_MLM_DISASSOC_CNF,
3900 (tANI_U32 *) &mlmDisassocCnf);
3901 return eHAL_STATUS_SUCCESS;
3902}
3903
3904eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3905{
3906 return limSendDisassocCnf(pMac);
3907}
3908
3909eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3910{
3911 return limSendDeauthCnf(pMac);
3912}
3913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914/**
3915 * \brief This function is called to send Disassociate frame.
3916 *
3917 *
3918 * \param pMac Pointer to Global MAC structure
3919 *
3920 * \param nReason Indicates the reason that need to be sent in
3921 * Disassociation frame
3922 *
3923 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3924 * sent
3925 *
3926 *
3927 */
3928
3929void
3930limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3931 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003932 tSirMacAddr peer,
3933 tpPESession psessionEntry,
3934 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003935{
3936 tDot11fDisassociation frm;
3937 tANI_U8 *pFrame;
3938 tSirRetStatus nSirStatus;
3939 tpSirMacMgmtHdr pMacHdr;
3940 tANI_U32 nBytes, nPayload, nStatus;
3941 void *pPacket;
3942 eHalStatus halstatus;
3943 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003944 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 if(NULL == psessionEntry)
3946 {
3947 return;
3948 }
3949
3950 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3951
3952 frm.Reason.code = nReason;
3953
3954 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3955 if ( DOT11F_FAILED( nStatus ) )
3956 {
3957 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3958 "or a Disassociation (0x%08x).\n"),
3959 nStatus );
3960 // We'll fall back on the worst case scenario:
3961 nPayload = sizeof( tDot11fDisassociation );
3962 }
3963 else if ( DOT11F_WARNED( nStatus ) )
3964 {
3965 limLog( pMac, LOGW, FL("There were warnings while calculating"
3966 "the packed size for a Disassociation "
3967 "(0x%08x).\n"), nStatus );
3968 }
3969
3970 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3971
3972 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3973 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3974 ( void** ) &pPacket );
3975 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3976 {
3977 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
3978 "association.\n"), nBytes );
3979 return;
3980 }
3981
3982 // Paranoia:
3983 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3984
3985 // Next, we fill out the buffer descriptor:
3986 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3987 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3988 if ( eSIR_SUCCESS != nSirStatus )
3989 {
3990 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3991 "tor for a Disassociation (%d).\n"),
3992 nSirStatus );
3993 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3994 ( void* ) pFrame, ( void* ) pPacket );
3995 return; // just allocated...
3996 }
3997
3998 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3999
4000 // Prepare the BSSID
4001 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4002
4003 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4004 sizeof(tSirMacMgmtHdr),
4005 nPayload, &nPayload );
4006 if ( DOT11F_FAILED( nStatus ) )
4007 {
4008 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x).\n"),
4009 nStatus );
4010 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4011 ( void* ) pFrame, ( void* ) pPacket );
4012 return; // allocated!
4013 }
4014 else if ( DOT11F_WARNED( nStatus ) )
4015 {
4016 limLog( pMac, LOGW, FL("There were warnings while packing a D"
4017 "isassociation (0x%08x).\n") );
4018 }
4019
4020 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
4021 "son %d to\n"), nReason );
4022 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
4023
4024 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4025#ifdef WLAN_FEATURE_P2P
4026 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4027 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4028#endif
4029 )
4030 {
4031 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4032 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004033
4034#ifdef WLAN_FEATURE_P2P
Ganesh K08bce952012-12-13 15:04:41 -08004035 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
4036 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
4037 {
4038 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4039 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004040#endif
4041
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004042 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004044 // Queue Disassociation frame in high priority WQ
4045 /* get the duration from the request */
4046 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4047 HAL_TXRX_FRM_802_11_MGMT,
4048 ANI_TXDIR_TODS,
4049 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4050 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4051 txFlag );
4052 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004053
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004054 if (tx_timer_change(
4055 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4056 != TX_SUCCESS)
4057 {
4058 limLog(pMac, LOGP,
4059 FL("Unable to change Disassoc ack Timer val\n"));
4060 return;
4061 }
4062 else if(TX_SUCCESS != tx_timer_activate(
4063 &pMac->lim.limTimers.gLimDisassocAckTimer))
4064 {
4065 limLog(pMac, LOGP,
4066 FL("Unable to activate Disassoc ack Timer\n"));
4067 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4068 return;
4069 }
4070 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004071 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004072 {
4073 // Queue Disassociation frame in high priority WQ
4074 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4075 HAL_TXRX_FRM_802_11_MGMT,
4076 ANI_TXDIR_TODS,
4077 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4078 limTxComplete, pFrame, txFlag );
4079 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4080 {
4081 limLog( pMac, LOGE, FL("Failed to send Disassociation "
4082 "(%X)!\n"),
4083 nSirStatus );
4084 //Pkt will be freed up by the callback
4085 return;
4086 }
4087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004088} // End limSendDisassocMgmtFrame.
4089
4090/**
4091 * \brief This function is called to send a Deauthenticate frame
4092 *
4093 *
4094 * \param pMac Pointer to global MAC structure
4095 *
4096 * \param nReason Indicates the reason that need to be sent in the
4097 * Deauthenticate frame
4098 *
4099 * \param peeer address of the STA to which the frame is to be sent
4100 *
4101 *
4102 */
4103
4104void
4105limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4106 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004107 tSirMacAddr peer,
4108 tpPESession psessionEntry,
4109 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110{
4111 tDot11fDeAuth frm;
4112 tANI_U8 *pFrame;
4113 tSirRetStatus nSirStatus;
4114 tpSirMacMgmtHdr pMacHdr;
4115 tANI_U32 nBytes, nPayload, nStatus;
4116 void *pPacket;
4117 eHalStatus halstatus;
4118 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004119 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 if(NULL == psessionEntry)
4121 {
4122 return;
4123 }
4124
4125 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
4126
4127 frm.Reason.code = nReason;
4128
4129 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4130 if ( DOT11F_FAILED( nStatus ) )
4131 {
4132 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4133 "or a De-Authentication (0x%08x).\n"),
4134 nStatus );
4135 // We'll fall back on the worst case scenario:
4136 nPayload = sizeof( tDot11fDeAuth );
4137 }
4138 else if ( DOT11F_WARNED( nStatus ) )
4139 {
4140 limLog( pMac, LOGW, FL("There were warnings while calculating"
4141 "the packed size for a De-Authentication "
4142 "(0x%08x).\n"), nStatus );
4143 }
4144
4145 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4146
4147 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4148 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4149 ( void** ) &pPacket );
4150 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4151 {
4152 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
4153 "Authentication.\n"), nBytes );
4154 return;
4155 }
4156
4157 // Paranoia:
4158 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4159
4160 // Next, we fill out the buffer descriptor:
4161 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4162 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4163 if ( eSIR_SUCCESS != nSirStatus )
4164 {
4165 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4166 "tor for a De-Authentication (%d).\n"),
4167 nSirStatus );
4168 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4169 ( void* ) pFrame, ( void* ) pPacket );
4170 return; // just allocated...
4171 }
4172
4173 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4174
4175 // Prepare the BSSID
4176 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4177
4178 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4179 sizeof(tSirMacMgmtHdr),
4180 nPayload, &nPayload );
4181 if ( DOT11F_FAILED( nStatus ) )
4182 {
4183 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x).\n"),
4184 nStatus );
4185 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4186 ( void* ) pFrame, ( void* ) pPacket );
4187 return;
4188 }
4189 else if ( DOT11F_WARNED( nStatus ) )
4190 {
4191 limLog( pMac, LOGW, FL("There were warnings while packing a D"
4192 "e-Authentication (0x%08x).\n") );
4193 }
4194
4195 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
4196 "son %d to\n"), nReason );
4197 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
4198
4199 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4200#ifdef WLAN_FEATURE_P2P
4201 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4202 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4203#endif
4204 )
4205 {
4206 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4207 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004208
4209#ifdef WLAN_FEATURE_P2P
Ganesh K08bce952012-12-13 15:04:41 -08004210 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
4211 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
4212 {
4213 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4214 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004215#endif
4216
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004217 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004219 // Queue Disassociation frame in high priority WQ
4220 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4221 HAL_TXRX_FRM_802_11_MGMT,
4222 ANI_TXDIR_TODS,
4223 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4224 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
4225 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4226 {
4227 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
4228 "(%X)!\n"),
4229 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004230 //Pkt will be freed up by the callback limTxComplete
4231
4232 /*Call limProcessDeauthAckTimeout which will send
4233 * DeauthCnf for this frame
4234 */
4235 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004236 return;
4237 }
4238
4239 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4240
4241 if (tx_timer_change(
4242 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4243 != TX_SUCCESS)
4244 {
4245 limLog(pMac, LOGP,
4246 FL("Unable to change Deauth ack Timer val\n"));
4247 return;
4248 }
4249 else if(TX_SUCCESS != tx_timer_activate(
4250 &pMac->lim.limTimers.gLimDeauthAckTimer))
4251 {
4252 limLog(pMac, LOGP,
4253 FL("Unable to activate Deauth ack Timer\n"));
4254 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4255 return;
4256 }
4257 }
4258 else
4259 {
4260 // Queue Disassociation frame in high priority WQ
4261 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4262 HAL_TXRX_FRM_802_11_MGMT,
4263 ANI_TXDIR_TODS,
4264 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4265 limTxComplete, pFrame, txFlag );
4266 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4267 {
4268 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
4269 "(%X)!\n"),
4270 nSirStatus );
4271 //Pkt will be freed up by the callback
4272 return;
4273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 }
4275
4276} // End limSendDeauthMgmtFrame.
4277
4278
4279#ifdef ANI_SUPPORT_11H
4280/**
4281 * \brief Send a Measurement Report Action frame
4282 *
4283 *
4284 * \param pMac Pointer to the global MAC structure
4285 *
4286 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4287 *
4288 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4289 *
4290 *
4291 */
4292
4293tSirRetStatus
4294limSendMeasReportFrame(tpAniSirGlobal pMac,
4295 tpSirMacMeasReqActionFrame pMeasReqFrame,
4296 tSirMacAddr peer)
4297{
4298 tDot11fMeasurementReport frm;
4299 tANI_U8 *pFrame;
4300 tSirRetStatus nSirStatus;
4301 tpSirMacMgmtHdr pMacHdr;
4302 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4303 void *pPacket;
4304 eHalStatus halstatus;
4305
4306 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4307
4308 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4309 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4310 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4311
4312 switch ( pMeasReqFrame->measReqIE.measType )
4313 {
4314 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4315 nSirStatus =
4316 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4317 &frm.MeasurementReport );
4318 break;
4319 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4320 nSirStatus =
4321 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4322 &frm.MeasurementReport );
4323 break;
4324 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4325 nSirStatus =
4326 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4327 &frm.MeasurementReport );
4328 break;
4329 default:
4330 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
4331 "dMeasReportFrame.\n"),
4332 pMeasReqFrame->measReqIE.measType );
4333 return eSIR_FAILURE;
4334 }
4335
4336 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4337
4338 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4339 if ( DOT11F_FAILED( nStatus ) )
4340 {
4341 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4342 "or a Measurement Report (0x%08x).\n"),
4343 nStatus );
4344 // We'll fall back on the worst case scenario:
4345 nPayload = sizeof( tDot11fMeasurementReport );
4346 }
4347 else if ( DOT11F_WARNED( nStatus ) )
4348 {
4349 limLog( pMac, LOGW, FL("There were warnings while calculating"
4350 "the packed size for a Measurement Rep"
4351 "ort (0x%08x).\n"), nStatus );
4352 }
4353
4354 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4355
4356 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4357 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4358 {
4359 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
4360 "Authentication.\n"), nBytes );
4361 return eSIR_FAILURE;
4362 }
4363
4364 // Paranoia:
4365 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4366
4367 // Next, we fill out the buffer descriptor:
4368 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4369 SIR_MAC_MGMT_ACTION, peer);
4370 if ( eSIR_SUCCESS != nSirStatus )
4371 {
4372 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4373 "tor for a Measurement Report (%d).\n"),
4374 nSirStatus );
4375 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4376 return eSIR_FAILURE; // just allocated...
4377 }
4378
4379 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4380
4381 nCfg = 6;
4382 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4383 if ( eSIR_SUCCESS != nSirStatus )
4384 {
4385 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4386 " CFG (%d).\n"),
4387 nSirStatus );
4388 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4389 return eSIR_FAILURE; // just allocated...
4390 }
4391
4392 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4393 sizeof(tSirMacMgmtHdr),
4394 nPayload, &nPayload );
4395 if ( DOT11F_FAILED( nStatus ) )
4396 {
4397 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x).\n"),
4398 nStatus );
4399 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4400 return eSIR_FAILURE; // allocated!
4401 }
4402 else if ( DOT11F_WARNED( nStatus ) )
4403 {
4404 limLog( pMac, LOGW, FL("There were warnings while packing a M"
4405 "easurement Report (0x%08x).\n") );
4406 }
4407
4408 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4409 HAL_TXRX_FRM_802_11_MGMT,
4410 ANI_TXDIR_TODS,
4411 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4412 limTxComplete, pFrame, 0 );
4413 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4414 {
4415 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
4416 "(%X)!\n"),
4417 nSirStatus );
4418 //Pkt will be freed up by the callback
4419 return eSIR_FAILURE; // just allocated...
4420 }
4421
4422 return eSIR_SUCCESS;
4423
4424} // End limSendMeasReportFrame.
4425
4426
4427/**
4428 * \brief Send a TPC Request Action frame
4429 *
4430 *
4431 * \param pMac Pointer to the global MAC datastructure
4432 *
4433 * \param peer MAC address to which the frame should be sent
4434 *
4435 *
4436 */
4437
4438void
4439limSendTpcRequestFrame(tpAniSirGlobal pMac,
4440 tSirMacAddr peer)
4441{
4442 tDot11fTPCRequest frm;
4443 tANI_U8 *pFrame;
4444 tSirRetStatus nSirStatus;
4445 tpSirMacMgmtHdr pMacHdr;
4446 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4447 void *pPacket;
4448 eHalStatus halstatus;
4449
4450 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4451
4452 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4453 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4454 frm.DialogToken.token = 1;
4455 frm.TPCRequest.present = 1;
4456
4457 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4458 if ( DOT11F_FAILED( nStatus ) )
4459 {
4460 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4461 "or a TPC Request (0x%08x).\n"),
4462 nStatus );
4463 // We'll fall back on the worst case scenario:
4464 nPayload = sizeof( tDot11fTPCRequest );
4465 }
4466 else if ( DOT11F_WARNED( nStatus ) )
4467 {
4468 limLog( pMac, LOGW, FL("There were warnings while calculating"
4469 "the packed size for a TPC Request (0x"
4470 "%08x).\n"), nStatus );
4471 }
4472
4473 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4474
4475 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4476 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4477 {
4478 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4479 " Request.\n"), nBytes );
4480 return;
4481 }
4482
4483 // Paranoia:
4484 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4485
4486 // Next, we fill out the buffer descriptor:
4487 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4488 SIR_MAC_MGMT_ACTION, peer);
4489 if ( eSIR_SUCCESS != nSirStatus )
4490 {
4491 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4492 "tor for a TPC Request (%d).\n"),
4493 nSirStatus );
4494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4495 return; // just allocated...
4496 }
4497
4498 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4499
4500 nCfg = 6;
4501 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4502 if ( eSIR_SUCCESS != nSirStatus )
4503 {
4504 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4505 " CFG (%d).\n"),
4506 nSirStatus );
4507 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4508 return; // just allocated...
4509 }
4510
4511 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4512 sizeof(tSirMacMgmtHdr),
4513 nPayload, &nPayload );
4514 if ( DOT11F_FAILED( nStatus ) )
4515 {
4516 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x).\n"),
4517 nStatus );
4518 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4519 return; // allocated!
4520 }
4521 else if ( DOT11F_WARNED( nStatus ) )
4522 {
4523 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4524 "PC Request (0x%08x).\n") );
4525 }
4526
4527 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4528 HAL_TXRX_FRM_802_11_MGMT,
4529 ANI_TXDIR_TODS,
4530 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4531 limTxComplete, pFrame, 0 );
4532 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4533 {
4534 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
4535 "(%X)!\n"),
4536 nSirStatus );
4537 //Pkt will be freed up by the callback
4538 return;
4539 }
4540
4541} // End limSendTpcRequestFrame.
4542
4543
4544/**
4545 * \brief Send a TPC Report Action frame
4546 *
4547 *
4548 * \param pMac Pointer to the global MAC datastructure
4549 *
4550 * \param pTpcReqFrame Pointer to the received TPC Request
4551 *
4552 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4553 *
4554 *
4555 */
4556
4557tSirRetStatus
4558limSendTpcReportFrame(tpAniSirGlobal pMac,
4559 tpSirMacTpcReqActionFrame pTpcReqFrame,
4560 tSirMacAddr peer)
4561{
4562 tDot11fTPCReport frm;
4563 tANI_U8 *pFrame;
4564 tSirRetStatus nSirStatus;
4565 tpSirMacMgmtHdr pMacHdr;
4566 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4567 void *pPacket;
4568 eHalStatus halstatus;
4569
4570 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4571
4572 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4573 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4574 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4575
4576 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4577 // "misplaced this function, need to replace:
4578 // txPower = halGetRateToPwrValue(pMac, staid,
4579 // pMac->lim.gLimCurrentChannelId, 0);
4580 frm.TPCReport.tx_power = 0;
4581 frm.TPCReport.link_margin = 0;
4582 frm.TPCReport.present = 1;
4583
4584 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4585 if ( DOT11F_FAILED( nStatus ) )
4586 {
4587 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4588 "or a TPC Report (0x%08x).\n"),
4589 nStatus );
4590 // We'll fall back on the worst case scenario:
4591 nPayload = sizeof( tDot11fTPCReport );
4592 }
4593 else if ( DOT11F_WARNED( nStatus ) )
4594 {
4595 limLog( pMac, LOGW, FL("There were warnings while calculating"
4596 "the packed size for a TPC Report (0x"
4597 "%08x).\n"), nStatus );
4598 }
4599
4600 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4601
4602 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4603 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4604 {
4605 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4606 " Report.\n"), nBytes );
4607 return eSIR_FAILURE;
4608 }
4609
4610 // Paranoia:
4611 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4612
4613 // Next, we fill out the buffer descriptor:
4614 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4615 SIR_MAC_MGMT_ACTION, peer);
4616 if ( eSIR_SUCCESS != nSirStatus )
4617 {
4618 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4619 "tor for a TPC Report (%d).\n"),
4620 nSirStatus );
4621 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4622 return eSIR_FAILURE; // just allocated...
4623 }
4624
4625 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4626
4627 nCfg = 6;
4628 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4629 if ( eSIR_SUCCESS != nSirStatus )
4630 {
4631 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4632 " CFG (%d).\n"),
4633 nSirStatus );
4634 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4635 return eSIR_FAILURE; // just allocated...
4636 }
4637
4638 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4639 sizeof(tSirMacMgmtHdr),
4640 nPayload, &nPayload );
4641 if ( DOT11F_FAILED( nStatus ) )
4642 {
4643 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x).\n"),
4644 nStatus );
4645 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4646 return eSIR_FAILURE; // allocated!
4647 }
4648 else if ( DOT11F_WARNED( nStatus ) )
4649 {
4650 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4651 "PC Report (0x%08x).\n") );
4652 }
4653
4654
4655 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4656 HAL_TXRX_FRM_802_11_MGMT,
4657 ANI_TXDIR_TODS,
4658 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4659 limTxComplete, pFrame, 0 );
4660 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4661 {
4662 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
4663 "(%X)!\n"),
4664 nSirStatus );
4665 //Pkt will be freed up by the callback
4666 return eSIR_FAILURE; // just allocated...
4667 }
4668
4669 return eSIR_SUCCESS;
4670
4671} // End limSendTpcReportFrame.
4672#endif //ANI_SUPPORT_11H
4673
4674
Jeff Johnsone7245742012-09-05 17:12:55 -07004675#if 1//def ANI_PRODUCT_TYPE_AP
Jeff Johnson295189b2012-06-20 16:38:30 -07004676/**
4677 * \brief Send a Channel Switch Announcement
4678 *
4679 *
4680 * \param pMac Pointer to the global MAC datastructure
4681 *
4682 * \param peer MAC address to which this frame will be sent
4683 *
4684 * \param nMode
4685 *
4686 * \param nNewChannel
4687 *
4688 * \param nCount
4689 *
4690 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4691 *
4692 *
4693 */
4694
4695tSirRetStatus
4696limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4697 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004698 tANI_U8 nMode,
4699 tANI_U8 nNewChannel,
4700 tANI_U8 nCount,
4701 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004702{
4703 tDot11fChannelSwitch frm;
4704 tANI_U8 *pFrame;
4705 tSirRetStatus nSirStatus;
4706 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004707 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 void *pPacket;
4709 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004710 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004711
4712 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4713
4714 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4715 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4716 frm.ChanSwitchAnn.switchMode = nMode;
4717 frm.ChanSwitchAnn.newChannel = nNewChannel;
4718 frm.ChanSwitchAnn.switchCount = nCount;
4719 frm.ChanSwitchAnn.present = 1;
4720
4721 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4722 if ( DOT11F_FAILED( nStatus ) )
4723 {
4724 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4725 "or a Channel Switch (0x%08x).\n"),
4726 nStatus );
4727 // We'll fall back on the worst case scenario:
4728 nPayload = sizeof( tDot11fChannelSwitch );
4729 }
4730 else if ( DOT11F_WARNED( nStatus ) )
4731 {
4732 limLog( pMac, LOGW, FL("There were warnings while calculating"
4733 "the packed size for a Channel Switch (0x"
4734 "%08x).\n"), nStatus );
4735 }
4736
4737 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4738
4739 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4740 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4741 {
4742 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4743 " Report.\n"), nBytes );
4744 return eSIR_FAILURE;
4745 }
4746
4747 // Paranoia:
4748 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4749
4750 // Next, we fill out the buffer descriptor:
4751 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004752 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4753 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4754 palCopyMemory( pMac->hHdd,
4755 (tANI_U8 *) pMacHdr->bssId,
4756 (tANI_U8 *) psessionEntry->bssId,
4757 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 if ( eSIR_SUCCESS != nSirStatus )
4759 {
4760 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4761 "tor for a Channel Switch (%d).\n"),
4762 nSirStatus );
4763 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4764 return eSIR_FAILURE; // just allocated...
4765 }
4766
Jeff Johnsone7245742012-09-05 17:12:55 -07004767#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4769
4770 nCfg = 6;
4771 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4772 if ( eSIR_SUCCESS != nSirStatus )
4773 {
4774 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4775 " CFG (%d).\n"),
4776 nSirStatus );
4777 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4778 return eSIR_FAILURE; // just allocated...
4779 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004780#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4782 sizeof(tSirMacMgmtHdr),
4783 nPayload, &nPayload );
4784 if ( DOT11F_FAILED( nStatus ) )
4785 {
4786 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4787 nStatus );
4788 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4789 return eSIR_FAILURE; // allocated!
4790 }
4791 else if ( DOT11F_WARNED( nStatus ) )
4792 {
4793 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4794 "hannel Switch (0x%08x).\n") );
4795 }
4796
Jeff Johnsone7245742012-09-05 17:12:55 -07004797 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4798#ifdef WLAN_FEATURE_P2P
4799 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4800 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4801#endif
4802 )
4803 {
4804 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4807 HAL_TXRX_FRM_802_11_MGMT,
4808 ANI_TXDIR_TODS,
4809 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004810 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4812 {
4813 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4814 "(%X)!\n"),
4815 nSirStatus );
4816 //Pkt will be freed up by the callback
4817 return eSIR_FAILURE;
4818 }
4819
4820 return eSIR_SUCCESS;
4821
4822} // End limSendChannelSwitchMgmtFrame.
4823
4824#endif // (ANI_PRODUCT_TYPE_AP)
4825
4826
Mohit Khanna4a70d262012-09-11 16:30:12 -07004827#ifdef WLAN_FEATURE_11AC
4828tSirRetStatus
4829limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4830 tSirMacAddr peer,
4831 tANI_U8 nMode,
4832 tpPESession psessionEntry )
4833{
4834 tDot11fOperatingMode frm;
4835 tANI_U8 *pFrame;
4836 tSirRetStatus nSirStatus;
4837 tpSirMacMgmtHdr pMacHdr;
4838 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4839 void *pPacket;
4840 eHalStatus halstatus;
4841 tANI_U8 txFlag = 0;
4842
4843 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4844
4845 frm.Category.category = SIR_MAC_ACTION_VHT;
4846 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4847 frm.OperatingMode.chanWidth = nMode;
4848 frm.OperatingMode.rxNSS = 0;
4849 frm.OperatingMode.rxNSSType = 0;
4850
4851 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4852 if ( DOT11F_FAILED( nStatus ) )
4853 {
4854 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4855 "or a Operating Mode (0x%08x).\n"),
4856 nStatus );
4857 // We'll fall back on the worst case scenario:
4858 nPayload = sizeof( tDot11fOperatingMode);
4859 }
4860 else if ( DOT11F_WARNED( nStatus ) )
4861 {
4862 limLog( pMac, LOGW, FL("There were warnings while calculating"
4863 "the packed size for a Operating Mode (0x"
4864 "%08x).\n"), nStatus );
4865 }
4866
4867 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4868
4869 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4870 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4871 {
4872 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
4873 " Report.\n"), nBytes );
4874 return eSIR_FAILURE;
4875 }
4876
4877 // Paranoia:
4878 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4879
4880
4881 // Next, we fill out the buffer descriptor:
4882 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4883 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4884 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4885 } else
4886 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4887 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4888 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4889 palCopyMemory( pMac->hHdd,
4890 (tANI_U8 *) pMacHdr->bssId,
4891 (tANI_U8 *) psessionEntry->bssId,
4892 sizeof( tSirMacAddr ));
4893 if ( eSIR_SUCCESS != nSirStatus )
4894 {
4895 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4896 "tor for a Operating Mode (%d).\n"),
4897 nSirStatus );
4898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4899 return eSIR_FAILURE; // just allocated...
4900 }
4901 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4902 sizeof(tSirMacMgmtHdr),
4903 nPayload, &nPayload );
4904 if ( DOT11F_FAILED( nStatus ) )
4905 {
4906 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x).\n"),
4907 nStatus );
4908 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4909 return eSIR_FAILURE; // allocated!
4910 }
4911 else if ( DOT11F_WARNED( nStatus ) )
4912 {
4913 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
4914 " (0x%08x).\n") );
4915 }
4916 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
4917#ifdef WLAN_FEATURE_P2P
4918 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4919 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
4920#endif
4921 )
4922 {
4923 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4924 }
4925 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4926 HAL_TXRX_FRM_802_11_MGMT,
4927 ANI_TXDIR_TODS,
4928 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4929 limTxComplete, pFrame, txFlag );
4930 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4931 {
4932 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4933 "(%X)!\n"),
4934 nSirStatus );
4935 //Pkt will be freed up by the callback
4936 return eSIR_FAILURE;
4937 }
4938
4939 return eSIR_SUCCESS;
4940}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004941
4942/**
4943 * \brief Send a VHT Channel Switch Announcement
4944 *
4945 *
4946 * \param pMac Pointer to the global MAC datastructure
4947 *
4948 * \param peer MAC address to which this frame will be sent
4949 *
4950 * \param nChanWidth
4951 *
4952 * \param nNewChannel
4953 *
4954 *
4955 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4956 *
4957 *
4958 */
4959
4960tSirRetStatus
4961limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4962 tSirMacAddr peer,
4963 tANI_U8 nChanWidth,
4964 tANI_U8 nNewChannel,
4965 tANI_U8 ncbMode,
4966 tpPESession psessionEntry )
4967{
4968 tDot11fChannelSwitch frm;
4969 tANI_U8 *pFrame;
4970 tSirRetStatus nSirStatus;
4971 tpSirMacMgmtHdr pMacHdr;
4972 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4973 void *pPacket;
4974 eHalStatus halstatus;
4975 tANI_U8 txFlag = 0;
4976
4977 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4978
4979
4980 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4981 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4982 frm.ChanSwitchAnn.switchMode = 1;
4983 frm.ChanSwitchAnn.newChannel = nNewChannel;
4984 frm.ChanSwitchAnn.switchCount = 1;
4985 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4986 frm.ExtChanSwitchAnn.present = 1;
4987 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4988 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4989 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4990 frm.ChanSwitchAnn.present = 1;
4991 frm.WiderBWChanSwitchAnn.present = 1;
4992
4993 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4994 if ( DOT11F_FAILED( nStatus ) )
4995 {
4996 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4997 "or a Channel Switch (0x%08x).\n"),
4998 nStatus );
4999 // We'll fall back on the worst case scenario:
5000 nPayload = sizeof( tDot11fChannelSwitch );
5001 }
5002 else if ( DOT11F_WARNED( nStatus ) )
5003 {
5004 limLog( pMac, LOGW, FL("There were warnings while calculating"
5005 "the packed size for a Channel Switch (0x"
5006 "%08x).\n"), nStatus );
5007 }
5008
5009 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5010
5011 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5012 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5013 {
5014 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
5015 " Report.\n"), nBytes );
5016 return eSIR_FAILURE;
5017 }
5018 // Paranoia:
5019 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5020
5021 // Next, we fill out the buffer descriptor:
5022 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5023 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5024 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5025 palCopyMemory( pMac->hHdd,
5026 (tANI_U8 *) pMacHdr->bssId,
5027 (tANI_U8 *) psessionEntry->bssId,
5028 sizeof( tSirMacAddr ));
5029 if ( eSIR_SUCCESS != nSirStatus )
5030 {
5031 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
5032 "tor for a Channel Switch (%d).\n"),
5033 nSirStatus );
5034 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5035 return eSIR_FAILURE; // just allocated...
5036 }
5037 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5038 sizeof(tSirMacMgmtHdr),
5039 nPayload, &nPayload );
5040 if ( DOT11F_FAILED( nStatus ) )
5041 {
5042 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
5043 nStatus );
5044 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5045 return eSIR_FAILURE; // allocated!
5046 }
5047 else if ( DOT11F_WARNED( nStatus ) )
5048 {
5049 limLog( pMac, LOGW, FL("There were warnings while packing a C"
5050 "hannel Switch (0x%08x).\n") );
5051 }
5052
5053 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5054#ifdef WLAN_FEATURE_P2P
5055 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5056 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5057#endif
5058 )
5059 {
5060 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5061 }
5062 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5063 HAL_TXRX_FRM_802_11_MGMT,
5064 ANI_TXDIR_TODS,
5065 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5066 limTxComplete, pFrame, txFlag );
5067 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5068 {
5069 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
5070 "(%X)!\n"),
5071 nSirStatus );
5072 //Pkt will be freed up by the callback
5073 return eSIR_FAILURE;
5074 }
5075
5076 return eSIR_SUCCESS;
5077
5078} // End limSendVHTChannelSwitchMgmtFrame.
5079
5080
5081
Mohit Khanna4a70d262012-09-11 16:30:12 -07005082#endif
5083
Jeff Johnson295189b2012-06-20 16:38:30 -07005084/**
5085 * \brief Send an ADDBA Req Action Frame to peer
5086 *
5087 * \sa limSendAddBAReq
5088 *
5089 * \param pMac The global tpAniSirGlobal object
5090 *
5091 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5092 * the necessary parameters reqd by PE send the ADDBA Req Action
5093 * Frame to the peer
5094 *
5095 * \return eSIR_SUCCESS if setup completes successfully
5096 * eSIR_FAILURE is some problem is encountered
5097 */
5098tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
5099 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
5100{
5101 tDot11fAddBAReq frmAddBAReq;
5102 tANI_U8 *pAddBAReqBuffer = NULL;
5103 tpSirMacMgmtHdr pMacHdr;
5104 tANI_U32 frameLen = 0, nStatus, nPayload;
5105 tSirRetStatus statusCode;
5106 eHalStatus halStatus;
5107 void *pPacket;
5108 tANI_U8 txFlag = 0;
5109
5110 if(NULL == psessionEntry)
5111 {
5112 return eSIR_FAILURE;
5113 }
5114
5115 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
5116
5117 // Category - 3 (BA)
5118 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5119
5120 // Action - 0 (ADDBA Req)
5121 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5122
5123 // FIXME - Dialog Token, generalize this...
5124 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5125
5126 // Fill the ADDBA Parameter Set
5127 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5128 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5129 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5130
5131 // BA timeout
5132 // 0 - indicates no BA timeout
5133 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5134
5135 // BA Starting Sequence Number
5136 // Fragment number will always be zero
5137 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5138 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5139 }
5140
5141 frmAddBAReq.BAStartingSequenceControl.ssn =
5142 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5143
5144 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5145
5146 if( DOT11F_FAILED( nStatus ))
5147 {
5148 limLog( pMac, LOGW,
5149 FL( "Failed to calculate the packed size for "
5150 "an ADDBA Request (0x%08x).\n"),
5151 nStatus );
5152
5153 // We'll fall back on the worst case scenario:
5154 nPayload = sizeof( tDot11fAddBAReq );
5155 }
5156 else if( DOT11F_WARNED( nStatus ))
5157 {
5158 limLog( pMac, LOGW,
5159 FL( "There were warnings while calculating"
5160 "the packed size for an ADDBA Req (0x%08x).\n"),
5161 nStatus );
5162 }
5163
5164 // Add the MGMT header to frame length
5165 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5166
5167 // Need to allocate a buffer for ADDBA AF
5168 if( eHAL_STATUS_SUCCESS !=
5169 (halStatus = palPktAlloc( pMac->hHdd,
5170 HAL_TXRX_FRM_802_11_MGMT,
5171 (tANI_U16) frameLen,
5172 (void **) &pAddBAReqBuffer,
5173 (void **) &pPacket )))
5174 {
5175 // Log error
5176 limLog( pMac, LOGP,
5177 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5178 frameLen,
5179 halStatus );
5180
5181 statusCode = eSIR_MEM_ALLOC_FAILED;
5182 goto returnAfterError;
5183 }
5184
5185 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
5186
5187 // Copy necessary info to BD
5188 if( eSIR_SUCCESS !=
5189 (statusCode = limPopulateMacHeader( pMac,
5190 pAddBAReqBuffer,
5191 SIR_MAC_MGMT_FRAME,
5192 SIR_MAC_MGMT_ACTION,
5193 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5194 goto returnAfterError;
5195
5196 // Update A3 with the BSSID
5197 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5198
5199 #if 0
5200 cfgLen = SIR_MAC_ADDR_LENGTH;
5201 if( eSIR_SUCCESS != cfgGetStr( pMac,
5202 WNI_CFG_BSSID,
5203 (tANI_U8 *) pMacHdr->bssId,
5204 &cfgLen ))
5205 {
5206 limLog( pMac, LOGP,
5207 FL( "Failed to retrieve WNI_CFG_BSSID while"
5208 "sending an ACTION Frame\n" ));
5209
5210 // FIXME - Need to convert to tSirRetStatus
5211 statusCode = eSIR_FAILURE;
5212 goto returnAfterError;
5213 }
5214 #endif//TO SUPPORT BT-AMP
5215 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5216
5217 // Now, we're ready to "pack" the frames
5218 nStatus = dot11fPackAddBAReq( pMac,
5219 &frmAddBAReq,
5220 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5221 nPayload,
5222 &nPayload );
5223
5224 if( DOT11F_FAILED( nStatus ))
5225 {
5226 limLog( pMac, LOGE,
5227 FL( "Failed to pack an ADDBA Req (0x%08x).\n" ),
5228 nStatus );
5229
5230 // FIXME - Need to convert to tSirRetStatus
5231 statusCode = eSIR_FAILURE;
5232 goto returnAfterError;
5233 }
5234 else if( DOT11F_WARNED( nStatus ))
5235 {
5236 limLog( pMac, LOGW,
5237 FL( "There were warnings while packing an ADDBA Req (0x%08x).\n" ));
5238 }
5239
5240 limLog( pMac, LOGW,
5241 FL( "Sending an ADDBA REQ to \n" ));
5242 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5243
5244 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5245#ifdef WLAN_FEATURE_P2P
5246 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5247 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5248#endif
5249 )
5250 {
5251 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5252 }
5253
5254 if( eHAL_STATUS_SUCCESS !=
5255 (halStatus = halTxFrame( pMac,
5256 pPacket,
5257 (tANI_U16) frameLen,
5258 HAL_TXRX_FRM_802_11_MGMT,
5259 ANI_TXDIR_TODS,
5260 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5261 limTxComplete,
5262 pAddBAReqBuffer, txFlag )))
5263 {
5264 limLog( pMac, LOGE,
5265 FL( "halTxFrame FAILED! Status [%d]\n"),
5266 halStatus );
5267
5268 // FIXME - Need to convert eHalStatus to tSirRetStatus
5269 statusCode = eSIR_FAILURE;
5270 //Pkt will be freed up by the callback
5271 return statusCode;
5272 }
5273 else
5274 return eSIR_SUCCESS;
5275
5276returnAfterError:
5277
5278 // Release buffer, if allocated
5279 if( NULL != pAddBAReqBuffer )
5280 palPktFree( pMac->hHdd,
5281 HAL_TXRX_FRM_802_11_MGMT,
5282 (void *) pAddBAReqBuffer,
5283 (void *) pPacket );
5284
5285 return statusCode;
5286}
5287
5288/**
5289 * \brief Send an ADDBA Rsp Action Frame to peer
5290 *
5291 * \sa limSendAddBARsp
5292 *
5293 * \param pMac The global tpAniSirGlobal object
5294 *
5295 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5296 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5297 * Frame to the peer
5298 *
5299 * \return eSIR_SUCCESS if setup completes successfully
5300 * eSIR_FAILURE is some problem is encountered
5301 */
5302tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5303 tpLimMlmAddBARsp pMlmAddBARsp,
5304 tpPESession psessionEntry)
5305{
5306 tDot11fAddBARsp frmAddBARsp;
5307 tANI_U8 *pAddBARspBuffer = NULL;
5308 tpSirMacMgmtHdr pMacHdr;
5309 tANI_U32 frameLen = 0, nStatus, nPayload;
5310 tSirRetStatus statusCode;
5311 eHalStatus halStatus;
5312 void *pPacket;
5313 tANI_U8 txFlag = 0;
5314
5315 if(NULL == psessionEntry)
5316 {
5317 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!\n"));)
5318 return eSIR_FAILURE;
5319 }
5320
5321 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
5322
5323 // Category - 3 (BA)
5324 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5325 // Action - 1 (ADDBA Rsp)
5326 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5327
5328 // Should be same as the one we received in the ADDBA Req
5329 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5330
5331 // ADDBA Req status
5332 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5333
5334 // Fill the ADDBA Parameter Set as provided by caller
5335 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5336 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5337 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
5338
5339 // BA timeout
5340 // 0 - indicates no BA timeout
5341 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5342
5343 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5344
5345 if( DOT11F_FAILED( nStatus ))
5346 {
5347 limLog( pMac, LOGW,
5348 FL( "Failed to calculate the packed size for "
5349 "an ADDBA Response (0x%08x).\n"),
5350 nStatus );
5351
5352 // We'll fall back on the worst case scenario:
5353 nPayload = sizeof( tDot11fAddBARsp );
5354 }
5355 else if( DOT11F_WARNED( nStatus ))
5356 {
5357 limLog( pMac, LOGW,
5358 FL( "There were warnings while calculating"
5359 "the packed size for an ADDBA Rsp (0x%08x).\n"),
5360 nStatus );
5361 }
5362
5363 // Need to allocate a buffer for ADDBA AF
5364 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5365
5366 // Allocate shared memory
5367 if( eHAL_STATUS_SUCCESS !=
5368 (halStatus = palPktAlloc( pMac->hHdd,
5369 HAL_TXRX_FRM_802_11_MGMT,
5370 (tANI_U16) frameLen,
5371 (void **) &pAddBARspBuffer,
5372 (void **) &pPacket )))
5373 {
5374 // Log error
5375 limLog( pMac, LOGP,
5376 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5377 frameLen,
5378 halStatus );
5379
5380 statusCode = eSIR_MEM_ALLOC_FAILED;
5381 goto returnAfterError;
5382 }
5383
5384 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5385
5386 // Copy necessary info to BD
5387 if( eSIR_SUCCESS !=
5388 (statusCode = limPopulateMacHeader( pMac,
5389 pAddBARspBuffer,
5390 SIR_MAC_MGMT_FRAME,
5391 SIR_MAC_MGMT_ACTION,
5392 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5393 goto returnAfterError;
5394
5395 // Update A3 with the BSSID
5396
5397 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5398
5399 #if 0
5400 cfgLen = SIR_MAC_ADDR_LENGTH;
5401 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5402 WNI_CFG_BSSID,
5403 (tANI_U8 *) pMacHdr->bssId,
5404 &cfgLen ))
5405 {
5406 limLog( pMac, LOGP,
5407 FL( "Failed to retrieve WNI_CFG_BSSID while"
5408 "sending an ACTION Frame\n" ));
5409
5410 // FIXME - Need to convert to tSirRetStatus
5411 statusCode = eSIR_FAILURE;
5412 goto returnAfterError;
5413 }
5414 #endif // TO SUPPORT BT-AMP
5415 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5416
5417 // Now, we're ready to "pack" the frames
5418 nStatus = dot11fPackAddBARsp( pMac,
5419 &frmAddBARsp,
5420 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5421 nPayload,
5422 &nPayload );
5423
5424 if( DOT11F_FAILED( nStatus ))
5425 {
5426 limLog( pMac, LOGE,
5427 FL( "Failed to pack an ADDBA Rsp (0x%08x).\n" ),
5428 nStatus );
5429
5430 // FIXME - Need to convert to tSirRetStatus
5431 statusCode = eSIR_FAILURE;
5432 goto returnAfterError;
5433 }
5434 else if( DOT11F_WARNED( nStatus ))
5435 {
5436 limLog( pMac, LOGW,
5437 FL( "There were warnings while packing an ADDBA Rsp (0x%08x).\n" ));
5438 }
5439
5440 limLog( pMac, LOGW,
5441 FL( "Sending an ADDBA RSP to \n" ));
5442 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5443
5444 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5445#ifdef WLAN_FEATURE_P2P
5446 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5447 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5448#endif
5449 )
5450 {
5451 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5452 }
5453
5454 if( eHAL_STATUS_SUCCESS !=
5455 (halStatus = halTxFrame( pMac,
5456 pPacket,
5457 (tANI_U16) frameLen,
5458 HAL_TXRX_FRM_802_11_MGMT,
5459 ANI_TXDIR_TODS,
5460 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5461 limTxComplete,
5462 pAddBARspBuffer, txFlag )))
5463 {
5464 limLog( pMac, LOGE,
5465 FL( "halTxFrame FAILED! Status [%d]\n" ),
5466 halStatus );
5467
5468 // FIXME - HAL error codes are different from PE error
5469 // codes!! And, this routine is returning tSirRetStatus
5470 statusCode = eSIR_FAILURE;
5471 //Pkt will be freed up by the callback
5472 return statusCode;
5473 }
5474 else
5475 return eSIR_SUCCESS;
5476
5477 returnAfterError:
5478
5479 // Release buffer, if allocated
5480 if( NULL != pAddBARspBuffer )
5481 palPktFree( pMac->hHdd,
5482 HAL_TXRX_FRM_802_11_MGMT,
5483 (void *) pAddBARspBuffer,
5484 (void *) pPacket );
5485
5486 return statusCode;
5487}
5488
5489/**
5490 * \brief Send a DELBA Indication Action Frame to peer
5491 *
5492 * \sa limSendDelBAInd
5493 *
5494 * \param pMac The global tpAniSirGlobal object
5495 *
5496 * \param peerMacAddr MAC Address of peer
5497 *
5498 * \param reasonCode Reason for the DELBA notification
5499 *
5500 * \param pBAParameterSet The DELBA Parameter Set.
5501 * This identifies the TID for which the BA session is
5502 * being deleted.
5503 *
5504 * \return eSIR_SUCCESS if setup completes successfully
5505 * eSIR_FAILURE is some problem is encountered
5506 */
5507tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5508 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5509{
5510 tDot11fDelBAInd frmDelBAInd;
5511 tANI_U8 *pDelBAIndBuffer = NULL;
5512 //tANI_U32 val;
5513 tpSirMacMgmtHdr pMacHdr;
5514 tANI_U32 frameLen = 0, nStatus, nPayload;
5515 tSirRetStatus statusCode;
5516 eHalStatus halStatus;
5517 void *pPacket;
5518 tANI_U8 txFlag = 0;
5519
5520 if(NULL == psessionEntry)
5521 {
5522 return eSIR_FAILURE;
5523 }
5524
5525 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5526
5527 // Category - 3 (BA)
5528 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5529 // Action - 2 (DELBA)
5530 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5531
5532 // Fill the DELBA Parameter Set as provided by caller
5533 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5534 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5535
5536 // BA Starting Sequence Number
5537 // Fragment number will always be zero
5538 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5539
5540 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5541
5542 if( DOT11F_FAILED( nStatus ))
5543 {
5544 limLog( pMac, LOGW,
5545 FL( "Failed to calculate the packed size for "
5546 "an DELBA Indication (0x%08x).\n"),
5547 nStatus );
5548
5549 // We'll fall back on the worst case scenario:
5550 nPayload = sizeof( tDot11fDelBAInd );
5551 }
5552 else if( DOT11F_WARNED( nStatus ))
5553 {
5554 limLog( pMac, LOGW,
5555 FL( "There were warnings while calculating"
5556 "the packed size for an DELBA Ind (0x%08x).\n"),
5557 nStatus );
5558 }
5559
5560 // Add the MGMT header to frame length
5561 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5562
5563 // Allocate shared memory
5564 if( eHAL_STATUS_SUCCESS !=
5565 (halStatus = palPktAlloc( pMac->hHdd,
5566 HAL_TXRX_FRM_802_11_MGMT,
5567 (tANI_U16) frameLen,
5568 (void **) &pDelBAIndBuffer,
5569 (void **) &pPacket )))
5570 {
5571 // Log error
5572 limLog( pMac, LOGP,
5573 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5574 frameLen,
5575 halStatus );
5576
5577 statusCode = eSIR_MEM_ALLOC_FAILED;
5578 goto returnAfterError;
5579 }
5580
5581 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5582
5583 // Copy necessary info to BD
5584 if( eSIR_SUCCESS !=
5585 (statusCode = limPopulateMacHeader( pMac,
5586 pDelBAIndBuffer,
5587 SIR_MAC_MGMT_FRAME,
5588 SIR_MAC_MGMT_ACTION,
5589 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5590 goto returnAfterError;
5591
5592 // Update A3 with the BSSID
5593 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5594
5595 #if 0
5596 cfgLen = SIR_MAC_ADDR_LENGTH;
5597 if( eSIR_SUCCESS != cfgGetStr( pMac,
5598 WNI_CFG_BSSID,
5599 (tANI_U8 *) pMacHdr->bssId,
5600 &cfgLen ))
5601 {
5602 limLog( pMac, LOGP,
5603 FL( "Failed to retrieve WNI_CFG_BSSID while"
5604 "sending an ACTION Frame\n" ));
5605
5606 // FIXME - Need to convert to tSirRetStatus
5607 statusCode = eSIR_FAILURE;
5608 goto returnAfterError;
5609 }
5610 #endif //TO SUPPORT BT-AMP
5611 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5612
5613 // Now, we're ready to "pack" the frames
5614 nStatus = dot11fPackDelBAInd( pMac,
5615 &frmDelBAInd,
5616 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5617 nPayload,
5618 &nPayload );
5619
5620 if( DOT11F_FAILED( nStatus ))
5621 {
5622 limLog( pMac, LOGE,
5623 FL( "Failed to pack an DELBA Ind (0x%08x).\n" ),
5624 nStatus );
5625
5626 // FIXME - Need to convert to tSirRetStatus
5627 statusCode = eSIR_FAILURE;
5628 goto returnAfterError;
5629 }
5630 else if( DOT11F_WARNED( nStatus ))
5631 {
5632 limLog( pMac, LOGW,
5633 FL( "There were warnings while packing an DELBA Ind (0x%08x).\n" ));
5634 }
5635
5636 limLog( pMac, LOGW,
5637 FL( "Sending a DELBA IND to \n" ));
5638 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5639
5640 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5641#ifdef WLAN_FEATURE_P2P
5642 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5643 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5644#endif
5645 )
5646 {
5647 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5648 }
5649
5650 if( eHAL_STATUS_SUCCESS !=
5651 (halStatus = halTxFrame( pMac,
5652 pPacket,
5653 (tANI_U16) frameLen,
5654 HAL_TXRX_FRM_802_11_MGMT,
5655 ANI_TXDIR_TODS,
5656 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5657 limTxComplete,
5658 pDelBAIndBuffer, txFlag )))
5659 {
5660 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halStatus );)
5661 statusCode = eSIR_FAILURE;
5662 //Pkt will be freed up by the callback
5663 return statusCode;
5664 }
5665 else
5666 return eSIR_SUCCESS;
5667
5668 returnAfterError:
5669
5670 // Release buffer, if allocated
5671 if( NULL != pDelBAIndBuffer )
5672 palPktFree( pMac->hHdd,
5673 HAL_TXRX_FRM_802_11_MGMT,
5674 (void *) pDelBAIndBuffer,
5675 (void *) pPacket );
5676
5677 return statusCode;
5678}
5679
5680#if defined WLAN_FEATURE_VOWIFI
5681
5682/**
5683 * \brief Send a Neighbor Report Request Action frame
5684 *
5685 *
5686 * \param pMac Pointer to the global MAC structure
5687 *
5688 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5689 *
5690 * \param peer mac address of peer station.
5691 *
5692 * \param psessionEntry address of session entry.
5693 *
5694 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5695 *
5696 *
5697 */
5698
5699tSirRetStatus
5700limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5701 tpSirMacNeighborReportReq pNeighborReq,
5702 tSirMacAddr peer,
5703 tpPESession psessionEntry
5704 )
5705{
5706 tSirRetStatus statusCode = eSIR_SUCCESS;
5707 tDot11fNeighborReportRequest frm;
5708 tANI_U8 *pFrame;
5709 tpSirMacMgmtHdr pMacHdr;
5710 tANI_U32 nBytes, nPayload, nStatus;
5711 void *pPacket;
5712 eHalStatus halstatus;
5713 tANI_U8 txFlag = 0;
5714
5715 if ( psessionEntry == NULL )
5716 {
5717 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame\n") );
5718 return eSIR_FAILURE;
5719 }
5720 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5721
5722 frm.Category.category = SIR_MAC_ACTION_RRM;
5723 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5724 frm.DialogToken.token = pNeighborReq->dialogToken;
5725
5726
5727 if( pNeighborReq->ssid_present )
5728 {
5729 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5730 }
5731
5732 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5733 if ( DOT11F_FAILED( nStatus ) )
5734 {
5735 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5736 "or a Neighbor Report Request(0x%08x).\n"),
5737 nStatus );
5738 // We'll fall back on the worst case scenario:
5739 nPayload = sizeof( tDot11fNeighborReportRequest );
5740 }
5741 else if ( DOT11F_WARNED( nStatus ) )
5742 {
5743 limLog( pMac, LOGW, FL("There were warnings while calculating"
5744 "the packed size for a Neighbor Rep"
5745 "ort Request(0x%08x).\n"), nStatus );
5746 }
5747
5748 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5749
5750 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5751 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5752 {
5753 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
5754 "Report Request.\n"), nBytes );
5755 return eSIR_FAILURE;
5756 }
5757
5758 // Paranoia:
5759 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5760
5761 // Copy necessary info to BD
5762 if( eSIR_SUCCESS !=
5763 (statusCode = limPopulateMacHeader( pMac,
5764 pFrame,
5765 SIR_MAC_MGMT_FRAME,
5766 SIR_MAC_MGMT_ACTION,
5767 peer, psessionEntry->selfMacAddr)))
5768 goto returnAfterError;
5769
5770 // Update A3 with the BSSID
5771 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5772
5773 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5774
5775 // Now, we're ready to "pack" the frames
5776 nStatus = dot11fPackNeighborReportRequest( pMac,
5777 &frm,
5778 pFrame + sizeof( tSirMacMgmtHdr ),
5779 nPayload,
5780 &nPayload );
5781
5782 if( DOT11F_FAILED( nStatus ))
5783 {
5784 limLog( pMac, LOGE,
5785 FL( "Failed to pack an Neighbor Report Request (0x%08x).\n" ),
5786 nStatus );
5787
5788 // FIXME - Need to convert to tSirRetStatus
5789 statusCode = eSIR_FAILURE;
5790 goto returnAfterError;
5791 }
5792 else if( DOT11F_WARNED( nStatus ))
5793 {
5794 limLog( pMac, LOGW,
5795 FL( "There were warnings while packing Neighbor Report Request (0x%08x).\n" ));
5796 }
5797
5798 limLog( pMac, LOGW,
5799 FL( "Sending a Neighbor Report Request to \n" ));
5800 limPrintMacAddr( pMac, peer, LOGW );
5801
5802 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5803#ifdef WLAN_FEATURE_P2P
5804 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5805 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5806#endif
5807 )
5808 {
5809 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5810 }
5811
5812 if( eHAL_STATUS_SUCCESS !=
5813 (halstatus = halTxFrame( pMac,
5814 pPacket,
5815 (tANI_U16) nBytes,
5816 HAL_TXRX_FRM_802_11_MGMT,
5817 ANI_TXDIR_TODS,
5818 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5819 limTxComplete,
5820 pFrame, txFlag )))
5821 {
5822 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5823 statusCode = eSIR_FAILURE;
5824 //Pkt will be freed up by the callback
5825 return statusCode;
5826 }
5827 else
5828 return eSIR_SUCCESS;
5829
5830returnAfterError:
5831 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5832
5833 return statusCode;
5834} // End limSendNeighborReportRequestFrame.
5835
5836/**
5837 * \brief Send a Link Report Action frame
5838 *
5839 *
5840 * \param pMac Pointer to the global MAC structure
5841 *
5842 * \param pLinkReport Address of a tSirMacLinkReport
5843 *
5844 * \param peer mac address of peer station.
5845 *
5846 * \param psessionEntry address of session entry.
5847 *
5848 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5849 *
5850 *
5851 */
5852
5853tSirRetStatus
5854limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5855 tpSirMacLinkReport pLinkReport,
5856 tSirMacAddr peer,
5857 tpPESession psessionEntry
5858 )
5859{
5860 tSirRetStatus statusCode = eSIR_SUCCESS;
5861 tDot11fLinkMeasurementReport frm;
5862 tANI_U8 *pFrame;
5863 tpSirMacMgmtHdr pMacHdr;
5864 tANI_U32 nBytes, nPayload, nStatus;
5865 void *pPacket;
5866 eHalStatus halstatus;
5867 tANI_U8 txFlag = 0;
5868
5869
5870 if ( psessionEntry == NULL )
5871 {
5872 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame\n") );
5873 return eSIR_FAILURE;
5874 }
5875
5876 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5877
5878 frm.Category.category = SIR_MAC_ACTION_RRM;
5879 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5880 frm.DialogToken.token = pLinkReport->dialogToken;
5881
5882
5883 //IEEE Std. 802.11 7.3.2.18. for the report element.
5884 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5885 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5886 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5887 //such case this way than changing the frame parser.
5888 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5889 frm.TPCEleLen.TPCLen = 2;
5890 frm.TxPower.txPower = pLinkReport->txPower;
5891 frm.LinkMargin.linkMargin = 0;
5892
5893 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5894 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5895 frm.RCPI.rcpi = pLinkReport->rcpi;
5896 frm.RSNI.rsni = pLinkReport->rsni;
5897
5898 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5899 if ( DOT11F_FAILED( nStatus ) )
5900 {
5901 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5902 "or a Link Report (0x%08x).\n"),
5903 nStatus );
5904 // We'll fall back on the worst case scenario:
5905 nPayload = sizeof( tDot11fLinkMeasurementReport );
5906 }
5907 else if ( DOT11F_WARNED( nStatus ) )
5908 {
5909 limLog( pMac, LOGW, FL("There were warnings while calculating"
5910 "the packed size for a Link Rep"
5911 "ort (0x%08x).\n"), nStatus );
5912 }
5913
5914 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5915
5916 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5917 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5918 {
5919 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
5920 "Report.\n"), nBytes );
5921 return eSIR_FAILURE;
5922 }
5923
5924 // Paranoia:
5925 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5926
5927 // Copy necessary info to BD
5928 if( eSIR_SUCCESS !=
5929 (statusCode = limPopulateMacHeader( pMac,
5930 pFrame,
5931 SIR_MAC_MGMT_FRAME,
5932 SIR_MAC_MGMT_ACTION,
5933 peer, psessionEntry->selfMacAddr)))
5934 goto returnAfterError;
5935
5936 // Update A3 with the BSSID
5937 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5938
5939 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5940
5941 // Now, we're ready to "pack" the frames
5942 nStatus = dot11fPackLinkMeasurementReport( pMac,
5943 &frm,
5944 pFrame + sizeof( tSirMacMgmtHdr ),
5945 nPayload,
5946 &nPayload );
5947
5948 if( DOT11F_FAILED( nStatus ))
5949 {
5950 limLog( pMac, LOGE,
5951 FL( "Failed to pack an Link Report (0x%08x).\n" ),
5952 nStatus );
5953
5954 // FIXME - Need to convert to tSirRetStatus
5955 statusCode = eSIR_FAILURE;
5956 goto returnAfterError;
5957 }
5958 else if( DOT11F_WARNED( nStatus ))
5959 {
5960 limLog( pMac, LOGW,
5961 FL( "There were warnings while packing Link Report (0x%08x).\n" ));
5962 }
5963
5964 limLog( pMac, LOGW,
5965 FL( "Sending a Link Report to \n" ));
5966 limPrintMacAddr( pMac, peer, LOGW );
5967
5968 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
5969#ifdef WLAN_FEATURE_P2P
5970 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5971 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
5972#endif
5973 )
5974 {
5975 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5976 }
5977
5978 if( eHAL_STATUS_SUCCESS !=
5979 (halstatus = halTxFrame( pMac,
5980 pPacket,
5981 (tANI_U16) nBytes,
5982 HAL_TXRX_FRM_802_11_MGMT,
5983 ANI_TXDIR_TODS,
5984 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5985 limTxComplete,
5986 pFrame, txFlag )))
5987 {
5988 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5989 statusCode = eSIR_FAILURE;
5990 //Pkt will be freed up by the callback
5991 return statusCode;
5992 }
5993 else
5994 return eSIR_SUCCESS;
5995
5996returnAfterError:
5997 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5998
5999 return statusCode;
6000} // End limSendLinkReportActionFrame.
6001
6002/**
6003 * \brief Send a Beacon Report Action frame
6004 *
6005 *
6006 * \param pMac Pointer to the global MAC structure
6007 *
6008 * \param dialog_token dialog token to be used in the action frame.
6009 *
6010 * \param num_report number of reports in pRRMReport.
6011 *
6012 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6013 *
6014 * \param peer mac address of peer station.
6015 *
6016 * \param psessionEntry address of session entry.
6017 *
6018 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6019 *
6020 *
6021 */
6022
6023tSirRetStatus
6024limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6025 tANI_U8 dialog_token,
6026 tANI_U8 num_report,
6027 tpSirMacRadioMeasureReport pRRMReport,
6028 tSirMacAddr peer,
6029 tpPESession psessionEntry
6030 )
6031{
6032 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 tANI_U8 *pFrame;
6034 tpSirMacMgmtHdr pMacHdr;
6035 tANI_U32 nBytes, nPayload, nStatus;
6036 void *pPacket;
6037 eHalStatus halstatus;
6038 tANI_U8 i;
6039 tANI_U8 txFlag = 0;
6040
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006041 tDot11fRadioMeasurementReport *frm =
6042 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6043 if (!frm) {
6044 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport\n") );
6045 return eSIR_FAILURE;
6046 }
6047
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 if ( psessionEntry == NULL )
6049 {
6050 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame\n") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006051 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 return eSIR_FAILURE;
6053 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006054 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07006055
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006056 frm->Category.category = SIR_MAC_ACTION_RRM;
6057 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6058 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006059
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006060 frm->num_MeasurementReport = (num_report > RADIO_REPORTS_MAX_IN_A_FRAME ) ? RADIO_REPORTS_MAX_IN_A_FRAME : num_report;
Jeff Johnson295189b2012-06-20 16:38:30 -07006061
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006062 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006064 frm->MeasurementReport[i].type = pRRMReport[i].type;
6065 frm->MeasurementReport[i].token = pRRMReport[i].token;
6066 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 switch( pRRMReport[i].type )
6068 {
6069 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006070 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6071 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6072 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6073 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 break;
6075 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306076 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6077 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006078 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 break;
6080 }
6081 }
6082
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006083 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 if ( DOT11F_FAILED( nStatus ) )
6085 {
6086 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6087 "or a Radio Measure Report (0x%08x).\n"),
6088 nStatus );
6089 // We'll fall back on the worst case scenario:
6090 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006091 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 return eSIR_FAILURE;
6093 }
6094 else if ( DOT11F_WARNED( nStatus ) )
6095 {
6096 limLog( pMac, LOGW, FL("There were warnings while calculating"
6097 "the packed size for a Radio Measure Rep"
6098 "ort (0x%08x).\n"), nStatus );
6099 }
6100
6101 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6102
6103 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6104 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6105 {
6106 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
6107 "Report.\n"), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006108 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 return eSIR_FAILURE;
6110 }
6111
6112 // Paranoia:
6113 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6114
6115 // Copy necessary info to BD
6116 if( eSIR_SUCCESS !=
6117 (statusCode = limPopulateMacHeader( pMac,
6118 pFrame,
6119 SIR_MAC_MGMT_FRAME,
6120 SIR_MAC_MGMT_ACTION,
6121 peer, psessionEntry->selfMacAddr)))
6122 goto returnAfterError;
6123
6124 // Update A3 with the BSSID
6125 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6126
6127 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6128
6129 // Now, we're ready to "pack" the frames
6130 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006131 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 pFrame + sizeof( tSirMacMgmtHdr ),
6133 nPayload,
6134 &nPayload );
6135
6136 if( DOT11F_FAILED( nStatus ))
6137 {
6138 limLog( pMac, LOGE,
6139 FL( "Failed to pack an Radio Measure Report (0x%08x).\n" ),
6140 nStatus );
6141
6142 // FIXME - Need to convert to tSirRetStatus
6143 statusCode = eSIR_FAILURE;
6144 goto returnAfterError;
6145 }
6146 else if( DOT11F_WARNED( nStatus ))
6147 {
6148 limLog( pMac, LOGW,
6149 FL( "There were warnings while packing Radio Measure Report (0x%08x).\n" ));
6150 }
6151
6152 limLog( pMac, LOGW,
6153 FL( "Sending a Radio Measure Report to \n" ));
6154 limPrintMacAddr( pMac, peer, LOGW );
6155
6156 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
6157#ifdef WLAN_FEATURE_P2P
6158 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6159 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
6160#endif
6161 )
6162 {
6163 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6164 }
6165
6166 if( eHAL_STATUS_SUCCESS !=
6167 (halstatus = halTxFrame( pMac,
6168 pPacket,
6169 (tANI_U16) nBytes,
6170 HAL_TXRX_FRM_802_11_MGMT,
6171 ANI_TXDIR_TODS,
6172 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6173 limTxComplete,
6174 pFrame, txFlag )))
6175 {
6176 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
6177 statusCode = eSIR_FAILURE;
6178 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006179 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 return statusCode;
6181 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006182 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006183 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006186
6187returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006188 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 return statusCode;
6191} // End limSendBeaconReportActionFrame.
6192
6193#endif
6194
6195#ifdef WLAN_FEATURE_11W
6196/**
6197 * \brief Send SA query response action frame to peer
6198 *
6199 * \sa limSendSaQueryResponseFrame
6200 *
6201 *
6202 * \param pMac The global tpAniSirGlobal object
6203 *
6204 * \param peer The Mac address of the AP to which this action frame is
6205addressed
6206 *
6207 * \param transId Transaction identifier received in SA query request action
6208frame
6209 *
6210 * \return eSIR_SUCCESS if setup completes successfully
6211 * eSIR_FAILURE is some problem is encountered
6212 */
6213
6214tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U16 transId,
6215tSirMacAddr peer,tpPESession psessionEntry)
6216{
6217
6218 tDot11wSaQueryRsp frm; // SA query reponse action frame
6219 tANI_U8 *pFrame;
6220 tSirRetStatus nSirStatus;
6221 tpSirMacMgmtHdr pMacHdr;
6222 tANI_U32 nBytes, nPayload;
6223 void *pPacket;
6224 eHalStatus halstatus;
6225 // Local variables used to dump prepared SA query response frame
6226 tANI_U8 *pDump;
6227 tANI_U16 dumpCount;
6228 tANI_U8 txFlag = 0;
6229 //tANI_U16 nBytes
6230
6231 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
6232 frm.category = SIR_MAC_ACTION_SA_QUERY;
6233 /*11w action fiedl is :
6234 action: 0 --> SA query request action frame
6235 action: 1 --> SA query response action frame */
6236 frm.action = 1;
6237 /*11w Draft9.0 SA query response transId is same as
6238 SA query request transId*/
6239 frm.transId = transId;
6240
6241 nPayload = sizeof(tDot11wSaQueryRsp);
6242 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6243 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6244 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6245 {
6246 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
6247 " action frame\n"), nBytes );
6248 return eSIR_FAILURE;
6249 }
6250
6251 // Paranoia:
6252 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6253
6254 // Next, we fill out the buffer descriptor:
6255 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
6256 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr );
6257 if ( eSIR_SUCCESS != nSirStatus )
6258 {
6259 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
6260 "tor for a TPC Report (%d).\n"),
6261 nSirStatus );
6262 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6263 return eSIR_FAILURE; // just allocated...
6264 }
6265
6266 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6267
6268 // Pack 11w SA query response frame
6269 DOT11F_MEMCPY(pMac, (tANI_U8 *)(pFrame + sizeof(tSirMacMgmtHdr)),(tANI_U8 *)&frm, nPayload);
6270 pDump = (tANI_U8 *) pFrame;
6271
6272 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
6273 HAL_TXRX_FRM_802_11_MGMT,
6274 ANI_TXDIR_TODS,
6275 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6276 limTxComplete, pFrame,txFlag);
6277 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6278 {
6279 limLog( pMac, LOGE, FL("Failed to send a SA Query resp frame "
6280 "(%X)!\n"),halstatus );
6281 //Pkt will be freed up by the callback
6282 return eSIR_FAILURE; // just allocated...
6283 }
6284
6285 return eSIR_SUCCESS;
6286}
6287#endif