blob: 0dbd4324b761b798584032db6876526b4c26fe20 [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"
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "cfgApi.h"
54#include "utilsApi.h"
55#include "limTypes.h"
56#include "limUtils.h"
57#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070058#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include "dot11f.h"
60#include "limStaHashApi.h"
61#include "schApi.h"
62#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080063#include "limAssocUtils.h"
64#include "limFT.h"
65
Jeff Johnson295189b2012-06-20 16:38:30 -070066#if defined WLAN_FEATURE_VOWIFI
67#include "rrmApi.h"
68#endif
69
70#ifdef FEATURE_WLAN_CCX
71#include <limCcxparserApi.h>
72#endif
73#include "wlan_qct_wda.h"
74#ifdef WLAN_FEATURE_11W
75#include "dot11fdefs.h"
76#endif
77
78
79////////////////////////////////////////////////////////////////////////
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081
82/**
83 *
84 * \brief This function is called by various LIM modules to prepare the
85 * 802.11 frame MAC header
86 *
87 *
88 * \param pMac Pointer to Global MAC structure
89 *
90 * \param pBD Pointer to the frame buffer that needs to be populate
91 *
92 * \param type Type of the frame
93 *
94 * \param subType Subtype of the frame
95 *
96 * \return eHalStatus
97 *
98 *
99 * The pFrameBuf argument points to the beginning of the frame buffer to
100 * which - a) The 802.11 MAC header is set b) Following this MAC header
101 * will be the MGMT frame payload The payload itself is populated by the
102 * caller API
103 *
104 *
105 */
106
107tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
108 tANI_U8* pBD,
109 tANI_U8 type,
110 tANI_U8 subType,
111 tSirMacAddr peerAddr ,tSirMacAddr selfMacAddr)
112{
113 tSirRetStatus statusCode = eSIR_SUCCESS;
114 tpSirMacMgmtHdr pMacHdr;
115
116 /// Prepare MAC management header
117 pMacHdr = (tpSirMacMgmtHdr) (pBD);
118
119 // Prepare FC
120 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 pMacHdr->fc.type = type;
122 pMacHdr->fc.subType = subType;
123
124 // Prepare Address 1
125 palCopyMemory( pMac->hHdd,
126 (tANI_U8 *) pMacHdr->da,
127 (tANI_U8 *) peerAddr,
128 sizeof( tSirMacAddr ));
129
130 // Prepare Address 2
131 #if 0
132 if ((statusCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMacHdr->sa,
133 &cfgLen)) != eSIR_SUCCESS)
134 {
135 // Could not get STA_ID from CFG. Log error.
136 limLog( pMac, LOGP,
137 FL("Failed to retrive STA_ID\n"));
138 return statusCode;
139 }
140 #endif// TO SUPPORT BT-AMP
141 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
142
143 // Prepare Address 3
144 palCopyMemory( pMac->hHdd,
145 (tANI_U8 *) pMacHdr->bssId,
146 (tANI_U8 *) peerAddr,
147 sizeof( tSirMacAddr ));
148 return statusCode;
149} /*** end limPopulateMacHeader() ***/
150
151/**
152 * \brief limSendProbeReqMgmtFrame
153 *
154 *
155 * \param pMac Pointer to Global MAC structure
156 *
157 * \param pSsid SSID to be sent in Probe Request frame
158 *
159 * \param bssid BSSID to be sent in Probe Request frame
160 *
161 * \param nProbeDelay probe delay to be used before sending Probe Request
162 * frame
163 *
164 * \param nChannelNum Channel # on which the Probe Request is going out
165 *
166 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
167 *
168 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
169 *
170 * This function is called by various LIM modules to send Probe Request frame
171 * during active scan/learn phase.
172 * Probe request is sent out in the following scenarios:
173 * --heartbeat failure: session needed
174 * --join req: session needed
175 * --foreground scan: no session
176 * --background scan: no session
177 * --schBeaconProcessing: to get EDCA parameters: session needed
178 *
179 *
180 */
181tSirRetStatus
182limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
183 tSirMacSSid *pSsid,
184 tSirMacAddr bssid,
185 tANI_U8 nChannelNum,
186 tSirMacAddr SelfMacAddr,
187 tANI_U32 dot11mode,
188 tANI_U32 nAdditionalIELen,
189 tANI_U8 *pAdditionalIE)
190{
191 tDot11fProbeRequest pr;
192 tANI_U32 nStatus, nBytes, nPayload;
193 tSirRetStatus nSirStatus;
194 tANI_U8 *pFrame;
195 void *pPacket;
196 eHalStatus halstatus;
197 tpPESession psessionEntry;
198 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 tANI_U8 txFlag = 0;
201
202#ifndef GEN4_SCAN
203 return eSIR_FAILURE;
204#endif
205
206#if defined ( ANI_DVT_DEBUG )
207 return eSIR_FAILURE;
208#endif
209
210 /*
211 * session context may or may not be present, when probe request needs to be sent out.
212 * following cases exist:
213 * --heartbeat failure: session needed
214 * --join req: session needed
215 * --foreground scan: no session
216 * --background scan: no session
217 * --schBeaconProcessing: to get EDCA parameters: session needed
218 * If session context does not exist, some IEs will be populated from CFGs,
219 * e.g. Supported and Extended rate set IEs
220 */
221 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
222
223 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
224 // and then hand it off to 'dot11fPackProbeRequest' (for
225 // serialization). We start by zero-initializing the structure:
226 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
227
228 // & delegating to assorted helpers:
229 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 if( nAdditionalIELen && pAdditionalIE )
232 {
233 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
234 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700235 /* Don't include 11b rate only when device is doing P2P Search */
236 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
237 ( p2pIe != NULL ) &&
238 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
239 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
240 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
241 ( ( psessionEntry != NULL ) &&
242 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
243 )
244 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700245 {
246 /* In the below API pass channel number > 14, do that it fills only
247 * 11a rates in supported rates */
248 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
249 }
250 else
251 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 PopulateDot11fSuppRates( pMac, nChannelNum,
253 &pr.SuppRates,psessionEntry);
254
255 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
256 {
257 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
258 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
261#if defined WLAN_FEATURE_VOWIFI
262 //Table 7-14 in IEEE Std. 802.11k-2008 says
263 //DS params "can" be present in RRM is disabled and "is" present if
264 //RRM is enabled. It should be ok even if we add it into probe req when
265 //RRM is not enabled.
266 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
267 //Call RRM module to get the tx power for management used.
268 {
269 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
270 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
271 }
272#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700275 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700277 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700279 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700281 } else { //psessionEntry == NULL
282 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700284 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
286 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800287
288 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
289 if( nChannelNum <= SIR_11B_CHANNEL_END)
290 {
291 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
292 pr.HTCaps.shortGI40MHz = 0;
293 }
294
Jeff Johnsone7245742012-09-05 17:12:55 -0700295#ifdef WLAN_FEATURE_11AC
296 if (psessionEntry != NULL ) {
297 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
298 //Include HT Capability IE
299 if (psessionEntry->vhtCapability)
300 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700301 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
302 }
303 } else {
304 if (IS_DOT11_MODE_VHT(dot11mode))
305 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700306 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
307 }
308 }
309#endif
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312 // That's it-- now we pack it. First, how much space are we going to
313 // need?
314 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
315 if ( DOT11F_FAILED( nStatus ) )
316 {
317 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
318 "or a Probe Request (0x%08x).\n"), nStatus );
319 // We'll fall back on the worst case scenario:
320 nPayload = sizeof( tDot11fProbeRequest );
321 }
322 else if ( DOT11F_WARNED( nStatus ) )
323 {
324 limLog( pMac, LOGW, FL("There were warnings while calculating"
325 "the packed size for a Probe Request ("
326 "0x%08x).\n"), nStatus );
327 }
328
329 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
330
331 // Ok-- try to allocate some memory:
332 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
333 ( tANI_U16 )nBytes, ( void** ) &pFrame,
334 ( void** ) &pPacket );
335 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
336 {
337 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
338 "be Request.\n"), nBytes );
339 return eSIR_MEM_ALLOC_FAILED;
340 }
341
342 // Paranoia:
343 palZeroMemory( pMac->hHdd, pFrame, nBytes );
344
345 // Next, we fill out the buffer descriptor:
346 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
347 SIR_MAC_MGMT_PROBE_REQ, bssid ,SelfMacAddr);
348 if ( eSIR_SUCCESS != nSirStatus )
349 {
350 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
351 "tor for a Probe Request (%d).\n"),
352 nSirStatus );
353 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
354 ( void* ) pFrame, ( void* ) pPacket );
355 return nSirStatus; // allocated!
356 }
357
358 // That done, pack the Probe Request:
359 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
360 sizeof( tSirMacMgmtHdr ),
361 nPayload, &nPayload );
362 if ( DOT11F_FAILED( nStatus ) )
363 {
364 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x).\n"),
365 nStatus );
366 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
367 return eSIR_FAILURE; // allocated!
368 }
369 else if ( DOT11F_WARNED( nStatus ) )
370 {
371 limLog( pMac, LOGW, FL("There were warnings while packing a P"
372 "robe Request (0x%08x).\n") );
373 }
374
375 // Append any AddIE if present.
376 if( nAdditionalIELen )
377 {
378 palCopyMemory( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
379 pAdditionalIE, nAdditionalIELen );
380 nPayload += nAdditionalIELen;
381 }
382
383 /* If this probe request is sent during P2P Search State, then we need
384 * to send it at OFDM rate.
385 */
386 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
388 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530389 /* For unicast probe req mgmt from Join function
390 we don't set above variables. So we need to add
391 one more check whether it is pePersona is P2P_CLIENT or not */
392 || ( ( psessionEntry != NULL ) &&
393 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 )
395 {
396 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
397 }
398
399
400 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
401 HAL_TXRX_FRM_802_11_MGMT,
402 ANI_TXDIR_TODS,
403 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
404 limTxComplete, pFrame, txFlag );
405 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
406 {
407 limLog( pMac, LOGE, FL("could not send Probe Request frame!\n" ));
408 //Pkt will be freed up by the callback
409 return eSIR_FAILURE;
410 }
411
412 return eSIR_SUCCESS;
413} // End limSendProbeReqMgmtFrame.
414
Jeff Johnson295189b2012-06-20 16:38:30 -0700415tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
416 tANI_U8* addIE, tANI_U16 *addnIELen,
417 tANI_U8 probeReqP2pIe)
418{
419 /* If Probe request doesn't have P2P IE, then take out P2P IE
420 from additional IE */
421 if(!probeReqP2pIe)
422 {
423 tANI_U8* tempbuf = NULL;
424 tANI_U16 tempLen = 0;
425 int left = *addnIELen;
426 v_U8_t *ptr = addIE;
427 v_U8_t elem_id, elem_len;
428
429 if(NULL == addIE)
430 {
431 PELOGE(limLog(pMac, LOGE,
432 FL(" NULL addIE pointer"));)
433 return eSIR_FAILURE;
434 }
435
436 if( (palAllocateMemory(pMac->hHdd, (void**)&tempbuf,
Jeff Johnson43971f52012-07-17 12:26:56 -0700437 left)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700438 {
439 PELOGE(limLog(pMac, LOGE,
440 FL("Unable to allocate memory to store addn IE"));)
441 return eSIR_MEM_ALLOC_FAILED;
442 }
443
444 while(left >= 2)
445 {
446 elem_id = ptr[0];
447 elem_len = ptr[1];
448 left -= 2;
449 if(elem_len > left)
450 {
451 limLog( pMac, LOGE,
452 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
453 elem_id,elem_len,left);
454 palFreeMemory(pMac->hHdd, tempbuf);
455 return eSIR_FAILURE;
456 }
457 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
458 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
459 {
460 palCopyMemory ( pMac->hHdd, tempbuf + tempLen, &ptr[0], elem_len + 2);
461 tempLen += (elem_len + 2);
462 }
463 left -= elem_len;
464 ptr += (elem_len + 2);
465 }
466 palCopyMemory ( pMac->hHdd, addIE, tempbuf, tempLen);
467 *addnIELen = tempLen;
468 palFreeMemory(pMac->hHdd, tempbuf);
469 }
470 return eSIR_SUCCESS;
471}
Jeff Johnson295189b2012-06-20 16:38:30 -0700472
473void
474limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
475 tSirMacAddr peerMacAddr,
476 tpAniSSID pSsid,
477 short nStaId,
478 tANI_U8 nKeepAlive,
479 tpPESession psessionEntry,
480 tANI_U8 probeReqP2pIe)
481{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700482 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 tSirRetStatus nSirStatus;
484 tANI_U32 cfg, nPayload, nBytes, nStatus;
485 tpSirMacMgmtHdr pMacHdr;
486 tANI_U8 *pFrame;
487 void *pPacket;
488 eHalStatus halstatus;
489 tANI_U32 addnIEPresent;
490 tANI_U32 addnIE1Len=0;
491 tANI_U32 addnIE2Len=0;
492 tANI_U32 addnIE3Len=0;
493 tANI_U16 totalAddnIeLen = 0;
494 tANI_U32 wpsApEnable=0, tmp;
495 tANI_U8 txFlag = 0;
496 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 tANI_U8 *pP2pIe = NULL;
498 tANI_U8 noaLen = 0;
499 tANI_U8 total_noaLen = 0;
500 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
501 + SIR_P2P_IE_HEADER_LEN];
502 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700503
504 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
505 {
506 return; // in this case.
507 }
508
509 if(NULL == psessionEntry)
510 {
511 return;
512 }
513
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700514 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
515 (void **)&pFrm, sizeof(tDot11fProbeResponse)))
516 {
517 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendProbeRspMgmtFrame\n") );
518 return;
519 }
520
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 // Fill out 'frm', after which we'll just hand the struct off to
522 // 'dot11fPackProbeResponse'.
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700523 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
525 // Timestamp to be updated by TFP, below.
526
527 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
529 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700530 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 }
532 else
533 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800534 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
535 if (eSIR_SUCCESS != nSirStatus)
536 {
537 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d).\n"),
538 nSirStatus );
539 return;
540 }
541 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700544 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
545 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700547 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700548
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700549 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
550 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700551
Jeff Johnson295189b2012-06-20 16:38:30 -0700552
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
554 {
555 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
556 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700557 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 }
559 }
560 else
561 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800562 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
563 limLog(pMac, LOGP,"Failed to cfg get id %d\n", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700564
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800565 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800567 if (wpsApEnable)
568 {
569 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
570 }
571
572 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
573 {
574 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
575 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
576 }
577
578 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
579 {
580 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
581 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
582 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700585 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
586 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700590 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592
593 // N.B. In earlier implementations, the RSN IE would be placed in
594 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
595 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700596 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700597
598 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700599 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700601 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700602 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700604#ifdef WLAN_FEATURE_11AC
605 if(psessionEntry->vhtCapability)
606 {
607 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response\n"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700608 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
609 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700610 // we do not support multi users yet
611 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700612 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700613 }
614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700615
616 if ( psessionEntry->pLimStartBssReq )
617 {
618 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700619 &pFrm->WPA );
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 PopulateDot11fRSN( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700621 &pFrm->RSN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 }
623
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700624 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700625
626#if defined(FEATURE_WLAN_WAPI)
627 if( psessionEntry->pLimStartBssReq )
628 {
629 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700630 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 }
632
633#endif // defined(FEATURE_WLAN_WAPI)
634
635
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700636 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 if ( DOT11F_FAILED( nStatus ) )
638 {
639 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
640 "or a Probe Response (0x%08x).\n"),
641 nStatus );
642 // We'll fall back on the worst case scenario:
643 nPayload = sizeof( tDot11fProbeResponse );
644 }
645 else if ( DOT11F_WARNED( nStatus ) )
646 {
647 limLog( pMac, LOGW, FL("There were warnings while calculating"
648 "the packed size for a Probe Response "
649 "(0x%08x).\n"), nStatus );
650 }
651
652 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
653
654 addnIEPresent = false;
655
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 if( pMac->lim.gpLimRemainOnChanReq )
657 {
658 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
659 }
660 //Only use CFG for non-listen mode. This CFG is not working for concurrency
661 //In listening mode, probe rsp IEs is passed in the message from SME to PE
662 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 {
664
665 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
666 &addnIEPresent) != eSIR_SUCCESS)
667 {
668 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700669 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 return;
671 }
672 }
673
674 if (addnIEPresent)
675 {
676 if( (palAllocateMemory(pMac->hHdd, (void**)&addIE,
Jeff Johnson43971f52012-07-17 12:26:56 -0700677 WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3 )) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 {
679 PELOGE(limLog(pMac, LOGE,
680 FL("Unable to allocate memory to store addn IE"));)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700681 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 return;
683 }
684
685 //Probe rsp IE available
686 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
687 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
688 {
689 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
690 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700691 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 return;
693 }
694 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
695 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
696 {
697 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
698 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
699 &addnIE1Len) )
700 {
701 limLog(pMac, LOGP,
702 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
703 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700704 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 return;
706 }
707 }
708
709 //Probe rsp IE available
710 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
711 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
712 {
713 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
714 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700715 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 return;
717 }
718 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
719 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
720 {
721 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
722 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
723 &addnIE2Len) )
724 {
725 limLog(pMac, LOGP,
726 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
727 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700728 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 return;
730 }
731 }
732
733 //Probe rsp IE available
734 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
735 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
736 {
737 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 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 (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
743 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
744 {
745 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
746 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
747 &addIE[addnIE1Len + addnIE2Len],
748 &addnIE3Len) )
749 {
750 limLog(pMac, LOGP,
751 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
752 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700753 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 return;
755 }
756 }
757 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
758
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
760 {
761 limLog(pMac, LOGP,
762 FL("Unable to get final Additional IE for Probe Req"));
763 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700764 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 return;
766 }
767 nBytes = nBytes + totalAddnIeLen;
768
769 if (probeReqP2pIe)
770 {
771 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
772 if (pP2pIe != NULL)
773 {
774 //get NoA attribute stream P2P IE
775 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
776 if (noaLen != 0)
777 {
778 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
779 &noaStream[0], noaLen);
780 nBytes = nBytes + total_noaLen;
781 }
782 }
783 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 }
785
786 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
787 ( tANI_U16 )nBytes, ( void** ) &pFrame,
788 ( void** ) &pPacket );
789 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
790 {
791 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
792 "be Response.\n"), nBytes );
793 if ( addIE != NULL )
794 {
795 palFreeMemory(pMac->hHdd, addIE);
796 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700797 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 return;
799 }
800
801 // Paranoia:
802 palZeroMemory( pMac->hHdd, pFrame, nBytes );
803
804 // Next, we fill out the buffer descriptor:
805 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
806 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
807 if ( eSIR_SUCCESS != nSirStatus )
808 {
809 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
810 "tor for a Probe Response (%d).\n"),
811 nSirStatus );
812 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
813 ( void* ) pFrame, ( void* ) pPacket );
814 if ( addIE != NULL )
815 {
816 palFreeMemory(pMac->hHdd, addIE);
817 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700818 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 return;
820 }
821
822 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
823
824 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
825
826 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700827 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 nPayload, &nPayload );
829 if ( DOT11F_FAILED( nStatus ) )
830 {
831 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x).\n"),
832 nStatus );
833 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
834 if ( addIE != NULL )
835 {
836 palFreeMemory(pMac->hHdd, addIE);
837 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700838 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 return; // allocated!
840 }
841 else if ( DOT11F_WARNED( nStatus ) )
842 {
843 limLog( pMac, LOGW, FL("There were warnings while packing a P"
844 "robe Response (0x%08x).\n") );
845 }
846
847 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
848 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
849
850 pMac->sys.probeRespond++;
851
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 if( pMac->lim.gpLimRemainOnChanReq )
853 {
854 palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
855 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
856 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700857
858 if ( addnIEPresent )
859 {
860 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -0700861 &addIE[0], totalAddnIeLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 {
863 limLog(pMac, LOGP, FL("Additional Probe Rp IE request failed while Appending: %x"),halstatus);
864 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
865 ( void* ) pFrame, ( void* ) pPacket );
866 if ( addIE != NULL )
867 {
868 palFreeMemory(pMac->hHdd, addIE);
869 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700870 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 if (noaLen != 0)
875 {
876 if (palCopyMemory ( pMac->hHdd, &pFrame[nBytes - (total_noaLen)],
Jeff Johnson43971f52012-07-17 12:26:56 -0700877 &noaIe[0], total_noaLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 {
879 limLog(pMac, LOGE,
880 FL("Not able to insert NoA because of length constraint"));
881 }
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883
884 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
886 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 )
888 {
889 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
890 }
891
892 // Queue Probe Response frame in high priority WQ
893 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
894 ( tANI_U16 ) nBytes,
895 HAL_TXRX_FRM_802_11_MGMT,
896 ANI_TXDIR_TODS,
897 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
898 limTxComplete, pFrame, txFlag );
899 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
900 {
901 limLog( pMac, LOGE, FL("Could not send Probe Response.\n") );
902 //Pkt will be freed up by the callback
903 }
904
905 if ( addIE != NULL )
906 {
907 palFreeMemory(pMac->hHdd, addIE);
908 }
909
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700910 palFreeMemory(pMac->hHdd, pFrm);
911 return;
912
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914} // End limSendProbeRspMgmtFrame.
915
916void
917limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
918 tSirMacAddr peerMacAddr,
919 tSirAddtsReqInfo *pAddTS,
920 tpPESession psessionEntry)
921{
922 tANI_U16 i;
923 tANI_U8 *pFrame;
924 tSirRetStatus nSirStatus;
925 tDot11fAddTSRequest AddTSReq;
926 tDot11fWMMAddTSRequest WMMAddTSReq;
927 tANI_U32 nPayload, nBytes, nStatus;
928 tpSirMacMgmtHdr pMacHdr;
929 void *pPacket;
930#ifdef FEATURE_WLAN_CCX
931 tANI_U32 phyMode;
932#endif
933 eHalStatus halstatus;
934 tANI_U8 txFlag = 0;
935
936 if(NULL == psessionEntry)
937 {
938 return;
939 }
940
941 if ( ! pAddTS->wmeTspecPresent )
942 {
943 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSReq, sizeof( AddTSReq ) );
944
945 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
946 AddTSReq.DialogToken.token = pAddTS->dialogToken;
947 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
948 if ( pAddTS->lleTspecPresent )
949 {
950 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
951 }
952 else
953 {
954 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
955 }
956
957 if ( pAddTS->lleTspecPresent )
958 {
959 AddTSReq.num_WMMTCLAS = 0;
960 AddTSReq.num_TCLAS = pAddTS->numTclas;
961 for ( i = 0; i < pAddTS->numTclas; ++i)
962 {
963 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
964 &AddTSReq.TCLAS[i] );
965 }
966 }
967 else
968 {
969 AddTSReq.num_TCLAS = 0;
970 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
971 for ( i = 0; i < pAddTS->numTclas; ++i)
972 {
973 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
974 &AddTSReq.WMMTCLAS[i] );
975 }
976 }
977
978 if ( pAddTS->tclasProcPresent )
979 {
980 if ( pAddTS->lleTspecPresent )
981 {
982 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
983 AddTSReq.TCLASSPROC.present = 1;
984 }
985 else
986 {
987 AddTSReq.WMMTCLASPROC.version = 1;
988 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
989 AddTSReq.WMMTCLASPROC.present = 1;
990 }
991 }
992
993 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
994 if ( DOT11F_FAILED( nStatus ) )
995 {
996 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
997 "or an Add TS Request (0x%08x).\n"),
998 nStatus );
999 // We'll fall back on the worst case scenario:
1000 nPayload = sizeof( tDot11fAddTSRequest );
1001 }
1002 else if ( DOT11F_WARNED( nStatus ) )
1003 {
1004 limLog( pMac, LOGW, FL("There were warnings while calculating"
1005 "the packed size for an Add TS Request"
1006 " (0x%08x).\n"), nStatus );
1007 }
1008 }
1009 else
1010 {
1011 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ) );
1012
1013 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1014 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1015 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1016
1017 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1018 WMMAddTSReq.StatusCode.statusCode = 0;
1019
1020 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1021#ifdef FEATURE_WLAN_CCX
1022 limGetPhyMode(pMac, &phyMode, psessionEntry);
1023
1024 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1025 {
1026 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1027 }
1028 else
1029 {
1030 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1031 }
1032 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1033#endif
1034 // fillWmeTspecIE
1035
1036 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1037 if ( DOT11F_FAILED( nStatus ) )
1038 {
1039 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1040 "or a WMM Add TS Request (0x%08x).\n"),
1041 nStatus );
1042 // We'll fall back on the worst case scenario:
1043 nPayload = sizeof( tDot11fAddTSRequest );
1044 }
1045 else if ( DOT11F_WARNED( nStatus ) )
1046 {
1047 limLog( pMac, LOGW, FL("There were warnings while calculating"
1048 "the packed size for a WMM Add TS Requ"
1049 "est (0x%08x).\n"), nStatus );
1050 }
1051 }
1052
1053 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1054
1055 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1056 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1057 ( void** ) &pPacket );
1058 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1059 {
1060 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1061 "d TS Request.\n"), nBytes );
1062 return;
1063 }
1064
1065 // Paranoia:
1066 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1067
1068 // Next, we fill out the buffer descriptor:
1069 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1070 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1071 if ( eSIR_SUCCESS != nSirStatus )
1072 {
1073 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1074 "tor for an Add TS Request (%d).\n"),
1075 nSirStatus );
1076 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1077 ( void* ) pFrame, ( void* ) pPacket );
1078 return;
1079 }
1080
1081 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1082
1083 #if 0
1084 cfgLen = SIR_MAC_ADDR_LENGTH;
1085 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1086 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1087 {
1088 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1089 "e sending an Add TS Request.\n") );
1090 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1091 ( void* ) pFrame, ( void* ) pPacket );
1092 return;
1093 }
1094 #endif //TO SUPPORT BT-AMP
1095
1096 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1097
Chet Lanctot186b5732013-03-18 10:26:30 -07001098#ifdef WLAN_FEATURE_11W
1099 if ( psessionEntry->limRmfEnabled )
1100 {
1101 pMacHdr->fc.wep = 1;
1102 }
1103#endif
1104
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 // That done, pack the struct:
1106 if ( ! pAddTS->wmeTspecPresent )
1107 {
1108 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1109 pFrame + sizeof(tSirMacMgmtHdr),
1110 nPayload, &nPayload );
1111 if ( DOT11F_FAILED( nStatus ) )
1112 {
1113 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
1114 "(0x%08x).\n"),
1115 nStatus );
1116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1117 return; // allocated!
1118 }
1119 else if ( DOT11F_WARNED( nStatus ) )
1120 {
1121 limLog( pMac, LOGW, FL("There were warnings while packing"
1122 "an Add TS Request (0x%08x).\n") );
1123 }
1124 }
1125 else
1126 {
1127 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1128 pFrame + sizeof(tSirMacMgmtHdr),
1129 nPayload, &nPayload );
1130 if ( DOT11F_FAILED( nStatus ) )
1131 {
1132 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
1133 "st (0x%08x).\n"),
1134 nStatus );
1135 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1136 return; // allocated!
1137 }
1138 else if ( DOT11F_WARNED( nStatus ) )
1139 {
1140 limLog( pMac, LOGW, FL("There were warnings while packing"
1141 "a WMM Add TS Request (0x%08x).\n") );
1142 }
1143 }
1144
1145 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1146 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1147
1148 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1150 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 )
1152 {
1153 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1154 }
1155
1156 // Queue Addts Response frame in high priority WQ
1157 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1158 HAL_TXRX_FRM_802_11_MGMT,
1159 ANI_TXDIR_TODS,
1160 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1161 limTxComplete, pFrame, txFlag );
1162 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1163 {
1164 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
1165 " (%X) ***\n" ), halstatus );
1166 //Pkt will be freed up by the callback
1167 }
1168
1169} // End limSendAddtsReqActionFrame.
1170
Jeff Johnson295189b2012-06-20 16:38:30 -07001171
1172
1173void
1174limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1175 tANI_U16 statusCode,
1176 tANI_U16 aid,
1177 tSirMacAddr peerMacAddr,
1178 tANI_U8 subType,
1179 tpDphHashNode pSta,tpPESession psessionEntry)
1180{
1181 static tDot11fAssocResponse frm;
1182 tANI_U8 *pFrame, *macAddr;
1183 tpSirMacMgmtHdr pMacHdr;
1184 tSirRetStatus nSirStatus;
1185 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1186 tHalBitVal qosMode, wmeMode;
1187 tANI_U32 nPayload, nBytes, nStatus;
1188 void *pPacket;
1189 eHalStatus halstatus;
1190 tUpdateBeaconParams beaconParams;
1191 tANI_U8 txFlag = 0;
1192 tANI_U32 addnIEPresent = false;
1193 tANI_U32 addnIELen=0;
1194 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1195 tpSirAssocReq pAssocReq = NULL;
1196
1197 if(NULL == psessionEntry)
1198 {
1199 return;
1200 }
1201
1202 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
1203
1204 limGetQosMode(psessionEntry, &qosMode);
1205 limGetWmeMode(psessionEntry, &wmeMode);
1206
1207 // An Add TS IE is added only if the AP supports it and the requesting
1208 // STA sent a traffic spec.
1209 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1210
1211 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1212
1213 frm.Status.status = statusCode;
1214
1215 frm.AID.associd = aid | LIM_AID_MASK;
1216
1217 if ( NULL == pSta )
1218 {
1219 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1220 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1221 }
1222 else
1223 {
1224 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1225 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1226 }
1227
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1229 {
1230 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1231 {
1232 pAssocReq =
1233 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1235 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1236 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 }
1239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001240
1241 if ( NULL != pSta )
1242 {
1243 if ( eHAL_SET == qosMode )
1244 {
1245 if ( pSta->lleEnabled )
1246 {
1247 lleMode = 1;
1248 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1249 {
1250 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1251
1252// FramesToDo:...
1253// if ( fAddTS )
1254// {
1255// tANI_U8 *pAf = pBody;
1256// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1257// tANI_U32 tlen;
1258// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1259// &tlen, bufLen - frameLen);
1260// } // End if on Add TS.
1261 }
1262 } // End if on .11e enabled in 'pSta'.
1263 } // End if on QOS Mode on.
1264
1265 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1266 {
1267 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1268 {
1269
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
1272 if ( pSta->wsmEnabled )
1273 {
1274 PopulateDot11fWMMCaps(&frm.WMMCaps );
1275 }
1276 }
1277 }
1278
1279 if ( pSta->aniPeer )
1280 {
1281 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1282 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1283 {
1284 edcaInclude = 1;
1285 }
1286
1287 } // End if on Airgo peer.
1288
1289 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001290 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001292 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001295
1296#ifdef WLAN_FEATURE_11AC
1297 if( pSta->mlmStaContext.vhtCapability &&
1298 psessionEntry->vhtCapability )
1299 {
1300 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response\n"));
1301 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1302 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Mohit Khanna4a70d262012-09-11 16:30:12 -07001303 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07001304 }
1305#endif
1306
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 } // End if on non-NULL 'pSta'.
1308
1309
1310 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1311
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1313 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1314 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
1317 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1318 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1319
1320 beaconParams.bssIdx = psessionEntry->bssIdx;
1321
1322 //Send message to HAL about beacon parameter change.
1323 if(beaconParams.paramChangeBitmap)
1324 {
1325 schSetFixedBeaconFields(pMac,psessionEntry);
1326 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1327 }
1328
1329 // Allocate a buffer for this frame:
1330 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1331 if ( DOT11F_FAILED( nStatus ) )
1332 {
1333 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1334 "or an Association Response (0x%08x).\n"),
1335 nStatus );
1336 return;
1337 }
1338 else if ( DOT11F_WARNED( nStatus ) )
1339 {
1340 limLog( pMac, LOGW, FL("There were warnings while calculating"
1341 "the packed size for an Association Re"
1342 "sponse (0x%08x).\n"), nStatus );
1343 }
1344
1345 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1346
1347 if ( pAssocReq != NULL )
1348 {
1349 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1350 &addnIEPresent) != eSIR_SUCCESS)
1351 {
1352 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
1353 return;
1354 }
1355
1356 if (addnIEPresent)
1357 {
1358 //Assoc rsp IE available
1359 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1360 &addnIELen) != eSIR_SUCCESS)
1361 {
1362 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
1363 return;
1364 }
1365
1366 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1367 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1368 {
1369 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1370 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1371 {
1372 nBytes = nBytes + addnIELen;
1373 }
1374 }
1375 }
1376 }
1377
1378 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1379 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1380 ( void** ) &pPacket );
1381 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1382 {
1383 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP.\n"));
1384 return;
1385 }
1386
1387 // Paranoia:
1388 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1389
1390 // Next, we fill out the buffer descriptor:
1391 nSirStatus = limPopulateMacHeader( pMac,
1392 pFrame,
1393 SIR_MAC_MGMT_FRAME,
1394 ( LIM_ASSOC == subType ) ?
1395 SIR_MAC_MGMT_ASSOC_RSP :
1396 SIR_MAC_MGMT_REASSOC_RSP,
1397 peerMacAddr,psessionEntry->selfMacAddr);
1398 if ( eSIR_SUCCESS != nSirStatus )
1399 {
1400 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1401 "tor for an Association Response (%d).\n"),
1402 nSirStatus );
1403 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1404 ( void* ) pFrame, ( void* ) pPacket );
1405 return;
1406 }
1407
1408 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1409
1410 #if 0
1411 cfgLen = SIR_MAC_ADDR_LENGTH;
1412 if ( eSIR_SUCCESS != cfgGetStr( pMac, WNI_CFG_BSSID,
1413 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1414 {
1415 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1416 "e sending an Association Response.\n") );
1417 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1418 return; // allocated!
1419 }
1420 #endif //TO SUPPORT BT-AMP
1421 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1422
1423 nStatus = dot11fPackAssocResponse( pMac, &frm,
1424 pFrame + sizeof( tSirMacMgmtHdr ),
1425 nPayload, &nPayload );
1426 if ( DOT11F_FAILED( nStatus ) )
1427 {
1428 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x).\n"),
1429 nStatus );
1430 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1431 ( void* ) pFrame, ( void* ) pPacket );
1432 return; // allocated!
1433 }
1434 else if ( DOT11F_WARNED( nStatus ) )
1435 {
1436 limLog( pMac, LOGW, FL("There were warnings while packing an "
1437 "Association Response (0x%08x).\n") );
1438 }
1439
1440 macAddr = pMacHdr->da;
1441
1442 if (subType == LIM_ASSOC)
1443 {
1444 PELOG1(limLog(pMac, LOG1,
1445 FL("*** Sending Assoc Resp status %d aid %d to "),
1446 statusCode, aid);)
1447 }
1448 else{
1449 PELOG1(limLog(pMac, LOG1,
1450 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1451 statusCode, aid);)
1452 }
1453 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1454
1455 if ( addnIEPresent )
1456 {
1457 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -07001458 &addIE[0], addnIELen ) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 {
1460 limLog(pMac, LOGP, FL("Additional Assoc IEs request failed while Appending: %x\n"),halstatus);
1461 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1462 ( void* ) pFrame, ( void* ) pPacket );
1463 return;
1464 }
1465 }
1466
1467 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1469 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 )
1471 {
1472 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1473 }
1474
1475 /// Queue Association Response frame in high priority WQ
1476 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1477 HAL_TXRX_FRM_802_11_MGMT,
1478 ANI_TXDIR_TODS,
1479 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1480 limTxComplete, pFrame, txFlag );
1481 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1482 {
1483 limLog(pMac, LOGE,
1484 FL("*** Could not Send Re/AssocRsp, retCode=%X ***\n"),
1485 nSirStatus);
1486
1487 //Pkt will be freed up by the callback
1488 }
1489
1490 // update the ANI peer station count
1491 //FIXME_PROTECTION : take care of different type of station
1492 // counter inside this function.
1493 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1494
1495} // End limSendAssocRspMgmtFrame.
1496
1497
1498
1499void
1500limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1501 tSirMacAddr peer,
1502 tANI_U16 nStatusCode,
1503 tSirAddtsReqInfo *pAddTS,
1504 tSirMacScheduleIE *pSchedule,
1505 tpPESession psessionEntry)
1506{
1507 tANI_U8 *pFrame;
1508 tpSirMacMgmtHdr pMacHdr;
1509 tDot11fAddTSResponse AddTSRsp;
1510 tDot11fWMMAddTSResponse WMMAddTSRsp;
1511 tSirRetStatus nSirStatus;
1512 tANI_U32 i, nBytes, nPayload, nStatus;
1513 void *pPacket;
1514 eHalStatus halstatus;
1515 tANI_U8 txFlag = 0;
1516
1517 if(NULL == psessionEntry)
1518 {
1519 return;
1520 }
1521
1522 if ( ! pAddTS->wmeTspecPresent )
1523 {
1524 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ) );
1525
1526 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1527 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1528 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1529 AddTSRsp.Status.status = nStatusCode;
1530
1531 // The TsDelay information element is only filled in for a specific
1532 // status code:
1533 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1534 {
1535 if ( pAddTS->wsmTspecPresent )
1536 {
1537 AddTSRsp.WMMTSDelay.version = 1;
1538 AddTSRsp.WMMTSDelay.delay = 10;
1539 AddTSRsp.WMMTSDelay.present = 1;
1540 }
1541 else
1542 {
1543 AddTSRsp.TSDelay.delay = 10;
1544 AddTSRsp.TSDelay.present = 1;
1545 }
1546 }
1547
1548 if ( pAddTS->wsmTspecPresent )
1549 {
1550 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1551 }
1552 else
1553 {
1554 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1555 }
1556
1557 if ( pAddTS->wsmTspecPresent )
1558 {
1559 AddTSRsp.num_WMMTCLAS = 0;
1560 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1561 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1562 {
1563 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1564 &AddTSRsp.TCLAS[i] );
1565 }
1566 }
1567 else
1568 {
1569 AddTSRsp.num_TCLAS = 0;
1570 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1571 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1572 {
1573 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1574 &AddTSRsp.WMMTCLAS[i] );
1575 }
1576 }
1577
1578 if ( pAddTS->tclasProcPresent )
1579 {
1580 if ( pAddTS->wsmTspecPresent )
1581 {
1582 AddTSRsp.WMMTCLASPROC.version = 1;
1583 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1584 AddTSRsp.WMMTCLASPROC.present = 1;
1585 }
1586 else
1587 {
1588 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1589 AddTSRsp.TCLASSPROC.present = 1;
1590 }
1591 }
1592
1593 // schedule element is included only if requested in the tspec and we are
1594 // using hcca (or both edca and hcca)
1595 // 11e-D8.0 is inconsistent on whether the schedule element is included
1596 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1597 // pg 46, line 17-18 says something else. So just include it and let the
1598 // sta figure it out
1599 if ((pSchedule != NULL) &&
1600 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1601 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1602 {
1603 if ( pAddTS->wsmTspecPresent )
1604 {
1605 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1606 }
1607 else
1608 {
1609 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1610 }
1611 }
1612
1613 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1614 if ( DOT11F_FAILED( nStatus ) )
1615 {
1616 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1617 "ze for an Add TS Response (0x%08x).\n"),
1618 nStatus );
1619 // We'll fall back on the worst case scenario:
1620 nPayload = sizeof( tDot11fAddTSResponse );
1621 }
1622 else if ( DOT11F_WARNED( nStatus ) )
1623 {
1624 limLog( pMac, LOGW, FL("There were warnings while calcula"
1625 "tingthe packed size for an Add TS"
1626 " Response (0x%08x).\n"), nStatus );
1627 }
1628 }
1629 else
1630 {
1631 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ) );
1632
1633 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1634 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1635 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1636 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1637
1638 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1639
1640 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1641 if ( DOT11F_FAILED( nStatus ) )
1642 {
1643 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1644 "ze for a WMM Add TS Response (0x%08x).\n"),
1645 nStatus );
1646 // We'll fall back on the worst case scenario:
1647 nPayload = sizeof( tDot11fWMMAddTSResponse );
1648 }
1649 else if ( DOT11F_WARNED( nStatus ) )
1650 {
1651 limLog( pMac, LOGW, FL("There were warnings while calcula"
1652 "tingthe packed size for a WMM Add"
1653 "TS Response (0x%08x).\n"), nStatus );
1654 }
1655 }
1656
1657 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1658
1659 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1660 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1661 {
1662 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1663 "d TS Response.\n"), nBytes );
1664 return;
1665 }
1666
1667 // Paranoia:
1668 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1669
1670 // Next, we fill out the buffer descriptor:
1671 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1672 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1673 if ( eSIR_SUCCESS != nSirStatus )
1674 {
1675 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1676 "tor for an Add TS Response (%d).\n"),
1677 nSirStatus );
1678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1679 return; // allocated!
1680 }
1681
1682 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1683
1684
1685 #if 0
1686 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1687 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1688 {
1689 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1690 "e sending an Add TS Response.\n") );
1691 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1692 return; // allocated!
1693 }
1694 #endif //TO SUPPORT BT-AMP
1695 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1696
Chet Lanctot186b5732013-03-18 10:26:30 -07001697#ifdef WLAN_FEATURE_11W
1698 if ( psessionEntry->limRmfEnabled )
1699 {
1700 pMacHdr->fc.wep = 1;
1701 }
1702#endif
1703
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 // That done, pack the struct:
1705 if ( ! pAddTS->wmeTspecPresent )
1706 {
1707 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1708 pFrame + sizeof( tSirMacMgmtHdr ),
1709 nPayload, &nPayload );
1710 if ( DOT11F_FAILED( nStatus ) )
1711 {
1712 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
1713 "(0x%08x).\n"),
1714 nStatus );
1715 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1716 return;
1717 }
1718 else if ( DOT11F_WARNED( nStatus ) )
1719 {
1720 limLog( pMac, LOGW, FL("There were warnings while packing"
1721 "an Add TS Response (0x%08x).\n") );
1722 }
1723 }
1724 else
1725 {
1726 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1727 pFrame + sizeof( tSirMacMgmtHdr ),
1728 nPayload, &nPayload );
1729 if ( DOT11F_FAILED( nStatus ) )
1730 {
1731 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
1732 "(0x%08x).\n"),
1733 nStatus );
1734 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1735 return;
1736 }
1737 else if ( DOT11F_WARNED( nStatus ) )
1738 {
1739 limLog( pMac, LOGW, FL("There were warnings while packing"
1740 "a WMM Add TS Response (0x%08x).\n") );
1741 }
1742 }
1743
1744 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1745 nStatusCode );
1746 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1747
1748 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1750 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 )
1752 {
1753 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1754 }
1755
1756 // Queue the frame in high priority WQ:
1757 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1758 HAL_TXRX_FRM_802_11_MGMT,
1759 ANI_TXDIR_TODS,
1760 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1761 limTxComplete, pFrame, txFlag );
1762 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1763 {
1764 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!\n"),
1765 nSirStatus );
1766 //Pkt will be freed up by the callback
1767 }
1768
1769} // End limSendAddtsRspActionFrame.
1770
1771void
1772limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1773 tSirMacAddr peer,
1774 tANI_U8 wmmTspecPresent,
1775 tSirMacTSInfo *pTsinfo,
1776 tSirMacTspecIE *pTspecIe,
1777 tpPESession psessionEntry)
1778{
1779 tANI_U8 *pFrame;
1780 tpSirMacMgmtHdr pMacHdr;
1781 tDot11fDelTS DelTS;
1782 tDot11fWMMDelTS WMMDelTS;
1783 tSirRetStatus nSirStatus;
1784 tANI_U32 nBytes, nPayload, nStatus;
1785 void *pPacket;
1786 eHalStatus halstatus;
1787 tANI_U8 txFlag = 0;
1788
1789 if(NULL == psessionEntry)
1790 {
1791 return;
1792 }
1793
1794 if ( ! wmmTspecPresent )
1795 {
1796 palZeroMemory( pMac->hHdd, ( tANI_U8* )&DelTS, sizeof( DelTS ) );
1797
1798 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1799 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1800 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1801
1802 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1803 if ( DOT11F_FAILED( nStatus ) )
1804 {
1805 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1806 "ze for a Del TS (0x%08x).\n"),
1807 nStatus );
1808 // We'll fall back on the worst case scenario:
1809 nPayload = sizeof( tDot11fDelTS );
1810 }
1811 else if ( DOT11F_WARNED( nStatus ) )
1812 {
1813 limLog( pMac, LOGW, FL("There were warnings while calcula"
1814 "ting the packed size for a Del TS"
1815 " (0x%08x).\n"), nStatus );
1816 }
1817 }
1818 else
1819 {
1820 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ) );
1821
1822 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1823 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1824 WMMDelTS.DialogToken.token = 0;
1825 WMMDelTS.StatusCode.statusCode = 0;
1826 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1827 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1828 if ( DOT11F_FAILED( nStatus ) )
1829 {
1830 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
1831 "ze for a WMM Del TS (0x%08x).\n"),
1832 nStatus );
1833 // We'll fall back on the worst case scenario:
1834 nPayload = sizeof( tDot11fDelTS );
1835 }
1836 else if ( DOT11F_WARNED( nStatus ) )
1837 {
1838 limLog( pMac, LOGW, FL("There were warnings while calcula"
1839 "ting the packed size for a WMM De"
1840 "l TS (0x%08x).\n"), nStatus );
1841 }
1842 }
1843
1844 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1845
1846 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1847 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1848 {
1849 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1850 "d TS Response.\n"), nBytes );
1851 return;
1852 }
1853
1854 // Paranoia:
1855 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1856
1857 // Next, we fill out the buffer descriptor:
1858 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1859 SIR_MAC_MGMT_ACTION, peer,
1860 psessionEntry->selfMacAddr);
1861 if ( eSIR_SUCCESS != nSirStatus )
1862 {
1863 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
1864 "tor for an Add TS Response (%d).\n"),
1865 nSirStatus );
1866 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1867 return; // allocated!
1868 }
1869
1870 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1871
1872 #if 0
1873
1874 cfgLen = SIR_MAC_ADDR_LENGTH;
1875 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1876 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1877 {
1878 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
1879 "e sending an Add TS Response.\n") );
1880 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1881 return; // allocated!
1882 }
1883 #endif //TO SUPPORT BT-AMP
1884 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1885
Chet Lanctot186b5732013-03-18 10:26:30 -07001886#ifdef WLAN_FEATURE_11W
1887 if ( psessionEntry->limRmfEnabled )
1888 {
1889 pMacHdr->fc.wep = 1;
1890 }
1891#endif
1892
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 // That done, pack the struct:
1894 if ( !wmmTspecPresent )
1895 {
1896 nStatus = dot11fPackDelTS( pMac, &DelTS,
1897 pFrame + sizeof( tSirMacMgmtHdr ),
1898 nPayload, &nPayload );
1899 if ( DOT11F_FAILED( nStatus ) )
1900 {
1901 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x).\n"),
1902 nStatus );
1903 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1904 return; // allocated!
1905 }
1906 else if ( DOT11F_WARNED( nStatus ) )
1907 {
1908 limLog( pMac, LOGW, FL("There were warnings while packing"
1909 "a Del TS frame (0x%08x).\n") );
1910 }
1911 }
1912 else
1913 {
1914 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1915 pFrame + sizeof( tSirMacMgmtHdr ),
1916 nPayload, &nPayload );
1917 if ( DOT11F_FAILED( nStatus ) )
1918 {
1919 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x).\n"),
1920 nStatus );
1921 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1922 return; // allocated!
1923 }
1924 else if ( DOT11F_WARNED( nStatus ) )
1925 {
1926 limLog( pMac, LOGW, FL("There were warnings while packing"
1927 "a WMM Del TS frame (0x%08x).\n") );
1928 }
1929 }
1930
1931 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1932 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1933
1934 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1936 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 )
1938 {
1939 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1940 }
1941
1942 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1943 HAL_TXRX_FRM_802_11_MGMT,
1944 ANI_TXDIR_TODS,
1945 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1946 limTxComplete, pFrame, txFlag );
1947 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1948 {
1949 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!\n"),
1950 nSirStatus );
1951 //Pkt will be freed up by the callback
1952 }
1953
1954} // End limSendDeltsReqActionFrame.
1955
1956void
1957limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1958 tLimMlmAssocReq *pMlmAssocReq,
1959 tpPESession psessionEntry)
1960{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001961 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 tANI_U16 caps;
1963 tANI_U8 *pFrame;
1964 tSirRetStatus nSirStatus;
1965 tLimMlmAssocCnf mlmAssocCnf;
1966 tANI_U32 nBytes, nPayload, nStatus;
1967 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1968 void *pPacket;
1969 eHalStatus halstatus;
1970 tANI_U16 nAddIELen;
1971 tANI_U8 *pAddIE;
1972 tANI_U8 *wpsIe = NULL;
1973#if defined WLAN_FEATURE_VOWIFI
1974 tANI_U8 PowerCapsPopulated = FALSE;
1975#endif
1976 tANI_U8 txFlag = 0;
1977
1978 if(NULL == psessionEntry)
1979 {
1980 return;
1981 }
1982
1983 if(NULL == psessionEntry->pLimJoinReq)
1984 {
1985 return;
1986 }
1987
1988 /* check this early to avoid unncessary operation */
1989 if(NULL == psessionEntry->pLimJoinReq)
1990 {
1991 return;
1992 }
1993 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1994 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1995
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001996 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1997 (void **)&pFrm, sizeof(tDot11fAssocRequest)))
1998 {
1999 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendAssocReqMgmtFrame\n") );
2000 return;
2001 }
2002
2003
2004 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002005
2006 caps = pMlmAssocReq->capabilityInfo;
2007 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2008 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2009#if defined(FEATURE_WLAN_WAPI)
2010 /* CR: 262463 :
2011 According to WAPI standard:
2012 7.3.1.4 Capability Information field
2013 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2014 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2015 Reassociation management frames. */
2016 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2017 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2018#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002019 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002020
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002021 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2022 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002024 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025
2026 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2027 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2028
2029 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2030 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2031
2032 // We prefer .11e asociations:
2033 if ( fQosEnabled ) fWmeEnabled = false;
2034
2035 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2036 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2037
2038 if ( psessionEntry->lim11hEnable &&
2039 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2040 {
2041#if defined WLAN_FEATURE_VOWIFI
2042 PowerCapsPopulated = TRUE;
2043
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002045#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002046 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047
2048 }
2049
2050#if defined WLAN_FEATURE_VOWIFI
2051 if( pMac->rrm.rrmPEContext.rrmEnable &&
2052 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2053 {
2054 if (PowerCapsPopulated == FALSE)
2055 {
2056 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002057 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 }
2060#endif
2061
2062 if ( fQosEnabled &&
2063 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002064 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002065
2066 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002067 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
2069#if defined WLAN_FEATURE_VOWIFI
2070 if( pMac->rrm.rrmPEContext.rrmEnable &&
2071 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2072 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002073 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 }
2075#endif
2076 // The join request *should* contain zero or one of the WPA and RSN
2077 // IEs. The payload send along with the request is a
2078 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2079
2080 // typedef struct sSirRSNie
2081 // {
2082 // tANI_U16 length;
2083 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2084 // } tSirRSNie, *tpSirRSNie;
2085
2086 // So, we should be able to make the following two calls harmlessly,
2087 // since they do nothing if they don't find the given IE in the
2088 // bytestream with which they're provided.
2089
2090 // The net effect of this will be to faithfully transmit whatever
2091 // security IE is in the join request.
2092
2093 // *However*, if we're associating for the purpose of WPS
2094 // enrollment, and we've been configured to indicate that by
2095 // eliding the WPA or RSN IE, we just skip this:
2096 if( nAddIELen && pAddIE )
2097 {
2098 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2099 }
2100 if ( NULL == wpsIe )
2101 {
2102 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002103 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002105 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106#if defined(FEATURE_WLAN_WAPI)
2107 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002108 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002109#endif // defined(FEATURE_WLAN_WAPI)
2110 }
2111
2112 // include WME EDCA IE as well
2113 if ( fWmeEnabled )
2114 {
2115 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2116 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002117 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 }
2119
2120 if ( fWsmEnabled &&
2121 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2122 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002123 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 }
2125 }
2126
2127 //Populate HT IEs, when operating in 11n or Taurus modes AND
2128 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002129 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 pMac->lim.htCapabilityPresentInBeacon)
2131 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002132 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002133#ifdef DISABLE_GF_FOR_INTEROP
2134
2135 /*
2136 * To resolve the interop problem with Broadcom AP,
2137 * where TQ STA could not pass traffic with GF enabled,
2138 * TQ STA will do Greenfield only with TQ AP, for
2139 * everybody else it will be turned off.
2140 */
2141
2142 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2143 {
2144 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002145 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 }
2147#endif
2148
2149 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002150#ifdef WLAN_FEATURE_11AC
2151 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002152 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002153 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002154 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002155 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2156 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002157 }
2158#endif
2159
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161#if defined WLAN_FEATURE_VOWIFI_11R
2162 if (psessionEntry->pLimJoinReq->is11Rconnection)
2163 {
2164#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002165 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2167 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2168 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2169#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002170 PopulateMDIE( pMac, &pFrm->MobilityDomain, psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 }
2172 else
2173 {
2174 // No 11r IEs dont send any MDIE
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002175 limLog( pMac, LOG1, FL("mdie not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177#endif
2178
2179#ifdef FEATURE_WLAN_CCX
2180 // For CCX Associations fill the CCX IEs
2181 if (psessionEntry->isCCXconnection)
2182 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002183 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
2184 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 }
2186#endif
2187
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002188 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 if ( DOT11F_FAILED( nStatus ) )
2190 {
2191 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2192 "or an Association Request (0x%08x).\n"),
2193 nStatus );
2194 // We'll fall back on the worst case scenario:
2195 nPayload = sizeof( tDot11fAssocRequest );
2196 }
2197 else if ( DOT11F_WARNED( nStatus ) )
2198 {
2199 limLog( pMac, LOGW, FL("There were warnings while calculating"
2200 "the packed size for an Association Re "
2201 "quest(0x%08x).\n"), nStatus );
2202 }
2203
2204 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2205
2206 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2207 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2208 ( void** ) &pPacket );
2209 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2210 {
2211 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
2212 "sociation Request.\n"), nBytes );
2213
2214 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002215 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217
2218 /* Update PE session id*/
2219 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2220
2221 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2222
2223 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2224 ( void* ) pFrame, ( void* ) pPacket );
2225
2226 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2227 ( tANI_U32* ) &mlmAssocCnf);
2228
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002229 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 return;
2231 }
2232
2233 // Paranoia:
2234 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2235
2236 // Next, we fill out the buffer descriptor:
2237 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2238 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2239 if ( eSIR_SUCCESS != nSirStatus )
2240 {
2241 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2242 "tor for an Association Request (%d).\n"),
2243 nSirStatus );
2244 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002245 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 return;
2247 }
2248
2249
2250 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002251 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 sizeof(tSirMacMgmtHdr),
2253 nPayload, &nPayload );
2254 if ( DOT11F_FAILED( nStatus ) )
2255 {
2256 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
2257 "8x).\n"),
2258 nStatus );
2259 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2260 ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002261 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 return;
2263 }
2264 else if ( DOT11F_WARNED( nStatus ) )
2265 {
2266 limLog( pMac, LOGW, FL("There were warnings while packing a P"
2267 "robe Response (0x%08x).\n") );
2268 }
2269
2270 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
2271 "to \n"),
2272 nBytes );)
2273 // limPrintMacAddr( pMac, bssid, LOG1 );
2274
2275 if( psessionEntry->assocReq != NULL )
2276 {
2277 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2278 psessionEntry->assocReq = NULL;
2279 }
2280
2281 if( nAddIELen )
2282 {
2283 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2284 pAddIE,
2285 nAddIELen );
2286 nPayload += nAddIELen;
2287 }
2288
Jeff Johnson43971f52012-07-17 12:26:56 -07002289 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2290 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 {
2292 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2293 }
2294 else
2295 {
2296 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2297 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2298 psessionEntry->assocReqLen = nPayload;
2299 }
2300
2301 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2303 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 )
2305 {
2306 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2307 }
2308
Ganesh K08bce952012-12-13 15:04:41 -08002309 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2310 {
2311 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2312 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002313
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2315 HAL_TXRX_FRM_802_11_MGMT,
2316 ANI_TXDIR_TODS,
2317 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2318 limTxComplete, pFrame, txFlag );
2319 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2320 {
2321 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!\n"),
2322 halstatus );
2323 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002324 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 return;
2326 }
2327
2328 // Free up buffer allocated for mlmAssocReq
2329 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmAssocReq );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002330 palFreeMemory(pMac->hHdd, pFrm);
2331 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002332} // End limSendAssocReqMgmtFrame
2333
2334
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002335#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002336/*------------------------------------------------------------------------------------
2337 *
2338 * Send Reassoc Req with FTIEs.
2339 *
2340 *-----------------------------------------------------------------------------------
2341 */
2342void
2343limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2344 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2345{
2346 static tDot11fReAssocRequest frm;
2347 tANI_U16 caps;
2348 tANI_U8 *pFrame;
2349 tSirRetStatus nSirStatus;
2350 tANI_U32 nBytes, nPayload, nStatus;
2351 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2352 void *pPacket;
2353 eHalStatus halstatus;
2354#if defined WLAN_FEATURE_VOWIFI
2355 tANI_U8 PowerCapsPopulated = FALSE;
2356#endif
2357 tANI_U16 ft_ies_length = 0;
2358 tANI_U8 *pBody;
2359 tANI_U16 nAddIELen;
2360 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002361#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 tANI_U8 *wpsIe = NULL;
2363#endif
2364 tANI_U8 txFlag = 0;
2365
2366 if (NULL == psessionEntry)
2367 {
2368 return;
2369 }
2370
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 /* check this early to avoid unncessary operation */
2372 if(NULL == psessionEntry->pLimReAssocReq)
2373 {
2374 return;
2375 }
2376 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2377 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002378 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2379 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380
2381 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2382
2383 caps = pMlmReassocReq->capabilityInfo;
2384 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2385 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2386#if defined(FEATURE_WLAN_WAPI)
2387 /* CR: 262463 :
2388 According to WAPI standard:
2389 7.3.1.4 Capability Information field
2390 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2391 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2392 Reassociation management frames. */
2393 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2394 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2395#endif
2396 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2397
2398 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2399
2400 // Get the old bssid of the older AP.
2401 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2402 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2403
2404 PopulateDot11fSSID2( pMac, &frm.SSID );
2405 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2406 &frm.SuppRates,psessionEntry);
2407
2408 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2409 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2410
2411 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2412 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2413
2414 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2415 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2416
2417 if ( psessionEntry->lim11hEnable &&
2418 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2419 {
2420#if defined WLAN_FEATURE_VOWIFI
2421 PowerCapsPopulated = TRUE;
2422
2423 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2424 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2425#endif
2426 }
2427
2428#if defined WLAN_FEATURE_VOWIFI
2429 if( pMac->rrm.rrmPEContext.rrmEnable &&
2430 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2431 {
2432 if (PowerCapsPopulated == FALSE)
2433 {
2434 PowerCapsPopulated = TRUE;
2435 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2436 }
2437 }
2438#endif
2439
2440 if ( fQosEnabled &&
2441 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2442 {
2443 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2444 }
2445
2446 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2447 &frm.ExtSuppRates, psessionEntry );
2448
2449#if defined WLAN_FEATURE_VOWIFI
2450 if( pMac->rrm.rrmPEContext.rrmEnable &&
2451 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2452 {
2453 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2454 }
2455#endif
2456
2457 // Ideally this should be enabled for 11r also. But 11r does
2458 // not follow the usual norm of using the Opaque object
2459 // for rsnie and fties. Instead we just add
2460 // the rsnie and fties at the end of the pack routine for 11r.
2461 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002462#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 //
2464 // The join request *should* contain zero or one of the WPA and RSN
2465 // IEs. The payload send along with the request is a
2466 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2467
2468 // typedef struct sSirRSNie
2469 // {
2470 // tANI_U16 length;
2471 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2472 // } tSirRSNie, *tpSirRSNie;
2473
2474 // So, we should be able to make the following two calls harmlessly,
2475 // since they do nothing if they don't find the given IE in the
2476 // bytestream with which they're provided.
2477
2478 // The net effect of this will be to faithfully transmit whatever
2479 // security IE is in the join request.
2480
2481 // *However*, if we're associating for the purpose of WPS
2482 // enrollment, and we've been configured to indicate that by
2483 // eliding the WPA or RSN IE, we just skip this:
2484 if (!psessionEntry->is11Rconnection)
2485 {
2486 if( nAddIELen && pAddIE )
2487 {
2488 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2489 }
2490 if ( NULL == wpsIe )
2491 {
2492 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2493 &frm.RSNOpaque );
2494 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2495 &frm.WPAOpaque );
2496 }
2497
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002498#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 if(psessionEntry->pLimReAssocReq->cckmIE.length)
2500 {
2501 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2502 &frm.CCXCckmOpaque );
2503 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002504#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 }
2506
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 // For CCX Associations fill the CCX IEs
2509 if (psessionEntry->isCCXconnection)
2510 {
2511 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
2512 PopulateDot11fCCXVersion(&frm.CCXVersion);
2513 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002514#endif //FEATURE_WLAN_CCX
2515#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002516
2517 // include WME EDCA IE as well
2518 if ( fWmeEnabled )
2519 {
2520 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2521 {
2522 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2523 }
2524
2525 if ( fWsmEnabled &&
2526 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2527 {
2528 PopulateDot11fWMMCaps( &frm.WMMCaps );
2529 }
2530#ifdef FEATURE_WLAN_CCX
2531 if (psessionEntry->isCCXconnection)
2532 {
2533 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2534
2535 // Populate the TSRS IE if TSPEC is included in the reassoc request
2536 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2537 {
2538 tANI_U32 phyMode;
2539 tSirMacCCXTSRSIE tsrsIE;
2540 limGetPhyMode(pMac, &phyMode, psessionEntry);
2541
2542 tsrsIE.tsid = 0;
2543 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2544 {
2545 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2546 }
2547 else
2548 {
2549 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2550 }
2551 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2552 }
2553 }
2554#endif
2555 }
2556
Jeff Johnsone7245742012-09-05 17:12:55 -07002557 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 pMac->lim.htCapabilityPresentInBeacon)
2559 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002560 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 }
2562
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002563#if defined WLAN_FEATURE_VOWIFI_11R
2564 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length) )
2565 {
2566 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2567 }
2568#endif
2569
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2571 if ( DOT11F_FAILED( nStatus ) )
2572 {
2573 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2574 "or a Re-Association Request (0x%08x).\n"),
2575 nStatus );
2576 // We'll fall back on the worst case scenario:
2577 nPayload = sizeof( tDot11fReAssocRequest );
2578 }
2579 else if ( DOT11F_WARNED( nStatus ) )
2580 {
2581 limLog( pMac, LOGW, FL("There were warnings while calculating"
2582 "the packed size for a Re-Association Re "
2583 "quest(0x%08x).\n"), nStatus );
2584 }
2585
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002586 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002587
2588#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002589 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2591#endif
2592
2593#if defined WLAN_FEATURE_VOWIFI_11R
2594 if (psessionEntry->is11Rconnection)
2595 {
2596 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2597 }
2598#endif
2599
2600 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2601 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2602 ( void** ) &pPacket );
2603 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2604 {
2605 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002606 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
2608 "sociation Request.\n"), nBytes );
2609 goto end;
2610 }
2611
2612 // Paranoia:
2613 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2614
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002615#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002616 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002617#endif
2618 // Next, we fill out the buffer descriptor:
2619 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2620 SIR_MAC_MGMT_REASSOC_REQ,
2621 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2622 if ( eSIR_SUCCESS != nSirStatus )
2623 {
2624 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
2625 "tor for an Association Request (%d).\n"),
2626 nSirStatus );
2627 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2628 goto end;
2629 }
2630
2631
2632 // That done, pack the ReAssoc Request:
2633 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2634 sizeof(tSirMacMgmtHdr),
2635 nPayload, &nPayload );
2636 if ( DOT11F_FAILED( nStatus ) )
2637 {
2638 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
2639 "st (0x%08x).\n"),
2640 nStatus );
2641 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2642 goto end;
2643 }
2644 else if ( DOT11F_WARNED( nStatus ) )
2645 {
2646 limLog( pMac, LOGW, FL("There were warnings while packing a R"
2647 "e-Association Request (0x%08x).\n") );
2648 }
2649
2650 PELOG3(limLog( pMac, LOG3,
2651 FL("*** Sending Re-Association Request length %d %d to \n"),
2652 nBytes, nPayload );)
2653 if( psessionEntry->assocReq != NULL )
2654 {
2655 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2656 psessionEntry->assocReq = NULL;
2657 }
2658
2659 if( nAddIELen )
2660 {
2661 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2662 pAddIE,
2663 nAddIELen );
2664 nPayload += nAddIELen;
2665 }
2666
Jeff Johnson43971f52012-07-17 12:26:56 -07002667 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2668 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 {
2670 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002671 }
2672 else
2673 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2675 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2676 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002678
2679 if (psessionEntry->is11Rconnection)
2680 {
2681 {
2682 int i = 0;
2683
2684 pBody = pFrame + nBytes;
2685 for (i=0; i<ft_ies_length; i++)
2686 {
2687 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2688 pBody++;
2689 }
2690 }
2691 }
2692
2693#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002694 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2695 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 (tANI_U8 *)pFrame,
2697 (nBytes + ft_ies_length));)
2698#endif
2699
2700
2701 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2703 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 )
2705 {
2706 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2707 }
2708
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002709 if( NULL != psessionEntry->assocReq )
2710 {
2711 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2712 psessionEntry->assocReq = NULL;
2713 }
2714
2715 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2716 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
2717 {
2718 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002719 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002720 }
2721 else
2722 {
2723 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2724 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2725 (ft_ies_length));
2726 psessionEntry->assocReqLen = (ft_ies_length);
2727 }
2728
2729
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2731 HAL_TXRX_FRM_802_11_MGMT,
2732 ANI_TXDIR_TODS,
2733 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2734 limTxComplete, pFrame, txFlag );
2735 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2736 {
2737 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
2738 "(%X)!\n"),
2739 nSirStatus );
2740 //Pkt will be freed up by the callback
2741 goto end;
2742 }
2743
2744end:
2745 // Free up buffer allocated for mlmAssocReq
2746 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
2747 psessionEntry->pLimMlmReassocReq = NULL;
2748
2749}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002750
2751void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2752 tLimMlmReassocReq *pMlmReassocReq,
2753 tpPESession psessionEntry)
2754{
2755 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2756 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2757 if(NULL == pTmpMlmReassocReq)
2758 {
2759 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
2760 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
2761 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
2762 }
2763
2764 // Prepare and send Reassociation request frame
2765 // start reassoc timer.
2766 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2767 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002768 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002769 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2770 != TX_SUCCESS)
2771 {
2772 // Could not start reassoc failure timer.
2773 // Log error
2774 limLog(pMac, LOGP,
2775 FL("could not start Reassociation failure timer\n"));
2776 // Return Reassoc confirm with
2777 // Resources Unavailable
2778 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2779 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2780 goto end;
2781 }
2782
2783 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2784 return;
2785
2786end:
2787 // Free up buffer allocated for reassocReq
2788 if (pMlmReassocReq != NULL)
2789 {
2790 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
2791 pMlmReassocReq = NULL;
2792 }
2793 if (pTmpMlmReassocReq != NULL)
2794 {
2795 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
2796 pTmpMlmReassocReq = NULL;
2797 }
2798 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2799 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2800 /* Update PE sessio Id*/
2801 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2802
2803 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2804}
2805
Jeff Johnson295189b2012-06-20 16:38:30 -07002806#endif /* WLAN_FEATURE_VOWIFI_11R */
2807
2808
2809void
2810limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2811 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2812{
2813 static tDot11fReAssocRequest frm;
2814 tANI_U16 caps;
2815 tANI_U8 *pFrame;
2816 tSirRetStatus nSirStatus;
2817 tANI_U32 nBytes, nPayload, nStatus;
2818 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2819 void *pPacket;
2820 eHalStatus halstatus;
2821 tANI_U16 nAddIELen;
2822 tANI_U8 *pAddIE;
2823 tANI_U8 *wpsIe = NULL;
2824 tANI_U8 txFlag = 0;
2825#if defined WLAN_FEATURE_VOWIFI
2826 tANI_U8 PowerCapsPopulated = FALSE;
2827#endif
2828
2829 if(NULL == psessionEntry)
2830 {
2831 return;
2832 }
2833
2834 /* check this early to avoid unncessary operation */
2835 if(NULL == psessionEntry->pLimReAssocReq)
2836 {
2837 return;
2838 }
2839 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2840 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2841
2842 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2843
2844 caps = pMlmReassocReq->capabilityInfo;
2845 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2846 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2847#if defined(FEATURE_WLAN_WAPI)
2848 /* CR: 262463 :
2849 According to WAPI standard:
2850 7.3.1.4 Capability Information field
2851 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2852 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2853 Reassociation management frames. */
2854 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2855 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2856#endif
2857 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2858
2859 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2860
2861 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2862 ( tANI_U8* )psessionEntry->bssId, 6 );
2863
2864 PopulateDot11fSSID2( pMac, &frm.SSID );
2865 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2866 &frm.SuppRates,psessionEntry);
2867
2868 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2869 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2870
2871 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2872 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2873
2874 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2875 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2876
2877
2878 if ( psessionEntry->lim11hEnable &&
2879 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2880 {
2881#if defined WLAN_FEATURE_VOWIFI
2882 PowerCapsPopulated = TRUE;
2883 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2884 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2885#endif
2886 }
2887
2888#if defined WLAN_FEATURE_VOWIFI
2889 if( pMac->rrm.rrmPEContext.rrmEnable &&
2890 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2891 {
2892 if (PowerCapsPopulated == FALSE)
2893 {
2894 PowerCapsPopulated = TRUE;
2895 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2896 }
2897 }
2898#endif
2899
2900 if ( fQosEnabled &&
2901 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2902 {
2903 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2904 }
2905
2906 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2907 &frm.ExtSuppRates, psessionEntry );
2908
2909#if defined WLAN_FEATURE_VOWIFI
2910 if( pMac->rrm.rrmPEContext.rrmEnable &&
2911 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2912 {
2913 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2914 }
2915#endif
2916 // The join request *should* contain zero or one of the WPA and RSN
2917 // IEs. The payload send along with the request is a
2918 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2919
2920 // typedef struct sSirRSNie
2921 // {
2922 // tANI_U16 length;
2923 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2924 // } tSirRSNie, *tpSirRSNie;
2925
2926 // So, we should be able to make the following two calls harmlessly,
2927 // since they do nothing if they don't find the given IE in the
2928 // bytestream with which they're provided.
2929
2930 // The net effect of this will be to faithfully transmit whatever
2931 // security IE is in the join request.
2932
2933 // *However*, if we're associating for the purpose of WPS
2934 // enrollment, and we've been configured to indicate that by
2935 // eliding the WPA or RSN IE, we just skip this:
2936 if( nAddIELen && pAddIE )
2937 {
2938 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2939 }
2940 if ( NULL == wpsIe )
2941 {
2942 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2943 &frm.RSNOpaque );
2944 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2945 &frm.WPAOpaque );
2946#if defined(FEATURE_WLAN_WAPI)
2947 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2948 &frm.WAPIOpaque );
2949#endif // defined(FEATURE_WLAN_WAPI)
2950 }
2951
2952 // include WME EDCA IE as well
2953 if ( fWmeEnabled )
2954 {
2955 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2956 {
2957 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2958 }
2959
2960 if ( fWsmEnabled &&
2961 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2962 {
2963 PopulateDot11fWMMCaps( &frm.WMMCaps );
2964 }
2965 }
2966
Jeff Johnsone7245742012-09-05 17:12:55 -07002967 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 pMac->lim.htCapabilityPresentInBeacon)
2969 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002970 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002972#ifdef WLAN_FEATURE_11AC
2973 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002974 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002975 {
2976 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request\n"));
2977 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002978 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002979 }
2980#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002981
2982 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2983 if ( DOT11F_FAILED( nStatus ) )
2984 {
2985 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
2986 "or a Re-Association Request (0x%08x).\n"),
2987 nStatus );
2988 // We'll fall back on the worst case scenario:
2989 nPayload = sizeof( tDot11fReAssocRequest );
2990 }
2991 else if ( DOT11F_WARNED( nStatus ) )
2992 {
2993 limLog( pMac, LOGW, FL("There were warnings while calculating"
2994 "the packed size for a Re-Association Re "
2995 "quest(0x%08x).\n"), nStatus );
2996 }
2997
2998 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2999
3000 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3001 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3002 ( void** ) &pPacket );
3003 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3004 {
3005 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003006 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
3008 "sociation Request.\n"), nBytes );
3009 goto end;
3010 }
3011
3012 // Paranoia:
3013 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3014
3015 // Next, we fill out the buffer descriptor:
3016 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3017 SIR_MAC_MGMT_REASSOC_REQ,
3018 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3019 if ( eSIR_SUCCESS != nSirStatus )
3020 {
3021 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3022 "tor for an Association Request (%d).\n"),
3023 nSirStatus );
3024 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3025 goto end;
3026 }
3027
3028
3029 // That done, pack the Probe Request:
3030 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3031 sizeof(tSirMacMgmtHdr),
3032 nPayload, &nPayload );
3033 if ( DOT11F_FAILED( nStatus ) )
3034 {
3035 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
3036 "st (0x%08x).\n"),
3037 nStatus );
3038 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3039 goto end;
3040 }
3041 else if ( DOT11F_WARNED( nStatus ) )
3042 {
3043 limLog( pMac, LOGW, FL("There were warnings while packing a R"
3044 "e-Association Request (0x%08x).\n") );
3045 }
3046
3047 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
3048 "to \n"),
3049 nBytes );)
3050
3051 if( psessionEntry->assocReq != NULL )
3052 {
3053 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3054 psessionEntry->assocReq = NULL;
3055 }
3056
3057 if( nAddIELen )
3058 {
3059 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3060 pAddIE,
3061 nAddIELen );
3062 nPayload += nAddIELen;
3063 }
3064
Jeff Johnson43971f52012-07-17 12:26:56 -07003065 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3066 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 {
3068 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003069 }
3070 else
3071 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3073 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3074 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003076
3077 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3079 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 )
3081 {
3082 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3083 }
3084
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003085 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003086 {
3087 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3088 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003089
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3091 HAL_TXRX_FRM_802_11_MGMT,
3092 ANI_TXDIR_TODS,
3093 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3094 limTxComplete, pFrame, txFlag );
3095 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3096 {
3097 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
3098 "(%X)!\n"),
3099 nSirStatus );
3100 //Pkt will be freed up by the callback
3101 goto end;
3102 }
3103
3104end:
3105 // Free up buffer allocated for mlmAssocReq
3106 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3107 psessionEntry->pLimMlmReassocReq = NULL;
3108
3109} // limSendReassocReqMgmtFrame
3110
3111/**
3112 * \brief Send an Authentication frame
3113 *
3114 *
3115 * \param pMac Pointer to Global MAC structure
3116 *
3117 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3118 * to be sent
3119 *
3120 * \param peerMacAddr MAC address of the peer entity to which Authentication
3121 * frame is destined
3122 *
3123 * \param wepBit Indicates whether wep bit to be set in FC while sending
3124 * Authentication frame3
3125 *
3126 *
3127 * This function is called by limProcessMlmMessages(). Authentication frame
3128 * is formatted and sent when this function is called.
3129 *
3130 *
3131 */
3132
3133void
3134limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3135 tpSirMacAuthFrameBody pAuthFrameBody,
3136 tSirMacAddr peerMacAddr,
3137 tANI_U8 wepBit,
3138 tpPESession psessionEntry
3139 )
3140{
3141 tANI_U8 *pFrame, *pBody;
3142 tANI_U32 frameLen = 0, bodyLen = 0;
3143 tpSirMacMgmtHdr pMacHdr;
3144 tANI_U16 i;
3145 void *pPacket;
3146 eHalStatus halstatus;
3147 tANI_U8 txFlag = 0;
3148
3149 if(NULL == psessionEntry)
3150 {
3151 return;
3152 }
3153
3154 if (wepBit == LIM_WEP_IN_FC)
3155 {
3156 /// Auth frame3 to be sent with encrypted framebody
3157 /**
3158 * Allocate buffer for Authenticaton frame of size equal
3159 * to management frame header length plus 2 bytes each for
3160 * auth algorithm number, transaction number, status code,
3161 * 128 bytes for challenge text and 4 bytes each for
3162 * IV & ICV.
3163 */
3164
3165 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3166
3167 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3168 } // if (wepBit == LIM_WEP_IN_FC)
3169 else
3170 {
3171 switch (pAuthFrameBody->authTransactionSeqNumber)
3172 {
3173 case SIR_MAC_AUTH_FRAME_1:
3174 /**
3175 * Allocate buffer for Authenticaton frame of size
3176 * equal to management frame header length plus 2 bytes
3177 * each for auth algorithm number, transaction number
3178 * and status code.
3179 */
3180
3181 frameLen = sizeof(tSirMacMgmtHdr) +
3182 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3183 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3184
3185#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003186 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3187 {
3188 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003190 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
3191 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d\n"),
3192 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003194 else
3195 {
3196 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!\n"));
3197 frameLen += (2+SIR_MDIE_SIZE);
3198 }
3199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003200#endif
3201 break;
3202
3203 case SIR_MAC_AUTH_FRAME_2:
3204 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3205 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3206 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3207 {
3208 /**
3209 * Allocate buffer for Authenticaton frame of size
3210 * equal to management frame header length plus
3211 * 2 bytes each for auth algorithm number,
3212 * transaction number and status code.
3213 */
3214
3215 frameLen = sizeof(tSirMacMgmtHdr) +
3216 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3217 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3218 }
3219 else
3220 {
3221 // Shared Key algorithm with challenge text
3222 // to be sent
3223 /**
3224 * Allocate buffer for Authenticaton frame of size
3225 * equal to management frame header length plus
3226 * 2 bytes each for auth algorithm number,
3227 * transaction number, status code and 128 bytes
3228 * for challenge text.
3229 */
3230
3231 frameLen = sizeof(tSirMacMgmtHdr) +
3232 sizeof(tSirMacAuthFrame);
3233 bodyLen = sizeof(tSirMacAuthFrameBody);
3234 }
3235
3236 break;
3237
3238 case SIR_MAC_AUTH_FRAME_3:
3239 /// Auth frame3 to be sent without encrypted framebody
3240 /**
3241 * Allocate buffer for Authenticaton frame of size equal
3242 * to management frame header length plus 2 bytes each
3243 * for auth algorithm number, transaction number and
3244 * status code.
3245 */
3246
3247 frameLen = sizeof(tSirMacMgmtHdr) +
3248 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3249 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3250
3251 break;
3252
3253 case SIR_MAC_AUTH_FRAME_4:
3254 /**
3255 * Allocate buffer for Authenticaton frame of size equal
3256 * to management frame header length plus 2 bytes each
3257 * for auth algorithm number, transaction number and
3258 * status code.
3259 */
3260
3261 frameLen = sizeof(tSirMacMgmtHdr) +
3262 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3263 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3264
3265 break;
3266 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3267 } // end if (wepBit == LIM_WEP_IN_FC)
3268
3269
3270 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3271
3272 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3273 {
3274 // Log error
3275 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame\n"));
3276
3277 return;
3278 }
3279
3280 for (i = 0; i < frameLen; i++)
3281 pFrame[i] = 0;
3282
3283 // Prepare BD
3284 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3285 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3286 {
3287 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3288 return;
3289 }
3290
3291 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3292 pMacHdr->fc.wep = wepBit;
3293
3294 // Prepare BSSId
3295 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3296 {
3297 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3298 (tANI_U8 *) psessionEntry->bssId,
3299 sizeof( tSirMacAddr ));
3300 }
3301
3302 /// Prepare Authentication frame body
3303 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3304
3305 if (wepBit == LIM_WEP_IN_FC)
3306 {
3307 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3308
3309 PELOG1(limLog(pMac, LOG1,
3310 FL("*** Sending Auth seq# 3 status %d (%d) to\n"),
3311 pAuthFrameBody->authStatusCode,
3312 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3313
3314 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3315 }
3316 else
3317 {
3318 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3319 pBody += sizeof(tANI_U16);
3320 bodyLen -= sizeof(tANI_U16);
3321
3322 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3323 pBody += sizeof(tANI_U16);
3324 bodyLen -= sizeof(tANI_U16);
3325
3326 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3327 pBody += sizeof(tANI_U16);
3328 bodyLen -= sizeof(tANI_U16);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07003329 if ( bodyLen < sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))
3330 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003331
3332#if defined WLAN_FEATURE_VOWIFI_11R
3333 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3334 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3335 {
3336
3337 {
3338 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3340 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003341#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3343 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3344 (tANI_U8 *)pBody,
3345 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003346#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003347 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3348 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003349 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3350 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003351 }
3352 }
3353 else
3354 {
3355 /* MDID attr is 54*/
3356 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003358 *pBody = SIR_MDIE_SIZE;
3359 pBody++;
3360 for(i=0;i<SIR_MDIE_SIZE;i++)
3361 {
3362 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3363 pBody++;
3364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 }
3366 }
3367 }
3368#endif
3369
3370 PELOG1(limLog(pMac, LOG1,
3371 FL("*** Sending Auth seq# %d status %d (%d) to "),
3372 pAuthFrameBody->authTransactionSeqNumber,
3373 pAuthFrameBody->authStatusCode,
3374 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3375
3376 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3377 }
3378 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3379
3380 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3382 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003383#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3384 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3385 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3386#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 )
3388 {
3389 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3390 }
3391
Ganesh K08bce952012-12-13 15:04:41 -08003392 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3393 {
3394 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3395 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003396
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 /// Queue Authentication frame in high priority WQ
3398 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3399 HAL_TXRX_FRM_802_11_MGMT,
3400 ANI_TXDIR_TODS,
3401 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3402 limTxComplete, pFrame, txFlag );
3403 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3404 {
3405 limLog(pMac, LOGE,
3406 FL("*** Could not send Auth frame, retCode=%X ***\n"),
3407 halstatus);
3408
3409 //Pkt will be freed up by the callback
3410 }
3411
3412 return;
3413} /*** end limSendAuthMgmtFrame() ***/
3414
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003415eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3416{
3417 tANI_U16 aid;
3418 tpDphHashNode pStaDs;
3419 tLimMlmDeauthReq *pMlmDeauthReq;
3420 tLimMlmDeauthCnf mlmDeauthCnf;
3421 tpPESession psessionEntry;
3422
3423 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3424 if (pMlmDeauthReq)
3425 {
3426 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3427 {
3428 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3429 }
3430
3431 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3432 {
3433
3434 PELOGE(limLog(pMac, LOGE,
3435 FL("session does not exist for given sessionId\n"));)
3436 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3437 goto end;
3438 }
3439
3440 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3441 if (pStaDs == NULL)
3442 {
3443 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3444 goto end;
3445 }
3446
3447
3448 /// Receive path cleanup with dummy packet
3449 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3450 /// Free up buffer allocated for mlmDeauthReq
3451 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3452 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3453 }
3454 return eHAL_STATUS_SUCCESS;
3455end:
3456 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3457 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3458 sizeof(tSirMacAddr));
3459 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3460 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3461 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3462
3463 // Free up buffer allocated
3464 // for mlmDeauthReq
3465 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3466
3467 limPostSmeMessage(pMac,
3468 LIM_MLM_DEAUTH_CNF,
3469 (tANI_U32 *) &mlmDeauthCnf);
3470 return eHAL_STATUS_SUCCESS;
3471}
3472
3473eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3474{
3475 tANI_U16 aid;
3476 tpDphHashNode pStaDs;
3477 tLimMlmDisassocCnf mlmDisassocCnf;
3478 tpPESession psessionEntry;
3479 tLimMlmDisassocReq *pMlmDisassocReq;
3480
3481 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3482 if (pMlmDisassocReq)
3483 {
3484 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3485 {
3486 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3487 }
3488
3489 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3490 {
3491
3492 PELOGE(limLog(pMac, LOGE,
3493 FL("session does not exist for given sessionId\n"));)
3494 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3495 goto end;
3496 }
3497
3498 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3499 if (pStaDs == NULL)
3500 {
3501 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3502 goto end;
3503 }
3504
3505 /// Receive path cleanup with dummy packet
3506 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3507 {
3508 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3509 goto end;
3510 }
3511
3512#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003513 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3514 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003515#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003516 (psessionEntry->isCCXconnection ) ||
3517#endif
3518#ifdef FEATURE_WLAN_LFR
3519 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003520#endif
3521 (psessionEntry->is11Rconnection )) &&
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003522 (pMlmDisassocReq->reasonCode !=
3523 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003524 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003525 PELOGE(limLog(pMac, LOGE,
3526 FL("FT Preauth Session (%p,%d) Cleanup\n"),
3527 psessionEntry, psessionEntry->peSessionId););
3528 limFTCleanup(pMac);
3529 }
3530 else
3531 {
3532 PELOGE(limLog(pMac, LOGE,
3533 FL("No FT Preauth Session Cleanup in role %d"
3534#ifdef FEATURE_WLAN_CCX
3535 " isCCX %d"
3536#endif
3537#ifdef FEATURE_WLAN_LFR
3538 " isLFR %d"
3539#endif
3540 " is11r %d reason %d\n"),
3541 psessionEntry->limSystemRole,
3542#ifdef FEATURE_WLAN_CCX
3543 psessionEntry->isCCXconnection,
3544#endif
3545#ifdef FEATURE_WLAN_LFR
3546 psessionEntry->isFastRoamIniFeatureEnabled,
3547#endif
3548 psessionEntry->is11Rconnection,
3549 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003550 }
3551#endif
3552
3553 /// Free up buffer allocated for mlmDisassocReq
3554 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3555 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3556 return eHAL_STATUS_SUCCESS;
3557 }
3558 else
3559 {
3560 return eHAL_STATUS_SUCCESS;
3561 }
3562end:
3563 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3564 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3565 sizeof(tSirMacAddr));
3566 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3567 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3568
3569 /* Update PE session ID*/
3570 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3571
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003572 if(pMlmDisassocReq != NULL)
3573 {
3574 /// Free up buffer allocated for mlmDisassocReq
3575 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3576 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3577 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003578
3579 limPostSmeMessage(pMac,
3580 LIM_MLM_DISASSOC_CNF,
3581 (tANI_U32 *) &mlmDisassocCnf);
3582 return eHAL_STATUS_SUCCESS;
3583}
3584
3585eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3586{
3587 return limSendDisassocCnf(pMac);
3588}
3589
3590eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3591{
3592 return limSendDeauthCnf(pMac);
3593}
3594
Jeff Johnson295189b2012-06-20 16:38:30 -07003595/**
3596 * \brief This function is called to send Disassociate frame.
3597 *
3598 *
3599 * \param pMac Pointer to Global MAC structure
3600 *
3601 * \param nReason Indicates the reason that need to be sent in
3602 * Disassociation frame
3603 *
3604 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3605 * sent
3606 *
3607 *
3608 */
3609
3610void
3611limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3612 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003613 tSirMacAddr peer,
3614 tpPESession psessionEntry,
3615 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003616{
3617 tDot11fDisassociation frm;
3618 tANI_U8 *pFrame;
3619 tSirRetStatus nSirStatus;
3620 tpSirMacMgmtHdr pMacHdr;
3621 tANI_U32 nBytes, nPayload, nStatus;
3622 void *pPacket;
3623 eHalStatus halstatus;
3624 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003625 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 if(NULL == psessionEntry)
3627 {
3628 return;
3629 }
3630
3631 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3632
3633 frm.Reason.code = nReason;
3634
3635 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3636 if ( DOT11F_FAILED( nStatus ) )
3637 {
3638 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3639 "or a Disassociation (0x%08x).\n"),
3640 nStatus );
3641 // We'll fall back on the worst case scenario:
3642 nPayload = sizeof( tDot11fDisassociation );
3643 }
3644 else if ( DOT11F_WARNED( nStatus ) )
3645 {
3646 limLog( pMac, LOGW, FL("There were warnings while calculating"
3647 "the packed size for a Disassociation "
3648 "(0x%08x).\n"), nStatus );
3649 }
3650
3651 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3652
3653 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3654 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3655 ( void** ) &pPacket );
3656 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3657 {
3658 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
3659 "association.\n"), nBytes );
3660 return;
3661 }
3662
3663 // Paranoia:
3664 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3665
3666 // Next, we fill out the buffer descriptor:
3667 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3668 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3669 if ( eSIR_SUCCESS != nSirStatus )
3670 {
3671 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3672 "tor for a Disassociation (%d).\n"),
3673 nSirStatus );
3674 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3675 ( void* ) pFrame, ( void* ) pPacket );
3676 return; // just allocated...
3677 }
3678
3679 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3680
3681 // Prepare the BSSID
3682 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3683
Chet Lanctot186b5732013-03-18 10:26:30 -07003684#ifdef WLAN_FEATURE_11W
3685 if ( psessionEntry->limRmfEnabled )
3686 {
3687 pMacHdr->fc.wep = 1;
3688 }
3689#endif
3690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3692 sizeof(tSirMacMgmtHdr),
3693 nPayload, &nPayload );
3694 if ( DOT11F_FAILED( nStatus ) )
3695 {
3696 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x).\n"),
3697 nStatus );
3698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3699 ( void* ) pFrame, ( void* ) pPacket );
3700 return; // allocated!
3701 }
3702 else if ( DOT11F_WARNED( nStatus ) )
3703 {
3704 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3705 "isassociation (0x%08x).\n") );
3706 }
3707
3708 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
3709 "son %d to\n"), nReason );
3710 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3711
3712 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3714 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 )
3716 {
3717 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3718 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003719
Ganesh K08bce952012-12-13 15:04:41 -08003720 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3721 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3722 {
3723 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3724 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003725
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003726 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003728 // Queue Disassociation frame in high priority WQ
3729 /* get the duration from the request */
3730 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3731 HAL_TXRX_FRM_802_11_MGMT,
3732 ANI_TXDIR_TODS,
3733 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3734 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3735 txFlag );
3736 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003737
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003738 if (tx_timer_change(
3739 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3740 != TX_SUCCESS)
3741 {
3742 limLog(pMac, LOGP,
3743 FL("Unable to change Disassoc ack Timer val\n"));
3744 return;
3745 }
3746 else if(TX_SUCCESS != tx_timer_activate(
3747 &pMac->lim.limTimers.gLimDisassocAckTimer))
3748 {
3749 limLog(pMac, LOGP,
3750 FL("Unable to activate Disassoc ack Timer\n"));
3751 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3752 return;
3753 }
3754 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003755 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003756 {
3757 // Queue Disassociation frame in high priority WQ
3758 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3759 HAL_TXRX_FRM_802_11_MGMT,
3760 ANI_TXDIR_TODS,
3761 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3762 limTxComplete, pFrame, txFlag );
3763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3764 {
3765 limLog( pMac, LOGE, FL("Failed to send Disassociation "
3766 "(%X)!\n"),
3767 nSirStatus );
3768 //Pkt will be freed up by the callback
3769 return;
3770 }
3771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003772} // End limSendDisassocMgmtFrame.
3773
3774/**
3775 * \brief This function is called to send a Deauthenticate frame
3776 *
3777 *
3778 * \param pMac Pointer to global MAC structure
3779 *
3780 * \param nReason Indicates the reason that need to be sent in the
3781 * Deauthenticate frame
3782 *
3783 * \param peeer address of the STA to which the frame is to be sent
3784 *
3785 *
3786 */
3787
3788void
3789limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3790 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003791 tSirMacAddr peer,
3792 tpPESession psessionEntry,
3793 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003794{
3795 tDot11fDeAuth frm;
3796 tANI_U8 *pFrame;
3797 tSirRetStatus nSirStatus;
3798 tpSirMacMgmtHdr pMacHdr;
3799 tANI_U32 nBytes, nPayload, nStatus;
3800 void *pPacket;
3801 eHalStatus halstatus;
3802 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003803 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003804#ifdef FEATURE_WLAN_TDLS
3805 tANI_U16 aid;
3806 tpDphHashNode pStaDs;
3807#endif
3808
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 if(NULL == psessionEntry)
3810 {
3811 return;
3812 }
3813
3814 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
3815
3816 frm.Reason.code = nReason;
3817
3818 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3819 if ( DOT11F_FAILED( nStatus ) )
3820 {
3821 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
3822 "or a De-Authentication (0x%08x).\n"),
3823 nStatus );
3824 // We'll fall back on the worst case scenario:
3825 nPayload = sizeof( tDot11fDeAuth );
3826 }
3827 else if ( DOT11F_WARNED( nStatus ) )
3828 {
3829 limLog( pMac, LOGW, FL("There were warnings while calculating"
3830 "the packed size for a De-Authentication "
3831 "(0x%08x).\n"), nStatus );
3832 }
3833
3834 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3835
3836 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3837 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3838 ( void** ) &pPacket );
3839 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3840 {
3841 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
3842 "Authentication.\n"), nBytes );
3843 return;
3844 }
3845
3846 // Paranoia:
3847 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3848
3849 // Next, we fill out the buffer descriptor:
3850 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3851 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3852 if ( eSIR_SUCCESS != nSirStatus )
3853 {
3854 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
3855 "tor for a De-Authentication (%d).\n"),
3856 nSirStatus );
3857 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3858 ( void* ) pFrame, ( void* ) pPacket );
3859 return; // just allocated...
3860 }
3861
3862 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3863
3864 // Prepare the BSSID
3865 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3866
Chet Lanctot186b5732013-03-18 10:26:30 -07003867#ifdef WLAN_FEATURE_11W
3868 if ( psessionEntry->limRmfEnabled )
3869 {
3870 pMacHdr->fc.wep = 1;
3871 }
3872#endif
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3875 sizeof(tSirMacMgmtHdr),
3876 nPayload, &nPayload );
3877 if ( DOT11F_FAILED( nStatus ) )
3878 {
3879 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x).\n"),
3880 nStatus );
3881 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3882 ( void* ) pFrame, ( void* ) pPacket );
3883 return;
3884 }
3885 else if ( DOT11F_WARNED( nStatus ) )
3886 {
3887 limLog( pMac, LOGW, FL("There were warnings while packing a D"
3888 "e-Authentication (0x%08x).\n") );
3889 }
3890
3891 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
3892 "son %d to\n"), nReason );
3893 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3894
3895 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3897 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 )
3899 {
3900 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3901 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003902
Ganesh K08bce952012-12-13 15:04:41 -08003903 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3904 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3905 {
3906 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3907 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003908
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003909#ifdef FEATURE_WLAN_TDLS
3910 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3911#endif
3912
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003913 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003915 // Queue Disassociation frame in high priority WQ
3916 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3917 HAL_TXRX_FRM_802_11_MGMT,
3918 ANI_TXDIR_TODS,
3919 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3920 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3921 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3922 {
3923 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
3924 "(%X)!\n"),
3925 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003926 //Pkt will be freed up by the callback limTxComplete
3927
3928 /*Call limProcessDeauthAckTimeout which will send
3929 * DeauthCnf for this frame
3930 */
3931 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003932 return;
3933 }
3934
3935 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3936
3937 if (tx_timer_change(
3938 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3939 != TX_SUCCESS)
3940 {
3941 limLog(pMac, LOGP,
3942 FL("Unable to change Deauth ack Timer val\n"));
3943 return;
3944 }
3945 else if(TX_SUCCESS != tx_timer_activate(
3946 &pMac->lim.limTimers.gLimDeauthAckTimer))
3947 {
3948 limLog(pMac, LOGP,
3949 FL("Unable to activate Deauth ack Timer\n"));
3950 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3951 return;
3952 }
3953 }
3954 else
3955 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003956#ifdef FEATURE_WLAN_TDLS
3957 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3958 {
3959 // Queue Disassociation frame in high priority WQ
3960 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003961 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003962 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003963 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3964 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003965 }
3966 else
3967 {
3968#endif
3969 // Queue Disassociation frame in high priority WQ
3970 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3971 HAL_TXRX_FRM_802_11_MGMT,
3972 ANI_TXDIR_TODS,
3973 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3974 limTxComplete, pFrame, txFlag );
3975#ifdef FEATURE_WLAN_TDLS
3976 }
3977#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003978 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3979 {
3980 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
3981 "(%X)!\n"),
3982 nSirStatus );
3983 //Pkt will be freed up by the callback
3984 return;
3985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987
3988} // End limSendDeauthMgmtFrame.
3989
3990
3991#ifdef ANI_SUPPORT_11H
3992/**
3993 * \brief Send a Measurement Report Action frame
3994 *
3995 *
3996 * \param pMac Pointer to the global MAC structure
3997 *
3998 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3999 *
4000 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4001 *
4002 *
4003 */
4004
4005tSirRetStatus
4006limSendMeasReportFrame(tpAniSirGlobal pMac,
4007 tpSirMacMeasReqActionFrame pMeasReqFrame,
4008 tSirMacAddr peer)
4009{
4010 tDot11fMeasurementReport frm;
4011 tANI_U8 *pFrame;
4012 tSirRetStatus nSirStatus;
4013 tpSirMacMgmtHdr pMacHdr;
4014 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4015 void *pPacket;
4016 eHalStatus halstatus;
4017
4018 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4019
4020 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4021 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4022 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4023
4024 switch ( pMeasReqFrame->measReqIE.measType )
4025 {
4026 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4027 nSirStatus =
4028 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4029 &frm.MeasurementReport );
4030 break;
4031 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4032 nSirStatus =
4033 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4034 &frm.MeasurementReport );
4035 break;
4036 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4037 nSirStatus =
4038 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4039 &frm.MeasurementReport );
4040 break;
4041 default:
4042 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
4043 "dMeasReportFrame.\n"),
4044 pMeasReqFrame->measReqIE.measType );
4045 return eSIR_FAILURE;
4046 }
4047
4048 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4049
4050 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4051 if ( DOT11F_FAILED( nStatus ) )
4052 {
4053 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4054 "or a Measurement Report (0x%08x).\n"),
4055 nStatus );
4056 // We'll fall back on the worst case scenario:
4057 nPayload = sizeof( tDot11fMeasurementReport );
4058 }
4059 else if ( DOT11F_WARNED( nStatus ) )
4060 {
4061 limLog( pMac, LOGW, FL("There were warnings while calculating"
4062 "the packed size for a Measurement Rep"
4063 "ort (0x%08x).\n"), nStatus );
4064 }
4065
4066 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4067
4068 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4069 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4070 {
4071 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
4072 "Authentication.\n"), nBytes );
4073 return eSIR_FAILURE;
4074 }
4075
4076 // Paranoia:
4077 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4078
4079 // Next, we fill out the buffer descriptor:
4080 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4081 SIR_MAC_MGMT_ACTION, peer);
4082 if ( eSIR_SUCCESS != nSirStatus )
4083 {
4084 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4085 "tor for a Measurement Report (%d).\n"),
4086 nSirStatus );
4087 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4088 return eSIR_FAILURE; // just allocated...
4089 }
4090
4091 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4092
4093 nCfg = 6;
4094 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4095 if ( eSIR_SUCCESS != nSirStatus )
4096 {
4097 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4098 " CFG (%d).\n"),
4099 nSirStatus );
4100 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4101 return eSIR_FAILURE; // just allocated...
4102 }
4103
Chet Lanctot186b5732013-03-18 10:26:30 -07004104#ifdef WLAN_FEATURE_11W
4105 if ( psessionEntry->limRmfEnabled )
4106 {
4107 pMacHdr->fc.wep = 1;
4108 }
4109#endif
4110
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4112 sizeof(tSirMacMgmtHdr),
4113 nPayload, &nPayload );
4114 if ( DOT11F_FAILED( nStatus ) )
4115 {
4116 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x).\n"),
4117 nStatus );
4118 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4119 return eSIR_FAILURE; // allocated!
4120 }
4121 else if ( DOT11F_WARNED( nStatus ) )
4122 {
4123 limLog( pMac, LOGW, FL("There were warnings while packing a M"
4124 "easurement Report (0x%08x).\n") );
4125 }
4126
4127 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4128 HAL_TXRX_FRM_802_11_MGMT,
4129 ANI_TXDIR_TODS,
4130 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4131 limTxComplete, pFrame, 0 );
4132 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4133 {
4134 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
4135 "(%X)!\n"),
4136 nSirStatus );
4137 //Pkt will be freed up by the callback
4138 return eSIR_FAILURE; // just allocated...
4139 }
4140
4141 return eSIR_SUCCESS;
4142
4143} // End limSendMeasReportFrame.
4144
4145
4146/**
4147 * \brief Send a TPC Request Action frame
4148 *
4149 *
4150 * \param pMac Pointer to the global MAC datastructure
4151 *
4152 * \param peer MAC address to which the frame should be sent
4153 *
4154 *
4155 */
4156
4157void
4158limSendTpcRequestFrame(tpAniSirGlobal pMac,
4159 tSirMacAddr peer)
4160{
4161 tDot11fTPCRequest frm;
4162 tANI_U8 *pFrame;
4163 tSirRetStatus nSirStatus;
4164 tpSirMacMgmtHdr pMacHdr;
4165 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4166 void *pPacket;
4167 eHalStatus halstatus;
4168
4169 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4170
4171 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4172 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4173 frm.DialogToken.token = 1;
4174 frm.TPCRequest.present = 1;
4175
4176 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4177 if ( DOT11F_FAILED( nStatus ) )
4178 {
4179 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4180 "or a TPC Request (0x%08x).\n"),
4181 nStatus );
4182 // We'll fall back on the worst case scenario:
4183 nPayload = sizeof( tDot11fTPCRequest );
4184 }
4185 else if ( DOT11F_WARNED( nStatus ) )
4186 {
4187 limLog( pMac, LOGW, FL("There were warnings while calculating"
4188 "the packed size for a TPC Request (0x"
4189 "%08x).\n"), nStatus );
4190 }
4191
4192 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4193
4194 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4195 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4196 {
4197 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4198 " Request.\n"), nBytes );
4199 return;
4200 }
4201
4202 // Paranoia:
4203 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4204
4205 // Next, we fill out the buffer descriptor:
4206 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4207 SIR_MAC_MGMT_ACTION, peer);
4208 if ( eSIR_SUCCESS != nSirStatus )
4209 {
4210 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4211 "tor for a TPC Request (%d).\n"),
4212 nSirStatus );
4213 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4214 return; // just allocated...
4215 }
4216
4217 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4218
4219 nCfg = 6;
4220 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4221 if ( eSIR_SUCCESS != nSirStatus )
4222 {
4223 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4224 " CFG (%d).\n"),
4225 nSirStatus );
4226 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4227 return; // just allocated...
4228 }
4229
Chet Lanctot186b5732013-03-18 10:26:30 -07004230#ifdef WLAN_FEATURE_11W
4231 if ( psessionEntry->limRmfEnabled )
4232 {
4233 pMacHdr->fc.wep = 1;
4234 }
4235#endif
4236
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4238 sizeof(tSirMacMgmtHdr),
4239 nPayload, &nPayload );
4240 if ( DOT11F_FAILED( nStatus ) )
4241 {
4242 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x).\n"),
4243 nStatus );
4244 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4245 return; // allocated!
4246 }
4247 else if ( DOT11F_WARNED( nStatus ) )
4248 {
4249 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4250 "PC Request (0x%08x).\n") );
4251 }
4252
4253 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4254 HAL_TXRX_FRM_802_11_MGMT,
4255 ANI_TXDIR_TODS,
4256 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4257 limTxComplete, pFrame, 0 );
4258 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4259 {
4260 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
4261 "(%X)!\n"),
4262 nSirStatus );
4263 //Pkt will be freed up by the callback
4264 return;
4265 }
4266
4267} // End limSendTpcRequestFrame.
4268
4269
4270/**
4271 * \brief Send a TPC Report Action frame
4272 *
4273 *
4274 * \param pMac Pointer to the global MAC datastructure
4275 *
4276 * \param pTpcReqFrame Pointer to the received TPC Request
4277 *
4278 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4279 *
4280 *
4281 */
4282
4283tSirRetStatus
4284limSendTpcReportFrame(tpAniSirGlobal pMac,
4285 tpSirMacTpcReqActionFrame pTpcReqFrame,
4286 tSirMacAddr peer)
4287{
4288 tDot11fTPCReport frm;
4289 tANI_U8 *pFrame;
4290 tSirRetStatus nSirStatus;
4291 tpSirMacMgmtHdr pMacHdr;
4292 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4293 void *pPacket;
4294 eHalStatus halstatus;
4295
4296 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4297
4298 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4299 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4300 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4301
4302 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4303 // "misplaced this function, need to replace:
4304 // txPower = halGetRateToPwrValue(pMac, staid,
4305 // pMac->lim.gLimCurrentChannelId, 0);
4306 frm.TPCReport.tx_power = 0;
4307 frm.TPCReport.link_margin = 0;
4308 frm.TPCReport.present = 1;
4309
4310 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4311 if ( DOT11F_FAILED( nStatus ) )
4312 {
4313 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4314 "or a TPC Report (0x%08x).\n"),
4315 nStatus );
4316 // We'll fall back on the worst case scenario:
4317 nPayload = sizeof( tDot11fTPCReport );
4318 }
4319 else if ( DOT11F_WARNED( nStatus ) )
4320 {
4321 limLog( pMac, LOGW, FL("There were warnings while calculating"
4322 "the packed size for a TPC Report (0x"
4323 "%08x).\n"), nStatus );
4324 }
4325
4326 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4327
4328 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4329 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4330 {
4331 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4332 " Report.\n"), nBytes );
4333 return eSIR_FAILURE;
4334 }
4335
4336 // Paranoia:
4337 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4338
4339 // Next, we fill out the buffer descriptor:
4340 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4341 SIR_MAC_MGMT_ACTION, peer);
4342 if ( eSIR_SUCCESS != nSirStatus )
4343 {
4344 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4345 "tor for a TPC Report (%d).\n"),
4346 nSirStatus );
4347 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4348 return eSIR_FAILURE; // just allocated...
4349 }
4350
4351 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4352
4353 nCfg = 6;
4354 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4355 if ( eSIR_SUCCESS != nSirStatus )
4356 {
4357 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4358 " CFG (%d).\n"),
4359 nSirStatus );
4360 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4361 return eSIR_FAILURE; // just allocated...
4362 }
4363
Chet Lanctot186b5732013-03-18 10:26:30 -07004364#ifdef WLAN_FEATURE_11W
4365 if ( psessionEntry->limRmfEnabled )
4366 {
4367 pMacHdr->fc.wep = 1;
4368 }
4369#endif
4370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4372 sizeof(tSirMacMgmtHdr),
4373 nPayload, &nPayload );
4374 if ( DOT11F_FAILED( nStatus ) )
4375 {
4376 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x).\n"),
4377 nStatus );
4378 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4379 return eSIR_FAILURE; // allocated!
4380 }
4381 else if ( DOT11F_WARNED( nStatus ) )
4382 {
4383 limLog( pMac, LOGW, FL("There were warnings while packing a T"
4384 "PC Report (0x%08x).\n") );
4385 }
4386
4387
4388 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4389 HAL_TXRX_FRM_802_11_MGMT,
4390 ANI_TXDIR_TODS,
4391 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4392 limTxComplete, pFrame, 0 );
4393 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4394 {
4395 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
4396 "(%X)!\n"),
4397 nSirStatus );
4398 //Pkt will be freed up by the callback
4399 return eSIR_FAILURE; // just allocated...
4400 }
4401
4402 return eSIR_SUCCESS;
4403
4404} // End limSendTpcReportFrame.
4405#endif //ANI_SUPPORT_11H
4406
4407
Jeff Johnson295189b2012-06-20 16:38:30 -07004408/**
4409 * \brief Send a Channel Switch Announcement
4410 *
4411 *
4412 * \param pMac Pointer to the global MAC datastructure
4413 *
4414 * \param peer MAC address to which this frame will be sent
4415 *
4416 * \param nMode
4417 *
4418 * \param nNewChannel
4419 *
4420 * \param nCount
4421 *
4422 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4423 *
4424 *
4425 */
4426
4427tSirRetStatus
4428limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4429 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004430 tANI_U8 nMode,
4431 tANI_U8 nNewChannel,
4432 tANI_U8 nCount,
4433 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004434{
4435 tDot11fChannelSwitch frm;
4436 tANI_U8 *pFrame;
4437 tSirRetStatus nSirStatus;
4438 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004439 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 void *pPacket;
4441 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004442 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004443
4444 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4445
4446 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4447 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4448 frm.ChanSwitchAnn.switchMode = nMode;
4449 frm.ChanSwitchAnn.newChannel = nNewChannel;
4450 frm.ChanSwitchAnn.switchCount = nCount;
4451 frm.ChanSwitchAnn.present = 1;
4452
4453 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4454 if ( DOT11F_FAILED( nStatus ) )
4455 {
4456 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4457 "or a Channel Switch (0x%08x).\n"),
4458 nStatus );
4459 // We'll fall back on the worst case scenario:
4460 nPayload = sizeof( tDot11fChannelSwitch );
4461 }
4462 else if ( DOT11F_WARNED( nStatus ) )
4463 {
4464 limLog( pMac, LOGW, FL("There were warnings while calculating"
4465 "the packed size for a Channel Switch (0x"
4466 "%08x).\n"), nStatus );
4467 }
4468
4469 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4470
4471 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4472 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4473 {
4474 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4475 " Report.\n"), nBytes );
4476 return eSIR_FAILURE;
4477 }
4478
4479 // Paranoia:
4480 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4481
4482 // Next, we fill out the buffer descriptor:
4483 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004484 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4485 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4486 palCopyMemory( pMac->hHdd,
4487 (tANI_U8 *) pMacHdr->bssId,
4488 (tANI_U8 *) psessionEntry->bssId,
4489 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 if ( eSIR_SUCCESS != nSirStatus )
4491 {
4492 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4493 "tor for a Channel Switch (%d).\n"),
4494 nSirStatus );
4495 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4496 return eSIR_FAILURE; // just allocated...
4497 }
4498
Jeff Johnsone7245742012-09-05 17:12:55 -07004499#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4501
4502 nCfg = 6;
4503 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4504 if ( eSIR_SUCCESS != nSirStatus )
4505 {
4506 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
4507 " CFG (%d).\n"),
4508 nSirStatus );
4509 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4510 return eSIR_FAILURE; // just allocated...
4511 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004512#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004513
4514#ifdef WLAN_FEATURE_11W
4515 if ( psessionEntry->limRmfEnabled )
4516 {
4517 pMacHdr->fc.wep = 1;
4518 }
4519#endif
4520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4522 sizeof(tSirMacMgmtHdr),
4523 nPayload, &nPayload );
4524 if ( DOT11F_FAILED( nStatus ) )
4525 {
4526 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4527 nStatus );
4528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4529 return eSIR_FAILURE; // allocated!
4530 }
4531 else if ( DOT11F_WARNED( nStatus ) )
4532 {
4533 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4534 "hannel Switch (0x%08x).\n") );
4535 }
4536
Jeff Johnsone7245742012-09-05 17:12:55 -07004537 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004538 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4539 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004540 )
4541 {
4542 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4545 HAL_TXRX_FRM_802_11_MGMT,
4546 ANI_TXDIR_TODS,
4547 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004548 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4550 {
4551 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4552 "(%X)!\n"),
4553 nSirStatus );
4554 //Pkt will be freed up by the callback
4555 return eSIR_FAILURE;
4556 }
4557
4558 return eSIR_SUCCESS;
4559
4560} // End limSendChannelSwitchMgmtFrame.
4561
Jeff Johnson295189b2012-06-20 16:38:30 -07004562
4563
Mohit Khanna4a70d262012-09-11 16:30:12 -07004564#ifdef WLAN_FEATURE_11AC
4565tSirRetStatus
4566limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4567 tSirMacAddr peer,
4568 tANI_U8 nMode,
4569 tpPESession psessionEntry )
4570{
4571 tDot11fOperatingMode frm;
4572 tANI_U8 *pFrame;
4573 tSirRetStatus nSirStatus;
4574 tpSirMacMgmtHdr pMacHdr;
4575 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4576 void *pPacket;
4577 eHalStatus halstatus;
4578 tANI_U8 txFlag = 0;
4579
4580 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4581
4582 frm.Category.category = SIR_MAC_ACTION_VHT;
4583 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4584 frm.OperatingMode.chanWidth = nMode;
4585 frm.OperatingMode.rxNSS = 0;
4586 frm.OperatingMode.rxNSSType = 0;
4587
4588 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4589 if ( DOT11F_FAILED( nStatus ) )
4590 {
4591 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4592 "or a Operating Mode (0x%08x).\n"),
4593 nStatus );
4594 // We'll fall back on the worst case scenario:
4595 nPayload = sizeof( tDot11fOperatingMode);
4596 }
4597 else if ( DOT11F_WARNED( nStatus ) )
4598 {
4599 limLog( pMac, LOGW, FL("There were warnings while calculating"
4600 "the packed size for a Operating Mode (0x"
4601 "%08x).\n"), nStatus );
4602 }
4603
4604 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4605
4606 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4607 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4608 {
4609 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
4610 " Report.\n"), nBytes );
4611 return eSIR_FAILURE;
4612 }
4613
4614 // Paranoia:
4615 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4616
4617
4618 // Next, we fill out the buffer descriptor:
4619 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4620 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4621 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4622 } else
4623 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4624 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4625 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4626 palCopyMemory( pMac->hHdd,
4627 (tANI_U8 *) pMacHdr->bssId,
4628 (tANI_U8 *) psessionEntry->bssId,
4629 sizeof( tSirMacAddr ));
4630 if ( eSIR_SUCCESS != nSirStatus )
4631 {
4632 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4633 "tor for a Operating Mode (%d).\n"),
4634 nSirStatus );
4635 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4636 return eSIR_FAILURE; // just allocated...
4637 }
4638 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4639 sizeof(tSirMacMgmtHdr),
4640 nPayload, &nPayload );
4641 if ( DOT11F_FAILED( nStatus ) )
4642 {
4643 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (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 Operating Mode"
4651 " (0x%08x).\n") );
4652 }
4653 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004654 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4655 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004656 )
4657 {
4658 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4659 }
4660 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4661 HAL_TXRX_FRM_802_11_MGMT,
4662 ANI_TXDIR_TODS,
4663 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4664 limTxComplete, pFrame, txFlag );
4665 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4666 {
4667 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4668 "(%X)!\n"),
4669 nSirStatus );
4670 //Pkt will be freed up by the callback
4671 return eSIR_FAILURE;
4672 }
4673
4674 return eSIR_SUCCESS;
4675}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004676
4677/**
4678 * \brief Send a VHT Channel Switch Announcement
4679 *
4680 *
4681 * \param pMac Pointer to the global MAC datastructure
4682 *
4683 * \param peer MAC address to which this frame will be sent
4684 *
4685 * \param nChanWidth
4686 *
4687 * \param nNewChannel
4688 *
4689 *
4690 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4691 *
4692 *
4693 */
4694
4695tSirRetStatus
4696limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4697 tSirMacAddr peer,
4698 tANI_U8 nChanWidth,
4699 tANI_U8 nNewChannel,
4700 tANI_U8 ncbMode,
4701 tpPESession psessionEntry )
4702{
4703 tDot11fChannelSwitch frm;
4704 tANI_U8 *pFrame;
4705 tSirRetStatus nSirStatus;
4706 tpSirMacMgmtHdr pMacHdr;
4707 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4708 void *pPacket;
4709 eHalStatus halstatus;
4710 tANI_U8 txFlag = 0;
4711
4712 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4713
4714
4715 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4716 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4717 frm.ChanSwitchAnn.switchMode = 1;
4718 frm.ChanSwitchAnn.newChannel = nNewChannel;
4719 frm.ChanSwitchAnn.switchCount = 1;
4720 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4721 frm.ExtChanSwitchAnn.present = 1;
4722 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4723 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4724 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4725 frm.ChanSwitchAnn.present = 1;
4726 frm.WiderBWChanSwitchAnn.present = 1;
4727
4728 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4729 if ( DOT11F_FAILED( nStatus ) )
4730 {
4731 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
4732 "or a Channel Switch (0x%08x).\n"),
4733 nStatus );
4734 // We'll fall back on the worst case scenario:
4735 nPayload = sizeof( tDot11fChannelSwitch );
4736 }
4737 else if ( DOT11F_WARNED( nStatus ) )
4738 {
4739 limLog( pMac, LOGW, FL("There were warnings while calculating"
4740 "the packed size for a Channel Switch (0x"
4741 "%08x).\n"), nStatus );
4742 }
4743
4744 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4745
4746 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4747 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4748 {
4749 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
4750 " Report.\n"), nBytes );
4751 return eSIR_FAILURE;
4752 }
4753 // Paranoia:
4754 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4755
4756 // Next, we fill out the buffer descriptor:
4757 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4758 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4759 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4760 palCopyMemory( pMac->hHdd,
4761 (tANI_U8 *) pMacHdr->bssId,
4762 (tANI_U8 *) psessionEntry->bssId,
4763 sizeof( tSirMacAddr ));
4764 if ( eSIR_SUCCESS != nSirStatus )
4765 {
4766 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
4767 "tor for a Channel Switch (%d).\n"),
4768 nSirStatus );
4769 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4770 return eSIR_FAILURE; // just allocated...
4771 }
4772 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4773 sizeof(tSirMacMgmtHdr),
4774 nPayload, &nPayload );
4775 if ( DOT11F_FAILED( nStatus ) )
4776 {
4777 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x).\n"),
4778 nStatus );
4779 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4780 return eSIR_FAILURE; // allocated!
4781 }
4782 else if ( DOT11F_WARNED( nStatus ) )
4783 {
4784 limLog( pMac, LOGW, FL("There were warnings while packing a C"
4785 "hannel Switch (0x%08x).\n") );
4786 }
4787
4788 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004789 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4790 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004791 )
4792 {
4793 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4794 }
4795 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4796 HAL_TXRX_FRM_802_11_MGMT,
4797 ANI_TXDIR_TODS,
4798 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4799 limTxComplete, pFrame, txFlag );
4800 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4801 {
4802 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
4803 "(%X)!\n"),
4804 nSirStatus );
4805 //Pkt will be freed up by the callback
4806 return eSIR_FAILURE;
4807 }
4808
4809 return eSIR_SUCCESS;
4810
4811} // End limSendVHTChannelSwitchMgmtFrame.
4812
4813
4814
Mohit Khanna4a70d262012-09-11 16:30:12 -07004815#endif
4816
Jeff Johnson295189b2012-06-20 16:38:30 -07004817/**
4818 * \brief Send an ADDBA Req Action Frame to peer
4819 *
4820 * \sa limSendAddBAReq
4821 *
4822 * \param pMac The global tpAniSirGlobal object
4823 *
4824 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4825 * the necessary parameters reqd by PE send the ADDBA Req Action
4826 * Frame to the peer
4827 *
4828 * \return eSIR_SUCCESS if setup completes successfully
4829 * eSIR_FAILURE is some problem is encountered
4830 */
4831tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
4832 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
4833{
4834 tDot11fAddBAReq frmAddBAReq;
4835 tANI_U8 *pAddBAReqBuffer = NULL;
4836 tpSirMacMgmtHdr pMacHdr;
4837 tANI_U32 frameLen = 0, nStatus, nPayload;
4838 tSirRetStatus statusCode;
4839 eHalStatus halStatus;
4840 void *pPacket;
4841 tANI_U8 txFlag = 0;
4842
4843 if(NULL == psessionEntry)
4844 {
4845 return eSIR_FAILURE;
4846 }
4847
4848 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
4849
4850 // Category - 3 (BA)
4851 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4852
4853 // Action - 0 (ADDBA Req)
4854 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4855
4856 // FIXME - Dialog Token, generalize this...
4857 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4858
4859 // Fill the ADDBA Parameter Set
4860 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4861 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4862 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4863
4864 // BA timeout
4865 // 0 - indicates no BA timeout
4866 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4867
4868 // BA Starting Sequence Number
4869 // Fragment number will always be zero
4870 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4871 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4872 }
4873
4874 frmAddBAReq.BAStartingSequenceControl.ssn =
4875 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4876
4877 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4878
4879 if( DOT11F_FAILED( nStatus ))
4880 {
4881 limLog( pMac, LOGW,
4882 FL( "Failed to calculate the packed size for "
4883 "an ADDBA Request (0x%08x).\n"),
4884 nStatus );
4885
4886 // We'll fall back on the worst case scenario:
4887 nPayload = sizeof( tDot11fAddBAReq );
4888 }
4889 else if( DOT11F_WARNED( nStatus ))
4890 {
4891 limLog( pMac, LOGW,
4892 FL( "There were warnings while calculating"
4893 "the packed size for an ADDBA Req (0x%08x).\n"),
4894 nStatus );
4895 }
4896
4897 // Add the MGMT header to frame length
4898 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4899
4900 // Need to allocate a buffer for ADDBA AF
4901 if( eHAL_STATUS_SUCCESS !=
4902 (halStatus = palPktAlloc( pMac->hHdd,
4903 HAL_TXRX_FRM_802_11_MGMT,
4904 (tANI_U16) frameLen,
4905 (void **) &pAddBAReqBuffer,
4906 (void **) &pPacket )))
4907 {
4908 // Log error
4909 limLog( pMac, LOGP,
4910 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
4911 frameLen,
4912 halStatus );
4913
4914 statusCode = eSIR_MEM_ALLOC_FAILED;
4915 goto returnAfterError;
4916 }
4917
4918 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
4919
4920 // Copy necessary info to BD
4921 if( eSIR_SUCCESS !=
4922 (statusCode = limPopulateMacHeader( pMac,
4923 pAddBAReqBuffer,
4924 SIR_MAC_MGMT_FRAME,
4925 SIR_MAC_MGMT_ACTION,
4926 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4927 goto returnAfterError;
4928
4929 // Update A3 with the BSSID
4930 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4931
4932 #if 0
4933 cfgLen = SIR_MAC_ADDR_LENGTH;
4934 if( eSIR_SUCCESS != cfgGetStr( pMac,
4935 WNI_CFG_BSSID,
4936 (tANI_U8 *) pMacHdr->bssId,
4937 &cfgLen ))
4938 {
4939 limLog( pMac, LOGP,
4940 FL( "Failed to retrieve WNI_CFG_BSSID while"
4941 "sending an ACTION Frame\n" ));
4942
4943 // FIXME - Need to convert to tSirRetStatus
4944 statusCode = eSIR_FAILURE;
4945 goto returnAfterError;
4946 }
4947 #endif//TO SUPPORT BT-AMP
4948 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4949
Chet Lanctot186b5732013-03-18 10:26:30 -07004950#ifdef WLAN_FEATURE_11W
4951 if ( psessionEntry->limRmfEnabled )
4952 {
4953 pMacHdr->fc.wep = 1;
4954 }
4955#endif
4956
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 // Now, we're ready to "pack" the frames
4958 nStatus = dot11fPackAddBAReq( pMac,
4959 &frmAddBAReq,
4960 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4961 nPayload,
4962 &nPayload );
4963
4964 if( DOT11F_FAILED( nStatus ))
4965 {
4966 limLog( pMac, LOGE,
4967 FL( "Failed to pack an ADDBA Req (0x%08x).\n" ),
4968 nStatus );
4969
4970 // FIXME - Need to convert to tSirRetStatus
4971 statusCode = eSIR_FAILURE;
4972 goto returnAfterError;
4973 }
4974 else if( DOT11F_WARNED( nStatus ))
4975 {
4976 limLog( pMac, LOGW,
4977 FL( "There were warnings while packing an ADDBA Req (0x%08x).\n" ));
4978 }
4979
4980 limLog( pMac, LOGW,
4981 FL( "Sending an ADDBA REQ to \n" ));
4982 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4983
4984 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4986 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 )
4988 {
4989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4990 }
4991
4992 if( eHAL_STATUS_SUCCESS !=
4993 (halStatus = halTxFrame( pMac,
4994 pPacket,
4995 (tANI_U16) frameLen,
4996 HAL_TXRX_FRM_802_11_MGMT,
4997 ANI_TXDIR_TODS,
4998 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4999 limTxComplete,
5000 pAddBAReqBuffer, txFlag )))
5001 {
5002 limLog( pMac, LOGE,
5003 FL( "halTxFrame FAILED! Status [%d]\n"),
5004 halStatus );
5005
5006 // FIXME - Need to convert eHalStatus to tSirRetStatus
5007 statusCode = eSIR_FAILURE;
5008 //Pkt will be freed up by the callback
5009 return statusCode;
5010 }
5011 else
5012 return eSIR_SUCCESS;
5013
5014returnAfterError:
5015
5016 // Release buffer, if allocated
5017 if( NULL != pAddBAReqBuffer )
5018 palPktFree( pMac->hHdd,
5019 HAL_TXRX_FRM_802_11_MGMT,
5020 (void *) pAddBAReqBuffer,
5021 (void *) pPacket );
5022
5023 return statusCode;
5024}
5025
5026/**
5027 * \brief Send an ADDBA Rsp Action Frame to peer
5028 *
5029 * \sa limSendAddBARsp
5030 *
5031 * \param pMac The global tpAniSirGlobal object
5032 *
5033 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5034 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5035 * Frame to the peer
5036 *
5037 * \return eSIR_SUCCESS if setup completes successfully
5038 * eSIR_FAILURE is some problem is encountered
5039 */
5040tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5041 tpLimMlmAddBARsp pMlmAddBARsp,
5042 tpPESession psessionEntry)
5043{
5044 tDot11fAddBARsp frmAddBARsp;
5045 tANI_U8 *pAddBARspBuffer = NULL;
5046 tpSirMacMgmtHdr pMacHdr;
5047 tANI_U32 frameLen = 0, nStatus, nPayload;
5048 tSirRetStatus statusCode;
5049 eHalStatus halStatus;
5050 void *pPacket;
5051 tANI_U8 txFlag = 0;
5052
5053 if(NULL == psessionEntry)
5054 {
5055 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!\n"));)
5056 return eSIR_FAILURE;
5057 }
5058
5059 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
5060
5061 // Category - 3 (BA)
5062 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5063 // Action - 1 (ADDBA Rsp)
5064 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5065
5066 // Should be same as the one we received in the ADDBA Req
5067 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5068
5069 // ADDBA Req status
5070 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5071
5072 // Fill the ADDBA Parameter Set as provided by caller
5073 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5074 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5075 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
5076
5077 // BA timeout
5078 // 0 - indicates no BA timeout
5079 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5080
5081 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5082
5083 if( DOT11F_FAILED( nStatus ))
5084 {
5085 limLog( pMac, LOGW,
5086 FL( "Failed to calculate the packed size for "
5087 "an ADDBA Response (0x%08x).\n"),
5088 nStatus );
5089
5090 // We'll fall back on the worst case scenario:
5091 nPayload = sizeof( tDot11fAddBARsp );
5092 }
5093 else if( DOT11F_WARNED( nStatus ))
5094 {
5095 limLog( pMac, LOGW,
5096 FL( "There were warnings while calculating"
5097 "the packed size for an ADDBA Rsp (0x%08x).\n"),
5098 nStatus );
5099 }
5100
5101 // Need to allocate a buffer for ADDBA AF
5102 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5103
5104 // Allocate shared memory
5105 if( eHAL_STATUS_SUCCESS !=
5106 (halStatus = palPktAlloc( pMac->hHdd,
5107 HAL_TXRX_FRM_802_11_MGMT,
5108 (tANI_U16) frameLen,
5109 (void **) &pAddBARspBuffer,
5110 (void **) &pPacket )))
5111 {
5112 // Log error
5113 limLog( pMac, LOGP,
5114 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5115 frameLen,
5116 halStatus );
5117
5118 statusCode = eSIR_MEM_ALLOC_FAILED;
5119 goto returnAfterError;
5120 }
5121
5122 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5123
5124 // Copy necessary info to BD
5125 if( eSIR_SUCCESS !=
5126 (statusCode = limPopulateMacHeader( pMac,
5127 pAddBARspBuffer,
5128 SIR_MAC_MGMT_FRAME,
5129 SIR_MAC_MGMT_ACTION,
5130 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5131 goto returnAfterError;
5132
5133 // Update A3 with the BSSID
5134
5135 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5136
5137 #if 0
5138 cfgLen = SIR_MAC_ADDR_LENGTH;
5139 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5140 WNI_CFG_BSSID,
5141 (tANI_U8 *) pMacHdr->bssId,
5142 &cfgLen ))
5143 {
5144 limLog( pMac, LOGP,
5145 FL( "Failed to retrieve WNI_CFG_BSSID while"
5146 "sending an ACTION Frame\n" ));
5147
5148 // FIXME - Need to convert to tSirRetStatus
5149 statusCode = eSIR_FAILURE;
5150 goto returnAfterError;
5151 }
5152 #endif // TO SUPPORT BT-AMP
5153 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5154
Chet Lanctot186b5732013-03-18 10:26:30 -07005155#ifdef WLAN_FEATURE_11W
5156 if ( psessionEntry->limRmfEnabled )
5157 {
5158 pMacHdr->fc.wep = 1;
5159 }
5160#endif
5161
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 // Now, we're ready to "pack" the frames
5163 nStatus = dot11fPackAddBARsp( pMac,
5164 &frmAddBARsp,
5165 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5166 nPayload,
5167 &nPayload );
5168
5169 if( DOT11F_FAILED( nStatus ))
5170 {
5171 limLog( pMac, LOGE,
5172 FL( "Failed to pack an ADDBA Rsp (0x%08x).\n" ),
5173 nStatus );
5174
5175 // FIXME - Need to convert to tSirRetStatus
5176 statusCode = eSIR_FAILURE;
5177 goto returnAfterError;
5178 }
5179 else if( DOT11F_WARNED( nStatus ))
5180 {
5181 limLog( pMac, LOGW,
5182 FL( "There were warnings while packing an ADDBA Rsp (0x%08x).\n" ));
5183 }
5184
5185 limLog( pMac, LOGW,
5186 FL( "Sending an ADDBA RSP to \n" ));
5187 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5188
5189 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5191 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 )
5193 {
5194 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5195 }
5196
5197 if( eHAL_STATUS_SUCCESS !=
5198 (halStatus = halTxFrame( pMac,
5199 pPacket,
5200 (tANI_U16) frameLen,
5201 HAL_TXRX_FRM_802_11_MGMT,
5202 ANI_TXDIR_TODS,
5203 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5204 limTxComplete,
5205 pAddBARspBuffer, txFlag )))
5206 {
5207 limLog( pMac, LOGE,
5208 FL( "halTxFrame FAILED! Status [%d]\n" ),
5209 halStatus );
5210
5211 // FIXME - HAL error codes are different from PE error
5212 // codes!! And, this routine is returning tSirRetStatus
5213 statusCode = eSIR_FAILURE;
5214 //Pkt will be freed up by the callback
5215 return statusCode;
5216 }
5217 else
5218 return eSIR_SUCCESS;
5219
5220 returnAfterError:
5221
5222 // Release buffer, if allocated
5223 if( NULL != pAddBARspBuffer )
5224 palPktFree( pMac->hHdd,
5225 HAL_TXRX_FRM_802_11_MGMT,
5226 (void *) pAddBARspBuffer,
5227 (void *) pPacket );
5228
5229 return statusCode;
5230}
5231
5232/**
5233 * \brief Send a DELBA Indication Action Frame to peer
5234 *
5235 * \sa limSendDelBAInd
5236 *
5237 * \param pMac The global tpAniSirGlobal object
5238 *
5239 * \param peerMacAddr MAC Address of peer
5240 *
5241 * \param reasonCode Reason for the DELBA notification
5242 *
5243 * \param pBAParameterSet The DELBA Parameter Set.
5244 * This identifies the TID for which the BA session is
5245 * being deleted.
5246 *
5247 * \return eSIR_SUCCESS if setup completes successfully
5248 * eSIR_FAILURE is some problem is encountered
5249 */
5250tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5251 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5252{
5253 tDot11fDelBAInd frmDelBAInd;
5254 tANI_U8 *pDelBAIndBuffer = NULL;
5255 //tANI_U32 val;
5256 tpSirMacMgmtHdr pMacHdr;
5257 tANI_U32 frameLen = 0, nStatus, nPayload;
5258 tSirRetStatus statusCode;
5259 eHalStatus halStatus;
5260 void *pPacket;
5261 tANI_U8 txFlag = 0;
5262
5263 if(NULL == psessionEntry)
5264 {
5265 return eSIR_FAILURE;
5266 }
5267
5268 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5269
5270 // Category - 3 (BA)
5271 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5272 // Action - 2 (DELBA)
5273 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5274
5275 // Fill the DELBA Parameter Set as provided by caller
5276 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5277 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5278
5279 // BA Starting Sequence Number
5280 // Fragment number will always be zero
5281 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5282
5283 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5284
5285 if( DOT11F_FAILED( nStatus ))
5286 {
5287 limLog( pMac, LOGW,
5288 FL( "Failed to calculate the packed size for "
5289 "an DELBA Indication (0x%08x).\n"),
5290 nStatus );
5291
5292 // We'll fall back on the worst case scenario:
5293 nPayload = sizeof( tDot11fDelBAInd );
5294 }
5295 else if( DOT11F_WARNED( nStatus ))
5296 {
5297 limLog( pMac, LOGW,
5298 FL( "There were warnings while calculating"
5299 "the packed size for an DELBA Ind (0x%08x).\n"),
5300 nStatus );
5301 }
5302
5303 // Add the MGMT header to frame length
5304 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5305
5306 // Allocate shared memory
5307 if( eHAL_STATUS_SUCCESS !=
5308 (halStatus = palPktAlloc( pMac->hHdd,
5309 HAL_TXRX_FRM_802_11_MGMT,
5310 (tANI_U16) frameLen,
5311 (void **) &pDelBAIndBuffer,
5312 (void **) &pPacket )))
5313 {
5314 // Log error
5315 limLog( pMac, LOGP,
5316 FL("palPktAlloc FAILED! Length [%d], Status [%d]\n"),
5317 frameLen,
5318 halStatus );
5319
5320 statusCode = eSIR_MEM_ALLOC_FAILED;
5321 goto returnAfterError;
5322 }
5323
5324 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5325
5326 // Copy necessary info to BD
5327 if( eSIR_SUCCESS !=
5328 (statusCode = limPopulateMacHeader( pMac,
5329 pDelBAIndBuffer,
5330 SIR_MAC_MGMT_FRAME,
5331 SIR_MAC_MGMT_ACTION,
5332 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5333 goto returnAfterError;
5334
5335 // Update A3 with the BSSID
5336 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5337
5338 #if 0
5339 cfgLen = SIR_MAC_ADDR_LENGTH;
5340 if( eSIR_SUCCESS != cfgGetStr( pMac,
5341 WNI_CFG_BSSID,
5342 (tANI_U8 *) pMacHdr->bssId,
5343 &cfgLen ))
5344 {
5345 limLog( pMac, LOGP,
5346 FL( "Failed to retrieve WNI_CFG_BSSID while"
5347 "sending an ACTION Frame\n" ));
5348
5349 // FIXME - Need to convert to tSirRetStatus
5350 statusCode = eSIR_FAILURE;
5351 goto returnAfterError;
5352 }
5353 #endif //TO SUPPORT BT-AMP
5354 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5355
Chet Lanctot186b5732013-03-18 10:26:30 -07005356#ifdef WLAN_FEATURE_11W
5357 if ( psessionEntry->limRmfEnabled )
5358 {
5359 pMacHdr->fc.wep = 1;
5360 }
5361#endif
5362
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 // Now, we're ready to "pack" the frames
5364 nStatus = dot11fPackDelBAInd( pMac,
5365 &frmDelBAInd,
5366 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5367 nPayload,
5368 &nPayload );
5369
5370 if( DOT11F_FAILED( nStatus ))
5371 {
5372 limLog( pMac, LOGE,
5373 FL( "Failed to pack an DELBA Ind (0x%08x).\n" ),
5374 nStatus );
5375
5376 // FIXME - Need to convert to tSirRetStatus
5377 statusCode = eSIR_FAILURE;
5378 goto returnAfterError;
5379 }
5380 else if( DOT11F_WARNED( nStatus ))
5381 {
5382 limLog( pMac, LOGW,
5383 FL( "There were warnings while packing an DELBA Ind (0x%08x).\n" ));
5384 }
5385
5386 limLog( pMac, LOGW,
5387 FL( "Sending a DELBA IND to \n" ));
5388 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5389
5390 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5392 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 )
5394 {
5395 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5396 }
5397
5398 if( eHAL_STATUS_SUCCESS !=
5399 (halStatus = halTxFrame( pMac,
5400 pPacket,
5401 (tANI_U16) frameLen,
5402 HAL_TXRX_FRM_802_11_MGMT,
5403 ANI_TXDIR_TODS,
5404 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5405 limTxComplete,
5406 pDelBAIndBuffer, txFlag )))
5407 {
5408 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halStatus );)
5409 statusCode = eSIR_FAILURE;
5410 //Pkt will be freed up by the callback
5411 return statusCode;
5412 }
5413 else
5414 return eSIR_SUCCESS;
5415
5416 returnAfterError:
5417
5418 // Release buffer, if allocated
5419 if( NULL != pDelBAIndBuffer )
5420 palPktFree( pMac->hHdd,
5421 HAL_TXRX_FRM_802_11_MGMT,
5422 (void *) pDelBAIndBuffer,
5423 (void *) pPacket );
5424
5425 return statusCode;
5426}
5427
5428#if defined WLAN_FEATURE_VOWIFI
5429
5430/**
5431 * \brief Send a Neighbor Report Request Action frame
5432 *
5433 *
5434 * \param pMac Pointer to the global MAC structure
5435 *
5436 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5437 *
5438 * \param peer mac address of peer station.
5439 *
5440 * \param psessionEntry address of session entry.
5441 *
5442 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5443 *
5444 *
5445 */
5446
5447tSirRetStatus
5448limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5449 tpSirMacNeighborReportReq pNeighborReq,
5450 tSirMacAddr peer,
5451 tpPESession psessionEntry
5452 )
5453{
5454 tSirRetStatus statusCode = eSIR_SUCCESS;
5455 tDot11fNeighborReportRequest frm;
5456 tANI_U8 *pFrame;
5457 tpSirMacMgmtHdr pMacHdr;
5458 tANI_U32 nBytes, nPayload, nStatus;
5459 void *pPacket;
5460 eHalStatus halstatus;
5461 tANI_U8 txFlag = 0;
5462
5463 if ( psessionEntry == NULL )
5464 {
5465 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame\n") );
5466 return eSIR_FAILURE;
5467 }
5468 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5469
5470 frm.Category.category = SIR_MAC_ACTION_RRM;
5471 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5472 frm.DialogToken.token = pNeighborReq->dialogToken;
5473
5474
5475 if( pNeighborReq->ssid_present )
5476 {
5477 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5478 }
5479
5480 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5481 if ( DOT11F_FAILED( nStatus ) )
5482 {
5483 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5484 "or a Neighbor Report Request(0x%08x).\n"),
5485 nStatus );
5486 // We'll fall back on the worst case scenario:
5487 nPayload = sizeof( tDot11fNeighborReportRequest );
5488 }
5489 else if ( DOT11F_WARNED( nStatus ) )
5490 {
5491 limLog( pMac, LOGW, FL("There were warnings while calculating"
5492 "the packed size for a Neighbor Rep"
5493 "ort Request(0x%08x).\n"), nStatus );
5494 }
5495
5496 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5497
5498 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5499 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5500 {
5501 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
5502 "Report Request.\n"), nBytes );
5503 return eSIR_FAILURE;
5504 }
5505
5506 // Paranoia:
5507 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5508
5509 // Copy necessary info to BD
5510 if( eSIR_SUCCESS !=
5511 (statusCode = limPopulateMacHeader( pMac,
5512 pFrame,
5513 SIR_MAC_MGMT_FRAME,
5514 SIR_MAC_MGMT_ACTION,
5515 peer, psessionEntry->selfMacAddr)))
5516 goto returnAfterError;
5517
5518 // Update A3 with the BSSID
5519 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5520
5521 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5522
Chet Lanctot186b5732013-03-18 10:26:30 -07005523#ifdef WLAN_FEATURE_11W
5524 if ( psessionEntry->limRmfEnabled )
5525 {
5526 pMacHdr->fc.wep = 1;
5527 }
5528#endif
5529
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 // Now, we're ready to "pack" the frames
5531 nStatus = dot11fPackNeighborReportRequest( pMac,
5532 &frm,
5533 pFrame + sizeof( tSirMacMgmtHdr ),
5534 nPayload,
5535 &nPayload );
5536
5537 if( DOT11F_FAILED( nStatus ))
5538 {
5539 limLog( pMac, LOGE,
5540 FL( "Failed to pack an Neighbor Report Request (0x%08x).\n" ),
5541 nStatus );
5542
5543 // FIXME - Need to convert to tSirRetStatus
5544 statusCode = eSIR_FAILURE;
5545 goto returnAfterError;
5546 }
5547 else if( DOT11F_WARNED( nStatus ))
5548 {
5549 limLog( pMac, LOGW,
5550 FL( "There were warnings while packing Neighbor Report Request (0x%08x).\n" ));
5551 }
5552
5553 limLog( pMac, LOGW,
5554 FL( "Sending a Neighbor Report Request to \n" ));
5555 limPrintMacAddr( pMac, peer, LOGW );
5556
5557 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5559 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 )
5561 {
5562 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5563 }
5564
5565 if( eHAL_STATUS_SUCCESS !=
5566 (halstatus = halTxFrame( pMac,
5567 pPacket,
5568 (tANI_U16) nBytes,
5569 HAL_TXRX_FRM_802_11_MGMT,
5570 ANI_TXDIR_TODS,
5571 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5572 limTxComplete,
5573 pFrame, txFlag )))
5574 {
5575 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5576 statusCode = eSIR_FAILURE;
5577 //Pkt will be freed up by the callback
5578 return statusCode;
5579 }
5580 else
5581 return eSIR_SUCCESS;
5582
5583returnAfterError:
5584 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5585
5586 return statusCode;
5587} // End limSendNeighborReportRequestFrame.
5588
5589/**
5590 * \brief Send a Link Report Action frame
5591 *
5592 *
5593 * \param pMac Pointer to the global MAC structure
5594 *
5595 * \param pLinkReport Address of a tSirMacLinkReport
5596 *
5597 * \param peer mac address of peer station.
5598 *
5599 * \param psessionEntry address of session entry.
5600 *
5601 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5602 *
5603 *
5604 */
5605
5606tSirRetStatus
5607limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5608 tpSirMacLinkReport pLinkReport,
5609 tSirMacAddr peer,
5610 tpPESession psessionEntry
5611 )
5612{
5613 tSirRetStatus statusCode = eSIR_SUCCESS;
5614 tDot11fLinkMeasurementReport frm;
5615 tANI_U8 *pFrame;
5616 tpSirMacMgmtHdr pMacHdr;
5617 tANI_U32 nBytes, nPayload, nStatus;
5618 void *pPacket;
5619 eHalStatus halstatus;
5620 tANI_U8 txFlag = 0;
5621
5622
5623 if ( psessionEntry == NULL )
5624 {
5625 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame\n") );
5626 return eSIR_FAILURE;
5627 }
5628
5629 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5630
5631 frm.Category.category = SIR_MAC_ACTION_RRM;
5632 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5633 frm.DialogToken.token = pLinkReport->dialogToken;
5634
5635
5636 //IEEE Std. 802.11 7.3.2.18. for the report element.
5637 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5638 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5639 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5640 //such case this way than changing the frame parser.
5641 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5642 frm.TPCEleLen.TPCLen = 2;
5643 frm.TxPower.txPower = pLinkReport->txPower;
5644 frm.LinkMargin.linkMargin = 0;
5645
5646 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5647 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5648 frm.RCPI.rcpi = pLinkReport->rcpi;
5649 frm.RSNI.rsni = pLinkReport->rsni;
5650
5651 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5652 if ( DOT11F_FAILED( nStatus ) )
5653 {
5654 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5655 "or a Link Report (0x%08x).\n"),
5656 nStatus );
5657 // We'll fall back on the worst case scenario:
5658 nPayload = sizeof( tDot11fLinkMeasurementReport );
5659 }
5660 else if ( DOT11F_WARNED( nStatus ) )
5661 {
5662 limLog( pMac, LOGW, FL("There were warnings while calculating"
5663 "the packed size for a Link Rep"
5664 "ort (0x%08x).\n"), nStatus );
5665 }
5666
5667 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5668
5669 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5670 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5671 {
5672 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
5673 "Report.\n"), nBytes );
5674 return eSIR_FAILURE;
5675 }
5676
5677 // Paranoia:
5678 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5679
5680 // Copy necessary info to BD
5681 if( eSIR_SUCCESS !=
5682 (statusCode = limPopulateMacHeader( pMac,
5683 pFrame,
5684 SIR_MAC_MGMT_FRAME,
5685 SIR_MAC_MGMT_ACTION,
5686 peer, psessionEntry->selfMacAddr)))
5687 goto returnAfterError;
5688
5689 // Update A3 with the BSSID
5690 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5691
5692 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5693
Chet Lanctot186b5732013-03-18 10:26:30 -07005694#ifdef WLAN_FEATURE_11W
5695 if ( psessionEntry->limRmfEnabled )
5696 {
5697 pMacHdr->fc.wep = 1;
5698 }
5699#endif
5700
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 // Now, we're ready to "pack" the frames
5702 nStatus = dot11fPackLinkMeasurementReport( pMac,
5703 &frm,
5704 pFrame + sizeof( tSirMacMgmtHdr ),
5705 nPayload,
5706 &nPayload );
5707
5708 if( DOT11F_FAILED( nStatus ))
5709 {
5710 limLog( pMac, LOGE,
5711 FL( "Failed to pack an Link Report (0x%08x).\n" ),
5712 nStatus );
5713
5714 // FIXME - Need to convert to tSirRetStatus
5715 statusCode = eSIR_FAILURE;
5716 goto returnAfterError;
5717 }
5718 else if( DOT11F_WARNED( nStatus ))
5719 {
5720 limLog( pMac, LOGW,
5721 FL( "There were warnings while packing Link Report (0x%08x).\n" ));
5722 }
5723
5724 limLog( pMac, LOGW,
5725 FL( "Sending a Link Report to \n" ));
5726 limPrintMacAddr( pMac, peer, LOGW );
5727
5728 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5730 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 )
5732 {
5733 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5734 }
5735
5736 if( eHAL_STATUS_SUCCESS !=
5737 (halstatus = halTxFrame( pMac,
5738 pPacket,
5739 (tANI_U16) nBytes,
5740 HAL_TXRX_FRM_802_11_MGMT,
5741 ANI_TXDIR_TODS,
5742 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5743 limTxComplete,
5744 pFrame, txFlag )))
5745 {
5746 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5747 statusCode = eSIR_FAILURE;
5748 //Pkt will be freed up by the callback
5749 return statusCode;
5750 }
5751 else
5752 return eSIR_SUCCESS;
5753
5754returnAfterError:
5755 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5756
5757 return statusCode;
5758} // End limSendLinkReportActionFrame.
5759
5760/**
5761 * \brief Send a Beacon Report Action frame
5762 *
5763 *
5764 * \param pMac Pointer to the global MAC structure
5765 *
5766 * \param dialog_token dialog token to be used in the action frame.
5767 *
5768 * \param num_report number of reports in pRRMReport.
5769 *
5770 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5771 *
5772 * \param peer mac address of peer station.
5773 *
5774 * \param psessionEntry address of session entry.
5775 *
5776 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5777 *
5778 *
5779 */
5780
5781tSirRetStatus
5782limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5783 tANI_U8 dialog_token,
5784 tANI_U8 num_report,
5785 tpSirMacRadioMeasureReport pRRMReport,
5786 tSirMacAddr peer,
5787 tpPESession psessionEntry
5788 )
5789{
5790 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 tANI_U8 *pFrame;
5792 tpSirMacMgmtHdr pMacHdr;
5793 tANI_U32 nBytes, nPayload, nStatus;
5794 void *pPacket;
5795 eHalStatus halstatus;
5796 tANI_U8 i;
5797 tANI_U8 txFlag = 0;
5798
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005799 tDot11fRadioMeasurementReport *frm =
5800 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5801 if (!frm) {
5802 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport\n") );
5803 return eSIR_FAILURE;
5804 }
5805
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 if ( psessionEntry == NULL )
5807 {
5808 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame\n") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005809 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 return eSIR_FAILURE;
5811 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005812 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005813
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005814 frm->Category.category = SIR_MAC_ACTION_RRM;
5815 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5816 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005817
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005818 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 -07005819
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005820 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005822 frm->MeasurementReport[i].type = pRRMReport[i].type;
5823 frm->MeasurementReport[i].token = pRRMReport[i].token;
5824 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 switch( pRRMReport[i].type )
5826 {
5827 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005828 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5829 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5830 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5831 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 break;
5833 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305834 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5835 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005836 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 break;
5838 }
5839 }
5840
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005841 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 if ( DOT11F_FAILED( nStatus ) )
5843 {
5844 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
5845 "or a Radio Measure Report (0x%08x).\n"),
5846 nStatus );
5847 // We'll fall back on the worst case scenario:
5848 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005849 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 return eSIR_FAILURE;
5851 }
5852 else if ( DOT11F_WARNED( nStatus ) )
5853 {
5854 limLog( pMac, LOGW, FL("There were warnings while calculating"
5855 "the packed size for a Radio Measure Rep"
5856 "ort (0x%08x).\n"), nStatus );
5857 }
5858
5859 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5860
5861 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5862 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5863 {
5864 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
5865 "Report.\n"), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005866 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 return eSIR_FAILURE;
5868 }
5869
5870 // Paranoia:
5871 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5872
5873 // Copy necessary info to BD
5874 if( eSIR_SUCCESS !=
5875 (statusCode = limPopulateMacHeader( pMac,
5876 pFrame,
5877 SIR_MAC_MGMT_FRAME,
5878 SIR_MAC_MGMT_ACTION,
5879 peer, psessionEntry->selfMacAddr)))
5880 goto returnAfterError;
5881
5882 // Update A3 with the BSSID
5883 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5884
5885 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5886
Chet Lanctot186b5732013-03-18 10:26:30 -07005887#ifdef WLAN_FEATURE_11W
5888 if ( psessionEntry->limRmfEnabled )
5889 {
5890 pMacHdr->fc.wep = 1;
5891 }
5892#endif
5893
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 // Now, we're ready to "pack" the frames
5895 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005896 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 pFrame + sizeof( tSirMacMgmtHdr ),
5898 nPayload,
5899 &nPayload );
5900
5901 if( DOT11F_FAILED( nStatus ))
5902 {
5903 limLog( pMac, LOGE,
5904 FL( "Failed to pack an Radio Measure Report (0x%08x).\n" ),
5905 nStatus );
5906
5907 // FIXME - Need to convert to tSirRetStatus
5908 statusCode = eSIR_FAILURE;
5909 goto returnAfterError;
5910 }
5911 else if( DOT11F_WARNED( nStatus ))
5912 {
5913 limLog( pMac, LOGW,
5914 FL( "There were warnings while packing Radio Measure Report (0x%08x).\n" ));
5915 }
5916
5917 limLog( pMac, LOGW,
5918 FL( "Sending a Radio Measure Report to \n" ));
5919 limPrintMacAddr( pMac, peer, LOGW );
5920
5921 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5923 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 )
5925 {
5926 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5927 }
5928
5929 if( eHAL_STATUS_SUCCESS !=
5930 (halstatus = halTxFrame( pMac,
5931 pPacket,
5932 (tANI_U16) nBytes,
5933 HAL_TXRX_FRM_802_11_MGMT,
5934 ANI_TXDIR_TODS,
5935 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5936 limTxComplete,
5937 pFrame, txFlag )))
5938 {
5939 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]\n" ), halstatus );)
5940 statusCode = eSIR_FAILURE;
5941 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005942 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 return statusCode;
5944 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005945 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005946 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005949
5950returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005951 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 return statusCode;
5954} // End limSendBeaconReportActionFrame.
5955
5956#endif
5957
5958#ifdef WLAN_FEATURE_11W
5959/**
5960 * \brief Send SA query response action frame to peer
5961 *
5962 * \sa limSendSaQueryResponseFrame
5963 *
5964 *
5965 * \param pMac The global tpAniSirGlobal object
5966 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005967 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005969 * \param peer The Mac address of the AP to which this action frame is addressed
5970 *
5971 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 *
5973 * \return eSIR_SUCCESS if setup completes successfully
5974 * eSIR_FAILURE is some problem is encountered
5975 */
5976
Chet Lanctot186b5732013-03-18 10:26:30 -07005977tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005978tSirMacAddr peer,tpPESession psessionEntry)
5979{
5980
Chet Lanctot186b5732013-03-18 10:26:30 -07005981 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 tANI_U8 *pFrame;
5983 tSirRetStatus nSirStatus;
5984 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005985 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 void *pPacket;
5987 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005988 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005989
5990 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
Chet Lanctot186b5732013-03-18 10:26:30 -07005991 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5992 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 action: 0 --> SA query request action frame
5994 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005995 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5996 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005998 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005999
Chet Lanctot186b5732013-03-18 10:26:30 -07006000 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6001 if ( DOT11F_FAILED( nStatus ) )
6002 {
6003 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6004 "or a SA Query Response (0x%08x)."),
6005 nStatus );
6006 // We'll fall back on the worst case scenario:
6007 nPayload = sizeof( tDot11fSaQueryRsp );
6008 }
6009 else if ( DOT11F_WARNED( nStatus ) )
6010 {
6011 limLog( pMac, LOGW, FL("There were warnings while calculating"
6012 "the packed size for an SA Query Response"
6013 " (0x%08x)."), nStatus );
6014 }
6015
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6017 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6018 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6019 {
6020 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
6021 " action frame\n"), nBytes );
6022 return eSIR_FAILURE;
6023 }
6024
6025 // Paranoia:
6026 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6027
Chet Lanctot186b5732013-03-18 10:26:30 -07006028 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006029 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006030 pFrame,
6031 SIR_MAC_MGMT_FRAME,
6032 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006033 peer, psessionEntry->selfMacAddr );
6034 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006035 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006036
Chet Lanctot186b5732013-03-18 10:26:30 -07006037 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6039
Chet Lanctot186b5732013-03-18 10:26:30 -07006040 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006041
Chet Lanctot186b5732013-03-18 10:26:30 -07006042 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6043 // in the FC
6044 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006046 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 }
6048
Chet Lanctot186b5732013-03-18 10:26:30 -07006049 // Pack 11w SA query response frame
6050 nStatus = dot11fPackSaQueryRsp( pMac,
6051 &frm,
6052 pFrame + sizeof( tSirMacMgmtHdr ),
6053 nPayload,
6054 &nPayload );
6055
6056 if ( DOT11F_FAILED( nStatus ))
6057 {
6058 limLog( pMac, LOGE,
6059 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6060 nStatus );
6061 // FIXME - Need to convert to tSirRetStatus
6062 nSirStatus = eSIR_FAILURE;
6063 goto returnAfterError;
6064 }
6065 else if ( DOT11F_WARNED( nStatus ))
6066 {
6067 limLog( pMac, LOGW,
6068 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6069 nStatus);
6070 }
6071
6072 limLog( pMac, LOG1,
6073 FL( "Sending a SA Query Response to " ));
6074 limPrintMacAddr( pMac, peer, LOGW );
6075
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006076 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006077#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006078 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6079 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006080#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006081 )
6082 {
6083 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6084 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006085
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006086 halstatus = halTxFrame( pMac,
6087 pPacket,
6088 (tANI_U16) nBytes,
6089 HAL_TXRX_FRM_802_11_MGMT,
6090 ANI_TXDIR_TODS,
6091 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6092 limTxComplete,
6093 pFrame, txFlag );
6094 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006095 {
6096 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6097 nSirStatus = eSIR_FAILURE;
6098 //Pkt will be freed up by the callback
6099 return nSirStatus;
6100 }
6101 else {
6102 return eSIR_SUCCESS;
6103 }
6104
6105returnAfterError:
6106 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6107 return nSirStatus;
6108} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006109#endif