blob: 45b292a632d55e3033cfa0455f79b1efa286495d [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
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
132
133 // Prepare Address 3
134 palCopyMemory( pMac->hHdd,
135 (tANI_U8 *) pMacHdr->bssId,
136 (tANI_U8 *) peerAddr,
137 sizeof( tSirMacAddr ));
138 return statusCode;
139} /*** end limPopulateMacHeader() ***/
140
141/**
142 * \brief limSendProbeReqMgmtFrame
143 *
144 *
145 * \param pMac Pointer to Global MAC structure
146 *
147 * \param pSsid SSID to be sent in Probe Request frame
148 *
149 * \param bssid BSSID to be sent in Probe Request frame
150 *
151 * \param nProbeDelay probe delay to be used before sending Probe Request
152 * frame
153 *
154 * \param nChannelNum Channel # on which the Probe Request is going out
155 *
156 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
157 *
158 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
159 *
160 * This function is called by various LIM modules to send Probe Request frame
161 * during active scan/learn phase.
162 * Probe request is sent out in the following scenarios:
163 * --heartbeat failure: session needed
164 * --join req: session needed
165 * --foreground scan: no session
166 * --background scan: no session
167 * --schBeaconProcessing: to get EDCA parameters: session needed
168 *
169 *
170 */
171tSirRetStatus
172limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
173 tSirMacSSid *pSsid,
174 tSirMacAddr bssid,
175 tANI_U8 nChannelNum,
176 tSirMacAddr SelfMacAddr,
177 tANI_U32 dot11mode,
178 tANI_U32 nAdditionalIELen,
179 tANI_U8 *pAdditionalIE)
180{
181 tDot11fProbeRequest pr;
182 tANI_U32 nStatus, nBytes, nPayload;
183 tSirRetStatus nSirStatus;
184 tANI_U8 *pFrame;
185 void *pPacket;
186 eHalStatus halstatus;
187 tpPESession psessionEntry;
188 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 tANI_U8 txFlag = 0;
191
192#ifndef GEN4_SCAN
193 return eSIR_FAILURE;
194#endif
195
196#if defined ( ANI_DVT_DEBUG )
197 return eSIR_FAILURE;
198#endif
199
200 /*
201 * session context may or may not be present, when probe request needs to be sent out.
202 * following cases exist:
203 * --heartbeat failure: session needed
204 * --join req: session needed
205 * --foreground scan: no session
206 * --background scan: no session
207 * --schBeaconProcessing: to get EDCA parameters: session needed
208 * If session context does not exist, some IEs will be populated from CFGs,
209 * e.g. Supported and Extended rate set IEs
210 */
211 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
212
213 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
214 // and then hand it off to 'dot11fPackProbeRequest' (for
215 // serialization). We start by zero-initializing the structure:
216 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
217
218 // & delegating to assorted helpers:
219 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
220
Jeff Johnson295189b2012-06-20 16:38:30 -0700221 if( nAdditionalIELen && pAdditionalIE )
222 {
223 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
224 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700225 /* Don't include 11b rate only when device is doing P2P Search */
226 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
227 ( p2pIe != NULL ) &&
228 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
229 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
230 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
231 ( ( psessionEntry != NULL ) &&
232 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
233 )
234 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 {
236 /* In the below API pass channel number > 14, do that it fills only
237 * 11a rates in supported rates */
238 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
239 }
240 else
241 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 PopulateDot11fSuppRates( pMac, nChannelNum,
243 &pr.SuppRates,psessionEntry);
244
245 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
246 {
247 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
248 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251#if defined WLAN_FEATURE_VOWIFI
252 //Table 7-14 in IEEE Std. 802.11k-2008 says
253 //DS params "can" be present in RRM is disabled and "is" present if
254 //RRM is enabled. It should be ok even if we add it into probe req when
255 //RRM is not enabled.
256 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
257 //Call RRM module to get the tx power for management used.
258 {
259 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
260 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
261 }
262#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700265 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700267 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700269 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700271 } else { //psessionEntry == NULL
272 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700274 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 }
276 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800277
278 /* Set channelbonding information as "disabled" when tunned to a 2.4 GHz channel */
279 if( nChannelNum <= SIR_11B_CHANNEL_END)
280 {
281 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
282 pr.HTCaps.shortGI40MHz = 0;
283 }
284
Jeff Johnsone7245742012-09-05 17:12:55 -0700285#ifdef WLAN_FEATURE_11AC
286 if (psessionEntry != NULL ) {
287 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
288 //Include HT Capability IE
289 if (psessionEntry->vhtCapability)
290 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700291 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
292 }
293 } else {
294 if (IS_DOT11_MODE_VHT(dot11mode))
295 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700296 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
297 }
298 }
299#endif
300
Jeff Johnson295189b2012-06-20 16:38:30 -0700301
302 // That's it-- now we pack it. First, how much space are we going to
303 // need?
304 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
305 if ( DOT11F_FAILED( nStatus ) )
306 {
307 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700308 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 // We'll fall back on the worst case scenario:
310 nPayload = sizeof( tDot11fProbeRequest );
311 }
312 else if ( DOT11F_WARNED( nStatus ) )
313 {
314 limLog( pMac, LOGW, FL("There were warnings while calculating"
315 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700316 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 }
318
319 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
320
321 // Ok-- try to allocate some memory:
322 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
323 ( tANI_U16 )nBytes, ( void** ) &pFrame,
324 ( void** ) &pPacket );
325 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
326 {
327 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700328 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return eSIR_MEM_ALLOC_FAILED;
330 }
331
332 // Paranoia:
333 palZeroMemory( pMac->hHdd, pFrame, nBytes );
334
335 // Next, we fill out the buffer descriptor:
336 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
337 SIR_MAC_MGMT_PROBE_REQ, bssid ,SelfMacAddr);
338 if ( eSIR_SUCCESS != nSirStatus )
339 {
340 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700341 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 nSirStatus );
343 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
344 ( void* ) pFrame, ( void* ) pPacket );
345 return nSirStatus; // allocated!
346 }
347
348 // That done, pack the Probe Request:
349 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
350 sizeof( tSirMacMgmtHdr ),
351 nPayload, &nPayload );
352 if ( DOT11F_FAILED( nStatus ) )
353 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700354 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 nStatus );
356 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
357 return eSIR_FAILURE; // allocated!
358 }
359 else if ( DOT11F_WARNED( nStatus ) )
360 {
361 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700362 "robe Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 }
364
365 // Append any AddIE if present.
366 if( nAdditionalIELen )
367 {
368 palCopyMemory( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
369 pAdditionalIE, nAdditionalIELen );
370 nPayload += nAdditionalIELen;
371 }
372
373 /* If this probe request is sent during P2P Search State, then we need
374 * to send it at OFDM rate.
375 */
376 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
378 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530379 /* For unicast probe req mgmt from Join function
380 we don't set above variables. So we need to add
381 one more check whether it is pePersona is P2P_CLIENT or not */
382 || ( ( psessionEntry != NULL ) &&
383 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 )
385 {
386 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
387 }
388
389
390 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
391 HAL_TXRX_FRM_802_11_MGMT,
392 ANI_TXDIR_TODS,
393 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
394 limTxComplete, pFrame, txFlag );
395 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
396 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700397 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 //Pkt will be freed up by the callback
399 return eSIR_FAILURE;
400 }
401
402 return eSIR_SUCCESS;
403} // End limSendProbeReqMgmtFrame.
404
Jeff Johnson295189b2012-06-20 16:38:30 -0700405tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
406 tANI_U8* addIE, tANI_U16 *addnIELen,
407 tANI_U8 probeReqP2pIe)
408{
409 /* If Probe request doesn't have P2P IE, then take out P2P IE
410 from additional IE */
411 if(!probeReqP2pIe)
412 {
413 tANI_U8* tempbuf = NULL;
414 tANI_U16 tempLen = 0;
415 int left = *addnIELen;
416 v_U8_t *ptr = addIE;
417 v_U8_t elem_id, elem_len;
418
419 if(NULL == addIE)
420 {
421 PELOGE(limLog(pMac, LOGE,
422 FL(" NULL addIE pointer"));)
423 return eSIR_FAILURE;
424 }
425
426 if( (palAllocateMemory(pMac->hHdd, (void**)&tempbuf,
Jeff Johnson43971f52012-07-17 12:26:56 -0700427 left)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 {
429 PELOGE(limLog(pMac, LOGE,
430 FL("Unable to allocate memory to store addn IE"));)
431 return eSIR_MEM_ALLOC_FAILED;
432 }
433
434 while(left >= 2)
435 {
436 elem_id = ptr[0];
437 elem_len = ptr[1];
438 left -= 2;
439 if(elem_len > left)
440 {
441 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700442 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700443 elem_id,elem_len,left);
444 palFreeMemory(pMac->hHdd, tempbuf);
445 return eSIR_FAILURE;
446 }
447 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
448 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
449 {
450 palCopyMemory ( pMac->hHdd, tempbuf + tempLen, &ptr[0], elem_len + 2);
451 tempLen += (elem_len + 2);
452 }
453 left -= elem_len;
454 ptr += (elem_len + 2);
455 }
456 palCopyMemory ( pMac->hHdd, addIE, tempbuf, tempLen);
457 *addnIELen = tempLen;
458 palFreeMemory(pMac->hHdd, tempbuf);
459 }
460 return eSIR_SUCCESS;
461}
Jeff Johnson295189b2012-06-20 16:38:30 -0700462
463void
464limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
465 tSirMacAddr peerMacAddr,
466 tpAniSSID pSsid,
467 short nStaId,
468 tANI_U8 nKeepAlive,
469 tpPESession psessionEntry,
470 tANI_U8 probeReqP2pIe)
471{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700472 tDot11fProbeResponse *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 tSirRetStatus nSirStatus;
474 tANI_U32 cfg, nPayload, nBytes, nStatus;
475 tpSirMacMgmtHdr pMacHdr;
476 tANI_U8 *pFrame;
477 void *pPacket;
478 eHalStatus halstatus;
479 tANI_U32 addnIEPresent;
480 tANI_U32 addnIE1Len=0;
481 tANI_U32 addnIE2Len=0;
482 tANI_U32 addnIE3Len=0;
483 tANI_U16 totalAddnIeLen = 0;
484 tANI_U32 wpsApEnable=0, tmp;
485 tANI_U8 txFlag = 0;
486 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 tANI_U8 *pP2pIe = NULL;
488 tANI_U8 noaLen = 0;
489 tANI_U8 total_noaLen = 0;
490 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
491 + SIR_P2P_IE_HEADER_LEN];
492 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
495 {
496 return; // in this case.
497 }
498
499 if(NULL == psessionEntry)
500 {
501 return;
502 }
503
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700504 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
505 (void **)&pFrm, sizeof(tDot11fProbeResponse)))
506 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700507 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700508 return;
509 }
510
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 // Fill out 'frm', after which we'll just hand the struct off to
512 // 'dot11fPackProbeResponse'.
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700513 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 // Timestamp to be updated by TFP, below.
516
517 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
519 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700520 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 }
522 else
523 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800524 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
525 if (eSIR_SUCCESS != nSirStatus)
526 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700527 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800528 nSirStatus );
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530529 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800530 return;
531 }
532 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800533 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700534
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700535 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
536 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700538 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700539
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700540 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
541 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700542
Jeff Johnson295189b2012-06-20 16:38:30 -0700543
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
545 {
546 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
547 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700548 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 }
550 }
551 else
552 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800553 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700554 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800556 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800558 if (wpsApEnable)
559 {
560 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
561 }
562
563 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
564 {
565 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
566 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
567 }
568
569 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
570 {
571 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
572 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
573 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700576 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
577 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
580 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700581 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700582
583
584 // N.B. In earlier implementations, the RSN IE would be placed in
585 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
586 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700587 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700590 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700592 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700593 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700595#ifdef WLAN_FEATURE_11AC
596 if(psessionEntry->vhtCapability)
597 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700598 limLog( pMac, LOGW, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700599 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
600 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700601 // we do not support multi users yet
602 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700603 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700604 }
605#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700606
607 if ( psessionEntry->pLimStartBssReq )
608 {
609 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700610 &pFrm->WPA );
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 PopulateDot11fRSN( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700612 &pFrm->RSN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 }
614
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700615 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700616
617#if defined(FEATURE_WLAN_WAPI)
618 if( psessionEntry->pLimStartBssReq )
619 {
620 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700621 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 }
623
624#endif // defined(FEATURE_WLAN_WAPI)
625
626
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 if ( DOT11F_FAILED( nStatus ) )
629 {
630 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700631 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 nStatus );
633 // We'll fall back on the worst case scenario:
634 nPayload = sizeof( tDot11fProbeResponse );
635 }
636 else if ( DOT11F_WARNED( nStatus ) )
637 {
638 limLog( pMac, LOGW, FL("There were warnings while calculating"
639 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700640 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 }
642
643 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
644
645 addnIEPresent = false;
646
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 if( pMac->lim.gpLimRemainOnChanReq )
648 {
649 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
650 }
651 //Only use CFG for non-listen mode. This CFG is not working for concurrency
652 //In listening mode, probe rsp IEs is passed in the message from SME to PE
653 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 {
655
656 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
657 &addnIEPresent) != eSIR_SUCCESS)
658 {
659 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700660 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 return;
662 }
663 }
664
665 if (addnIEPresent)
666 {
667 if( (palAllocateMemory(pMac->hHdd, (void**)&addIE,
Jeff Johnson43971f52012-07-17 12:26:56 -0700668 WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3 )) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 {
670 PELOGE(limLog(pMac, LOGE,
671 FL("Unable to allocate memory to store addn IE"));)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700672 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 return;
674 }
675
676 //Probe rsp IE available
677 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
678 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
679 {
680 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
681 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 return;
684 }
685 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
686 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
687 {
688 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
689 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
690 &addnIE1Len) )
691 {
692 limLog(pMac, LOGP,
693 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
694 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700695 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 return;
697 }
698 }
699
700 //Probe rsp IE available
701 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
702 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
703 {
704 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
705 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700706 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 return;
708 }
709 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
710 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
711 {
712 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
713 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
714 &addnIE2Len) )
715 {
716 limLog(pMac, LOGP,
717 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
718 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700719 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722 }
723
724 //Probe rsp IE available
725 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
726 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
727 {
728 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
729 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700730 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return;
732 }
733 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
734 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
735 {
736 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
737 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
738 &addIE[addnIE1Len + addnIE2Len],
739 &addnIE3Len) )
740 {
741 limLog(pMac, LOGP,
742 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
743 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700744 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 return;
746 }
747 }
748 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
749
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
751 {
752 limLog(pMac, LOGP,
753 FL("Unable to get final Additional IE for Probe Req"));
754 palFreeMemory(pMac->hHdd, addIE);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700755 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 return;
757 }
758 nBytes = nBytes + totalAddnIeLen;
759
760 if (probeReqP2pIe)
761 {
762 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
763 if (pP2pIe != NULL)
764 {
765 //get NoA attribute stream P2P IE
766 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
767 if (noaLen != 0)
768 {
769 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
770 &noaStream[0], noaLen);
771 nBytes = nBytes + total_noaLen;
772 }
773 }
774 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 }
776
777 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
778 ( tANI_U16 )nBytes, ( void** ) &pFrame,
779 ( void** ) &pPacket );
780 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
781 {
782 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700783 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 if ( addIE != NULL )
785 {
786 palFreeMemory(pMac->hHdd, addIE);
787 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700788 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 return;
790 }
791
792 // Paranoia:
793 palZeroMemory( pMac->hHdd, pFrame, nBytes );
794
795 // Next, we fill out the buffer descriptor:
796 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
797 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
798 if ( eSIR_SUCCESS != nSirStatus )
799 {
800 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700801 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 nSirStatus );
803 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
804 ( void* ) pFrame, ( void* ) pPacket );
805 if ( addIE != NULL )
806 {
807 palFreeMemory(pMac->hHdd, addIE);
808 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700809 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 return;
811 }
812
813 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
814
815 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
816
817 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700818 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 nPayload, &nPayload );
820 if ( DOT11F_FAILED( nStatus ) )
821 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700822 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 nStatus );
824 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
825 if ( addIE != NULL )
826 {
827 palFreeMemory(pMac->hHdd, addIE);
828 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700829 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 return; // allocated!
831 }
832 else if ( DOT11F_WARNED( nStatus ) )
833 {
834 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700835 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 }
837
838 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
839 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
840
841 pMac->sys.probeRespond++;
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 if( pMac->lim.gpLimRemainOnChanReq )
844 {
845 palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
846 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
847 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700848
849 if ( addnIEPresent )
850 {
851 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -0700852 &addIE[0], totalAddnIeLen) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 {
854 limLog(pMac, LOGP, FL("Additional Probe Rp IE request failed while Appending: %x"),halstatus);
855 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
856 ( void* ) pFrame, ( void* ) pPacket );
857 if ( addIE != NULL )
858 {
859 palFreeMemory(pMac->hHdd, addIE);
860 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700861 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 return;
863 }
864 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 if (noaLen != 0)
866 {
Krunal Soni81b24262013-05-15 17:46:41 -0700867 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 {
869 limLog(pMac, LOGE,
870 FL("Not able to insert NoA because of length constraint"));
Krunal Soni81b24262013-05-15 17:46:41 -0700871 palFreeMemory(pMac->hHdd, addIE);
872 palFreeMemory(pMac->hHdd, pFrm);
873 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
874 ( void* ) pFrame, ( void* ) pPacket );
875 return;
876 }
877 else
878 {
879 palCopyMemory(pMac->hHdd, &pFrame[nBytes - (total_noaLen)],
880 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 }
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 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700901 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 //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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700997 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001006 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 }
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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001040 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001049 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 }
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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001061 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001074 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001089 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 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 "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001114 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001122 "an Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 }
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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001133 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001141 "a WMM Add TS Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 }
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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001165 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 //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 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001300 limLog( pMac, LOGW, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001301 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001334 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001342 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 }
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 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001383 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 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"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001401 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 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
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1411
1412 nStatus = dot11fPackAssocResponse( pMac, &frm,
1413 pFrame + sizeof( tSirMacMgmtHdr ),
1414 nPayload, &nPayload );
1415 if ( DOT11F_FAILED( nStatus ) )
1416 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001417 limLog( pMac, LOGE, FL("Failed to pack an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 nStatus );
1419 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1420 ( void* ) pFrame, ( void* ) pPacket );
1421 return; // allocated!
1422 }
1423 else if ( DOT11F_WARNED( nStatus ) )
1424 {
1425 limLog( pMac, LOGW, FL("There were warnings while packing an "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001426 "Association Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 }
1428
1429 macAddr = pMacHdr->da;
1430
1431 if (subType == LIM_ASSOC)
1432 {
1433 PELOG1(limLog(pMac, LOG1,
1434 FL("*** Sending Assoc Resp status %d aid %d to "),
1435 statusCode, aid);)
1436 }
1437 else{
1438 PELOG1(limLog(pMac, LOG1,
1439 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1440 statusCode, aid);)
1441 }
1442 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1443
1444 if ( addnIEPresent )
1445 {
1446 if (palCopyMemory ( pMac->hHdd, pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson43971f52012-07-17 12:26:56 -07001447 &addIE[0], addnIELen ) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001449 limLog(pMac, LOGP, FL("Additional Assoc IEs request failed while Appending: %x"),halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1451 ( void* ) pFrame, ( void* ) pPacket );
1452 return;
1453 }
1454 }
1455
1456 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1458 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 )
1460 {
1461 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1462 }
1463
1464 /// Queue Association Response frame in high priority WQ
1465 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1466 HAL_TXRX_FRM_802_11_MGMT,
1467 ANI_TXDIR_TODS,
1468 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1469 limTxComplete, pFrame, txFlag );
1470 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1471 {
1472 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001473 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 nSirStatus);
1475
1476 //Pkt will be freed up by the callback
1477 }
1478
1479 // update the ANI peer station count
1480 //FIXME_PROTECTION : take care of different type of station
1481 // counter inside this function.
1482 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1483
1484} // End limSendAssocRspMgmtFrame.
1485
1486
1487
1488void
1489limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1490 tSirMacAddr peer,
1491 tANI_U16 nStatusCode,
1492 tSirAddtsReqInfo *pAddTS,
1493 tSirMacScheduleIE *pSchedule,
1494 tpPESession psessionEntry)
1495{
1496 tANI_U8 *pFrame;
1497 tpSirMacMgmtHdr pMacHdr;
1498 tDot11fAddTSResponse AddTSRsp;
1499 tDot11fWMMAddTSResponse WMMAddTSRsp;
1500 tSirRetStatus nSirStatus;
1501 tANI_U32 i, nBytes, nPayload, nStatus;
1502 void *pPacket;
1503 eHalStatus halstatus;
1504 tANI_U8 txFlag = 0;
1505
1506 if(NULL == psessionEntry)
1507 {
1508 return;
1509 }
1510
1511 if ( ! pAddTS->wmeTspecPresent )
1512 {
1513 palZeroMemory( pMac->hHdd, ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ) );
1514
1515 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1516 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1517 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1518 AddTSRsp.Status.status = nStatusCode;
1519
1520 // The TsDelay information element is only filled in for a specific
1521 // status code:
1522 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1523 {
1524 if ( pAddTS->wsmTspecPresent )
1525 {
1526 AddTSRsp.WMMTSDelay.version = 1;
1527 AddTSRsp.WMMTSDelay.delay = 10;
1528 AddTSRsp.WMMTSDelay.present = 1;
1529 }
1530 else
1531 {
1532 AddTSRsp.TSDelay.delay = 10;
1533 AddTSRsp.TSDelay.present = 1;
1534 }
1535 }
1536
1537 if ( pAddTS->wsmTspecPresent )
1538 {
1539 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1540 }
1541 else
1542 {
1543 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1544 }
1545
1546 if ( pAddTS->wsmTspecPresent )
1547 {
1548 AddTSRsp.num_WMMTCLAS = 0;
1549 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1550 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1551 {
1552 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1553 &AddTSRsp.TCLAS[i] );
1554 }
1555 }
1556 else
1557 {
1558 AddTSRsp.num_TCLAS = 0;
1559 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1560 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1561 {
1562 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1563 &AddTSRsp.WMMTCLAS[i] );
1564 }
1565 }
1566
1567 if ( pAddTS->tclasProcPresent )
1568 {
1569 if ( pAddTS->wsmTspecPresent )
1570 {
1571 AddTSRsp.WMMTCLASPROC.version = 1;
1572 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1573 AddTSRsp.WMMTCLASPROC.present = 1;
1574 }
1575 else
1576 {
1577 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1578 AddTSRsp.TCLASSPROC.present = 1;
1579 }
1580 }
1581
1582 // schedule element is included only if requested in the tspec and we are
1583 // using hcca (or both edca and hcca)
1584 // 11e-D8.0 is inconsistent on whether the schedule element is included
1585 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1586 // pg 46, line 17-18 says something else. So just include it and let the
1587 // sta figure it out
1588 if ((pSchedule != NULL) &&
1589 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1590 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1591 {
1592 if ( pAddTS->wsmTspecPresent )
1593 {
1594 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1595 }
1596 else
1597 {
1598 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1599 }
1600 }
1601
1602 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1603 if ( DOT11F_FAILED( nStatus ) )
1604 {
1605 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001606 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 nStatus );
1608 // We'll fall back on the worst case scenario:
1609 nPayload = sizeof( tDot11fAddTSResponse );
1610 }
1611 else if ( DOT11F_WARNED( nStatus ) )
1612 {
1613 limLog( pMac, LOGW, FL("There were warnings while calcula"
1614 "tingthe packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001615 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 }
1617 }
1618 else
1619 {
1620 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ) );
1621
1622 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1623 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1624 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1625 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1626
1627 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1628
1629 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1630 if ( DOT11F_FAILED( nStatus ) )
1631 {
1632 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001633 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 nStatus );
1635 // We'll fall back on the worst case scenario:
1636 nPayload = sizeof( tDot11fWMMAddTSResponse );
1637 }
1638 else if ( DOT11F_WARNED( nStatus ) )
1639 {
1640 limLog( pMac, LOGW, FL("There were warnings while calcula"
1641 "tingthe packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001642 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 }
1644 }
1645
1646 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1647
1648 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1649 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1650 {
1651 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001652 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 return;
1654 }
1655
1656 // Paranoia:
1657 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1658
1659 // Next, we fill out the buffer descriptor:
1660 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1661 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1662 if ( eSIR_SUCCESS != nSirStatus )
1663 {
1664 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001665 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 nSirStatus );
1667 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1668 return; // allocated!
1669 }
1670
1671 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1672
1673
1674 #if 0
1675 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1676 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1677 {
1678 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001679 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1681 return; // allocated!
1682 }
1683 #endif //TO SUPPORT BT-AMP
1684 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1685
Chet Lanctot186b5732013-03-18 10:26:30 -07001686#ifdef WLAN_FEATURE_11W
1687 if ( psessionEntry->limRmfEnabled )
1688 {
1689 pMacHdr->fc.wep = 1;
1690 }
1691#endif
1692
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 // That done, pack the struct:
1694 if ( ! pAddTS->wmeTspecPresent )
1695 {
1696 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1697 pFrame + sizeof( tSirMacMgmtHdr ),
1698 nPayload, &nPayload );
1699 if ( DOT11F_FAILED( nStatus ) )
1700 {
1701 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001702 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 nStatus );
1704 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1705 return;
1706 }
1707 else if ( DOT11F_WARNED( nStatus ) )
1708 {
1709 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001710 "an Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 }
1712 }
1713 else
1714 {
1715 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1716 pFrame + sizeof( tSirMacMgmtHdr ),
1717 nPayload, &nPayload );
1718 if ( DOT11F_FAILED( nStatus ) )
1719 {
1720 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001721 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 nStatus );
1723 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1724 return;
1725 }
1726 else if ( DOT11F_WARNED( nStatus ) )
1727 {
1728 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001729 "a WMM Add TS Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 }
1731 }
1732
1733 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1734 nStatusCode );
1735 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1736
1737 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1739 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 )
1741 {
1742 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1743 }
1744
1745 // Queue the frame in high priority WQ:
1746 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1747 HAL_TXRX_FRM_802_11_MGMT,
1748 ANI_TXDIR_TODS,
1749 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1750 limTxComplete, pFrame, txFlag );
1751 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1752 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001753 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 nSirStatus );
1755 //Pkt will be freed up by the callback
1756 }
1757
1758} // End limSendAddtsRspActionFrame.
1759
1760void
1761limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1762 tSirMacAddr peer,
1763 tANI_U8 wmmTspecPresent,
1764 tSirMacTSInfo *pTsinfo,
1765 tSirMacTspecIE *pTspecIe,
1766 tpPESession psessionEntry)
1767{
1768 tANI_U8 *pFrame;
1769 tpSirMacMgmtHdr pMacHdr;
1770 tDot11fDelTS DelTS;
1771 tDot11fWMMDelTS WMMDelTS;
1772 tSirRetStatus nSirStatus;
1773 tANI_U32 nBytes, nPayload, nStatus;
1774 void *pPacket;
1775 eHalStatus halstatus;
1776 tANI_U8 txFlag = 0;
1777
1778 if(NULL == psessionEntry)
1779 {
1780 return;
1781 }
1782
1783 if ( ! wmmTspecPresent )
1784 {
1785 palZeroMemory( pMac->hHdd, ( tANI_U8* )&DelTS, sizeof( DelTS ) );
1786
1787 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1788 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1789 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1790
1791 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1792 if ( DOT11F_FAILED( nStatus ) )
1793 {
1794 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001795 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 nStatus );
1797 // We'll fall back on the worst case scenario:
1798 nPayload = sizeof( tDot11fDelTS );
1799 }
1800 else if ( DOT11F_WARNED( nStatus ) )
1801 {
1802 limLog( pMac, LOGW, FL("There were warnings while calcula"
1803 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001804 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 }
1806 }
1807 else
1808 {
1809 palZeroMemory( pMac->hHdd, ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ) );
1810
1811 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1812 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1813 WMMDelTS.DialogToken.token = 0;
1814 WMMDelTS.StatusCode.statusCode = 0;
1815 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1816 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1817 if ( DOT11F_FAILED( nStatus ) )
1818 {
1819 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001820 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 nStatus );
1822 // We'll fall back on the worst case scenario:
1823 nPayload = sizeof( tDot11fDelTS );
1824 }
1825 else if ( DOT11F_WARNED( nStatus ) )
1826 {
1827 limLog( pMac, LOGW, FL("There were warnings while calcula"
1828 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001829 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 }
1831 }
1832
1833 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1834
1835 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1836 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1837 {
1838 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001839 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 return;
1841 }
1842
1843 // Paranoia:
1844 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1845
1846 // Next, we fill out the buffer descriptor:
1847 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1848 SIR_MAC_MGMT_ACTION, peer,
1849 psessionEntry->selfMacAddr);
1850 if ( eSIR_SUCCESS != nSirStatus )
1851 {
1852 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001853 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 nSirStatus );
1855 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1856 return; // allocated!
1857 }
1858
1859 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1860
1861 #if 0
1862
1863 cfgLen = SIR_MAC_ADDR_LENGTH;
1864 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1865 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1866 {
1867 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001868 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1870 return; // allocated!
1871 }
1872 #endif //TO SUPPORT BT-AMP
1873 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1874
Chet Lanctot186b5732013-03-18 10:26:30 -07001875#ifdef WLAN_FEATURE_11W
1876 if ( psessionEntry->limRmfEnabled )
1877 {
1878 pMacHdr->fc.wep = 1;
1879 }
1880#endif
1881
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 // That done, pack the struct:
1883 if ( !wmmTspecPresent )
1884 {
1885 nStatus = dot11fPackDelTS( pMac, &DelTS,
1886 pFrame + sizeof( tSirMacMgmtHdr ),
1887 nPayload, &nPayload );
1888 if ( DOT11F_FAILED( nStatus ) )
1889 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001890 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 nStatus );
1892 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1893 return; // allocated!
1894 }
1895 else if ( DOT11F_WARNED( nStatus ) )
1896 {
1897 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001898 "a Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 }
1900 }
1901 else
1902 {
1903 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1904 pFrame + sizeof( tSirMacMgmtHdr ),
1905 nPayload, &nPayload );
1906 if ( DOT11F_FAILED( nStatus ) )
1907 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001908 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 nStatus );
1910 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1911 return; // allocated!
1912 }
1913 else if ( DOT11F_WARNED( nStatus ) )
1914 {
1915 limLog( pMac, LOGW, FL("There were warnings while packing"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001916 "a WMM Del TS frame (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 }
1918 }
1919
1920 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1921 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1922
1923 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1925 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 )
1927 {
1928 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1929 }
1930
1931 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1932 HAL_TXRX_FRM_802_11_MGMT,
1933 ANI_TXDIR_TODS,
1934 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1935 limTxComplete, pFrame, txFlag );
1936 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1937 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001938 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 nSirStatus );
1940 //Pkt will be freed up by the callback
1941 }
1942
1943} // End limSendDeltsReqActionFrame.
1944
1945void
1946limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1947 tLimMlmAssocReq *pMlmAssocReq,
1948 tpPESession psessionEntry)
1949{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001950 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 tANI_U16 caps;
1952 tANI_U8 *pFrame;
1953 tSirRetStatus nSirStatus;
1954 tLimMlmAssocCnf mlmAssocCnf;
1955 tANI_U32 nBytes, nPayload, nStatus;
1956 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
1957 void *pPacket;
1958 eHalStatus halstatus;
1959 tANI_U16 nAddIELen;
1960 tANI_U8 *pAddIE;
1961 tANI_U8 *wpsIe = NULL;
1962#if defined WLAN_FEATURE_VOWIFI
1963 tANI_U8 PowerCapsPopulated = FALSE;
1964#endif
1965 tANI_U8 txFlag = 0;
1966
1967 if(NULL == psessionEntry)
1968 {
1969 return;
1970 }
1971
1972 if(NULL == psessionEntry->pLimJoinReq)
1973 {
1974 return;
1975 }
1976
1977 /* check this early to avoid unncessary operation */
1978 if(NULL == psessionEntry->pLimJoinReq)
1979 {
1980 return;
1981 }
1982 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
1983 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
1984
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001985 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
1986 (void **)&pFrm, sizeof(tDot11fAssocRequest)))
1987 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001988 limLog(pMac, LOGE, FL("Unable to PAL allocate memory in limSendAssocReqMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001989 return;
1990 }
1991
1992
1993 palZeroMemory( pMac->hHdd, ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001994
1995 caps = pMlmAssocReq->capabilityInfo;
1996 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
1997 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
1998#if defined(FEATURE_WLAN_WAPI)
1999 /* CR: 262463 :
2000 According to WAPI standard:
2001 7.3.1.4 Capability Information field
2002 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2003 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2004 Reassociation management frames. */
2005 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2006 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2007#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002008 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002009
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002010 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2011 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002013 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002014
2015 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2016 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2017
2018 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2019 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2020
2021 // We prefer .11e asociations:
2022 if ( fQosEnabled ) fWmeEnabled = false;
2023
2024 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2025 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2026
2027 if ( psessionEntry->lim11hEnable &&
2028 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2029 {
2030#if defined WLAN_FEATURE_VOWIFI
2031 PowerCapsPopulated = TRUE;
2032
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002033 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002034#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002035 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 }
2038
2039#if defined WLAN_FEATURE_VOWIFI
2040 if( pMac->rrm.rrmPEContext.rrmEnable &&
2041 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2042 {
2043 if (PowerCapsPopulated == FALSE)
2044 {
2045 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002046 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 }
2048 }
2049#endif
2050
2051 if ( fQosEnabled &&
2052 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002053 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002054
2055 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002056 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002057
2058#if defined WLAN_FEATURE_VOWIFI
2059 if( pMac->rrm.rrmPEContext.rrmEnable &&
2060 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2061 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002062 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 }
2064#endif
2065 // The join request *should* contain zero or one of the WPA and RSN
2066 // IEs. The payload send along with the request is a
2067 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2068
2069 // typedef struct sSirRSNie
2070 // {
2071 // tANI_U16 length;
2072 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2073 // } tSirRSNie, *tpSirRSNie;
2074
2075 // So, we should be able to make the following two calls harmlessly,
2076 // since they do nothing if they don't find the given IE in the
2077 // bytestream with which they're provided.
2078
2079 // The net effect of this will be to faithfully transmit whatever
2080 // security IE is in the join request.
2081
2082 // *However*, if we're associating for the purpose of WPS
2083 // enrollment, and we've been configured to indicate that by
2084 // eliding the WPA or RSN IE, we just skip this:
2085 if( nAddIELen && pAddIE )
2086 {
2087 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2088 }
2089 if ( NULL == wpsIe )
2090 {
2091 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002092 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002094 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002095#if defined(FEATURE_WLAN_WAPI)
2096 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002097 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098#endif // defined(FEATURE_WLAN_WAPI)
2099 }
2100
2101 // include WME EDCA IE as well
2102 if ( fWmeEnabled )
2103 {
2104 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2105 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002106 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 }
2108
2109 if ( fWsmEnabled &&
2110 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2111 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002112 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 }
2114 }
2115
2116 //Populate HT IEs, when operating in 11n or Taurus modes AND
2117 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002118 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 pMac->lim.htCapabilityPresentInBeacon)
2120 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002121 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002122#ifdef DISABLE_GF_FOR_INTEROP
2123
2124 /*
2125 * To resolve the interop problem with Broadcom AP,
2126 * where TQ STA could not pass traffic with GF enabled,
2127 * TQ STA will do Greenfield only with TQ AP, for
2128 * everybody else it will be turned off.
2129 */
2130
2131 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2132 {
2133 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP, Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002134 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 }
2136#endif
2137
2138 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002139#ifdef WLAN_FEATURE_11AC
2140 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002141 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002142 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002143 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002144 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
2145 PopulateDot11fExtCap( pMac, &pFrm->ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002146 }
2147#endif
2148
Jeff Johnson295189b2012-06-20 16:38:30 -07002149
2150#if defined WLAN_FEATURE_VOWIFI_11R
2151 if (psessionEntry->pLimJoinReq->is11Rconnection)
2152 {
2153#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002154 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2156 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2157 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2158#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002159 PopulateMDIE( pMac, &pFrm->MobilityDomain, psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 }
2161 else
2162 {
2163 // No 11r IEs dont send any MDIE
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002164 limLog( pMac, LOG1, FL("mdie not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 }
2166#endif
2167
2168#ifdef FEATURE_WLAN_CCX
2169 // For CCX Associations fill the CCX IEs
2170 if (psessionEntry->isCCXconnection)
2171 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002172#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002173 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002174#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002175 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177#endif
2178
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002179 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 if ( DOT11F_FAILED( nStatus ) )
2181 {
2182 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002183 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 nStatus );
2185 // We'll fall back on the worst case scenario:
2186 nPayload = sizeof( tDot11fAssocRequest );
2187 }
2188 else if ( DOT11F_WARNED( nStatus ) )
2189 {
2190 limLog( pMac, LOGW, FL("There were warnings while calculating"
2191 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002192 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 }
2194
2195 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2196
2197 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2198 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2199 ( void** ) &pPacket );
2200 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2201 {
2202 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002203 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002204
2205 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002206 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002207
2208
2209 /* Update PE session id*/
2210 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2211
2212 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2213
2214 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2215 ( void* ) pFrame, ( void* ) pPacket );
2216
2217 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2218 ( tANI_U32* ) &mlmAssocCnf);
2219
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002220 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 return;
2222 }
2223
2224 // Paranoia:
2225 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2226
2227 // Next, we fill out the buffer descriptor:
2228 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2229 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2230 if ( eSIR_SUCCESS != nSirStatus )
2231 {
2232 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002233 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 nSirStatus );
2235 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002236 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 return;
2238 }
2239
2240
2241 // That done, pack the Probe Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002242 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 sizeof(tSirMacMgmtHdr),
2244 nPayload, &nPayload );
2245 if ( DOT11F_FAILED( nStatus ) )
2246 {
2247 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002248 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 nStatus );
2250 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2251 ( void* ) pFrame, ( void* ) pPacket );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002252 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 return;
2254 }
2255 else if ( DOT11F_WARNED( nStatus ) )
2256 {
2257 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002258 "robe Response (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 }
2260
2261 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002262 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 nBytes );)
2264 // limPrintMacAddr( pMac, bssid, LOG1 );
2265
2266 if( psessionEntry->assocReq != NULL )
2267 {
2268 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2269 psessionEntry->assocReq = NULL;
2270 }
2271
2272 if( nAddIELen )
2273 {
2274 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2275 pAddIE,
2276 nAddIELen );
2277 nPayload += nAddIELen;
2278 }
2279
Jeff Johnson43971f52012-07-17 12:26:56 -07002280 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2281 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 {
2283 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
2284 }
2285 else
2286 {
2287 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2288 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2289 psessionEntry->assocReqLen = nPayload;
2290 }
2291
2292 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2294 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 )
2296 {
2297 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2298 }
2299
Ganesh K08bce952012-12-13 15:04:41 -08002300 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2301 {
2302 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2303 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08002304
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2306 HAL_TXRX_FRM_802_11_MGMT,
2307 ANI_TXDIR_TODS,
2308 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2309 limTxComplete, pFrame, txFlag );
2310 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2311 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002312 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 halstatus );
2314 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002315 palFreeMemory(pMac->hHdd, pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 return;
2317 }
2318
2319 // Free up buffer allocated for mlmAssocReq
2320 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmAssocReq );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002321 palFreeMemory(pMac->hHdd, pFrm);
2322 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002323} // End limSendAssocReqMgmtFrame
2324
2325
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002326#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002327/*------------------------------------------------------------------------------------
2328 *
2329 * Send Reassoc Req with FTIEs.
2330 *
2331 *-----------------------------------------------------------------------------------
2332 */
2333void
2334limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2335 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2336{
2337 static tDot11fReAssocRequest frm;
2338 tANI_U16 caps;
2339 tANI_U8 *pFrame;
2340 tSirRetStatus nSirStatus;
2341 tANI_U32 nBytes, nPayload, nStatus;
2342 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2343 void *pPacket;
2344 eHalStatus halstatus;
2345#if defined WLAN_FEATURE_VOWIFI
2346 tANI_U8 PowerCapsPopulated = FALSE;
2347#endif
2348 tANI_U16 ft_ies_length = 0;
2349 tANI_U8 *pBody;
2350 tANI_U16 nAddIELen;
2351 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002352#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 tANI_U8 *wpsIe = NULL;
2354#endif
2355 tANI_U8 txFlag = 0;
2356
2357 if (NULL == psessionEntry)
2358 {
2359 return;
2360 }
2361
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 /* check this early to avoid unncessary operation */
2363 if(NULL == psessionEntry->pLimReAssocReq)
2364 {
2365 return;
2366 }
2367 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2368 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002369 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2370 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371
2372 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2373
2374 caps = pMlmReassocReq->capabilityInfo;
2375 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2376 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2377#if defined(FEATURE_WLAN_WAPI)
2378 /* CR: 262463 :
2379 According to WAPI standard:
2380 7.3.1.4 Capability Information field
2381 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2382 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2383 Reassociation management frames. */
2384 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2385 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2386#endif
2387 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2388
2389 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2390
2391 // Get the old bssid of the older AP.
2392 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2393 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2394
2395 PopulateDot11fSSID2( pMac, &frm.SSID );
2396 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2397 &frm.SuppRates,psessionEntry);
2398
2399 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2400 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2401
2402 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2403 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2404
2405 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2406 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2407
2408 if ( psessionEntry->lim11hEnable &&
2409 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2410 {
2411#if defined WLAN_FEATURE_VOWIFI
2412 PowerCapsPopulated = TRUE;
2413
2414 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2415 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2416#endif
2417 }
2418
2419#if defined WLAN_FEATURE_VOWIFI
2420 if( pMac->rrm.rrmPEContext.rrmEnable &&
2421 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2422 {
2423 if (PowerCapsPopulated == FALSE)
2424 {
2425 PowerCapsPopulated = TRUE;
2426 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2427 }
2428 }
2429#endif
2430
2431 if ( fQosEnabled &&
2432 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2433 {
2434 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2435 }
2436
2437 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2438 &frm.ExtSuppRates, psessionEntry );
2439
2440#if defined WLAN_FEATURE_VOWIFI
2441 if( pMac->rrm.rrmPEContext.rrmEnable &&
2442 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2443 {
2444 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2445 }
2446#endif
2447
2448 // Ideally this should be enabled for 11r also. But 11r does
2449 // not follow the usual norm of using the Opaque object
2450 // for rsnie and fties. Instead we just add
2451 // the rsnie and fties at the end of the pack routine for 11r.
2452 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002453#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 //
2455 // The join request *should* contain zero or one of the WPA and RSN
2456 // IEs. The payload send along with the request is a
2457 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2458
2459 // typedef struct sSirRSNie
2460 // {
2461 // tANI_U16 length;
2462 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2463 // } tSirRSNie, *tpSirRSNie;
2464
2465 // So, we should be able to make the following two calls harmlessly,
2466 // since they do nothing if they don't find the given IE in the
2467 // bytestream with which they're provided.
2468
2469 // The net effect of this will be to faithfully transmit whatever
2470 // security IE is in the join request.
2471
2472 // *However*, if we're associating for the purpose of WPS
2473 // enrollment, and we've been configured to indicate that by
2474 // eliding the WPA or RSN IE, we just skip this:
2475 if (!psessionEntry->is11Rconnection)
2476 {
2477 if( nAddIELen && pAddIE )
2478 {
2479 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2480 }
2481 if ( NULL == wpsIe )
2482 {
2483 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2484 &frm.RSNOpaque );
2485 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2486 &frm.WPAOpaque );
2487 }
2488
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002489#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 if(psessionEntry->pLimReAssocReq->cckmIE.length)
2491 {
2492 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2493 &frm.CCXCckmOpaque );
2494 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002495#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 }
2497
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002498#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 // For CCX Associations fill the CCX IEs
2500 if (psessionEntry->isCCXconnection)
2501 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002502#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 PopulateDot11fCCXVersion(&frm.CCXVersion);
2506 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507#endif //FEATURE_WLAN_CCX
2508#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002509
2510 // include WME EDCA IE as well
2511 if ( fWmeEnabled )
2512 {
2513 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2514 {
2515 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2516 }
2517
2518 if ( fWsmEnabled &&
2519 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2520 {
2521 PopulateDot11fWMMCaps( &frm.WMMCaps );
2522 }
2523#ifdef FEATURE_WLAN_CCX
2524 if (psessionEntry->isCCXconnection)
2525 {
2526 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2527
2528 // Populate the TSRS IE if TSPEC is included in the reassoc request
2529 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2530 {
2531 tANI_U32 phyMode;
2532 tSirMacCCXTSRSIE tsrsIE;
2533 limGetPhyMode(pMac, &phyMode, psessionEntry);
2534
2535 tsrsIE.tsid = 0;
2536 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2537 {
2538 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2539 }
2540 else
2541 {
2542 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2543 }
2544 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2545 }
2546 }
2547#endif
2548 }
2549
Jeff Johnsone7245742012-09-05 17:12:55 -07002550 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 pMac->lim.htCapabilityPresentInBeacon)
2552 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002553 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 }
2555
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002556#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302557 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2558#if defined FEATURE_WLAN_CCX
2559 && !psessionEntry->isCCXconnection
2560#endif
2561 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002562 {
2563 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2564 }
2565#endif
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2568 if ( DOT11F_FAILED( nStatus ) )
2569 {
2570 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002571 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 nStatus );
2573 // We'll fall back on the worst case scenario:
2574 nPayload = sizeof( tDot11fReAssocRequest );
2575 }
2576 else if ( DOT11F_WARNED( nStatus ) )
2577 {
2578 limLog( pMac, LOGW, FL("There were warnings while calculating"
2579 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002580 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 }
2582
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002583 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
2585#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002586 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2588#endif
2589
2590#if defined WLAN_FEATURE_VOWIFI_11R
2591 if (psessionEntry->is11Rconnection)
2592 {
2593 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2594 }
2595#endif
2596
2597 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2598 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2599 ( void** ) &pPacket );
2600 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2601 {
2602 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002603 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002605 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 goto end;
2607 }
2608
2609 // Paranoia:
2610 palZeroMemory( pMac->hHdd, pFrame, nBytes + ft_ies_length);
2611
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002612#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002613 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614#endif
2615 // Next, we fill out the buffer descriptor:
2616 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2617 SIR_MAC_MGMT_REASSOC_REQ,
2618 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2619 if ( eSIR_SUCCESS != nSirStatus )
2620 {
2621 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002622 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 nSirStatus );
2624 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2625 goto end;
2626 }
2627
2628
2629 // That done, pack the ReAssoc Request:
2630 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2631 sizeof(tSirMacMgmtHdr),
2632 nPayload, &nPayload );
2633 if ( DOT11F_FAILED( nStatus ) )
2634 {
2635 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002636 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 nStatus );
2638 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2639 goto end;
2640 }
2641 else if ( DOT11F_WARNED( nStatus ) )
2642 {
2643 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002644 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 }
2646
2647 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002648 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 nBytes, nPayload );)
2650 if( psessionEntry->assocReq != NULL )
2651 {
2652 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2653 psessionEntry->assocReq = NULL;
2654 }
2655
2656 if( nAddIELen )
2657 {
2658 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2659 pAddIE,
2660 nAddIELen );
2661 nPayload += nAddIELen;
2662 }
2663
Jeff Johnson43971f52012-07-17 12:26:56 -07002664 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2665 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 {
2667 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002668 }
2669 else
2670 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2672 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
2673 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002675
2676 if (psessionEntry->is11Rconnection)
2677 {
2678 {
2679 int i = 0;
2680
2681 pBody = pFrame + nBytes;
2682 for (i=0; i<ft_ies_length; i++)
2683 {
2684 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2685 pBody++;
2686 }
2687 }
2688 }
2689
2690#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002691 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2692 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 (tANI_U8 *)pFrame,
2694 (nBytes + ft_ies_length));)
2695#endif
2696
2697
2698 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2700 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 )
2702 {
2703 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2704 }
2705
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002706 if( NULL != psessionEntry->assocReq )
2707 {
2708 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
2709 psessionEntry->assocReq = NULL;
2710 }
2711
2712 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
2713 (ft_ies_length))) != eHAL_STATUS_SUCCESS )
2714 {
2715 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002716 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002717 }
2718 else
2719 {
2720 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
2721 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2722 (ft_ies_length));
2723 psessionEntry->assocReqLen = (ft_ies_length);
2724 }
2725
2726
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2728 HAL_TXRX_FRM_802_11_MGMT,
2729 ANI_TXDIR_TODS,
2730 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2731 limTxComplete, pFrame, txFlag );
2732 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2733 {
2734 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002735 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 nSirStatus );
2737 //Pkt will be freed up by the callback
2738 goto end;
2739 }
2740
2741end:
2742 // Free up buffer allocated for mlmAssocReq
2743 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
2744 psessionEntry->pLimMlmReassocReq = NULL;
2745
2746}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002747
2748void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2749 tLimMlmReassocReq *pMlmReassocReq,
2750 tpPESession psessionEntry)
2751{
2752 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2753 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2754 if(NULL == pTmpMlmReassocReq)
2755 {
2756 if ( !HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pTmpMlmReassocReq, sizeof(tLimMlmReassocReq))) ) goto end;
2757 palZeroMemory(pMac->hHdd, pTmpMlmReassocReq, sizeof(tLimMlmReassocReq));
2758 palCopyMemory( pMac->hHdd, pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
2759 }
2760
2761 // Prepare and send Reassociation request frame
2762 // start reassoc timer.
2763 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2764 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002765 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002766 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2767 != TX_SUCCESS)
2768 {
2769 // Could not start reassoc failure timer.
2770 // Log error
2771 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002772 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002773 // Return Reassoc confirm with
2774 // Resources Unavailable
2775 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2776 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2777 goto end;
2778 }
2779
2780 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2781 return;
2782
2783end:
2784 // Free up buffer allocated for reassocReq
2785 if (pMlmReassocReq != NULL)
2786 {
2787 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
2788 pMlmReassocReq = NULL;
2789 }
2790 if (pTmpMlmReassocReq != NULL)
2791 {
2792 palFreeMemory( pMac->hHdd, (tANI_U8 *) pTmpMlmReassocReq);
2793 pTmpMlmReassocReq = NULL;
2794 }
2795 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2796 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2797 /* Update PE sessio Id*/
2798 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2799
2800 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2801}
2802
Jeff Johnson295189b2012-06-20 16:38:30 -07002803#endif /* WLAN_FEATURE_VOWIFI_11R */
2804
2805
2806void
2807limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2808 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2809{
2810 static tDot11fReAssocRequest frm;
2811 tANI_U16 caps;
2812 tANI_U8 *pFrame;
2813 tSirRetStatus nSirStatus;
2814 tANI_U32 nBytes, nPayload, nStatus;
2815 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2816 void *pPacket;
2817 eHalStatus halstatus;
2818 tANI_U16 nAddIELen;
2819 tANI_U8 *pAddIE;
2820 tANI_U8 *wpsIe = NULL;
2821 tANI_U8 txFlag = 0;
2822#if defined WLAN_FEATURE_VOWIFI
2823 tANI_U8 PowerCapsPopulated = FALSE;
2824#endif
2825
2826 if(NULL == psessionEntry)
2827 {
2828 return;
2829 }
2830
2831 /* check this early to avoid unncessary operation */
2832 if(NULL == psessionEntry->pLimReAssocReq)
2833 {
2834 return;
2835 }
2836 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2837 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2838
2839 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
2840
2841 caps = pMlmReassocReq->capabilityInfo;
2842 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2843 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2844#if defined(FEATURE_WLAN_WAPI)
2845 /* CR: 262463 :
2846 According to WAPI standard:
2847 7.3.1.4 Capability Information field
2848 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2849 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2850 Reassociation management frames. */
2851 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2852 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2853#endif
2854 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2855
2856 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2857
2858 palCopyMemory( pMac->hHdd, ( tANI_U8* )frm.CurrentAPAddress.mac,
2859 ( tANI_U8* )psessionEntry->bssId, 6 );
2860
2861 PopulateDot11fSSID2( pMac, &frm.SSID );
2862 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2863 &frm.SuppRates,psessionEntry);
2864
2865 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2866 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2867
2868 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2869 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2870
2871 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2872 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2873
2874
2875 if ( psessionEntry->lim11hEnable &&
2876 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2877 {
2878#if defined WLAN_FEATURE_VOWIFI
2879 PowerCapsPopulated = TRUE;
2880 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2881 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2882#endif
2883 }
2884
2885#if defined WLAN_FEATURE_VOWIFI
2886 if( pMac->rrm.rrmPEContext.rrmEnable &&
2887 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2888 {
2889 if (PowerCapsPopulated == FALSE)
2890 {
2891 PowerCapsPopulated = TRUE;
2892 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2893 }
2894 }
2895#endif
2896
2897 if ( fQosEnabled &&
2898 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2899 {
2900 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2901 }
2902
2903 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2904 &frm.ExtSuppRates, psessionEntry );
2905
2906#if defined WLAN_FEATURE_VOWIFI
2907 if( pMac->rrm.rrmPEContext.rrmEnable &&
2908 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2909 {
2910 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2911 }
2912#endif
2913 // The join request *should* contain zero or one of the WPA and RSN
2914 // IEs. The payload send along with the request is a
2915 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2916
2917 // typedef struct sSirRSNie
2918 // {
2919 // tANI_U16 length;
2920 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2921 // } tSirRSNie, *tpSirRSNie;
2922
2923 // So, we should be able to make the following two calls harmlessly,
2924 // since they do nothing if they don't find the given IE in the
2925 // bytestream with which they're provided.
2926
2927 // The net effect of this will be to faithfully transmit whatever
2928 // security IE is in the join request.
2929
2930 // *However*, if we're associating for the purpose of WPS
2931 // enrollment, and we've been configured to indicate that by
2932 // eliding the WPA or RSN IE, we just skip this:
2933 if( nAddIELen && pAddIE )
2934 {
2935 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2936 }
2937 if ( NULL == wpsIe )
2938 {
2939 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2940 &frm.RSNOpaque );
2941 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2942 &frm.WPAOpaque );
2943#if defined(FEATURE_WLAN_WAPI)
2944 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2945 &frm.WAPIOpaque );
2946#endif // defined(FEATURE_WLAN_WAPI)
2947 }
2948
2949 // include WME EDCA IE as well
2950 if ( fWmeEnabled )
2951 {
2952 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2953 {
2954 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2955 }
2956
2957 if ( fWsmEnabled &&
2958 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2959 {
2960 PopulateDot11fWMMCaps( &frm.WMMCaps );
2961 }
2962 }
2963
Jeff Johnsone7245742012-09-05 17:12:55 -07002964 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 pMac->lim.htCapabilityPresentInBeacon)
2966 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002967 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002969#ifdef WLAN_FEATURE_11AC
2970 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002971 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002972 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002973 limLog( pMac, LOGW, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002974 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Mohit Khanna4a70d262012-09-11 16:30:12 -07002975 PopulateDot11fExtCap( pMac, &frm.ExtCap);
Jeff Johnsone7245742012-09-05 17:12:55 -07002976 }
2977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002978
2979 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2980 if ( DOT11F_FAILED( nStatus ) )
2981 {
2982 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002983 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 nStatus );
2985 // We'll fall back on the worst case scenario:
2986 nPayload = sizeof( tDot11fReAssocRequest );
2987 }
2988 else if ( DOT11F_WARNED( nStatus ) )
2989 {
2990 limLog( pMac, LOGW, FL("There were warnings while calculating"
2991 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002992 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 }
2994
2995 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2996
2997 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2998 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2999 ( void** ) &pPacket );
3000 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3001 {
3002 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003003 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003005 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 goto end;
3007 }
3008
3009 // Paranoia:
3010 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3011
3012 // Next, we fill out the buffer descriptor:
3013 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3014 SIR_MAC_MGMT_REASSOC_REQ,
3015 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3016 if ( eSIR_SUCCESS != nSirStatus )
3017 {
3018 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003019 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 nSirStatus );
3021 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3022 goto end;
3023 }
3024
3025
3026 // That done, pack the Probe Request:
3027 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3028 sizeof(tSirMacMgmtHdr),
3029 nPayload, &nPayload );
3030 if ( DOT11F_FAILED( nStatus ) )
3031 {
3032 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003033 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 nStatus );
3035 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3036 goto end;
3037 }
3038 else if ( DOT11F_WARNED( nStatus ) )
3039 {
3040 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003041 "e-Association Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 }
3043
3044 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003045 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 nBytes );)
3047
3048 if( psessionEntry->assocReq != NULL )
3049 {
3050 palFreeMemory(pMac->hHdd, psessionEntry->assocReq);
3051 psessionEntry->assocReq = NULL;
3052 }
3053
3054 if( nAddIELen )
3055 {
3056 palCopyMemory( pMac->hHdd, pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3057 pAddIE,
3058 nAddIELen );
3059 nPayload += nAddIELen;
3060 }
3061
Jeff Johnson43971f52012-07-17 12:26:56 -07003062 if( (palAllocateMemory(pMac->hHdd, (void**)&psessionEntry->assocReq,
3063 nPayload)) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 {
3065 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003066 }
3067 else
3068 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
3070 palCopyMemory(pMac->hHdd, psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
3071 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003073
3074 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3076 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 )
3078 {
3079 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3080 }
3081
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003082 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003083 {
3084 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3085 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003086
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3088 HAL_TXRX_FRM_802_11_MGMT,
3089 ANI_TXDIR_TODS,
3090 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3091 limTxComplete, pFrame, txFlag );
3092 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3093 {
3094 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003095 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 nSirStatus );
3097 //Pkt will be freed up by the callback
3098 goto end;
3099 }
3100
3101end:
3102 // Free up buffer allocated for mlmAssocReq
3103 palFreeMemory( pMac->hHdd, ( tANI_U8* ) pMlmReassocReq );
3104 psessionEntry->pLimMlmReassocReq = NULL;
3105
3106} // limSendReassocReqMgmtFrame
3107
3108/**
3109 * \brief Send an Authentication frame
3110 *
3111 *
3112 * \param pMac Pointer to Global MAC structure
3113 *
3114 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3115 * to be sent
3116 *
3117 * \param peerMacAddr MAC address of the peer entity to which Authentication
3118 * frame is destined
3119 *
3120 * \param wepBit Indicates whether wep bit to be set in FC while sending
3121 * Authentication frame3
3122 *
3123 *
3124 * This function is called by limProcessMlmMessages(). Authentication frame
3125 * is formatted and sent when this function is called.
3126 *
3127 *
3128 */
3129
3130void
3131limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3132 tpSirMacAuthFrameBody pAuthFrameBody,
3133 tSirMacAddr peerMacAddr,
3134 tANI_U8 wepBit,
3135 tpPESession psessionEntry
3136 )
3137{
3138 tANI_U8 *pFrame, *pBody;
3139 tANI_U32 frameLen = 0, bodyLen = 0;
3140 tpSirMacMgmtHdr pMacHdr;
3141 tANI_U16 i;
3142 void *pPacket;
3143 eHalStatus halstatus;
3144 tANI_U8 txFlag = 0;
3145
3146 if(NULL == psessionEntry)
3147 {
3148 return;
3149 }
3150
3151 if (wepBit == LIM_WEP_IN_FC)
3152 {
3153 /// Auth frame3 to be sent with encrypted framebody
3154 /**
3155 * Allocate buffer for Authenticaton frame of size equal
3156 * to management frame header length plus 2 bytes each for
3157 * auth algorithm number, transaction number, status code,
3158 * 128 bytes for challenge text and 4 bytes each for
3159 * IV & ICV.
3160 */
3161
3162 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3163
3164 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3165 } // if (wepBit == LIM_WEP_IN_FC)
3166 else
3167 {
3168 switch (pAuthFrameBody->authTransactionSeqNumber)
3169 {
3170 case SIR_MAC_AUTH_FRAME_1:
3171 /**
3172 * Allocate buffer for Authenticaton frame of size
3173 * equal to management frame header length plus 2 bytes
3174 * each for auth algorithm number, transaction number
3175 * and status code.
3176 */
3177
3178 frameLen = sizeof(tSirMacMgmtHdr) +
3179 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3180 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3181
3182#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003183 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3184 {
3185 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003187 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003188 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003189 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003191 else
3192 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003193 limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003194 frameLen += (2+SIR_MDIE_SIZE);
3195 }
3196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003197#endif
3198 break;
3199
3200 case SIR_MAC_AUTH_FRAME_2:
3201 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3202 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3203 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3204 {
3205 /**
3206 * Allocate buffer for Authenticaton frame of size
3207 * equal to management frame header length plus
3208 * 2 bytes each for auth algorithm number,
3209 * transaction number and status code.
3210 */
3211
3212 frameLen = sizeof(tSirMacMgmtHdr) +
3213 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3214 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3215 }
3216 else
3217 {
3218 // Shared Key algorithm with challenge text
3219 // to be sent
3220 /**
3221 * Allocate buffer for Authenticaton frame of size
3222 * equal to management frame header length plus
3223 * 2 bytes each for auth algorithm number,
3224 * transaction number, status code and 128 bytes
3225 * for challenge text.
3226 */
3227
3228 frameLen = sizeof(tSirMacMgmtHdr) +
3229 sizeof(tSirMacAuthFrame);
3230 bodyLen = sizeof(tSirMacAuthFrameBody);
3231 }
3232
3233 break;
3234
3235 case SIR_MAC_AUTH_FRAME_3:
3236 /// Auth frame3 to be sent without encrypted framebody
3237 /**
3238 * Allocate buffer for Authenticaton frame of size equal
3239 * to management frame header length plus 2 bytes each
3240 * for auth algorithm number, transaction number and
3241 * status code.
3242 */
3243
3244 frameLen = sizeof(tSirMacMgmtHdr) +
3245 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3246 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3247
3248 break;
3249
3250 case SIR_MAC_AUTH_FRAME_4:
3251 /**
3252 * Allocate buffer for Authenticaton frame of size equal
3253 * to management frame header length plus 2 bytes each
3254 * for auth algorithm number, transaction number and
3255 * status code.
3256 */
3257
3258 frameLen = sizeof(tSirMacMgmtHdr) +
3259 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3260 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3261
3262 break;
3263 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3264 } // end if (wepBit == LIM_WEP_IN_FC)
3265
3266
3267 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3268
3269 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3270 {
3271 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003272 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003273
3274 return;
3275 }
3276
3277 for (i = 0; i < frameLen; i++)
3278 pFrame[i] = 0;
3279
3280 // Prepare BD
3281 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3282 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3283 {
3284 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3285 return;
3286 }
3287
3288 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3289 pMacHdr->fc.wep = wepBit;
3290
3291 // Prepare BSSId
3292 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3293 {
3294 palCopyMemory( pMac->hHdd,(tANI_U8 *) pMacHdr->bssId,
3295 (tANI_U8 *) psessionEntry->bssId,
3296 sizeof( tSirMacAddr ));
3297 }
3298
3299 /// Prepare Authentication frame body
3300 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3301
3302 if (wepBit == LIM_WEP_IN_FC)
3303 {
3304 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
3305
3306 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003307 FL("*** Sending Auth seq# 3 status %d (%d) to"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 pAuthFrameBody->authStatusCode,
3309 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3310
3311 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3312 }
3313 else
3314 {
3315 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3316 pBody += sizeof(tANI_U16);
3317 bodyLen -= sizeof(tANI_U16);
3318
3319 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3320 pBody += sizeof(tANI_U16);
3321 bodyLen -= sizeof(tANI_U16);
3322
3323 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3324 pBody += sizeof(tANI_U16);
3325 bodyLen -= sizeof(tANI_U16);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07003326 if ( bodyLen < sizeof (pAuthFrameBody->type) + sizeof (pAuthFrameBody->length) + sizeof (pAuthFrameBody->challengeText))
3327 palCopyMemory( pMac->hHdd, pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003328
3329#if defined WLAN_FEATURE_VOWIFI_11R
3330 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3331 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3332 {
3333
3334 {
3335 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3337 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003338#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
3340 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
3341 (tANI_U8 *)pBody,
3342 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003343#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003344 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3345 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003346 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3347 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003348 }
3349 }
3350 else
3351 {
3352 /* MDID attr is 54*/
3353 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003355 *pBody = SIR_MDIE_SIZE;
3356 pBody++;
3357 for(i=0;i<SIR_MDIE_SIZE;i++)
3358 {
3359 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3360 pBody++;
3361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 }
3363 }
3364 }
3365#endif
3366
3367 PELOG1(limLog(pMac, LOG1,
3368 FL("*** Sending Auth seq# %d status %d (%d) to "),
3369 pAuthFrameBody->authTransactionSeqNumber,
3370 pAuthFrameBody->authStatusCode,
3371 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS));
3372
3373 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
3374 }
3375 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3376
3377 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3379 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003380#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3381 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
3382 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3383#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 )
3385 {
3386 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3387 }
3388
Ganesh K08bce952012-12-13 15:04:41 -08003389 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3390 {
3391 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3392 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003393
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 /// Queue Authentication frame in high priority WQ
3395 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3396 HAL_TXRX_FRM_802_11_MGMT,
3397 ANI_TXDIR_TODS,
3398 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3399 limTxComplete, pFrame, txFlag );
3400 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3401 {
3402 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003403 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 halstatus);
3405
3406 //Pkt will be freed up by the callback
3407 }
3408
3409 return;
3410} /*** end limSendAuthMgmtFrame() ***/
3411
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003412eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3413{
3414 tANI_U16 aid;
3415 tpDphHashNode pStaDs;
3416 tLimMlmDeauthReq *pMlmDeauthReq;
3417 tLimMlmDeauthCnf mlmDeauthCnf;
3418 tpPESession psessionEntry;
3419
3420 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3421 if (pMlmDeauthReq)
3422 {
3423 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3424 {
3425 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3426 }
3427
3428 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3429 {
3430
3431 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003432 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003433 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3434 goto end;
3435 }
3436
3437 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3438 if (pStaDs == NULL)
3439 {
3440 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3441 goto end;
3442 }
3443
3444
3445 /// Receive path cleanup with dummy packet
3446 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3447 /// Free up buffer allocated for mlmDeauthReq
3448 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3449 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3450 }
3451 return eHAL_STATUS_SUCCESS;
3452end:
3453 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3454 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3455 sizeof(tSirMacAddr));
3456 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3457 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3458 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3459
3460 // Free up buffer allocated
3461 // for mlmDeauthReq
3462 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3463
3464 limPostSmeMessage(pMac,
3465 LIM_MLM_DEAUTH_CNF,
3466 (tANI_U32 *) &mlmDeauthCnf);
3467 return eHAL_STATUS_SUCCESS;
3468}
3469
3470eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3471{
3472 tANI_U16 aid;
3473 tpDphHashNode pStaDs;
3474 tLimMlmDisassocCnf mlmDisassocCnf;
3475 tpPESession psessionEntry;
3476 tLimMlmDisassocReq *pMlmDisassocReq;
3477
3478 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3479 if (pMlmDisassocReq)
3480 {
3481 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3482 {
3483 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3484 }
3485
3486 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3487 {
3488
3489 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003490 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003491 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3492 goto end;
3493 }
3494
3495 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3496 if (pStaDs == NULL)
3497 {
3498 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3499 goto end;
3500 }
3501
3502 /// Receive path cleanup with dummy packet
3503 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3504 {
3505 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3506 goto end;
3507 }
3508
3509#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003510 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3511 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003512#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003513 (psessionEntry->isCCXconnection ) ||
3514#endif
3515#ifdef FEATURE_WLAN_LFR
3516 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003517#endif
3518 (psessionEntry->is11Rconnection )) &&
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003519 (pMlmDisassocReq->reasonCode !=
3520 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003521 {
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003522 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003523 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003524 psessionEntry, psessionEntry->peSessionId););
3525 limFTCleanup(pMac);
3526 }
3527 else
3528 {
3529 PELOGE(limLog(pMac, LOGE,
3530 FL("No FT Preauth Session Cleanup in role %d"
3531#ifdef FEATURE_WLAN_CCX
3532 " isCCX %d"
3533#endif
3534#ifdef FEATURE_WLAN_LFR
3535 " isLFR %d"
3536#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003537 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003538 psessionEntry->limSystemRole,
3539#ifdef FEATURE_WLAN_CCX
3540 psessionEntry->isCCXconnection,
3541#endif
3542#ifdef FEATURE_WLAN_LFR
3543 psessionEntry->isFastRoamIniFeatureEnabled,
3544#endif
3545 psessionEntry->is11Rconnection,
3546 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003547 }
3548#endif
3549
3550 /// Free up buffer allocated for mlmDisassocReq
3551 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3552 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3553 return eHAL_STATUS_SUCCESS;
3554 }
3555 else
3556 {
3557 return eHAL_STATUS_SUCCESS;
3558 }
3559end:
3560 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
3561 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3562 sizeof(tSirMacAddr));
3563 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3564 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3565
3566 /* Update PE session ID*/
3567 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3568
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003569 if(pMlmDisassocReq != NULL)
3570 {
3571 /// Free up buffer allocated for mlmDisassocReq
3572 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
3573 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3574 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003575
3576 limPostSmeMessage(pMac,
3577 LIM_MLM_DISASSOC_CNF,
3578 (tANI_U32 *) &mlmDisassocCnf);
3579 return eHAL_STATUS_SUCCESS;
3580}
3581
3582eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3583{
3584 return limSendDisassocCnf(pMac);
3585}
3586
3587eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3588{
3589 return limSendDeauthCnf(pMac);
3590}
3591
Jeff Johnson295189b2012-06-20 16:38:30 -07003592/**
3593 * \brief This function is called to send Disassociate frame.
3594 *
3595 *
3596 * \param pMac Pointer to Global MAC structure
3597 *
3598 * \param nReason Indicates the reason that need to be sent in
3599 * Disassociation frame
3600 *
3601 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3602 * sent
3603 *
3604 *
3605 */
3606
3607void
3608limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3609 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003610 tSirMacAddr peer,
3611 tpPESession psessionEntry,
3612 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003613{
3614 tDot11fDisassociation frm;
3615 tANI_U8 *pFrame;
3616 tSirRetStatus nSirStatus;
3617 tpSirMacMgmtHdr pMacHdr;
3618 tANI_U32 nBytes, nPayload, nStatus;
3619 void *pPacket;
3620 eHalStatus halstatus;
3621 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003622 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 if(NULL == psessionEntry)
3624 {
3625 return;
3626 }
3627
3628 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
3629
3630 frm.Reason.code = nReason;
3631
3632 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3633 if ( DOT11F_FAILED( nStatus ) )
3634 {
3635 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003636 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 nStatus );
3638 // We'll fall back on the worst case scenario:
3639 nPayload = sizeof( tDot11fDisassociation );
3640 }
3641 else if ( DOT11F_WARNED( nStatus ) )
3642 {
3643 limLog( pMac, LOGW, FL("There were warnings while calculating"
3644 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003645 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 }
3647
3648 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3649
3650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3651 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3652 ( void** ) &pPacket );
3653 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3654 {
3655 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003656 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 return;
3658 }
3659
3660 // Paranoia:
3661 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3662
3663 // Next, we fill out the buffer descriptor:
3664 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3665 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3666 if ( eSIR_SUCCESS != nSirStatus )
3667 {
3668 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003669 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 nSirStatus );
3671 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3672 ( void* ) pFrame, ( void* ) pPacket );
3673 return; // just allocated...
3674 }
3675
3676 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3677
3678 // Prepare the BSSID
3679 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3680
Chet Lanctot186b5732013-03-18 10:26:30 -07003681#ifdef WLAN_FEATURE_11W
3682 if ( psessionEntry->limRmfEnabled )
3683 {
3684 pMacHdr->fc.wep = 1;
3685 }
3686#endif
3687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3689 sizeof(tSirMacMgmtHdr),
3690 nPayload, &nPayload );
3691 if ( DOT11F_FAILED( nStatus ) )
3692 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003693 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 nStatus );
3695 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3696 ( void* ) pFrame, ( void* ) pPacket );
3697 return; // allocated!
3698 }
3699 else if ( DOT11F_WARNED( nStatus ) )
3700 {
3701 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003702 "isassociation (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 }
3704
3705 PELOG1(limLog( pMac, LOG1, FL("*** Sending Disassociation frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003706 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3708
3709 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3711 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 )
3713 {
3714 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3715 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003716
Ganesh K08bce952012-12-13 15:04:41 -08003717 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3718 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3719 {
3720 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3721 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003722
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003723 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003725 // Queue Disassociation frame in high priority WQ
3726 /* get the duration from the request */
3727 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3728 HAL_TXRX_FRM_802_11_MGMT,
3729 ANI_TXDIR_TODS,
3730 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3731 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3732 txFlag );
3733 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003734
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003735 if (tx_timer_change(
3736 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3737 != TX_SUCCESS)
3738 {
3739 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003740 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003741 return;
3742 }
3743 else if(TX_SUCCESS != tx_timer_activate(
3744 &pMac->lim.limTimers.gLimDisassocAckTimer))
3745 {
3746 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003747 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003748 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3749 return;
3750 }
3751 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003752 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003753 {
3754 // Queue Disassociation frame in high priority WQ
3755 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3756 HAL_TXRX_FRM_802_11_MGMT,
3757 ANI_TXDIR_TODS,
3758 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3759 limTxComplete, pFrame, txFlag );
3760 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3761 {
3762 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003763 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003764 nSirStatus );
3765 //Pkt will be freed up by the callback
3766 return;
3767 }
3768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003769} // End limSendDisassocMgmtFrame.
3770
3771/**
3772 * \brief This function is called to send a Deauthenticate frame
3773 *
3774 *
3775 * \param pMac Pointer to global MAC structure
3776 *
3777 * \param nReason Indicates the reason that need to be sent in the
3778 * Deauthenticate frame
3779 *
3780 * \param peeer address of the STA to which the frame is to be sent
3781 *
3782 *
3783 */
3784
3785void
3786limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3787 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003788 tSirMacAddr peer,
3789 tpPESession psessionEntry,
3790 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003791{
3792 tDot11fDeAuth frm;
3793 tANI_U8 *pFrame;
3794 tSirRetStatus nSirStatus;
3795 tpSirMacMgmtHdr pMacHdr;
3796 tANI_U32 nBytes, nPayload, nStatus;
3797 void *pPacket;
3798 eHalStatus halstatus;
3799 tANI_U8 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003800 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003801#ifdef FEATURE_WLAN_TDLS
3802 tANI_U16 aid;
3803 tpDphHashNode pStaDs;
3804#endif
3805
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 if(NULL == psessionEntry)
3807 {
3808 return;
3809 }
3810
3811 palZeroMemory( pMac->hHdd, ( tANI_U8* ) &frm, sizeof( frm ) );
3812
3813 frm.Reason.code = nReason;
3814
3815 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3816 if ( DOT11F_FAILED( nStatus ) )
3817 {
3818 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003819 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 nStatus );
3821 // We'll fall back on the worst case scenario:
3822 nPayload = sizeof( tDot11fDeAuth );
3823 }
3824 else if ( DOT11F_WARNED( nStatus ) )
3825 {
3826 limLog( pMac, LOGW, FL("There were warnings while calculating"
3827 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003828 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 }
3830
3831 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3832
3833 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3834 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3835 ( void** ) &pPacket );
3836 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3837 {
3838 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003839 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 return;
3841 }
3842
3843 // Paranoia:
3844 palZeroMemory( pMac->hHdd, pFrame, nBytes );
3845
3846 // Next, we fill out the buffer descriptor:
3847 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3848 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3849 if ( eSIR_SUCCESS != nSirStatus )
3850 {
3851 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003852 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 nSirStatus );
3854 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3855 ( void* ) pFrame, ( void* ) pPacket );
3856 return; // just allocated...
3857 }
3858
3859 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3860
3861 // Prepare the BSSID
3862 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3863
Chet Lanctot186b5732013-03-18 10:26:30 -07003864#ifdef WLAN_FEATURE_11W
3865 if ( psessionEntry->limRmfEnabled )
3866 {
3867 pMacHdr->fc.wep = 1;
3868 }
3869#endif
3870
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3872 sizeof(tSirMacMgmtHdr),
3873 nPayload, &nPayload );
3874 if ( DOT11F_FAILED( nStatus ) )
3875 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003876 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 nStatus );
3878 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3879 ( void* ) pFrame, ( void* ) pPacket );
3880 return;
3881 }
3882 else if ( DOT11F_WARNED( nStatus ) )
3883 {
3884 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003885 "e-Authentication (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 }
3887
3888 PELOG1(limLog( pMac, LOG1, FL("*** Sending De-Authentication frame with rea"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003889 "son %d to"), nReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
3891
3892 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3894 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 )
3896 {
3897 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3898 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003899
Ganesh K08bce952012-12-13 15:04:41 -08003900 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
3901 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
3902 {
3903 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3904 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003905
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003906#ifdef FEATURE_WLAN_TDLS
3907 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
3908#endif
3909
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003910 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 {
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003912 // Queue Disassociation frame in high priority WQ
3913 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3914 HAL_TXRX_FRM_802_11_MGMT,
3915 ANI_TXDIR_TODS,
3916 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3917 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
3918 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3919 {
3920 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003921 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003922 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08003923 //Pkt will be freed up by the callback limTxComplete
3924
3925 /*Call limProcessDeauthAckTimeout which will send
3926 * DeauthCnf for this frame
3927 */
3928 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003929 return;
3930 }
3931
3932 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3933
3934 if (tx_timer_change(
3935 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3936 != TX_SUCCESS)
3937 {
3938 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003939 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003940 return;
3941 }
3942 else if(TX_SUCCESS != tx_timer_activate(
3943 &pMac->lim.limTimers.gLimDeauthAckTimer))
3944 {
3945 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003946 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003947 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3948 return;
3949 }
3950 }
3951 else
3952 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003953#ifdef FEATURE_WLAN_TDLS
3954 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
3955 {
3956 // Queue Disassociation frame in high priority WQ
3957 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003958 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003959 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003960 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3961 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003962 }
3963 else
3964 {
3965#endif
3966 // Queue Disassociation frame in high priority WQ
3967 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3968 HAL_TXRX_FRM_802_11_MGMT,
3969 ANI_TXDIR_TODS,
3970 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3971 limTxComplete, pFrame, txFlag );
3972#ifdef FEATURE_WLAN_TDLS
3973 }
3974#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003975 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3976 {
3977 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003978 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003979 nSirStatus );
3980 //Pkt will be freed up by the callback
3981 return;
3982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984
3985} // End limSendDeauthMgmtFrame.
3986
3987
3988#ifdef ANI_SUPPORT_11H
3989/**
3990 * \brief Send a Measurement Report Action frame
3991 *
3992 *
3993 * \param pMac Pointer to the global MAC structure
3994 *
3995 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3996 *
3997 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3998 *
3999 *
4000 */
4001
4002tSirRetStatus
4003limSendMeasReportFrame(tpAniSirGlobal pMac,
4004 tpSirMacMeasReqActionFrame pMeasReqFrame,
4005 tSirMacAddr peer)
4006{
4007 tDot11fMeasurementReport frm;
4008 tANI_U8 *pFrame;
4009 tSirRetStatus nSirStatus;
4010 tpSirMacMgmtHdr pMacHdr;
4011 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4012 void *pPacket;
4013 eHalStatus halstatus;
4014
4015 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4016
4017 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4018 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4019 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4020
4021 switch ( pMeasReqFrame->measReqIE.measType )
4022 {
4023 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4024 nSirStatus =
4025 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4026 &frm.MeasurementReport );
4027 break;
4028 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4029 nSirStatus =
4030 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4031 &frm.MeasurementReport );
4032 break;
4033 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4034 nSirStatus =
4035 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4036 &frm.MeasurementReport );
4037 break;
4038 default:
4039 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004040 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 pMeasReqFrame->measReqIE.measType );
4042 return eSIR_FAILURE;
4043 }
4044
4045 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4046
4047 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4048 if ( DOT11F_FAILED( nStatus ) )
4049 {
4050 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004051 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 nStatus );
4053 // We'll fall back on the worst case scenario:
4054 nPayload = sizeof( tDot11fMeasurementReport );
4055 }
4056 else if ( DOT11F_WARNED( nStatus ) )
4057 {
4058 limLog( pMac, LOGW, FL("There were warnings while calculating"
4059 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004060 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 }
4062
4063 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4064
4065 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4066 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4067 {
4068 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004069 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 return eSIR_FAILURE;
4071 }
4072
4073 // Paranoia:
4074 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4075
4076 // Next, we fill out the buffer descriptor:
4077 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4078 SIR_MAC_MGMT_ACTION, peer);
4079 if ( eSIR_SUCCESS != nSirStatus )
4080 {
4081 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004082 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 nSirStatus );
4084 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4085 return eSIR_FAILURE; // just allocated...
4086 }
4087
4088 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4089
4090 nCfg = 6;
4091 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4092 if ( eSIR_SUCCESS != nSirStatus )
4093 {
4094 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004095 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 nSirStatus );
4097 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4098 return eSIR_FAILURE; // just allocated...
4099 }
4100
Chet Lanctot186b5732013-03-18 10:26:30 -07004101#ifdef WLAN_FEATURE_11W
4102 if ( psessionEntry->limRmfEnabled )
4103 {
4104 pMacHdr->fc.wep = 1;
4105 }
4106#endif
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4109 sizeof(tSirMacMgmtHdr),
4110 nPayload, &nPayload );
4111 if ( DOT11F_FAILED( nStatus ) )
4112 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004113 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 nStatus );
4115 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4116 return eSIR_FAILURE; // allocated!
4117 }
4118 else if ( DOT11F_WARNED( nStatus ) )
4119 {
4120 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004121 "easurement Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 }
4123
4124 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4125 HAL_TXRX_FRM_802_11_MGMT,
4126 ANI_TXDIR_TODS,
4127 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4128 limTxComplete, pFrame, 0 );
4129 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4130 {
4131 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004132 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 nSirStatus );
4134 //Pkt will be freed up by the callback
4135 return eSIR_FAILURE; // just allocated...
4136 }
4137
4138 return eSIR_SUCCESS;
4139
4140} // End limSendMeasReportFrame.
4141
4142
4143/**
4144 * \brief Send a TPC Request Action frame
4145 *
4146 *
4147 * \param pMac Pointer to the global MAC datastructure
4148 *
4149 * \param peer MAC address to which the frame should be sent
4150 *
4151 *
4152 */
4153
4154void
4155limSendTpcRequestFrame(tpAniSirGlobal pMac,
4156 tSirMacAddr peer)
4157{
4158 tDot11fTPCRequest frm;
4159 tANI_U8 *pFrame;
4160 tSirRetStatus nSirStatus;
4161 tpSirMacMgmtHdr pMacHdr;
4162 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4163 void *pPacket;
4164 eHalStatus halstatus;
4165
4166 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4167
4168 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4169 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4170 frm.DialogToken.token = 1;
4171 frm.TPCRequest.present = 1;
4172
4173 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4174 if ( DOT11F_FAILED( nStatus ) )
4175 {
4176 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004177 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 nStatus );
4179 // We'll fall back on the worst case scenario:
4180 nPayload = sizeof( tDot11fTPCRequest );
4181 }
4182 else if ( DOT11F_WARNED( nStatus ) )
4183 {
4184 limLog( pMac, LOGW, FL("There were warnings while calculating"
4185 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004186 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 }
4188
4189 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4190
4191 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4192 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4193 {
4194 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004195 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 return;
4197 }
4198
4199 // Paranoia:
4200 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4201
4202 // Next, we fill out the buffer descriptor:
4203 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4204 SIR_MAC_MGMT_ACTION, peer);
4205 if ( eSIR_SUCCESS != nSirStatus )
4206 {
4207 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004208 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 nSirStatus );
4210 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4211 return; // just allocated...
4212 }
4213
4214 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4215
4216 nCfg = 6;
4217 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4218 if ( eSIR_SUCCESS != nSirStatus )
4219 {
4220 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004221 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 nSirStatus );
4223 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4224 return; // just allocated...
4225 }
4226
Chet Lanctot186b5732013-03-18 10:26:30 -07004227#ifdef WLAN_FEATURE_11W
4228 if ( psessionEntry->limRmfEnabled )
4229 {
4230 pMacHdr->fc.wep = 1;
4231 }
4232#endif
4233
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4235 sizeof(tSirMacMgmtHdr),
4236 nPayload, &nPayload );
4237 if ( DOT11F_FAILED( nStatus ) )
4238 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004239 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 nStatus );
4241 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4242 return; // allocated!
4243 }
4244 else if ( DOT11F_WARNED( nStatus ) )
4245 {
4246 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004247 "PC Request (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 }
4249
4250 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4251 HAL_TXRX_FRM_802_11_MGMT,
4252 ANI_TXDIR_TODS,
4253 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4254 limTxComplete, pFrame, 0 );
4255 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4256 {
4257 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004258 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 nSirStatus );
4260 //Pkt will be freed up by the callback
4261 return;
4262 }
4263
4264} // End limSendTpcRequestFrame.
4265
4266
4267/**
4268 * \brief Send a TPC Report Action frame
4269 *
4270 *
4271 * \param pMac Pointer to the global MAC datastructure
4272 *
4273 * \param pTpcReqFrame Pointer to the received TPC Request
4274 *
4275 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4276 *
4277 *
4278 */
4279
4280tSirRetStatus
4281limSendTpcReportFrame(tpAniSirGlobal pMac,
4282 tpSirMacTpcReqActionFrame pTpcReqFrame,
4283 tSirMacAddr peer)
4284{
4285 tDot11fTPCReport frm;
4286 tANI_U8 *pFrame;
4287 tSirRetStatus nSirStatus;
4288 tpSirMacMgmtHdr pMacHdr;
4289 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4290 void *pPacket;
4291 eHalStatus halstatus;
4292
4293 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4294
4295 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4296 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4297 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4298
4299 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4300 // "misplaced this function, need to replace:
4301 // txPower = halGetRateToPwrValue(pMac, staid,
4302 // pMac->lim.gLimCurrentChannelId, 0);
4303 frm.TPCReport.tx_power = 0;
4304 frm.TPCReport.link_margin = 0;
4305 frm.TPCReport.present = 1;
4306
4307 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4308 if ( DOT11F_FAILED( nStatus ) )
4309 {
4310 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004311 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 nStatus );
4313 // We'll fall back on the worst case scenario:
4314 nPayload = sizeof( tDot11fTPCReport );
4315 }
4316 else if ( DOT11F_WARNED( nStatus ) )
4317 {
4318 limLog( pMac, LOGW, FL("There were warnings while calculating"
4319 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004320 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 }
4322
4323 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4324
4325 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4326 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4327 {
4328 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004329 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 return eSIR_FAILURE;
4331 }
4332
4333 // Paranoia:
4334 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4335
4336 // Next, we fill out the buffer descriptor:
4337 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4338 SIR_MAC_MGMT_ACTION, peer);
4339 if ( eSIR_SUCCESS != nSirStatus )
4340 {
4341 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004342 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 nSirStatus );
4344 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4345 return eSIR_FAILURE; // just allocated...
4346 }
4347
4348 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4349
4350 nCfg = 6;
4351 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4352 if ( eSIR_SUCCESS != nSirStatus )
4353 {
4354 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004355 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 nSirStatus );
4357 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4358 return eSIR_FAILURE; // just allocated...
4359 }
4360
Chet Lanctot186b5732013-03-18 10:26:30 -07004361#ifdef WLAN_FEATURE_11W
4362 if ( psessionEntry->limRmfEnabled )
4363 {
4364 pMacHdr->fc.wep = 1;
4365 }
4366#endif
4367
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4369 sizeof(tSirMacMgmtHdr),
4370 nPayload, &nPayload );
4371 if ( DOT11F_FAILED( nStatus ) )
4372 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004373 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 nStatus );
4375 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4376 return eSIR_FAILURE; // allocated!
4377 }
4378 else if ( DOT11F_WARNED( nStatus ) )
4379 {
4380 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004381 "PC Report (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 }
4383
4384
4385 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4386 HAL_TXRX_FRM_802_11_MGMT,
4387 ANI_TXDIR_TODS,
4388 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4389 limTxComplete, pFrame, 0 );
4390 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4391 {
4392 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004393 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 nSirStatus );
4395 //Pkt will be freed up by the callback
4396 return eSIR_FAILURE; // just allocated...
4397 }
4398
4399 return eSIR_SUCCESS;
4400
4401} // End limSendTpcReportFrame.
4402#endif //ANI_SUPPORT_11H
4403
4404
Jeff Johnson295189b2012-06-20 16:38:30 -07004405/**
4406 * \brief Send a Channel Switch Announcement
4407 *
4408 *
4409 * \param pMac Pointer to the global MAC datastructure
4410 *
4411 * \param peer MAC address to which this frame will be sent
4412 *
4413 * \param nMode
4414 *
4415 * \param nNewChannel
4416 *
4417 * \param nCount
4418 *
4419 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4420 *
4421 *
4422 */
4423
4424tSirRetStatus
4425limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4426 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004427 tANI_U8 nMode,
4428 tANI_U8 nNewChannel,
4429 tANI_U8 nCount,
4430 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004431{
4432 tDot11fChannelSwitch frm;
4433 tANI_U8 *pFrame;
4434 tSirRetStatus nSirStatus;
4435 tpSirMacMgmtHdr pMacHdr;
Jeff Johnsone7245742012-09-05 17:12:55 -07004436 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 void *pPacket;
4438 eHalStatus halstatus;
Jeff Johnsone7245742012-09-05 17:12:55 -07004439 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004440
4441 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4442
4443 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4444 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4445 frm.ChanSwitchAnn.switchMode = nMode;
4446 frm.ChanSwitchAnn.newChannel = nNewChannel;
4447 frm.ChanSwitchAnn.switchCount = nCount;
4448 frm.ChanSwitchAnn.present = 1;
4449
4450 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4451 if ( DOT11F_FAILED( nStatus ) )
4452 {
4453 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004454 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 nStatus );
4456 // We'll fall back on the worst case scenario:
4457 nPayload = sizeof( tDot11fChannelSwitch );
4458 }
4459 else if ( DOT11F_WARNED( nStatus ) )
4460 {
4461 limLog( pMac, LOGW, FL("There were warnings while calculating"
4462 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004463 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 }
4465
4466 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4467
4468 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4469 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4470 {
4471 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004472 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 return eSIR_FAILURE;
4474 }
4475
4476 // Paranoia:
4477 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4478
4479 // Next, we fill out the buffer descriptor:
4480 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004481 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4482 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4483 palCopyMemory( pMac->hHdd,
4484 (tANI_U8 *) pMacHdr->bssId,
4485 (tANI_U8 *) psessionEntry->bssId,
4486 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 if ( eSIR_SUCCESS != nSirStatus )
4488 {
4489 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004490 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 nSirStatus );
4492 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4493 return eSIR_FAILURE; // just allocated...
4494 }
4495
Jeff Johnsone7245742012-09-05 17:12:55 -07004496#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4498
4499 nCfg = 6;
4500 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4501 if ( eSIR_SUCCESS != nSirStatus )
4502 {
4503 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004504 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 nSirStatus );
4506 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4507 return eSIR_FAILURE; // just allocated...
4508 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004509#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004510
4511#ifdef WLAN_FEATURE_11W
4512 if ( psessionEntry->limRmfEnabled )
4513 {
4514 pMacHdr->fc.wep = 1;
4515 }
4516#endif
4517
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4519 sizeof(tSirMacMgmtHdr),
4520 nPayload, &nPayload );
4521 if ( DOT11F_FAILED( nStatus ) )
4522 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004523 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 nStatus );
4525 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4526 return eSIR_FAILURE; // allocated!
4527 }
4528 else if ( DOT11F_WARNED( nStatus ) )
4529 {
4530 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004531 "hannel Switch (0x%08x).") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 }
4533
Jeff Johnsone7245742012-09-05 17:12:55 -07004534 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004535 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4536 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004537 )
4538 {
4539 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4542 HAL_TXRX_FRM_802_11_MGMT,
4543 ANI_TXDIR_TODS,
4544 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004545 limTxComplete, pFrame, txFlag );
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4547 {
4548 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004549 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 nSirStatus );
4551 //Pkt will be freed up by the callback
4552 return eSIR_FAILURE;
4553 }
4554
4555 return eSIR_SUCCESS;
4556
4557} // End limSendChannelSwitchMgmtFrame.
4558
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560
Mohit Khanna4a70d262012-09-11 16:30:12 -07004561#ifdef WLAN_FEATURE_11AC
4562tSirRetStatus
4563limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4564 tSirMacAddr peer,
4565 tANI_U8 nMode,
4566 tpPESession psessionEntry )
4567{
4568 tDot11fOperatingMode frm;
4569 tANI_U8 *pFrame;
4570 tSirRetStatus nSirStatus;
4571 tpSirMacMgmtHdr pMacHdr;
4572 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4573 void *pPacket;
4574 eHalStatus halstatus;
4575 tANI_U8 txFlag = 0;
4576
4577 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4578
4579 frm.Category.category = SIR_MAC_ACTION_VHT;
4580 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4581 frm.OperatingMode.chanWidth = nMode;
4582 frm.OperatingMode.rxNSS = 0;
4583 frm.OperatingMode.rxNSSType = 0;
4584
4585 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4586 if ( DOT11F_FAILED( nStatus ) )
4587 {
4588 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004589 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004590 nStatus );
4591 // We'll fall back on the worst case scenario:
4592 nPayload = sizeof( tDot11fOperatingMode);
4593 }
4594 else if ( DOT11F_WARNED( nStatus ) )
4595 {
4596 limLog( pMac, LOGW, FL("There were warnings while calculating"
4597 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004598 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004599 }
4600
4601 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4602
4603 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4604 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4605 {
4606 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004607 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004608 return eSIR_FAILURE;
4609 }
4610
4611 // Paranoia:
4612 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4613
4614
4615 // Next, we fill out the buffer descriptor:
4616 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4617 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4618 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4619 } else
4620 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4621 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4622 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4623 palCopyMemory( pMac->hHdd,
4624 (tANI_U8 *) pMacHdr->bssId,
4625 (tANI_U8 *) psessionEntry->bssId,
4626 sizeof( tSirMacAddr ));
4627 if ( eSIR_SUCCESS != nSirStatus )
4628 {
4629 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004630 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004631 nSirStatus );
4632 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4633 return eSIR_FAILURE; // just allocated...
4634 }
4635 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4636 sizeof(tSirMacMgmtHdr),
4637 nPayload, &nPayload );
4638 if ( DOT11F_FAILED( nStatus ) )
4639 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004640 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004641 nStatus );
4642 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4643 return eSIR_FAILURE; // allocated!
4644 }
4645 else if ( DOT11F_WARNED( nStatus ) )
4646 {
4647 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004648 " (0x%08x).") );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004649 }
4650 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004651 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4652 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004653 )
4654 {
4655 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4656 }
4657 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4658 HAL_TXRX_FRM_802_11_MGMT,
4659 ANI_TXDIR_TODS,
4660 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4661 limTxComplete, pFrame, txFlag );
4662 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4663 {
4664 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004665 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004666 nSirStatus );
4667 //Pkt will be freed up by the callback
4668 return eSIR_FAILURE;
4669 }
4670
4671 return eSIR_SUCCESS;
4672}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004673
4674/**
4675 * \brief Send a VHT Channel Switch Announcement
4676 *
4677 *
4678 * \param pMac Pointer to the global MAC datastructure
4679 *
4680 * \param peer MAC address to which this frame will be sent
4681 *
4682 * \param nChanWidth
4683 *
4684 * \param nNewChannel
4685 *
4686 *
4687 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4688 *
4689 *
4690 */
4691
4692tSirRetStatus
4693limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4694 tSirMacAddr peer,
4695 tANI_U8 nChanWidth,
4696 tANI_U8 nNewChannel,
4697 tANI_U8 ncbMode,
4698 tpPESession psessionEntry )
4699{
4700 tDot11fChannelSwitch frm;
4701 tANI_U8 *pFrame;
4702 tSirRetStatus nSirStatus;
4703 tpSirMacMgmtHdr pMacHdr;
4704 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4705 void *pPacket;
4706 eHalStatus halstatus;
4707 tANI_U8 txFlag = 0;
4708
4709 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
4710
4711
4712 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4713 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4714 frm.ChanSwitchAnn.switchMode = 1;
4715 frm.ChanSwitchAnn.newChannel = nNewChannel;
4716 frm.ChanSwitchAnn.switchCount = 1;
4717 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4718 frm.ExtChanSwitchAnn.present = 1;
4719 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4720 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4721 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4722 frm.ChanSwitchAnn.present = 1;
4723 frm.WiderBWChanSwitchAnn.present = 1;
4724
4725 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4726 if ( DOT11F_FAILED( nStatus ) )
4727 {
4728 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004729 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004730 nStatus );
4731 // We'll fall back on the worst case scenario:
4732 nPayload = sizeof( tDot11fChannelSwitch );
4733 }
4734 else if ( DOT11F_WARNED( nStatus ) )
4735 {
4736 limLog( pMac, LOGW, FL("There were warnings while calculating"
4737 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004738 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004739 }
4740
4741 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4742
4743 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4744 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4745 {
4746 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004747 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004748 return eSIR_FAILURE;
4749 }
4750 // Paranoia:
4751 palZeroMemory( pMac->hHdd, pFrame, nBytes );
4752
4753 // Next, we fill out the buffer descriptor:
4754 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4755 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4756 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4757 palCopyMemory( pMac->hHdd,
4758 (tANI_U8 *) pMacHdr->bssId,
4759 (tANI_U8 *) psessionEntry->bssId,
4760 sizeof( tSirMacAddr ));
4761 if ( eSIR_SUCCESS != nSirStatus )
4762 {
4763 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004764 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004765 nSirStatus );
4766 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4767 return eSIR_FAILURE; // just allocated...
4768 }
4769 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4770 sizeof(tSirMacMgmtHdr),
4771 nPayload, &nPayload );
4772 if ( DOT11F_FAILED( nStatus ) )
4773 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004774 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004775 nStatus );
4776 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4777 return eSIR_FAILURE; // allocated!
4778 }
4779 else if ( DOT11F_WARNED( nStatus ) )
4780 {
4781 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004782 "hannel Switch (0x%08x).") );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004783 }
4784
4785 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004786 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4787 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004788 )
4789 {
4790 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4791 }
4792 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4793 HAL_TXRX_FRM_802_11_MGMT,
4794 ANI_TXDIR_TODS,
4795 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4796 limTxComplete, pFrame, txFlag );
4797 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4798 {
4799 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004800 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004801 nSirStatus );
4802 //Pkt will be freed up by the callback
4803 return eSIR_FAILURE;
4804 }
4805
4806 return eSIR_SUCCESS;
4807
4808} // End limSendVHTChannelSwitchMgmtFrame.
4809
4810
4811
Mohit Khanna4a70d262012-09-11 16:30:12 -07004812#endif
4813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814/**
4815 * \brief Send an ADDBA Req Action Frame to peer
4816 *
4817 * \sa limSendAddBAReq
4818 *
4819 * \param pMac The global tpAniSirGlobal object
4820 *
4821 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4822 * the necessary parameters reqd by PE send the ADDBA Req Action
4823 * Frame to the peer
4824 *
4825 * \return eSIR_SUCCESS if setup completes successfully
4826 * eSIR_FAILURE is some problem is encountered
4827 */
4828tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
4829 tpLimMlmAddBAReq pMlmAddBAReq ,tpPESession psessionEntry)
4830{
4831 tDot11fAddBAReq frmAddBAReq;
4832 tANI_U8 *pAddBAReqBuffer = NULL;
4833 tpSirMacMgmtHdr pMacHdr;
4834 tANI_U32 frameLen = 0, nStatus, nPayload;
4835 tSirRetStatus statusCode;
4836 eHalStatus halStatus;
4837 void *pPacket;
4838 tANI_U8 txFlag = 0;
4839
4840 if(NULL == psessionEntry)
4841 {
4842 return eSIR_FAILURE;
4843 }
4844
4845 palZeroMemory( pMac->hHdd, (void *) &frmAddBAReq, sizeof( frmAddBAReq ));
4846
4847 // Category - 3 (BA)
4848 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
4849
4850 // Action - 0 (ADDBA Req)
4851 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
4852
4853 // FIXME - Dialog Token, generalize this...
4854 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
4855
4856 // Fill the ADDBA Parameter Set
4857 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
4858 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
4859 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
4860
4861 // BA timeout
4862 // 0 - indicates no BA timeout
4863 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
4864
4865 // BA Starting Sequence Number
4866 // Fragment number will always be zero
4867 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
4868 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4869 }
4870
4871 frmAddBAReq.BAStartingSequenceControl.ssn =
4872 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
4873
4874 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
4875
4876 if( DOT11F_FAILED( nStatus ))
4877 {
4878 limLog( pMac, LOGW,
4879 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004880 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 nStatus );
4882
4883 // We'll fall back on the worst case scenario:
4884 nPayload = sizeof( tDot11fAddBAReq );
4885 }
4886 else if( DOT11F_WARNED( nStatus ))
4887 {
4888 limLog( pMac, LOGW,
4889 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004890 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 nStatus );
4892 }
4893
4894 // Add the MGMT header to frame length
4895 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
4896
4897 // Need to allocate a buffer for ADDBA AF
4898 if( eHAL_STATUS_SUCCESS !=
4899 (halStatus = palPktAlloc( pMac->hHdd,
4900 HAL_TXRX_FRM_802_11_MGMT,
4901 (tANI_U16) frameLen,
4902 (void **) &pAddBAReqBuffer,
4903 (void **) &pPacket )))
4904 {
4905 // Log error
4906 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004907 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 frameLen,
4909 halStatus );
4910
4911 statusCode = eSIR_MEM_ALLOC_FAILED;
4912 goto returnAfterError;
4913 }
4914
4915 palZeroMemory( pMac->hHdd, (void *) pAddBAReqBuffer, frameLen );
4916
4917 // Copy necessary info to BD
4918 if( eSIR_SUCCESS !=
4919 (statusCode = limPopulateMacHeader( pMac,
4920 pAddBAReqBuffer,
4921 SIR_MAC_MGMT_FRAME,
4922 SIR_MAC_MGMT_ACTION,
4923 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
4924 goto returnAfterError;
4925
4926 // Update A3 with the BSSID
4927 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
4928
4929 #if 0
4930 cfgLen = SIR_MAC_ADDR_LENGTH;
4931 if( eSIR_SUCCESS != cfgGetStr( pMac,
4932 WNI_CFG_BSSID,
4933 (tANI_U8 *) pMacHdr->bssId,
4934 &cfgLen ))
4935 {
4936 limLog( pMac, LOGP,
4937 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004938 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004939
4940 // FIXME - Need to convert to tSirRetStatus
4941 statusCode = eSIR_FAILURE;
4942 goto returnAfterError;
4943 }
4944 #endif//TO SUPPORT BT-AMP
4945 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4946
Chet Lanctot186b5732013-03-18 10:26:30 -07004947#ifdef WLAN_FEATURE_11W
4948 if ( psessionEntry->limRmfEnabled )
4949 {
4950 pMacHdr->fc.wep = 1;
4951 }
4952#endif
4953
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 // Now, we're ready to "pack" the frames
4955 nStatus = dot11fPackAddBAReq( pMac,
4956 &frmAddBAReq,
4957 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
4958 nPayload,
4959 &nPayload );
4960
4961 if( DOT11F_FAILED( nStatus ))
4962 {
4963 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004964 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 nStatus );
4966
4967 // FIXME - Need to convert to tSirRetStatus
4968 statusCode = eSIR_FAILURE;
4969 goto returnAfterError;
4970 }
4971 else if( DOT11F_WARNED( nStatus ))
4972 {
4973 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004974 FL( "There were warnings while packing an ADDBA Req (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 }
4976
4977 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004978 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
4980
4981 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4983 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 )
4985 {
4986 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4987 }
4988
4989 if( eHAL_STATUS_SUCCESS !=
4990 (halStatus = halTxFrame( pMac,
4991 pPacket,
4992 (tANI_U16) frameLen,
4993 HAL_TXRX_FRM_802_11_MGMT,
4994 ANI_TXDIR_TODS,
4995 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4996 limTxComplete,
4997 pAddBAReqBuffer, txFlag )))
4998 {
4999 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005000 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 halStatus );
5002
5003 // FIXME - Need to convert eHalStatus to tSirRetStatus
5004 statusCode = eSIR_FAILURE;
5005 //Pkt will be freed up by the callback
5006 return statusCode;
5007 }
5008 else
5009 return eSIR_SUCCESS;
5010
5011returnAfterError:
5012
5013 // Release buffer, if allocated
5014 if( NULL != pAddBAReqBuffer )
5015 palPktFree( pMac->hHdd,
5016 HAL_TXRX_FRM_802_11_MGMT,
5017 (void *) pAddBAReqBuffer,
5018 (void *) pPacket );
5019
5020 return statusCode;
5021}
5022
5023/**
5024 * \brief Send an ADDBA Rsp Action Frame to peer
5025 *
5026 * \sa limSendAddBARsp
5027 *
5028 * \param pMac The global tpAniSirGlobal object
5029 *
5030 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5031 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5032 * Frame to the peer
5033 *
5034 * \return eSIR_SUCCESS if setup completes successfully
5035 * eSIR_FAILURE is some problem is encountered
5036 */
5037tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5038 tpLimMlmAddBARsp pMlmAddBARsp,
5039 tpPESession psessionEntry)
5040{
5041 tDot11fAddBARsp frmAddBARsp;
5042 tANI_U8 *pAddBARspBuffer = NULL;
5043 tpSirMacMgmtHdr pMacHdr;
5044 tANI_U32 frameLen = 0, nStatus, nPayload;
5045 tSirRetStatus statusCode;
5046 eHalStatus halStatus;
5047 void *pPacket;
5048 tANI_U8 txFlag = 0;
5049
5050 if(NULL == psessionEntry)
5051 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005052 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 return eSIR_FAILURE;
5054 }
5055
5056 palZeroMemory( pMac->hHdd, (void *) &frmAddBARsp, sizeof( frmAddBARsp ));
5057
5058 // Category - 3 (BA)
5059 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5060 // Action - 1 (ADDBA Rsp)
5061 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5062
5063 // Should be same as the one we received in the ADDBA Req
5064 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5065
5066 // ADDBA Req status
5067 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5068
5069 // Fill the ADDBA Parameter Set as provided by caller
5070 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5071 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5072 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
5073
5074 // BA timeout
5075 // 0 - indicates no BA timeout
5076 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5077
5078 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5079
5080 if( DOT11F_FAILED( nStatus ))
5081 {
5082 limLog( pMac, LOGW,
5083 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005084 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 nStatus );
5086
5087 // We'll fall back on the worst case scenario:
5088 nPayload = sizeof( tDot11fAddBARsp );
5089 }
5090 else if( DOT11F_WARNED( nStatus ))
5091 {
5092 limLog( pMac, LOGW,
5093 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005094 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 nStatus );
5096 }
5097
5098 // Need to allocate a buffer for ADDBA AF
5099 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5100
5101 // Allocate shared memory
5102 if( eHAL_STATUS_SUCCESS !=
5103 (halStatus = palPktAlloc( pMac->hHdd,
5104 HAL_TXRX_FRM_802_11_MGMT,
5105 (tANI_U16) frameLen,
5106 (void **) &pAddBARspBuffer,
5107 (void **) &pPacket )))
5108 {
5109 // Log error
5110 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005111 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 frameLen,
5113 halStatus );
5114
5115 statusCode = eSIR_MEM_ALLOC_FAILED;
5116 goto returnAfterError;
5117 }
5118
5119 palZeroMemory( pMac->hHdd, (void *) pAddBARspBuffer, frameLen );
5120
5121 // Copy necessary info to BD
5122 if( eSIR_SUCCESS !=
5123 (statusCode = limPopulateMacHeader( pMac,
5124 pAddBARspBuffer,
5125 SIR_MAC_MGMT_FRAME,
5126 SIR_MAC_MGMT_ACTION,
5127 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5128 goto returnAfterError;
5129
5130 // Update A3 with the BSSID
5131
5132 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5133
5134 #if 0
5135 cfgLen = SIR_MAC_ADDR_LENGTH;
5136 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5137 WNI_CFG_BSSID,
5138 (tANI_U8 *) pMacHdr->bssId,
5139 &cfgLen ))
5140 {
5141 limLog( pMac, LOGP,
5142 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005143 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005144
5145 // FIXME - Need to convert to tSirRetStatus
5146 statusCode = eSIR_FAILURE;
5147 goto returnAfterError;
5148 }
5149 #endif // TO SUPPORT BT-AMP
5150 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5151
Chet Lanctot186b5732013-03-18 10:26:30 -07005152#ifdef WLAN_FEATURE_11W
5153 if ( psessionEntry->limRmfEnabled )
5154 {
5155 pMacHdr->fc.wep = 1;
5156 }
5157#endif
5158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 // Now, we're ready to "pack" the frames
5160 nStatus = dot11fPackAddBARsp( pMac,
5161 &frmAddBARsp,
5162 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5163 nPayload,
5164 &nPayload );
5165
5166 if( DOT11F_FAILED( nStatus ))
5167 {
5168 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005169 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 nStatus );
5171
5172 // FIXME - Need to convert to tSirRetStatus
5173 statusCode = eSIR_FAILURE;
5174 goto returnAfterError;
5175 }
5176 else if( DOT11F_WARNED( nStatus ))
5177 {
5178 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005179 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 }
5181
5182 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005183 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5185
5186 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5188 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 )
5190 {
5191 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5192 }
5193
5194 if( eHAL_STATUS_SUCCESS !=
5195 (halStatus = halTxFrame( pMac,
5196 pPacket,
5197 (tANI_U16) frameLen,
5198 HAL_TXRX_FRM_802_11_MGMT,
5199 ANI_TXDIR_TODS,
5200 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5201 limTxComplete,
5202 pAddBARspBuffer, txFlag )))
5203 {
5204 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005205 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 halStatus );
5207
5208 // FIXME - HAL error codes are different from PE error
5209 // codes!! And, this routine is returning tSirRetStatus
5210 statusCode = eSIR_FAILURE;
5211 //Pkt will be freed up by the callback
5212 return statusCode;
5213 }
5214 else
5215 return eSIR_SUCCESS;
5216
5217 returnAfterError:
5218
5219 // Release buffer, if allocated
5220 if( NULL != pAddBARspBuffer )
5221 palPktFree( pMac->hHdd,
5222 HAL_TXRX_FRM_802_11_MGMT,
5223 (void *) pAddBARspBuffer,
5224 (void *) pPacket );
5225
5226 return statusCode;
5227}
5228
5229/**
5230 * \brief Send a DELBA Indication Action Frame to peer
5231 *
5232 * \sa limSendDelBAInd
5233 *
5234 * \param pMac The global tpAniSirGlobal object
5235 *
5236 * \param peerMacAddr MAC Address of peer
5237 *
5238 * \param reasonCode Reason for the DELBA notification
5239 *
5240 * \param pBAParameterSet The DELBA Parameter Set.
5241 * This identifies the TID for which the BA session is
5242 * being deleted.
5243 *
5244 * \return eSIR_SUCCESS if setup completes successfully
5245 * eSIR_FAILURE is some problem is encountered
5246 */
5247tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5248 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5249{
5250 tDot11fDelBAInd frmDelBAInd;
5251 tANI_U8 *pDelBAIndBuffer = NULL;
5252 //tANI_U32 val;
5253 tpSirMacMgmtHdr pMacHdr;
5254 tANI_U32 frameLen = 0, nStatus, nPayload;
5255 tSirRetStatus statusCode;
5256 eHalStatus halStatus;
5257 void *pPacket;
5258 tANI_U8 txFlag = 0;
5259
5260 if(NULL == psessionEntry)
5261 {
5262 return eSIR_FAILURE;
5263 }
5264
5265 palZeroMemory( pMac->hHdd, (void *) &frmDelBAInd, sizeof( frmDelBAInd ));
5266
5267 // Category - 3 (BA)
5268 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5269 // Action - 2 (DELBA)
5270 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5271
5272 // Fill the DELBA Parameter Set as provided by caller
5273 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5274 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5275
5276 // BA Starting Sequence Number
5277 // Fragment number will always be zero
5278 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5279
5280 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5281
5282 if( DOT11F_FAILED( nStatus ))
5283 {
5284 limLog( pMac, LOGW,
5285 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005286 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 nStatus );
5288
5289 // We'll fall back on the worst case scenario:
5290 nPayload = sizeof( tDot11fDelBAInd );
5291 }
5292 else if( DOT11F_WARNED( nStatus ))
5293 {
5294 limLog( pMac, LOGW,
5295 FL( "There were warnings while calculating"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005296 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 nStatus );
5298 }
5299
5300 // Add the MGMT header to frame length
5301 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5302
5303 // Allocate shared memory
5304 if( eHAL_STATUS_SUCCESS !=
5305 (halStatus = palPktAlloc( pMac->hHdd,
5306 HAL_TXRX_FRM_802_11_MGMT,
5307 (tANI_U16) frameLen,
5308 (void **) &pDelBAIndBuffer,
5309 (void **) &pPacket )))
5310 {
5311 // Log error
5312 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005313 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 frameLen,
5315 halStatus );
5316
5317 statusCode = eSIR_MEM_ALLOC_FAILED;
5318 goto returnAfterError;
5319 }
5320
5321 palZeroMemory( pMac->hHdd, (void *) pDelBAIndBuffer, frameLen );
5322
5323 // Copy necessary info to BD
5324 if( eSIR_SUCCESS !=
5325 (statusCode = limPopulateMacHeader( pMac,
5326 pDelBAIndBuffer,
5327 SIR_MAC_MGMT_FRAME,
5328 SIR_MAC_MGMT_ACTION,
5329 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5330 goto returnAfterError;
5331
5332 // Update A3 with the BSSID
5333 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5334
5335 #if 0
5336 cfgLen = SIR_MAC_ADDR_LENGTH;
5337 if( eSIR_SUCCESS != cfgGetStr( pMac,
5338 WNI_CFG_BSSID,
5339 (tANI_U8 *) pMacHdr->bssId,
5340 &cfgLen ))
5341 {
5342 limLog( pMac, LOGP,
5343 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005344 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005345
5346 // FIXME - Need to convert to tSirRetStatus
5347 statusCode = eSIR_FAILURE;
5348 goto returnAfterError;
5349 }
5350 #endif //TO SUPPORT BT-AMP
5351 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5352
Chet Lanctot186b5732013-03-18 10:26:30 -07005353#ifdef WLAN_FEATURE_11W
5354 if ( psessionEntry->limRmfEnabled )
5355 {
5356 pMacHdr->fc.wep = 1;
5357 }
5358#endif
5359
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 // Now, we're ready to "pack" the frames
5361 nStatus = dot11fPackDelBAInd( pMac,
5362 &frmDelBAInd,
5363 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5364 nPayload,
5365 &nPayload );
5366
5367 if( DOT11F_FAILED( nStatus ))
5368 {
5369 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005370 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 nStatus );
5372
5373 // FIXME - Need to convert to tSirRetStatus
5374 statusCode = eSIR_FAILURE;
5375 goto returnAfterError;
5376 }
5377 else if( DOT11F_WARNED( nStatus ))
5378 {
5379 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005380 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 }
5382
5383 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005384 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5386
5387 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5389 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 )
5391 {
5392 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5393 }
5394
5395 if( eHAL_STATUS_SUCCESS !=
5396 (halStatus = halTxFrame( pMac,
5397 pPacket,
5398 (tANI_U16) frameLen,
5399 HAL_TXRX_FRM_802_11_MGMT,
5400 ANI_TXDIR_TODS,
5401 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5402 limTxComplete,
5403 pDelBAIndBuffer, txFlag )))
5404 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005405 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 statusCode = eSIR_FAILURE;
5407 //Pkt will be freed up by the callback
5408 return statusCode;
5409 }
5410 else
5411 return eSIR_SUCCESS;
5412
5413 returnAfterError:
5414
5415 // Release buffer, if allocated
5416 if( NULL != pDelBAIndBuffer )
5417 palPktFree( pMac->hHdd,
5418 HAL_TXRX_FRM_802_11_MGMT,
5419 (void *) pDelBAIndBuffer,
5420 (void *) pPacket );
5421
5422 return statusCode;
5423}
5424
5425#if defined WLAN_FEATURE_VOWIFI
5426
5427/**
5428 * \brief Send a Neighbor Report Request Action frame
5429 *
5430 *
5431 * \param pMac Pointer to the global MAC structure
5432 *
5433 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5434 *
5435 * \param peer mac address of peer station.
5436 *
5437 * \param psessionEntry address of session entry.
5438 *
5439 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5440 *
5441 *
5442 */
5443
5444tSirRetStatus
5445limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5446 tpSirMacNeighborReportReq pNeighborReq,
5447 tSirMacAddr peer,
5448 tpPESession psessionEntry
5449 )
5450{
5451 tSirRetStatus statusCode = eSIR_SUCCESS;
5452 tDot11fNeighborReportRequest frm;
5453 tANI_U8 *pFrame;
5454 tpSirMacMgmtHdr pMacHdr;
5455 tANI_U32 nBytes, nPayload, nStatus;
5456 void *pPacket;
5457 eHalStatus halstatus;
5458 tANI_U8 txFlag = 0;
5459
5460 if ( psessionEntry == NULL )
5461 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005462 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 return eSIR_FAILURE;
5464 }
5465 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5466
5467 frm.Category.category = SIR_MAC_ACTION_RRM;
5468 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5469 frm.DialogToken.token = pNeighborReq->dialogToken;
5470
5471
5472 if( pNeighborReq->ssid_present )
5473 {
5474 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5475 }
5476
5477 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5478 if ( DOT11F_FAILED( nStatus ) )
5479 {
5480 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005481 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 nStatus );
5483 // We'll fall back on the worst case scenario:
5484 nPayload = sizeof( tDot11fNeighborReportRequest );
5485 }
5486 else if ( DOT11F_WARNED( nStatus ) )
5487 {
5488 limLog( pMac, LOGW, FL("There were warnings while calculating"
5489 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005490 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 }
5492
5493 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5494
5495 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5496 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5497 {
5498 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005499 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 return eSIR_FAILURE;
5501 }
5502
5503 // Paranoia:
5504 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5505
5506 // Copy necessary info to BD
5507 if( eSIR_SUCCESS !=
5508 (statusCode = limPopulateMacHeader( pMac,
5509 pFrame,
5510 SIR_MAC_MGMT_FRAME,
5511 SIR_MAC_MGMT_ACTION,
5512 peer, psessionEntry->selfMacAddr)))
5513 goto returnAfterError;
5514
5515 // Update A3 with the BSSID
5516 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5517
5518 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5519
Chet Lanctot186b5732013-03-18 10:26:30 -07005520#ifdef WLAN_FEATURE_11W
5521 if ( psessionEntry->limRmfEnabled )
5522 {
5523 pMacHdr->fc.wep = 1;
5524 }
5525#endif
5526
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 // Now, we're ready to "pack" the frames
5528 nStatus = dot11fPackNeighborReportRequest( pMac,
5529 &frm,
5530 pFrame + sizeof( tSirMacMgmtHdr ),
5531 nPayload,
5532 &nPayload );
5533
5534 if( DOT11F_FAILED( nStatus ))
5535 {
5536 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005537 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 nStatus );
5539
5540 // FIXME - Need to convert to tSirRetStatus
5541 statusCode = eSIR_FAILURE;
5542 goto returnAfterError;
5543 }
5544 else if( DOT11F_WARNED( nStatus ))
5545 {
5546 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005547 FL( "There were warnings while packing Neighbor Report Request (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 }
5549
5550 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005551 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 limPrintMacAddr( pMac, peer, LOGW );
5553
5554 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5556 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 )
5558 {
5559 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5560 }
5561
5562 if( eHAL_STATUS_SUCCESS !=
5563 (halstatus = halTxFrame( pMac,
5564 pPacket,
5565 (tANI_U16) nBytes,
5566 HAL_TXRX_FRM_802_11_MGMT,
5567 ANI_TXDIR_TODS,
5568 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5569 limTxComplete,
5570 pFrame, txFlag )))
5571 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005572 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 statusCode = eSIR_FAILURE;
5574 //Pkt will be freed up by the callback
5575 return statusCode;
5576 }
5577 else
5578 return eSIR_SUCCESS;
5579
5580returnAfterError:
5581 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5582
5583 return statusCode;
5584} // End limSendNeighborReportRequestFrame.
5585
5586/**
5587 * \brief Send a Link Report Action frame
5588 *
5589 *
5590 * \param pMac Pointer to the global MAC structure
5591 *
5592 * \param pLinkReport Address of a tSirMacLinkReport
5593 *
5594 * \param peer mac address of peer station.
5595 *
5596 * \param psessionEntry address of session entry.
5597 *
5598 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5599 *
5600 *
5601 */
5602
5603tSirRetStatus
5604limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5605 tpSirMacLinkReport pLinkReport,
5606 tSirMacAddr peer,
5607 tpPESession psessionEntry
5608 )
5609{
5610 tSirRetStatus statusCode = eSIR_SUCCESS;
5611 tDot11fLinkMeasurementReport frm;
5612 tANI_U8 *pFrame;
5613 tpSirMacMgmtHdr pMacHdr;
5614 tANI_U32 nBytes, nPayload, nStatus;
5615 void *pPacket;
5616 eHalStatus halstatus;
5617 tANI_U8 txFlag = 0;
5618
5619
5620 if ( psessionEntry == NULL )
5621 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005622 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 return eSIR_FAILURE;
5624 }
5625
5626 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
5627
5628 frm.Category.category = SIR_MAC_ACTION_RRM;
5629 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5630 frm.DialogToken.token = pLinkReport->dialogToken;
5631
5632
5633 //IEEE Std. 802.11 7.3.2.18. for the report element.
5634 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5635 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5636 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5637 //such case this way than changing the frame parser.
5638 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5639 frm.TPCEleLen.TPCLen = 2;
5640 frm.TxPower.txPower = pLinkReport->txPower;
5641 frm.LinkMargin.linkMargin = 0;
5642
5643 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5644 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5645 frm.RCPI.rcpi = pLinkReport->rcpi;
5646 frm.RSNI.rsni = pLinkReport->rsni;
5647
5648 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5649 if ( DOT11F_FAILED( nStatus ) )
5650 {
5651 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005652 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 nStatus );
5654 // We'll fall back on the worst case scenario:
5655 nPayload = sizeof( tDot11fLinkMeasurementReport );
5656 }
5657 else if ( DOT11F_WARNED( nStatus ) )
5658 {
5659 limLog( pMac, LOGW, FL("There were warnings while calculating"
5660 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005661 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 }
5663
5664 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5665
5666 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5667 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5668 {
5669 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005670 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 return eSIR_FAILURE;
5672 }
5673
5674 // Paranoia:
5675 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5676
5677 // Copy necessary info to BD
5678 if( eSIR_SUCCESS !=
5679 (statusCode = limPopulateMacHeader( pMac,
5680 pFrame,
5681 SIR_MAC_MGMT_FRAME,
5682 SIR_MAC_MGMT_ACTION,
5683 peer, psessionEntry->selfMacAddr)))
5684 goto returnAfterError;
5685
5686 // Update A3 with the BSSID
5687 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5688
5689 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5690
Chet Lanctot186b5732013-03-18 10:26:30 -07005691#ifdef WLAN_FEATURE_11W
5692 if ( psessionEntry->limRmfEnabled )
5693 {
5694 pMacHdr->fc.wep = 1;
5695 }
5696#endif
5697
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 // Now, we're ready to "pack" the frames
5699 nStatus = dot11fPackLinkMeasurementReport( pMac,
5700 &frm,
5701 pFrame + sizeof( tSirMacMgmtHdr ),
5702 nPayload,
5703 &nPayload );
5704
5705 if( DOT11F_FAILED( nStatus ))
5706 {
5707 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005708 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 nStatus );
5710
5711 // FIXME - Need to convert to tSirRetStatus
5712 statusCode = eSIR_FAILURE;
5713 goto returnAfterError;
5714 }
5715 else if( DOT11F_WARNED( nStatus ))
5716 {
5717 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005718 FL( "There were warnings while packing Link Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 }
5720
5721 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005722 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 limPrintMacAddr( pMac, peer, LOGW );
5724
5725 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5727 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 )
5729 {
5730 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5731 }
5732
5733 if( eHAL_STATUS_SUCCESS !=
5734 (halstatus = halTxFrame( pMac,
5735 pPacket,
5736 (tANI_U16) nBytes,
5737 HAL_TXRX_FRM_802_11_MGMT,
5738 ANI_TXDIR_TODS,
5739 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5740 limTxComplete,
5741 pFrame, txFlag )))
5742 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005743 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 statusCode = eSIR_FAILURE;
5745 //Pkt will be freed up by the callback
5746 return statusCode;
5747 }
5748 else
5749 return eSIR_SUCCESS;
5750
5751returnAfterError:
5752 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5753
5754 return statusCode;
5755} // End limSendLinkReportActionFrame.
5756
5757/**
5758 * \brief Send a Beacon Report Action frame
5759 *
5760 *
5761 * \param pMac Pointer to the global MAC structure
5762 *
5763 * \param dialog_token dialog token to be used in the action frame.
5764 *
5765 * \param num_report number of reports in pRRMReport.
5766 *
5767 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5768 *
5769 * \param peer mac address of peer station.
5770 *
5771 * \param psessionEntry address of session entry.
5772 *
5773 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5774 *
5775 *
5776 */
5777
5778tSirRetStatus
5779limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5780 tANI_U8 dialog_token,
5781 tANI_U8 num_report,
5782 tpSirMacRadioMeasureReport pRRMReport,
5783 tSirMacAddr peer,
5784 tpPESession psessionEntry
5785 )
5786{
5787 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 tANI_U8 *pFrame;
5789 tpSirMacMgmtHdr pMacHdr;
5790 tANI_U32 nBytes, nPayload, nStatus;
5791 void *pPacket;
5792 eHalStatus halstatus;
5793 tANI_U8 i;
5794 tANI_U8 txFlag = 0;
5795
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005796 tDot11fRadioMeasurementReport *frm =
5797 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5798 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005799 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005800 return eSIR_FAILURE;
5801 }
5802
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 if ( psessionEntry == NULL )
5804 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005805 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005806 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 return eSIR_FAILURE;
5808 }
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005809 palZeroMemory( pMac->hHdd, ( tANI_U8* )frm, sizeof( *frm ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005810
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005811 frm->Category.category = SIR_MAC_ACTION_RRM;
5812 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
5813 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07005814
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005815 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 -07005816
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005817 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005819 frm->MeasurementReport[i].type = pRRMReport[i].type;
5820 frm->MeasurementReport[i].token = pRRMReport[i].token;
5821 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 switch( pRRMReport[i].type )
5823 {
5824 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005825 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
5826 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5827 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
5828 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 break;
5830 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05305831 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
5832 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005833 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 break;
5835 }
5836 }
5837
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005838 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 if ( DOT11F_FAILED( nStatus ) )
5840 {
5841 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005842 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 nStatus );
5844 // We'll fall back on the worst case scenario:
5845 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005846 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 return eSIR_FAILURE;
5848 }
5849 else if ( DOT11F_WARNED( nStatus ) )
5850 {
5851 limLog( pMac, LOGW, FL("There were warnings while calculating"
5852 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005853 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 }
5855
5856 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5857
5858 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5859 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5860 {
5861 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005862 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005863 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 return eSIR_FAILURE;
5865 }
5866
5867 // Paranoia:
5868 palZeroMemory( pMac->hHdd, pFrame, nBytes );
5869
5870 // Copy necessary info to BD
5871 if( eSIR_SUCCESS !=
5872 (statusCode = limPopulateMacHeader( pMac,
5873 pFrame,
5874 SIR_MAC_MGMT_FRAME,
5875 SIR_MAC_MGMT_ACTION,
5876 peer, psessionEntry->selfMacAddr)))
5877 goto returnAfterError;
5878
5879 // Update A3 with the BSSID
5880 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5881
5882 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5883
Chet Lanctot186b5732013-03-18 10:26:30 -07005884#ifdef WLAN_FEATURE_11W
5885 if ( psessionEntry->limRmfEnabled )
5886 {
5887 pMacHdr->fc.wep = 1;
5888 }
5889#endif
5890
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 // Now, we're ready to "pack" the frames
5892 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005893 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 pFrame + sizeof( tSirMacMgmtHdr ),
5895 nPayload,
5896 &nPayload );
5897
5898 if( DOT11F_FAILED( nStatus ))
5899 {
5900 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005901 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 nStatus );
5903
5904 // FIXME - Need to convert to tSirRetStatus
5905 statusCode = eSIR_FAILURE;
5906 goto returnAfterError;
5907 }
5908 else if( DOT11F_WARNED( nStatus ))
5909 {
5910 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005911 FL( "There were warnings while packing Radio Measure Report (0x%08x)." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 }
5913
5914 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005915 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 limPrintMacAddr( pMac, peer, LOGW );
5917
5918 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5920 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 )
5922 {
5923 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5924 }
5925
5926 if( eHAL_STATUS_SUCCESS !=
5927 (halstatus = halTxFrame( pMac,
5928 pPacket,
5929 (tANI_U16) nBytes,
5930 HAL_TXRX_FRM_802_11_MGMT,
5931 ANI_TXDIR_TODS,
5932 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5933 limTxComplete,
5934 pFrame, txFlag )))
5935 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005936 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 statusCode = eSIR_FAILURE;
5938 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005939 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 return statusCode;
5941 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005942 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005943 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07005945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005946
5947returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005948 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 return statusCode;
5951} // End limSendBeaconReportActionFrame.
5952
5953#endif
5954
5955#ifdef WLAN_FEATURE_11W
5956/**
5957 * \brief Send SA query response action frame to peer
5958 *
5959 * \sa limSendSaQueryResponseFrame
5960 *
5961 *
5962 * \param pMac The global tpAniSirGlobal object
5963 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005964 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 *
Chet Lanctot186b5732013-03-18 10:26:30 -07005966 * \param peer The Mac address of the AP to which this action frame is addressed
5967 *
5968 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 *
5970 * \return eSIR_SUCCESS if setup completes successfully
5971 * eSIR_FAILURE is some problem is encountered
5972 */
5973
Chet Lanctot186b5732013-03-18 10:26:30 -07005974tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005975tSirMacAddr peer,tpPESession psessionEntry)
5976{
5977
Chet Lanctot186b5732013-03-18 10:26:30 -07005978 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 tANI_U8 *pFrame;
5980 tSirRetStatus nSirStatus;
5981 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07005982 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 void *pPacket;
5984 eHalStatus halstatus;
Chet Lanctot186b5732013-03-18 10:26:30 -07005985 tANI_U8 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986
5987 palZeroMemory( pMac->hHdd, ( tANI_U8* )&frm, sizeof( frm ) );
Chet Lanctot186b5732013-03-18 10:26:30 -07005988 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
5989 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 action: 0 --> SA query request action frame
5991 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07005992 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
5993 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07005995 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005996
Chet Lanctot186b5732013-03-18 10:26:30 -07005997 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
5998 if ( DOT11F_FAILED( nStatus ) )
5999 {
6000 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6001 "or a SA Query Response (0x%08x)."),
6002 nStatus );
6003 // We'll fall back on the worst case scenario:
6004 nPayload = sizeof( tDot11fSaQueryRsp );
6005 }
6006 else if ( DOT11F_WARNED( nStatus ) )
6007 {
6008 limLog( pMac, LOGW, FL("There were warnings while calculating"
6009 "the packed size for an SA Query Response"
6010 " (0x%08x)."), nStatus );
6011 }
6012
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6014 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6015 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6016 {
6017 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006018 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 return eSIR_FAILURE;
6020 }
6021
6022 // Paranoia:
6023 palZeroMemory( pMac->hHdd, pFrame, nBytes );
6024
Chet Lanctot186b5732013-03-18 10:26:30 -07006025 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006026 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006027 pFrame,
6028 SIR_MAC_MGMT_FRAME,
6029 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006030 peer, psessionEntry->selfMacAddr );
6031 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006032 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033
Chet Lanctot186b5732013-03-18 10:26:30 -07006034 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6036
Chet Lanctot186b5732013-03-18 10:26:30 -07006037 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006038
Chet Lanctot186b5732013-03-18 10:26:30 -07006039 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6040 // in the FC
6041 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006043 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 }
6045
Chet Lanctot186b5732013-03-18 10:26:30 -07006046 // Pack 11w SA query response frame
6047 nStatus = dot11fPackSaQueryRsp( pMac,
6048 &frm,
6049 pFrame + sizeof( tSirMacMgmtHdr ),
6050 nPayload,
6051 &nPayload );
6052
6053 if ( DOT11F_FAILED( nStatus ))
6054 {
6055 limLog( pMac, LOGE,
6056 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6057 nStatus );
6058 // FIXME - Need to convert to tSirRetStatus
6059 nSirStatus = eSIR_FAILURE;
6060 goto returnAfterError;
6061 }
6062 else if ( DOT11F_WARNED( nStatus ))
6063 {
6064 limLog( pMac, LOGW,
6065 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6066 nStatus);
6067 }
6068
6069 limLog( pMac, LOG1,
6070 FL( "Sending a SA Query Response to " ));
6071 limPrintMacAddr( pMac, peer, LOGW );
6072
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006073 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006074#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006075 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6076 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006077#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006078 )
6079 {
6080 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6081 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006082
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006083 halstatus = halTxFrame( pMac,
6084 pPacket,
6085 (tANI_U16) nBytes,
6086 HAL_TXRX_FRM_802_11_MGMT,
6087 ANI_TXDIR_TODS,
6088 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6089 limTxComplete,
6090 pFrame, txFlag );
6091 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006092 {
6093 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6094 nSirStatus = eSIR_FAILURE;
6095 //Pkt will be freed up by the callback
6096 return nSirStatus;
6097 }
6098 else {
6099 return eSIR_SUCCESS;
6100 }
6101
6102returnAfterError:
6103 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6104 return nSirStatus;
6105} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006106#endif